fix(nv14): incorrect read/write of module data (#4953)
This commit is contained in:
@@ -83,17 +83,15 @@ AFHDS2ASettings::AFHDS2ASettings(Window* parent, const FlexGridLayout& g,
|
||||
[=](uint8_t v) { md->flysky.mode = v; });
|
||||
|
||||
#if defined(PCBNV14)
|
||||
if (getNV14RfFwVersion() >= 0x1000E) {
|
||||
line = newLine(grid);
|
||||
static const char* _rf_power[] = {"Default", "High"};
|
||||
afhds2RFPowerText = new StaticText(line, rect_t{}, STR_MULTI_RFPOWER);
|
||||
afhds2RFPowerChoice = new Choice(line, rect_t{}, _rf_power, 0, 1,
|
||||
GET_DEFAULT(md->flysky.rfPower),
|
||||
[=](int32_t newValue) -> void {
|
||||
md->flysky.rfPower = newValue;
|
||||
resetPulsesAFHDS2();
|
||||
});
|
||||
}
|
||||
line = newLine(grid);
|
||||
static const char* _rf_power[] = {"Default", "High"};
|
||||
afhds2RFPowerText = new StaticText(line, rect_t{}, STR_MULTI_RFPOWER);
|
||||
afhds2RFPowerChoice = new Choice(line, rect_t{}, _rf_power, 0, 1,
|
||||
GET_DEFAULT(md->flysky.rfPower),
|
||||
[=](int32_t newValue) -> void {
|
||||
md->flysky.rfPower = newValue;
|
||||
resetPulsesAFHDS2();
|
||||
});
|
||||
#endif
|
||||
|
||||
hideAFHDS2Options();
|
||||
@@ -104,10 +102,8 @@ void AFHDS2ASettings::hideAFHDS2Options()
|
||||
afhds2OptionsLabel->hide();
|
||||
afhds2ProtoOpts->hide();
|
||||
#if defined(PCBNV14)
|
||||
if (afhds2RFPowerText != nullptr)
|
||||
afhds2RFPowerText->hide();
|
||||
if (afhds2RFPowerChoice != nullptr)
|
||||
afhds2RFPowerChoice->hide();
|
||||
afhds2RFPowerText->hide();
|
||||
afhds2RFPowerChoice->hide();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -116,23 +112,24 @@ void AFHDS2ASettings::showAFHDS2Options()
|
||||
afhds2OptionsLabel->show();
|
||||
afhds2ProtoOpts->show();
|
||||
#if defined(PCBNV14)
|
||||
if (afhds2RFPowerText != nullptr)
|
||||
afhds2RFPowerText->show();
|
||||
if (afhds2RFPowerChoice != nullptr)
|
||||
{
|
||||
afhds2RFPowerChoice->show();
|
||||
bool showRFPower = (getNV14RfFwVersion() >= 0x1000E);
|
||||
afhds2RFPowerText->show(showRFPower);
|
||||
afhds2RFPowerChoice->show(showRFPower);
|
||||
if (showRFPower && (showRFPower != hasRFPower)) {
|
||||
hasRFPower = showRFPower;
|
||||
lv_event_send(afhds2RFPowerChoice->getLvObj(), LV_EVENT_VALUE_CHANGED, nullptr);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void AFHDS2ASettings::checkEvents() {
|
||||
void AFHDS2ASettings::checkEvents()
|
||||
{
|
||||
Window::checkEvents();
|
||||
update();
|
||||
}
|
||||
|
||||
void AFHDS2ASettings::update()
|
||||
{
|
||||
lastRefresh = get_tmr10ms();
|
||||
if (isModuleAFHDS2A(moduleIdx)) {
|
||||
showAFHDS2Options();
|
||||
} else {
|
||||
|
||||
@@ -31,11 +31,11 @@ class AFHDS2ASettings : public Window, public ModuleOptions
|
||||
uint8_t moduleIdx;
|
||||
ModuleData* md;
|
||||
FlexGridLayout grid;
|
||||
tmr10ms_t lastRefresh = 0;
|
||||
|
||||
Window* afhds2OptionsLabel = nullptr;
|
||||
Window* afhds2ProtoOpts = nullptr;
|
||||
#if defined(PCBNV14)
|
||||
bool hasRFPower = false;
|
||||
Window* afhds2RFPowerText = nullptr;
|
||||
Window* afhds2RFPowerChoice = nullptr;
|
||||
#endif
|
||||
|
||||
@@ -2063,11 +2063,13 @@ static void r_modSubtype(void* user, uint8_t* data, uint32_t bitoffs,
|
||||
md->subType = yaml_parse_enum(enum_ISRM_Subtypes, val, val_len);
|
||||
} else if (isModuleTypeR9MNonAccess(md->type)) {
|
||||
md->subType = yaml_parse_enum(enum_R9M_Subtypes, val, val_len);
|
||||
#if defined(AFHDS3)
|
||||
} else if (md->type == MODULE_TYPE_FLYSKY_AFHDS2A) {
|
||||
// Flysky sub-types have been converted into separate module types
|
||||
auto sub_type = yaml_parse_enum(enum_FLYSKY_Subtypes, val, val_len);
|
||||
if (sub_type == FLYSKY_SUBTYPE_AFHDS3)
|
||||
md->type = MODULE_TYPE_FLYSKY_AFHDS3;
|
||||
#endif
|
||||
} else if (md->type == MODULE_TYPE_MULTIMODULE) {
|
||||
#if defined(MULTIMODULE)
|
||||
// Read type/subType by the book (see MPM documentation)
|
||||
@@ -2128,6 +2130,10 @@ static bool w_modSubtype(void* user, uint8_t* data, uint32_t bitoffs,
|
||||
str = yaml_output_enum(md->subType, enum_DSM2_Subtypes);
|
||||
} else if (md->type == MODULE_TYPE_PPM) {
|
||||
str = yaml_output_enum(md->subType, enum_PPM_Subtypes);
|
||||
} else if (md->type == MODULE_TYPE_FLYSKY_AFHDS2A) {
|
||||
str = yaml_output_enum(FLYSKY_SUBTYPE_AFHDS2A, enum_FLYSKY_Subtypes);
|
||||
} else if (md->type == MODULE_TYPE_FLYSKY_AFHDS3) {
|
||||
str = yaml_output_enum(FLYSKY_SUBTYPE_AFHDS3, enum_FLYSKY_Subtypes);
|
||||
} else {
|
||||
str = yaml_unsigned2str(val);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user