From 8c4610ede75666da2b0add1ae8095222d59e5821 Mon Sep 17 00:00:00 2001 From: "bsongis@gmail.com" Date: Sat, 17 Aug 2013 07:07:01 +0000 Subject: [PATCH] [all] Issue 104 fixed (inputs instead of sticks for BL activation). Should spare some flash on stock, but I didn't check [Taranis] No scrollbar on failsafe screen (and some arrangements to keep consistency with other menus) [Taranis] PPM_UNIT=PREC0 / US taken into account in channels view --- src/Makefile | 9 -------- src/gui/menu_model.cpp | 45 ++++++++++++++++++--------------------- src/gui/menus.cpp | 11 ++++++++-- src/gui/menus.h | 11 ++++++++++ src/gui/view_channels.cpp | 15 +++++++++---- src/myeeprom.h | 8 +++---- src/opentx.cpp | 14 ++++++------ src/opentx.h | 2 +- src/translations/en.h | 4 ++-- 9 files changed, 67 insertions(+), 52 deletions(-) diff --git a/src/Makefile b/src/Makefile index f1a4d7712..490879b0a 100644 --- a/src/Makefile +++ b/src/Makefile @@ -233,10 +233,6 @@ FLIGHT_MODES = YES # Values = YES, NO CURVES = YES -# Customizable Curves -# Values = YES, NO -XCURVES = YES - # Global Vars # Values = YES, NO GVARS = NO @@ -274,7 +270,6 @@ ifeq ($(PCB), $(filter $(PCB), STD 9X 9XR)) TRGT = avr- MCU = atmega64 OPT = s - XCURVES = NO SDCARD = NO THR_TRACE = NO EXTRAINCDIRS = targets/stock @@ -793,10 +788,6 @@ ifeq ($(CURVES), YES) CPPDEFS += -DCURVES endif -ifeq ($(XCURVES), YES) - CPPDEFS += -DXCURVES -endif - ifeq ($(GVARS), YES) CPPDEFS += -DGVARS EEPROM_VARIANT += ${GVARS_VARIANT} diff --git a/src/gui/menu_model.cpp b/src/gui/menu_model.cpp index 3717d4a9b..8320a1c05 100644 --- a/src/gui/menu_model.cpp +++ b/src/gui/menu_model.cpp @@ -650,15 +650,17 @@ void menuModelFailsafe(uint8_t event) bool newLongNames = false; uint8_t ch; - SUBMENU_NOTITLE(32, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}); - - switch(event) - { - case EVT_KEY_BREAK(KEY_EXIT): - popMenu(); - return; + if (event == EVT_KEY_BREAK(KEY_ENTER) && s_editMode) { + g_model.moduleData[g_moduleIdx].failsafeChannels[m_posVert] = channelOutputs[m_posVert]; + eeDirty(EE_MODEL); + AUDIO_WARNING1(); + SEND_FAILSAFE_NOW(g_moduleIdx); } + SIMPLE_SUBMENU_NOTITLE(32); + + SET_SCROLLBAR_X(0); + if (m_posVert >= 16) ch = 16; else @@ -687,17 +689,8 @@ void menuModelFailsafe(uint8_t event) else val = g_model.moduleData[g_moduleIdx].failsafeChannels[8*col+line]; - if (m_posVert == ch && event == EVT_KEY_LONG(KEY_ENTER)) { - g_model.moduleData[g_moduleIdx].failsafeChannels[8*col+line] = val; - eeDirty(EE_MODEL); - s_editMode = 0; - AUDIO_WARNING1(); - SEND_FAILSAFE_NOW(g_moduleIdx); - killEvents(event); - } - // Channel name if present, number if not - uint8_t lenLabel = zlen(g_model.limitData[ch].name, sizeof(g_model.limitData[ch].name)); + uint8_t lenLabel = ZLEN(g_model.limitData[ch].name); if (lenLabel > 4) { newLongNames = longNames = true; } @@ -707,18 +700,23 @@ void menuModelFailsafe(uint8_t event) else putsChn(x+1-ofs, y, ch+1, SMLSIZE); - uint8_t wbar = (longNames ? 48 : 58); - // Value - LcdFlags flags = PREC1 | TINSIZE; - + LcdFlags flags = TINSIZE; if (m_posVert == ch) { flags |= INVERS; if (s_editMode) flags |= BLINK; } - - lcd_outdezNAtt(x+LCD_W/2-3-wbar-ofs, y+1, calcRESXto1000(val), flags); +#if defined(PPM_UNIT_US) + uint8_t wbar = (longNames ? 54 : 64); + lcd_outdezAtt(x+LCD_W/2-4-wbar-ofs, y, PPM_CH_CENTER(ch)+val/2, flags); +#elif defined(PPM_UNIT_PERCENT_PREC1) + uint8_t wbar = (longNames ? 48 : 58); + lcd_outdezAtt(x+LCD_W/2-4-wbar-ofs, y, calcRESXto1000(val), PREC1|flags); +#else + uint8_t wbar = (longNames ? 54 : 64); + lcd_outdezAtt(x+LCD_W/2-4-wbar-ofs, y, calcRESXto1000(val)/10, flags); +#endif // Gauge lcd_rect(x+LCD_W/2-3-wbar-ofs, y, wbar+1, 6); @@ -735,7 +733,6 @@ void menuModelFailsafe(uint8_t event) } longNames = newLongNames; - } #endif diff --git a/src/gui/menus.cpp b/src/gui/menus.cpp index 5092aea89..10a3e0aad 100644 --- a/src/gui/menus.cpp +++ b/src/gui/menus.cpp @@ -317,6 +317,10 @@ void title(const pm_char * s) #define INC(val, min, max) if (valmin) {val--;} else {val=max;} +#if LCD_W >= 212 +uint8_t scrollbar_X = LCD_W-1; +#endif + bool 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) { vertpos_t l_posVert = m_posVert; @@ -476,6 +480,7 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t case EVT_ENTRY: l_posVert = POS_VERT_INIT; l_posHorz = POS_HORZ_INIT(l_posVert); + SET_SCROLLBAR_X(LCD_W-1); #if defined(ROTARY_ENCODER_NAVIGATION) if (menuTab) { s_editMode = EDIT_MODE_INIT; @@ -491,6 +496,7 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t case EVT_ENTRY_UP: s_editMode = 0; l_posHorz = POS_HORZ_INIT(l_posVert); + SET_SCROLLBAR_X(LCD_W-1); break; case EVT_ROTARY_BREAK: @@ -502,6 +508,7 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t #elif defined(ROTARY_ENCODER_NAVIGATION) case EVT_ENTRY_UP: s_editMode = 0; + SET_SCROLLBAR_X(LCD_W-1); break; case EVT_ROTARY_BREAK: @@ -749,8 +756,8 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t } #if LCD_W >= 212 - if (maxrow > LCD_LINES-1) - displayScrollbar(LCD_W-1, FH, LCD_H-FH, s_pgOfs, maxrow, LCD_LINES-1); + if (maxrow > LCD_LINES-1 && scrollbar_X) + displayScrollbar(scrollbar_X, FH, LCD_H-FH, s_pgOfs, maxrow, LCD_LINES-1); #endif #else diff --git a/src/gui/menus.h b/src/gui/menus.h index 114ebc8a5..711e5ef0e 100644 --- a/src/gui/menus.h +++ b/src/gui/menus.h @@ -45,6 +45,17 @@ inline void displayColumnHeader(const char **headers, uint8_t index) lcd_putsAtt(17*FW, 0, headers[index], 0); } +#if !defined(CPUM64) + void displayScrollbar(xcoord_t x, uint8_t y, uint8_t h, uint16_t offset, uint16_t count, uint8_t visible); +#endif + +#if LCD_W >= 212 + extern uint8_t scrollbar_X; + #define SET_SCROLLBAR_X(x) scrollbar_X = (x); +#else + #define SET_SCROLLBAR_X(x) +#endif + #if LCD_W >= 212 #if defined(TRANSLATIONS_FR) #define MENU_COLUMNS 1 diff --git a/src/gui/view_channels.cpp b/src/gui/view_channels.cpp index b3d940757..aec4cebb0 100644 --- a/src/gui/view_channels.cpp +++ b/src/gui/view_channels.cpp @@ -76,7 +76,7 @@ void menuChannelsView(uint8_t event) 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)); + uint8_t lenLabel = ZLEN(g_model.limitData[ch].name); if (lenLabel > 4) { newLongNames = longNames = true; } @@ -86,10 +86,17 @@ void menuChannelsView(uint8_t event) 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); +#if defined(PPM_UNIT_US) + uint8_t wbar = (longNames ? 54 : 64); + lcd_outdezAtt(x+LCD_W/2-3-wbar-ofs, y+1, PPM_CH_CENTER(ch)+val/2, TINSIZE); +#elif defined(PPM_UNIT_PERCENT_PREC1) + uint8_t wbar = (longNames ? 48 : 58); + lcd_outdezAtt(x+LCD_W/2-3-wbar-ofs, y+1, calcRESXto1000(val), PREC1|TINSIZE); +#else + uint8_t wbar = (longNames ? 54 : 64); + lcd_outdezAtt(x+LCD_W/2-3-wbar-ofs, y+1, calcRESXto1000(val)/10, TINSIZE); // G: Don't like the decimal part* +#endif // Gauge lcd_rect(x+LCD_W/2-3-wbar-ofs, y, wbar+1, 6); diff --git a/src/myeeprom.h b/src/myeeprom.h index 20aa7599e..35d34d34c 100644 --- a/src/myeeprom.h +++ b/src/myeeprom.h @@ -257,10 +257,10 @@ enum ModuleIndex { #endif enum BacklightMode { - e_backlight_mode_off = 0, - e_backlight_mode_keys, - e_backlight_mode_sticks, - e_backlight_mode_both, + e_backlight_mode_off = 0, + e_backlight_mode_keys = 1, + e_backlight_mode_sticks = 2, + e_backlight_mode_all = e_backlight_mode_keys+e_backlight_mode_sticks, e_backlight_mode_on }; diff --git a/src/opentx.cpp b/src/opentx.cpp index e5bb44f04..f04f007f2 100644 --- a/src/opentx.cpp +++ b/src/opentx.cpp @@ -416,7 +416,7 @@ void generalDefault() #endif #if !defined(CPUM64) - g_eeGeneral.backlightMode = e_backlight_mode_both; + g_eeGeneral.backlightMode = e_backlight_mode_all; g_eeGeneral.lightAutoOff = 2; g_eeGeneral.inactivityTimer = 10; #endif @@ -1499,11 +1499,13 @@ FORCEINLINE void convertUnit(getvalue_t & val, uint8_t & unit) #define INAC_DEVISOR 512 // bypass splash screen with stick movement #define INAC_DEV_SHIFT 9 // shift right value for stick movement -uint16_t stickMoveValue() +uint8_t inputsMoveValue() { - uint16_t sum = 0; + uint8_t sum = 0; for (uint8_t i=0; i> INAC_DEV_SHIFT; + for (uint8_t i=0; i> 10; return sum; } @@ -1518,7 +1520,7 @@ void checkBacklight() uint8_t x = g_blinkTmr10ms; if (tmr10ms != x) { tmr10ms = x; - uint16_t tsum = stickMoveValue(); + uint8_t tsum = inputsMoveValue(); if (tsum != inactivity.sum) { inactivity.sum = tsum; inactivity.counter = 0; @@ -1578,7 +1580,7 @@ void doSplash() getADC(); // init ADC array - uint16_t inacSum = stickMoveValue(); + uint8_t inacSum = inputsMoveValue(); tmr10ms_t tgtime = get_tmr10ms() + SPLASH_TIMEOUT; while (tgtime != get_tmr10ms()) { @@ -1590,7 +1592,7 @@ void doSplash() getADC(); - uint16_t tsum = stickMoveValue(); + uint8_t tsum = inputsMoveValue(); #if defined(FSPLASH) || defined(XSPLASH) if (!(g_eeGeneral.splashMode & 0x04)) diff --git a/src/opentx.h b/src/opentx.h index f63ffc3b7..57eebc264 100644 --- a/src/opentx.h +++ b/src/opentx.h @@ -729,7 +729,7 @@ void watchdogSetTimeout(uint32_t timeout); struct t_inactivity { uint16_t counter; - uint16_t sum; + uint8_t sum; }; extern struct t_inactivity inactivity; diff --git a/src/translations/en.h b/src/translations/en.h index c2da27c71..e2a203a63 100644 --- a/src/translations/en.h +++ b/src/translations/en.h @@ -53,8 +53,8 @@ #define LEN_VRENAVIG "\003" #define TR_VRENAVIG "No REaREb" -#define LEN_VBLMODE "\004" -#define TR_VBLMODE "OFF ""Keys""Stks""Both""ON\0" +#define LEN_VBLMODE TR("\004", "\006") +#define TR_VBLMODE TR("OFF\0""Keys""Stks""Both""ON\0", "OFF\0 ""Keys\0 ""Inputs""Both\0 ""ON\0") #define LEN_TRNMODE "\003" #define TR_TRNMODE "OFF"" +="" :="