From 61fffdd7cbe76b471a182729356543f87b449605 Mon Sep 17 00:00:00 2001 From: 3djc Date: Thu, 18 Jun 2020 12:21:19 +0200 Subject: [PATCH] Only display warning box for existing switches --- radio/src/gui/colorlcd/model_setup.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/radio/src/gui/colorlcd/model_setup.cpp b/radio/src/gui/colorlcd/model_setup.cpp index 4c2735979..f50dfbb45 100644 --- a/radio/src/gui/colorlcd/model_setup.cpp +++ b/radio/src/gui/colorlcd/model_setup.cpp @@ -1073,11 +1073,15 @@ void ModelSetupPage::build(FormWindow * window) new StaticText(window, grid.getLabelSlot(true), STR_SWITCHWARNING); auto group = new FormGroup(window, grid.getFieldSlot(), FORM_BORDER_FOCUS_ONLY | PAINT_CHILDREN_FIRST); GridLayout switchesGrid(group); - for (int i = 0; i < NUM_SWITCHES; i++) { + for (int i = 0, j = -1; i < NUM_SWITCHES; i++) { char s[SWITCH_WARNING_STR_SIZE]; - if (i > 0 && (i % 3) == 0) + if (SWITCH_EXISTS(i)) + j++; + else + break; + if (j > 0 && (j % 3) == 0) switchesGrid.nextLine(); - auto button = new TextButton(group, switchesGrid.getSlot(3, i % 3), getSwitchWarningString(s, i), nullptr, + auto button = new TextButton(group, switchesGrid.getSlot(3, j % 3), getSwitchWarningString(s, i), nullptr, (bfGet(g_model.switchWarningState, 3 * i, 3) == 0 ? 0 : BUTTON_CHECKED)); button->setPressHandler([button, i] { swarnstate_t newstate = bfGet(g_model.switchWarningState, 3 * i, 3);