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),
|
||||
LV_GRID_TEMPLATE_LAST};
|
||||
static const lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(2), LV_GRID_TEMPLATE_LAST};
|
||||
static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST};
|
||||
|
||||
class VersionDialog : public Dialog
|
||||
{
|
||||
Window* int_module_name_w;
|
||||
StaticText* int_name;
|
||||
Window* int_module_status_w;
|
||||
StaticText* int_status;
|
||||
Window* int_rx_line;
|
||||
|
||||
Window* int_rx_name_w;
|
||||
StaticText* int_rx_name;
|
||||
Window* int_rx_status_w;
|
||||
StaticText* int_rx_status;
|
||||
|
||||
Window* ext_module_name_w;
|
||||
StaticText* ext_name;
|
||||
Window* ext_module_status_w;
|
||||
StaticText* ext_status;
|
||||
Window* ext_rx_line;
|
||||
|
||||
Window* ext_rx_name_w;
|
||||
StaticText* ext_rx_name;
|
||||
Window* ext_rx_status_w;
|
||||
StaticText* ext_rx_status;
|
||||
|
||||
public:
|
||||
@@ -82,36 +89,64 @@ class VersionDialog : public Dialog
|
||||
|
||||
setCloseWhenClickOutside(true);
|
||||
|
||||
// define grid layout
|
||||
FlexGridLayout grid(col_dsc, row_dsc);
|
||||
|
||||
// define form
|
||||
auto form = &content->form;
|
||||
form->setFlexLayout();
|
||||
|
||||
FlexGridLayout grid(col_dsc, row_dsc);
|
||||
|
||||
// headline "Internal module"
|
||||
new StaticText(form, rect_t{}, STR_INTERNAL_MODULE, 0, COLOR_THEME_PRIMARY1);
|
||||
|
||||
auto line = form->newLine(&grid);
|
||||
new StaticText(line, rect_t{}, STR_MODULE, 0, COLOR_THEME_PRIMARY1);
|
||||
int_name = new StaticText(line, rect_t{}, "", 0, COLOR_THEME_PRIMARY1);
|
||||
int_status = new StaticText(line, rect_t{}, "", 0, COLOR_THEME_PRIMARY1);
|
||||
// Internal module name
|
||||
int_module_name_w = form->newLine(&grid);
|
||||
new StaticText(int_module_name_w, rect_t{}, STR_MODULE, 0, COLOR_THEME_PRIMARY1);
|
||||
int_name = new StaticText(int_module_name_w, rect_t{}, "", 0, COLOR_THEME_PRIMARY1);
|
||||
|
||||
int_rx_line = form->newLine(&grid);
|
||||
new StaticText(int_rx_line, rect_t{}, STR_RECEIVER, 0, COLOR_THEME_PRIMARY1);
|
||||
int_rx_name = new StaticText(int_rx_line, rect_t{}, "", 0, COLOR_THEME_PRIMARY1);
|
||||
int_rx_status = new StaticText(int_rx_line, rect_t{}, "", 0, COLOR_THEME_PRIMARY1);
|
||||
lv_obj_add_flag(int_rx_line->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||
// internal module status
|
||||
int_module_status_w = form->newLine(&grid);
|
||||
new StaticText(int_module_status_w, rect_t{}, STR_STATUS, 0, COLOR_THEME_PRIMARY1);
|
||||
int_status = new StaticText(int_module_status_w, rect_t{}, "", 0, COLOR_THEME_PRIMARY1);
|
||||
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);
|
||||
|
||||
line = form->newLine(&grid);
|
||||
new StaticText(line, rect_t{}, STR_MODULE, 0, COLOR_THEME_PRIMARY1);
|
||||
ext_name = new StaticText(line, rect_t{}, "", 0, COLOR_THEME_PRIMARY1);
|
||||
ext_status = new StaticText(line, rect_t{}, "", 0, COLOR_THEME_PRIMARY1);
|
||||
// external module name
|
||||
ext_module_name_w = form->newLine(&grid);
|
||||
new StaticText(ext_module_name_w, rect_t{}, STR_MODULE, 0, COLOR_THEME_PRIMARY1);
|
||||
ext_name = new StaticText(ext_module_name_w, rect_t{}, "", 0, COLOR_THEME_PRIMARY1);
|
||||
|
||||
// external module status
|
||||
ext_module_status_w = form->newLine(&grid);
|
||||
new StaticText(ext_module_status_w, rect_t{}, STR_STATUS, 0, COLOR_THEME_PRIMARY1);
|
||||
ext_status = new StaticText(ext_module_status_w, rect_t{}, "", 0, COLOR_THEME_PRIMARY1);
|
||||
lv_obj_add_flag(ext_module_status_w->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||
|
||||
ext_rx_line = form->newLine(&grid);
|
||||
new StaticText(ext_rx_line, rect_t{}, STR_RECEIVER, 0, COLOR_THEME_PRIMARY1);
|
||||
ext_rx_name = new StaticText(ext_rx_line, rect_t{}, "", 0, COLOR_THEME_PRIMARY1);
|
||||
ext_rx_status = new StaticText(ext_rx_line, rect_t{}, "", 0, COLOR_THEME_PRIMARY1);
|
||||
lv_obj_add_flag(ext_rx_line->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);
|
||||
update();
|
||||
@@ -119,48 +154,77 @@ class VersionDialog : public Dialog
|
||||
|
||||
void update()
|
||||
{
|
||||
updateModule(INTERNAL_MODULE, int_name, int_status, int_rx_line,
|
||||
int_rx_name, int_rx_status);
|
||||
updateModule(EXTERNAL_MODULE, ext_name, ext_status, ext_rx_line,
|
||||
ext_rx_name, ext_rx_status);
|
||||
updateModule(INTERNAL_MODULE,
|
||||
int_name,
|
||||
int_module_status_w, int_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();
|
||||
}
|
||||
|
||||
void updateModule(uint8_t module, StaticText* name, StaticText* status,
|
||||
Window* rx_line, StaticText* rx_name, StaticText* rx_status)
|
||||
{
|
||||
char tmp[20];
|
||||
void updateModule(uint8_t module,
|
||||
StaticText* name,
|
||||
Window* module_status_w, StaticText* status,
|
||||
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)
|
||||
else if (isModuleCrossfire(module)) {
|
||||
name->setText("CRSF");
|
||||
|
||||
// CRSF is able to provide status
|
||||
if (isModuleCrossfire(module)) {
|
||||
char statusText[64];
|
||||
|
||||
auto hz = 1000000 / getMixerSchedulerPeriod();
|
||||
snprintf(statusText, 64, "%d Hz %" PRIu32 " Err", hz, telemetryErrors);
|
||||
status->setText(statusText);
|
||||
lv_obj_clear_flag(module_status_w->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
#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);
|
||||
status->setText(statusText);
|
||||
lv_obj_clear_flag(module_status_w->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
#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]
|
||||
.information.modelID));
|
||||
|
||||
// PXX2 module status
|
||||
std::string mod_ver;
|
||||
if (reusableBuffer.hardwareAndSettings.modules[module]
|
||||
.information.modelID) {
|
||||
@@ -180,6 +244,7 @@ class VersionDialog : public Dialog
|
||||
}
|
||||
}
|
||||
status->setText(mod_ver);
|
||||
lv_obj_clear_flag(module_status_w->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||
|
||||
// PXX2 Receivers
|
||||
std::string rx_n;
|
||||
@@ -214,19 +279,17 @@ class VersionDialog : public Dialog
|
||||
|
||||
if (!rx_n.empty() && !rx_ver.empty()) {
|
||||
// unhide RX labels
|
||||
lv_obj_clear_flag(rx_line->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||
rx_name->setText(rx_n);
|
||||
lv_obj_clear_flag(rx_name_w->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||
rx_status->setText(rx_ver);
|
||||
lv_obj_clear_flag(rx_status_w->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||
} else {
|
||||
// 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
|
||||
else {
|
||||
name->setText(STR_NO_INFORMATION);
|
||||
status->setText("");
|
||||
}
|
||||
}
|
||||
|
||||
void checkEvents() override
|
||||
@@ -256,7 +319,6 @@ RadioVersionPage::RadioVersionPage():
|
||||
}
|
||||
|
||||
#if defined(PCBNV14)
|
||||
extern uint32_t NV14internalModuleFwVersion;
|
||||
extern const char* boardLcdType;
|
||||
#endif
|
||||
|
||||
@@ -283,16 +345,6 @@ void RadioVersionPage::build(FormWindow * window)
|
||||
version += nl;
|
||||
version += "LCD: ";
|
||||
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
|
||||
|
||||
auto txt = new StaticText(window, rect_t{}, version, 0, COLOR_THEME_PRIMARY1);
|
||||
|
||||
Reference in New Issue
Block a user