fix(color): new model may not load radio info and date/time widgets (#6825)
This commit is contained in:
@@ -245,7 +245,7 @@ void ModelData::removeScreenLayout(int idx)
|
|||||||
_screenData[idx] = nullptr;
|
_screenData[idx] = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelData::initScreenData()
|
void ModelData::resetScreenData()
|
||||||
{
|
{
|
||||||
_topbarData.clear();
|
_topbarData.clear();
|
||||||
|
|
||||||
|
|||||||
@@ -831,7 +831,7 @@ PACK(struct ModelData {
|
|||||||
NOBACKUP(uint8_t topbarWidgetWidth[MAX_TOPBAR_ZONES]);
|
NOBACKUP(uint8_t topbarWidgetWidth[MAX_TOPBAR_ZONES]);
|
||||||
NOBACKUP(uint8_t view);
|
NOBACKUP(uint8_t view);
|
||||||
|
|
||||||
void initScreenData();
|
void resetScreenData();
|
||||||
const char* getScreenLayoutId(int screenNum);
|
const char* getScreenLayoutId(int screenNum);
|
||||||
void setScreenLayoutId(int screenNum, const char* s);
|
void setScreenLayoutId(int screenNum, const char* s);
|
||||||
TopBarPersistentData* getTopbarData();
|
TopBarPersistentData* getTopbarData();
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ const LayoutOption defaultLayoutOptions[] = {LAYOUT_COMMON_OPTIONS,
|
|||||||
|
|
||||||
void ZonePersistentData::clear()
|
void ZonePersistentData::clear()
|
||||||
{
|
{
|
||||||
widgetName[0] = 0;
|
widgetName.clear();
|
||||||
widgetData.clear();
|
widgetData.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ WidgetPersistentData* LayoutPersistentData::getWidgetData(int idx)
|
|||||||
|
|
||||||
bool LayoutPersistentData::hasWidget(int idx)
|
bool LayoutPersistentData::hasWidget(int idx)
|
||||||
{
|
{
|
||||||
return zones[idx].widgetName[0] != 0;
|
return !zones[idx].widgetName.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -280,9 +280,8 @@ void LayoutFactory::initPersistentData(int screenNum, bool setDefault) const
|
|||||||
// TODO compiler bug? The CPU freezes ... persistentData->options[i++]
|
// TODO compiler bug? The CPU freezes ... persistentData->options[i++]
|
||||||
// = option->deflt;
|
// = option->deflt;
|
||||||
auto optVal = &layoutData->options[i];
|
auto optVal = &layoutData->options[i];
|
||||||
if (setDefault) {
|
if (setDefault)
|
||||||
memcpy(&optVal->value, &option->deflt, sizeof(LayoutOptionValue));
|
optVal->value.unsignedValue = option->deflt.unsignedValue;
|
||||||
}
|
|
||||||
optVal->type = layoutValueEnumFromType(option->type);
|
optVal->type = layoutValueEnumFromType(option->type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,7 +79,8 @@ void WidgetPersistentData::setDefault(int idx, const WidgetOption* opt, bool for
|
|||||||
if (forced || options[idx].type != optType) {
|
if (forced || options[idx].type != optType) {
|
||||||
// reset to default value
|
// reset to default value
|
||||||
options[idx].type = optType;
|
options[idx].type = optType;
|
||||||
memcpy((void*)&options[idx].value, (void*)&opt->deflt, sizeof(WidgetOptionValue));
|
options[idx].value.unsignedValue = opt->deflt.unsignedValue;
|
||||||
|
options[idx].value.stringValue = opt->deflt.stringValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ void applyDefaultTemplate()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(COLORLCD)
|
#if defined(COLORLCD)
|
||||||
g_model.initScreenData();
|
g_model.resetScreenData();
|
||||||
LayoutFactory::loadDefaultLayout();
|
LayoutFactory::loadDefaultLayout();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -348,7 +348,7 @@ const char * readModelYaml(const char * filename, uint8_t * buffer, uint32_t siz
|
|||||||
initCustomSwitches();
|
initCustomSwitches();
|
||||||
#endif
|
#endif
|
||||||
#if defined(COLORLCD)
|
#if defined(COLORLCD)
|
||||||
g_model.initScreenData();
|
g_model.resetScreenData();
|
||||||
#endif
|
#endif
|
||||||
auto md = reinterpret_cast<ModelData*>(buffer);
|
auto md = reinterpret_cast<ModelData*>(buffer);
|
||||||
#if defined(FLIGHT_MODES) && defined(GVARS)
|
#if defined(FLIGHT_MODES) && defined(GVARS)
|
||||||
|
|||||||
Reference in New Issue
Block a user