diff --git a/src/lib/LUA/lua.h b/src/lib/LUA/lua.h index ab26f9fd81..3de5f8df38 100644 --- a/src/lib/LUA/lua.h +++ b/src/lib/LUA/lua.h @@ -21,7 +21,7 @@ enum lua_Flags{ struct luaPropertiesCommon { const char* const name; // display name - const crsf_value_type_e type; + crsf_value_type_e type; uint8_t id; // Sequential id assigned by enumeration uint8_t parent; // id of parent folder } PACKED; @@ -115,12 +115,12 @@ struct luaItem_float { } PACKED; struct luaItem_string { - const struct luaPropertiesCommon common; + struct luaPropertiesCommon common; const char* value; } PACKED; struct luaItem_folder { - const struct luaPropertiesCommon common; + struct luaPropertiesCommon common; char* dyn_name; } PACKED; @@ -138,6 +138,9 @@ uint8_t getLuaWarningFlags(void); void luaRegisterDevicePingCallback(void (*callback)()); #endif +#define LUA_FIELD_HIDE(fld) { fld.common.type = (crsf_value_type_e)((uint8_t)fld.common.type | CRSF_FIELD_HIDDEN); } +#define LUA_FIELD_SHOW(fld) { fld.common.type = (crsf_value_type_e)((uint8_t)fld.common.type & ~CRSF_FIELD_HIDDEN); } + void sendLuaCommandResponse(struct luaItem_command *cmd, luaCmdStep_e step, const char *message); extern void luaParamUpdateReq(uint8_t type, uint8_t index, uint8_t arg); diff --git a/src/lib/LUA/tx_devLUA.cpp b/src/lib/LUA/tx_devLUA.cpp index 99e6776b99..42fc052664 100644 --- a/src/lib/LUA/tx_devLUA.cpp +++ b/src/lib/LUA/tx_devLUA.cpp @@ -31,8 +31,6 @@ static const char luastrHeadTrackingEnable[] = "Off;On;" STR_LUA_ALLAUX_UPDOWN; static const char luastrHeadTrackingStart[] = STR_LUA_ALLAUX; static const char luastrOffOn[] = "Off;On"; -static const char luastrDisabled[] = "Disabled"; - #define HAS_RADIO (GPIO_PIN_SCK != UNDEF_PIN) static struct luaItem_selection luaAirRate = { @@ -343,21 +341,23 @@ static void luadevUpdateBackpackOpts() if (config.GetBackpackDisable()) { // If backpack is disabled, set all the Backpack select options to "Disabled" - luaDvrAux.options = luastrDisabled; - luaDvrStartDelay.options = luastrDisabled; - luaDvrStopDelay.options = luastrDisabled; - luaHeadTrackingEnableChannel.options = luastrDisabled; - luaHeadTrackingStartChannel.options = luastrDisabled; - luaBackpackTelemetry.options = luastrDisabled; + LUA_FIELD_HIDE(luaDvrAux); + LUA_FIELD_HIDE(luaDvrStartDelay); + LUA_FIELD_HIDE(luaDvrStopDelay); + LUA_FIELD_HIDE(luaHeadTrackingEnableChannel); + LUA_FIELD_HIDE(luaHeadTrackingStartChannel); + LUA_FIELD_HIDE(luaBackpackTelemetry); + LUA_FIELD_HIDE(luaBackpackVersion); } else { - luaDvrAux.options = luastrDvrAux; - luaDvrStartDelay.options = luastrDvrDelay; - luaDvrStopDelay.options = luastrDvrDelay; - luaHeadTrackingEnableChannel.options = luastrHeadTrackingEnable; - luaHeadTrackingStartChannel.options = luastrHeadTrackingStart; - luaBackpackTelemetry.options = luastrOffOn; + LUA_FIELD_SHOW(luaDvrAux); + LUA_FIELD_SHOW(luaDvrStartDelay); + LUA_FIELD_SHOW(luaDvrStopDelay); + LUA_FIELD_SHOW(luaHeadTrackingEnableChannel); + LUA_FIELD_SHOW(luaHeadTrackingStartChannel); + LUA_FIELD_SHOW(luaBackpackTelemetry); + LUA_FIELD_SHOW(luaBackpackVersion); } }