From ea562a25024b906be06cde5e886c8cd1dab198e5 Mon Sep 17 00:00:00 2001 From: 3djc Date: Mon, 20 Jun 2016 21:12:46 +0200 Subject: [PATCH] 3djc/ls mon bugfix (#3618) * First step into fixing the bug. One issue remains, when left encoding, it requires two exist * Bsongis did magic again ! * Housekeeping --- radio/src/gui/horus/view_channels.cpp | 2 - radio/src/gui/horus/view_logical_switches.cpp | 73 +++++-------------- 2 files changed, 18 insertions(+), 57 deletions(-) diff --git a/radio/src/gui/horus/view_channels.cpp b/radio/src/gui/horus/view_channels.cpp index f88521574..71f91b7df 100644 --- a/radio/src/gui/horus/view_channels.cpp +++ b/radio/src/gui/horus/view_channels.cpp @@ -27,8 +27,6 @@ #define X_OFFSET 30 #define Y_OFFSET 75 -bool menuChannels1(evt_t event); -bool menuChannels2(evt_t event); bool menuOutputs1(evt_t); bool menuOutputs2(evt_t); bool menuMixers1(evt_t); diff --git a/radio/src/gui/horus/view_logical_switches.cpp b/radio/src/gui/horus/view_logical_switches.cpp index e4ef8d6f2..f86ece2a9 100644 --- a/radio/src/gui/horus/view_logical_switches.cpp +++ b/radio/src/gui/horus/view_logical_switches.cpp @@ -20,8 +20,8 @@ #include "opentx.h" -#define X_OFF 15 -#define Y_OFF 55 +#define X_OFF 45 +#define Y_OFF 70 #define HLINE_Y_OFF 215 #define LS_COL_WIDTH 50 #define LS_LINE_HEIGHT 17 @@ -36,40 +36,8 @@ #define CSW_6TH_COLUMN 390 #define NUM_LOGICAL_SWITCH 64 - -int lsScrollIdx = 0; -bool menuLogicalSwitchesMonitor(evt_t, uint8_t); extern void putsEdgeDelayParam(coord_t, coord_t, LogicalSwitchData *, uint8_t, uint8_t); -bool scrollLogicalSwitchesMonitor(evt_t event) -{ - switch (event) { - case EVT_ROTARY_LEFT: - if (lsScrollIdx > 0) { - lsScrollIdx--; - } - else { - lsScrollIdx = NUM_LOGICAL_SWITCH - 1; - } - killEvents(event); - break; - - case EVT_ROTARY_RIGHT: - if (lsScrollIdx < NUM_LOGICAL_SWITCH - 1) { - lsScrollIdx++; - } - else { - lsScrollIdx = 0; - } - killEvents(event); - break; - - case EVT_KEY_FIRST(KEY_EXIT): - popMenu(); - } - return true; -} - void displayLogicalSwitchedDetails(coord_t x, coord_t y, uint8_t idx) { LogicalSwitchData * cs = lswAddress(idx); @@ -119,36 +87,31 @@ void displayLogicalSwitchedDetails(coord_t x, coord_t y, uint8_t idx) } } -bool menuLogicalSwitchesMonitor(evt_t event, uint8_t page) +bool menuLogicalSwitchesMonitor(evt_t event) { char lsString[] = "L64"; - uint8_t col, lsIdx, line; - LcdFlags attr; - lcdColorTable[CUSTOM_COLOR_INDEX] = RGB(160, 160, 160); - scrollLogicalSwitchesMonitor(event); - for (line = 1, lsIdx = 1; line < 9; line++) { - for (col = 1; col < 9; col++, lsIdx++) { - strAppendSigned(&lsString[1], lsIdx, 2); - LogicalSwitchData * cs = lswAddress(lsIdx - 1); - attr = (CENTERED); - if (cs->func == LS_FUNC_NONE) attr += (CUSTOM_COLOR); - else if (getSwitch(SWSRC_SW1 + lsIdx - 1)) attr += (BOLD); - if (lsIdx == (lsScrollIdx + 1)) attr += (INVERS); - lcdDrawText(X_OFF + col * LS_COL_WIDTH, Y_OFF + line * LS_LINE_HEIGHT, lsString, attr); - } + for (uint8_t i = 0; i < NUM_LOGICAL_SWITCH; i++) { + LcdFlags attr = (menuHorizontalPosition == i ? INVERS : 0) | LEFT; + LogicalSwitchData * cs = lswAddress(i); + strAppendSigned(&lsString[1], i + 1, 2); + if (cs->func == LS_FUNC_NONE) + attr += CUSTOM_COLOR; + else if (getSwitch(SWSRC_SW1 + i)) + attr += BOLD; + lcdDrawText(X_OFF + (i & 0x07) * LS_COL_WIDTH, Y_OFF + (i >> 3) * LS_LINE_HEIGHT, lsString, attr); } lcdDrawHorizontalLine(0, HLINE_Y_OFF, LCD_W, SOLID); - displayLogicalSwitchedDetails(X_FUNC, Y_FUNC, lsScrollIdx); - + if (lswAddress(menuHorizontalPosition)->func != LS_FUNC_NONE) { + displayLogicalSwitchedDetails(X_FUNC, Y_FUNC, menuHorizontalPosition); + } + s_editMode = 0; return true; } bool menuLogicalSwitches(evt_t event) { - MENU(STR_MONITOR_SWITCHES, MONITOR_ICONS, menuTabMonitors, e_MonLogicalSwitches, 0, { 0 }); + MENU(STR_MONITOR_SWITCHES, MONITOR_ICONS, menuTabMonitors, e_MonLogicalSwitches, 1, { NUM_LOGICAL_SWITCH - 1 }); lastMonitorPage = e_MonLogicalSwitches; - return menuLogicalSwitchesMonitor(event, 4); + return menuLogicalSwitchesMonitor(event); } - -