[colorlcd] Fix pot and slider warning checks (#1281)
Some pot/sliders were being ignored or check state was inverted
This commit is contained in:
@@ -1512,7 +1512,7 @@ void ModelSetupPage::build(FormWindow * window)
|
||||
new FormGroup(window, grid.getFieldSlot(),
|
||||
FORM_BORDER_FOCUS_ONLY | PAINT_CHILDREN_FIRST);
|
||||
GridLayout centerGrid(group);
|
||||
for (int i = POT_FIRST, j = 0; i <= POT_LAST; i++) {
|
||||
for (int i = POT_FIRST, j = 0, k = 0; i <= POT_LAST; i++, k++) {
|
||||
char s[8];
|
||||
if ((IS_POT(i) || IS_POT_MULTIPOS(i)) && IS_POT_AVAILABLE(i)) {
|
||||
if (j > 0 && ((j % 4) == 0)) centerGrid.nextLine();
|
||||
@@ -1520,19 +1520,21 @@ void ModelSetupPage::build(FormWindow * window)
|
||||
auto button = new TextButton(
|
||||
group, centerGrid.getSlot(4, j % 4),
|
||||
getStringAtIndex(s, STR_VSRCRAW, i + 1), nullptr,
|
||||
OPAQUE | ((g_model.potsWarnEnabled & (1 << j)) ? BUTTON_CHECKED
|
||||
OPAQUE | ((g_model.potsWarnEnabled & (1 << k)) ? BUTTON_CHECKED
|
||||
: 0));
|
||||
button->setPressHandler([button, j] {
|
||||
g_model.potsWarnEnabled ^= (1 << j);
|
||||
button->setPressHandler([button, k] {
|
||||
g_model.potsWarnEnabled ^= (1 << k);
|
||||
if ((g_model.potsWarnMode == POTS_WARN_MANUAL) &&
|
||||
(g_model.potsWarnEnabled & (1 << j))) {
|
||||
SAVE_POT_POSITION(j);
|
||||
(g_model.potsWarnEnabled & (1 << k))) {
|
||||
SAVE_POT_POSITION(k);
|
||||
}
|
||||
button->check(g_model.potsWarnEnabled & (1 << j));
|
||||
button->check(g_model.potsWarnEnabled & (1 << k) ? true : false);
|
||||
SET_DIRTY();
|
||||
return (g_model.potsWarnEnabled & (1 << j));
|
||||
return (g_model.potsWarnEnabled & (1 << k) ? 1 : 0);
|
||||
});
|
||||
j++;
|
||||
} else {
|
||||
g_model.potsWarnEnabled &= ~(1 << k);
|
||||
}
|
||||
}
|
||||
grid.addWindow(group);
|
||||
@@ -1546,7 +1548,7 @@ void ModelSetupPage::build(FormWindow * window)
|
||||
new FormGroup(window, grid.getFieldSlot(),
|
||||
FORM_BORDER_FOCUS_ONLY | PAINT_CHILDREN_FIRST);
|
||||
GridLayout centerGrid(group);
|
||||
for (int i = SLIDER_FIRST, j = 0; i <= SLIDER_LAST; i++) {
|
||||
for (int i = SLIDER_FIRST, j = 0, k = NUM_POTS; i <= SLIDER_LAST; i++, k++) {
|
||||
char s[8];
|
||||
if ((IS_SLIDER(i))) {
|
||||
if (j > 0 && ((j % 4) == 0)) centerGrid.nextLine();
|
||||
@@ -1554,18 +1556,17 @@ void ModelSetupPage::build(FormWindow * window)
|
||||
auto *button = new TextButton(
|
||||
group, centerGrid.getSlot(4, j % 4),
|
||||
getStringAtIndex(s, STR_VSRCRAW, i + 1), nullptr,
|
||||
OPAQUE | ((g_model.potsWarnEnabled & (1 << (j + NUM_POTS)))
|
||||
? BUTTON_CHECKED
|
||||
: 0));
|
||||
button->setPressHandler([button, j] {
|
||||
g_model.potsWarnEnabled ^= (1 << (j + NUM_POTS));
|
||||
OPAQUE | ((g_model.potsWarnEnabled & (1 << k)) ? BUTTON_CHECKED
|
||||
: 0));
|
||||
button->setPressHandler([button, k] {
|
||||
g_model.potsWarnEnabled ^= (1 << (k));
|
||||
if ((g_model.potsWarnMode == POTS_WARN_MANUAL) &&
|
||||
(g_model.potsWarnEnabled & (1 << (j + NUM_POTS)))) {
|
||||
SAVE_POT_POSITION(j + NUM_POTS);
|
||||
(g_model.potsWarnEnabled & (1 << k))) {
|
||||
SAVE_POT_POSITION(k);
|
||||
}
|
||||
button->check(g_model.potsWarnEnabled & (1 << (j + NUM_POTS)) ? true : false);
|
||||
button->check(g_model.potsWarnEnabled & (1 << k) ? true : false);
|
||||
SET_DIRTY();
|
||||
return (g_model.potsWarnEnabled & (1 << (j + NUM_POTS)) ? 1 : 0);
|
||||
return (g_model.potsWarnEnabled & (1 << k) ? 1 : 0);
|
||||
});
|
||||
j++;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ bool SwitchWarnDialog::warningInactive()
|
||||
|
||||
if (last_bad_switches != switches_states || last_bad_pots != bad_pots) {
|
||||
invalidate();
|
||||
if (last_bad_switches == 0xff || last_bad_pots == 0xff) {
|
||||
if (last_bad_switches == 0xff || last_bad_pots & 0x7ff) {
|
||||
AUDIO_ERROR_MESSAGE(AU_SWITCH_ALERT);
|
||||
}
|
||||
}
|
||||
@@ -82,9 +82,7 @@ void SwitchWarnDialog::paint(BitmapBuffer * dc)
|
||||
if (abs(g_model.potsWarnPosition[i] - GET_LOWRES_POT_POSITION(i)) > 1) {
|
||||
if (y < LCD_H) {
|
||||
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';
|
||||
getStringAtIndex(s, STR_VSRCRAW, POT1 + i + 1);
|
||||
dc->drawText(x, y, s, COLOR_THEME_PRIMARY1 | FONT(BOLD));
|
||||
x += 40;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class SwitchWarnDialog: public FullScreenDialog {
|
||||
{
|
||||
last_bad_switches = 0xff;
|
||||
bad_pots = 0;
|
||||
last_bad_pots = 0xff;
|
||||
last_bad_pots = 0x0;
|
||||
setCloseCondition(std::bind(&SwitchWarnDialog::warningInactive, this));
|
||||
}
|
||||
|
||||
@@ -49,8 +49,8 @@ class SwitchWarnDialog: public FullScreenDialog {
|
||||
|
||||
protected:
|
||||
swarnstate_t last_bad_switches;
|
||||
uint8_t bad_pots;
|
||||
uint8_t last_bad_pots;
|
||||
uint16_t bad_pots;
|
||||
uint16_t last_bad_pots;
|
||||
bool warningInactive();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user