Skip to content

Commit

Permalink
Hide backpack items instead of changing the text
Browse files Browse the repository at this point in the history
  • Loading branch information
CapnBry committed Oct 2, 2023
1 parent ee91f3a commit 1ff9458
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
9 changes: 6 additions & 3 deletions src/lib/LUA/lua.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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);
Expand Down
28 changes: 14 additions & 14 deletions src/lib/LUA/tx_devLUA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 1ff9458

Please sign in to comment.