Bsongis/x9lite pwr fix (#6501)

X9 Pwr fix
This commit is contained in:
Bertrand Songis
2019-06-14 21:19:26 +02:00
committed by GitHub
parent 7c3ad50e7d
commit c3388dc65e
24 changed files with 306 additions and 353 deletions
+54 -38
View File
@@ -25,10 +25,9 @@
#if defined(PCBHORUS)
#define SWITCH_WARNING_LIST_X WARNING_LINE_X
#define SWITCH_WARNING_LIST_Y WARNING_LINE_Y+3*FH
#define SWITCH_WARNING_LIST_INTERVAL 35
#elif LCD_W >= 212
#define SWITCH_WARNING_LIST_X 60
#define SWITCH_WARNING_LIST_Y 4*FH+3
#define SWITCH_WARNING_LIST_Y 4*FH+4
#else
#define SWITCH_WARNING_LIST_X 4
#define SWITCH_WARNING_LIST_Y 4*FH+4
@@ -558,6 +557,10 @@ void checkSwitches()
uint8_t bad_pots = 0, last_bad_pots = 0xff;
#endif
#if defined(PWR_BUTTON_PRESS)
bool refresh = false;
#endif
while (1) {
#if defined(PCBTARANIS) || defined(PCBHORUS)
@@ -642,12 +645,13 @@ void checkSwitches()
// first - display warning
#if defined(PCBTARANIS) || defined(PCBHORUS)
if ((last_bad_switches != switches_states) || (last_bad_pots != bad_pots)) {
drawAlertBox(STR_SWITCHWARN, NULL, STR_PRESSANYKEYTOSKIP);
if (last_bad_switches != switches_states || last_bad_pots != bad_pots) {
drawAlertBox(STR_SWITCHWARN, nullptr, STR_PRESSANYKEYTOSKIP);
if (last_bad_switches == 0xff || last_bad_pots == 0xff) {
AUDIO_ERROR_MESSAGE(AU_SWITCH_ALERT);
}
int x = SWITCH_WARNING_LIST_X, y = SWITCH_WARNING_LIST_Y;
int x = SWITCH_WARNING_LIST_X;
int y = SWITCH_WARNING_LIST_Y;
int numWarnings = 0;
for (int i=0; i<NUM_SWITCHES; ++i) {
#if defined(COLORLCD)
@@ -658,10 +662,7 @@ void checkSwitches()
// LcdFlags attr = ((states & mask) == (switches_states & mask)) ? TEXT_COLOR : ALARM_COLOR;
LcdFlags attr = ALARM_COLOR;
drawSwitch(x, y, SWSRC_FIRST_SWITCH+i*3+state-1, attr);
x += SWITCH_WARNING_LIST_INTERVAL;
}
else if (numWarnings == 6) {
lcdDrawText(x, y, "...", ALARM_COLOR);
x += 35;
}
}
}
@@ -670,59 +671,54 @@ void checkSwitches()
swarnstate_t mask = ((swarnstate_t)0x03 << (i*2));
LcdFlags attr = ((states & mask) == (switches_states & mask)) ? 0 : INVERS;
if (attr) {
if (++numWarnings < 7) {
if (++numWarnings < 6) {
char c = "\300-\301"[(states & mask) >> (i*2)];
drawSource(x, y, MIXSRC_FIRST_SWITCH+i, attr);
lcdDrawChar(lcdNextPos, y, c, attr);
x = lcdNextPos + 3;
}
else if (numWarnings == 7) {
lcdDrawText(x, y, "...", 0);
}
}
}
#endif
}
if (g_model.potsWarnMode) {
if (y == 4*FH+3) {
y = 6*FH-2;
x = 60;
}
for (int i=0; i<NUM_POTS+NUM_SLIDERS; i++) {
if (!IS_POT_SLIDER_AVAILABLE(POT1+i)) {
continue;
}
if (!(g_model.potsWarnEnabled & (1 << i))) {
if (abs(g_model.potsWarnPosition[i] - GET_LOWRES_POT_POSITION(i)) > 1) {
#if defined(COLORLCD)
char s[8];
// TODO add an helper
strncpy(s, &STR_VSRCRAW[1+(NUM_STICKS+1+i)*STR_VSRCRAW[0]], STR_VSRCRAW[0]);
s[int(STR_VSRCRAW[0])] = '\0';
#else
lcdDrawTextAtIndex(x, y, STR_VSRCRAW, NUM_STICKS+1+i, INVERS);
if (IS_POT(POT1+i))
lcdDrawChar(lcdNextPos, y, g_model.potsWarnPosition[i] > GET_LOWRES_POT_POSITION(i) ? 126 : 127, INVERS);
else
lcdDrawChar(lcdNextPos, y, g_model.potsWarnPosition[i] > GET_LOWRES_POT_POSITION(i) ? '\300' : '\301', INVERS);
#endif
#if defined(COLORLCD)
if (++numWarnings < 6) {
#if defined(COLORLCD)
char s[8];
// TODO add an helper
strncpy(s, &STR_VSRCRAW[1+(NUM_STICKS+1+i)*STR_VSRCRAW[0]], STR_VSRCRAW[0]);
s[int(STR_VSRCRAW[0])] = '\0';
lcdDrawText(x, y, s, ALARM_COLOR);
}
else if (numWarnings == 6) {
lcdDrawText(x, y, "...", ALARM_COLOR);
}
x += 40;
x += 40;
#else
x = lcdNextPos + 3;
lcdDrawTextAtIndex(x, y, STR_VSRCRAW, NUM_STICKS + 1 + i, INVERS);
if (IS_POT(POT1 + i))
lcdDrawChar(lcdNextPos, y, g_model.potsWarnPosition[i] > GET_LOWRES_POT_POSITION(i) ? 126 : 127, INVERS);
else
lcdDrawChar(lcdNextPos, y, g_model.potsWarnPosition[i] > GET_LOWRES_POT_POSITION(i) ? '\300' : '\301', INVERS);
x = lcdNextPos + 3;
#endif
}
}
}
}
}
if (numWarnings >= 6) {
#if defined(COLORLCD)
lcdDrawText(x, y, "...", ALARM_COLOR);
#else
lcdDrawText(x, y, "...", 0);
#endif
}
last_bad_pots = bad_pots;
#else
if (last_bad_switches != switches_states) {
@@ -747,7 +743,27 @@ void checkSwitches()
last_bad_switches = switches_states;
}
if (pwrCheck() == e_power_off || keyDown()) break;
if (keyDown())
break;
#if defined(PWR_BUTTON_PRESS)
uint32_t power = pwrCheck();
if (power == e_power_off) {
break;
}
else if (power == e_power_press) {
refresh = true;
}
else if (power == e_power_on && refresh) {
last_bad_switches = 0xff;
last_bad_pots = 0xff;
refresh = false;
}
#else
if (pwrCheck() == e_power_off) {
break;
}
#endif
doLoopCommonActions();