fix(color): Improve layout of Module / RX version pop up (#2325)
* initial commit for Module / RX version pop up - fixes #2320 * got rid of "no information" module names. Module names are now identical to the settings internal and external RF dialog, expect PXX2 which sets name depending on hw info. * cosmetics * hide int/ext status when there is no status to report * fix: Also unhide PXX2 module status if set * feat: Move NV14 fw version to module info screen
This commit is contained in:
@@ -41,22 +41,29 @@ char *getVersion(char *str, PXX2Version version)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(2),
|
static const lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(2), LV_GRID_TEMPLATE_LAST};
|
||||||
LV_GRID_TEMPLATE_LAST};
|
|
||||||
static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST};
|
static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST};
|
||||||
|
|
||||||
class VersionDialog : public Dialog
|
class VersionDialog : public Dialog
|
||||||
{
|
{
|
||||||
|
Window* int_module_name_w;
|
||||||
StaticText* int_name;
|
StaticText* int_name;
|
||||||
|
Window* int_module_status_w;
|
||||||
StaticText* int_status;
|
StaticText* int_status;
|
||||||
Window* int_rx_line;
|
|
||||||
|
Window* int_rx_name_w;
|
||||||
StaticText* int_rx_name;
|
StaticText* int_rx_name;
|
||||||
|
Window* int_rx_status_w;
|
||||||
StaticText* int_rx_status;
|
StaticText* int_rx_status;
|
||||||
|
|
||||||
|
Window* ext_module_name_w;
|
||||||
StaticText* ext_name;
|
StaticText* ext_name;
|
||||||
|
Window* ext_module_status_w;
|
||||||
StaticText* ext_status;
|
StaticText* ext_status;
|
||||||
Window* ext_rx_line;
|
|
||||||
|
Window* ext_rx_name_w;
|
||||||
StaticText* ext_rx_name;
|
StaticText* ext_rx_name;
|
||||||
|
Window* ext_rx_status_w;
|
||||||
StaticText* ext_rx_status;
|
StaticText* ext_rx_status;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -82,36 +89,64 @@ class VersionDialog : public Dialog
|
|||||||
|
|
||||||
setCloseWhenClickOutside(true);
|
setCloseWhenClickOutside(true);
|
||||||
|
|
||||||
|
// define grid layout
|
||||||
|
FlexGridLayout grid(col_dsc, row_dsc);
|
||||||
|
|
||||||
|
// define form
|
||||||
auto form = &content->form;
|
auto form = &content->form;
|
||||||
form->setFlexLayout();
|
form->setFlexLayout();
|
||||||
|
|
||||||
FlexGridLayout grid(col_dsc, row_dsc);
|
// headline "Internal module"
|
||||||
|
|
||||||
new StaticText(form, rect_t{}, STR_INTERNAL_MODULE, 0, COLOR_THEME_PRIMARY1);
|
new StaticText(form, rect_t{}, STR_INTERNAL_MODULE, 0, COLOR_THEME_PRIMARY1);
|
||||||
|
|
||||||
auto line = form->newLine(&grid);
|
// Internal module name
|
||||||
new StaticText(line, rect_t{}, STR_MODULE, 0, COLOR_THEME_PRIMARY1);
|
int_module_name_w = form->newLine(&grid);
|
||||||
int_name = new StaticText(line, rect_t{}, "", 0, COLOR_THEME_PRIMARY1);
|
new StaticText(int_module_name_w, rect_t{}, STR_MODULE, 0, COLOR_THEME_PRIMARY1);
|
||||||
int_status = new StaticText(line, rect_t{}, "", 0, COLOR_THEME_PRIMARY1);
|
int_name = new StaticText(int_module_name_w, rect_t{}, "", 0, COLOR_THEME_PRIMARY1);
|
||||||
|
|
||||||
int_rx_line = form->newLine(&grid);
|
// internal module status
|
||||||
new StaticText(int_rx_line, rect_t{}, STR_RECEIVER, 0, COLOR_THEME_PRIMARY1);
|
int_module_status_w = form->newLine(&grid);
|
||||||
int_rx_name = new StaticText(int_rx_line, rect_t{}, "", 0, COLOR_THEME_PRIMARY1);
|
new StaticText(int_module_status_w, rect_t{}, STR_STATUS, 0, COLOR_THEME_PRIMARY1);
|
||||||
int_rx_status = new StaticText(int_rx_line, rect_t{}, "", 0, COLOR_THEME_PRIMARY1);
|
int_status = new StaticText(int_module_status_w, rect_t{}, "", 0, COLOR_THEME_PRIMARY1);
|
||||||
lv_obj_add_flag(int_rx_line->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
lv_obj_add_flag(int_module_status_w->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||||
|
|
||||||
|
// internal receiver name
|
||||||
|
int_rx_name_w = form->newLine(&grid);
|
||||||
|
new StaticText(int_rx_name_w, rect_t{}, STR_RECEIVER, 0, COLOR_THEME_PRIMARY1);
|
||||||
|
int_rx_name = new StaticText(int_rx_name_w, rect_t{}, "", 0, COLOR_THEME_PRIMARY1);
|
||||||
|
lv_obj_add_flag(int_rx_name_w->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||||
|
|
||||||
|
// internal reciever status
|
||||||
|
int_rx_status_w = form->newLine(&grid);
|
||||||
|
new StaticText(int_rx_status_w, rect_t{}, STR_STATUS, 0, COLOR_THEME_PRIMARY1);
|
||||||
|
int_rx_status = new StaticText(int_rx_status_w, rect_t{}, "", 0, COLOR_THEME_PRIMARY1);
|
||||||
|
lv_obj_add_flag(int_rx_status_w->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||||
|
|
||||||
|
// headline "External module"
|
||||||
new StaticText(form, rect_t{}, STR_EXTERNAL_MODULE, 0, COLOR_THEME_PRIMARY1);
|
new StaticText(form, rect_t{}, STR_EXTERNAL_MODULE, 0, COLOR_THEME_PRIMARY1);
|
||||||
|
|
||||||
line = form->newLine(&grid);
|
// external module name
|
||||||
new StaticText(line, rect_t{}, STR_MODULE, 0, COLOR_THEME_PRIMARY1);
|
ext_module_name_w = form->newLine(&grid);
|
||||||
ext_name = new StaticText(line, rect_t{}, "", 0, COLOR_THEME_PRIMARY1);
|
new StaticText(ext_module_name_w, rect_t{}, STR_MODULE, 0, COLOR_THEME_PRIMARY1);
|
||||||
ext_status = new StaticText(line, rect_t{}, "", 0, COLOR_THEME_PRIMARY1);
|
ext_name = new StaticText(ext_module_name_w, rect_t{}, "", 0, COLOR_THEME_PRIMARY1);
|
||||||
|
|
||||||
ext_rx_line = form->newLine(&grid);
|
// external module status
|
||||||
new StaticText(ext_rx_line, rect_t{}, STR_RECEIVER, 0, COLOR_THEME_PRIMARY1);
|
ext_module_status_w = form->newLine(&grid);
|
||||||
ext_rx_name = new StaticText(ext_rx_line, rect_t{}, "", 0, COLOR_THEME_PRIMARY1);
|
new StaticText(ext_module_status_w, rect_t{}, STR_STATUS, 0, COLOR_THEME_PRIMARY1);
|
||||||
ext_rx_status = new StaticText(ext_rx_line, rect_t{}, "", 0, COLOR_THEME_PRIMARY1);
|
ext_status = new StaticText(ext_module_status_w, rect_t{}, "", 0, COLOR_THEME_PRIMARY1);
|
||||||
lv_obj_add_flag(ext_rx_line->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
lv_obj_add_flag(ext_module_status_w->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||||
|
|
||||||
|
// external receiver name
|
||||||
|
ext_rx_name_w = form->newLine(&grid);
|
||||||
|
new StaticText(ext_rx_name_w, rect_t{}, STR_RECEIVER, 0, COLOR_THEME_PRIMARY1);
|
||||||
|
ext_rx_name = new StaticText(ext_rx_name_w, rect_t{}, "", 0, COLOR_THEME_PRIMARY1);
|
||||||
|
lv_obj_add_flag(ext_rx_name_w->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||||
|
|
||||||
|
// external receiver status
|
||||||
|
ext_rx_status_w = form->newLine(&grid);
|
||||||
|
new StaticText(ext_rx_status_w, rect_t{}, STR_STATUS, 0, COLOR_THEME_PRIMARY1);
|
||||||
|
ext_rx_status = new StaticText(ext_rx_status_w, rect_t{}, "", 0, COLOR_THEME_PRIMARY1);
|
||||||
|
lv_obj_add_flag(ext_rx_status_w->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||||
|
|
||||||
content->setWidth(LCD_W * 0.8);
|
content->setWidth(LCD_W * 0.8);
|
||||||
update();
|
update();
|
||||||
@@ -119,48 +154,77 @@ class VersionDialog : public Dialog
|
|||||||
|
|
||||||
void update()
|
void update()
|
||||||
{
|
{
|
||||||
updateModule(INTERNAL_MODULE, int_name, int_status, int_rx_line,
|
updateModule(INTERNAL_MODULE,
|
||||||
int_rx_name, int_rx_status);
|
int_name,
|
||||||
updateModule(EXTERNAL_MODULE, ext_name, ext_status, ext_rx_line,
|
int_module_status_w, int_status,
|
||||||
ext_rx_name, ext_rx_status);
|
int_rx_name_w, int_rx_name,
|
||||||
|
int_rx_status_w, int_rx_status);
|
||||||
|
updateModule(EXTERNAL_MODULE,
|
||||||
|
ext_name,
|
||||||
|
ext_module_status_w, ext_status,
|
||||||
|
ext_rx_name_w, ext_rx_name,
|
||||||
|
ext_rx_status_w, ext_rx_status);
|
||||||
content->updateSize();
|
content->updateSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateModule(uint8_t module, StaticText* name, StaticText* status,
|
void updateModule(uint8_t module,
|
||||||
Window* rx_line, StaticText* rx_name, StaticText* rx_status)
|
StaticText* name,
|
||||||
{
|
Window* module_status_w, StaticText* status,
|
||||||
char tmp[20];
|
Window* rx_name_w, StaticText* rx_name,
|
||||||
|
Window* rx_status_w, StaticText* rx_status) {
|
||||||
|
// initialize module name with module selection made in model settings
|
||||||
|
// initialize to module does not provide status
|
||||||
|
// PXX2 will overwrite name
|
||||||
|
// CRSF, MPM, NV14 and PXX2 will overwrite status
|
||||||
|
name->setText(STR_INTERNAL_MODULE_PROTOCOLS[g_model.moduleData[module].type]);
|
||||||
|
lv_obj_add_flag(module_status_w->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||||
|
|
||||||
if (g_model.moduleData[module].type == MODULE_TYPE_NONE) {
|
|
||||||
name->setText(STR_OFF);
|
|
||||||
status->setText("");
|
|
||||||
}
|
|
||||||
#if defined(CROSSFIRE)
|
#if defined(CROSSFIRE)
|
||||||
else if (isModuleCrossfire(module)) {
|
// CRSF is able to provide status
|
||||||
name->setText("CRSF");
|
if (isModuleCrossfire(module)) {
|
||||||
|
|
||||||
char statusText[64];
|
char statusText[64];
|
||||||
|
|
||||||
auto hz = 1000000 / getMixerSchedulerPeriod();
|
auto hz = 1000000 / getMixerSchedulerPeriod();
|
||||||
snprintf(statusText, 64, "%d Hz %" PRIu32 " Err", hz, telemetryErrors);
|
snprintf(statusText, 64, "%d Hz %" PRIu32 " Err", hz, telemetryErrors);
|
||||||
status->setText(statusText);
|
status->setText(statusText);
|
||||||
|
lv_obj_clear_flag(module_status_w->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(MULTIMODULE)
|
|
||||||
else if (isModuleMultimodule(module)) {
|
|
||||||
name->setText("Multimodule");
|
|
||||||
|
|
||||||
char statusText[64] = "";
|
#if defined(PCBNV14) && defined(AFHDS2)
|
||||||
|
// NV14 AFHDS2A internal module is able to provide FW version
|
||||||
|
extern uint32_t NV14internalModuleFwVersion;
|
||||||
|
if (isModuleAFHDS2A(module)) {
|
||||||
|
sprintf(reusableBuffer.moduleSetup.msg, "FW Ver %d.%d.%d",
|
||||||
|
(int)((NV14internalModuleFwVersion >> 16) & 0xFF),
|
||||||
|
(int)((NV14internalModuleFwVersion >> 8) & 0xFF),
|
||||||
|
(int)(NV14internalModuleFwVersion & 0xFF));
|
||||||
|
status->setText(reusableBuffer.moduleSetup.msg);
|
||||||
|
lv_obj_clear_flag(module_status_w->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MULTIMODULE)
|
||||||
|
// MPM is able to provide status
|
||||||
|
if (isModuleMultimodule(module)) {
|
||||||
|
char statusText[64];
|
||||||
|
|
||||||
getMultiModuleStatus(module).getStatusString(statusText);
|
getMultiModuleStatus(module).getStatusString(statusText);
|
||||||
status->setText(statusText);
|
status->setText(statusText);
|
||||||
|
lv_obj_clear_flag(module_status_w->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(PXX2)
|
|
||||||
else if (isModulePXX2(module)) {
|
|
||||||
|
|
||||||
// PXX2 Module
|
#if defined(PXX2)
|
||||||
|
// PXX2 modules are able to provide status
|
||||||
|
if (isModulePXX2(module)) {
|
||||||
|
char tmp[20];
|
||||||
|
|
||||||
|
// PXX2 module name
|
||||||
name->setText(getPXX2ModuleName(reusableBuffer.hardwareAndSettings.modules[module]
|
name->setText(getPXX2ModuleName(reusableBuffer.hardwareAndSettings.modules[module]
|
||||||
.information.modelID));
|
.information.modelID));
|
||||||
|
|
||||||
|
// PXX2 module status
|
||||||
std::string mod_ver;
|
std::string mod_ver;
|
||||||
if (reusableBuffer.hardwareAndSettings.modules[module]
|
if (reusableBuffer.hardwareAndSettings.modules[module]
|
||||||
.information.modelID) {
|
.information.modelID) {
|
||||||
@@ -180,6 +244,7 @@ class VersionDialog : public Dialog
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
status->setText(mod_ver);
|
status->setText(mod_ver);
|
||||||
|
lv_obj_clear_flag(module_status_w->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||||
|
|
||||||
// PXX2 Receivers
|
// PXX2 Receivers
|
||||||
std::string rx_n;
|
std::string rx_n;
|
||||||
@@ -214,19 +279,17 @@ class VersionDialog : public Dialog
|
|||||||
|
|
||||||
if (!rx_n.empty() && !rx_ver.empty()) {
|
if (!rx_n.empty() && !rx_ver.empty()) {
|
||||||
// unhide RX labels
|
// unhide RX labels
|
||||||
lv_obj_clear_flag(rx_line->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
|
||||||
rx_name->setText(rx_n);
|
rx_name->setText(rx_n);
|
||||||
|
lv_obj_clear_flag(rx_name_w->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||||
rx_status->setText(rx_ver);
|
rx_status->setText(rx_ver);
|
||||||
|
lv_obj_clear_flag(rx_status_w->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||||
} else {
|
} else {
|
||||||
// hide RX labels
|
// hide RX labels
|
||||||
lv_obj_add_flag(rx_line->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
lv_obj_add_flag(rx_name_w->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||||
|
lv_obj_add_flag(rx_status_w->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else {
|
|
||||||
name->setText(STR_NO_INFORMATION);
|
|
||||||
status->setText("");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkEvents() override
|
void checkEvents() override
|
||||||
@@ -256,7 +319,6 @@ RadioVersionPage::RadioVersionPage():
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PCBNV14)
|
#if defined(PCBNV14)
|
||||||
extern uint32_t NV14internalModuleFwVersion;
|
|
||||||
extern const char* boardLcdType;
|
extern const char* boardLcdType;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -283,16 +345,6 @@ void RadioVersionPage::build(FormWindow * window)
|
|||||||
version += nl;
|
version += nl;
|
||||||
version += "LCD: ";
|
version += "LCD: ";
|
||||||
version += boardLcdType;
|
version += boardLcdType;
|
||||||
|
|
||||||
#if defined(AFHDS2)
|
|
||||||
version += nl;
|
|
||||||
version += "RF FW: ";
|
|
||||||
sprintf(reusableBuffer.moduleSetup.msg, "%d.%d.%d",
|
|
||||||
(int)((NV14internalModuleFwVersion >> 16) & 0xFF),
|
|
||||||
(int)((NV14internalModuleFwVersion >> 8) & 0xFF),
|
|
||||||
(int)(NV14internalModuleFwVersion & 0xFF));
|
|
||||||
version += reusableBuffer.moduleSetup.msg;
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto txt = new StaticText(window, rect_t{}, version, 0, COLOR_THEME_PRIMARY1);
|
auto txt = new StaticText(window, rect_t{}, version, 0, COLOR_THEME_PRIMARY1);
|
||||||
|
|||||||
Reference in New Issue
Block a user