From faf0027818521e78affda7abc2baa8bed4eecc52 Mon Sep 17 00:00:00 2001 From: philmoz Date: Sat, 27 Jul 2024 16:06:48 +1000 Subject: [PATCH] feat(color): allow changing the size of topbar widgets (#5235) --- .../src/firmwares/edgetx/yaml_modeldata.cpp | 12 +++- companion/src/firmwares/modeldata.h | 1 + radio/src/datastructs.h | 8 +-- radio/src/datastructs_private.h | 5 +- .../src/gui/colorlcd/layouts/topbar_impl.cpp | 27 ++++---- .../gui/colorlcd/screen_user_interface.cpp | 66 +++++++++++++++++-- .../src/gui/colorlcd/screen_user_interface.h | 5 ++ radio/src/storage/storage_common.cpp | 36 +++++----- .../storage/yaml/yaml_datastructs_128x64.cpp | 4 +- .../storage/yaml/yaml_datastructs_nv14.cpp | 5 +- .../storage/yaml/yaml_datastructs_pl18.cpp | 5 +- .../src/storage/yaml/yaml_datastructs_t15.cpp | 5 +- .../src/storage/yaml/yaml_datastructs_t20.cpp | 4 +- .../storage/yaml/yaml_datastructs_tpro.cpp | 4 +- .../src/storage/yaml/yaml_datastructs_x10.cpp | 5 +- .../storage/yaml/yaml_datastructs_x12s.cpp | 5 +- .../src/storage/yaml/yaml_datastructs_x9d.cpp | 4 +- .../src/storage/yaml/yaml_datastructs_x9e.cpp | 4 +- .../storage/yaml/yaml_datastructs_xlites.cpp | 4 +- radio/src/thirdparty/libopenui/src/choice.cpp | 2 +- radio/src/translations.cpp | 1 + radio/src/translations.h | 1 + radio/src/translations/cn.h | 2 + radio/src/translations/cz.h | 2 + radio/src/translations/da.h | 2 + radio/src/translations/de.h | 2 + radio/src/translations/en.h | 2 + radio/src/translations/es.h | 2 + radio/src/translations/fi.h | 2 + radio/src/translations/fr.h | 2 + radio/src/translations/he.h | 2 + radio/src/translations/it.h | 3 +- radio/src/translations/jp.h | 2 + radio/src/translations/nl.h | 2 + radio/src/translations/pl.h | 2 + radio/src/translations/pt.h | 2 + radio/src/translations/ru.h | 2 + radio/src/translations/se.h | 2 + radio/src/translations/tw.h | 2 + radio/src/translations/ua.h | 2 + 40 files changed, 185 insertions(+), 65 deletions(-) diff --git a/companion/src/firmwares/edgetx/yaml_modeldata.cpp b/companion/src/firmwares/edgetx/yaml_modeldata.cpp index 37936eb74c3..01241b456eb 100644 --- a/companion/src/firmwares/edgetx/yaml_modeldata.cpp +++ b/companion/src/firmwares/edgetx/yaml_modeldata.cpp @@ -1179,6 +1179,9 @@ Node convert::encode(const ModelData& rhs) if (topbarData && topbarData.IsMap()) { node["topbarData"] = topbarData; } + for (int i = 0; i < MAX_TOPBAR_ZONES; i += 1) + if (rhs.topbarWidgetWidth[i] > 0) + node["topbarWidgetWidth"][std::to_string(i)]["val"] = (int)rhs.topbarWidgetWidth[i]; node["view"] = rhs.view; } @@ -1447,8 +1450,15 @@ bool convert::decode(const Node& node, ModelData& rhs) node["screenData"] >> rhs.customScreens.customScreenData; node["topbarData"] >> rhs.topBarData; - + if (node["topbarWidgetWidth"]) { + for (int i = 0; i < MAX_TOPBAR_ZONES; i += 1) { + if (node["topbarWidgetWidth"][std::to_string(i)]) { + node["topbarWidgetWidth"][std::to_string(i)]["val"] >> rhs.topbarWidgetWidth[i]; + } + } + } node["view"] >> rhs.view; + node["modelRegistrationID"] >> rhs.registrationId; node["hatsMode"] >> hatsModeLut >> rhs.hatsMode; diff --git a/companion/src/firmwares/modeldata.h b/companion/src/firmwares/modeldata.h index 8be1e31c93b..dfce148e939 100644 --- a/companion/src/firmwares/modeldata.h +++ b/companion/src/firmwares/modeldata.h @@ -188,6 +188,7 @@ class ModelData { RadioLayout::CustomScreens customScreens; TopBarPersistentData topBarData; + uint8_t topbarWidgetWidth[MAX_TOPBAR_ZONES]; unsigned int view; char registrationId[8+1]; diff --git a/radio/src/datastructs.h b/radio/src/datastructs.h index 03ab30ab5a2..f0e56d65dfc 100644 --- a/radio/src/datastructs.h +++ b/radio/src/datastructs.h @@ -101,13 +101,13 @@ static inline void check_struct() #elif defined(PCBX7) || defined(PCBXLITE) || defined(PCBX9LITE) CHKSIZE(ModelData, 6329); #elif defined(PCBNV14) - CHKSIZE(ModelData, 15655); + CHKSIZE(ModelData, 15659); #elif defined(PCBPL18) - CHKSIZE(ModelData, 15835); + CHKSIZE(ModelData, 15841); #elif defined(RADIO_T15) - CHKSIZE(ModelData, 15824); + CHKSIZE(ModelData, 15830); #elif defined(PCBHORUS) - CHKSIZE(ModelData, 15799); + CHKSIZE(ModelData, 15805); #else #error CHKSIZE not set up #endif diff --git a/radio/src/datastructs_private.h b/radio/src/datastructs_private.h index 0013434b738..e2d317b7b33 100644 --- a/radio/src/datastructs_private.h +++ b/radio/src/datastructs_private.h @@ -95,7 +95,7 @@ PACK(struct MixData { uint16_t mltpx:2 ENUM(MixerMultiplex); uint16_t speedPrec:1; uint16_t flightModes:9 CUST(r_flightModes, w_flightModes); - uint16_t spare:2; + uint16_t spare:2 SKIP; uint32_t weight:11 CUST(r_sourceNumVal,w_sourceNumVal); uint32_t offset:11 CUST(r_sourceNumVal,w_sourceNumVal); int32_t swtch:10 CUST(r_swtchSrc,w_swtchSrc); @@ -123,7 +123,7 @@ PACK(struct ExpoData { CurveRef curve; uint16_t chn:5; uint16_t flightModes:9 CUST(r_flightModes, w_flightModes); - uint16_t spare:2; + uint16_t spare:2 SKIP; NOBACKUP(char name[LEN_EXPOMIX_NAME]); }); @@ -596,6 +596,7 @@ PACK(struct CustomScreenData { #define CUSTOM_SCREENS_DATA \ NOBACKUP(CustomScreenData screenData[MAX_CUSTOM_SCREENS]); \ NOBACKUP(TopBarPersistentData topbarData); \ + NOBACKUP(uint8_t topbarWidgetWidth[MAX_TOPBAR_ZONES]); \ NOBACKUP(uint8_t view); #else #define CUSTOM_SCREENS_DATA \ diff --git a/radio/src/gui/colorlcd/layouts/topbar_impl.cpp b/radio/src/gui/colorlcd/layouts/topbar_impl.cpp index 4fd599e9a4d..f05efc91965 100644 --- a/radio/src/gui/colorlcd/layouts/topbar_impl.cpp +++ b/radio/src/gui/colorlcd/layouts/topbar_impl.cpp @@ -50,24 +50,25 @@ TopBar::TopBar(Window * parent) : unsigned int TopBar::getZonesCount() const { - return MAX_TOPBAR_ZONES; + unsigned int zoneCount = 0; + for (int i = 0; i < MAX_TOPBAR_ZONES; i += 1) + if (g_model.topbarWidgetWidth[i] > 0) + zoneCount += 1; + return zoneCount; } rect_t TopBar::getZone(unsigned int index) const { -#if PORTRAIT_LCD - if (index == MAX_TOPBAR_ZONES - 1) { - coord_t size = LCD_W - HDR_DATE_XO - (MAX_TOPBAR_ZONES - 1) * (TOPBAR_ZONE_WIDTH + TOPBAR_ZONE_HMARGIN); - return {LCD_W - size, TOPBAR_ZONE_VMARGIN, size, TOPBAR_ZONE_HEIGHT}; - } -#endif + coord_t x = MENU_HEADER_BUTTONS_LEFT + 1; + + for (int i = 0; i < index; i += 1) + x += (g_model.topbarWidgetWidth[i] * (TOPBAR_ZONE_WIDTH + TOPBAR_ZONE_HMARGIN)); + + coord_t size = ((g_model.topbarWidgetWidth[index] - 1) * (TOPBAR_ZONE_WIDTH + TOPBAR_ZONE_HMARGIN) + TOPBAR_ZONE_WIDTH); + + if ((x + size) > LCD_W) size = LCD_W - x; - return { - coord_t(MENU_HEADER_BUTTONS_LEFT + 1 + (TOPBAR_ZONE_WIDTH + TOPBAR_ZONE_HMARGIN) * index), - TOPBAR_ZONE_VMARGIN, - TOPBAR_ZONE_WIDTH, - TOPBAR_ZONE_HEIGHT - }; + return {x, TOPBAR_ZONE_VMARGIN, size, TOPBAR_ZONE_HEIGHT}; } void TopBar::setVisible(float visible) // 0.0 -> 1.0 diff --git a/radio/src/gui/colorlcd/screen_user_interface.cpp b/radio/src/gui/colorlcd/screen_user_interface.cpp index a61136f2f14..9db3c588145 100644 --- a/radio/src/gui/colorlcd/screen_user_interface.cpp +++ b/radio/src/gui/colorlcd/screen_user_interface.cpp @@ -24,6 +24,8 @@ #include "file_preview.h" #include "menu_screen.h" #include "theme_manager.h" +#include "topbar_impl.h" +#include "view_main.h" #if !PORTRAIT_LCD // landscape @@ -146,12 +148,64 @@ void ScreenUserInterfacePage::build(Window* window) auto line = window->newLine(grid); new StaticText(line, rect_t{}, STR_TOP_BAR); - auto setupTopbarWidgets = new TextButton(line, rect_t{}, STR_SETUP_WIDGETS); - setupTopbarWidgets->setPressHandler([=]() -> uint8_t { - menu->deleteLater(); - new SetupTopBarWidgetsPage(); - return 0; - }); + auto setupTopbarWidgets = new TextButton(line, rect_t{}, STR_SETUP_WIDGETS, + [=]() -> uint8_t { + menu->deleteLater(); + new SetupTopBarWidgetsPage(); + return 0; + }); + + line = window->newLine(grid); + new StaticText(line, rect_t{}, STR_WIDGET_SIZE); + line = window->newLine(grid); + auto box = new Window(line, rect_t{}); + box->setFlexLayout(LV_FLEX_FLOW_ROW, PAD_TINY); + box->padAll(PAD_TINY); + box->padLeft(PAD_MEDIUM); + for (int i = 0; i < MAX_TOPBAR_ZONES; i += 1) { + coord_t w = (g_model.topbarWidgetWidth[i] * (WWBTN_W + PAD_TINY)) - PAD_TINY; + if (w < WWBTN_W) w = WWBTN_W; + widths[i] = new Choice(box, {0, 0, w, 0}, 0, MAX_TOPBAR_ZONES, + [=]() { + return g_model.topbarWidgetWidth[i]; + }, + [=](int value) { + g_model.topbarWidgetWidth[i] = value; + coord_t w = (g_model.topbarWidgetWidth[i] * (WWBTN_W + PAD_TINY)) - PAD_TINY; + widths[i]->setWidth(w); + int remaining = MAX_TOPBAR_ZONES; + for (int n = 0; n < MAX_TOPBAR_ZONES; n += 1) { + if (n > i) { + if (remaining > 0) { + if (g_model.topbarWidgetWidth[n] == 0) { + g_model.topbarWidgetWidth[n] = 1; + widths[n]->setWidth(WWBTN_W); + widths[n]->show(); + widths[n]->update(); + } + } else { + if (g_model.topbarWidgetWidth[n] != 0) { + g_model.topbarWidgetWidth[n] = 0; + widths[n]->setWidth(WWBTN_W); + widths[n]->hide(); + ViewMain::instance()->getTopbar()->removeWidget(n); + } + } + } + ViewMain::instance()->getTopbar()->load(); + remaining -= g_model.topbarWidgetWidth[n]; + } + storageDirty(EE_MODEL); + }, STR_WIDGET_SIZE); + widths[i]->setAvailableHandler([=](int value) { + int remaining = MAX_TOPBAR_ZONES; + for (int n = 0; n < i; n += 1) + remaining -= g_model.topbarWidgetWidth[n]; + return value > 0 && value <= remaining; + }); + if (g_model.topbarWidgetWidth[i] == 0) + widths[i]->hide(); + } // Theme choice line = window->newLine(grid); diff --git a/radio/src/gui/colorlcd/screen_user_interface.h b/radio/src/gui/colorlcd/screen_user_interface.h index 4ca8918cc0a..613b69cca03 100644 --- a/radio/src/gui/colorlcd/screen_user_interface.h +++ b/radio/src/gui/colorlcd/screen_user_interface.h @@ -22,9 +22,11 @@ #pragma once #include "tabsgroup.h" +#include "widgets_container.h" class ScreenMenu; class ThemeView; +class Choice; class ScreenUserInterfacePage : public PageTab { @@ -33,7 +35,10 @@ class ScreenUserInterfacePage : public PageTab void build(Window* window) override; + static LAYOUT_VAL(WWBTN_W, 60, 60) + protected: ScreenMenu* menu; + Choice* widths[MAX_TOPBAR_ZONES]; ThemeView* themeView = nullptr; }; diff --git a/radio/src/storage/storage_common.cpp b/radio/src/storage/storage_common.cpp index 65ed4e83e70..6ff0d330b75 100644 --- a/radio/src/storage/storage_common.cpp +++ b/radio/src/storage/storage_common.cpp @@ -161,23 +161,29 @@ static void sanitizeMixerLines() void postModelLoad(bool alarms) { #if defined(COLORLCD) - // Load 'date time' widget if slot is empty - if (g_model.topbarData.zones[MAX_TOPBAR_ZONES-1].widgetName[0] == 0) { - strAppend(g_model.topbarData.zones[MAX_TOPBAR_ZONES-1].widgetName, "Date Time", WIDGET_NAME_LEN); - storageDirty(EE_MODEL); - } - // Load 'radio info' widget if slot is empty - if (g_model.topbarData.zones[MAX_TOPBAR_ZONES-2].widgetName[0] == 0) { - strAppend(g_model.topbarData.zones[MAX_TOPBAR_ZONES-2].widgetName, "Radio Info", WIDGET_NAME_LEN); - storageDirty(EE_MODEL); - } + if (g_model.topbarWidgetWidth[0] == 0) { + // Set default width for top bar widgets + for (int i = 0; i < MAX_TOPBAR_ZONES; i += 1) + g_model.topbarWidgetWidth[i] = 1; + + // Load 'date time' widget if slot is empty + if (g_model.topbarData.zones[MAX_TOPBAR_ZONES-1].widgetName[0] == 0) { + strAppend(g_model.topbarData.zones[MAX_TOPBAR_ZONES-1].widgetName, "Date Time", WIDGET_NAME_LEN); + storageDirty(EE_MODEL); + } + // Load 'radio info' widget if slot is empty + if (g_model.topbarData.zones[MAX_TOPBAR_ZONES-2].widgetName[0] == 0) { + strAppend(g_model.topbarData.zones[MAX_TOPBAR_ZONES-2].widgetName, "Radio Info", WIDGET_NAME_LEN); + storageDirty(EE_MODEL); + } #if defined(INTERNAL_GPS) - // Load 'internal gps' widget if slot is empty - if (g_model.topbarData.zones[MAX_TOPBAR_ZONES-3].widgetName[0] == 0) { - strAppend(g_model.topbarData.zones[MAX_TOPBAR_ZONES-3].widgetName, "Internal GPS", WIDGET_NAME_LEN); - storageDirty(EE_MODEL); - } + // Load 'internal gps' widget if slot is empty + if (g_model.topbarData.zones[MAX_TOPBAR_ZONES-3].widgetName[0] == 0) { + strAppend(g_model.topbarData.zones[MAX_TOPBAR_ZONES-3].widgetName, "Internal GPS", WIDGET_NAME_LEN); + storageDirty(EE_MODEL); + } #endif + } #elif LCD_W == 128 // Prevent GVARS to be off when imported or manually modified yaml // Since there is no way to have those back diff --git a/radio/src/storage/yaml/yaml_datastructs_128x64.cpp b/radio/src/storage/yaml/yaml_datastructs_128x64.cpp index c3e68ef1911..0d02200dca6 100644 --- a/radio/src/storage/yaml/yaml_datastructs_128x64.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_128x64.cpp @@ -403,7 +403,7 @@ static const struct YamlNode struct_MixData[] = { YAML_ENUM("mltpx", 2, enum_MixerMultiplex), YAML_UNSIGNED( "speedPrec", 1 ), YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ), - YAML_UNSIGNED( "spare", 2 ), + YAML_PADDING( 2 ), YAML_UNSIGNED_CUST( "weight", 11, r_sourceNumVal, w_sourceNumVal ), YAML_UNSIGNED_CUST( "offset", 11, r_sourceNumVal, w_sourceNumVal ), YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ), @@ -440,7 +440,7 @@ static const struct YamlNode struct_ExpoData[] = { YAML_STRUCT("curve", 16, struct_CurveRef, NULL), YAML_UNSIGNED( "chn", 5 ), YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ), - YAML_UNSIGNED( "spare", 2 ), + YAML_PADDING( 2 ), YAML_STRING("name", 6), YAML_END }; diff --git a/radio/src/storage/yaml/yaml_datastructs_nv14.cpp b/radio/src/storage/yaml/yaml_datastructs_nv14.cpp index 32b50c3c067..633214913fe 100644 --- a/radio/src/storage/yaml/yaml_datastructs_nv14.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_nv14.cpp @@ -429,7 +429,7 @@ static const struct YamlNode struct_MixData[] = { YAML_ENUM("mltpx", 2, enum_MixerMultiplex), YAML_UNSIGNED( "speedPrec", 1 ), YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ), - YAML_UNSIGNED( "spare", 2 ), + YAML_PADDING( 2 ), YAML_UNSIGNED_CUST( "weight", 11, r_sourceNumVal, w_sourceNumVal ), YAML_UNSIGNED_CUST( "offset", 11, r_sourceNumVal, w_sourceNumVal ), YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ), @@ -466,7 +466,7 @@ static const struct YamlNode struct_ExpoData[] = { YAML_STRUCT("curve", 16, struct_CurveRef, NULL), YAML_UNSIGNED( "chn", 5 ), YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ), - YAML_UNSIGNED( "spare", 2 ), + YAML_PADDING( 2 ), YAML_STRING("name", 6), YAML_END }; @@ -864,6 +864,7 @@ static const struct YamlNode struct_ModelData[] = { YAML_ARRAY("telemetrySensors", 112, 60, struct_TelemetrySensor, NULL), YAML_ARRAY("screenData", 6816, 10, struct_CustomScreenData, NULL), YAML_STRUCT("topbarData", 2400, struct_TopBarPersistentData, NULL), + YAML_ARRAY("topbarWidgetWidth", 8, 4, struct_unsigned_8, NULL), YAML_UNSIGNED( "view", 8 ), YAML_STRING("modelRegistrationID", 8), YAML_UNSIGNED( "usbJoystickExtMode", 1 ), diff --git a/radio/src/storage/yaml/yaml_datastructs_pl18.cpp b/radio/src/storage/yaml/yaml_datastructs_pl18.cpp index 8787191712a..955fbfe23a6 100644 --- a/radio/src/storage/yaml/yaml_datastructs_pl18.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_pl18.cpp @@ -429,7 +429,7 @@ static const struct YamlNode struct_MixData[] = { YAML_ENUM("mltpx", 2, enum_MixerMultiplex), YAML_UNSIGNED( "speedPrec", 1 ), YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ), - YAML_UNSIGNED( "spare", 2 ), + YAML_PADDING( 2 ), YAML_UNSIGNED_CUST( "weight", 11, r_sourceNumVal, w_sourceNumVal ), YAML_UNSIGNED_CUST( "offset", 11, r_sourceNumVal, w_sourceNumVal ), YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ), @@ -466,7 +466,7 @@ static const struct YamlNode struct_ExpoData[] = { YAML_STRUCT("curve", 16, struct_CurveRef, NULL), YAML_UNSIGNED( "chn", 5 ), YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ), - YAML_UNSIGNED( "spare", 2 ), + YAML_PADDING( 2 ), YAML_STRING("name", 6), YAML_END }; @@ -864,6 +864,7 @@ static const struct YamlNode struct_ModelData[] = { YAML_ARRAY("telemetrySensors", 112, 60, struct_TelemetrySensor, NULL), YAML_ARRAY("screenData", 6816, 10, struct_CustomScreenData, NULL), YAML_STRUCT("topbarData", 3552, struct_TopBarPersistentData, NULL), + YAML_ARRAY("topbarWidgetWidth", 8, 6, struct_unsigned_8, NULL), YAML_UNSIGNED( "view", 8 ), YAML_STRING("modelRegistrationID", 8), YAML_UNSIGNED( "usbJoystickExtMode", 1 ), diff --git a/radio/src/storage/yaml/yaml_datastructs_t15.cpp b/radio/src/storage/yaml/yaml_datastructs_t15.cpp index 4a68b20a57b..f85faec894e 100644 --- a/radio/src/storage/yaml/yaml_datastructs_t15.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_t15.cpp @@ -431,7 +431,7 @@ static const struct YamlNode struct_MixData[] = { YAML_ENUM("mltpx", 2, enum_MixerMultiplex), YAML_UNSIGNED( "speedPrec", 1 ), YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ), - YAML_UNSIGNED( "spare", 2 ), + YAML_PADDING( 2 ), YAML_UNSIGNED_CUST( "weight", 11, r_sourceNumVal, w_sourceNumVal ), YAML_UNSIGNED_CUST( "offset", 11, r_sourceNumVal, w_sourceNumVal ), YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ), @@ -468,7 +468,7 @@ static const struct YamlNode struct_ExpoData[] = { YAML_STRUCT("curve", 16, struct_CurveRef, NULL), YAML_UNSIGNED( "chn", 5 ), YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ), - YAML_UNSIGNED( "spare", 2 ), + YAML_PADDING( 2 ), YAML_STRING("name", 6), YAML_END }; @@ -870,6 +870,7 @@ static const struct YamlNode struct_ModelData[] = { YAML_ARRAY("telemetrySensors", 112, 60, struct_TelemetrySensor, NULL), YAML_ARRAY("screenData", 6816, 10, struct_CustomScreenData, NULL), YAML_STRUCT("topbarData", 3552, struct_TopBarPersistentData, NULL), + YAML_ARRAY("topbarWidgetWidth", 8, 6, struct_unsigned_8, NULL), YAML_UNSIGNED( "view", 8 ), YAML_STRING("modelRegistrationID", 8), YAML_UNSIGNED( "functionSwitchConfig", 16 ), diff --git a/radio/src/storage/yaml/yaml_datastructs_t20.cpp b/radio/src/storage/yaml/yaml_datastructs_t20.cpp index e91042a062d..0e7e982cd6b 100644 --- a/radio/src/storage/yaml/yaml_datastructs_t20.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_t20.cpp @@ -403,7 +403,7 @@ static const struct YamlNode struct_MixData[] = { YAML_ENUM("mltpx", 2, enum_MixerMultiplex), YAML_UNSIGNED( "speedPrec", 1 ), YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ), - YAML_UNSIGNED( "spare", 2 ), + YAML_PADDING( 2 ), YAML_UNSIGNED_CUST( "weight", 11, r_sourceNumVal, w_sourceNumVal ), YAML_UNSIGNED_CUST( "offset", 11, r_sourceNumVal, w_sourceNumVal ), YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ), @@ -440,7 +440,7 @@ static const struct YamlNode struct_ExpoData[] = { YAML_STRUCT("curve", 16, struct_CurveRef, NULL), YAML_UNSIGNED( "chn", 5 ), YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ), - YAML_UNSIGNED( "spare", 2 ), + YAML_PADDING( 2 ), YAML_STRING("name", 6), YAML_END }; diff --git a/radio/src/storage/yaml/yaml_datastructs_tpro.cpp b/radio/src/storage/yaml/yaml_datastructs_tpro.cpp index 2a9ccc5e903..a8397a8bf74 100644 --- a/radio/src/storage/yaml/yaml_datastructs_tpro.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_tpro.cpp @@ -403,7 +403,7 @@ static const struct YamlNode struct_MixData[] = { YAML_ENUM("mltpx", 2, enum_MixerMultiplex), YAML_UNSIGNED( "speedPrec", 1 ), YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ), - YAML_UNSIGNED( "spare", 2 ), + YAML_PADDING( 2 ), YAML_UNSIGNED_CUST( "weight", 11, r_sourceNumVal, w_sourceNumVal ), YAML_UNSIGNED_CUST( "offset", 11, r_sourceNumVal, w_sourceNumVal ), YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ), @@ -440,7 +440,7 @@ static const struct YamlNode struct_ExpoData[] = { YAML_STRUCT("curve", 16, struct_CurveRef, NULL), YAML_UNSIGNED( "chn", 5 ), YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ), - YAML_UNSIGNED( "spare", 2 ), + YAML_PADDING( 2 ), YAML_STRING("name", 6), YAML_END }; diff --git a/radio/src/storage/yaml/yaml_datastructs_x10.cpp b/radio/src/storage/yaml/yaml_datastructs_x10.cpp index 18640aba4b0..a214c3048c7 100644 --- a/radio/src/storage/yaml/yaml_datastructs_x10.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_x10.cpp @@ -431,7 +431,7 @@ static const struct YamlNode struct_MixData[] = { YAML_ENUM("mltpx", 2, enum_MixerMultiplex), YAML_UNSIGNED( "speedPrec", 1 ), YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ), - YAML_UNSIGNED( "spare", 2 ), + YAML_PADDING( 2 ), YAML_UNSIGNED_CUST( "weight", 11, r_sourceNumVal, w_sourceNumVal ), YAML_UNSIGNED_CUST( "offset", 11, r_sourceNumVal, w_sourceNumVal ), YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ), @@ -468,7 +468,7 @@ static const struct YamlNode struct_ExpoData[] = { YAML_STRUCT("curve", 16, struct_CurveRef, NULL), YAML_UNSIGNED( "chn", 5 ), YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ), - YAML_UNSIGNED( "spare", 2 ), + YAML_PADDING( 2 ), YAML_STRING("name", 6), YAML_END }; @@ -865,6 +865,7 @@ static const struct YamlNode struct_ModelData[] = { YAML_ARRAY("telemetrySensors", 112, 60, struct_TelemetrySensor, NULL), YAML_ARRAY("screenData", 6816, 10, struct_CustomScreenData, NULL), YAML_STRUCT("topbarData", 3552, struct_TopBarPersistentData, NULL), + YAML_ARRAY("topbarWidgetWidth", 8, 6, struct_unsigned_8, NULL), YAML_UNSIGNED( "view", 8 ), YAML_STRING("modelRegistrationID", 8), YAML_UNSIGNED( "usbJoystickExtMode", 1 ), diff --git a/radio/src/storage/yaml/yaml_datastructs_x12s.cpp b/radio/src/storage/yaml/yaml_datastructs_x12s.cpp index 18640aba4b0..a214c3048c7 100644 --- a/radio/src/storage/yaml/yaml_datastructs_x12s.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_x12s.cpp @@ -431,7 +431,7 @@ static const struct YamlNode struct_MixData[] = { YAML_ENUM("mltpx", 2, enum_MixerMultiplex), YAML_UNSIGNED( "speedPrec", 1 ), YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ), - YAML_UNSIGNED( "spare", 2 ), + YAML_PADDING( 2 ), YAML_UNSIGNED_CUST( "weight", 11, r_sourceNumVal, w_sourceNumVal ), YAML_UNSIGNED_CUST( "offset", 11, r_sourceNumVal, w_sourceNumVal ), YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ), @@ -468,7 +468,7 @@ static const struct YamlNode struct_ExpoData[] = { YAML_STRUCT("curve", 16, struct_CurveRef, NULL), YAML_UNSIGNED( "chn", 5 ), YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ), - YAML_UNSIGNED( "spare", 2 ), + YAML_PADDING( 2 ), YAML_STRING("name", 6), YAML_END }; @@ -865,6 +865,7 @@ static const struct YamlNode struct_ModelData[] = { YAML_ARRAY("telemetrySensors", 112, 60, struct_TelemetrySensor, NULL), YAML_ARRAY("screenData", 6816, 10, struct_CustomScreenData, NULL), YAML_STRUCT("topbarData", 3552, struct_TopBarPersistentData, NULL), + YAML_ARRAY("topbarWidgetWidth", 8, 6, struct_unsigned_8, NULL), YAML_UNSIGNED( "view", 8 ), YAML_STRING("modelRegistrationID", 8), YAML_UNSIGNED( "usbJoystickExtMode", 1 ), diff --git a/radio/src/storage/yaml/yaml_datastructs_x9d.cpp b/radio/src/storage/yaml/yaml_datastructs_x9d.cpp index 05b4e35a838..81a77893d32 100644 --- a/radio/src/storage/yaml/yaml_datastructs_x9d.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_x9d.cpp @@ -402,7 +402,7 @@ static const struct YamlNode struct_MixData[] = { YAML_ENUM("mltpx", 2, enum_MixerMultiplex), YAML_UNSIGNED( "speedPrec", 1 ), YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ), - YAML_UNSIGNED( "spare", 2 ), + YAML_PADDING( 2 ), YAML_UNSIGNED_CUST( "weight", 11, r_sourceNumVal, w_sourceNumVal ), YAML_UNSIGNED_CUST( "offset", 11, r_sourceNumVal, w_sourceNumVal ), YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ), @@ -439,7 +439,7 @@ static const struct YamlNode struct_ExpoData[] = { YAML_STRUCT("curve", 16, struct_CurveRef, NULL), YAML_UNSIGNED( "chn", 5 ), YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ), - YAML_UNSIGNED( "spare", 2 ), + YAML_PADDING( 2 ), YAML_STRING("name", 6), YAML_END }; diff --git a/radio/src/storage/yaml/yaml_datastructs_x9e.cpp b/radio/src/storage/yaml/yaml_datastructs_x9e.cpp index b60ad2d93b4..2c8e9a7e541 100644 --- a/radio/src/storage/yaml/yaml_datastructs_x9e.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_x9e.cpp @@ -403,7 +403,7 @@ static const struct YamlNode struct_MixData[] = { YAML_ENUM("mltpx", 2, enum_MixerMultiplex), YAML_UNSIGNED( "speedPrec", 1 ), YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ), - YAML_UNSIGNED( "spare", 2 ), + YAML_PADDING( 2 ), YAML_UNSIGNED_CUST( "weight", 11, r_sourceNumVal, w_sourceNumVal ), YAML_UNSIGNED_CUST( "offset", 11, r_sourceNumVal, w_sourceNumVal ), YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ), @@ -440,7 +440,7 @@ static const struct YamlNode struct_ExpoData[] = { YAML_STRUCT("curve", 16, struct_CurveRef, NULL), YAML_UNSIGNED( "chn", 5 ), YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ), - YAML_UNSIGNED( "spare", 2 ), + YAML_PADDING( 2 ), YAML_STRING("name", 6), YAML_END }; diff --git a/radio/src/storage/yaml/yaml_datastructs_xlites.cpp b/radio/src/storage/yaml/yaml_datastructs_xlites.cpp index 6299d1c31b1..4f53ac92685 100644 --- a/radio/src/storage/yaml/yaml_datastructs_xlites.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_xlites.cpp @@ -406,7 +406,7 @@ static const struct YamlNode struct_MixData[] = { YAML_ENUM("mltpx", 2, enum_MixerMultiplex), YAML_UNSIGNED( "speedPrec", 1 ), YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ), - YAML_UNSIGNED( "spare", 2 ), + YAML_PADDING( 2 ), YAML_UNSIGNED_CUST( "weight", 11, r_sourceNumVal, w_sourceNumVal ), YAML_UNSIGNED_CUST( "offset", 11, r_sourceNumVal, w_sourceNumVal ), YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ), @@ -443,7 +443,7 @@ static const struct YamlNode struct_ExpoData[] = { YAML_STRUCT("curve", 16, struct_CurveRef, NULL), YAML_UNSIGNED( "chn", 5 ), YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ), - YAML_UNSIGNED( "spare", 2 ), + YAML_PADDING( 2 ), YAML_STRING("name", 6), YAML_END }; diff --git a/radio/src/thirdparty/libopenui/src/choice.cpp b/radio/src/thirdparty/libopenui/src/choice.cpp index a7f82320608..ae2a749e9e9 100644 --- a/radio/src/thirdparty/libopenui/src/choice.cpp +++ b/radio/src/thirdparty/libopenui/src/choice.cpp @@ -80,7 +80,7 @@ std::string Choice::getLabelText() if (val >= 0 && val < (int)values.size()) { text = values[val]; } else { - text = std::to_string(val); + text = std::to_string(val + vmin); } } } diff --git a/radio/src/translations.cpp b/radio/src/translations.cpp index 435446a0ad5..a7abfd650d4 100644 --- a/radio/src/translations.cpp +++ b/radio/src/translations.cpp @@ -1107,6 +1107,7 @@ const char STR_RADIO_INFO_WIDGET[] = TR_RADIO_INFO_WIDGET; const char STR_LOW_BATT_COLOR[] = TR_LOW_BATT_COLOR; const char STR_MID_BATT_COLOR[] = TR_MID_BATT_COLOR; const char STR_HIGH_BATT_COLOR[] = TR_HIGH_BATT_COLOR; +const char STR_WIDGET_SIZE[] = TR_WIDGET_SIZE; #endif const char STR_MIX_SLOW_PREC[] = TR_MIX_SLOW_PREC; diff --git a/radio/src/translations.h b/radio/src/translations.h index 826bbb98077..a37d5fdd7be 100644 --- a/radio/src/translations.h +++ b/radio/src/translations.h @@ -1272,6 +1272,7 @@ extern const char STR_RADIO_INFO_WIDGET[]; extern const char STR_LOW_BATT_COLOR[]; extern const char STR_MID_BATT_COLOR[]; extern const char STR_HIGH_BATT_COLOR[]; +extern const char STR_WIDGET_SIZE[]; #endif extern const char STR_MIX_SLOW_PREC[]; diff --git a/radio/src/translations/cn.h b/radio/src/translations/cn.h index 335664141d6..6d111a8789d 100644 --- a/radio/src/translations/cn.h +++ b/radio/src/translations/cn.h @@ -1302,3 +1302,5 @@ #define TR_LOW_BATT_COLOR "低电量" #define TR_MID_BATT_COLOR "中电量" #define TR_HIGH_BATT_COLOR "高电量" + +#define TR_WIDGET_SIZE "小部件尺寸" diff --git a/radio/src/translations/cz.h b/radio/src/translations/cz.h index b7213a0585b..9f26aec6ad1 100644 --- a/radio/src/translations/cz.h +++ b/radio/src/translations/cz.h @@ -1315,3 +1315,5 @@ #define TR_LOW_BATT_COLOR "Vybitá baterie" #define TR_MID_BATT_COLOR "Středně nabitá baterie" #define TR_HIGH_BATT_COLOR "Plně nabitá baterie" + +#define TR_WIDGET_SIZE "Velikost widgetu" diff --git a/radio/src/translations/da.h b/radio/src/translations/da.h index 4f01b9783ce..a403717620e 100644 --- a/radio/src/translations/da.h +++ b/radio/src/translations/da.h @@ -1315,3 +1315,5 @@ #define TR_LOW_BATT_COLOR "Batteri lavt" #define TR_MID_BATT_COLOR "Batteri medio" #define TR_HIGH_BATT_COLOR "Batteri højt" + +#define TR_WIDGET_SIZE "Widget størrelse" diff --git a/radio/src/translations/de.h b/radio/src/translations/de.h index 2ed11658bda..2c981b13458 100644 --- a/radio/src/translations/de.h +++ b/radio/src/translations/de.h @@ -1306,3 +1306,5 @@ #define TR_LOW_BATT_COLOR "Farbe Akku fast leer" #define TR_MID_BATT_COLOR "Farbe Akku mittel" #define TR_HIGH_BATT_COLOR "Farbe Akku voll" + +#define TR_WIDGET_SIZE "Widget Größe" diff --git a/radio/src/translations/en.h b/radio/src/translations/en.h index 7f47407490a..c63d967f699 100644 --- a/radio/src/translations/en.h +++ b/radio/src/translations/en.h @@ -1301,3 +1301,5 @@ #define TR_LOW_BATT_COLOR "Low battery" #define TR_MID_BATT_COLOR "Mid battery" #define TR_HIGH_BATT_COLOR "High battery" + +#define TR_WIDGET_SIZE "Widget size" diff --git a/radio/src/translations/es.h b/radio/src/translations/es.h index c1ee60eac10..0b59a940a00 100644 --- a/radio/src/translations/es.h +++ b/radio/src/translations/es.h @@ -1303,3 +1303,5 @@ #define TR_LOW_BATT_COLOR "Low battery" #define TR_MID_BATT_COLOR "Mid battery" #define TR_HIGH_BATT_COLOR "High battery" + +#define TR_WIDGET_SIZE "Widget size" diff --git a/radio/src/translations/fi.h b/radio/src/translations/fi.h index db570ab5ec0..3e0f04b9049 100644 --- a/radio/src/translations/fi.h +++ b/radio/src/translations/fi.h @@ -1319,3 +1319,5 @@ #define TR_LOW_BATT_COLOR "Low battery" #define TR_MID_BATT_COLOR "Mid battery" #define TR_HIGH_BATT_COLOR "High battery" + +#define TR_WIDGET_SIZE "Widget size" diff --git a/radio/src/translations/fr.h b/radio/src/translations/fr.h index 52c4ebb116d..bed552e74ec 100644 --- a/radio/src/translations/fr.h +++ b/radio/src/translations/fr.h @@ -1318,3 +1318,5 @@ #define TR_LOW_BATT_COLOR "Low battery" #define TR_MID_BATT_COLOR "Mid battery" #define TR_HIGH_BATT_COLOR "High battery" + +#define TR_WIDGET_SIZE "Taille Widget" diff --git a/radio/src/translations/he.h b/radio/src/translations/he.h index a9678a14f22..234554898fe 100644 --- a/radio/src/translations/he.h +++ b/radio/src/translations/he.h @@ -1302,3 +1302,5 @@ #define TR_LOW_BATT_COLOR "מתח סוללה נמוך" #define TR_MID_BATT_COLOR "מתח סוללה בינוני" #define TR_HIGH_BATT_COLOR "מתח סוללה גבוה" + +#define TR_WIDGET_SIZE "Widget size" diff --git a/radio/src/translations/it.h b/radio/src/translations/it.h index 409b75b49d9..ea4022162b8 100644 --- a/radio/src/translations/it.h +++ b/radio/src/translations/it.h @@ -1280,7 +1280,6 @@ #define TR_RADIO_MENU_TABS "Schede del Menu Radio" #define TR_MODEL_MENU_TABS "Schede del Menu Modello" - #define TR_SELECT_MENU_ALL "Tutto" #define TR_SELECT_MENU_CLR "Pulisci" #define TR_SELECT_MENU_INV "Inverti" @@ -1298,3 +1297,5 @@ #define TR_LOW_BATT_COLOR "Batteria scarica" #define TR_MID_BATT_COLOR "Batteria media" #define TR_HIGH_BATT_COLOR "Batteria carica" + +#define TR_WIDGET_SIZE "Dimensione widget" diff --git a/radio/src/translations/jp.h b/radio/src/translations/jp.h index 61af4f073c1..99bd233cd96 100644 --- a/radio/src/translations/jp.h +++ b/radio/src/translations/jp.h @@ -1302,3 +1302,5 @@ #define TR_LOW_BATT_COLOR "バッテリー低" #define TR_MID_BATT_COLOR "バッテリー中" #define TR_HIGH_BATT_COLOR "バッテリー高" + +#define TR_WIDGET_SIZE "ウィジェットサイズ" diff --git a/radio/src/translations/nl.h b/radio/src/translations/nl.h index 3578fe9927c..b917ef77780 100644 --- a/radio/src/translations/nl.h +++ b/radio/src/translations/nl.h @@ -1309,3 +1309,5 @@ #define TR_LOW_BATT_COLOR "Low battery" #define TR_MID_BATT_COLOR "Mid battery" #define TR_HIGH_BATT_COLOR "High battery" + +#define TR_WIDGET_SIZE "Widget size" diff --git a/radio/src/translations/pl.h b/radio/src/translations/pl.h index 4b198f4dc3d..2213d1a1383 100644 --- a/radio/src/translations/pl.h +++ b/radio/src/translations/pl.h @@ -1302,3 +1302,5 @@ #define TR_LOW_BATT_COLOR "Rozładowana bateria" #define TR_MID_BATT_COLOR "Średni stan baterii" #define TR_HIGH_BATT_COLOR "Naładowana bateria" + +#define TR_WIDGET_SIZE "Rozmiar widżetu" diff --git a/radio/src/translations/pt.h b/radio/src/translations/pt.h index 53afaaffa3d..b3e1c7b5f09 100644 --- a/radio/src/translations/pt.h +++ b/radio/src/translations/pt.h @@ -1306,3 +1306,5 @@ #define TR_LOW_BATT_COLOR "Bateria Baixa" #define TR_MID_BATT_COLOR "Bateria Média" #define TR_HIGH_BATT_COLOR "Bateria Alta" + +#define TR_WIDGET_SIZE "Tamanho do widget" diff --git a/radio/src/translations/ru.h b/radio/src/translations/ru.h index 124e42ca7cd..bc5f7a8be99 100644 --- a/radio/src/translations/ru.h +++ b/radio/src/translations/ru.h @@ -1305,3 +1305,5 @@ #define TR_LOW_BATT_COLOR "Разряженная АКБ" #define TR_MID_BATT_COLOR "Середина АКБ " #define TR_HIGH_BATT_COLOR "Заряженная АКБ" + +#define TR_WIDGET_SIZE "Widget size" diff --git a/radio/src/translations/se.h b/radio/src/translations/se.h index cfb15534749..011407b7a24 100644 --- a/radio/src/translations/se.h +++ b/radio/src/translations/se.h @@ -1337,3 +1337,5 @@ #define TR_LOW_BATT_COLOR "Lågt batteri" #define TR_MID_BATT_COLOR "Medium batteri" #define TR_HIGH_BATT_COLOR "Högt batteri" + +#define TR_WIDGET_SIZE "Widgetstorlek" diff --git a/radio/src/translations/tw.h b/radio/src/translations/tw.h index 671132e344d..62b3e973878 100644 --- a/radio/src/translations/tw.h +++ b/radio/src/translations/tw.h @@ -1307,3 +1307,5 @@ #define TR_LOW_BATT_COLOR "低電量" #define TR_MID_BATT_COLOR "中電量" #define TR_HIGH_BATT_COLOR "高電量" + +#define TR_WIDGET_SIZE "小部件尺寸" diff --git a/radio/src/translations/ua.h b/radio/src/translations/ua.h index 3d09a098265..c6ef6f5bb22 100644 --- a/radio/src/translations/ua.h +++ b/radio/src/translations/ua.h @@ -1301,3 +1301,5 @@ #define TR_LOW_BATT_COLOR "Розряджена батарея" #define TR_MID_BATT_COLOR "Середній заряд батареї" #define TR_HIGH_BATT_COLOR "Заряджена батарея" + +#define TR_WIDGET_SIZE "Розмір віджета"