/* * 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 * - Romolo Manfredini * - 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. * */ #ifndef _MENUS_H_ #define _MENUS_H_ #include "../../keys.h" #if defined(TRANSLATIONS_FR) #define MENU_COLUMNS 1 #define COLUMN_X 0 #else #define MENU_COLUMNS 2 #endif #define MENU_COLUMN2_X 280 #define MIXES_2ND_COLUMN 100 #define COLUMN_HEADER_X 150 typedef int16_t vertpos_t; typedef evt_t & check_event_t; #define horzpos_t int8_t extern uint8_t menuPageIndex; extern uint8_t menuPageCount; extern uint16_t linesCount; extern vertpos_t menuVerticalPosition; extern horzpos_t menuHorizontalPosition; extern vertpos_t menuVerticalOffset; extern uint8_t calibrationState; // Temporary no highlight extern uint8_t noHighlightCounter; #define NO_HIGHLIGHT() (noHighlightCounter > 0) #define START_NO_HIGHLIGHT() do { noHighlightCounter = 25; } while(0) void drawCheckBox(coord_t x, coord_t y, uint8_t value, LcdFlags attr); typedef bool (*MenuHandlerFunc)(evt_t event); extern MenuHandlerFunc menuHandlers[5]; extern uint8_t menuVerticalPositions[4]; extern uint8_t menuLevel; extern evt_t menuEvent; /// goto given Menu, but substitute current menu in menuStack void chainMenu(MenuHandlerFunc newMenu); /// goto given Menu, store current menu in menuStack void pushMenu(MenuHandlerFunc newMenu); /// return to last menu in menustack void popMenu(); enum EnumTabModel { // e_ModelSelect, e_ModelSetup, CASE_HELI(e_Heli) CASE_FLIGHT_MODES(e_FlightModesAll) e_InputsAll, e_MixAll, e_Limits, CASE_CURVES(e_CurvesAll) CASE_GVARS(e_GVars) e_LogicalSwitches, e_CustomFunctions, #if defined(LUA_MODEL_SCRIPTS) e_CustomScripts, #endif CASE_FRSKY(e_Telemetry) }; bool menuModelSetup(evt_t event); bool menuModelHeli(evt_t event); bool menuModelFlightModesAll(evt_t event); bool menuModelExposAll(evt_t event); bool menuModelMixAll(evt_t event); bool menuModelLimits(evt_t event); bool menuModelCurvesAll(evt_t event); bool menuModelCurveOne(evt_t event); bool menuModelGVars(evt_t event); bool menuModelLogicalSwitches(evt_t event); bool menuModelCustomFunctions(evt_t event); bool menuModelCustomScripts(evt_t event); bool menuModelTelemetry(evt_t event); bool menuModelExpoOne(evt_t event); const MenuHandlerFunc menuTabModel[] = { // menuModelSelect, menuModelSetup, CASE_HELI(menuModelHeli) CASE_FLIGHT_MODES(menuModelFlightModesAll) menuModelExposAll, menuModelMixAll, menuModelLimits, CASE_CURVES(menuModelCurvesAll) #if defined(GVARS) && defined(FLIGHT_MODES) CASE_GVARS(menuModelGVars) #endif menuModelLogicalSwitches, menuModelCustomFunctions, #if defined(LUA_MODEL_SCRIPTS) menuModelCustomScripts, #endif CASE_FRSKY(menuModelTelemetry) CASE_MAVLINK(menuTelemetryMavlinkSetup) CASE_TEMPLATES(menuModelTemplates) }; enum EnumTabDiag { e_Setup, e_Sd, e_GeneralCustomFunctions, e_Trainer, e_Calib, e_Vers, }; bool menuGeneralSetup(evt_t event); bool menuGeneralSdManager(evt_t event); bool menuGeneralCustomFunctions(evt_t event); bool menuGeneralTrainer(evt_t event); bool menuGeneralVersion(evt_t event); bool menuGeneralCalib(evt_t event); static const MenuHandlerFunc menuTabGeneral[] PROGMEM = { menuGeneralSetup, menuGeneralSdManager, menuGeneralCustomFunctions, menuGeneralTrainer, menuGeneralCalib, menuGeneralVersion, }; bool menuFirstCalib(evt_t event); bool menuMainView(evt_t event); bool menuCustomFunctions(evt_t event, CustomFunctionData * functions, CustomFunctionsContext & functionsContext); bool menuModelSelect(evt_t event); bool menuStatisticsView(evt_t event); bool menuStatisticsDebug(evt_t event); bool menuAboutView(evt_t event); bool menuMainViewChannelsMonitor(evt_t event); bool menuChannelsView(evt_t event); bool menuChannelsView(evt_t event); bool menuTextView(evt_t event); #if defined(DEBUG_TRACE_BUFFER) void menuTraceBuffer(evt_t event); #endif typedef uint16_t FlightModesType; extern int8_t checkIncDec_Ret; // global helper vars #define EDIT_SELECT_MENU -1 #define EDIT_SELECT_FIELD 0 #define EDIT_MODIFY_FIELD 1 #define EDIT_MODIFY_STRING 2 extern int8_t s_editMode; // global editmode // checkIncDec flags #define EE_GENERAL 0x01 #define EE_MODEL 0x02 #define NO_INCDEC_MARKS 0x04 #define INCDEC_SWITCH 0x08 #define INCDEC_SOURCE 0x10 #define INCDEC_REP10 0x40 #define NO_DBLKEYS 0x80 // mawrow special values #define TITLE_ROW ((uint8_t)-1) #define HIDDEN_ROW ((uint8_t)-2) struct CheckIncDecStops { const int count; const int stops[]; int min() const { return stops[0]; } int max() const { return stops[count-1]; } bool contains(int value) const { for (int i=0; i 0) REPEAT_LAST_CURSOR_MOVE(0) #define MENU_FIRST_LINE_EDIT (MAXCOL((uint16_t)0) >= HIDDEN_ROW ? (MAXCOL((uint16_t)1) >= HIDDEN_ROW ? 2 : 1) : 0) #define POS_HORZ_INIT(posVert) ((COLATTR(posVert) & NAVIGATION_LINE_BY_LINE) ? -1 : 0) #define EDIT_MODE_INIT 0 // TODO enum typedef int (*FnFuncP) (int x); void drawFunction(FnFuncP fn, int offset=0); uint8_t switchToMix(uint8_t source); #endif // _MENUS_H_