From 7973386f9a85e95e356c52d3d64cf0dd194e7778 Mon Sep 17 00:00:00 2001 From: bsongis Date: Tue, 19 Mar 2013 20:28:33 +0000 Subject: [PATCH] [X9D] Navigation reviewed again! --- src/menus.cpp | 75 +++++++++++++++++++++++++++++++++++---------- src/menus.h | 9 ++++-- src/model_menus.cpp | 30 +++++++++--------- src/x9d/board_x9d.h | 5 +-- 4 files changed, 83 insertions(+), 36 deletions(-) diff --git a/src/menus.cpp b/src/menus.cpp index 6d928d152..f138c62e8 100644 --- a/src/menus.cpp +++ b/src/menus.cpp @@ -231,7 +231,14 @@ void title(const pm_char * s) #define SCROLL_TH 64 #define SCROLL_POT1_TH 32 -#define MAXCOL(row) (horTab ? pgm_read_byte(horTab+min(row, (vertpos_t)horTabMax)) : (const uint8_t)0) +#if defined(PCBX9D) + #define MAXCOL_RAW(row) (horTab ? pgm_read_byte(horTab+min(row, (vertpos_t)horTabMax)) : (const uint8_t)0) + #define MAXCOL(row) (MAXCOL_RAW(row) == (uint8_t)-1 ? (uint8_t)-1 : (const uint8_t)(MAXCOL_RAW(row) & (~NAVIGATION_LINE_BY_LINE))) + #define COLATTR(row) (MAXCOL_RAW(row) == (uint8_t)-1 ? (const uint8_t)0 : (const uint8_t)(MAXCOL_RAW(row) & NAVIGATION_LINE_BY_LINE)) +#else + #define MAXCOL(row) (horTab ? pgm_read_byte(horTab+min(row, (vertpos_t)horTabMax)) : (const uint8_t)0) +#endif + #define INC(val, min, max) if (valmin) {val--;} else {val=max;} @@ -387,7 +394,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_posHorz = POS_HORZ_INIT(l_posVert); #if defined(ROTARY_ENCODER_NAVIGATION) if (menuTab) { s_editMode = EDIT_MODE_INIT; @@ -399,13 +406,12 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t break; #endif -#if defined(ROTARY_ENCODER_NAVIGATION) +#if defined(PCBX9D) case EVT_ENTRY_UP: s_editMode = 0; + l_posHorz = POS_HORZ_INIT(l_posVert); break; -#endif -#if defined(PCBX9D) case EVT_ROTARY_BREAK: if (s_editMode > 1) break; if (m_posHorz < 0 && maxcol > 0) { @@ -413,6 +419,10 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t break; } #elif defined(ROTARY_ENCODER_NAVIGATION) + case EVT_ENTRY_UP: + s_editMode = 0; + break; + case EVT_ROTARY_BREAK: if (s_editMode > 1) break; #endif @@ -451,8 +461,8 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t break; } #if defined(PCBX9D) - if (l_posHorz >= 0 && maxcol > 0) { - l_posHorz = POS_HORZ_INIT; + if (l_posHorz >= 0 && (COLATTR(l_posVert) & NAVIGATION_LINE_BY_LINE)) { + l_posHorz = -1; } else { @@ -460,7 +470,7 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t if (s_pgOfs != 0 || l_posVert != posVertInit) { s_pgOfs = 0; l_posVert = posVertInit; - l_posHorz = POS_HORZ_INIT; + l_posHorz = POS_HORZ_INIT(l_posVert); } else { popMenu(); @@ -492,9 +502,22 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t #if defined(PCBX9D) CASE_EVT_ROTARY_MOVE_RIGHT if (s_editMode != 0) break; - if (l_posHorz >= 0) { - INC(l_posHorz, 0, maxcol); - 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) CASE_EVT_ROTARY_MOVE_RIGHT @@ -530,7 +553,7 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t #endif #if defined(PCBX9D) - l_posHorz = POS_HORZ_INIT; + l_posHorz = POS_HORZ_INIT(l_posVert); #else l_posHorz = min(l_posHorz, MAXCOL(l_posVert)); #endif @@ -548,9 +571,24 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t #if defined(PCBX9D) CASE_EVT_ROTARY_MOVE_LEFT if (s_editMode != 0) break; - if (l_posHorz >= 0) { - DEC(l_posHorz, 0, maxcol); - 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) CASE_EVT_ROTARY_MOVE_LEFT @@ -588,7 +626,10 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t #endif #if defined(PCBX9D) - l_posHorz = POS_HORZ_INIT; + 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 @@ -616,7 +657,7 @@ void popMenu() g_menuStackPtr = g_menuStackPtr-1; AUDIO_KEYPAD_UP(); - m_posHorz = POS_HORZ_INIT; + m_posHorz = 0; m_posVert = g_menuPos[g_menuStackPtr]; (*g_menuStack[g_menuStackPtr])(EVT_ENTRY_UP); } diff --git a/src/menus.h b/src/menus.h index e1b78593d..69d845d3d 100644 --- a/src/menus.h +++ b/src/menus.h @@ -182,6 +182,11 @@ int8_t checkIncDecGen(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max); extern vertpos_t m_posVert; extern horzpos_t m_posHorz; +#if defined(PCBX9D) + #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); @@ -324,11 +329,11 @@ void menuChannelsMonitor(uint8_t event); #if defined(PCBX9D) #define POS_VERT_INIT (menuTab ? (MAXCOL((uint16_t)1) == 255 ? 2 : 1) : 0) - #define POS_HORZ_INIT -1 + #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 0 + #define POS_HORZ_INIT(posVert) 0 #define EDIT_MODE_INIT -1 #endif diff --git a/src/model_menus.cpp b/src/model_menus.cpp index 5bbafb6d3..e8e5be0b4 100644 --- a/src/model_menus.cpp +++ b/src/model_menus.cpp @@ -790,8 +790,10 @@ void menuModelSetup(uint8_t event) #endif #if defined(PCBX9D) - MENU(STR_MENUSETUP, menuTabModel, e_Model, 1+ITEM_MODEL_SETUP_MAX, { 0, 0, CASE_PCBX9D(0) 2, IF_PERSISTENT_TIMERS(0) 0, 0, 2, IF_PERSISTENT_TIMERS(0) 0, 0, 0, 0, 0, 0, 0, 0, 0, NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS-1, LABEL(InternalModule), 2, 2, g_model.failsafeMode==FAILSAFE_CUSTOM ? (uint8_t)1 : (uint8_t)0}); + bool CURSOR_ON_CELL = (m_posHorz >= 0); + MENU(STR_MENUSETUP, menuTabModel, e_Model, 1+ITEM_MODEL_SETUP_MAX, { 0, 0, CASE_PCBX9D(0) 2, IF_PERSISTENT_TIMERS(0) 0, 0, 2, IF_PERSISTENT_TIMERS(0) 0, 0, 0, 0, 0, 0, 0, 0, 0, NAVIGATION_LINE_BY_LINE|(NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS-1), LABEL(InternalModule), 2, 2, g_model.failsafeMode==FAILSAFE_CUSTOM ? (uint8_t)1 : (uint8_t)0}); #else + #define CURSOR_ON_CELL (true) uint8_t protocol = g_model.protocol; MENU(STR_MENUSETUP, menuTabModel, e_Model, ((IS_PPM_PROTOCOL(protocol)||IS_DSM2_PROTOCOL(protocol)||IS_PXX_PROTOCOL(protocol)) ? 1+ITEM_MODEL_SETUP_MAX : ITEM_MODEL_SETUP_MAX), { 0, 0, CASE_PCBX9D(0) 2, IF_PERSISTENT_TIMERS(0) 0, 0, 2, IF_PERSISTENT_TIMERS(0) 0, 0, 0, 0, 0, 0, 0, 0, 0, NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS-1, FIELD_PROTOCOL_MAX, IF_PCBSKY9X(1) 2 }); #endif @@ -973,7 +975,7 @@ void menuModelSetup(uint8_t event) lcd_putsLeft(y, STR_BEEPCTR); for (uint8_t i=0; i= 212 - #define TELEM_COL1 (7*FW) - #define TELEM_COL2 (15*FW) - #define TELEM_COL3 (23*FW) + #define TELEM_COL1 (1*FW) + #define TELEM_COL2 (13*FW) + #define TELEM_COL3 (25*FW) #define TELEM_BARS_COLMIN (3*FW+56) #define TELEM_BARS_COLMAX (20*FW-3) #else @@ -3812,8 +3814,6 @@ enum menuModelTelemetryItems { #define TELEM_BARS_COLMAX (14*FW-3) #endif - - void menuModelTelemetry(uint8_t event) { MENU(STR_MENUTELEMETRY, menuTabModel, e_Telemetry, ITEM_TELEMETRY_MAX+1, {0, (uint8_t)-1, 1, 0, 2, 2, (uint8_t)-1, 1, 0, 2, 2, (uint8_t)-1, 1, 1, USRDATA_LINES 0, 0, IF_VARIO((uint8_t)-1) IF_VARIO(0) IF_VARIO(3) 0, 2, 2, 2, 2, 0, 2, 2, 2, IF_CPUARM(2) IF_CPUARM(0) IF_CPUARM(2) IF_CPUARM(2) IF_CPUARM(2) 2 }); @@ -4064,7 +4064,7 @@ void menuModelTelemetry(uint8_t event) lineIndex = k-ITEM_TELEMETRY_SCREEN_LINE5; } -#if LCD_W >= 212 +#if 0 putsStrIdx(0, y, PSTR(INDENT"Line"), lineIndex+1, m_posHorz<0 ? attr : 0); #endif @@ -4076,8 +4076,8 @@ void menuModelTelemetry(uint8_t event) putsTelemetryChannel(TELEM_BARS_COLMIN, y, barSource-1, convertTelemValue(barSource, bar.barMin), (m_posHorz==1 ? attr : 0) | LEFT); putsTelemetryChannel(TELEM_BARS_COLMAX, y, barSource-1, convertTelemValue(barSource, 255-bar.barMax), (m_posHorz==2 ? attr : 0) | LEFT); } - else { - if (attr && m_posHorz>=0) m_posHorz = 0; + else if (attr && m_posHorz>0) { + REPEAT_LAST_CURSOR_MOVE(); } if (attr && (s_editMode>0 || p1valdiff)) { switch (m_posHorz) { diff --git a/src/x9d/board_x9d.h b/src/x9d/board_x9d.h index c68598080..4cdb1683a 100644 --- a/src/x9d/board_x9d.h +++ b/src/x9d/board_x9d.h @@ -78,16 +78,17 @@ uint8_t getTemperature(); extern uint16_t sessionTimer; +/* USB driver */ uint8_t usbPlugged(void); #define BOOTLOADER_REQUEST() (0) #define usbBootloader() -#define SLAVE_MODE() (0/*pwrCheck() == e_power_trainer*/) +#define SLAVE_MODE() (0/*pwrCheck() == e_power_trainer*/) void delaysInit(); #define DEBUG_UART_BAUDRATE 115200 -#define SPORT_BAUDRATE 9600 +#define SPORT_BAUDRATE 9600 void uartInit(uint32_t baudrate); void uartPutc(const char c);