Files movement.

Issue 26 fixed (JETI)
This commit is contained in:
bsongis@gmail.com
2013-05-07 05:42:43 +00:00
parent 37880ee9ec
commit c7c907e7ce
306 changed files with 937 additions and 892 deletions
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+1053
View File
File diff suppressed because it is too large Load Diff
+358
View File
@@ -0,0 +1,358 @@
/*
* 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
typedef void (*MenuFuncP)(uint8_t event);
void displayScreenIndex(uint8_t index, uint8_t count, uint8_t attr);
inline void displayColumnHeader(const char **headers, uint8_t index)
{
lcd_putsAtt(17*FW, 0, headers[index], 0);
}
#if LCD_W >= 212
#if defined(TRANSLATIONS_FR)
#define MENU_COLUMNS 1
#define COLUMN_X 0
#else
#define MENU_COLUMNS 2
#endif
#define MENUS_SCROLLBAR_WIDTH 2
#define MENU_COLUMN2_X (14 + LCD_W / 2)
#define lcd_putsColumnLeft(x, y, str) lcd_puts((x > (LCD_W-10*FW-MENUS_SCROLLBAR_WIDTH)) ? MENU_COLUMN2_X : 0, y, str)
#else
#define MENUS_SCROLLBAR_WIDTH 0
#define MENU_COLUMNS 1
#define COLUMN_X 0
#define lcd_putsColumnLeft(x, y, str) lcd_putsLeft(y, str)
#endif
// Menus related stuff ...
#if defined(SDCARD)
typedef uint16_t vertpos_t;
#else
typedef uint8_t vertpos_t;
#endif
#if defined(PCBTARANIS)
typedef uint8_t & check_event_t;
#define horzpos_t int8_t
#else
typedef uint8_t check_event_t;
#define horzpos_t uint8_t
#endif
extern vertpos_t m_posVert;
extern horzpos_t m_posHorz;
extern vertpos_t s_pgOfs;
extern uint8_t s_noHi;
extern uint8_t s_noScroll;
void menu_lcd_onoff(uint8_t x, uint8_t y, uint8_t value, LcdFlags attr);
extern MenuFuncP g_menuStack[5];
extern uint8_t g_menuStackPtr;
/// 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 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 menuModelSelect(uint8_t event);
void menuModelCustomFunctions(uint8_t event);
void menuStatisticsView(uint8_t event);
void menuStatisticsDebug(uint8_t event);
#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
// mawrow special values
#define TITLE_ROW ((uint8_t)-1)
#define HIDDEN_ROW ((uint8_t)-2)
int16_t checkIncDec(uint8_t event, int16_t i_pval, int16_t i_min, int16_t i_max, uint8_t i_flags=0);
#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(AUTOSWITCH)
#define AUTOSWITCH_ENTER_LONG() (attr && event==EVT_KEY_LONG(KEY_ENTER))
#define CHECK_INCDEC_MODELSWITCH(event, var, min, max) \
var = checkIncDec(event,var,min,max,EE_MODEL|INCDEC_SWITCH)
#else
#define AUTOSWITCH_ENTER_LONG() (0)
#define CHECK_INCDEC_MODELSWITCH CHECK_INCDEC_MODELVAR
#endif
#if defined(AUTOSOURCE)
#define CHECK_INCDEC_MODELSOURCE(event, var, min, max) \
var = checkIncDec(event,var,min,max,EE_MODEL|INCDEC_SOURCE)
#else
#define CHECK_INCDEC_MODELSOURCE CHECK_INCDEC_MODELVAR
#endif
#define CHECK_INCDEC_GENVAR(event, var, min, max) \
var = checkIncDecGen(event,var,min,max)
#if defined(PCBTARANIS)
#define NAVIGATION_LINE_BY_LINE 0x40
#else
#define NAVIGATION_LINE_BY_LINE 0
#endif
bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTabSize, const pm_uint8_t *subTab, uint8_t subTabMax, vertpos_t maxrow);
bool check_simple(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTabSize, vertpos_t maxrow);
bool check_submenu_simple(check_event_t event, uint8_t maxrow);
typedef void (*MenuFuncP_PROGMEM)(uint8_t event);
void title(const pm_char * s);
#define TITLE(str) title(str)
#if defined(CPUARM)
#define MENU(title, tab, menu, lines_count, ...) \
const uint8_t mstate_tab[] = __VA_ARGS__; \
if (!check(event,menu,tab,DIM(tab),mstate_tab,DIM(mstate_tab)-1,(lines_count)-1)) return; \
TITLE(title)
#else
#define MENU(title, tab, menu, lines_count, ...) \
static const pm_uint8_t mstate_tab[] PROGMEM = __VA_ARGS__; \
if (!check(event,menu,tab,DIM(tab),mstate_tab,DIM(mstate_tab)-1,(lines_count)-1)) return; \
TITLE(title)
#endif
#define SIMPLE_MENU_NOTITLE(tab, menu, lines_count) \
if (!check_simple(event,menu,tab,DIM(tab),(lines_count)-1)) return;
#define SIMPLE_MENU(title, tab, menu, lines_count) \
SIMPLE_MENU_NOTITLE(tab, menu, lines_count); \
TITLE(title)
#define SUBMENU_NOTITLE(lines_count, ...) { \
static const pm_uint8_t mstate_tab[] PROGMEM = __VA_ARGS__; \
if (!check(event,0,NULL,0,mstate_tab,DIM(mstate_tab)-1,(lines_count)-1)) return; }
#define SUBMENU(title, lines_count, ...) \
static const pm_uint8_t mstate_tab[] PROGMEM = __VA_ARGS__; \
if (!check(event,0,NULL,0,mstate_tab,DIM(mstate_tab)-1,(lines_count)-1)) return; \
TITLE(title)
#define SIMPLE_SUBMENU_NOTITLE(lines_count) \
if (!check_submenu_simple(event,(lines_count)-1)) return;
#define SIMPLE_SUBMENU(title, lines_count) \
SIMPLE_SUBMENU_NOTITLE(lines_count); \
TITLE(title)
int8_t selectMenuItem(uint8_t x, uint8_t y, const pm_char *label, const pm_char *values, int8_t value, int8_t min, int8_t max, LcdFlags attr, uint8_t event);
uint8_t onoffMenuItem(uint8_t value, uint8_t x, uint8_t y, const pm_char *label, LcdFlags attr, uint8_t event );
int8_t switchMenuItem(uint8_t x, uint8_t y, int8_t value, LcdFlags attr, uint8_t event);
#if defined(GVARS)
int16_t gvarMenuItem(uint8_t x, uint8_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, uint8_t event); // @@@ open.20.fsguruh
#define displayGVar(x, y, v, min, max) gvarMenuItem(x, y, v, min, max, 0, 0)
#else
int8_t gvarMenuItem(uint8_t x, uint8_t y, int8_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
#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;
extern const pm_char * s_global_warning;
#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;
#endif
#if defined(CPUARM)
#define DISPLAY_WARNING (*popupFunc)
#define POPUP_WARNING(s) do { s_warning = s; popupFunc = displayWarning; } while(0)
#define POPUP_CONFIRMATION(s) do { s_warning = s; s_warning_type = WARNING_TYPE_CONFIRM; popupFunc = displayWarning; } while(0)
#define POPUP_INPUT(s, func, start, min, max) do { 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; } while(0)
#else
#define DISPLAY_WARNING displayWarning
#define POPUP_WARNING(s) s_warning = s
#define POPUP_CONFIRMATION(s) do { s_warning = s; s_warning_type = WARNING_TYPE_CONFIRM; } while(0)
#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
void menuChannelsView(uint8_t event);
#define LABEL(...) (uint8_t)-1
#if defined(PCBTARANIS)
#define KEY_MOVE_UP KEY_PLUS
#define KEY_MOVE_DOWN KEY_MINUS
#define CURSOR_MOVED_LEFT(event) (EVT_KEY_MASK(event) == KEY_PLUS)
#define CURSOR_MOVED_RIGHT(event) (EVT_KEY_MASK(event) == KEY_MINUS)
#define CASE_EVT_ROTARY_MOVE_RIGHT CASE_EVT_ROTARY_LEFT
#define CASE_EVT_ROTARY_MOVE_LEFT CASE_EVT_ROTARY_RIGHT
#define IS_ROTARY_MOVE_RIGHT IS_ROTARY_LEFT
#define IS_ROTARY_MOVE_LEFT IS_ROTARY_RIGHT
#else
#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
#endif
#if defined(PCBTARANIS)
#define REPEAT_LAST_CURSOR_MOVE() { if (CURSOR_MOVED_LEFT(event) || CURSOR_MOVED_RIGHT(event)) putEvent(event); else m_posHorz = 0; }
#elif defined(ROTARY_ENCODER_NAVIGATION)
#define REPEAT_LAST_CURSOR_MOVE() { if (EVT_KEY_MASK(event) >= 0x0e) putEvent(event); else m_posHorz = 0; }
#else
#define REPEAT_LAST_CURSOR_MOVE() m_posHorz = 0;
#endif
#if defined(PCBTARANIS)
#define POS_VERT_INIT (menuTab ? (MAXCOL((uint16_t)1) == 255 ? 2 : 1) : 0)
#define POS_HORZ_INIT(posVert) ((COLATTR(posVert) & NAVIGATION_LINE_BY_LINE) ? -1 : 0)
#define EDIT_MODE_INIT 0 // TODO enum
#else
#define POS_VERT_INIT 0
#define POS_HORZ_INIT(posVert) 0
#define EDIT_MODE_INIT -1
#endif
#endif
+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"
void menuChannelsView(uint8_t event)
{
static bool longNames = false;
bool newLongNames = false;
static bool secondPage = false;
uint8_t ch;
switch(event)
{
case EVT_KEY_BREAK(KEY_EXIT):
popMenu();
return;
case EVT_KEY_FIRST(KEY_RIGHT):
case EVT_KEY_FIRST(KEY_LEFT):
secondPage = !secondPage;
break;
}
if (secondPage)
ch = 16;
else
ch = 0;
lcd_putsCenter(0*FH, CHANNELS_MONITOR);
lcd_invert_line(0);
// Column separator
lcd_vline(LCD_W/2, FH, LCD_H-FH);
for (uint8_t col=0; col<2; col++) {
uint8_t x = col*LCD_W/2+1;
// Channels
for (uint8_t line=0; line<8; line++) {
uint8_t y = 9+line*7;
int32_t val = channelOutputs[ch];
uint8_t ofs = (col ? 0 : 1);
// Channel name if present, number if not
uint8_t lenLabel = zlen(g_model.limitData[ch].name, sizeof(g_model.limitData[ch].name));
if (lenLabel > 4) {
newLongNames = longNames = true;
}
if (lenLabel > 0)
lcd_putsnAtt(x+1-ofs, y, g_model.limitData[ch].name, sizeof(g_model.limitData[ch].name), ZCHAR | SMLSIZE);
else
putsChn(x+1-ofs, y, ch+1, SMLSIZE);
uint8_t wbar = (longNames ? 48 : 58);
// Value
lcd_outdezNAtt(x+LCD_W/2-3-wbar-ofs, y+1, calcRESXto1000(val), PREC1 | TINSIZE);
// Gauge
lcd_rect(x+LCD_W/2-3-wbar-ofs, y, wbar+1, 6);
uint16_t lim = g_model.extendedLimits ? 640*2 : 512*2;
uint8_t len = limit((uint8_t)1, uint8_t((abs(val) * wbar/2 + lim/2) / lim), uint8_t(wbar/2));
uint8_t x0 = (val>0) ? x+LCD_W/2-ofs-3-wbar/2 : x+LCD_W/2-ofs-2-wbar/2-len;
lcd_hline(x0, y+1, len);
lcd_hline(x0, y+2, len);
lcd_hline(x0, y+3, len);
lcd_hline(x0, y+4, len);
ch++;
}
}
longNames = newLongNames;
}
+831
View File
@@ -0,0 +1,831 @@
/*
* 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 LCD_W >= 212
#define BIGSIZE MIDSIZE
#define BOX_WIDTH 31
#define LBOX_CENTERX (BOX_WIDTH/2 + 17)
#define LBOX_CENTERY (LCD_H-BOX_WIDTH/2-10)
#define RBOX_CENTERX (LCD_W-LBOX_CENTERX)
#define RBOX_CENTERY LBOX_CENTERY
#define MODELNAME_X (15)
#define MODELNAME_Y (11)
#define VBATT_X (MODELNAME_X+26)
#define VBATT_Y (FH+3)
#define VBATTUNIT_X (VBATT_X-2)
#define VBATTUNIT_Y VBATT_Y
#define BITMAP_X ((LCD_W-64)/2)
#define BITMAP_Y (LCD_H/2)
#define PHASE_X BITMAP_X
#define PHASE_Y (3*FH)
#define PHASE_FLAGS (0)
#define TIMERS_X 144
#define TIMER1_Y 20
#define TIMER2_Y 45
#define TIMERS_R 192
#define REBOOT_X (LCD_W-FW)
#define VSWITCH_X(i) (((i>=NUM_CSW*3/4) ? BITMAP_X+28 : ((i>=NUM_CSW/2) ? BITMAP_X+25 : ((i>=NUM_CSW/4) ? 21 : 18))) + 3*i)
#define VSWITCH_Y (LCD_H-9)
#define BAR_HEIGHT (31-9)
#define TRIM_LH_X (32+9)
#define TRIM_LV_X 10
#define TRIM_RV_X (LCD_W-11)
#define TRIM_RH_X (LCD_W-32-9)
#else
#define BIGSIZE DBLSIZE
#define BOX_WIDTH 23
#define LBOX_CENTERX (LCD_W/4 + 10)
#define LBOX_CENTERY (LCD_H-9-BOX_WIDTH/2)
#define RBOX_CENTERX (3*LCD_W/4 - 10)
#define RBOX_CENTERY LBOX_CENTERY
#define MODELNAME_X (2*FW-2)
#define MODELNAME_Y (0)
#define PHASE_X (6*FW)
#define PHASE_Y (2*FH)
#define PHASE_FLAGS 0
#define VBATT_X (6*FW)
#define VBATT_Y (2*FH)
#define VBATTUNIT_X (VBATT_X-1)
#define VBATTUNIT_Y (3*FH)
#define REBOOT_X (20*FW-3)
#define VSWITCH_X(i) (16 + 3*i)
#define VSWITCH_Y (LCD_H-8)
#define BAR_HEIGHT (BOX_WIDTH-1l)
#define TRIM_LH_X (LCD_W*1/4+2)
#define TRIM_LV_X 3
#define TRIM_RV_X (LCD_W-4)
#define TRIM_RH_X (LCD_W*3/4-2)
#endif
#define TRIM_LEN 27
#define MARKER_WIDTH 5
#define BOX_LIMIT (BOX_WIDTH-MARKER_WIDTH)
#if defined(PCBTARANIS)
const pm_uchar logo_taranis[] PROGMEM = {
#include "bitmaps/logo_taranis.lbm"
};
const pm_uchar icons[] PROGMEM = {
#include "bitmaps/icons.lbm"
};
#define ICON_RSSI 0, 9
#define ICON_SPEAKER0 9, 8
#define ICON_SPEAKER1 17, 8
#define ICON_SPEAKER2 25, 8
#define ICON_SPEAKER3 33, 8
#define ICON_SD 41, 11
#define ICON_LOGS 51, 11
#define ICON_TRAINER 61, 11
#define ICON_TRAINEE 71, 11
#define ICON_USB 81, 11
#define ICON_REBOOT 91, 11
#endif
void drawPotsBars()
{
// Optimization by Mike Blandford
uint8_t x, y, len ; // declare temporary variables
for (x=LCD_W/2-5, y=NUM_STICKS; y<NUM_STICKS+NUM_POTS; x+=5, y++) {
len = ((calibratedStick[y]+RESX)*BAR_HEIGHT/(RESX*2))+1l; // calculate once per loop
V_BAR(x, LCD_H-8, len)
}
}
void doMainScreenGraphics()
{
lcd_square(LBOX_CENTERX-BOX_WIDTH/2, LBOX_CENTERY-BOX_WIDTH/2, BOX_WIDTH);
lcd_square(RBOX_CENTERX-BOX_WIDTH/2, RBOX_CENTERY-BOX_WIDTH/2, BOX_WIDTH);
DO_CROSS(LBOX_CENTERX, LBOX_CENTERY, 3)
DO_CROSS(RBOX_CENTERX, RBOX_CENTERY, 3)
int16_t calibStickVert = calibratedStick[CONVERT_MODE(1+1)-1];
if (g_model.throttleReversed && CONVERT_MODE(1+1)-1 == THR_STICK)
calibStickVert = -calibStickVert;
lcd_square(LBOX_CENTERX+(calibratedStick[CONVERT_MODE(0+1)-1]*BOX_LIMIT/(2*RESX))-MARKER_WIDTH/2, LBOX_CENTERY-(calibStickVert*BOX_LIMIT/(2*RESX))-MARKER_WIDTH/2, MARKER_WIDTH, ROUND);
calibStickVert = calibratedStick[CONVERT_MODE(2+1)-1];
if (g_model.throttleReversed && CONVERT_MODE(2+1)-1 == THR_STICK)
calibStickVert = -calibStickVert;
lcd_square(RBOX_CENTERX+(calibratedStick[CONVERT_MODE(3+1)-1]*BOX_LIMIT/(2*RESX))-MARKER_WIDTH/2, RBOX_CENTERY-(calibStickVert*BOX_LIMIT/(2*RESX))-MARKER_WIDTH/2, MARKER_WIDTH, ROUND);
#if !defined(PCBTARANIS)
drawPotsBars();
#endif
}
void displayTrims(uint8_t phase)
{
for (uint8_t i=0; i<4; i++) {
static xcoord_t x[4] = {TRIM_LH_X, TRIM_LV_X, TRIM_RV_X, TRIM_RH_X};
static uint8_t vert[4] = {0,1,1,0};
uint8_t xm, ym;
xm = x[CONVERT_MODE(i+1)-1];
uint8_t att = ROUND;
int16_t val = getTrimValue(phase, i);
if (val < -125 || val > 125)
att = BLINK|INVERS|ROUND;
if (val < -(TRIM_LEN+1)*4)
val = -(TRIM_LEN+1);
else if (val > (TRIM_LEN+1)*4)
val = TRIM_LEN+1;
else
val /= 4;
if (vert[i]) {
ym = 31;
lcd_vline(xm, ym-TRIM_LEN, TRIM_LEN*2);
if (i!=2 || !g_model.thrTrim) {
lcd_vline(xm-1, ym-1, 3);
lcd_vline(xm+1, ym-1, 3);
}
ym -= val;
}
else {
ym = 60;
lcd_hline(xm-TRIM_LEN, ym, TRIM_LEN*2);
lcd_hline(xm-1, ym-1, 3);
lcd_hline(xm-1, ym+1, 3);
xm += val;
}
lcd_square(xm-3, ym-3, 7, att);
}
}
#if defined(PCBTARANIS)
void displaySliders()
{
for (uint8_t i=NUM_STICKS; i<NUM_STICKS+NUM_POTS; i++) {
xcoord_t x = (i%2 ? LCD_W-5 : 3);
int8_t y = (i>NUM_STICKS+1 ? LCD_H/2+1 : 1);
lcd_vline(x, y, LCD_H/2-2);
lcd_vline(x+1, y, LCD_H/2-2);
y += LCD_H/2-4;
y -= ((calibratedStick[i]+RESX)*(LCD_H/2-4)/(RESX*2)); // calculate once per loop
lcd_vline(x-1, y, 2);
lcd_vline(x+2, y, 2);
}
}
#define BAR_X 14
#define BAR_Y 1
#define BAR_W 184
#define BAR_H 9
#define BAR_BATT_X BAR_X+18
#define BAR_RSSI_X BAR_X+42
#define BAR_A1_X BAR_X+69
#define BAR_NOTIFS_X BAR_X+133
#define BAR_VOLUME_X BAR_X+147
#define BAR_TIME_X BAR_X+168
void displayTopBarGauge(xcoord_t x, int count, bool blinking=false)
{
if (!blinking || BLINK_ON_PHASE)
lcd_filled_rect(x+1, BAR_Y+2, 11, 5, SOLID, ERASE);
count = min(10, count);
for (int i=0; i<count; i+=2)
lcd_vline(x+2+i, BAR_Y+3, 3);
}
#define LCD_NOTIF_ICON(x, icon) \
lcd_bmp(x, BAR_Y, icons, icon); \
lcd_hline(x, BAR_Y+8, 11)
void displayTopBar()
{
/* Tx voltage */
putsVBat(BAR_BATT_X, BAR_Y+1, 0);
lcd_rect(BAR_BATT_X+FW, BAR_Y+1, 13, 7);
lcd_vline(BAR_BATT_X+FW+13, BAR_Y+2, 5);
if (frskyData.rssi[0].value > 0) {
/* RSSI */
LCD_ICON(BAR_RSSI_X, BAR_Y, ICON_RSSI);
lcd_rect(BAR_RSSI_X+10, BAR_Y+1, 13, 7);
/* Rx voltage */
if (g_model.frsky.voltsSource <= 1) {
uint8_t value = frskyData.analog[g_model.frsky.voltsSource].value;
if (value > 0) {
putsTelemetryChannel(BAR_A1_X, BAR_Y+1, TELEM_A1+g_model.frsky.voltsSource-1, value, LEFT);
}
}
}
/* Notifs icons */
xcoord_t x = BAR_NOTIFS_X;
if (unexpectedShutdown) {
LCD_NOTIF_ICON(x, ICON_REBOOT);
x -= 12;
}
if (usbPlugged()) {
LCD_NOTIF_ICON(x, ICON_USB);
x -= 12;
}
if (TRAINER_CONNECTED() && SLAVE_MODE()) {
LCD_NOTIF_ICON(x, ICON_TRAINEE);
x -= 12;
}
else if (TRAINER_CONNECTED() && !SLAVE_MODE()) {
LCD_NOTIF_ICON(x, ICON_TRAINER);
x -= 12;
}
if (isFunctionActive(FUNC_LOGS)) {
LCD_NOTIF_ICON(x, ICON_LOGS);
x -= 12;
}
if (sdMounted()) {
LCD_NOTIF_ICON(x, ICON_SD);
}
/* Audio volume */
if (requiredSpeakerVolume == 0)
LCD_ICON(BAR_VOLUME_X, BAR_Y, ICON_SPEAKER0);
else if (requiredSpeakerVolume < 10)
LCD_ICON(BAR_VOLUME_X, BAR_Y, ICON_SPEAKER1);
else if (requiredSpeakerVolume < 20)
LCD_ICON(BAR_VOLUME_X, BAR_Y, ICON_SPEAKER2);
else
LCD_ICON(BAR_VOLUME_X, BAR_Y, ICON_SPEAKER3);
/* RTC time */
struct gtm t;
gettime(&t);
lcd_putcAtt(BAR_TIME_X-1, BAR_Y+1, ':', BLINK);
lcd_outdezNAtt(BAR_TIME_X+1, BAR_Y+1, t.tm_hour, LEADING0, 2);
lcd_outdezNAtt(BAR_TIME_X+3*FWNUM-1, BAR_Y+1, t.tm_min, LEADING0, 2);
/* The background */
lcd_filled_rect(BAR_X, BAR_Y, BAR_W, BAR_H, SOLID, FILL_WHITE|GREY_DEFAULT|ROUND);
/* The inside of the Batt gauge */
int count = 10 * (g_vbat100mV - g_eeGeneral.vBatMin - 90) / (30 + g_eeGeneral.vBatMax - g_eeGeneral.vBatMin);
displayTopBarGauge(BAR_BATT_X+FW, count, g_vbat100mV <= g_eeGeneral.vBatWarn);
/* The inside of the RSSI gauge */
if (frskyData.rssi[0].value > 0) {
displayTopBarGauge(BAR_RSSI_X+10, frskyData.rssi[0].value / 10, frskyData.rssi[0].value < getRssiAlarmValue(0));
}
}
#endif
#if LCD_W >= 212
void displayTimers()
{
// Main timer
if (g_model.timers[0].mode) {
putsTime(TIMERS_X, TIMER1_Y, s_timerVal[0], MIDSIZE|LEFT, MIDSIZE|LEFT);
putsTmrMode(TIMERS_X, TIMER1_Y-6, g_model.timers[0].mode, SWCONDENSED|SMLSIZE);
if (g_model.timers[0].persistent) lcd_putcAtt(TIMERS_R, TIMER1_Y+1, 'P', SMLSIZE);
if (s_timerVal[0] < 0) lcd_hline(TIMERS_X-6, TIMER1_Y+2, 4);
}
// Second timer
if (g_model.timers[1].mode) {
putsTime(TIMERS_X, TIMER2_Y, s_timerVal[1], MIDSIZE|LEFT, MIDSIZE|LEFT);
putsTmrMode(TIMERS_X, TIMER2_Y-6, g_model.timers[1].mode, SWCONDENSED|SMLSIZE);
if (g_model.timers[1].persistent) lcd_putcAtt(TIMERS_R, TIMER2_Y+1, 'P', SMLSIZE);
if (s_timerVal[1] < 0) lcd_hline(TIMERS_X-6, TIMER2_Y+2, 4);
}
// Main timer beeping
if (s_timerState[0]==TMR_BEEPING) {
if (BLINK_ON_PHASE)
lcd_filled_rect(TIMERS_X-17, TIMER1_Y, 70, 12);
}
// Second timer beeping
if (s_timerState[1]==TMR_BEEPING) {
if (BLINK_ON_PHASE)
lcd_filled_rect(TIMERS_X-17, TIMER2_Y, 70, 12);
}
}
#else
void displayTimers()
{
// Main timer
if (g_model.timers[0].mode) {
uint8_t att = DBLSIZE | (s_timerState[0]==TMR_BEEPING ? BLINK|INVERS : 0);
putsTime(12*FW+2+10*FWNUM-4, FH*2, s_timerVal[0], att, att);
putsTmrMode(s_timerVal[0] >= 0 ? 9*FW-FW/2+3 : 9*FW-FW/2-4, FH*3, g_model.timers[0].mode, SWCONDENSED);
}
}
#endif
void displayBattVoltage()
{
#if defined(BATTGRAPH)
putsVBat(VBATT_X-8, VBATT_Y+1, 0);
lcd_filled_rect(VBATT_X-25, VBATT_Y+9, 22, 5);
lcd_vline(VBATT_X-3, VBATT_Y+10, 3);
uint8_t count = limit<uint8_t>(2, 20 * (g_vbat100mV - g_eeGeneral.vBatMin - 90) / (30 + g_eeGeneral.vBatMax - g_eeGeneral.vBatMin), 20);
for (uint8_t i=0; i<count; i+=2)
lcd_vline(VBATT_X-24+i, VBATT_Y+10, 3);
if (g_vbat100mV > g_eeGeneral.vBatWarn || BLINK_ON_PHASE)
lcd_filled_rect(VBATT_X-26, VBATT_Y, 25, 15);
#else
LcdFlags att = (g_vbat100mV <= g_eeGeneral.vBatWarn ? BLINK|INVERS : 0) | BIGSIZE;
putsVBat(VBATT_X-1, VBATT_Y, att|NO_UNIT);
#if LCD_W >= 212
lcd_putcAtt(VBATTUNIT_X, VBATTUNIT_Y, 'v', MIDSIZE);
#else
lcd_putc(VBATT_X, VBATTUNIT_Y, 'V');
#endif
#endif
}
#if defined(CPUARM)
void displayVoltageOrAlarm()
{
if (g_vbat100mV > g_eeGeneral.vBatWarn && g_eeGeneral.temperatureWarn && getTemperature() >= g_eeGeneral.temperatureWarn) {
putsTelemetryValue(6*FW-1, 3*FH, getTemperature(), UNIT_DEGREES, BLINK|INVERS|DBLSIZE);
}
#if defined(PCBSKY9X)
else if (g_vbat100mV > g_eeGeneral.vBatWarn && g_eeGeneral.mAhWarn && (g_eeGeneral.mAhUsed + Current_used * (488 + g_eeGeneral.currentCalib)/8192/36) / 500 >= g_eeGeneral.mAhWarn) {
putsTelemetryValue(7*FW-1, 3*FH, (g_eeGeneral.mAhUsed + Current_used*(488 + g_eeGeneral.currentCalib)/8192/36)/10, UNIT_MAH, BLINK|INVERS|DBLSIZE);
}
#endif
else {
displayBattVoltage();
}
}
#else
#define displayVoltageOrAlarm() displayBattVoltage()
#endif
#if defined(PCBTARANIS)
#define EVT_KEY_MODEL_MENU EVT_KEY_BREAK(KEY_MENU)
#define EVT_KEY_GENERAL_MENU EVT_KEY_LONG(KEY_MENU)
#define EVT_KEY_TELEMETRY EVT_KEY_LONG(KEY_PAGE)
#define EVT_KEY_CONTEXT_MENU EVT_KEY_LONG(KEY_ENTER)
#else
#define EVT_KEY_MODEL_MENU EVT_KEY_LONG(KEY_RIGHT)
#define EVT_KEY_GENERAL_MENU EVT_KEY_LONG(KEY_LEFT)
#define EVT_KEY_TELEMETRY EVT_KEY_LONG(KEY_DOWN)
#define EVT_KEY_STATISTICS EVT_KEY_LONG(KEY_UP)
#define EVT_KEY_CONTEXT_MENU EVT_KEY_BREAK(KEY_MENU)
#endif
#if defined(PCBTARANIS)
void menuMainViewChannelsMonitor(uint8_t event)
{
switch(event) {
case EVT_KEY_BREAK(KEY_PAGE):
case EVT_KEY_BREAK(KEY_EXIT):
chainMenu(menuMainView);
return;
}
return menuChannelsView(event);
}
#endif
#if defined(NAVIGATION_MENUS)
void onMainViewMenu(const char *result)
{
if (result == STR_RESET_TIMER1) {
resetTimer(0);
}
else if (result == STR_RESET_TIMER2) {
resetTimer(1);
}
#if defined(FRSKY)
else if (result == STR_RESET_TELEMETRY) {
resetTelemetry();
}
#endif
else if (result == STR_RESET_FLIGHT) {
resetAll();
}
else if (result == STR_STATISTICS) {
chainMenu(menuStatisticsView);
}
}
#endif
void menuMainView(uint8_t event)
{
#if !defined(PCBTARANIS)
uint8_t view = g_eeGeneral.view;
uint8_t view_base = view & 0x0f;
#endif
uint8_t _event = event;
if (s_global_warning) {
event = 0;
}
switch(event)
{
case EVT_ENTRY:
killEvents(KEY_EXIT);
killEvents(KEY_UP);
killEvents(KEY_DOWN);
break;
#if !defined(PCBTARANIS)
/* TODO if timer2 is OFF, it's possible to use this timer2 as in er9x...
case EVT_KEY_BREAK(KEY_MENU):
if (view_base == VIEW_TIMER2) {
Timer2_running = !Timer2_running;
AUDIO_KEYPAD_UP();
}
break;
*/
case EVT_KEY_BREAK(KEY_RIGHT):
case EVT_KEY_BREAK(KEY_LEFT):
if (view_base <= VIEW_INPUTS) {
#if defined(PCBSKY9X)
if (view_base == VIEW_INPUTS)
g_eeGeneral.view ^= ALTERNATE_VIEW;
else
g_eeGeneral.view = (g_eeGeneral.view + (4*ALTERNATE_VIEW) + ((event==EVT_KEY_BREAK(KEY_LEFT)) ? -ALTERNATE_VIEW : ALTERNATE_VIEW)) % (4*ALTERNATE_VIEW);
#else
g_eeGeneral.view ^= ALTERNATE_VIEW;
#endif
eeDirty(EE_GENERAL);
AUDIO_KEYPAD_UP();
}
break;
#endif
#if defined(NAVIGATION_MENUS)
case EVT_KEY_CONTEXT_MENU:
killEvents(event);
MENU_ADD_ITEM(STR_RESET_FLIGHT);
MENU_ADD_ITEM(STR_RESET_TIMER1);
MENU_ADD_ITEM(STR_RESET_TIMER2);
#if defined(FRSKY)
MENU_ADD_ITEM(STR_RESET_TELEMETRY);
#endif
MENU_ADD_ITEM(STR_STATISTICS);
menuHandler = onMainViewMenu;
break;
#endif
#if !defined(READONLY)
#if !defined(PCBTARANIS)
case EVT_KEY_LONG(KEY_MENU):// go to last menu
pushMenu(lastPopMenu());
killEvents(event);
break;
#endif
CASE_EVT_ROTARY_BREAK
case EVT_KEY_MODEL_MENU:
pushMenu(menuModelSelect);
killEvents(event);
break;
CASE_EVT_ROTARY_LONG
case EVT_KEY_GENERAL_MENU:
pushMenu(menuGeneralSetup);
killEvents(event);
break;
#endif
#if defined(PCBTARANIS)
case EVT_KEY_BREAK(KEY_PAGE):
eeDirty(EE_GENERAL);
g_eeGeneral.view += 1;
if (g_eeGeneral.view >= VIEW_COUNT) {
g_eeGeneral.view = 0;
chainMenu(menuMainViewChannelsMonitor);
return;
}
break;
#else
case EVT_KEY_BREAK(KEY_UP):
case EVT_KEY_BREAK(KEY_DOWN):
g_eeGeneral.view = (event == EVT_KEY_BREAK(KEY_UP) ? (view_base == VIEW_COUNT-1 ? 0 : view_base+1) : (view_base == 0 ? VIEW_COUNT-1 : view_base-1));
eeDirty(EE_GENERAL);
AUDIO_KEYPAD_UP();
break;
#endif
#if !defined(PCBTARANIS)
case EVT_KEY_STATISTICS:
chainMenu(menuStatisticsView);
killEvents(event);
return;
#endif
case EVT_KEY_TELEMETRY:
#if defined(FRSKY)
chainMenu(menuTelemetryFrsky);
#elif defined(JETI)
JETI_EnableRXD(); // enable JETI-Telemetry reception
chainMenu(menuTelemetryJeti);
#elif defined(ARDUPILOT)
ARDUPILOT_EnableRXD(); // enable ArduPilot-Telemetry reception
chainMenu(menuTelemetryArduPilot);
#elif defined(NMEA)
NMEA_EnableRXD(); // enable NMEA-Telemetry reception
chainMenu(menuTelemetryNMEA);
#elif defined(MAVLINK)
chainMenu(menuTelemetryMavlink);
#else
chainMenu(menuStatisticsDebug);
#endif
killEvents(event);
return;
case EVT_KEY_FIRST(KEY_EXIT):
if (s_timerState[0]==TMR_BEEPING) {
s_timerState[0] = TMR_STOPPED;
}
else if (s_global_warning) {
s_global_warning = NULL;
}
#if defined(GVARS)
else if (s_gvar_timer > 0) {
s_gvar_timer = 0;
}
#endif
#if !defined(PCBTARANIS)
else if (view == VIEW_TIMER2) {
resetTimer(1);
}
#endif
AUDIO_KEYPAD_UP();
break;
case EVT_KEY_LONG(KEY_EXIT):
resetAll();
AUDIO_KEYPAD_UP();
break;
}
{
// Flight Phase Name
uint8_t phase = s_perout_flight_phase;
lcd_putsnAtt(PHASE_X, PHASE_Y, g_model.phaseData[phase].name, sizeof(g_model.phaseData[phase].name), ZCHAR|PHASE_FLAGS);
// Model Name
putsModelName(MODELNAME_X, MODELNAME_Y, g_model.header.name, g_eeGeneral.currModel, BIGSIZE);
#if !defined(PCBTARANIS)
// Main Voltage (or alarm if any)
displayVoltageOrAlarm();
// Timers
displayTimers();
#endif
// Trims sliders
displayTrims(phase);
}
#if defined(PCBTARANIS)
// Top bar
displayTopBar();
// Sliders (Pots / Sliders)
displaySliders();
lcd_bmp(BITMAP_X, BITMAP_Y, modelBitmap);
// Switches
for (uint8_t i=0; i<8; i++) {
getvalue_t sw;
getvalue_t val;
// TODO simplify this + reuse code in checkSwitches() + Menu MODELSETUP
switch(i) {
case 5:
sw = getValue(MIXSRC_SF-1) > 0 ? 3*i+2 : 3*i+1;
break;
case 6:
val = getValue(MIXSRC_SG-1);
sw = ((val < 0) ? 3*i : ((val == 0) ? 3*i+1 : 3*i+2));
break;
case 7:
sw = getValue(MIXSRC_SH-1) > 0 ? 3*i+1 : 3*i;
break;
default:
{
val = getValue(MIXSRC_SA+i-1);
sw = ((val < 0) ? 3*i+1 : ((val == 0) ? 3*i+2 : 3*i+3));
break;
}
}
putsSwitches((g_eeGeneral.view == VIEW_INPUTS) ? (i<4 ? 8*FW+3 : 24*FW+1) : (i<4 ? 3*FW+2 : 8*FW-1), (i%4)*FH+3*FH, sw, 0);
}
if (g_eeGeneral.view == VIEW_TIMERS) {
displayTimers();
}
else if (g_eeGeneral.view == VIEW_INPUTS) {
// Sticks
doMainScreenGraphics();
}
else {
// Custom Switches
uint8_t sw = 0;
for (uint8_t line=0; line<4; line++) {
for (uint8_t col=0; col<8; col++) {
uint8_t x = LCD_W/2+7*FW+col*FW;
uint8_t y = LCD_H/2-7+line*8;
lcd_putcAtt(x, y, sw>=9 ? 'A'+sw-9 : '1'+sw, SMLSIZE);
if (getSwitch(SWSRC_SW1+sw, 0))
lcd_filled_rect(x-1, y-1, 6, 8);
sw++;
}
}
}
#else // PCBTARANIS
if (view_base < VIEW_INPUTS) {
// scroll bar
lcd_hlineStip(38, 34, 54, DOTTED);
#if defined(PCBSKY9X)
lcd_hline(38 + (g_eeGeneral.view / ALTERNATE_VIEW) * 13, 34, 13, SOLID);
#else
lcd_hline((g_eeGeneral.view & ALTERNATE_VIEW) ? 64 : 38, 34, 26, SOLID);
#endif
for (uint8_t i=0; i<8; i++) {
uint8_t x0,y0;
#if defined(PCBSKY9X)
uint8_t chan = 8*(g_eeGeneral.view / ALTERNATE_VIEW) + i;
#else
uint8_t chan = (g_eeGeneral.view & ALTERNATE_VIEW) ? 8+i : i;
#endif
int16_t val = channelOutputs[chan];
switch(view_base)
{
case VIEW_OUTPUTS_VALUES:
x0 = (i%4*9+3)*FW/2;
y0 = i/4*FH+40;
#if defined(PPM_UNIT_US)
lcd_outdezAtt(x0+4*FW , y0, PPM_CH_CENTER(chan)+val/2, 0);
#elif defined(PPM_UNIT_PERCENT_PREC1)
lcd_outdezAtt(x0+4*FW , y0, calcRESXto1000(val), PREC1);
#else
lcd_outdezAtt(x0+4*FW , y0, calcRESXto1000(val)/10, 0); // G: Don't like the decimal part*
#endif
break;
case VIEW_OUTPUTS_BARS:
#define WBAR2 (50/2)
x0 = i<4 ? LCD_W/4+2 : LCD_W*3/4-2;
y0 = 38+(i%4)*5;
uint16_t lim = g_model.extendedLimits ? 640*2 : 512*2;
int8_t len = (abs(val) * WBAR2 + lim/2) / lim;
if(len>WBAR2) len = WBAR2; // prevent bars from going over the end - comment for debugging
lcd_hlineStip(x0-WBAR2, y0, WBAR2*2+1, DOTTED);
lcd_vline(x0,y0-2,5);
if (val>0)
x0+=1;
else
x0-=len;
lcd_hline(x0,y0+1,len);
lcd_hline(x0,y0-1,len);
break;
}
}
}
else if (view_base == VIEW_INPUTS) {
if (view == VIEW_INPUTS) {
// Sticks + Pots
doMainScreenGraphics();
// Switches
for (uint8_t i=SWSRC_THR; i<=SWSRC_TRN; i++) {
int8_t sw = (i == SWSRC_TRN ? (switchState(SW_ID0) ? SWSRC_ID0 : (switchState(SW_ID1) ? SWSRC_ID1 : SWSRC_ID2)) : i);
uint8_t x = 2*FW-2, y = i*FH+1;
if (i>=SWSRC_AIL) {
x = 17*FW-1;
y -= 3*FH;
}
putsSwitches(x, y, sw, getSwitch(i, 0) ? INVERS : 0);
}
}
else {
#if defined(PCBGRUVIN9X) && defined(ROTARY_ENCODERS)
for (uint8_t i=0; i<NUM_ROTARY_ENCODERS; i++) {
int16_t val = getRotaryEncoder(i);
int8_t len = limit((int16_t)0, (int16_t)(((val+1024) * BAR_HEIGHT) / 2048), (int16_t)BAR_HEIGHT);
#if ROTARY_ENCODERS > 2
#define V_BAR_W 5
V_BAR(LCD_W/2-8+V_BAR_W*i, LCD_H-8, len)
#else
#define V_BAR_W 5
V_BAR(LCD_W/2-3+V_BAR_W*i, LCD_H-8, len)
#endif
}
#endif // PCBGRUVIN9X && ROTARY_ENCODERS
// Custom Switches
#if defined(PCBSKY9X)
for (uint8_t i=0; i<NUM_CSW; i++) {
int8_t len = getSwitch(SWSRC_SW1+i, 0) ? BAR_HEIGHT : 1;
uint8_t x = VSWITCH_X(i);
lcd_vline(x-1, VSWITCH_Y-len, len);
lcd_vline(x, VSWITCH_Y-len, len);
}
#elif defined(PCBGRUVIN9X) && ROTARY_ENCODERS > 2
for (uint8_t i=0; i<NUM_CSW; i++)
putsSwitches(2*FW-2 + (i/3)*(4*FW-2) + (i/3>1 ? 3*FW+6 : 0), 4*FH+1 + (i%3)*FH, SWSRC_SW1+i, getSwitch(SWSRC_SW1+i, 0) ? INVERS : 0);
#elif defined(PCBGRUVIN9X)
for (uint8_t i=0; i<NUM_CSW; i++)
putsSwitches(2*FW-2 + (i/3)*(4*FW-2) + (i/3>1 ? 3*FW : 0), 4*FH+1 + (i%3)*FH, SWSRC_SW1+i, getSwitch(SWSRC_SW1+i, 0) ? INVERS : 0);
#elif !defined(PCBSTD)
for (uint8_t i=0; i<NUM_CSW; i++)
putsSwitches(2*FW-2 + (i/3)*(4*FW-1), 4*FH+1 + (i%3)*FH, SWSRC_SW1+i, getSwitch(SWSRC_SW1+i, 0) ? INVERS : 0);
#else
for (uint8_t i=0; i<NUM_CSW; i++)
putsSwitches(2*FW-2 + (i/3)*(5*FW), 4*FH+1 + (i%3)*FH, SWSRC_SW1+i, getSwitch(SWSRC_SW1+i, 0) ? INVERS : 0);
#endif
}
}
else { // timer2
putsTime(33+FW+2+10*FWNUM-4, FH*5, s_timerVal[1], DBLSIZE, DBLSIZE);
putsTmrMode(s_timerVal[1] >= 0 ? 20-FW/2+5 : 20-FW/2-2, FH*6, g_model.timers[1].mode, SWCONDENSED);
// lcd_outdezNAtt(33+11*FW, FH*6, s_timerVal_10ms[1], LEADING0, 2); // 1/100s
}
#endif // PCBTARANIS
#if !defined(PCBTARANIS)
// And ! in case of unexpected shutdown
if (unexpectedShutdown) {
lcd_putcAtt(REBOOT_X, 0*FH, '!', INVERS);
}
#endif
if (s_global_warning) {
s_warning = s_global_warning;
displayWarning(_event);
if (!s_warning) s_global_warning = NULL;
s_warning = NULL;
}
#if defined(GVARS)
else if (s_gvar_timer > 0) {
s_gvar_timer--;
s_warning = PSTR("Global Variable");
displayBox();
#if defined(PCBSTD)
lcd_putsAtt(16+4*FW, 5*FH, PSTR("[\010]"), BOLD);
lcd_outdezAtt(16+4*FW+4*FW+FW/2, 5*FH, GVAR_VALUE(s_gvar_last, s_perout_flight_phase), BOLD);
#else
lcd_putsnAtt(16, 5*FH, g_model.gvarsNames[s_gvar_last], sizeof(gvar_name_t), ZCHAR);
lcd_putsAtt(16+7*FW, 5*FH, PSTR("[\010]"), BOLD);
lcd_outdezAtt(16+7*FW+4*FW+FW/2, 5*FH, GVAR_VALUE(s_gvar_last, s_perout_flight_phase), BOLD);
#endif
s_warning = NULL;
}
#endif
#if defined(DSM2)
if (s_bind_mode) // Issue 98
lcd_putsAtt(15*FW, 0, PSTR("BIND"), 0);
#endif
}
+197
View File
@@ -0,0 +1,197 @@
/*
* 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"
void menuStatisticsView(uint8_t event)
{
TITLE(STR_MENUSTAT);
switch(event)
{
case EVT_KEY_FIRST(KEY_UP):
#if !defined(PCBTARANIS) || defined(DEBUG)
chainMenu(menuStatisticsDebug);
return;
#endif
case EVT_KEY_FIRST(KEY_DOWN):
case EVT_KEY_FIRST(KEY_EXIT):
chainMenu(menuMainView);
return;
}
lcd_puts( 1*FW, FH*1, STR_TM1TM2);
putsTime( 5*FW+5*FWNUM+1, FH*1, s_timerVal[0], 0, 0);
putsTime( 12*FW+5*FWNUM+1, FH*1, s_timerVal[1], 0, 0);
lcd_puts( 1*FW, FH*2, STR_THRTHP);
putsTime( 5*FW+5*FWNUM+1, FH*2, s_timeCumThr, 0, 0);
putsTime( 12*FW+5*FWNUM+1, FH*2, s_timeCum16ThrP/16, 0, 0);
lcd_puts( 17*FW, FH*0, STR_TOT);
putsTime( 12*FW+5*FWNUM+1, FH*0, s_timeCumTot, 0, 0);
#if defined(THRTRACE)
uint8_t traceRd = (s_traceCnt < 0 ? s_traceWr : 0);
const uint8_t x=5;
const uint8_t y=60;
lcd_hline(x-3,y,MAXTRACE+3+3);
lcd_vline(x,y-32,32+3);
for (uint8_t i=0; i<MAXTRACE; i+=6) {
lcd_vline(x+i+6,y-1,3);
}
for (uint8_t i=1; i<=MAXTRACE; i++) {
lcd_vline(x+i, y-s_traceBuf[traceRd], s_traceBuf[traceRd]);
traceRd++;
if (traceRd>=MAXTRACE) traceRd = 0;
if (traceRd==s_traceWr) break;
}
#endif
}
#if defined(CPUARM)
#define MENU_DEBUG_COL_OFS (13*FW)
#else
#define MENU_DEBUG_COL_OFS (14*FW)
#endif
void menuStatisticsDebug(uint8_t event)
{
TITLE(STR_MENUDEBUG);
switch(event)
{
#if defined(CPUARM)
case EVT_KEY_LONG(KEY_MENU):
g_eeGeneral.mAhUsed = 0;
g_eeGeneral.globalTimer = 0;
eeDirty(EE_GENERAL);
#if defined(PCBSKY9X)
Current_used = 0;
#endif
sessionTimer = 0;
killEvents(event);
AUDIO_KEYPAD_UP();
break;
#endif
case EVT_KEY_FIRST(KEY_MENU):
#if !defined(CPUARM)
g_tmr1Latency_min = 0xff;
g_tmr1Latency_max = 0;
#endif
maxMixerDuration = 0;
AUDIO_KEYPAD_UP();
break;
case EVT_KEY_FIRST(KEY_DOWN):
chainMenu(menuStatisticsView);
return;
case EVT_KEY_FIRST(KEY_UP):
case EVT_KEY_FIRST(KEY_EXIT):
chainMenu(menuMainView);
return;
}
#if defined(PCBSKY9X)
if ((ResetReason&RSTC_SR_RSTTYP) == (2<<8)) {
lcd_puts(LCD_W-8*FW, 0*FH, "WATCHDOG");
}
else if (unexpectedShutdown) {
lcd_puts(LCD_W-13*FW, 0*FH, "UNEXP.SHTDOWN");
}
#endif
#if defined(PCBSKY9X) && !defined(REVA)
lcd_putsLeft(1*FH, STR_CPU_CURRENT);
putsTelemetryValue(MENU_DEBUG_COL_OFS, 1*FH, getCurrent(), UNIT_MILLIAMPS, 0);
uint32_t current_scale = 488 + g_eeGeneral.currentCalib;
putsTelemetryValue(20*FW+2, 1*FH, Current_max*10*current_scale/8192, UNIT_RAW, 0);
lcd_putsLeft(2*FH, STR_CPU_MAH);
putsTelemetryValue(MENU_DEBUG_COL_OFS, 2*FH, g_eeGeneral.mAhUsed + Current_used*current_scale/8192/36, UNIT_MAH, PREC1);
putsTime(17*FW+5*FWNUM+1, 2*FH, g_eeGeneral.globalTimer + sessionTimer, 0, 0);
#endif
#if defined(CPUARM)
lcd_putsLeft(3*FH, STR_CPU_TEMP);
putsTelemetryValue(MENU_DEBUG_COL_OFS, 3*FH, getTemperature(), UNIT_DEGREES, 0);
putsTelemetryValue(20*FW+2, 3*FH, maxTemperature+g_eeGeneral.temperatureCalib, UNIT_DEGREES, 0);
#endif
#if defined(PCBSKY9X)
lcd_putsLeft(4*FH, STR_COPROC_TEMP);
if (Coproc_read==0) {
lcd_putsAtt(9*FW+2, 4*FH, PSTR("Co Proc NACK"),INVERS);
}
else if (Coproc_read==0x81) {
lcd_putsAtt(9*FW+2, 4*FH, PSTR("Inst.TinyApp"),INVERS);
}
else if (Coproc_read<3) {
lcd_putsAtt(9*FW+2, 4*FH, PSTR("Upgr.TinyApp"),INVERS);
}
else {
putsTelemetryValue(MENU_DEBUG_COL_OFS, 4*FH, Coproc_temp, UNIT_DEGREES, 0);
putsTelemetryValue(20*FW+2, 4*FH, Coproc_maxtemp, UNIT_DEGREES, 0);
}
#endif
#if defined(CPUARM)
lcd_putsLeft(5*FH, STR_TMIXMAXMS);
lcd_outdezAtt(MENU_DEBUG_COL_OFS, 5*FH, (maxMixerDuration)/20, PREC2);
lcd_putsLeft(6*FH, STR_FREESTACKMINB);
lcd_outdezAtt(13*FW, 6*FH, stack_free(0), UNSIGN);
lcd_putc(13*FW, 6*FH, '/');
lcd_outdezAtt(13*FW+FWNUM, 6*FH, stack_free(1), UNSIGN|LEFT);
lcd_putc(lcdLastPos, 6*FH, '/');
lcd_outdezAtt(lcdLastPos+FWNUM, 6*FH, stack_free(2), UNSIGN|LEFT);
#else
lcd_putsLeft(1*FH, STR_TMR1LATMAXUS);
lcd_outdez8(MENU_DEBUG_COL_OFS , 1*FH, g_tmr1Latency_max/2 );
lcd_putsLeft(2*FH, STR_TMR1LATMINUS);
lcd_outdez8(MENU_DEBUG_COL_OFS , 2*FH, g_tmr1Latency_min/2 );
lcd_putsLeft(3*FH, STR_TMR1JITTERUS);
lcd_outdez8(MENU_DEBUG_COL_OFS , 3*FH, (g_tmr1Latency_max - g_tmr1Latency_min) /2 );
lcd_putsLeft(4*FH, STR_TMIXMAXMS);
lcd_outdezAtt(MENU_DEBUG_COL_OFS, 4*FH, (maxMixerDuration*100)/16, PREC2);
lcd_putsLeft(5*FH, STR_FREESTACKMINB);
lcd_outdezAtt(14*FW, 5*FH, stack_free(), UNSIGN) ;
#endif
lcd_puts(3*FW, 7*FH+1, STR_MENUTORESET);
lcd_status_line();
}
+395
View File
@@ -0,0 +1,395 @@
/*
* 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(FRSKY_HUB)
uint8_t barsThresholds[THLD_MAX];
#endif
enum FrskyViews {
e_frsky_custom_screen_1,
e_frsky_custom_screen_2,
IF_CPUARM(e_frsky_custom_screen_3)
e_frsky_voltages,
e_frsky_after_flight,
FRSKY_VIEW_MAX = e_frsky_after_flight
};
static uint8_t s_frsky_view = e_frsky_custom_screen_1;
#if LCD_W >= 212
void displayRssiLine()
{
if (frskyStreaming > 0) {
lcd_hline(0, 55, 212, 0); // separator
uint8_t rssi = min((uint8_t)99, frskyData.rssi[1].value);
lcd_putsLeft(7*FH+1, STR_TX); lcd_outdezNAtt(4*FW, 7*FH+1, rssi, LEADING0, 2);
lcd_rect(25, 57, 78, 7);
lcd_filled_rect(26, 58, 19*rssi/25, 5, (rssi < getRssiAlarmValue(0)) ? DOTTED : SOLID);
rssi = min((uint8_t)99, frskyData.rssi[0].value);
lcd_puts(190, 7*FH+1, STR_RX); lcd_outdezNAtt(189+4*FW-1, 7*FH+1, rssi, LEADING0, 2);
lcd_rect(110, 57, 78, 7);
uint8_t v = 19*rssi/25;
lcd_filled_rect(111+76-v, 58, v, 5, (rssi < getRssiAlarmValue(0)) ? DOTTED : SOLID);
}
else {
lcd_putsAtt(7*FW, 7*FH+1, STR_NODATA, BLINK);
lcd_status_line();
}
}
#else
void displayRssiLine()
{
if (frskyStreaming > 0) {
lcd_hline(0, 55, 128, 0); // separator
uint8_t rssi = min((uint8_t)99, frskyData.rssi[1].value);
lcd_putsLeft(7*FH+1, STR_TX); lcd_outdezNAtt(4*FW, 7*FH+1, rssi, LEADING0, 2);
lcd_rect(25, 57, 38, 7);
lcd_filled_rect(26, 58, 4*rssi/11, 5, (rssi < getRssiAlarmValue(0)) ? DOTTED : SOLID);
rssi = min((uint8_t)99, frskyData.rssi[0].value);
lcd_puts(105, 7*FH+1, STR_RX); lcd_outdezNAtt(105+4*FW-1, 7*FH+1, rssi, LEADING0, 2);
lcd_rect(65, 57, 38, 7);
uint8_t v = 4*rssi/11;
lcd_filled_rect(66+36-v, 58, v, 5, (rssi < getRssiAlarmValue(0)) ? DOTTED : SOLID);
}
else {
lcd_putsAtt(7*FW, 7*FH+1, STR_NODATA, BLINK);
lcd_status_line();
}
}
#endif
#if defined(FRSKY_HUB)
void displayGpsTime()
{
#define TIME_LINE (7*FH+1)
uint8_t att = (frskyStreaming > 0 ? LEFT|LEADING0 : LEFT|LEADING0|BLINK);
lcd_outdezNAtt(6*FW+5, TIME_LINE, frskyData.hub.hour, att, 2);
lcd_putcAtt(8*FW+2, TIME_LINE, ':', att);
lcd_outdezNAtt(9*FW+2, TIME_LINE, frskyData.hub.min, att, 2);
lcd_putcAtt(11*FW-1, TIME_LINE, ':', att);
lcd_outdezNAtt(12*FW-1, TIME_LINE, frskyData.hub.sec, att, 2);
lcd_status_line();
}
void displayGpsCoord(uint8_t y, char direction, int16_t bp, int16_t ap)
{
if (frskyData.hub.gpsFix >= 0) {
if (!direction) direction = '-';
lcd_outdezAtt(10*FW, y, bp / 100, LEFT); // ddd before '.'
lcd_putc(lcdLastPos, y, '@');
uint8_t mn = bp % 100;
if (g_eeGeneral.gpsFormat == 0) {
lcd_putc(lcdLastPos+FWNUM, y, direction);
lcd_outdezNAtt(lcdLastPos+FW+FW+1, y, mn, LEFT|LEADING0, 2); // mm before '.'
lcd_vline(lcdLastPos, y, 2);
uint16_t ss = ap * 6;
lcd_outdezAtt(lcdLastPos+3, y, ss / 1000, LEFT); // ''
lcd_plot(lcdLastPos, y+FH-2, 0); // small decimal point
lcd_outdezAtt(lcdLastPos+2, y, ss % 1000, LEFT); // ''
lcd_vline(lcdLastPos, y, 2);
lcd_vline(lcdLastPos+2, y, 2);
}
else {
lcd_outdezNAtt(lcdLastPos+FW, y, mn, LEFT|LEADING0, 2); // mm before '.'
lcd_plot(lcdLastPos, y+FH-2, 0); // small decimal point
lcd_outdezNAtt(lcdLastPos+2, y, ap, LEFT|UNSIGN|LEADING0, 4); // after '.'
lcd_putc(lcdLastPos+1, y, direction);
}
}
else {
// no fix
lcd_puts(10*FW, y, STR_VCSWFUNC+1/*----*/);
}
}
#endif
NOINLINE uint8_t getRssiAlarmValue(uint8_t alarm)
{
return (50 + g_model.frsky.rssiAlarms[alarm].value);
}
void displayVoltageScreenLine(uint8_t y, uint8_t index)
{
putsStrIdx(0, y, STR_A, index+1, 0);
putsTelemetryChannel(3*FW+6*FW+4, y-FH+1, index+TELEM_A1-1, frskyData.analog[index].value, DBLSIZE);
lcd_putc(12*FW-1, y-FH, '<'); putsTelemetryChannel(17*FW, y-FH, index+TELEM_A1-1, frskyData.analog[index].min, NO_UNIT);
lcd_putc(12*FW, y, '>'); putsTelemetryChannel(17*FW, y, index+TELEM_A1-1, frskyData.analog[index].max, NO_UNIT);
}
uint8_t barCoord(int16_t value, int16_t min, int16_t max)
{
return limit((uint8_t)0, (uint8_t)(((int32_t)99 * (value - min)) / (max - min)), (uint8_t)100);
}
void menuTelemetryFrsky(uint8_t event)
{
if (event == EVT_KEY_FIRST(KEY_EXIT)) {
chainMenu(menuMainView);
return;
}
switch (event) {
case EVT_KEY_BREAK(KEY_UP):
if (s_frsky_view-- == 0)
s_frsky_view = FRSKY_VIEW_MAX;
break;
#if defined(PCBTARANIS)
case EVT_KEY_BREAK(KEY_PAGE):
#endif
case EVT_KEY_BREAK(KEY_DOWN):
if (s_frsky_view++ == FRSKY_VIEW_MAX)
s_frsky_view = 0;
break;
#if defined(PCBTARANIS)
case EVT_KEY_LONG(KEY_ENTER):
killEvents(event);
MENU_ADD_ITEM(STR_RESET_TELEMETRY);
MENU_ADD_ITEM(STR_RESET_FLIGHT);
menuHandler = onMainViewMenu;
break;
#else
case EVT_KEY_FIRST(KEY_ENTER):
resetTelemetry();
break;
#endif
}
lcdDrawTelemetryTopBar();
if (frskyStreaming >= 0) {
if (s_frsky_view < MAX_FRSKY_SCREENS) {
FrSkyScreenData & screen = g_model.frsky.screens[s_frsky_view];
if (g_model.frsky.screensType & (1<<s_frsky_view)) {
// Custom Screen with gauges
uint8_t barHeight = 5;
for (int8_t i=3; i>=0; i--) {
FrSkyBarData & bar = screen.bars[i];
uint8_t source = bar.source;
getvalue_t barMin = convertTelemValue(source, bar.barMin);
getvalue_t barMax = convertTelemValue(source, 255-bar.barMax);
if (source && barMax > barMin) {
uint8_t y = barHeight+6+i*(barHeight+6);
lcd_putsiAtt(0, y+barHeight-5, STR_VTELEMCHNS, source, 0);
lcd_rect(25, y, 101, barHeight+2);
getvalue_t value = getValue(MIXSRC_FIRST_TELEM+source-2);
getvalue_t threshold = 0;
uint8_t thresholdX = 0;
if (source <= TELEM_TM2)
threshold = 0;
else if (source <= TELEM_RSSI_RX)
threshold = getRssiAlarmValue(source-TELEM_RSSI_TX);
else if (source <= TELEM_A2)
threshold = g_model.frsky.channels[source-TELEM_A1].alarms_value[0];
#if defined(FRSKY_HUB)
else
threshold = convertTelemValue(source, barsThresholds[source-TELEM_ALT]);
#endif
if (threshold) {
thresholdX = barCoord(threshold, barMin, barMax);
if (thresholdX == 100)
thresholdX = 0;
}
uint8_t width = barCoord(value, barMin, barMax);
// reversed barshade for T1/T2
uint8_t barShade = ((threshold > value) ? DOTTED : SOLID);
if (source == TELEM_T1 || source == TELEM_T2)
barShade = -barShade;
lcd_filled_rect(26, y+1, width, barHeight, barShade);
for (uint8_t j=50; j<125; j+=25)
if (j>26+thresholdX || j>26+width) lcd_vline(j, y+1, barHeight);
if (thresholdX) {
lcd_vlineStip(26+thresholdX, y-2, barHeight+3, DOTTED);
lcd_hline(25+thresholdX, y-2, 3);
}
}
else {
barHeight += 2;
}
}
displayRssiLine();
}
else {
// Custom Screen with numbers
uint8_t fields_count = 0;
for (uint8_t i=0; i<4; i++) {
for (uint8_t j=0; j<NUM_LINE_ITEMS; j++) {
uint8_t field = screen.lines[i].sources[j];
if (i==3 && j==0) {
#if LCD_W >= 212
lcd_vline(69, 8, 48);
lcd_vline(141, 8, 48);
#else
lcd_vline(63, 8, 48);
#endif
if (frskyStreaming > 0) {
#if defined(FRSKY_HUB)
if (field == TELEM_ACC) {
lcd_putsLeft(7*FH+1, STR_ACCEL);
lcd_outdezNAtt(4*FW, 7*FH+1, frskyData.hub.accelX, LEFT|PREC2);
lcd_outdezNAtt(10*FW, 7*FH+1, frskyData.hub.accelY, LEFT|PREC2);
lcd_outdezNAtt(16*FW, 7*FH+1, frskyData.hub.accelZ, LEFT|PREC2);
break;
}
else if (field == TELEM_GPS_TIME) {
displayGpsTime();
return;
}
#endif
}
else {
displayRssiLine();
return;
}
}
if (field) {
fields_count++;
getvalue_t value = getValue(MIXSRC_FIRST_TELEM+field-2);
uint8_t att = (i==3 ? NO_UNIT : DBLSIZE|NO_UNIT);
#if LCD_W >= 212
xcoord_t pos[] = {0, 71, 143, 214};
#else
xcoord_t pos[] = {0, 65, 130};
#endif
putsTelemetryChannel(pos[j+1]-2, 1+FH+2*FH*i, field-1, value, att);
#if LCD_W < 212
if (field >= TELEM_TM1 && field <= TELEM_TM2 && i!=3) {
// there is not enough space on LCD for displaying "Tmr1" or "Tmr2", we write "T1" or "T2" instead
field = field-TELEM_TM1+TELEM_T1;
}
#endif
lcd_putsiAtt(pos[j], 1+FH+2*FH*i, STR_VTELEMCHNS, field, 0);
}
}
}
lcd_status_line();
if (fields_count == 0)
putEvent(event == EVT_KEY_BREAK(KEY_UP) ? event : EVT_KEY_BREAK(KEY_DOWN));
}
}
else if (s_frsky_view == e_frsky_voltages) {
// Volts / Amps / Watts / mAh
uint8_t analog = 0;
lcd_putsiAtt(0, 2*FH, STR_VOLTSRC, g_model.frsky.voltsSource+1, 0);
switch(g_model.frsky.voltsSource) {
case 0:
case 1:
displayVoltageScreenLine(2*FH, g_model.frsky.voltsSource);
analog = 1+g_model.frsky.voltsSource;
break;
#if defined(FRSKY_HUB)
case 2:
putsTelemetryChannel(3*FW+6*FW+4, FH+1, TELEM_VFAS-1, frskyData.hub.vfas, DBLSIZE);
break;
case 3:
putsTelemetryChannel(3*FW+6*FW+4, FH+1, TELEM_CELLS_SUM-1, frskyData.hub.cellsSum, DBLSIZE);
break;
#endif
}
if (g_model.frsky.currentSource) {
lcd_putsiAtt(0, 4*FH, STR_VOLTSRC, g_model.frsky.currentSource, 0);
switch(g_model.frsky.currentSource) {
case 1:
case 2:
displayVoltageScreenLine(4*FH, g_model.frsky.currentSource-1);
break;
#if defined(FRSKY_HUB)
case 3:
putsTelemetryChannel(3*FW+6*FW+4, 3*FH+1, TELEM_CURRENT-1, frskyData.hub.current, DBLSIZE);
break;
#endif
}
putsTelemetryChannel(4, 5*FH+1, TELEM_POWER-1, frskyData.power, LEFT|DBLSIZE);
putsTelemetryChannel(3*FW+4+4*FW+6*FW+FW, 5*FH+1, TELEM_CONSUMPTION-1, frskyData.currentConsumption, DBLSIZE);
}
else {
displayVoltageScreenLine(analog > 0 ? 5*FH : 4*FH, analog ? 2-analog : 0);
if (analog == 0) displayVoltageScreenLine(6*FH, 1);
}
#if defined(FRSKY_HUB)
// Cells voltage
if (frskyData.hub.cellsCount > 0) {
uint8_t y = 1*FH;
for (uint8_t k=0; k<frskyData.hub.cellsCount && k<6; k++) {
uint8_t attr = (barsThresholds[THLD_CELL] && frskyData.hub.cellVolts[k] < barsThresholds[THLD_CELL]) ? BLINK|PREC2 : PREC2;
lcd_outdezNAtt(LCD_W, y, frskyData.hub.cellVolts[k] * 2, attr, 4);
y += 1*FH;
}
lcd_vline(LCD_W-3*FW-2, 8, 47);
}
#endif
displayRssiLine();
}
#if defined(FRSKY_HUB)
else if (s_frsky_view == e_frsky_after_flight) {
uint8_t line=1*FH+1;
if (IS_USR_PROTO_FRSKY_HUB()) {
// Latitude
lcd_putsLeft(line, STR_LATITUDE);
displayGpsCoord(line, frskyData.hub.gpsLatitudeNS, frskyData.hub.gpsLatitude_bp, frskyData.hub.gpsLatitude_ap);
// Longitude
line+=1*FH+1;
lcd_putsLeft(line, STR_LONGITUDE);
displayGpsCoord(line, frskyData.hub.gpsLongitudeEW, frskyData.hub.gpsLongitude_bp, frskyData.hub.gpsLongitude_ap);
displayGpsTime();
line+=1*FH+1;
}
// Rssi
lcd_putsLeft(line, STR_MINRSSI);
lcd_puts(10*FW, line, STR_TX);
lcd_outdezNAtt(lcdLastPos, line, frskyData.rssi[1].min, LEFT|LEADING0, 2);
lcd_puts(16*FW, line, STR_RX);
lcd_outdezNAtt(lcdLastPos, line, frskyData.rssi[0].min, LEFT|LEADING0, 2);
}
#endif
}
else {
lcd_putsAtt(22, 40, STR_NODATA, DBLSIZE);
}
}