/* * 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" #define MENU_COLUMN2_X 280 #define MIXES_2ND_COLUMN 140 #define COLUMN_HEADER_X 150 extern uint8_t menuPageIndex; extern uint8_t menuPageCount; extern uint16_t linesCount; extern uint8_t linesDisplayed; extern int menuVerticalPosition; extern int menuHorizontalPosition; extern int menuVerticalOffset; extern uint8_t menuCalibrationState; // Temporary no highlight extern uint8_t noHighlightCounter; #define NO_HIGHLIGHT() (noHighlightCounter > 0) #define START_NO_HIGHLIGHT() do { noHighlightCounter = 25; } while(0) typedef bool (*MenuHandlerFunc)(event_t event); extern MenuHandlerFunc menuHandlers[5]; extern uint8_t menuVerticalPositions[4]; extern uint8_t menuLevel; extern event_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 MenuIcons { ICON_OPENTX, ICON_RADIO, ICON_RADIO_SETUP, ICON_RADIO_SD_BROWSER, ICON_RADIO_GLOBAL_FUNCTIONS, ICON_RADIO_TRAINER, ICON_RADIO_HARDWARE, ICON_RADIO_CALIBRATION, ICON_RADIO_VERSION, ICON_MODEL, ICON_MODEL_SETUP, ICON_MODEL_HELI, ICON_MODEL_FLIGHT_MODES, ICON_MODEL_INPUTS, ICON_MODEL_MIXER, ICON_MODEL_OUTPUTS, ICON_MODEL_CURVES, ICON_MODEL_GVARS, ICON_MODEL_LOGICAL_SWITCHES, ICON_MODEL_SPECIAL_FUNCTIONS, ICON_MODEL_LUA_SCRIPTS, ICON_MODEL_TELEMETRY, ICON_THEME, ICON_THEME_SETUP, ICON_THEME_VIEW1, ICON_THEME_VIEW2, ICON_THEME_VIEW3, ICON_THEME_VIEW4, ICON_THEME_VIEW5, ICON_THEME_ADD_VIEW, ICON_STATS, ICON_STATS_THROTTLE_GRAPH, ICON_STATS_TIMERS, ICON_STATS_ANALOGS, ICON_STATS_DEBUG, ICON_MONITOR, ICON_MONITOR_CHANNELS1, ICON_MONITOR_CHANNELS2, ICON_MONITOR_CHANNELS3, ICON_MONITOR_CHANNELS4, ICON_MONITOR_LOGICAL_SWITCHES, MENUS_ICONS_COUNT }; enum EnumTabModel { MENU_MODEL_SETUP, CASE_HELI(MENU_MODEL_HELI) CASE_FLIGHT_MODES(MENU_MODEL_FLIGHT_MODES) MENU_MODEL_INPUTS, MENU_MODEL_MIXES, MENU_MODEL_OUTPUTS, MENU_MODEL_CURVES, CASE_GVARS(MENU_MODEL_GVARS) MENU_MODEL_LOGICAL_SWITCHES, MENU_MODEL_SPECIAL_FUNCTIONS, #if defined(LUA_MODEL_SCRIPTS) MENU_MODEL_CUSTOM_SCRIPTS, #endif CASE_FRSKY(MENU_MODEL_TELEMETRY_FRSKY) MENU_MODEL_PAGES_COUNT }; const uint8_t RADIO_ICONS[] = { ICON_RADIO, ICON_RADIO_SETUP, ICON_RADIO_SD_BROWSER, ICON_RADIO_GLOBAL_FUNCTIONS, ICON_RADIO_TRAINER, ICON_RADIO_HARDWARE, ICON_RADIO_VERSION }; const uint8_t MODEL_ICONS[] = { ICON_MODEL, ICON_MODEL_SETUP, CASE_HELI(ICON_MODEL_HELI) CASE_FLIGHT_MODES(ICON_MODEL_FLIGHT_MODES) ICON_MODEL_INPUTS, ICON_MODEL_MIXER, ICON_MODEL_OUTPUTS, ICON_MODEL_CURVES, CASE_GVARS(ICON_MODEL_GVARS) ICON_MODEL_LOGICAL_SWITCHES, ICON_MODEL_SPECIAL_FUNCTIONS, #if defined(LUA_MODEL_SCRIPTS) ICON_MODEL_LUA_SCRIPTS, #endif ICON_MODEL_TELEMETRY }; const uint8_t STATS_ICONS[] = { ICON_STATS, ICON_STATS_THROTTLE_GRAPH, ICON_STATS_DEBUG, ICON_STATS_ANALOGS, #if defined(DEBUG_TRACE_BUFFER) ICON_STATS_TIMERS #endif }; const uint8_t MONITOR_ICONS[] = { ICON_MONITOR, ICON_MONITOR_CHANNELS1, ICON_MONITOR_CHANNELS2, ICON_MONITOR_CHANNELS3, ICON_MONITOR_CHANNELS4, ICON_MONITOR_LOGICAL_SWITCHES }; bool menuModelSetup(event_t event); bool menuModelFailsafe(event_t event); bool menuModelHeli(event_t event); bool menuModelFlightModesAll(event_t event); bool menuModelExposAll(event_t event); bool menuModelMixAll(event_t event); bool menuModelLimits(event_t event); bool menuModelCurvesAll(event_t event); bool menuModelCurveOne(event_t event); bool menuModelGVars(event_t event); bool menuModelLogicalSwitches(event_t event); bool menuModelSpecialFunctions(event_t event); bool menuModelCustomScripts(event_t event); bool menuModelTelemetryFrsky(event_t event); bool menuModelExpoOne(event_t event); extern const MenuHandlerFunc menuTabModel[MENU_MODEL_PAGES_COUNT]; enum EnumTabRadio { MENU_RADIO_SETUP, MENU_RADIO_SD_MANAGER, MENU_RADIO_SPECIAL_FUNCTIONS, MENU_RADIO_TRAINER, MENU_RADIO_HARDWARE, MENU_RADIO_VERSION, MENU_RADIO_PAGES_COUNT }; bool menuRadioSetup(event_t event); bool menuRadioSdManager(event_t event); bool menuRadioSpecialFunctions(event_t event); bool menuRadioTrainer(event_t event); bool menuRadioVersion(event_t event); bool menuRadioHardware(event_t event); bool menuRadioCalibration(event_t event); extern const MenuHandlerFunc menuTabGeneral[MENU_RADIO_PAGES_COUNT]; enum MenuRadioIndexes { e_StatsGraph, e_StatsDebug, e_StatsAnalogs, #if defined(DEBUG_TRACE_BUFFER) e_StatsTraces, #endif }; bool menuStatsGraph(event_t event); bool menuStatsDebug(event_t event); bool menuStatsAnalogs(event_t event); bool menuStatsTraces(event_t event); static const MenuHandlerFunc menuTabStats[] = { menuStatsGraph, menuStatsDebug, menuStatsAnalogs, #if defined(DEBUG_TRACE_BUFFER) menuStatsTraces, #endif }; enum EnumTabMonitors { e_MonChannelsFirst, e_MonChannels1 = e_MonChannelsFirst, e_MonChannels2, e_MonChannels3, e_MonChannels4, e_MonLogicalSwitches, e_MonTabChannelsPagesCount }; extern const MenuHandlerFunc menuTabMonitors[e_MonTabChannelsPagesCount]; extern uint8_t lastMonitorPage; extern void drawSingleMixerBar(coord_t, coord_t, coord_t, coord_t, uint8_t); extern void drawSingleOutputBar(coord_t, coord_t, coord_t, coord_t, uint8_t); extern const MenuHandlerFunc menuTabScreensSetup[1+MAX_CUSTOM_SCREENS] ; bool menuFirstCalib(event_t event); bool menuMainView(event_t event); bool menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomFunctionsContext & functionsContext); bool menuModelSelect(event_t event); bool menuAboutView(event_t event); bool menuMainViewChannelsMonitor(event_t event); bool menuTextView(event_t event); bool menuScreensTheme(event_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 ? (s < popupMenuNoItems ? s : popupMenuNoItems) : 0) #define POPUP_MENU_START(func) do { popupMenuHandler = (func); AUDIO_KEY_PRESS(); } while(0) #define POPUP_MENU_MAX_LINES 12 #define MENU_MAX_DISPLAY_LINES 9 #define MENU_LINE_LENGTH (LEN_MODEL_NAME+12) #define POPUP_MENU_SET_BSS_FLAG() extern const char * popupMenuItems[POPUP_MENU_MAX_LINES]; extern uint16_t popupMenuNoItems; extern uint16_t popupMenuOffset; enum { MENU_OFFSET_INTERNAL, MENU_OFFSET_EXTERNAL }; extern uint8_t popupMenuOffsetType; extern uint8_t s_menu_item; const char * runPopupMenu(event_t event); extern void (*popupMenuHandler)(const char * result); #define TEXT_FILENAME_MAXLEN 40 extern char s_text_file[TEXT_FILENAME_MAXLEN]; void pushMenuTextView(const char * filename); void pushModelNotes(); void readModelNotes(); #define LABEL(...) (uint8_t)-1 #define CURSOR_MOVED_LEFT(event) (event==EVT_ROTARY_LEFT || EVT_KEY_MASK(event) == KEY_LEFT) #define CURSOR_MOVED_RIGHT(event) (event==EVT_ROTARY_RIGHT || EVT_KEY_MASK(event) == KEY_RIGHT) #define REPEAT_LAST_CURSOR_MOVE(last, refresh) { if (CURSOR_MOVED_RIGHT(event)) menuHorizontalPosition = (menuHorizontalPosition >= (last) ? 0 : menuHorizontalPosition + 1); else menuHorizontalPosition = (menuHorizontalPosition <= (0) ? last : menuHorizontalPosition - 1); if (refresh) putEvent(EVT_REFRESH); } #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); void onSourceLongEnterPress(const char *result); uint8_t switchToMix(uint8_t source); #endif // _MENUS_H_