From 13927800e20ef13b822e211520f1a8fdbc82d59c Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Sun, 6 Dec 2015 23:11:42 +0100 Subject: [PATCH] Compilation fix --- .../gui/Horus/menu_model_custom_scripts.cpp | 186 ++++++++++++++++++ 1 file changed, 186 insertions(+) create mode 100644 radio/src/gui/Horus/menu_model_custom_scripts.cpp diff --git a/radio/src/gui/Horus/menu_model_custom_scripts.cpp b/radio/src/gui/Horus/menu_model_custom_scripts.cpp new file mode 100644 index 000000000..45d6fd2ca --- /dev/null +++ b/radio/src/gui/Horus/menu_model_custom_scripts.cpp @@ -0,0 +1,186 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - 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 (!sdListFiles(SCRIPTS_MIXES_PATH, SCRIPTS_EXT, sizeof(sd.file), NULL)) { + POPUP_WARNING(STR_NO_SCRIPTS_ON_SD); + } + } + else { + // The user choosed a lua file in the list + copySelection(sd.file, result, sizeof(sd.file)); + memset(sd.inputs, 0, sizeof(sd.inputs)); + storageDirty(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 (120) +#define SCRIPT_ONE_3RD_COLUMN_POS (240) + +bool menuModelCustomScriptOne(evt_t event) +{ + ScriptData &sd = g_model.scriptsData[s_currIdx]; + + // putsStrIdx(lcdLastPos+FW, 0, "LUA", s_currIdx+1, 0); + + SUBMENU(STR_MENUCUSTOMSCRIPT, 3+scriptInputsOutputs[s_currIdx].inputsCount, 0, { 0, 0, LABEL(inputs), 0/*repeated*/ }); + + int8_t sub = menuVerticalPosition; + + for (int k=0; k0 ? BLINK|INVERS : INVERS) : 0); + + if (i == ITEM_MODEL_CUSTOMSCRIPT_FILE) { + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_SCRIPT); + if (ZEXIST(sd.file)) + lcdDrawSizedText(SCRIPT_ONE_2ND_COLUMN_POS, y, sd.file, sizeof(sd.file), attr); + else + lcdDrawTextAtIndex(SCRIPT_ONE_2ND_COLUMN_POS, y, STR_VCSWFUNC, 0, attr); + if (attr && event==EVT_KEY_BREAK(KEY_ENTER) && !READ_ONLY()) { + s_editMode = 0; + if (sdListFiles(SCRIPTS_MIXES_PATH, SCRIPTS_EXT, sizeof(sd.file), sd.file, LIST_NONE_SD_FILE)) { + popupMenuHandler = onModelCustomScriptMenu; + } + else { + POPUP_WARNING(STR_NO_SCRIPTS_ON_SD); + } + } + } + else if (i == ITEM_MODEL_CUSTOMSCRIPT_NAME) { + lcdDrawText(MENUS_MARGIN_LEFT, 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) { + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_INPUTS); + } + else if (i <= ITEM_MODEL_CUSTOMSCRIPT_PARAMS_LABEL+scriptInputsOutputs[s_currIdx].inputsCount) { + int inputIdx = i-ITEM_MODEL_CUSTOMSCRIPT_PARAMS_LABEL-1; + lcdDrawSizedText(INDENT_WIDTH, y, scriptInputsOutputs[s_currIdx].inputs[inputIdx].name, 10, 0); + if (scriptInputsOutputs[s_currIdx].inputs[inputIdx].type == 0) { + lcdDrawNumber(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 { + uint8_t *source = (uint8_t *)&g_model.scriptsData[s_currIdx].inputs[inputIdx]; + putsMixerSource(SCRIPT_ONE_2ND_COLUMN_POS, y, *source + scriptInputsOutputs[s_currIdx].inputs[inputIdx].def, attr); + if (attr) { + 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) { + lcdDrawSolidVerticalLine(SCRIPT_ONE_3RD_COLUMN_POS-4, DEFAULT_SCROLLBAR_Y, DEFAULT_SCROLLBAR_H+5, TEXT_COLOR); + // lcdDrawText(SCRIPT_ONE_3RD_COLUMN_POS, FH+1, STR_OUTPUTS); + + for (int i=0; i