Fix switch handling on X9E, cleanup/harmonize code for all revisions

This commit is contained in:
Andre Bernet
2015-03-28 00:51:39 +04:00
parent 2325b0ea50
commit 95be0729cf
17 changed files with 128 additions and 143 deletions
+1 -28
View File
@@ -571,7 +571,6 @@ void menuMainView(uint8_t event)
lcd_bmp(BITMAP_X, BITMAP_Y, modelBitmap);
// Switches
#if defined(REV9E)
if (getSwitchCount() > 8) {
for (int i=0; i<NUM_SWITCHES; ++i) {
div_t qr = div(i, 9);
@@ -591,39 +590,13 @@ void menuMainView(uint8_t event)
int index = 0;
for (int i=0; i<NUM_SWITCHES; ++i) {
if (SWITCH_EXISTS(i)) {
getvalue_t val = getValue(MIXSRC_SA+i);
getvalue_t val = getValue(MIXSRC_FIRST_SWITCH+i);
getvalue_t sw = ((val < 0) ? 3*i+1 : ((val == 0) ? 3*i+2 : 3*i+3));
putsSwitches((g_eeGeneral.view == VIEW_INPUTS) ? (index<4 ? 8*FW+3 : 24*FW+1) : (index<4 ? 3*FW+2 : 8*FW-1), (index%4)*FH+3*FH, sw, 0);
index++;
}
}
}
#else
for (int i=0; i<8; ++i) {
getvalue_t sw;
getvalue_t val;
// TODO simplify this + reuse code in checkSwitches() + Menu MODELSETUP
switch(i) {
case 5:
sw = getValue(MIXSRC_SF) > 0 ? 3*i+2 : 3*i+1;
break;
case 6:
val = getValue(MIXSRC_SG);
sw = ((val < 0) ? 3*i : ((val == 0) ? 3*i+1 : 3*i+2));
break;
case 7:
sw = getValue(MIXSRC_SH) > 0 ? 3*i+1 : 3*i;
break;
default:
{
val = getValue(MIXSRC_SA+i);
sw = ((val < 0) ? 3*i+1 : ((val == 0) ? 3*i+2 : 3*i+3));
break;
}
}
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);
}
#endif
if (g_eeGeneral.view == VIEW_TIMERS) {
displayTimers();