From 7e706b73d5336bfa086b32913555bf83c5daa837 Mon Sep 17 00:00:00 2001 From: Neil Horne Date: Mon, 5 Feb 2024 12:23:54 +1100 Subject: [PATCH] fix(cpn): Widget name truncation, top bar widget cfg lost if more than 4 (#4584) --- companion/src/firmwares/customisation_data.cpp | 9 ++++++++- companion/src/firmwares/customisation_data.h | 8 ++++---- companion/src/firmwares/opentx/opentxeeprom.cpp | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/companion/src/firmwares/customisation_data.cpp b/companion/src/firmwares/customisation_data.cpp index ebca3c3b61b..2ecb27a1ec3 100644 --- a/companion/src/firmwares/customisation_data.cpp +++ b/companion/src/firmwares/customisation_data.cpp @@ -132,9 +132,16 @@ bool RadioLayout::CustomScreenData::isEmpty() const return strlen(layoutId) == 0; } +void RadioLayout::CustomScreens::clear() +{ + for (int i = 0; i < MAX_CUSTOM_SCREENS; i++) { + customScreenData[i] = CustomScreenData(); + } +} + void RadioLayout::init(const char* layoutId, CustomScreens& customScreens) { - memset(&customScreens, 0, sizeof(CustomScreens)); + customScreens.clear(); for (int i = 0; i < MAX_CUSTOM_SCREENS; i++) { if (i == 0) diff --git a/companion/src/firmwares/customisation_data.h b/companion/src/firmwares/customisation_data.h index 043707fac47..14a9ecfef62 100644 --- a/companion/src/firmwares/customisation_data.h +++ b/companion/src/firmwares/customisation_data.h @@ -35,9 +35,9 @@ constexpr int MAX_THEME_OPTIONS {5}; constexpr int LEN_ZONE_OPTION_STRING {8}; constexpr int MAX_LAYOUT_ZONES {10}; constexpr int MAX_LAYOUT_OPTIONS {10}; -constexpr int WIDGET_NAME_LEN {10}; +constexpr int WIDGET_NAME_LEN {12}; constexpr int MAX_WIDGET_OPTIONS {5}; -constexpr int MAX_TOPBAR_ZONES {4}; +constexpr int MAX_TOPBAR_ZONES {6}; // max 4 used for portrait constexpr int MAX_TOPBAR_OPTIONS {1}; constexpr int LAYOUT_ID_LEN {12}; @@ -79,8 +79,6 @@ enum ZoneOptionAlign ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT, - - // this one MUST be last ALIGN_COUNT }; @@ -160,6 +158,8 @@ class RadioLayout struct CustomScreens { CustomScreenData customScreenData[MAX_CUSTOM_SCREENS]; + + void clear(); }; static void init(const char * layoutId, CustomScreens & customScreens); diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index ce52b4aad49..d67fc3560b8 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -2940,7 +2940,7 @@ void OpenTxModelData::afterImport() if (version < 220) { // re-initialise as no conversion possible const char * layoutId = "Layout2P1"; // currently all using same default though might change for NV14 RadioLayout::init(layoutId, modelData.customScreens); - memset(&modelData.topBarData, 0, sizeof(TopBarPersistentData)); + modelData.topBarData = TopBarPersistentData(); } }