diff --git a/radio/src/gui/128x64/model_logical_switches.cpp b/radio/src/gui/128x64/model_logical_switches.cpp index 05dac43eb..cebf9c9a2 100644 --- a/radio/src/gui/128x64/model_logical_switches.cpp +++ b/radio/src/gui/128x64/model_logical_switches.cpp @@ -102,7 +102,7 @@ void menuModelLogicalSwitchOne(event_t event) int v1_min=0, v1_max=MIXSRC_LAST_TELEM; if (cstate == LS_FAMILY_BOOL || cstate == LS_FAMILY_STICKY || cstate == LS_FAMILY_EDGE) { drawSwitch(CSWONE_2ND_COLUMN, y, v1_val, attr); - v1_min = SWSRC_OFF+1; v1_max = SWSRC_ON-1; + v1_min = SWSRC_FIRST_IN_LOGICAL_SWITCHES; v1_max = SWSRC_LAST_IN_LOGICAL_SWITCHES; INCDEC_SET_FLAG(EE_MODEL | INCDEC_SWITCH); INCDEC_ENABLE_CHECK(isSwitchAvailableInLogicalSwitches); } @@ -130,7 +130,7 @@ void menuModelLogicalSwitchOne(event_t event) int16_t v2_min = 0, v2_max = MIXSRC_LAST_TELEM; if (cstate == LS_FAMILY_BOOL || cstate == LS_FAMILY_STICKY) { drawSwitch(CSWONE_2ND_COLUMN, y, cs->v2, attr); - v2_min = SWSRC_OFF+1; v2_max = SWSRC_ON-1; + v2_min = SWSRC_FIRST_IN_LOGICAL_SWITCHES; v2_max = SWSRC_LAST_IN_LOGICAL_SWITCHES; INCDEC_SET_FLAG(EE_MODEL | INCDEC_SWITCH); INCDEC_ENABLE_CHECK(isSwitchAvailableInLogicalSwitches); } diff --git a/radio/src/lua/api_model.cpp b/radio/src/lua/api_model.cpp index 0dbd3c05e..b04437a2e 100644 --- a/radio/src/lua/api_model.cpp +++ b/radio/src/lua/api_model.cpp @@ -860,9 +860,9 @@ Set Curve parameters @param curve (unsigned number) curve number (use 0 for Curve1) @param params see model.getCurve return format for table format. setCurve uses standard - lua array indexing and array start at index 1 + lua array indexing and arrays start at index 1 -The first and last x value must 0 and 100 and x values must be monotonically increasing +The first and last x value must -100 and 100 and x values must be monotonically increasing @retval 0 - Everything okay 1 - Wrong number of points @@ -879,15 +879,15 @@ The first and last x value must 0 and 100 and x values must be monotonically inc Example setting a 4-point custom curve: ```lua params = {} - params["x"] = {0, 34, 77, 100} + params["x"] = {-100, -34, 77, 100} params["y"] = {-70, 20, -89, -100} - params["smooth"] = 1 + params["smooth"] = true params["type"] = 1 val = model.setCurve(2, params) ``` setting a 6-point standard smoothed curve ```lua - val = model.setCurve(3, {smooth=1, y={-100, -50, 0, 50, 100, 80}}) + val = model.setCurve(3, {smooth=true, y={-100, -50, 0, 50, 100, 80}}) ``` */ @@ -923,7 +923,12 @@ static int luaModelSetCurve(lua_State *L) newCurveData.type = luaL_checkinteger(L, -1); } else if (!strcmp(key, "smooth")) { - newCurveData.smooth = luaL_checkinteger(L, -1); + // Earlier version of this api expected a 0/1 integer instead of a boolean + // Still accept a 0/1 here + if (lua_isboolean(L,-1)) + newCurveData.smooth = lua_toboolean(L, -1); + else + newCurveData.smooth = luaL_checkinteger(L, -1); } else if (!strcmp(key, "x") || !strcmp(key, "y")) { luaL_checktype(L, -1, LUA_TTABLE); @@ -972,7 +977,7 @@ static int luaModelSetCurve(lua_State *L) } // Check first and last point - if (xPoints[0] != 0 || xPoints[newCurveData.points + 4] != 100) { + if (xPoints[0] != -100 || xPoints[newCurveData.points + 4] != 100) { lua_pushinteger(L, 5); return 1; } diff --git a/radio/src/lua/interface.cpp b/radio/src/lua/interface.cpp index d16c3658c..513d0ce8e 100644 --- a/radio/src/lua/interface.cpp +++ b/radio/src/lua/interface.cpp @@ -633,6 +633,9 @@ bool luaLoadMixScript(uint8_t index) bool luaLoadFunctionScript(uint8_t index, uint8_t ref) { + if ((ref >= SCRIPT_GFUNC_FIRST) && g_model.noGlobalFunctions) + return false; + CustomFunctionData & fn = (ref < SCRIPT_GFUNC_FIRST ? g_model.customFn[index] : g_eeGeneral.customFn[index]); if (fn.func == FUNC_PLAY_SCRIPT && ZEXIST(fn.play.name)) {