From 62f921404ee5625bdba4e6a1eca817c3554f68f4 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Sun, 23 Feb 2014 09:22:51 +0100 Subject: [PATCH 1/6] Indication of current flight mode in global vars - 1st part: the 2 seconds --- radio/src/gui/menu_model.cpp | 10 +++++++++- radio/src/gui/menus.cpp | 8 ++++++++ radio/src/gui/menus.h | 4 ++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/radio/src/gui/menu_model.cpp b/radio/src/gui/menu_model.cpp index d1dd68a46..527f147a0 100644 --- a/radio/src/gui/menu_model.cpp +++ b/radio/src/gui/menu_model.cpp @@ -4087,7 +4087,15 @@ void onGVARSMenu(const char *result) void menuModelGVars(uint8_t event) { - MENU(STR_MENUGLOBALVARS, menuTabModel, e_GVars, 1+MAX_GVARS, {0, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES}); + tmr10ms_t tmr10ms = get_tmr10ms(); + const char * menuTitle; + + if (tmr10ms - menuEntryTime > 200/*2 seconds*/) + menuTitle = "GLOBAL V."; // TODO translate + else + menuTitle = STR_MENUGLOBALVARS; + + MENU(menuTitle, menuTabModel, e_GVars, 1+MAX_GVARS, {0, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES, NAVIGATION_LINE_BY_LINE|MAX_PHASES}); uint8_t sub = m_posVert - 1; diff --git a/radio/src/gui/menus.cpp b/radio/src/gui/menus.cpp index dfc74980e..51577c47a 100644 --- a/radio/src/gui/menus.cpp +++ b/radio/src/gui/menus.cpp @@ -358,6 +358,10 @@ void onLongMenuPress(const char *result) } #endif +#if defined(CPUARM) +tmr10ms_t menuEntryTime; +#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; @@ -522,6 +526,9 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t switch(event) { case EVT_ENTRY: +#if defined(CPUARM) + menuEntryTime = get_tmr10ms(); +#endif l_posVert = POS_VERT_INIT; l_posHorz = POS_HORZ_INIT(l_posVert); SET_SCROLLBAR_X(LCD_W-1); @@ -538,6 +545,7 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t #if defined(PCBTARANIS) case EVT_ENTRY_UP: + menuEntryTime = get_tmr10ms(); s_editMode = 0; l_posHorz = POS_HORZ_INIT(l_posVert); SET_SCROLLBAR_X(LCD_W-1); diff --git a/radio/src/gui/menus.h b/radio/src/gui/menus.h index 02ae64ca6..479be9039 100644 --- a/radio/src/gui/menus.h +++ b/radio/src/gui/menus.h @@ -88,6 +88,10 @@ inline void displayColumnHeader(const char **headers, uint8_t index) #define horzpos_t uint8_t #endif +#if defined(CPUARM) + extern tmr10ms_t menuEntryTime; +#endif + extern vertpos_t m_posVert; extern horzpos_t m_posHorz; extern vertpos_t s_pgOfs; From 7195ad38066a2586fe8e67f755d49183f6de6baa Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Sun, 23 Feb 2014 09:54:12 +0100 Subject: [PATCH 2/6] The headers in the top bar - still the page number to remove! --- radio/src/gui/menu_model.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/radio/src/gui/menu_model.cpp b/radio/src/gui/menu_model.cpp index 527f147a0..1b812eee7 100644 --- a/radio/src/gui/menu_model.cpp +++ b/radio/src/gui/menu_model.cpp @@ -4085,15 +4085,22 @@ void onGVARSMenu(const char *result) } } +#define GVARS_FM_COLUMN(p) (12*FW + FWNUM + (p)*(2+3*FWNUM) - 3) + void menuModelGVars(uint8_t event) { tmr10ms_t tmr10ms = get_tmr10ms(); const char * menuTitle; - if (tmr10ms - menuEntryTime > 200/*2 seconds*/) + if (tmr10ms - menuEntryTime > 200/*2 seconds*/) { menuTitle = "GLOBAL V."; // TODO translate - else + for (int i=0; i0) ? BLINK|INVERS : INVERS) : 0); - xcoord_t x = 12*FW + FWNUM + (j-1)*(2+3*FWNUM) - 3; + xcoord_t x = GVARS_FM_COLUMN(j-1); #if MAX_GVARS == 6 if (i==0 && j!=9) putsStrIdx(x+2, FH+1, STR_FP, j, SMLSIZE); From ed6fc15a13a538a9eb3815c00ea5cbce2ab533ee Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Sun, 23 Feb 2014 19:09:17 +0100 Subject: [PATCH 3/6] Screen index hidden on GVARS screen (after 2 seconds) --- radio/src/gui/menu_model.cpp | 5 +- radio/src/gui/menus.cpp | 404 +++++++++++++++++++++++------------ radio/src/gui/menus.h | 17 +- 3 files changed, 291 insertions(+), 135 deletions(-) diff --git a/radio/src/gui/menu_model.cpp b/radio/src/gui/menu_model.cpp index 1b812eee7..427634daa 100644 --- a/radio/src/gui/menu_model.cpp +++ b/radio/src/gui/menu_model.cpp @@ -4091,8 +4091,9 @@ void menuModelGVars(uint8_t event) { tmr10ms_t tmr10ms = get_tmr10ms(); const char * menuTitle; + bool first2seconds = (tmr10ms - menuEntryTime > 200); /*2 seconds*/ - if (tmr10ms - menuEntryTime > 200/*2 seconds*/) { + if (first2seconds) { menuTitle = "GLOBAL V."; // TODO translate for (int i=0; i scroll values - static int16_t p1val; - static int16_t p1valprev; - p1valdiff = (p1val-calibratedStick[6]) / SCROLL_POT1_TH; - if (p1valdiff) { - p1valdiff = (p1valprev-calibratedStick[6]) / 2; - p1val = calibratedStick[6]; - } - p1valprev = calibratedStick[6]; -#endif - -#ifdef NAVIGATION_POT2 - // check pot 2 - if changed -> scroll menu - static int16_t p2valprev; - p2valdiff = (p2valprev-calibratedStick[4]) / SCROLL_TH; - if (p2valdiff) p2valprev = calibratedStick[4]; -#endif - -#ifdef NAVIGATION_POT3 - // check pot 3 if changed -> cursor down/up - static int16_t p3valprev; - int8_t scrollUD = (p3valprev-calibratedStick[5]) / SCROLL_TH; - if (scrollUD) p3valprev = calibratedStick[5]; -#else #define scrollUD 0 -#endif if (p2valdiff || scrollUD || p1valdiff) backlightOn(); // on keypress turn the light on if (menuTab) { uint8_t attr = 0; -#if defined(PCBTARANIS) int8_t cc = curr; switch(event) { case EVT_KEY_LONG(KEY_MENU): @@ -439,7 +413,271 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t chainMenu((MenuFuncP)pgm_read_adr(&menuTab[cc])); return false; } + + s_noScroll = 0; + + if (!(flags&CHECK_FLAG_NO_SCREEN_INDEX)) { + displayScreenIndex(curr, menuTabSize, attr); + } + + lcd_filled_rect(0, 0, LCD_W, FH, SOLID, FILL_WHITE|GREY_DEFAULT); + } + + DISPLAY_PROGRESS_BAR(menuTab ? lcdLastPos-2*FW-((curr+1)/10*FWNUM)-2 : 20*FW+1); + + if (s_editMode<=0) { + if (scrollUD) { + l_posVert = limit((int8_t)0, (int8_t)(l_posVert - scrollUD), (int8_t)maxrow); + l_posHorz = min((uint8_t)l_posHorz, MAXCOL(l_posVert)); + } + + if (p2valdiff && l_posVert>0) { + l_posHorz = limit((int8_t)0, (int8_t)((uint8_t)l_posHorz - p2valdiff), (int8_t)maxcol); + } + } + + switch(event) + { + case EVT_ENTRY: + menuEntryTime = get_tmr10ms(); + 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; + break; + } + // no break #else + s_editMode = EDIT_MODE_INIT; + break; +#endif + + case EVT_ENTRY_UP: + menuEntryTime = get_tmr10ms(); + s_editMode = 0; + l_posHorz = POS_HORZ_INIT(l_posVert); + SET_SCROLLBAR_X(LCD_W-1); + break; + + case EVT_ROTARY_BREAK: + if (s_editMode > 1) break; + if (m_posHorz < 0 && maxcol > 0 && READ_ONLY_UNLOCKED()) { + l_posHorz = 0; + break; + } + if (!menuTab || l_posVert>0) { + if (READ_ONLY_UNLOCKED()) { + s_editMode = (s_editMode<=0); + } + } + break; + +#if defined(ROTARY_ENCODER_NAVIGATION) + case EVT_ROTARY_LONG: + if (s_editMode > 1) break; + killEvents(event); + if (l_posVert != POS_VERT_INIT) { + l_posVert = POS_VERT_INIT; + s_editMode = EDIT_MODE_INIT; + break; + } + // no break +#endif + case EVT_KEY_LONG(KEY_EXIT): + s_editMode = 0; // TODO needed? we call ENTRY_UP after which does the same + popMenu(); + return false; + + case EVT_KEY_BREAK(KEY_EXIT): +#if defined(ROTARY_ENCODER_NAVIGATION) + if (s_editMode == 0) + s_editMode = EDIT_MODE_INIT; + else +#endif + if (s_editMode>0) { + s_editMode = 0; + break; + } + + if (l_posHorz >= 0 && (COLATTR(l_posVert) & NAVIGATION_LINE_BY_LINE)) { + l_posHorz = -1; + } + else + { + uint8_t posVertInit = POS_VERT_INIT; + if (s_pgOfs != 0 || l_posVert != posVertInit) { + s_pgOfs = 0; + l_posVert = posVertInit; + l_posHorz = POS_HORZ_INIT(l_posVert); + } + else { + popMenu(); + return false; + } + } + break; + + CASE_EVT_ROTARY_MOVE_RIGHT + if (s_editMode != 0) break; + if ((COLATTR(l_posVert) & NAVIGATION_LINE_BY_LINE)) { + if (l_posHorz >= 0) { + INC(l_posHorz, 0, maxcol); + break; + } + } + else { + if (l_posHorz < maxcol) { + l_posHorz++; + break; + } + else { + l_posHorz = 0; + if (!IS_ROTARY_MOVE_RIGHT(event)) + break; + } + } + + do { + INC(l_posVert, POS_VERT_INIT, maxrow); + } while (CURSOR_NOT_ALLOWED_IN_ROW(l_posVert)); + + s_editMode = 0; // if we go down, we must be in this mode + + l_posHorz = POS_HORZ_INIT(l_posVert); + break; + + CASE_EVT_ROTARY_MOVE_LEFT + if (s_editMode != 0) break; + if ((COLATTR(l_posVert) & NAVIGATION_LINE_BY_LINE)) { + if (l_posHorz >= 0) { + DEC(l_posHorz, 0, maxcol); + break; + } + } + else { + if (l_posHorz > 0) { + l_posHorz--; + break; + } + else if (IS_ROTARY_MOVE_LEFT(event) && s_editMode == 0) { + l_posHorz = 0xff; + } + else { + l_posHorz = maxcol; + break; + } + } + + do { + DEC(l_posVert, POS_VERT_INIT, maxrow); + } while (CURSOR_NOT_ALLOWED_IN_ROW(l_posVert)); + + s_editMode = 0; // if we go up, we must be in this mode + + if ((COLATTR(l_posVert) & NAVIGATION_LINE_BY_LINE)) + l_posHorz = -1; + else + l_posHorz = min((uint8_t)l_posHorz, MAXCOL(l_posVert)); + + break; + } + +#if defined(CPUARM) + if (l_posVert<1) s_pgOfs=0; + else if (menuTab && horTab) { + vertpos_t realPosVert = l_posVert; + vertpos_t realPgOfs = s_pgOfs; + vertpos_t realMaxrow = maxrow; + for (vertpos_t i=1; i<=maxrow; i++) { + if (MAXCOL(i) == HIDDEN_ROW) { + realMaxrow--; + if (i < l_posVert) + realPosVert--; + if (i < s_pgOfs) + realPgOfs--; + } + } + if (realPosVert>(LCD_LINES-1)+realPgOfs) realPgOfs = realPosVert-(LCD_LINES-1); + else if (realPosVert<1+realPgOfs) realPgOfs = realPosVert-1; + s_pgOfs = realPgOfs; + for (vertpos_t i=1; i<=realPgOfs; i++) { + if (MAXCOL(i) == HIDDEN_ROW) { + s_pgOfs++; + } + } + maxrow = realMaxrow; + } + else { + uint8_t max = menuTab ? LCD_LINES-1 : LCD_LINES-2; + if (l_posVert>max+s_pgOfs) s_pgOfs = l_posVert-max; + else if (l_posVert<1+s_pgOfs) s_pgOfs = l_posVert-1; + } + +#if LCD_W >= 212 + if (maxrow > LCD_LINES-1 && scrollbar_X) + displayScrollbar(scrollbar_X, FH, LCD_H-FH, s_pgOfs, menuTab ? maxrow : maxrow+1, LCD_LINES-1); +#endif + +#else + uint8_t max = menuTab ? LCD_LINES-1 : LCD_LINES-2; + if (l_posVert<1) s_pgOfs=0; + else if (l_posVert>max+s_pgOfs) s_pgOfs = l_posVert-max; + else if (l_posVert<1+s_pgOfs) s_pgOfs = l_posVert-1; +#endif + m_posVert = l_posVert; + m_posHorz = l_posHorz; + if (s_pgOfs > 0) { + l_posVert--; + if (l_posVert == s_pgOfs && CURSOR_NOT_ALLOWED_IN_ROW(l_posVert)) + s_pgOfs = l_posVert-1; + } + return true; +} + +#else // defined(PCBTARANIS) + +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; + horzpos_t l_posHorz = m_posHorz; + + uint8_t maxcol = MAXCOL(l_posVert); + +#if defined(NAVIGATION_POT1) + // check pot 1 - if changed -> scroll values + static int16_t p1val; + static int16_t p1valprev; + p1valdiff = (p1val-calibratedStick[6]) / SCROLL_POT1_TH; + if (p1valdiff) { + p1valdiff = (p1valprev-calibratedStick[6]) / 2; + p1val = calibratedStick[6]; + } + p1valprev = calibratedStick[6]; +#endif + +#if defined(NAVIGATION_POT2) + // check pot 2 - if changed -> scroll menu + static int16_t p2valprev; + p2valdiff = (p2valprev-calibratedStick[4]) / SCROLL_TH; + if (p2valdiff) p2valprev = calibratedStick[4]; +#endif + +#if defined(NAVIGATION_POT3) + // check pot 3 if changed -> cursor down/up + static int16_t p3valprev; + int8_t scrollUD = (p3valprev-calibratedStick[5]) / SCROLL_TH; + if (scrollUD) p3valprev = calibratedStick[5]; +#else + #define scrollUD 0 +#endif + + if (p2valdiff || scrollUD || p1valdiff) backlightOn(); // on keypress turn the light on + + if (menuTab) { + uint8_t attr = 0; + if (l_posVert==0 && !s_noScroll) { attr = INVERS; @@ -500,14 +738,10 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t attr = INVERS|BLINK; #endif } -#endif s_noScroll = 0; displayScreenIndex(curr, menuTabSize, attr); -#if defined(PCBTARANIS) - lcd_filled_rect(0, 0, LCD_W, FH, SOLID, FILL_WHITE|GREY_DEFAULT); -#endif } DISPLAY_PROGRESS_BAR(menuTab ? lcdLastPos-2*FW-((curr+1)/10*FWNUM)-2 : 20*FW+1); @@ -543,21 +777,7 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t break; #endif -#if defined(PCBTARANIS) - case EVT_ENTRY_UP: - menuEntryTime = get_tmr10ms(); - s_editMode = 0; - l_posHorz = POS_HORZ_INIT(l_posVert); - SET_SCROLLBAR_X(LCD_W-1); - break; - - case EVT_ROTARY_BREAK: - if (s_editMode > 1) break; - if (m_posHorz < 0 && maxcol > 0 && READ_ONLY_UNLOCKED()) { - l_posHorz = 0; - break; - } -#elif defined(ROTARY_ENCODER_NAVIGATION) +#if defined(ROTARY_ENCODER_NAVIGATION) case EVT_ENTRY_UP: s_editMode = 0; SET_SCROLLBAR_X(LCD_W-1); @@ -567,9 +787,7 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t if (s_editMode > 1) break; #endif -#if !defined(PCBTARANIS) case EVT_KEY_FIRST(KEY_ENTER): -#endif if (!menuTab || l_posVert>0) { if (READ_ONLY_UNLOCKED()) { s_editMode = (s_editMode<=0); @@ -603,24 +821,7 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t s_editMode = 0; break; } -#if defined(PCBTARANIS) - if (l_posHorz >= 0 && (COLATTR(l_posVert) & NAVIGATION_LINE_BY_LINE)) { - l_posHorz = -1; - } - else - { - uint8_t posVertInit = POS_VERT_INIT; - if (s_pgOfs != 0 || l_posVert != posVertInit) { - s_pgOfs = 0; - l_posVert = posVertInit; - l_posHorz = POS_HORZ_INIT(l_posVert); - } - else { - popMenu(); - return false; - } - } -#else + if (l_posVert==0 || !menuTab) { popMenu(); // beeps itself return false; @@ -630,39 +831,16 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t l_posVert = 0; l_posHorz = 0; } -#endif break; -#if !defined(PCBTARANIS) case EVT_KEY_REPT(KEY_RIGHT): //inc if (l_posHorz==maxcol) break; // no break case EVT_KEY_FIRST(KEY_RIGHT)://inc if (!horTab || s_editMode>0) break; -#endif -#if defined(PCBTARANIS) - CASE_EVT_ROTARY_MOVE_RIGHT - if (s_editMode != 0) break; - if ((COLATTR(l_posVert) & NAVIGATION_LINE_BY_LINE)) { - if (l_posHorz >= 0) { - INC(l_posHorz, 0, maxcol); - break; - } - } - else { - if (l_posHorz < maxcol) { - l_posHorz++; - break; - } - else { - l_posHorz = 0; - if (!IS_ROTARY_MOVE_RIGHT(event)) - break; - } - } -#elif defined(ROTARY_ENCODER_NAVIGATION) +#if defined(ROTARY_ENCODER_NAVIGATION) CASE_EVT_ROTARY_MOVE_RIGHT if (s_editMode != 0) break; if (l_posHorz < maxcol) { @@ -679,61 +857,31 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t break; #endif -#if !defined(PCBTARANIS) case EVT_KEY_REPT(KEY_DOWN): //inc if (!IS_ROTARY_RIGHT(event) && l_posVert==maxrow) break; // no break case EVT_KEY_FIRST(KEY_DOWN): //inc if (s_editMode>0) break; -#endif do { INC(l_posVert, POS_VERT_INIT, maxrow); } while (CURSOR_NOT_ALLOWED_IN_ROW(l_posVert)); -#if defined(ROTARY_ENCODER_NAVIGATION) || defined(PCBTARANIS) +#if defined(ROTARY_ENCODER_NAVIGATION) s_editMode = 0; // if we go down, we must be in this mode #endif -#if defined(PCBTARANIS) - l_posHorz = POS_HORZ_INIT(l_posVert); -#else l_posHorz = min(l_posHorz, MAXCOL(l_posVert)); -#endif break; -#if !defined(PCBTARANIS) case EVT_KEY_REPT(KEY_LEFT): //dec if (l_posHorz==0) break; // no break case EVT_KEY_FIRST(KEY_LEFT)://dec if (!horTab || s_editMode>0) break; -#endif -#if defined(PCBTARANIS) - CASE_EVT_ROTARY_MOVE_LEFT - if (s_editMode != 0) break; - if ((COLATTR(l_posVert) & NAVIGATION_LINE_BY_LINE)) { - if (l_posHorz >= 0) { - DEC(l_posHorz, 0, maxcol); - break; - } - } - else { - if (l_posHorz > 0) { - l_posHorz--; - break; - } - else if (IS_ROTARY_MOVE_LEFT(event) && s_editMode == 0) { - l_posHorz = 0xff; - } - else { - l_posHorz = maxcol; - break; - } - } -#elif defined(ROTARY_ENCODER_NAVIGATION) +#if defined(ROTARY_ENCODER_NAVIGATION) CASE_EVT_ROTARY_MOVE_LEFT if (s_editMode != 0) break; if (l_posHorz > 0) { @@ -752,13 +900,11 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t break; #endif -#if !defined(PCBTARANIS) case EVT_KEY_REPT(KEY_UP): //dec if (!IS_ROTARY_LEFT(event) && l_posVert==0) break; // no break case EVT_KEY_FIRST(KEY_UP): //dec if (s_editMode>0) break; -#endif do { DEC(l_posVert, POS_VERT_INIT, maxrow); @@ -768,14 +914,7 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t s_editMode = 0; // if we go up, we must be in this mode #endif -#if defined(PCBTARANIS) - if ((COLATTR(l_posVert) & NAVIGATION_LINE_BY_LINE)) - l_posHorz = -1; - else - l_posHorz = min((uint8_t)l_posHorz, MAXCOL(l_posVert)); -#else l_posHorz = min((uint8_t)l_posHorz, MAXCOL(l_posVert)); -#endif break; } @@ -833,6 +972,7 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t #endif return true; } +#endif MenuFuncP g_menuStack[5]; uint8_t g_menuPos[4]; diff --git a/radio/src/gui/menus.h b/radio/src/gui/menus.h index 479be9039..fca197017 100644 --- a/radio/src/gui/menus.h +++ b/radio/src/gui/menus.h @@ -230,7 +230,14 @@ int8_t checkIncDecGen(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max); #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); + +#if defined(PCBTARANIS) + #define CHECK_FLAG_NO_SCREEN_INDEX 1 + 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, uint8_t flags=0); +#else + 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); +#endif + 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); @@ -246,11 +253,19 @@ void title(const pm_char * s); #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__); \ if (!MENU_CHECK(tab, menu, lines_count)) return; \ TITLE(title) +#define MENU_FLAGS(title, tab, menu, flags, lines_count, ...) \ + MENU_TAB(__VA_ARGS__); \ + if (!MENU_CHECK_FLAGS(tab, menu, flags, lines_count)) return; \ + TITLE(title) + #define SIMPLE_MENU_NOTITLE(tab, menu, lines_count) \ if (!check_simple(event,menu,tab,DIM(tab),(lines_count)-1)) return; From 525fee5acd02e86af6df2cd3a154e92232f1e90c Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Sun, 23 Feb 2014 19:14:30 +0100 Subject: [PATCH 4/6] .hex files ignored --- radio/src/.gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radio/src/.gitignore b/radio/src/.gitignore index c58685a26..9bff2bce9 100644 --- a/radio/src/.gitignore +++ b/radio/src/.gitignore @@ -1,7 +1,6 @@ /stamp-opentx.h /opentx.elf /simu -/opentx.hex /opentx.map /simu.d /snapshot_*.png @@ -10,6 +9,7 @@ /*.o /*.bin /*.bin.* +/*.hex /*.lst /SCRIPTS /TEMPLATES From 0bbb3c6b4f972e1104c8416b8033c5b959954dd6 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Sun, 23 Feb 2014 19:57:51 +0100 Subject: [PATCH 5/6] Translation for the string added --- radio/src/gui/menu_model.cpp | 2 +- radio/src/translations.cpp | 1 + radio/src/translations.h | 1 + radio/src/translations/cz.h.txt | 1 + radio/src/translations/de.h.txt | 1 + radio/src/translations/en.h | 1 + radio/src/translations/es.h.txt | 1 + radio/src/translations/fi.h.txt | 1 + radio/src/translations/fr.h.txt | 1 + radio/src/translations/it.h.txt | 1 + radio/src/translations/pl.h.txt | 1 + radio/src/translations/pt.h.txt | 1 + radio/src/translations/se.h.txt | 1 + 13 files changed, 13 insertions(+), 1 deletion(-) diff --git a/radio/src/gui/menu_model.cpp b/radio/src/gui/menu_model.cpp index 427634daa..18614a044 100644 --- a/radio/src/gui/menu_model.cpp +++ b/radio/src/gui/menu_model.cpp @@ -4094,7 +4094,7 @@ void menuModelGVars(uint8_t event) bool first2seconds = (tmr10ms - menuEntryTime > 200); /*2 seconds*/ if (first2seconds) { - menuTitle = "GLOBAL V."; // TODO translate + menuTitle = STR_GLOBAL_V; for (int i=0; i Date: Sun, 23 Feb 2014 19:58:52 +0100 Subject: [PATCH 6/6] Script to automatically add a translation into all files. Syntax: addtr.py TR_GLOBAL_V "GLOBAL V." TR_GLOBAL_VARS --- radio/util/addtr.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 radio/util/addtr.py diff --git a/radio/util/addtr.py b/radio/util/addtr.py new file mode 100644 index 000000000..2c4a45858 --- /dev/null +++ b/radio/util/addtr.py @@ -0,0 +1,36 @@ +#!/bin/env python + +import sys, glob + +string = sys.argv[1] +translation = sys.argv[2] +after = sys.argv[3] + +def addLine(filename, newline): + print filename, newline + lines = file(filename, 'r').readlines() + for i, line in enumerate(lines): + if after in line: + lines.insert(i+1, newline + '\n') + break + file(filename, 'w').writelines(lines) + +def modifyTranslations(): + for filename in ['translations/en.h'] + glob.glob('translations/*.h.txt'): + newline = "#define " + string + " "*(23-len(string)) + '"' + translation + '"' + addLine(filename, newline) + +def modifyDeclaration(): + newline = "extern const pm_char S" + string + "[];" + filename = "translations.h" + addLine(filename, newline) + +def modifyDefinition(): + newline = "const pm_char S" + string + "[] PROGMEM = " + string + ";" + filename = "translations.cpp" + addLine(filename, newline) + +modifyTranslations() +modifyDeclaration() +modifyDefinition() +