[Colorlcd] Pot and slider model setup settings implemented (#654)
* Pots and sliders warning implemented. #647 * add slider definitions * Remove whitespace change causing merge conflict * add slider definitions Co-authored-by: Peter Feerick <peter.feerick@gmail.com>
This commit is contained in:
@@ -1432,8 +1432,89 @@ void ModelSetupPage::build(FormWindow * window)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
grid.addWindow(group);
|
grid.addWindow(group);
|
||||||
|
|
||||||
|
// Pots and sliders warning
|
||||||
|
#if NUM_POTS + NUM_SLIDERS
|
||||||
|
{
|
||||||
|
new StaticText(window, grid.getLabelSlot(true), STR_POTWARNINGSTATE);
|
||||||
|
new Choice(window, grid.getFieldSlot(), {"OFF", "ON", "AUTO"}, 0, 2,
|
||||||
|
GET_SET_DEFAULT(g_model.potsWarnMode));
|
||||||
|
grid.nextLine();
|
||||||
|
|
||||||
|
#if (NUM_POTS)
|
||||||
|
{
|
||||||
|
new StaticText(window, grid.getLabelSlot(true), STR_POTWARNING);
|
||||||
|
auto group =
|
||||||
|
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++) {
|
||||||
|
char s[8];
|
||||||
|
if ((IS_POT(i) || IS_POT_MULTIPOS(i))) {
|
||||||
|
if (j > 0 && ((j % 4) == 0)) centerGrid.nextLine();
|
||||||
|
|
||||||
|
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
|
||||||
|
: 0));
|
||||||
|
button->setPressHandler([button, j] {
|
||||||
|
g_model.potsWarnEnabled ^= (1 << j);
|
||||||
|
if ((g_model.potsWarnMode == POTS_WARN_MANUAL) &&
|
||||||
|
(g_model.potsWarnEnabled & (1 << j))) {
|
||||||
|
SAVE_POT_POSITION(j);
|
||||||
|
}
|
||||||
|
button->check(g_model.potsWarnEnabled & (1 << j));
|
||||||
|
SET_DIRTY();
|
||||||
|
return (g_model.potsWarnEnabled & (1 << j));
|
||||||
|
});
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
grid.addWindow(group);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (NUM_SLIDERS)
|
||||||
|
{
|
||||||
|
new StaticText(window, grid.getLabelSlot(true), STR_SLIDERWARNING);
|
||||||
|
auto group =
|
||||||
|
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++) {
|
||||||
|
char s[8];
|
||||||
|
if ((IS_SLIDER(i))) {
|
||||||
|
if (j > 0 && ((j % 4) == 0)) centerGrid.nextLine();
|
||||||
|
|
||||||
|
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));
|
||||||
|
if ((g_model.potsWarnMode == POTS_WARN_MANUAL) &&
|
||||||
|
(g_model.potsWarnEnabled & (1 << (j + NUM_POTS)))) {
|
||||||
|
SAVE_POT_POSITION(j + NUM_POTS);
|
||||||
|
}
|
||||||
|
button->check(g_model.potsWarnEnabled & (1 << (j + NUM_POTS)));
|
||||||
|
SET_DIRTY();
|
||||||
|
return (g_model.potsWarnEnabled & (1 << (j + NUM_POTS)));
|
||||||
|
});
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
grid.addWindow(group);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
grid.nextLine();
|
||||||
|
|
||||||
// Center beeps
|
// Center beeps
|
||||||
{
|
{
|
||||||
new StaticText(window, grid.getLabelSlot(false), STR_BEEPCTR, 0, COLOR_THEME_PRIMARY1);
|
new StaticText(window, grid.getLabelSlot(false), STR_BEEPCTR, 0, COLOR_THEME_PRIMARY1);
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ bool SwitchWarnDialog::warningInactive()
|
|||||||
if (!IS_POT_SLIDER_AVAILABLE(POT1 + i)) {
|
if (!IS_POT_SLIDER_AVAILABLE(POT1 + i)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!(g_model.potsWarnEnabled & (1 << i)) && (abs(g_model.potsWarnPosition[i] - GET_LOWRES_POT_POSITION(i)) > 1)) {
|
if ( (g_model.potsWarnEnabled & (1 << i)) && (abs(g_model.potsWarnPosition[i] - GET_LOWRES_POT_POSITION(i)) > 1)) {
|
||||||
warn = true;
|
warn = true;
|
||||||
bad_pots |= (1 << i);
|
bad_pots |= (1 << i);
|
||||||
}
|
}
|
||||||
@@ -96,7 +96,7 @@ void SwitchWarnDialog::paint(BitmapBuffer * dc)
|
|||||||
if (!IS_POT_SLIDER_AVAILABLE(POT1 + i)) {
|
if (!IS_POT_SLIDER_AVAILABLE(POT1 + i)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!(g_model.potsWarnEnabled & (1 << i))) {
|
if ( (g_model.potsWarnEnabled & (1 << i))) {
|
||||||
if (abs(g_model.potsWarnPosition[i] - GET_LOWRES_POT_POSITION(i)) > 1) {
|
if (abs(g_model.potsWarnPosition[i] - GET_LOWRES_POT_POSITION(i)) > 1) {
|
||||||
if (y < LCD_H) {
|
if (y < LCD_H) {
|
||||||
char s[8];
|
char s[8];
|
||||||
|
|||||||
@@ -309,6 +309,9 @@ enum Analogs {
|
|||||||
NUM_ANALOGS
|
NUM_ANALOGS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define SLIDER_FIRST 0
|
||||||
|
#define SLIDER_LAST -1
|
||||||
|
|
||||||
#define DEFAULT_POTS_CONFIG (POT_WITHOUT_DETENT << 0) + (POT_WITHOUT_DETENT << 2) // 2 pots without detent
|
#define DEFAULT_POTS_CONFIG (POT_WITHOUT_DETENT << 0) + (POT_WITHOUT_DETENT << 2) // 2 pots without detent
|
||||||
|
|
||||||
enum CalibratedAnalogs {
|
enum CalibratedAnalogs {
|
||||||
|
|||||||
Reference in New Issue
Block a user