From 845e9890bb25e4579ab87617efc92709635be6ba Mon Sep 17 00:00:00 2001 From: bsongis Date: Sun, 30 Nov 2014 22:52:46 +0100 Subject: [PATCH] 18 switches displayed on main screen, thanks Martin for the graphics and font! --- radio/src/gui/Taranis/view_main.cpp | 46 ++++++++++++++++++++++---- radio/src/simu.cpp | 21 +++++++++++- radio/src/targets/simu/simpgmspace.cpp | 10 ++++++ 3 files changed, 70 insertions(+), 7 deletions(-) diff --git a/radio/src/gui/Taranis/view_main.cpp b/radio/src/gui/Taranis/view_main.cpp index 99ddf479f..4e4956900 100755 --- a/radio/src/gui/Taranis/view_main.cpp +++ b/radio/src/gui/Taranis/view_main.cpp @@ -397,6 +397,34 @@ void onMainViewMenu(const char *result) } } +void displaySwitch(coord_t x, coord_t y, int width, unsigned int index) +{ + int val = getValue(MIXSRC_FIRST_SWITCH+index); + + if (val >= 0) { + lcd_hline(x, y, width); + lcd_hline(x, y+2, width); + y += 4; + if (val > 0) { + lcd_hline(x, y, width); + lcd_hline(x, y+2, width); + y += 4; + } + } + + lcd_putcAtt(width==5 ? x+1 : x, y, 'A'+index, TINSIZE); + y += 6; + + if (val <= 0) { + lcd_hline(x, y, width); + lcd_hline(x, y+2, width); + if (val < 0) { + lcd_hline(x, y+4, width); + lcd_hline(x, y+6, width); + } + } +} + void menuMainView(uint8_t event) { STICK_SCROLL_DISABLE(); @@ -483,12 +511,18 @@ void menuMainView(uint8_t event) // Switches #if defined(REV9E) - for (uint8_t i=0; i<8; i++) { - getvalue_t sw; - getvalue_t val; - val = getValue(MIXSRC_SA+i); - sw = ((val < 0) ? 3*i+1 : ((val == 0) ? 3*i+2 : 3*i+3)); - 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); + for (unsigned i=0; i<18; i++) { + div_t qr = div(i, 9); + if (g_eeGeneral.view == VIEW_INPUTS) { + div_t qr2 = div(qr.rem, 5); + if (i >= 14) qr2.rem += 1; + const coord_t x[4] = { 50, 144 }; + const coord_t y[4] = { 25, 42, 25, 42 }; + displaySwitch(x[qr.quot]+qr2.rem*4, y[qr2.quot], 3, i); + } + else { + displaySwitch(15+qr.rem*6, 25+qr.quot*17, 5, i); + } } #else for (uint8_t i=0; i<8; i++) { diff --git a/radio/src/simu.cpp b/radio/src/simu.cpp index 02dc22eec..8d75692bd 100644 --- a/radio/src/simu.cpp +++ b/radio/src/simu.cpp @@ -281,7 +281,26 @@ long Open9xSim::onTimeout(FXObject*, FXSelector, void*) } \ simuSetSwitch(swtch, state_##swtch-states); -#if defined(PCBTARANIS) +#if defined(PCBTARANIS) && defined(REV9E) + SWITCH_KEY(A, 0, 3); + SWITCH_KEY(B, 1, 3); + SWITCH_KEY(C, 2, 3); + SWITCH_KEY(D, 3, 3); + SWITCH_KEY(E, 4, 3); + SWITCH_KEY(F, 5, 3); + SWITCH_KEY(G, 6, 3); + SWITCH_KEY(H, 7, 3); + SWITCH_KEY(I, 8, 3); + SWITCH_KEY(J, 9, 3); + SWITCH_KEY(K, 10, 3); + SWITCH_KEY(L, 11, 3); + SWITCH_KEY(M, 12, 3); + SWITCH_KEY(N, 13, 3); + SWITCH_KEY(O, 14, 3); + SWITCH_KEY(P, 15, 3); + SWITCH_KEY(Q, 16, 3); + SWITCH_KEY(R, 17, 3); +#elif defined(PCBTARANIS) SWITCH_KEY(A, 0, 3); SWITCH_KEY(B, 1, 3); SWITCH_KEY(C, 2, 3); diff --git a/radio/src/targets/simu/simpgmspace.cpp b/radio/src/targets/simu/simpgmspace.cpp index cf066d600..947a61215 100644 --- a/radio/src/targets/simu/simpgmspace.cpp +++ b/radio/src/targets/simu/simpgmspace.cpp @@ -187,6 +187,16 @@ void simuSetSwitch(uint8_t swtch, int8_t state) SWITCH_3_CASE(5, GPIO_PIN_SW_F_H, GPIO_PIN_SW_F_L, PIN_SW_F_H, PIN_SW_F_L) SWITCH_3_CASE(6, GPIO_PIN_SW_G_L, GPIO_PIN_SW_G_H, PIN_SW_G_L, PIN_SW_G_H) SWITCH_3_CASE(7, GPIO_PIN_SW_H_L, GPIO_PIN_SW_H_H, PIN_SW_H_H, PIN_SW_H_L) + SWITCH_3_CASE(8, GPIO_PIN_SW_I_L, GPIO_PIN_SW_I_H, PIN_SW_I_H, PIN_SW_I_L) + SWITCH_3_CASE(9, GPIO_PIN_SW_J_L, GPIO_PIN_SW_J_H, PIN_SW_J_H, PIN_SW_J_L) + SWITCH_3_CASE(10, GPIO_PIN_SW_K_L, GPIO_PIN_SW_K_H, PIN_SW_K_H, PIN_SW_I_L) + SWITCH_3_CASE(11, GPIO_PIN_SW_L_L, GPIO_PIN_SW_L_H, PIN_SW_L_H, PIN_SW_J_L) + SWITCH_3_CASE(12, GPIO_PIN_SW_M_L, GPIO_PIN_SW_M_H, PIN_SW_M_H, PIN_SW_I_L) + SWITCH_3_CASE(13, GPIO_PIN_SW_N_L, GPIO_PIN_SW_N_H, PIN_SW_N_H, PIN_SW_J_L) + SWITCH_3_CASE(14, GPIO_PIN_SW_O_L, GPIO_PIN_SW_O_H, PIN_SW_O_H, PIN_SW_I_L) + SWITCH_3_CASE(15, GPIO_PIN_SW_P_L, GPIO_PIN_SW_P_H, PIN_SW_P_H, PIN_SW_J_L) + SWITCH_3_CASE(16, GPIO_PIN_SW_Q_L, GPIO_PIN_SW_Q_H, PIN_SW_Q_H, PIN_SW_I_L) + SWITCH_3_CASE(17, GPIO_PIN_SW_R_L, GPIO_PIN_SW_R_H, PIN_SW_R_H, PIN_SW_J_L) #elif defined(PCBTARANIS) SWITCH_3_CASE(0, GPIO_PIN_SW_A_L, GPIO_PIN_SW_A_H, PIN_SW_A_L, PIN_SW_A_H) SWITCH_3_CASE(1, GPIO_PIN_SW_B_L, GPIO_PIN_SW_B_H, PIN_SW_B_L, PIN_SW_B_H)