From dc1848843d6f7f93dd494e327e0df49278498635 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Tue, 31 Mar 2020 15:52:12 +0200 Subject: [PATCH] Choice can now accept an array of const char * as values argument --- radio/src/gui/colorlcd/gvar_numberedit.h | 2 +- radio/src/gui/colorlcd/model_inputs.cpp | 2 +- radio/src/gui/colorlcd/model_mixes.cpp | 2 +- radio/src/gui/colorlcd/model_setup.cpp | 4 +++- radio/src/gui/colorlcd/radio_setup.cpp | 6 +++--- radio/src/gui/colorlcd/special_functions.cpp | 4 ++-- radio/src/thirdparty/libopenui | 2 +- 7 files changed, 12 insertions(+), 10 deletions(-) diff --git a/radio/src/gui/colorlcd/gvar_numberedit.h b/radio/src/gui/colorlcd/gvar_numberedit.h index f97eee284..1b0aba66e 100644 --- a/radio/src/gui/colorlcd/gvar_numberedit.h +++ b/radio/src/gui/colorlcd/gvar_numberedit.h @@ -84,7 +84,7 @@ class GVarNumberEdit: public FormGroup // The main field int32_t value = getValue(); if (GV_IS_GV_VALUE(value, vmin, vmax)) { - auto result = new Choice(this, {0, 0, width() - GVAR_BUTTON_WIDTH, height()}, nullptr, -MAX_GVARS, MAX_GVARS - 1, + auto result = new Choice(this, {0, 0, width() - GVAR_BUTTON_WIDTH, height()}, -MAX_GVARS, MAX_GVARS - 1, [=]() { uint16_t gvar1 = GV_GET_GV1_VALUE(vmin, vmax); return GV_INDEX_CALC_DELTA(getValue(), gvar1); diff --git a/radio/src/gui/colorlcd/model_inputs.cpp b/radio/src/gui/colorlcd/model_inputs.cpp index e5e7dede9..f0701b675 100644 --- a/radio/src/gui/colorlcd/model_inputs.cpp +++ b/radio/src/gui/colorlcd/model_inputs.cpp @@ -156,7 +156,7 @@ class InputEditWindow: public Page { case CURVE_REF_CUSTOM: { - auto choice = new Choice(curveParamField, rect, nullptr, -MAX_CURVES, MAX_CURVES, GET_SET_DEFAULT(line->curve.value)); + auto choice = new Choice(curveParamField, rect, -MAX_CURVES, MAX_CURVES, GET_SET_DEFAULT(line->curve.value)); choice->setTextHandler([](int value) { return getCurveString(value); }); diff --git a/radio/src/gui/colorlcd/model_mixes.cpp b/radio/src/gui/colorlcd/model_mixes.cpp index 306b46e72..766bc24da 100644 --- a/radio/src/gui/colorlcd/model_mixes.cpp +++ b/radio/src/gui/colorlcd/model_mixes.cpp @@ -216,7 +216,7 @@ class MixEditWindow : public Page { case CURVE_REF_CUSTOM: { - auto choice = new Choice(curveParamField, rect, nullptr, -MAX_CURVES, MAX_CURVES, GET_SET_DEFAULT(line->curve.value)); + auto choice = new Choice(curveParamField, rect, -MAX_CURVES, MAX_CURVES, GET_SET_DEFAULT(line->curve.value)); choice->setTextHandler([](int value) { return getCurveString(value); }); diff --git a/radio/src/gui/colorlcd/model_setup.cpp b/radio/src/gui/colorlcd/model_setup.cpp index 77859b17a..1a24b72fa 100644 --- a/radio/src/gui/colorlcd/model_setup.cpp +++ b/radio/src/gui/colorlcd/model_setup.cpp @@ -932,6 +932,8 @@ void onBindMenu(const char * result) moduleState[moduleIdx].mode = MODULE_MODE_BIND; } +const char * STR_TIMER_MODES[] = {"OFF", "ON", "Start", "Throttle", "Throttle %", "Throttle Start"}; + void ModelSetupPage::build(FormWindow * window) { FormGridLayout grid; @@ -983,7 +985,7 @@ void ModelSetupPage::build(FormWindow * window) // Timer mode new StaticText(window, grid.getLabelSlot(true), STR_MODE); grid.nextLine(); - new Choice(group, timerGrid.getSlot(2, 0), "\011""OFF\0 ""ON\0 ""Start\0 ""Thr\0 ""Thr%\0 ""Thr Start", 0, TMRMODE_MAX, GET_SET_DEFAULT(timer->mode)); + new Choice(group, timerGrid.getSlot(2, 0), STR_TIMER_MODES, 0, TMRMODE_MAX, GET_SET_DEFAULT(timer->mode)); new SwitchChoice(group, timerGrid.getSlot(2, 1), SWSRC_FIRST, SWSRC_LAST, GET_SET_DEFAULT(timer->swtch)); timerGrid.nextLine(); diff --git a/radio/src/gui/colorlcd/radio_setup.cpp b/radio/src/gui/colorlcd/radio_setup.cpp index 6894076e2..3b13677e6 100644 --- a/radio/src/gui/colorlcd/radio_setup.cpp +++ b/radio/src/gui/colorlcd/radio_setup.cpp @@ -410,7 +410,7 @@ void RadioSetupPage::build(FormWindow * window) // Audio language new StaticText(window, grid.getLabelSlot(), STR_VOICE_LANGUAGE); - auto choice = new Choice(window, grid.getFieldSlot(), nullptr, 0, DIM(languagePacks) - 2, GET_VALUE(currentLanguagePackIdx), + auto choice = new Choice(window, grid.getFieldSlot(), 0, DIM(languagePacks) - 2, GET_VALUE(currentLanguagePackIdx), [](uint8_t newValue) { currentLanguagePackIdx = newValue; currentLanguagePack = languagePacks[currentLanguagePackIdx]; @@ -455,7 +455,7 @@ void RadioSetupPage::build(FormWindow * window) // RX channel order new StaticText(window, grid.getLabelSlot(), STR_RXCHANNELORD); // RAET->AETR - choice = new Choice(window, grid.getFieldSlot(), nullptr, 0, 4*3*2 - 1, GET_SET_DEFAULT(g_eeGeneral.templateSetup)); + choice = new Choice(window, grid.getFieldSlot(), 0, 4*3*2 - 1, GET_SET_DEFAULT(g_eeGeneral.templateSetup)); choice->setTextHandler([](uint8_t value) { char s[5]; for (uint8_t i=0; i<4; i++) { @@ -468,7 +468,7 @@ void RadioSetupPage::build(FormWindow * window) // Stick mode new StaticText(window, grid.getLabelSlot(), STR_MODE); - choice = new Choice(window, grid.getFieldSlot(), nullptr, 0, 3, GET_DEFAULT(g_eeGeneral.stickMode), + choice = new Choice(window, grid.getFieldSlot(), 0, 3, GET_DEFAULT(g_eeGeneral.stickMode), [=](uint8_t newValue) { pausePulses(); g_eeGeneral.stickMode = newValue; diff --git a/radio/src/gui/colorlcd/special_functions.cpp b/radio/src/gui/colorlcd/special_functions.cpp index f40371225..cedc18c73 100644 --- a/radio/src/gui/colorlcd/special_functions.cpp +++ b/radio/src/gui/colorlcd/special_functions.cpp @@ -91,7 +91,7 @@ class SpecialFunctionEditPage : public Page { case FUNC_RESET: if (CFN_PARAM(cfn) < FUNC_RESET_PARAM_FIRST_TELEM) { new StaticText(specialFunctionOneWindow, grid.getLabelSlot(), STR_RESET); - auto choice = new Choice(specialFunctionOneWindow, grid.getFieldSlot(), nullptr, 0, + auto choice = new Choice(specialFunctionOneWindow, grid.getFieldSlot(), 0, FUNC_RESET_PARAM_FIRST_TELEM + lastUsedTelemetryIndex(), GET_SET_DEFAULT(CFN_PARAM(cfn))); choice->setAvailableHandler(isSourceAvailableInResetSpecialFunction); @@ -139,7 +139,7 @@ class SpecialFunctionEditPage : public Page { case FUNC_SET_TIMER: { new StaticText(specialFunctionOneWindow, grid.getLabelSlot(), STR_TIMER); - auto timerchoice = new Choice(specialFunctionOneWindow, grid.getFieldSlot(), nullptr, 0, TIMERS - 1, GET_SET_DEFAULT(CFN_TIMER_INDEX(cfn))); + auto timerchoice = new Choice(specialFunctionOneWindow, grid.getFieldSlot(), 0, TIMERS - 1, GET_SET_DEFAULT(CFN_TIMER_INDEX(cfn))); timerchoice->setTextHandler([](int32_t value) { return std::string(STR_TIMER) + std::to_string(value + 1); }); diff --git a/radio/src/thirdparty/libopenui b/radio/src/thirdparty/libopenui index 9c4e886fb..d4095e345 160000 --- a/radio/src/thirdparty/libopenui +++ b/radio/src/thirdparty/libopenui @@ -1 +1 @@ -Subproject commit 9c4e886fb51db85a0eb8b9b62e86caa255e254ce +Subproject commit d4095e345dd9fd5cb8619b7051e1ec2d5c73e3c2