Files movement continued (GUI finished). I will do the same for LCD

functions where we have too many ifdef
This commit is contained in:
bsongis
2015-01-18 14:26:44 +01:00
parent 35207ce6f6
commit 64d4219bfb
47 changed files with 1221 additions and 3403 deletions
+165
View File
@@ -0,0 +1,165 @@
/*
* Authors (alphabetical order)
* - Andre Bernet <bernet.andre@gmail.com>
* - Andreas Weitl
* - Bertrand Songis <bsongis@gmail.com>
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
* - Cameron Weeks <th9xer@gmail.com>
* - Erez Raviv
* - Gabriel Birkus
* - Jean-Pierre Parisy
* - Karl Szmutny
* - Michael Blandford
* - Michal Hlavinka
* - Pat Mackenzie
* - Philip Moss
* - Rob Thomson
* - Romolo Manfredini <romolo.manfredini@gmail.com>
* - 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"
const pm_uchar font_5x7[] PROGMEM = {
#if defined (CPUARM)
#include "font_05x07.lbm"
#else
#include "font_05x07_avr.lbm"
#endif
#if defined(TRANSLATIONS_DE)
#include "font_de_05x07.lbm"
#elif defined(TRANSLATIONS_CZ)
#include "font_cz_05x07.lbm"
#elif defined(TRANSLATIONS_ES)
#include "font_es_05x07.lbm"
#elif defined(TRANSLATIONS_FI)
#include "font_fi_05x07.lbm"
#elif defined(TRANSLATIONS_FR)
#include "font_fr_05x07.lbm"
#elif defined(TRANSLATIONS_IT)
#include "font_it_05x07.lbm"
#elif defined(TRANSLATIONS_PL)
#include "font_pl_05x07.lbm"
#elif defined(TRANSLATIONS_PT)
#include "font_pt_05x07.lbm"
#elif defined(TRANSLATIONS_SE)
#include "font_se_05x07.lbm"
#endif
};
#if defined(BOLD_FONT) && (!defined(CPUM64) || defined(EXTSTD))
const pm_uchar font_5x7_B[] PROGMEM = {
#include "font_05x07_B_compressed.lbm"
};
#endif
#if !defined(BOOT)
const pm_uchar font_10x14[] PROGMEM = {
#include "font_10x14_compressed.lbm"
#if defined(CPUARM)
#if defined(TRANSLATIONS_DE)
#include "font_de_10x14.lbm"
#elif defined(TRANSLATIONS_CZ)
#include "font_cz_10x14.lbm"
#elif defined(TRANSLATIONS_ES)
#include "font_es_10x14.lbm"
#elif defined(TRANSLATIONS_FI)
#include "font_fi_10x14.lbm"
#elif defined(TRANSLATIONS_FR)
#include "font_fr_10x14.lbm"
#elif defined(TRANSLATIONS_IT)
#include "font_it_10x14.lbm"
#elif defined(TRANSLATIONS_PL)
#include "font_pl_10x14.lbm"
#elif defined(TRANSLATIONS_PT)
#include "font_pt_10x14.lbm"
#elif defined(TRANSLATIONS_SE)
#include "font_se_10x14.lbm"
#endif
#endif
};
#endif
#if defined(CPUARM) && !defined(BOOT)
const pm_uchar font_3x5[] PROGMEM = {
#include "font_03x05.lbm"
};
const pm_uchar font_4x6[] PROGMEM = {
#include "font_04x06.lbm"
#if defined(TRANSLATIONS_DE)
#include "font_de_04x06.lbm"
#elif defined(TRANSLATIONS_CZ)
#include "font_cz_04x06.lbm"
#elif defined(TRANSLATIONS_ES)
#include "font_es_04x06.lbm"
#elif defined(TRANSLATIONS_FI)
#include "font_fi_04x06.lbm"
#elif defined(TRANSLATIONS_FR)
#include "font_fr_04x06.lbm"
#elif defined(TRANSLATIONS_IT)
#include "font_it_04x06.lbm"
#elif defined(TRANSLATIONS_PL)
#include "font_pl_04x06.lbm"
#elif defined(TRANSLATIONS_PT)
#include "font_pt_04x06.lbm"
#elif defined(TRANSLATIONS_SE)
#include "font_se_04x06.lbm"
#endif
};
const pm_uchar font_8x10[] PROGMEM = {
#include "font_08x10.lbm"
#if defined(TRANSLATIONS_DE)
#include "font_de_08x10.lbm"
#elif defined(TRANSLATIONS_CZ)
#include "font_cz_08x10.lbm"
#elif defined(TRANSLATIONS_ES)
#include "font_es_08x10.lbm"
#elif defined(TRANSLATIONS_FI)
#include "font_fi_08x10.lbm"
#elif defined(TRANSLATIONS_FR)
#include "font_fr_08x10.lbm"
#elif defined(TRANSLATIONS_IT)
#include "font_it_08x10.lbm"
#elif defined(TRANSLATIONS_PL)
#include "font_pl_08x10.lbm"
#elif defined(TRANSLATIONS_PT)
#include "font_pt_08x10.lbm"
#elif defined(TRANSLATIONS_SE)
#include "font_se_08x10.lbm"
#endif
};
const pm_uchar font_22x38_num[] PROGMEM = {
#include "font_22x38_num.lbm"
};
const pm_uchar font_4x6_extra[] PROGMEM = {
#include "font_04x06_extra.lbm"
};
const pm_uchar font_5x7_extra[] PROGMEM = {
#include "font_05x07_extra.lbm"
};
const pm_uchar font_10x14_extra[] PROGMEM = {
#include "font_10x14_extra.lbm"
};
#endif // defined(CPUARM) && !defined(BOOT)
+2
View File
@@ -34,6 +34,8 @@
*
*/
#include "menus.h"
#define NUM_BODY_LINES LCD_LINES-1
#define MENU_TITLE_HEIGHT FH
#define MENU_NAVIG_HEIGHT 0
+109
View File
@@ -0,0 +1,109 @@
/*
* Authors (alphabetical order)
* - Andre Bernet <bernet.andre@gmail.com>
* - Andreas Weitl
* - Bertrand Songis <bsongis@gmail.com>
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
* - Cameron Weeks <th9xer@gmail.com>
* - Erez Raviv
* - Gabriel Birkus
* - Jean-Pierre Parisy
* - Karl Szmutny
* - Michael Blandford
* - Michal Hlavinka
* - Pat Mackenzie
* - Philip Moss
* - Rob Thomson
* - Romolo Manfredini <romolo.manfredini@gmail.com>
* - 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"
#if defined(CPUARM)
extern LP_CONST LanguagePack czLanguagePack;
extern LP_CONST LanguagePack enLanguagePack;
extern LP_CONST LanguagePack esLanguagePack;
extern LP_CONST LanguagePack frLanguagePack;
extern LP_CONST LanguagePack deLanguagePack;
extern LP_CONST LanguagePack itLanguagePack;
extern LP_CONST LanguagePack plLanguagePack;
extern LP_CONST LanguagePack ptLanguagePack;
extern LP_CONST LanguagePack skLanguagePack;
extern LP_CONST LanguagePack seLanguagePack;
extern LP_CONST LanguagePack huLanguagePack;
const LanguagePack * LP_CONST languagePacks[] = {
// alphabetical order
&czLanguagePack,
&deLanguagePack,
&enLanguagePack,
&esLanguagePack,
&frLanguagePack,
&huLanguagePack,
&itLanguagePack,
&plLanguagePack,
&ptLanguagePack,
&seLanguagePack,
&skLanguagePack,
NULL
};
#endif
void menuGeneralSetup(uint8_t event);
void menuGeneralSdManager(uint8_t event);
void menuGeneralCustomFunctions(uint8_t event);
void menuGeneralTrainer(uint8_t event);
void menuGeneralVersion(uint8_t event);
void menuGeneralDiagKeys(uint8_t event);
void menuGeneralDiagAna(uint8_t event);
void menuGeneralHardware(uint8_t event);
void menuGeneralCalib(uint8_t event);
enum EnumTabDiag {
e_Setup,
CASE_SDCARD(e_Sd)
CASE_CPUARM(e_GeneralCustomFunctions)
e_Trainer,
e_Vers,
e_Keys,
e_Ana,
CASE_CPUARM(e_Hardware)
e_Calib
};
const MenuFuncP_PROGMEM menuTabGeneral[] PROGMEM = {
menuGeneralSetup,
CASE_SDCARD(menuGeneralSdManager)
CASE_CPUARM(menuGeneralCustomFunctions)
menuGeneralTrainer,
menuGeneralVersion,
menuGeneralDiagKeys,
menuGeneralDiagAna,
CASE_CPUARM(menuGeneralHardware)
menuGeneralCalib
};
#if defined(CPUARM)
void menuGeneralCustomFunctions(uint8_t event)
{
MENU(STR_MENUGLOBALFUNCS, menuTabGeneral, e_GeneralCustomFunctions, NUM_CFN+1, {0, NAVIGATION_LINE_BY_LINE|4/*repeated*/});
return menuCustomFunctions(event, g_eeGeneral.customFn, globalFunctionsContext);
}
#endif
+224
View File
@@ -0,0 +1,224 @@
/*
* Authors (alphabetical order)
* - Andre Bernet <bernet.andre@gmail.com>
* - Andreas Weitl
* - Bertrand Songis <bsongis@gmail.com>
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
* - Cameron Weeks <th9xer@gmail.com>
* - 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"
#if defined(MAVLINK)
#include "view_mavlink.h"
#endif
// TODO elsewhere!
#define WCHART (LCD_H/2)
#define X0 (LCD_W-WCHART-2)
#define Y0 (LCD_H/2)
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)
e_LogicalSwitches,
e_CustomFunctions,
CASE_FRSKY(e_Telemetry)
CASE_MAVLINK(e_MavSetup)
CASE_TEMPLATES(e_Templates)
};
void menuModelSelect(uint8_t event);
void menuModelSetup(uint8_t event);
void menuModelHeli(uint8_t event);
void menuModelFlightModesAll(uint8_t event);
void menuModelExposAll(uint8_t event);
void menuModelMixAll(uint8_t event);
void menuModelLimits(uint8_t event);
void menuModelCurvesAll(uint8_t event);
void menuModelCurveOne(uint8_t event);
void menuModelGVars(uint8_t event);
void menuModelLogicalSwitches(uint8_t event);
void menuModelCustomFunctions(uint8_t event);
void menuModelTelemetry(uint8_t event);
void menuModelTemplates(uint8_t event);
void menuModelExpoOne(uint8_t event);
extern uint8_t s_curveChan;
#if defined(CPUARM)
#define FlightModesType uint16_t
#else
#define FlightModesType uint8_t
#endif
#if LCD_W >= 212
#define MIXES_2ND_COLUMN (18*FW)
#else
#define MIXES_2ND_COLUMN (12*FW)
#endif
uint8_t editDelay(const coord_t y, const uint8_t event, const uint8_t attr, const pm_char *str, uint8_t delay)
{
lcd_putsLeft(y, str);
lcd_outdezAtt(MIXES_2ND_COLUMN, y, (10/DELAY_STEP)*delay, attr|PREC1|LEFT);
if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, delay, DELAY_MAX);
return delay;
}
#define EDIT_DELAY(x, y, event, attr, str, delay) editDelay(y, event, attr, str, delay)
const MenuFuncP_PROGMEM menuTabModel[] PROGMEM = {
menuModelSelect,
menuModelSetup,
CASE_HELI(menuModelHeli)
CASE_FLIGHT_MODES(menuModelFlightModesAll)
menuModelExposAll,
menuModelMixAll,
menuModelLimits,
CASE_CURVES(menuModelCurvesAll)
menuModelLogicalSwitches,
menuModelCustomFunctions,
CASE_FRSKY(menuModelTelemetry)
CASE_MAVLINK(menuTelemetryMavlinkSetup)
CASE_TEMPLATES(menuModelTemplates)
};
#define COPY_MODE 1
#define MOVE_MODE 2
static uint8_t s_copyMode = 0;
static int8_t s_copySrcRow;
static int8_t s_copyTgtOfs;
#if defined(CPUM64)
#define editNameCursorPos m_posHorz
#else
static uint8_t editNameCursorPos = 0;
#endif
void editName(coord_t x, coord_t y, char *name, uint8_t size, uint8_t event, uint8_t active)
{
#if defined(CPUM64)
// in order to save flash
lcd_putsLeft(y, STR_NAME);
#endif
uint8_t mode = 0;
if (active) {
if (s_editMode <= 0)
mode = INVERS + FIXEDWIDTH;
else
mode = FIXEDWIDTH;
}
lcd_putsnAtt(x, y, name, size, ZCHAR | mode);
if (active) {
uint8_t cur = editNameCursorPos;
if (s_editMode > 0) {
int8_t c = name[cur];
int8_t v = c;
if (p1valdiff || IS_ROTARY_RIGHT(event) || IS_ROTARY_LEFT(event) || event==EVT_KEY_FIRST(KEY_DOWN) || event==EVT_KEY_FIRST(KEY_UP)
|| event==EVT_KEY_REPT(KEY_DOWN) || event==EVT_KEY_REPT(KEY_UP)) {
v = checkIncDec(event, abs(v), 0, ZCHAR_MAX, 0);
if (c <= 0) v = -v;
}
switch (event) {
#if defined(ROTARY_ENCODER_NAVIGATION)
case EVT_ROTARY_BREAK:
if (s_editMode == EDIT_MODIFY_FIELD) {
s_editMode = EDIT_MODIFY_STRING;
cur = 0;
}
else if (cur<size-1)
cur++;
else
s_editMode = 0;
break;
#endif
case EVT_KEY_BREAK(KEY_LEFT):
if (cur>0) cur--;
break;
case EVT_KEY_BREAK(KEY_RIGHT):
if (cur<size-1) cur++;
break;
#if defined(ROTARY_ENCODER_NAVIGATION)
case EVT_ROTARY_LONG:
if (v==0) {
s_editMode = 0;
killEvents(event);
break;
}
// no break
#endif
case EVT_KEY_LONG(KEY_LEFT):
case EVT_KEY_LONG(KEY_RIGHT):
if (v>=-26 && v<=26) {
v = -v; // toggle case
if (event==EVT_KEY_LONG(KEY_LEFT))
killEvents(KEY_LEFT);
}
break;
}
if (c != v) {
name[cur] = v;
eeDirty(EE_MODEL);
}
lcd_putcAtt(x+editNameCursorPos*FW, y, idx2char(v), ERASEBG|INVERS|FIXEDWIDTH);
}
else {
cur = 0;
}
editNameCursorPos = cur;
}
}
#if defined(CPUM64)
#define editSingleName(x, y, label, name, size, event, active) editName(x, y, name, size, event, active)
#else
void editSingleName(coord_t x, coord_t y, const pm_char *label, char *name, uint8_t size, uint8_t event, uint8_t active)
{
lcd_putsLeft(y, label);
editName(x, y, name, size, event, active);
}
#endif
static uint8_t s_currIdx;
+87
View File
@@ -0,0 +1,87 @@
/*
* Authors (alphabetical order)
* - Andre Bernet <bernet.andre@gmail.com>
* - Andreas Weitl
* - Bertrand Songis <bsongis@gmail.com>
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
* - Cameron Weeks <th9xer@gmail.com>
* - Erez Raviv
* - Gabriel Birkus
* - Jean-Pierre Parisy
* - Karl Szmutny
* - Michael Blandford
* - Michal Hlavinka
* - Pat Mackenzie
* - Philip Moss
* - Rob Thomson
* - Romolo Manfredini <romolo.manfredini@gmail.com>
* - 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"
MenuFuncP g_menuStack[5];
uint8_t menuEvent = 0;
uint8_t g_menuPos[4];
uint8_t g_menuStackPtr = 0;
void popMenu()
{
assert(g_menuStackPtr>0);
g_menuStackPtr = g_menuStackPtr-1;
menuEvent = EVT_ENTRY_UP;
}
void chainMenu(MenuFuncP newMenu)
{
g_menuStack[g_menuStackPtr] = newMenu;
menuEvent = EVT_ENTRY;
}
void pushMenu(MenuFuncP newMenu)
{
killEvents(KEY_ENTER);
if (g_menuStackPtr == 0) {
if (newMenu == menuGeneralSetup)
g_menuPos[0] = 1;
if (newMenu == menuModelSelect)
g_menuPos[0] = 0;
}
else {
g_menuPos[g_menuStackPtr] = m_posVert;
}
g_menuStackPtr++;
assert(g_menuStackPtr < DIM(g_menuStack));
g_menuStack[g_menuStackPtr] = newMenu;
menuEvent = EVT_ENTRY;
}
#if defined(CPUARM)
void pushModelNotes()
{
char filename[sizeof(MODELS_PATH)+1+sizeof(g_model.header.name)+sizeof(TEXT_EXT)] = MODELS_PATH "/";
char *buf = strcat_modelname(&filename[sizeof(MODELS_PATH)], g_eeGeneral.currModel);
strcpy(buf, TEXT_EXT);
pushMenuTextView(filename);
}
#endif
+466
View File
@@ -0,0 +1,466 @@
/*
* Authors (alphabetical order)
* - Andre Bernet <bernet.andre@gmail.com>
* - Andreas Weitl
* - Bertrand Songis <bsongis@gmail.com>
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
* - Cameron Weeks <th9xer@gmail.com>
* - Erez Raviv
* - Gabriel Birkus
* - Jean-Pierre Parisy
* - Karl Szmutny
* - Michael Blandford
* - Michal Hlavinka
* - Pat Mackenzie
* - Philip Moss
* - Rob Thomson
* - Romolo Manfredini <romolo.manfredini@gmail.com>
* - 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_
#define NO_HI_LEN 25
#define MENUS_SCROLLBAR_WIDTH 0
#define MENU_COLUMNS 1
#define COLUMN_X 0
#define lcd_putsColumnLeft(x, y, str) lcd_putsLeft(y, str)
// Menus related stuff ...
#if defined(SDCARD)
typedef uint16_t vertpos_t;
#else
typedef uint8_t vertpos_t;
#endif
typedef uint8_t check_event_t;
#define horzpos_t uint8_t
#if defined(CPUARM)
extern tmr10ms_t menuEntryTime;
#endif
extern vertpos_t m_posVert;
extern horzpos_t m_posHorz;
extern vertpos_t s_pgOfs;
extern uint8_t s_noHi;
extern uint8_t calibrationState;
void menu_lcd_onoff(coord_t x, coord_t y, uint8_t value, LcdFlags attr);
typedef void (*MenuFuncP)(uint8_t event);
typedef void (*MenuFuncP_PROGMEM)(uint8_t event);
extern const MenuFuncP_PROGMEM menuTabModel[];
extern const MenuFuncP_PROGMEM menuTabGeneral[];
extern const MenuFuncP_PROGMEM menuTabFPV[];
extern const MenuFuncP_PROGMEM menuTabTelemetry[];
extern MenuFuncP g_menuStack[5];
extern uint8_t g_menuPos[4];
extern uint8_t g_menuStackPtr;
extern uint8_t menuEvent;
/// goto given Menu, but substitute current menu in menuStack
void chainMenu(MenuFuncP newMenu);
/// goto given Menu, store current menu in menuStack
void pushMenu(MenuFuncP newMenu);
/// return to last menu in menustack
void popMenu();
///deliver address of last menu which was popped from
inline MenuFuncP lastPopMenu()
{
return g_menuStack[g_menuStackPtr+1];
}
void drawPotsBars();
void doMainScreenGraphics();
void menuFirstCalib(uint8_t event);
void onMainViewMenu(const char *result);
void menuMainView(uint8_t event);
void menuGeneralDiagAna(uint8_t event);
#if defined(FRSKY)
void menuTelemetryFrsky(uint8_t event);
#endif
void menuGeneralSetup(uint8_t event);
void menuGeneralCalib(uint8_t event);
void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFunctionsContext & functionsContext);
void menuModelSelect(uint8_t event);
void menuModelCustomFunctions(uint8_t event);
void menuStatisticsView(uint8_t event);
void menuStatisticsDebug(uint8_t event);
void menuAboutView(uint8_t event);
#if defined(DEBUG_TRACE_BUFFER)
void menuTraceBuffer(uint8_t event);
#endif
#if !defined(CPUM64)
void displaySlider(coord_t x, coord_t y, uint8_t value, uint8_t max, uint8_t attr);
#elif defined(GRAPHICS)
void display5posSlider(coord_t x, coord_t y, uint8_t value, uint8_t attr);
#define displaySlider(x, y, value, max, attr) lcd_outdezAtt(x, y, value, attr|LEFT)
#else
#define displaySlider(x, y, value, max, attr) lcd_outdezAtt(x, y, value, attr|LEFT)
#endif
#if defined(NAVIGATION_POT1)
extern int16_t p1valdiff;
#else
#define p1valdiff 0
#endif
#if defined(NAVIGATION_POT2)
extern int8_t p2valdiff;
#else
#define p2valdiff 0
#endif
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)
#if defined(CPUARM)
typedef bool (*IsValueAvailable)(int);
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<count; ++i) {
int stop = stops[i];
if (value == stop)
return true;
else if (value < stop)
return false;
}
return false;
}
};
extern const CheckIncDecStops &stops100;
extern const CheckIncDecStops &stops1000;
extern const CheckIncDecStops &stopsSwitch;
#define INIT_STOPS(var, ...) \
const int _ ## var[] = { __VA_ARGS__ }; \
const CheckIncDecStops &var = (const CheckIncDecStops&)_ ## var;
#define CATEGORY_END(val) \
(val), (val+1)
int checkIncDec(unsigned int event, int val, int i_min, int i_max, unsigned int i_flags=0, IsValueAvailable isValueAvailable=NULL, const CheckIncDecStops &stops=stops100);
#else
int16_t checkIncDec(uint8_t event, int16_t i_pval, int16_t i_min, int16_t i_max, uint8_t i_flags=0);
#endif
int8_t checkIncDecMovedSwitch(int8_t val);
#if defined(CPUM64)
int8_t checkIncDecModel(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max);
int8_t checkIncDecModelZero(uint8_t event, int8_t i_val, int8_t i_max);
int8_t checkIncDecGen(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max);
#else
#define checkIncDecModel(event, i_val, i_min, i_max) checkIncDec(event, i_val, i_min, i_max, EE_MODEL)
#define checkIncDecModelZero(event, i_val, i_max) checkIncDec(event, i_val, 0, i_max, EE_MODEL)
#define checkIncDecGen(event, i_val, i_min, i_max) checkIncDec(event, i_val, i_min, i_max, EE_GENERAL)
#endif
#define CHECK_INCDEC_MODELVAR(event, var, min, max) \
var = checkIncDecModel(event,var,min,max)
#define CHECK_INCDEC_MODELVAR_ZERO(event, var, max) \
var = checkIncDecModelZero(event,var,max)
#if defined(CPUARM)
#define CHECK_INCDEC_MODELVAR_CHECK(event, var, min, max, check) \
var = checkIncDec(event, var, min, max, EE_MODEL, check)
#define CHECK_INCDEC_MODELVAR_ZERO_CHECK(event, var, max, check) \
var = checkIncDec(event, var, 0, max, EE_MODEL, check)
#else
#define CHECK_INCDEC_MODELVAR_CHECK(event, var, min, max, check) \
var = checkIncDec(event, var, min, max, EE_MODEL)
#define CHECK_INCDEC_MODELVAR_ZERO_CHECK(event, var, max, check) \
CHECK_INCDEC_MODELVAR_ZERO(event, var, max)
#endif
#if defined(CPUARM)
bool isThrottleSourceAvailable(int source);
bool isLogicalSwitchFunctionAvailable(int function);
bool isAssignableFunctionAvailable(int function);
bool isSwitchAvailableInLogicalSwitches(int swtch);
bool isSwitchAvailableInCustomFunctions(int swtch);
bool isSwitchAvailableInMixes(int swtch);
bool isSwitchAvailableInTimers(int swtch);
bool isModuleAvailable(int module);
#define AUTOSWITCH_ENTER_LONG() (attr && event==EVT_KEY_LONG(KEY_ENTER))
#define CHECK_INCDEC_SWITCH(event, var, min, max, flags, available) \
var = checkIncDec(event, var, min, max, (flags)|INCDEC_SWITCH, available)
#define CHECK_INCDEC_MODELSWITCH(event, var, min, max, available) \
CHECK_INCDEC_SWITCH(event, var, min, max, EE_MODEL, available)
#elif defined(AUTOSWITCH)
#define AUTOSWITCH_ENTER_LONG() (attr && event==EVT_KEY_LONG(KEY_ENTER))
#define CHECK_INCDEC_SWITCH(event, var, min, max, flags, available) \
var = checkIncDec(event, var, min, max, (flags)|INCDEC_SWITCH)
#define CHECK_INCDEC_MODELSWITCH(event, var, min, max, available) \
CHECK_INCDEC_SWITCH(event, var, min, max, EE_MODEL, available)
#else
#define AUTOSWITCH_ENTER_LONG() (0)
#define CHECK_INCDEC_SWITCH(event, var, min, max, flags, available) \
CHECK_INCDEC_MODELVAR(event, var, min, max)
#define CHECK_INCDEC_MODELSWITCH(event, var, min, max, available) \
CHECK_INCDEC_MODELVAR(event, var, min, max)
#endif
#if defined(CPUARM)
bool isInputAvailable(int input);
bool isSourceAvailable(int source);
bool isSourceAvailableInCustomSwitches(int source);
bool isInputSourceAvailable(int source);
#define CHECK_INCDEC_MODELSOURCE(event, var, min, max) \
var = checkIncDec(event,var,min,max,EE_MODEL|INCDEC_SOURCE|NO_INCDEC_MARKS, isSourceAvailable)
#elif defined(AUTOSOURCE)
#define CHECK_INCDEC_MODELSOURCE(event, var, min, max) \
var = checkIncDec(event,var,min,max,EE_MODEL|INCDEC_SOURCE|NO_INCDEC_MARKS)
#else
#define CHECK_INCDEC_MODELSOURCE CHECK_INCDEC_MODELVAR
#endif
#define CHECK_INCDEC_GENVAR(event, var, min, max) \
var = checkIncDecGen(event, var, min, max)
#define NAVIGATION_LINE_BY_LINE 0
#define CURSOR_ON_LINE() (0)
void check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTabSize, const pm_uint8_t *horTab, uint8_t horTabMax, vertpos_t maxrow);
void check_simple(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTabSize, vertpos_t maxrow);
void check_submenu_simple(check_event_t event, uint8_t maxrow);
void title(const pm_char * s);
#define TITLE(str) title(str)
#if defined(CPUARM)
#define MENU_TAB(...) const uint8_t mstate_tab[] = __VA_ARGS__
#else
#define MENU_TAB(...) static const pm_uint8_t mstate_tab[] PROGMEM = __VA_ARGS__
#endif
#define MENU_CHECK(tab, menu, lines_count) \
check(event, menu, tab, DIM(tab), mstate_tab, DIM(mstate_tab)-1, (lines_count)-1)
#define MENU_CHECK_FLAGS(tab, menu, flags, lines_count) \
check(event, menu, tab, DIM(tab), mstate_tab, DIM(mstate_tab)-1, (lines_count)-1, flags)
#define MENU(title, tab, menu, lines_count, ...) \
MENU_TAB(__VA_ARGS__); \
MENU_CHECK(tab, menu, lines_count); \
TITLE(title)
#define MENU_FLAGS(title, tab, menu, flags, lines_count, ...) \
MENU_TAB(__VA_ARGS__); \
MENU_CHECK_FLAGS(tab, menu, flags, lines_count); \
TITLE(title)
#define SIMPLE_MENU_NOTITLE(tab, menu, lines_count) \
check_simple(event, menu, tab, DIM(tab), (lines_count)-1);
#define SIMPLE_MENU(title, tab, menu, lines_count) \
SIMPLE_MENU_NOTITLE(tab, menu, lines_count); \
TITLE(title)
#define SUBMENU_NOTITLE(lines_count, ...) { \
MENU_TAB(__VA_ARGS__); \
check(event, 0, NULL, 0, mstate_tab, DIM(mstate_tab)-1, (lines_count)-1); \
}
#define SUBMENU(title, lines_count, ...) \
MENU_TAB(__VA_ARGS__); \
check(event, 0, NULL, 0, mstate_tab, DIM(mstate_tab)-1, (lines_count)-1); \
TITLE(title)
#define SIMPLE_SUBMENU_NOTITLE(lines_count) \
check_submenu_simple(event, (lines_count)-1);
#define SIMPLE_SUBMENU(title, lines_count) \
SIMPLE_SUBMENU_NOTITLE(lines_count); \
TITLE(title)
#if defined(CPUARM)
typedef int select_menu_value_t;
#else
typedef int8_t select_menu_value_t;
#endif
select_menu_value_t selectMenuItem(coord_t x, coord_t y, const pm_char *label, const pm_char *values, select_menu_value_t value, select_menu_value_t min, select_menu_value_t max, LcdFlags attr, uint8_t event);
uint8_t onoffMenuItem(uint8_t value, coord_t x, coord_t y, const pm_char *label, LcdFlags attr, uint8_t event);
int8_t switchMenuItem(coord_t x, coord_t y, int8_t value, LcdFlags attr, uint8_t event);
#define ON_OFF_MENU_ITEM(value, x, y, label, attr, event) value = onoffMenuItem(value, x, y, label, attr, event)
#if defined(CPUARM) && defined(GVARS)
#define GVAR_MENU_ITEM(x, y, v, min, max, lcdattr, editflags, event) gvarMenuItem(x, y, v, min, max, lcdattr, editflags, event)
#else
#define GVAR_MENU_ITEM(x, y, v, min, max, lcdattr, editflags, event) gvarMenuItem(x, y, v, min, max, lcdattr, event)
#endif
#if defined(GVARS)
#if defined(CPUARM)
int16_t gvarMenuItem(coord_t x, coord_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, uint8_t editflags, uint8_t event);
#else
int16_t gvarMenuItem(coord_t x, coord_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, uint8_t event); // @@@ open.20.fsguruh
#endif
#define displayGVar(x, y, v, min, max) GVAR_MENU_ITEM(x, y, v, min, max, 0, 0, 0)
#else
int16_t gvarMenuItem(coord_t x, coord_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, uint8_t event);
#define displayGVar(x, y, v, min, max) lcd_outdez8(x, y, v)
#endif
void editName(coord_t x, coord_t y, char *name, uint8_t size, uint8_t event, uint8_t active);
#define WARNING_TYPE_ASTERISK 0
#define WARNING_TYPE_CONFIRM 1
#define WARNING_TYPE_INPUT 2
extern const pm_char * s_warning;
extern const pm_char * s_warning_info;
extern uint8_t s_warning_info_len;
extern uint8_t s_warning_result;
extern uint8_t s_warning_type;
#define MENU_X 10
#define MENU_Y 16
#define MENU_W LCD_W-(2*MENU_X)
#define WARNING_LINE_LEN 20
#define WARNING_LINE_X 16
#define WARNING_LINE_Y 3*FH
void displayBox();
void displayPopup(const pm_char * pstr);
void displayWarning(uint8_t event);
#if defined(CPUARM)
extern void (*popupFunc)(uint8_t event);
extern int16_t s_warning_input_value;
extern int16_t s_warning_input_min;
extern int16_t s_warning_input_max;
extern uint8_t s_warning_info_flags;
#endif
#if defined(CPUARM)
#define DISPLAY_WARNING (*popupFunc)
#define POPUP_WARNING(s) (s_warning = s, s_warning_info = 0, popupFunc = displayWarning)
#define POPUP_CONFIRMATION(s) (s_warning = s, s_warning_type = WARNING_TYPE_CONFIRM, s_warning_info = 0, popupFunc = displayWarning)
#define POPUP_INPUT(s, func, start, min, max) (s_warning = s, s_warning_type = WARNING_TYPE_INPUT, popupFunc = func, s_warning_input_value = start, s_warning_input_min = min, s_warning_input_max = max)
#define WARNING_INFO_FLAGS s_warning_info_flags
#define SET_WARNING_INFO(info, len, flags) (s_warning_info = info, s_warning_info_len = len, s_warning_info_flags = flags)
#else
#define DISPLAY_WARNING displayWarning
#define POPUP_WARNING(s) s_warning = s
#define POPUP_CONFIRMATION(s) (s_warning = s, s_warning_type = WARNING_TYPE_CONFIRM)
#define WARNING_INFO_FLAGS ZCHAR
#define SET_WARNING_INFO(info, len, flags) (s_warning_info = info, s_warning_info_len = len)
#endif
#if defined(SDCARD) || (defined(ROTARY_ENCODER_NAVIGATION) && !defined(CPUM64))
#define NAVIGATION_MENUS
#define MENU_ADD_ITEM(s) s_menu[s_menu_count++] = s
#define MENU_MAX_LINES 6
#if defined(SDCARD)
#define MENU_ADD_SD_ITEM(s) MENU_ADD_ITEM(s)
#else
#define MENU_ADD_SD_ITEM(s)
#endif
#define MENU_LINE_LENGTH (LEN_MODEL_NAME+1)
extern const char *s_menu[MENU_MAX_LINES];
extern uint16_t s_menu_count;
extern uint8_t s_menu_flags;
extern uint16_t s_menu_offset;
const char * displayMenu(uint8_t event);
extern void (*menuHandler)(const char *result);
#else
#define s_menu_count 0
#endif
#if defined(SDCARD)
#define STATUS_LINE_LENGTH 32
extern char statusLineMsg[STATUS_LINE_LENGTH];
void showStatusLine();
void drawStatusLine();
#else
#define drawStatusLine()
#endif
#if defined(CPUARM)
void pushMenuTextView(const char *filename);
bool modelHasNotes();
void pushModelNotes();
#endif
#define LABEL(...) (uint8_t)-1
#define KEY_MOVE_UP KEY_UP
#define KEY_MOVE_DOWN KEY_DOWN
#define CURSOR_MOVED_LEFT(event) (IS_ROTARY_LEFT(event) || EVT_KEY_MASK(event) == KEY_LEFT)
#define CURSOR_MOVED_RIGHT(event) (IS_ROTARY_RIGHT(event) || EVT_KEY_MASK(event) == KEY_RIGHT)
#define CASE_EVT_ROTARY_MOVE_RIGHT CASE_EVT_ROTARY_RIGHT
#define CASE_EVT_ROTARY_MOVE_LEFT CASE_EVT_ROTARY_LEFT
#define IS_ROTARY_MOVE_RIGHT IS_ROTARY_RIGHT
#define IS_ROTARY_MOVE_LEFT IS_ROTARY_LEFT
#if defined(ROTARY_ENCODER_NAVIGATION)
void repeatLastCursorMove(uint8_t event);
#define REPEAT_LAST_CURSOR_MOVE() { if (EVT_KEY_MASK(event) >= 0x0e) putEvent(event); else repeatLastCursorMove(event); }
#define MOVE_CURSOR_FROM_HERE() if (m_posHorz > 0) REPEAT_LAST_CURSOR_MOVE()
#else
void repeatLastCursorMove(uint8_t event);
#define REPEAT_LAST_CURSOR_MOVE() repeatLastCursorMove(event)
#define MOVE_CURSOR_FROM_HERE() REPEAT_LAST_CURSOR_MOVE()
#endif
#define POS_VERT_INIT 0
#define POS_HORZ_INIT(posVert) 0
#define EDIT_MODE_INIT -1
typedef int16_t (*FnFuncP) (int16_t x);
void DrawFunction(FnFuncP fn, uint8_t offset=0);
#endif // _MENUS_H_
+166
View File
@@ -0,0 +1,166 @@
/*
* Authors (alphabetical order)
* - Andre Bernet <bernet.andre@gmail.com>
* - Andreas Weitl
* - Bertrand Songis <bsongis@gmail.com>
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
* - Cameron Weeks <th9xer@gmail.com>
* - Erez Raviv
* - Gabriel Birkus
* - Jean-Pierre Parisy
* - Karl Szmutny
* - Michael Blandford
* - Michal Hlavinka
* - Pat Mackenzie
* - Philip Moss
* - Rob Thomson
* - Romolo Manfredini <romolo.manfredini@gmail.com>
* - 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"
const pm_uchar about_bmp[] PROGMEM = {
#include "../../bitmaps/9X/about.lbm"
};
enum AboutScreens {
ABOUT_OPENTX,
ABOUT_BERTRAND,
ABOUT_ANDRE,
ABOUT_MIKE,
ABOUT_KJELL,
ABOUT_MARTIN,
ABOUT_ROMOLO,
ABOUT_ROB,
ABOUT_HARDWARE,
ABOUT_PARENTS,
ABOUT_END,
ABOUT_COUNT,
};
#define ABOUT_X 2
#define ABOUT_INDENT 4
void menuAboutView(uint8_t event)
{
static uint8_t screenIndex;
static uint8_t greyIndex;
switch(event)
{
case EVT_ENTRY:
screenIndex = 0;
greyIndex = 0;
break;
case EVT_KEY_FIRST(KEY_DOWN):
screenIndex < ABOUT_PARENTS ? screenIndex++ : screenIndex = ABOUT_OPENTX;
greyIndex = 0;
break;
case EVT_KEY_FIRST(KEY_UP):
screenIndex > ABOUT_OPENTX ? screenIndex-- : screenIndex = ABOUT_PARENTS;
greyIndex = 0;
break;
case EVT_KEY_FIRST(KEY_EXIT):
chainMenu(menuMainView);
break;
}
lcd_putsAtt(17, 0, STR_ABOUTUS, DBLSIZE|INVERS);
lcd_hline(17, 16, LCD_W-17);
lcd_img(8, 0, about_bmp, 0);
LcdFlags att = 0;
uint8_t screenDuration = 150;
switch (screenIndex) {
case ABOUT_OPENTX:
case ABOUT_END:
lcd_putsAtt(ABOUT_X, 22, STR_ABOUT_OPENTX_1, SMLSIZE);
lcd_putsAtt(ABOUT_X, 30, STR_ABOUT_OPENTX_2, SMLSIZE);
lcd_putsAtt(ABOUT_X, 38, STR_ABOUT_OPENTX_3, SMLSIZE);
lcd_putsAtt(ABOUT_X, 46, STR_ABOUT_OPENTX_4, SMLSIZE);
lcd_putsAtt(ABOUT_X, 54, STR_ABOUT_OPENTX_5, SMLSIZE);
screenDuration = 255;
break;
case ABOUT_BERTRAND:
lcd_putsAtt(ABOUT_X, 24, STR_ABOUT_BERTRAND_1, att);
lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_BERTRAND_2, att|SMLSIZE);
lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_BERTRAND_3, att|SMLSIZE);
break;
case ABOUT_ANDRE:
lcd_putsAtt(ABOUT_X, 24, STR_ABOUT_ANDRE_1, att);
lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_ANDRE_2, att|SMLSIZE);
lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_ANDRE_3, att|SMLSIZE);
break;
case ABOUT_MIKE:
lcd_putsAtt(ABOUT_X, 24, STR_ABOUT_MIKE_1, att);
lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_MIKE_2, att|SMLSIZE);
lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_MIKE_3, att|SMLSIZE);
lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 52, STR_ABOUT_MIKE_4, att|SMLSIZE);
break;
case ABOUT_KJELL:
lcd_putsAtt(ABOUT_X, 24, STR_ABOUT_KJELL_1, att);
lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_KJELL_2, att|SMLSIZE);
lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_KJELL_3, att|SMLSIZE);
lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 52, STR_ABOUT_KJELL_4, att|SMLSIZE);
break;
case ABOUT_MARTIN:
lcd_putsAtt(ABOUT_X, 24, STR_ABOUT_MARTIN_1, att);
lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_MARTIN_2, att|SMLSIZE);
break;
case ABOUT_ROMOLO:
lcd_putsAtt(ABOUT_X, 24, STR_ABOUT_ROMOLO_1, att);
lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_ROMOLO_2, att|SMLSIZE);
lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_ROMOLO_3, att|SMLSIZE);
break;
case ABOUT_ROB:
lcd_putsAtt(ABOUT_X, 24, STR_ABOUT_ROB_1, att);
lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_ROB_2, att|SMLSIZE);
break;
case ABOUT_HARDWARE:
lcd_putsAtt(ABOUT_X, 24, STR_ABOUT_HARDWARE_1, att);
lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_HARDWARE_2, att|SMLSIZE);
lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_HARDWARE_3, att|SMLSIZE);
break;
case ABOUT_PARENTS:
lcd_putsAtt(ABOUT_X, 24, STR_ABOUT_PARENTS_1, att);
lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_PARENTS_2, att|SMLSIZE);
lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_PARENTS_3, att|SMLSIZE);
lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 52, STR_ABOUT_PARENTS_4, att|SMLSIZE);
screenDuration = 255;
break;
}
if (++greyIndex == screenDuration) {
greyIndex = 0;
if (++screenIndex == ABOUT_COUNT) {
chainMenu(menuMainView);
}
}
}
+529
View File
@@ -0,0 +1,529 @@
/*
* Authors (alphabetical order)
* - Andre Bernet <bernet.andre@gmail.com>
* - Andreas Weitl
* - Bertrand Songis <bsongis@gmail.com>
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
* - Cameron Weeks <th9xer@gmail.com>
* - Erez Raviv
* - Gabriel Birkus
* - Gerard Valade <gerard.valade@gmail.com>
* - Jean-Pierre Parisy
* - Karl Szmutny
* - Michael Blandford
* - Michal Hlavinka
* - Pat Mackenzie
* - Philip Moss
* - Rienk de Jong
* - Rob Thomson
* - Romolo Manfredini <romolo.manfredini@gmail.com>
* - 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.
*
*/
/*! \file view_mavlink.cpp
* Mavlink menu
* Contains the menu specific code for Mavlink support.
*/
#include "view_mavlink.h"
// Globals declaration
/*! \brief Top Mavlink Menu definition
* \details Registers button events and handles that info. Buttons select menus,
* these are launched from the MAVLINK_menu switch statement. Setup menu is
* lanuched by the menu button. On exit (with exit button) the mavlink
* extension is reinitialized.
*/
void menuTelemetryMavlink(uint8_t event) {
switch (event) // new event received, branch accordingly
{
case EVT_ENTRY:
MAVLINK_menu = MENU_INFO;
break;
case EVT_KEY_FIRST(KEY_UP):
if (MAVLINK_menu > 0)
MAVLINK_menu--;
else
chainMenu(menuMainView);
break;
case EVT_KEY_FIRST(KEY_DOWN):
if (MAVLINK_menu < MAX_MAVLINK_MENU - 1)
MAVLINK_menu++;
break;
case EVT_KEY_FIRST(KEY_MENU):
return;
case EVT_KEY_FIRST(KEY_EXIT):
chainMenu(menuMainView);
break;
}
switch (MAVLINK_menu) {
case MENU_INFO:
menuTelemetryMavlinkInfos();
break;
case MENU_MODE:
menuTelemetryMavlinkFlightMode();
break;
case MENU_BATT:
menuTelemetryMavlinkBattery();
break;
case MENU_NAV:
menuTelemetryMavlinkNavigation();
break;
case MENU_GPS:
menuTelemetryMavlinkGPS();
break;
#ifdef DUMP_RX_TX
case MENU_DUMP_TX:
case MENU_DUMP_RX:
menuTelemetryMavlinkDump(event);
break;
#endif
default:
break;
}
}
/*! \brief Float variable display helper
* \param x x position on the screen
* \param y y position on the screen
* \param val value to display
* \param percis precision to display
* \param mode Use one of the defines in lcd.h line 81
* \details The maximum value is 9999. The position is the position of the ones, see below for explanation "*" marks
* the x position.
* \verbatim
*
9999.9999 \endverbatim
*/
void lcd_outdezFloat(uint8_t x, uint8_t y, float val, uint8_t precis, uint8_t mode) {
char c;
int16_t lnum = val;
uint8_t x1 = x;
val -= lnum;
uint8_t xinc = FWNUM;
if (mode & DBLSIZE)
xinc *= 2;
int8_t i = 0;
lnum = abs(lnum);
for (; i < 4; i++) {
c = (lnum % 10) + '0';
x1 -= xinc;
lcd_putcAtt(x1, y, c, mode);
lnum /= 10;
if (lnum == 0) {
break;
}
}
if (lnum != 0) {
// Error number too big
x1 = x;
for (i = 0; i < 4; i++) {
x1 -= FW;
lcd_putcAtt(x1, y, '?', mode);
}
} else {
if (val < 0) {
val = -val;
x1 -= xinc;
lcd_putcAtt(x1, y, '-', mode);
}
if (precis)
{
uint8_t y_temp = y;
if (mode & DBLSIZE)
y_temp += FH;
lcd_putcAtt(x, y_temp, '.', (mode & (~DBLSIZE)));
x -= (xinc / 2);
}
for (i = 0; i < precis; i++) {
val *= 10;
int a = val;
c = a + '0';
x += xinc;
lcd_putcAtt(x, y, c, mode);
val -= a;
}
}
}
/*! \brief Fightmode string printer
* \details Decodes the flight mode from Mavlink custom mode enum to a string.
* This funtion can handle ArduPilot and ArduCoper code.
* To support new autopilot pilots add a STR_MAVLINK_... to the translations,
* and if requred a lut (see arduplane for examle) if there are unused modes
* in the sequence.
*/
void print_mav_mode(uint8_t x, uint8_t y, uint32_t custom_mode, uint8_t attr) //, const char * mode_text_p)
{
uint8_t mode = (uint8_t) custom_mode;
switch (telemetry_data.type_autopilot) {
case MAVLINK_ARDUCOPTER:
lcd_putsiAtt(x,y,STR_MAVLINK_AC_MODES,mode,attr);
break;
case MAVLINK_ARDUPLANE:
lcd_putsiAtt(x,y,STR_MAVLINK_AP_MODES,ap_modes_lut[custom_mode],attr);
break;
default:
lcd_putsAtt (FW, y, PSTR("INV. MAV TYPE"), attr);
break;
}
}
/*! \brief Menu header
* \details Small helper function to print the standard header on the screen.
*/
void mav_title(const pm_char * s, uint8_t index)
{
lcd_putsAtt(0, 0, PSTR("MAVLINK"), INVERS);
lcd_puts(10 * FW, 0, s);
displayScreenIndex(index, MAX_MAVLINK_MENU, INVERS);
lcd_putc(7 * FW, 0, (mav_heartbeat > 0) ? '*' : ' ');
if (telemetry_data.active)
lcd_putcAtt(8 * FW, 0, 'A', BLINK);
}
/*! \brief Global info menu
* \details Quick status overview menu. The menu should contain current mode,
* armed | disarmed, battery status and RSSI info. Menu must be clean and
* readable with a quick glance.
* \todo Make menu as described as above.
*/
void menuTelemetryMavlinkInfos(void) {
mav_title(STR_MAVLINK_INFOS, MAVLINK_menu);
uint8_t x1, x2, xnum, y;
x1 = FW;
x2 = 7 * FW;
xnum = x2 + 5 * FWNUM;
y = FH;
/*
char * ptr = mav_statustext;
for (uint8_t j = 0; j < LEN_STATUSTEXT; j++) {
if (*ptr == 0) {
lcd_putc(x1, y, ' ');
} else {
lcd_putc(x1, y, *ptr++);
}
x1 += FW;
}
x1 = FW;
y += FH;
*/
if (telemetry_data.status) {
lcd_putsnAtt(x1, y, STR_MAVLINK_MODE, 4, 0);
if (telemetry_data.active)
lcd_putsnAtt(x2, y, PSTR("A"), 1, 0);
lcd_outdezAtt(xnum, y, telemetry_data.mode, 0);
y += FH;
lcd_puts(x1, y, PSTR("BATT"));
lcd_outdezNAtt(xnum, y, telemetry_data.vbat, PREC1, 5);
y += FH;
lcd_puts(x1, y, PSTR("DROP"));
lcd_outdezAtt(xnum, y, telemetry_data.packet_drop, 0);
/* y += FH;
lcd_puts(x1, y, PSTR("FIX"));
lcd_outdezAtt(xnum, y, telemetry_data.packet_fixed, 0);
y += FH;
lcd_puts(x1, y, PSTR("MAV Comp"));
lcd_outdezAtt(xnum, y, telemetry_data.mav_compid, 0);
y += FH;
lcd_puts(x1, y, PSTR("MAV Sys"));
lcd_outdezAtt(xnum, y, telemetry_data.mav_sysid, 0);
y += FH;
lcd_puts(x1, y, PSTR("Rad Comp"));
lcd_outdezAtt(xnum, y, telemetry_data.radio_compid, 0);
y += FH;
lcd_puts(x1, y, PSTR("Rad Sys"));
lcd_outdezAtt(xnum, y, telemetry_data.radio_sysid, 0);
*/
}
}
/*! \brief Flight mode menu
* \details Clear display of current flight mode.
* \todo Add functionality to change flight mode.
*/
void menuTelemetryMavlinkFlightMode(void) {
mav_title(STR_MAVLINK_MODE, MAVLINK_menu);
uint8_t x, y;
x = 0;
y = FH;
lcd_puts (x, y, STR_MAVLINK_CUR_MODE);
y += FH;
print_mav_mode(FW, y, telemetry_data.custom_mode, DBLSIZE);
y += 2 * FH;
char * ptr = mav_statustext;
for (uint8_t j = 0; j < LEN_STATUSTEXT; j++) {
if (*ptr == 0) {
lcd_putc(x, y, ' ');
} else {
lcd_putc(x, y, *ptr++);
}
x += FW;
}
y += FH;
x = 0;
if (telemetry_data.active)
lcd_putsAtt (FW, y, STR_MAVLINK_ARMED, DBLSIZE);
}
/*! \brief Batterystatus dislplay
* \details Shows flight batery status.
* Also RC and PC RSSI are in this menu.
*/
void menuTelemetryMavlinkBattery(void) {
mav_title(STR_MAVLINK_BAT_MENU_TITLE, MAVLINK_menu);
uint8_t x, y, ynum;
x = 7 * FWNUM;
// x = xnum + 0 * FW;
ynum = 2 * FH;
y = 3 * FH;
lcd_puts(0, 1*FH, STR_MAVLINK_BATTERY_LABEL);
lcd_outdezAtt(x, ynum, telemetry_data.vbat, (DBLSIZE | PREC1 | UNSIGN));
lcd_puts(x, y, PSTR("V"));
x += 4 * (2 * FWNUM);
lcd_outdezAtt(x, ynum, telemetry_data.ibat, (DBLSIZE | PREC1 | UNSIGN));
lcd_puts(x, y, PSTR("A"));
x += 4 * (2 * FWNUM);
lcd_outdezAtt(x, ynum, telemetry_data.rem_bat, (DBLSIZE | UNSIGN));
lcd_puts(x, y, PSTR("%"));
y += FH;
ynum += 3 * FH;
x = 0;
lcd_puts (x, y, STR_MAVLINK_RC_RSSI_LABEL);
lcd_outdezAtt(x + 7 * FWNUM, ynum, telemetry_data.rc_rssi, (DBLSIZE | UNSIGN));
lcd_puts(x + 7 * FWNUM, ynum + FH, PSTR("%"));
if (g_model.mavlink.pc_rssi_en)
{
x += 8 * (2 * FWNUM);
lcd_puts(x, y, STR_MAVLINK_PC_RSSI_LABEL);
lcd_outdezAtt(x + 7 * FWNUM, ynum, telemetry_data.pc_rssi, (DBLSIZE));
lcd_puts(x + 7 * FWNUM, ynum + FH, PSTR("%"));
}
}
/*! \brief Navigation dislplay
* \details Shows Navigation telemetry.
* Altitude in this menu is the relative (to the home location) altitude. This
* is the same altitude used by the waypoints.
* \todo Add a similar menu to fly back to the home location.
*/
void menuTelemetryMavlinkNavigation(void) {
mav_title(STR_MAVLINK_NAV_MENU_TITLE, MAVLINK_menu);
uint8_t x, y, ynum;
x = 7 * FWNUM;
// x = xnum + 0 * FW;
ynum = 2 * FH;
y = FH;
x = 0;
lcd_puts (x, y, STR_MAVLINK_COURSE);
lcd_outdezAtt(x + 7 * FWNUM, ynum, telemetry_data.course, (DBLSIZE | UNSIGN));
lcd_puts(x + 7 * FWNUM, ynum, PSTR("o"));
x += 8 * (2 * FWNUM);
lcd_puts(x, y, STR_MAVLINK_HEADING);
lcd_outdezAtt(x + 7 * FWNUM, ynum, telemetry_data.heading, (DBLSIZE | UNSIGN));
lcd_puts(x + 7 * FWNUM, ynum, PSTR("o"));
y += 3 * FH;
ynum += 3 * FH;
x = 0;
lcd_puts (x, y, STR_MAVLINK_BEARING);
lcd_outdezAtt(x + 7 * FWNUM, ynum, telemetry_data.bearing, (DBLSIZE | UNSIGN));
lcd_puts(x + 7 * FWNUM, ynum, PSTR("o"));
x += 8 * (2 * FWNUM);
lcd_puts(x, y, STR_MAVLINK_ALTITUDE);
lcd_outdezFloat(x + 4 * FWNUM - 1, ynum, telemetry_data.loc_current.rel_alt, 1, (DBLSIZE));
lcd_puts(x + 7 * FWNUM, ynum + FH, PSTR("m"));
}
/*! \brief GPS information menu
* \details Menu gives a lot of info from the gps like fix type, position,
* attitude, heading and velocity. Text is small and the user must focus to
* read it.
* \todo Text is small. Should we do something about this or leaf it like this.
* I don't think will be used much when a user is concentrated on flying.
*/
void menuTelemetryMavlinkGPS(void) {
mav_title(STR_MAVLINK_GPS, MAVLINK_menu);
uint8_t x1, x2, xnum, xnum2, y;
x1 = FW;
x2 = x1 + 12 * FW;
xnum = 7 * FW + 3 * FWNUM;
xnum2 = xnum + 11 * FWNUM;
y = FH;
lcd_putsnAtt(x1, y, STR_MAVLINK_GPS, 3, 0);
if (telemetry_data.fix_type < 2) {
lcd_putsnAtt(xnum, y, STR_MAVLINK_NO_FIX, 6, 0);
} else {
lcd_outdezNAtt(xnum, y, telemetry_data.fix_type, 0, 3);
lcd_puts(xnum, y, PSTR("D"));
}
lcd_puts(x2, y, STR_MAVLINK_SAT);
lcd_outdezNAtt(xnum2, y, telemetry_data.satellites_visible, 0, 2);
// if (telemetry_data.fix_type > 0) {
y += FH;
lcd_puts(x1, y, STR_MAVLINK_HDOP);
lcd_outdezFloat(xnum, y, telemetry_data.eph, 2);
y += FH;
lcd_puts(x1, y, STR_MAVLINK_LAT);
lcd_outdezFloat(xnum, y, telemetry_data.loc_current.lat, 2);
lcd_putsnAtt(x2, y, STR_MAVLINK_LON, 3, 0);
lcd_outdezFloat(xnum2, y, telemetry_data.loc_current.lon, 2);
y += FH;
lcd_putsnAtt(x1, y, STR_MAVLINK_ALTITUDE, 3, 0);
lcd_outdezAtt(xnum, y, telemetry_data.loc_current.gps_alt, 0);
y += FH;
lcd_putsnAtt(x1, y, STR_MAVLINK_COURSE, 6, 0);
lcd_outdezFloat(xnum, y, telemetry_data.course, 2);
y += FH;
lcd_putsnAtt(x1, y, PSTR("V"), 1, 0);
lcd_outdezAtt(xnum, y, telemetry_data.v, 0);
//}
}
#ifdef DUMP_RX_TX
//! \brief Display one byte as hex.
void lcd_outhex2(uint8_t x, uint8_t y, uint8_t val) {
x += FWNUM * 2;
for (int i = 0; i < 2; i++) {
x -= FWNUM;
char c = val & 0xf;
c = c > 9 ? c + 'A' - 10 : c + '0';
lcd_putcAtt(x, y, c, c >= 'A' ? CONDENSED : 0);
val >>= 4;
}
}
//! \brief Hex dump of the current mavlink message.
void menuTelemetryMavlinkDump(uint8_t event) {
uint8_t x = 0;
uint8_t y = FH;
uint16_t count = 0;
uint16_t bufferLen = 0;
uint8_t *ptr = NULL;
switch (MAVLINK_menu) {
case MENU_DUMP_RX:
mav_dump_rx = 1;
mav_title(PSTR("RX"), MAVLINK_menu);
bufferLen = mavlinkRxBufferCount;
ptr = mavlinkRxBuffer;
break;
case MENU_DUMP_TX:
mav_title(PSTR("TX"), MAVLINK_menu);
bufferLen = serialTxBufferCount;
ptr = ptrTxISR;
break;
default:
break;
}
for (uint16_t var = 0; var < bufferLen; var++) {
uint8_t byte = *ptr++;
lcd_outhex2(x, y, byte);
x += 2 * FW;
count++;
if (count > 8) {
count = 0;
x = 0;
y += FH;
if (y == (6 * FH))
break;
}
}
}
#endif
/*! \brief Mavlink General setup menu.
* \details Setup menu for generic mavlink settings.
* Current menu items
* - RC RSSI scale item. Used to adjust the scale of the RSSI indicator to match
* the actual rssi value
* - PC RSSI enable item. Can be used to dissable PC RSSI display if not used.
* This funcion is called from the model setup menus, not directly by the
* telemetry menus
*/
void menuTelemetryMavlinkSetup(uint8_t event) {
MENU(STR_MAVMENUSETUP_TITLE, menuTabModel, e_MavSetup, ITEM_MAVLINK_MAX + 1, {0, 0, 1/*to force edit mode*/});
uint8_t sub = m_posVert - 1;
for (uint8_t i=0; i<LCD_LINES-1; i++) {
uint8_t y = 1 + 1*FH + i*FH;
uint8_t k = i+s_pgOfs;
uint8_t blink = ((s_editMode>0) ? BLINK|INVERS : INVERS);
uint8_t attr = (sub == k ? blink : 0);
switch(k) {
case ITEM_MAVLINK_RC_RSSI_SCALE:
lcd_putsLeft(y, STR_MAVLINK_RC_RSSI_SCALE_LABEL);
lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, (25 + g_model.mavlink.rc_rssi_scale * 5), attr|LEFT);
lcd_putc(lcdLastPos, y, '%');
if (attr) CHECK_INCDEC_MODELVAR(event, g_model.mavlink.rc_rssi_scale, 0, 15);
break;
case ITEM_MAVLINK_PC_RSSI_EN:
g_model.mavlink.pc_rssi_en = onoffMenuItem(g_model.mavlink.pc_rssi_en,
RADIO_SETUP_2ND_COLUMN,
y,
STR_MAVLINK_PC_RSSI_EN_LABEL,
attr,
event);
break;
}
}
}
+100
View File
@@ -0,0 +1,100 @@
/*
* Authors (alphabetical order)
* - Andre Bernet <bernet.andre@gmail.com>
* - Andreas Weitl
* - Bertrand Songis <bsongis@gmail.com>
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
* - Cameron Weeks <th9xer@gmail.com>
* - Erez Raviv
* - Gabriel Birkus
* - Gerard Valade <gerard.valade@gmail.com>
* - Jean-Pierre Parisy
* - Karl Szmutny
* - Michael Blandford
* - Michal Hlavinka
* - Pat Mackenzie
* - Philip Moss
* - Rienk de Jong
* - Rob Thomson
* - Romolo Manfredini <romolo.manfredini@gmail.com>
* - 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.
*
*/
/*! \file view_mavlink.h
* Mavlink menu include file
*/
#ifndef _VIEW_MAVLINK_H_
#define _VIEW_MAVLINK_H_
#include "opentx.h"
#include "telemetry/mavlink.h"
#include "gui/menus.h"
#include "serial.h"
#define APSIZE (BSS | DBLSIZE)
void menuTelemetryMavlink(uint8_t event);
void displayScreenIndex(uint8_t index, uint8_t count, uint8_t attr);
void lcd_outdezFloat(uint8_t x, uint8_t y, float val, uint8_t precis, uint8_t mode = 0);
void mav_title(const pm_char * s, uint8_t index);
void menuTelemetryMavlinkInfos(void);
void menuTelemetryMavlinkFlightMode(void);
void menuTelemetryMavlinkBattery(void);
void menuTelemetryMavlinkNavigation(void);
void menuTelemetryMavlinkGPS(void);
#ifdef DUMP_RX_TX
void lcd_outhex2(uint8_t x, uint8_t y, uint8_t val);
void menuTelemetryMavlinkDump(uint8_t event);
#endif
void menuTelemetryMavlinkSetup(uint8_t event);
/*! \brief Mavlink menu enumerator
* \details Used to create a readable case statement for the
* \link menuTelemetryMavlink menuTelemetryMavlink \endlink funtion.
*/
enum mavlink_menu_ {
MENU_INFO = 0, //
MENU_MODE,
MENU_BATT,
MENU_NAV,
MENU_GPS, //
#ifdef DUMP_RX_TX
MENU_DUMP_RX, //
MENU_DUMP_TX, //
#endif
MAX_MAVLINK_MENU
};
//! \brief Pointer array to mavlink settings menus.
const MenuFuncP_PROGMEM menuTabMav[] PROGMEM = {
menuTelemetryMavlinkSetup
};
//! \brief Mavlink setup menu configuration items list.
enum menuMavlinkSetupItems {
ITEM_MAVLINK_RC_RSSI_SCALE,
ITEM_MAVLINK_PC_RSSI_EN,
ITEM_MAVLINK_MAX
};
//! \brief Menu index varible, initialized on info menu.
uint8_t MAVLINK_menu = MENU_INFO;
#endif