/* * Copyright (C) OpenTX * * Based on code named * th9x - http://code.google.com/p/th9x * er9x - http://code.google.com/p/er9x * gruvin9x - http://code.google.com/p/gruvin9x * * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html * * 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 evt_t & check_event_t; extern uint8_t menuPageIndex; extern uint8_t menuPageCount; extern uint16_t linesCount; extern int menuVerticalPosition; extern int menuHorizontalPosition; extern int 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) 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 EnumTabRadio { e_Setup, e_Sd, e_GeneralCustomFunctions, e_Trainer, e_Hardware, 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 menuGeneralHardware(evt_t event); bool menuGeneralCalib(evt_t event); static const MenuHandlerFunc menuTabGeneral[] PROGMEM = { menuGeneralSetup, menuGeneralSdManager, menuGeneralCustomFunctions, menuGeneralTrainer, menuGeneralHardware, menuGeneralVersion, }; enum EnumTabDiag { e_StatsGraph, e_StatsValue, e_StatsTime, #if defined(LUA) e_StatsLua, #endif #if defined(DEBUG_TRACE_BUFFER) s_StatsDebug, #endif }; bool menuStatsGraph(evt_t event); bool menuStatsValue(evt_t event); bool menuStatsTime(evt_t event); bool menuStatsLua(evt_t event); bool menuStatsDebug(evt_t event); static const MenuHandlerFunc menuTabStats[] PROGMEM = { menuStatsGraph, menuStatsValue, menuStatsTime, #if defined(LUA) menuStatsLua, #endif #if defined(DEBUG_TRACE_BUFFER) menuStatsDebug, #endif }; extern const MenuHandlerFunc menuTabScreensSetup[1+MAX_CUSTOM_SCREENS] PROGMEM; 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 menuAboutView(evt_t event); bool menuMainViewChannelsMonitor(evt_t event); bool menuChannelsView(evt_t event); bool menuChannelsView(evt_t event); bool menuTextView(evt_t event); bool menuScreensTheme(evt_t event); 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 ORPHAN_ROW ((uint8_t)-2) #define HIDDEN_ROW ((uint8_t)-3) #define NAVIGATION_LINE_BY_LINE 0x40 #define CURSOR_ON_LINE() (menuHorizontalPosition<0) 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 x, int y, int width); uint8_t switchToMix(uint8_t source); #endif // _MENUS_H_