From d7226f5e613616f1a88e6fed9bea7c78c6931287 Mon Sep 17 00:00:00 2001 From: bsongis Date: Tue, 4 Sep 2012 16:17:24 +0000 Subject: [PATCH] Trims/Keys should be correctly displayed in DIAG screen --- src/board_stock.cpp | 2 +- src/general_menus.cpp | 45 +++++++++++++++++++++++-------------------- src/open9x.h | 2 +- 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/src/board_stock.cpp b/src/board_stock.cpp index 73eceafe6..45d6fe290 100644 --- a/src/board_stock.cpp +++ b/src/board_stock.cpp @@ -81,7 +81,7 @@ bool keyState(EnumKeys enuk) uint8_t result = 0 ; if (enuk < (int)DIM(keys)) - return keys[enuk].state() ? 1 : 0; + return keys[enuk].state(); switch(enuk){ case SW_ElevDR: diff --git a/src/general_menus.cpp b/src/general_menus.cpp index 647a78421..0e6143c95 100644 --- a/src/general_menus.cpp +++ b/src/general_menus.cpp @@ -797,23 +797,35 @@ void menuProcDiagVers(uint8_t event) lcd_outdezAtt(8*FW, 7*FH, g_eeGeneral.myVers, LEFT); } +void displayKeyState(uint8_t x, uint8_t y, EnumKeys key) +{ + uint8_t t = keyState(key); + lcd_putcAtt(x, y, t+'0', t ? INVERS : 0); +} + void menuProcDiagKeys(uint8_t event) { SIMPLE_MENU(STR_MENUDIAG, menuTabDiag, e_Keys, 1); - for(uint8_t i=0; i<9; i++) { - uint8_t y=i*FH; //+FH; - if(i>(SW_ID0-SW_BASE_DIAG)) y-=FH; //overwrite ID0 - bool t=keyState((EnumKeys)(SW_BASE_DIAG+i)); - putsSwitches(8*FW, y, i+1, 0); //ohne off,on - lcd_putcAtt(11*FW+2, y, t+'0', t ? INVERS : 0); - } + lcd_puts(14*FW, 3*FH, STR_VTRIM); - for(uint8_t i=0; i<6; i++) { - uint8_t y=(5-i)*FH+2*FH; - bool t=keyState((EnumKeys)(KEY_MENU+i)); - lcd_putsiAtt(0, y, STR_VKEYS, i, 0); - lcd_putcAtt(5*FW+2, y, t+'0', t); + for(uint8_t i=0; i<9; i++) { + uint8_t y = i*FH; //+FH; + if(i>(SW_ID0-SW_BASE_DIAG)) y-=FH; //overwrite ID0 + putsSwitches(8*FW, y, i+1, 0); //ohne off,on + displayKeyState(11*FW+2, y, (EnumKeys)(SW_BASE_DIAG+i)); + + if (i<8) { + y = i/2*FH+FH*4; + lcd_img(14*FW, y, sticks, i/2, 0); + displayKeyState(i&1? 20*FW : 18*FW, y, (EnumKeys)(TRM_BASE+i)); + } + + if (i<6) { + y = (5-i)*FH+2*FH; + lcd_putsiAtt(0, y, STR_VKEYS, i, 0); + displayKeyState(5*FW+2, y, (EnumKeys)(KEY_MENU+i)); + } } #if defined (ROTARY_ENCODERS) @@ -824,15 +836,6 @@ void menuProcDiagKeys(uint8_t event) } #endif - lcd_puts(14*FW, 3*FH, STR_VTRIM); - for(uint8_t i=0; i<4; i++) { - uint8_t y=i*FH+FH*4; - lcd_img(14*FW, y, sticks,i,0); - bool tm=keyState((EnumKeys)(TRM_BASE+2*i)); - lcd_putcAtt(18*FW, y, tm+'0', tm ? INVERS : 0); - bool tp=keyState((EnumKeys)(TRM_BASE+2*i+1)); - lcd_putcAtt(20*FW, y, tp+'0', tp ? INVERS : 0); - } } void menuProcDiagAna(uint8_t event) diff --git a/src/open9x.h b/src/open9x.h index 34514cf63..cb2a4a32d 100644 --- a/src/open9x.h +++ b/src/open9x.h @@ -382,7 +382,7 @@ class Key uint8_t m_state; public: void input(bool val, EnumKeys enuk); - bool state() { return m_vals==FFVAL; } + bool state() { return m_vals > 0; } void pauseEvents() { m_state = KSTATE_PAUSE; m_cnt = 0;} void killEvents() { m_state = KSTATE_KILLED; } };