Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use setAvailableHandler to filter blMode menu #1798

Merged
merged 1 commit into from
Apr 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 11 additions & 18 deletions radio/src/gui/colorlcd/radio_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,25 +330,18 @@ void RadioSetupPage::build(FormWindow * window)

// Backlight mode
new StaticText(window, grid.getLabelSlot(true), STR_MODE, 0, COLOR_THEME_PRIMARY1);
#if defined COLORLCD
BacklightMode minBacklightMode = e_backlight_mode_keys;
#else
BacklightMode minBacklightMode = e_backlight_mode_off;
#endif
const char* values[e_backlight_mode_on+1] = {};
uint8_t len = STR_VBLMODE[0];
const char * value = &STR_VBLMODE[1];
for (int i = e_backlight_mode_off; i <= e_backlight_mode_on; i++) {
values[i] = value;
value += len;
}

new Choice(window, grid.getFieldSlot(2,0), &values[minBacklightMode], minBacklightMode, e_backlight_mode_on, GET_DEFAULT(g_eeGeneral.backlightMode),
[=](int32_t newValue) {
g_eeGeneral.backlightMode = newValue;
updateBacklightControls();
});
//grid.nextLine();
auto blMode = new Choice(window, grid.getFieldSlot(2, 0), STR_VBLMODE,
e_backlight_mode_off, e_backlight_mode_on,
GET_DEFAULT(g_eeGeneral.backlightMode),
[=](int32_t newValue) {
g_eeGeneral.backlightMode = newValue;
updateBacklightControls();
});

blMode->setAvailableHandler(
[=](int newValue) { return newValue != e_backlight_mode_off; });

// Delay
auto edit = new NumberEdit(window, grid.getFieldSlot(2, 1), 5, 600,
GET_DEFAULT(g_eeGeneral.lightAutoOff * 5),
Expand Down