Skip to content

Commit

Permalink
fix(cpn): Widget name truncation, top bar widget cfg lost if more tha…
Browse files Browse the repository at this point in the history
…n 4 (#4584)
  • Loading branch information
Neil Horne authored Feb 5, 2024
1 parent a40c2b8 commit 7e706b7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
9 changes: 8 additions & 1 deletion companion/src/firmwares/customisation_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions companion/src/firmwares/customisation_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -79,8 +79,6 @@ enum ZoneOptionAlign
ALIGN_LEFT,
ALIGN_CENTER,
ALIGN_RIGHT,

// this one MUST be last
ALIGN_COUNT
};

Expand Down Expand Up @@ -160,6 +158,8 @@ class RadioLayout

struct CustomScreens {
CustomScreenData customScreenData[MAX_CUSTOM_SCREENS];

void clear();
};

static void init(const char * layoutId, CustomScreens & customScreens);
Expand Down
2 changes: 1 addition & 1 deletion companion/src/firmwares/opentx/opentxeeprom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down

0 comments on commit 7e706b7

Please sign in to comment.