From 5a4c6df594ad3608b1b2b61552bbee816898b72b Mon Sep 17 00:00:00 2001 From: Wilhelm Date: Fri, 4 Feb 2022 12:53:14 +0100 Subject: [PATCH] fix: OSK DEF button was not setting Value inputs of mixer scripts correctly (#1536) * The set/reset switches for a logical switch are only processed if the are valid. * Revert "The set/reset switches for a logical switch are only processed if the are valid." This reverts commit c238108415aec39f64ba6bae4c86cfb3ea4713bc. * fix handling of default values in mixer scripts * revised the use of default value to be consistent to the past usage * Limited autoformatting Co-authored-by: Peter Feerick --- radio/src/gui/colorlcd/model_mixer_scripts.cpp | 5 ++--- radio/src/lua/interface.cpp | 7 ++++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/radio/src/gui/colorlcd/model_mixer_scripts.cpp b/radio/src/gui/colorlcd/model_mixer_scripts.cpp index fa97b7d9f..f3e6929fd 100644 --- a/radio/src/gui/colorlcd/model_mixer_scripts.cpp +++ b/radio/src/gui/colorlcd/model_mixer_scripts.cpp @@ -112,9 +112,8 @@ class ScriptEditWindow : public Page { new StaticText(window, grid.getLabelSlot(true), si.name, 0, COLOR_THEME_PRIMARY1); grid.nextLine(); if (si.type == INPUT_TYPE_VALUE) { - new NumberEdit(gInputs, inputsGrid.getSlot(), si.min - si.def, - si.max - si.def, - GET_SET_WITH_OFFSET(sd->inputs[i].value, si.def)); + (new NumberEdit(gInputs, inputsGrid.getSlot(), si.min, si.max, + GET_SET_WITH_OFFSET(sd->inputs[i].value, si.def)))->setDefault(si.def); } else { new SourceChoice(gInputs, inputsGrid.getSlot(), 0, MIXSRC_LAST_TELEM, diff --git a/radio/src/lua/interface.cpp b/radio/src/lua/interface.cpp index 587ae6b41..4e0aba09d 100644 --- a/radio/src/lua/interface.cpp +++ b/radio/src/lua/interface.cpp @@ -1119,12 +1119,13 @@ static bool resumeLua(bool init, bool allowLcdUsage) ScriptData & sd = g_model.scriptsData[ref - SCRIPT_MIX_FIRST]; ScriptInputsOutputs * sio = & scriptInputsOutputs[ref - SCRIPT_MIX_FIRST]; inputsCount = sio -> inputsCount; - + for (int j = 0; j < inputsCount; j++) { - if (sio -> inputs[j].type == INPUT_TYPE_SOURCE) + if (sio->inputs[j].type == INPUT_TYPE_SOURCE) luaGetValueAndPush(lsScripts, sd.inputs[j].source); else - lua_pushinteger(lsScripts, sd.inputs[j].value + sio -> inputs[j].def); + lua_pushinteger(lsScripts, + sd.inputs[j].value + sio->inputs[j].def); } } else #endif