continued radio setup rework

This commit is contained in:
gagarinlg
2022-06-11 15:38:08 +02:00
committed by Raphael Coeffic
parent f31a2af57b
commit 9962b73895
+49 -42
View File
@@ -164,7 +164,7 @@ class WindowButtonGroup : public FormGroup
{ {
public: public:
WindowButtonGroup( WindowButtonGroup(
FormGroup* parent, const rect_t& rect, Window* parent, const rect_t& rect,
std::vector<std::pair<const char*, std::function<void()>>> windows) : std::vector<std::pair<const char*, std::function<void()>>> windows) :
FormGroup(parent, rect, FORWARD_SCROLL | FORM_FORWARD_FOCUS), FormGroup(parent, rect, FORWARD_SCROLL | FORM_FORWARD_FOCUS),
windows(windows) windows(windows)
@@ -575,19 +575,23 @@ RadioSetupPage::RadioSetupPage():
void RadioSetupPage::build(FormWindow * window) void RadioSetupPage::build(FormWindow * window)
{ {
FormGridLayout grid; window->setFlexLayout();
grid.spacer(PAGE_PADDING); FlexGridLayout grid(line_col_dsc, line_row_dsc, 2);
// FormGridLayout grid;
// grid.spacer(PAGE_PADDING);
auto line = window->newLine(&grid);
// Date and Time // Date and Time
auto timeWindow = new DateTimeWindow(window, {0, grid.getWindowHeight(), LCD_W, 0}); // auto timeWindow = new DateTimeWindow(line, {0, 0, LCD_W, 0});
grid.addWindow(timeWindow); // grid.addWindow(timeWindow);
// Batt meter range - Range 3.0v to 16v // Batt meter range - Range 3.0v to 16v
new StaticText(window, grid.getLabelSlot(), STR_BATTERY_RANGE, 0, COLOR_THEME_PRIMARY1); line = window->newLine(&grid);
auto batMinEdit = new NumberEdit(window, grid.getFieldSlot(2, 0), -60 + 90, g_eeGeneral.vBatMax + 29 + 90, GET_SET_WITH_OFFSET(g_eeGeneral.vBatMin, 90), 0, PREC1); new StaticText(line, rect_t{}, STR_BATTERY_RANGE, 0, COLOR_THEME_PRIMARY1);
auto batMinEdit = new NumberEdit(line, rect_t{}, -60 + 90, g_eeGeneral.vBatMax + 29 + 90, GET_SET_WITH_OFFSET(g_eeGeneral.vBatMin, 90), 0, PREC1);
batMinEdit->setSuffix("V"); batMinEdit->setSuffix("V");
auto batMaxEdit = new NumberEdit(window, grid.getFieldSlot(2, 1), g_eeGeneral.vBatMin - 29 + 120, 40 + 120, GET_SET_WITH_OFFSET(g_eeGeneral.vBatMax, 120), 0, PREC1); auto batMaxEdit = new NumberEdit(line, rect_t{}, g_eeGeneral.vBatMin - 29 + 120, 40 + 120, GET_SET_WITH_OFFSET(g_eeGeneral.vBatMax, 120), 0, PREC1);
batMaxEdit->setSuffix("V"); batMaxEdit->setSuffix("V");
batMinEdit->setSetValueHandler([=](int32_t newValue) { batMinEdit->setSetValueHandler([=](int32_t newValue) {
g_eeGeneral.vBatMin= newValue - 90; g_eeGeneral.vBatMin= newValue - 90;
@@ -602,7 +606,8 @@ void RadioSetupPage::build(FormWindow * window)
batMinEdit->invalidate(); batMinEdit->invalidate();
}); });
grid.nextLine(); // grid.nextLine();
line = window->newLine(&grid);
std::vector<std::pair<const char*, std::function<void()> >> windows; std::vector<std::pair<const char*, std::function<void()> >> windows;
windows.push_back(std::make_pair(STR_SOUND_LABEL, [window](){new SoundPage();})); windows.push_back(std::make_pair(STR_SOUND_LABEL, [window](){new SoundPage();}));
#if defined(VARIO) #if defined(VARIO)
@@ -616,16 +621,16 @@ void RadioSetupPage::build(FormWindow * window)
#if defined(INTERNAL_GPS) #if defined(INTERNAL_GPS)
windows.push_back(std::make_pair(STR_GPS, [window](){new GpsPage();})); windows.push_back(std::make_pair(STR_GPS, [window](){new GpsPage();}));
#endif #endif
auto buttons = new WindowButtonGroup(window, {0,grid.getWindowHeight(), LCD_W, 0}, windows); auto buttons = new WindowButtonGroup(line, {0,0, LCD_W, 0}, windows);
buttons->adjustHeight(); buttons->adjustHeight();
grid.addWindow(buttons); // grid.addWindow(buttons);
#if defined(PWR_BUTTON_PRESS) #if defined(PWR_BUTTON_PRESS)
// Pwr Off Delay // Pwr Off Delay
{ {
new StaticText(window, grid.getLabelSlot(), STR_PWR_OFF_DELAY, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_PWR_OFF_DELAY, 0, COLOR_THEME_PRIMARY1);
new Choice(window, grid.getFieldSlot(), STR_PWR_OFF_DELAYS, 0, 3, new Choice(line, rect_t{}, STR_PWR_OFF_DELAYS, 0, 3,
[=]() -> int32_t { [=]() -> int32_t {
return 2 - g_eeGeneral.pwrOffSpeed; return 2 - g_eeGeneral.pwrOffSpeed;
}, },
@@ -633,25 +638,26 @@ void RadioSetupPage::build(FormWindow * window)
g_eeGeneral.pwrOffSpeed = 2 - newValue; g_eeGeneral.pwrOffSpeed = 2 - newValue;
SET_DIRTY(); SET_DIRTY();
}); });
grid.nextLine(); // grid.nextLine();
line = window->newLine(&grid);
} }
#endif #endif
#if defined(PXX2) #if defined(PXX2)
// Owner ID // Owner ID
new StaticText(window, grid.getLabelSlot(), STR_OWNER_ID, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_OWNER_ID, 0, COLOR_THEME_PRIMARY1);
new RadioTextEdit(window, grid.getFieldSlot(), g_eeGeneral.ownerRegistrationID, PXX2_LEN_REGISTRATION_ID); new RadioTextEdit(line, rect_t{}, g_eeGeneral.ownerRegistrationID, PXX2_LEN_REGISTRATION_ID);
grid.nextLine(); line = window->newLine(&grid);
#endif #endif
// Country code // Country code
new StaticText(window, grid.getLabelSlot(), STR_COUNTRY_CODE, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_COUNTRY_CODE, 0, COLOR_THEME_PRIMARY1);
new Choice(window, grid.getFieldSlot(), STR_COUNTRY_CODES, 0, 2, GET_SET_DEFAULT(g_eeGeneral.countryCode)); new Choice(line, rect_t{}, STR_COUNTRY_CODES, 0, 2, GET_SET_DEFAULT(g_eeGeneral.countryCode));
grid.nextLine(); line = window->newLine(&grid);
// Audio language // Audio language
new StaticText(window, grid.getLabelSlot(), STR_VOICE_LANGUAGE, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_VOICE_LANGUAGE, 0, COLOR_THEME_PRIMARY1);
auto choice = new Choice(window, grid.getFieldSlot(), 0, DIM(languagePacks) - 2, GET_VALUE(currentLanguagePackIdx), auto choice = new Choice(line, rect_t{}, 0, DIM(languagePacks) - 2, GET_VALUE(currentLanguagePackIdx),
[](uint8_t newValue) { [](uint8_t newValue) {
currentLanguagePackIdx = newValue; currentLanguagePackIdx = newValue;
currentLanguagePack = languagePacks[currentLanguagePackIdx]; currentLanguagePack = languagePacks[currentLanguagePackIdx];
@@ -660,12 +666,12 @@ void RadioSetupPage::build(FormWindow * window)
choice->setTextHandler([](uint8_t value) { choice->setTextHandler([](uint8_t value) {
return languagePacks[value]->name; return languagePacks[value]->name;
}); });
grid.nextLine(); line = window->newLine(&grid);
// Imperial units // Imperial units
new StaticText(window, grid.getLabelSlot(), STR_UNITS_SYSTEM, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_UNITS_SYSTEM, 0, COLOR_THEME_PRIMARY1);
new Choice(window, grid.getFieldSlot(), STR_VUNITSSYSTEM, 0, 1, GET_SET_DEFAULT(g_eeGeneral.imperial)); new Choice(line, rect_t{}, STR_VUNITSSYSTEM, 0, 1, GET_SET_DEFAULT(g_eeGeneral.imperial));
grid.nextLine(); line = window->newLine(&grid);
#if defined(FAI_CHOICE) #if defined(FAI_CHOICE)
/* case ITEM_SETUP_FAI: /* case ITEM_SETUP_FAI:
@@ -684,25 +690,25 @@ void RadioSetupPage::build(FormWindow * window)
#endif #endif
// Switches delay // Switches delay
new StaticText(window, grid.getLabelSlot(), STR_SWITCHES_DELAY, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_SWITCHES_DELAY, 0, COLOR_THEME_PRIMARY1);
auto edit = new NumberEdit(window, grid.getFieldSlot(2, 0), -15, 100 - 15, GET_SET_VALUE_WITH_OFFSET(g_eeGeneral.switchesDelay, 15)); auto edit = new NumberEdit(line, rect_t{}, -15, 100 - 15, GET_SET_VALUE_WITH_OFFSET(g_eeGeneral.switchesDelay, 15));
edit->setSuffix(std::string("0") + STR_MS); edit->setSuffix(std::string("0") + STR_MS);
grid.nextLine(); line = window->newLine(&grid);
// USB mode // USB mode
new StaticText(window, grid.getLabelSlot(), STR_USBMODE, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_USBMODE, 0, COLOR_THEME_PRIMARY1);
new Choice(window, grid.getFieldSlot(), STR_USBMODES, USB_UNSELECTED_MODE, USB_MAX_MODE, GET_SET_DEFAULT(g_eeGeneral.USBMode)); new Choice(line, rect_t{}, STR_USBMODES, USB_UNSELECTED_MODE, USB_MAX_MODE, GET_SET_DEFAULT(g_eeGeneral.USBMode));
grid.nextLine(); line = window->newLine(&grid);
#if defined(ROTARY_ENCODER_NAVIGATION) #if defined(ROTARY_ENCODER_NAVIGATION)
new StaticText(window, grid.getLabelSlot(), STR_INVERT_ROTARY, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_INVERT_ROTARY, 0, COLOR_THEME_PRIMARY1);
new CheckBox(window, grid.getFieldSlot(), GET_SET_DEFAULT(g_eeGeneral.rotEncDirection)); new CheckBox(line, rect_t{}, GET_SET_DEFAULT(g_eeGeneral.rotEncDirection));
grid.nextLine(); line = window->newLine(&grid);
#endif #endif
// RX channel order // RX channel order
new StaticText(window, grid.getLabelSlot(), STR_RXCHANNELORD, 0, COLOR_THEME_PRIMARY1); // RAET->AETR new StaticText(line, rect_t{}, STR_RXCHANNELORD, 0, COLOR_THEME_PRIMARY1); // RAET->AETR
choice = new Choice(window, grid.getFieldSlot(), 0, 4*3*2 - 1, GET_SET_DEFAULT(g_eeGeneral.templateSetup)); choice = new Choice(line, rect_t{}, 0, 4*3*2 - 1, GET_SET_DEFAULT(g_eeGeneral.templateSetup));
choice->setTextHandler([](uint8_t value) { choice->setTextHandler([](uint8_t value) {
std::string s; std::string s;
for (uint8_t i = 0; i < 4; i++) { for (uint8_t i = 0; i < 4; i++) {
@@ -710,11 +716,12 @@ void RadioSetupPage::build(FormWindow * window)
} }
return s; return s;
}); });
grid.nextLine(); line->adjustHeight();
line = window->newLine(&grid);
// Stick mode // Stick mode
new StaticText(window, grid.getLabelSlot(), STR_MODE, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_MODE, 0, COLOR_THEME_PRIMARY1);
choice = new Choice(window, grid.getFieldSlot(), 0, 3, GET_DEFAULT(g_eeGeneral.stickMode), choice = new Choice(line, rect_t{}, 0, 3, GET_DEFAULT(g_eeGeneral.stickMode),
[=](uint8_t newValue) { [=](uint8_t newValue) {
pausePulses(); pausePulses();
g_eeGeneral.stickMode = newValue; g_eeGeneral.stickMode = newValue;
@@ -725,11 +732,11 @@ void RadioSetupPage::build(FormWindow * window)
choice->setTextHandler([](uint8_t value) { choice->setTextHandler([](uint8_t value) {
return std::to_string(1 + value) + ": left=" + std::string(&getSourceString(MIXSRC_Rud + modn12x3[4 * value])[1]) + "+" + std::string(&getSourceString(MIXSRC_Rud + modn12x3[4 * value + 1])[1]); return std::to_string(1 + value) + ": left=" + std::string(&getSourceString(MIXSRC_Rud + modn12x3[4 * value])[1]) + "+" + std::string(&getSourceString(MIXSRC_Rud + modn12x3[4 * value + 1])[1]);
}); });
grid.nextLine(); line = window->newLine(&grid);
// extra bottom padding if touchscreen // extra bottom padding if touchscreen
#if defined HARDWARE_TOUCH #if defined HARDWARE_TOUCH
grid.nextLine(); line = window->newLine(&grid);
#endif #endif
} }