1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-25 17:25:13 +03:00

Module options fix (freeze when no option available)

This commit is contained in:
Bertrand Songis 2019-04-29 00:41:14 +02:00
parent 32639c0c2a
commit 9f1238ca38
2 changed files with 61 additions and 52 deletions

View file

@ -72,16 +72,8 @@ bool isPowerAvailable(int value)
void menuModelModuleOptions(event_t event)
{
uint8_t modelId = reusableBuffer.hardwareAndSettings.modules[g_moduleIdx].information.modelID;
// uint8_t variant = reusableBuffer.hardwareAndSettings.modules[g_moduleIdx].information.variant;
SUBMENU_NOTITLE(ITEM_MODULE_SETTINGS_COUNT, {
IF_MODULE_OPTIONS(MODULE_OPTION_RF_PROTOCOL, 0),
IF_MODULE_OPTIONS(MODULE_OPTION_EXTERNAL_ANTENNA, 0),
IF_MODULE_OPTIONS(MODULE_OPTION_POWER, 0),
});
if (event == EVT_ENTRY) {
memclear(&reusableBuffer.hardwareAndSettings, sizeof(reusableBuffer.hardwareAndSettings));
#if defined(SIMU)
reusableBuffer.hardwareAndSettings.moduleSettings.state = PXX2_SETTINGS_OK;
#else
@ -90,6 +82,17 @@ void menuModelModuleOptions(event_t event)
#endif
}
uint8_t modelId = reusableBuffer.hardwareAndSettings.modules[g_moduleIdx].information.modelID;
// uint8_t variant = reusableBuffer.hardwareAndSettings.modules[g_moduleIdx].information.variant;
uint8_t optionsAvailable = moduleOptions[g_moduleIdx] & ((1 << MODULE_OPTION_RF_PROTOCOL) | (1 << MODULE_OPTION_RF_PROTOCOL) | (1 << MODULE_OPTION_RF_PROTOCOL));
SUBMENU_NOTITLE(ITEM_MODULE_SETTINGS_COUNT, {
!optionsAvailable ? (uint8_t)0 : IF_MODULE_OPTIONS(MODULE_OPTION_RF_PROTOCOL, 0),
IF_MODULE_OPTIONS(MODULE_OPTION_EXTERNAL_ANTENNA, 0),
IF_MODULE_OPTIONS(MODULE_OPTION_POWER, 0),
});
if (reusableBuffer.hardwareAndSettings.moduleSettings.state == PXX2_HARDWARE_INFO && moduleState[g_moduleIdx].mode == MODULE_MODE_NORMAL) {
moduleState[g_moduleIdx].readModuleSettings(&reusableBuffer.hardwareAndSettings.moduleSettings);
}
@ -128,6 +131,7 @@ void menuModelModuleOptions(event_t event)
lcdInvertLine(0);
if (reusableBuffer.hardwareAndSettings.moduleSettings.state == PXX2_SETTINGS_OK) {
if (optionsAvailable) {
for (uint8_t k=0; k<LCD_LINES-1; k++) {
coord_t y = MENU_HEADER_HEIGHT + 1 + k*FH;
uint8_t i = k + menuVerticalOffset;
@ -173,7 +177,13 @@ void menuModelModuleOptions(event_t event)
}
}
}
else {
lcdDrawCenteredText(LCD_H/2, "No TX options");
s_editMode = 0;
}
}
else {
lcdDrawCenteredText(LCD_H/2, "Waiting for TX...");
s_editMode = 0;
}
}

View file

@ -1366,7 +1366,6 @@ void menuModelSetup(event_t event)
lcdDrawText(MODEL_SETUP_2ND_COLUMN, y, STR_SET, attr);
if (event == EVT_KEY_BREAK(KEY_ENTER) && attr) {
g_moduleIdx = CURRENT_MODULE_EDITED(k);
memclear(&reusableBuffer.hardwareAndSettings, sizeof(reusableBuffer.hardwareAndSettings));
pushMenu(menuModelModuleOptions);
}
break;