diff --git a/companion/src/CMakeLists.txt b/companion/src/CMakeLists.txt index 41067bbd4..6db3d9fe9 100644 --- a/companion/src/CMakeLists.txt +++ b/companion/src/CMakeLists.txt @@ -76,7 +76,7 @@ set(COMPANION_SRC_DIRECTORY ${PROJECT_SOURCE_DIR}) add_custom_command( OUTPUT ${RADIO_SRC_DIRECTORY}/bitmaps/sticks.lbm COMMAND make lbm - DEPENDS ${RADIO_SRC_DIRECTORY}/bitmaps/sticks_4x1.xbm + DEPENDS ${RADIO_SRC_DIRECTORY}/bitmaps/sticks.xbm WORKING_DIRECTORY ${RADIO_SRC_DIRECTORY} ) diff --git a/companion/src/firmwares/opentx/opentxTaranisSimulator.cpp b/companion/src/firmwares/opentx/opentxTaranisSimulator.cpp index 8c6318860..a9c303208 100644 --- a/companion/src/firmwares/opentx/opentxTaranisSimulator.cpp +++ b/companion/src/firmwares/opentx/opentxTaranisSimulator.cpp @@ -96,6 +96,7 @@ inline int geteepromsize() { #include "radio/src/vario.cpp" #include "radio/src/gui/menus.cpp" #include "radio/src/gui/menu_model.cpp" +#include "radio/src/gui/menu_model_custom_scripts.cpp" #include "radio/src/gui/menu_model_limits.cpp" #include "radio/src/gui/menu_model_telemetry.cpp" #include "radio/src/gui/menu_general.cpp" diff --git a/companion/src/firmwares/opentx/opentxTaranisX9ESimulator.cpp b/companion/src/firmwares/opentx/opentxTaranisX9ESimulator.cpp index 932a360b7..c50a66de2 100755 --- a/companion/src/firmwares/opentx/opentxTaranisX9ESimulator.cpp +++ b/companion/src/firmwares/opentx/opentxTaranisX9ESimulator.cpp @@ -98,6 +98,7 @@ inline int geteepromsize() { #include "radio/src/vario.cpp" #include "radio/src/gui/menus.cpp" #include "radio/src/gui/menu_model.cpp" +#include "radio/src/gui/menu_model_custom_scripts.cpp" #include "radio/src/gui/menu_model_limits.cpp" #include "radio/src/gui/menu_model_telemetry.cpp" #include "radio/src/gui/menu_general.cpp" diff --git a/radio/src/Makefile b/radio/src/Makefile index df23445de..079ee9636 100644 --- a/radio/src/Makefile +++ b/radio/src/Makefile @@ -365,6 +365,8 @@ M128_VARIANT = +32768 M2561_VARIANT = +16384 EEPROM_VARIANT = 0 +GUIMODELSRC = gui/menu_model.cpp gui/menu_model_limits.cpp gui/menu_model_telemetry.cpp + ifeq ($(PCB), $(filter $(PCB), STD 9X 9XR)) # 9x/9xr radio ARCH = AVR @@ -824,6 +826,7 @@ ifeq ($(PCB), TARANIS) ifneq ($(LUA), NO) ifeq ($(LUA), YES) CPPDEFS += -DLUA_MODEL_SCRIPTS + GUIMODELSRC += gui/menu_model_custom_scripts.cpp endif CPPDEFS += -DLUA INCDIRS += lua/src @@ -901,8 +904,6 @@ else TTS_SRC = $(shell sh -c "if test -f $(STD_TTS_SRC); then echo $(STD_TTS_SRC); else echo translations/tts_en.cpp; fi") endif -GUIMODELSRC = gui/menu_model.cpp gui/menu_model_limits.cpp gui/menu_model_telemetry.cpp - ifeq ($(PCB), TARANIS) GUISRC = gui/menus.cpp $(GUIMODELSRC) gui/menu_general.cpp gui/Taranis/view_main.cpp gui/view_statistics.cpp else diff --git a/radio/src/gui/menu_model.cpp b/radio/src/gui/menu_model.cpp index b001ff636..026c1f19f 100644 --- a/radio/src/gui/menu_model.cpp +++ b/radio/src/gui/menu_model.cpp @@ -5236,166 +5236,6 @@ void menuModelCustomFunctions(uint8_t event) return menuCustomFunctions(event, g_model.customFn, modelFunctionsContext); } -#if defined(LUA_MODEL_SCRIPTS) -void onModelCustomScriptMenu(const char *result) -{ - ScriptData &sd = g_model.scriptsData[s_currIdx]; - - if (result == STR_UPDATE_LIST) { - if (!listSdFiles(SCRIPTS_MIXES_PATH, SCRIPTS_EXT, sizeof(sd.file), NULL)) { - POPUP_WARNING(STR_NO_SCRIPTS_ON_SD); - s_menu_flags = 0; - } - } - else { - // The user choosed a lua file in the list - copySelection(sd.file, result, sizeof(sd.file)); - memset(sd.inputs, 0, sizeof(sd.inputs)); - eeDirty(EE_MODEL); - LUA_LOAD_MODEL_SCRIPT(s_currIdx); - } -} - -enum menuModelCustomScriptItems { - ITEM_MODEL_CUSTOMSCRIPT_FILE, - ITEM_MODEL_CUSTOMSCRIPT_NAME, - ITEM_MODEL_CUSTOMSCRIPT_PARAMS_LABEL, -}; - -#define SCRIPT_ONE_2ND_COLUMN_POS (12*FW) -#define SCRIPT_ONE_3RD_COLUMN_POS (23*FW) - -void menuModelCustomScriptOne(uint8_t event) -{ - TITLE(STR_MENUCUSTOMSCRIPT); - - ScriptData &sd = g_model.scriptsData[s_currIdx]; - - putsStrIdx(lcdLastPos+FW, 0, "LUA", s_currIdx+1, 0); - - SUBMENU_NOTITLE(3+scriptInputsOutputs[s_currIdx].inputsCount, { 0, 0, LABEL(inputs), 0/*repeated*/ }); - - int8_t sub = m_posVert; - - for (uint8_t k=0; k0 ? BLINK|INVERS : INVERS) : 0); - - if (i == ITEM_MODEL_CUSTOMSCRIPT_FILE) { - lcd_putsLeft(y, STR_SCRIPT); - if (ZEXIST(sd.file)) - lcd_putsnAtt(SCRIPT_ONE_2ND_COLUMN_POS, y, sd.file, sizeof(sd.file), attr); - else - lcd_putsiAtt(SCRIPT_ONE_2ND_COLUMN_POS, y, STR_VCSWFUNC, 0, attr); - if (attr && event==EVT_KEY_BREAK(KEY_ENTER) && !READ_ONLY()) { - s_editMode = 0; - if (listSdFiles(SCRIPTS_MIXES_PATH, SCRIPTS_EXT, sizeof(sd.file), sd.file, LIST_NONE_SD_FILE)) { - menuHandler = onModelCustomScriptMenu; - } - else { - POPUP_WARNING(STR_NO_SCRIPTS_ON_SD); - s_menu_flags = 0; - } - } - } - else if (i == ITEM_MODEL_CUSTOMSCRIPT_NAME) { - lcd_putsLeft(y, TR_NAME); - editName(SCRIPT_ONE_2ND_COLUMN_POS, y, sd.name, sizeof(sd.name), event, attr); - } - else if (i == ITEM_MODEL_CUSTOMSCRIPT_PARAMS_LABEL) { - lcd_putsLeft(y, STR_INPUTS); - } - else if (i <= ITEM_MODEL_CUSTOMSCRIPT_PARAMS_LABEL+scriptInputsOutputs[s_currIdx].inputsCount) { - int inputIdx = i-ITEM_MODEL_CUSTOMSCRIPT_PARAMS_LABEL-1; - lcd_putsnAtt(INDENT_WIDTH, y, scriptInputsOutputs[s_currIdx].inputs[inputIdx].name, 10, 0); - if (scriptInputsOutputs[s_currIdx].inputs[inputIdx].type == 0) { - lcd_outdezAtt(SCRIPT_ONE_2ND_COLUMN_POS, y, g_model.scriptsData[s_currIdx].inputs[inputIdx]+scriptInputsOutputs[s_currIdx].inputs[inputIdx].def, attr|LEFT); - if (attr) { - CHECK_INCDEC_MODELVAR(event, g_model.scriptsData[s_currIdx].inputs[inputIdx], scriptInputsOutputs[s_currIdx].inputs[inputIdx].min-scriptInputsOutputs[s_currIdx].inputs[inputIdx].def, scriptInputsOutputs[s_currIdx].inputs[inputIdx].max-scriptInputsOutputs[s_currIdx].inputs[inputIdx].def); - } - } - else { - putsMixerSource(SCRIPT_ONE_2ND_COLUMN_POS, y, g_model.scriptsData[s_currIdx].inputs[inputIdx]+scriptInputsOutputs[s_currIdx].inputs[inputIdx].def, attr); - if (attr) { - uint8_t *source = (uint8_t *)&g_model.scriptsData[s_currIdx].inputs[inputIdx]; - CHECK_INCDEC_MODELSOURCE(event, *source, scriptInputsOutputs[s_currIdx].inputs[inputIdx].min-scriptInputsOutputs[s_currIdx].inputs[inputIdx].def, scriptInputsOutputs[s_currIdx].inputs[inputIdx].max-scriptInputsOutputs[s_currIdx].inputs[inputIdx].def); - } - } - } - } - - if (scriptInputsOutputs[s_currIdx].outputsCount > 0) { - lcd_vline(SCRIPT_ONE_3RD_COLUMN_POS-4, FH+1, LCD_H-FH-1); - lcd_puts(SCRIPT_ONE_3RD_COLUMN_POS, FH+1, STR_OUTPUTS); - - for (int i=0; i= 0) { - s_currIdx = sub; - pushMenu(menuModelCustomScriptOne); - } - break; - } - - for (int i=0, scriptIndex=0; i + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../opentx.h" + +void onModelCustomScriptMenu(const char *result) +{ + ScriptData &sd = g_model.scriptsData[s_currIdx]; + + if (result == STR_UPDATE_LIST) { + if (!listSdFiles(SCRIPTS_MIXES_PATH, SCRIPTS_EXT, sizeof(sd.file), NULL)) { + POPUP_WARNING(STR_NO_SCRIPTS_ON_SD); + s_menu_flags = 0; + } + } + else { + // The user choosed a lua file in the list + copySelection(sd.file, result, sizeof(sd.file)); + memset(sd.inputs, 0, sizeof(sd.inputs)); + eeDirty(EE_MODEL); + LUA_LOAD_MODEL_SCRIPT(s_currIdx); + } +} + +enum menuModelCustomScriptItems { + ITEM_MODEL_CUSTOMSCRIPT_FILE, + ITEM_MODEL_CUSTOMSCRIPT_NAME, + ITEM_MODEL_CUSTOMSCRIPT_PARAMS_LABEL, +}; + +#define SCRIPT_ONE_2ND_COLUMN_POS (12*FW) +#define SCRIPT_ONE_3RD_COLUMN_POS (23*FW) + +void menuModelCustomScriptOne(uint8_t event) +{ + TITLE(STR_MENUCUSTOMSCRIPT); + + ScriptData &sd = g_model.scriptsData[s_currIdx]; + + putsStrIdx(lcdLastPos+FW, 0, "LUA", s_currIdx+1, 0); + + SUBMENU_NOTITLE(3+scriptInputsOutputs[s_currIdx].inputsCount, { 0, 0, LABEL(inputs), 0/*repeated*/ }); + + int8_t sub = m_posVert; + + for (uint8_t k=0; k0 ? BLINK|INVERS : INVERS) : 0); + + if (i == ITEM_MODEL_CUSTOMSCRIPT_FILE) { + lcd_putsLeft(y, STR_SCRIPT); + if (ZEXIST(sd.file)) + lcd_putsnAtt(SCRIPT_ONE_2ND_COLUMN_POS, y, sd.file, sizeof(sd.file), attr); + else + lcd_putsiAtt(SCRIPT_ONE_2ND_COLUMN_POS, y, STR_VCSWFUNC, 0, attr); + if (attr && event==EVT_KEY_BREAK(KEY_ENTER) && !READ_ONLY()) { + s_editMode = 0; + if (listSdFiles(SCRIPTS_MIXES_PATH, SCRIPTS_EXT, sizeof(sd.file), sd.file, LIST_NONE_SD_FILE)) { + menuHandler = onModelCustomScriptMenu; + } + else { + POPUP_WARNING(STR_NO_SCRIPTS_ON_SD); + s_menu_flags = 0; + } + } + } + else if (i == ITEM_MODEL_CUSTOMSCRIPT_NAME) { + lcd_putsLeft(y, TR_NAME); + editName(SCRIPT_ONE_2ND_COLUMN_POS, y, sd.name, sizeof(sd.name), event, attr); + } + else if (i == ITEM_MODEL_CUSTOMSCRIPT_PARAMS_LABEL) { + lcd_putsLeft(y, STR_INPUTS); + } + else if (i <= ITEM_MODEL_CUSTOMSCRIPT_PARAMS_LABEL+scriptInputsOutputs[s_currIdx].inputsCount) { + int inputIdx = i-ITEM_MODEL_CUSTOMSCRIPT_PARAMS_LABEL-1; + lcd_putsnAtt(INDENT_WIDTH, y, scriptInputsOutputs[s_currIdx].inputs[inputIdx].name, 10, 0); + if (scriptInputsOutputs[s_currIdx].inputs[inputIdx].type == 0) { + lcd_outdezAtt(SCRIPT_ONE_2ND_COLUMN_POS, y, g_model.scriptsData[s_currIdx].inputs[inputIdx]+scriptInputsOutputs[s_currIdx].inputs[inputIdx].def, attr|LEFT); + if (attr) { + CHECK_INCDEC_MODELVAR(event, g_model.scriptsData[s_currIdx].inputs[inputIdx], scriptInputsOutputs[s_currIdx].inputs[inputIdx].min-scriptInputsOutputs[s_currIdx].inputs[inputIdx].def, scriptInputsOutputs[s_currIdx].inputs[inputIdx].max-scriptInputsOutputs[s_currIdx].inputs[inputIdx].def); + } + } + else { + putsMixerSource(SCRIPT_ONE_2ND_COLUMN_POS, y, g_model.scriptsData[s_currIdx].inputs[inputIdx]+scriptInputsOutputs[s_currIdx].inputs[inputIdx].def, attr); + if (attr) { + uint8_t *source = (uint8_t *)&g_model.scriptsData[s_currIdx].inputs[inputIdx]; + CHECK_INCDEC_MODELSOURCE(event, *source, scriptInputsOutputs[s_currIdx].inputs[inputIdx].min-scriptInputsOutputs[s_currIdx].inputs[inputIdx].def, scriptInputsOutputs[s_currIdx].inputs[inputIdx].max-scriptInputsOutputs[s_currIdx].inputs[inputIdx].def); + } + } + } + } + + if (scriptInputsOutputs[s_currIdx].outputsCount > 0) { + lcd_vline(SCRIPT_ONE_3RD_COLUMN_POS-4, FH+1, LCD_H-FH-1); + lcd_puts(SCRIPT_ONE_3RD_COLUMN_POS, FH+1, STR_OUTPUTS); + + for (int i=0; i= 0) { + s_currIdx = sub; + pushMenu(menuModelCustomScriptOne); + } + break; + } + + for (int i=0, scriptIndex=0; i