switch radio hardware page to flex layout

This commit is contained in:
gagarinlg
2022-06-11 15:38:08 +02:00
committed by Raphael Coeffic
parent c80b040b1e
commit 5fe7de17bb
+154 -118
View File
@@ -30,6 +30,13 @@
#define SET_DIRTY() storageDirty(EE_GENERAL) #define SET_DIRTY() storageDirty(EE_GENERAL)
static const lv_coord_t col_two_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1),
LV_GRID_TEMPLATE_LAST};
static const lv_coord_t col_three_dsc[] = {LV_GRID_FR(2), LV_GRID_FR(1), LV_GRID_FR(1),
LV_GRID_TEMPLATE_LAST};
static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT, LV_GRID_CONTENT,
LV_GRID_TEMPLATE_LAST};
#if defined(PCBHORUS) #if defined(PCBHORUS)
#define SWITCH_TYPE_MAX(sw) ((MIXSRC_SF-MIXSRC_FIRST_SWITCH == sw || MIXSRC_SH-MIXSRC_FIRST_SWITCH == sw) ? SWITCH_2POS : SWITCH_3POS) #define SWITCH_TYPE_MAX(sw) ((MIXSRC_SF-MIXSRC_FIRST_SWITCH == sw || MIXSRC_SH-MIXSRC_FIRST_SWITCH == sw) ? SWITCH_2POS : SWITCH_3POS)
#else #else
@@ -95,7 +102,7 @@ RadioHardwarePage::RadioHardwarePage():
class ModeChoice : public Choice class ModeChoice : public Choice
{ {
public: public:
ModeChoice(FormGroup *parent, const rect_t &rect, const char **values, ModeChoice(Window *parent, const rect_t &rect, const char **values,
int vmin, int vmax, std::function<int()> getValue, int vmin, int vmax, std::function<int()> getValue,
std::function<void(int)> setValue = nullptr, std::function<void(int)> setValue = nullptr,
bool *menuOpen = nullptr) : bool *menuOpen = nullptr) :
@@ -118,7 +125,7 @@ class ModeChoice : public Choice
class BluetoothConfigWindow : public FormGroup class BluetoothConfigWindow : public FormGroup
{ {
public: public:
BluetoothConfigWindow(FormWindow * parent, const rect_t &rect) : BluetoothConfigWindow(Window * parent, const rect_t &rect) :
FormGroup(parent, rect, FORWARD_SCROLL // | FORM_FORWARD_FOCUS FormGroup(parent, rect, FORWARD_SCROLL // | FORM_FORWARD_FOCUS
) )
{ {
@@ -137,19 +144,19 @@ class BluetoothConfigWindow : public FormGroup
void update() void update()
{ {
FormGridLayout grid;
#if LCD_W > LCD_H
grid.setLabelWidth(180);
#else
grid.setLabelWidth(130);
#endif
clear(); clear();
new StaticText(this, grid.getLabelSlot(true), STR_MODE, 0, setFlexLayout();
FlexGridLayout grid(col_three_dsc, row_dsc, 2);
auto line = newLine(&grid);
auto label = new StaticText(line, rect_t{}, STR_MODE, 0,
COLOR_THEME_PRIMARY1); COLOR_THEME_PRIMARY1);
lv_obj_set_style_pad_left(label->getLvObj(), lv_dpx(8), LV_PART_MAIN);
modechoiceopen = false; modechoiceopen = false;
btMode = new ModeChoice( btMode = new ModeChoice(
this, grid.getFieldSlot(), STR_BLUETOOTH_MODES, BLUETOOTH_OFF, line, rect_t{}, STR_BLUETOOTH_MODES, BLUETOOTH_OFF,
BLUETOOTH_TRAINER, GET_DEFAULT(g_eeGeneral.bluetoothMode), BLUETOOTH_TRAINER, GET_DEFAULT(g_eeGeneral.bluetoothMode),
[=](int32_t newValue) { [=](int32_t newValue) {
g_eeGeneral.bluetoothMode = newValue; g_eeGeneral.bluetoothMode = newValue;
@@ -159,30 +166,34 @@ class BluetoothConfigWindow : public FormGroup
modechoiceopen = false; modechoiceopen = false;
}, },
&modechoiceopen); &modechoiceopen);
grid.nextLine(); line = newLine(&grid);
if (g_eeGeneral.bluetoothMode != BLUETOOTH_OFF) { if (g_eeGeneral.bluetoothMode != BLUETOOTH_OFF) {
// Pin code (displayed for information only, not editable) // Pin code (displayed for information only, not editable)
if (g_eeGeneral.bluetoothMode == BLUETOOTH_TELEMETRY) { if (g_eeGeneral.bluetoothMode == BLUETOOTH_TELEMETRY) {
new StaticText(this, grid.getLabelSlot(true), STR_BLUETOOTH_PIN_CODE, 0, COLOR_THEME_PRIMARY1); label = new StaticText(line, rect_t{}, STR_BLUETOOTH_PIN_CODE, 0, COLOR_THEME_PRIMARY1);
new StaticText(this, grid.getFieldSlot(), "000000", 0, COLOR_THEME_PRIMARY1); lv_obj_set_style_pad_left(label->getLvObj(), lv_dpx(8), LV_PART_MAIN);
grid.nextLine(); new StaticText(line, rect_t{}, "000000", 0, COLOR_THEME_PRIMARY1);
line = newLine(&grid);
} }
// Local MAC // Local MAC
new StaticText(this, grid.getLabelSlot(true), STR_BLUETOOTH_LOCAL_ADDR, 0, COLOR_THEME_PRIMARY1); label = new StaticText(line, rect_t{}, STR_BLUETOOTH_LOCAL_ADDR, 0, COLOR_THEME_PRIMARY1);
new StaticText(this, grid.getFieldSlot(), bluetooth.localAddr[0] == '\0' ? "---" : bluetooth.localAddr, 0, COLOR_THEME_PRIMARY1); lv_obj_set_style_pad_left(label->getLvObj(), lv_dpx(8), LV_PART_MAIN);
grid.nextLine(); new StaticText(line, rect_t{}, bluetooth.localAddr[0] == '\0' ? "---" : bluetooth.localAddr, 0, COLOR_THEME_PRIMARY1);
line = newLine(&grid);
// Remote MAC // Remote MAC
new StaticText(this, grid.getLabelSlot(true), STR_BLUETOOTH_DIST_ADDR, 0, COLOR_THEME_PRIMARY1); label = new StaticText(line, rect_t{}, STR_BLUETOOTH_DIST_ADDR, 0, COLOR_THEME_PRIMARY1);
new StaticText(this, grid.getFieldSlot(), bluetooth.distantAddr[0] == '\0' ? "---" : bluetooth.distantAddr, 0, COLOR_THEME_PRIMARY1); lv_obj_set_style_pad_left(label->getLvObj(), lv_dpx(8), LV_PART_MAIN);
grid.nextLine(); new StaticText(line, rect_t{}, bluetooth.distantAddr[0] == '\0' ? "---" : bluetooth.distantAddr, 0, COLOR_THEME_PRIMARY1);
line = newLine(&grid);
// BT radio name // BT radio name
new StaticText(this, grid.getLabelSlot(true), STR_NAME, 0, COLOR_THEME_PRIMARY1); label = new StaticText(line, rect_t{}, STR_NAME, 0, COLOR_THEME_PRIMARY1);
rte = new RadioTextEdit(this, grid.getFieldSlot(), g_eeGeneral.bluetoothName, LEN_BLUETOOTH_NAME); lv_obj_set_style_pad_left(label->getLvObj(), lv_dpx(8), LV_PART_MAIN);
grid.nextLine(); rte = new RadioTextEdit(line, rect_t{}, g_eeGeneral.bluetoothName, LEN_BLUETOOTH_NAME);
line = newLine(&grid);
} }
getParent()->moveWindowsTop(top() + 1, adjustHeight()); getParent()->moveWindowsTop(top() + 1, adjustHeight());
@@ -201,7 +212,7 @@ class BluetoothConfigWindow : public FormGroup
class SerialConfigWindow : public FormGroup class SerialConfigWindow : public FormGroup
{ {
public: public:
SerialConfigWindow(FormWindow *parent, const rect_t &rect) : SerialConfigWindow(Window *parent, const rect_t &rect) :
FormGroup(parent, rect, FORWARD_SCROLL // | FORM_FORWARD_FOCUS FormGroup(parent, rect, FORWARD_SCROLL // | FORM_FORWARD_FOCUS
) )
{ {
@@ -210,24 +221,24 @@ class SerialConfigWindow : public FormGroup
void update() void update()
{ {
FormGridLayout grid;
#if LCD_W > LCD_H
grid.setLabelWidth(180);
#else
grid.setLabelWidth(130);
#endif
clear(); clear();
setFlexLayout();
FlexGridLayout grid(col_two_dsc, row_dsc, 2);
auto line = newLine(&grid);
bool display_ttl_warning = false; bool display_ttl_warning = false;
for (uint8_t port_nr = 0; port_nr < MAX_SERIAL_PORTS; port_nr++) { for (uint8_t port_nr = 0; port_nr < MAX_SERIAL_PORTS; port_nr++) {
auto port = serialGetPort(port_nr); auto port = serialGetPort(port_nr);
if (!port || !port->name) continue; if (!port || !port->name) continue;
display_ttl_warning = true; display_ttl_warning = true;
new StaticText(this, grid.getLabelSlot(true), port->name, 0, auto label = new StaticText(line, rect_t{}, port->name, 0,
COLOR_THEME_PRIMARY1); COLOR_THEME_PRIMARY1);
lv_obj_set_style_pad_left(label->getLvObj(), lv_dpx(8), LV_PART_MAIN);
auto aux = new Choice( auto aux = new Choice(
this, grid.getFieldSlot(), STR_AUX_SERIAL_MODES, 0, line, rect_t{}, STR_AUX_SERIAL_MODES, 0,
UART_MODE_MAX, [=]() { return serialGetMode(port_nr); }, UART_MODE_MAX, [=]() { return serialGetMode(port_nr); },
[=](int value) { [=](int value) {
serialSetMode(port_nr, value); serialSetMode(port_nr, value);
@@ -236,29 +247,33 @@ class SerialConfigWindow : public FormGroup
}); });
aux->setAvailableHandler( aux->setAvailableHandler(
[=](int value) { return isSerialModeAvailable(port_nr, value); }); [=](int value) { return isSerialModeAvailable(port_nr, value); });
grid.nextLine(); line = newLine(&grid);
#if defined(SWSERIALPOWER) #if defined(SWSERIALPOWER)
if (port_nr < SP_VCP) if (port_nr < SP_VCP)
{ {
new StaticText(this, grid.getLabelSlot(true), STR_AUX_SERIAL_PORT_POWER, 0, COLOR_THEME_PRIMARY1); auto label = new StaticText(line, rect_t{}, STR_AUX_SERIAL_PORT_POWER, 0, COLOR_THEME_PRIMARY1);
lv_obj_set_style_pad_left(label->getLvObj(), lv_dpx(8), LV_PART_MAIN);
new CheckBox( new CheckBox(
this, grid.getFieldSlot(1, 0), line, rect_t{},
[=] { return serialGetPower(port_nr); }, [=] { return serialGetPower(port_nr); },
[=](int8_t newValue) { [=](int8_t newValue) {
serialSetPower(port_nr, (bool)newValue); serialSetPower(port_nr, (bool)newValue);
SET_DIRTY(); SET_DIRTY();
} }
); );
grid.nextLine(); line = newLine(&grid);
} }
#endif #endif
} }
if (display_ttl_warning) { if (display_ttl_warning) {
new StaticText(this, grid.getFieldSlot(), STR_TTL_WARNING, 0, grid.setColSpan(2);
auto label = new StaticText(line, rect_t{}, STR_TTL_WARNING, 0,
COLOR_THEME_WARNING); COLOR_THEME_WARNING);
grid.nextLine(); lv_obj_set_style_pad_left(label->getLvObj(), lv_dpx(8), LV_PART_MAIN);
grid.setColSpan(1);
line = newLine(&grid);
} }
getParent()->moveWindowsTop(top() + 1, adjustHeight()); getParent()->moveWindowsTop(top() + 1, adjustHeight());
@@ -267,7 +282,7 @@ class SerialConfigWindow : public FormGroup
class InternalModuleWindow : public FormGroup { class InternalModuleWindow : public FormGroup {
public: public:
InternalModuleWindow(FormWindow *parent, const rect_t &rect) : InternalModuleWindow(Window *parent, const rect_t &rect) :
FormGroup(parent, rect, FORWARD_SCROLL), FormGroup(parent, rect, FORWARD_SCROLL),
lastModule(g_eeGeneral.internalModule) lastModule(g_eeGeneral.internalModule)
{ {
@@ -276,17 +291,17 @@ class InternalModuleWindow : public FormGroup {
void update() void update()
{ {
FormGridLayout grid;
#if LCD_W > LCD_H
grid.setLabelWidth(180);
#else
grid.setLabelWidth(130);
#endif
clear(); clear();
new StaticText(this, grid.getLabelSlot(true), TR_INTERNAL_MODULE, 0, setFlexLayout();
FlexGridLayout grid(col_two_dsc, row_dsc, 2);
auto line = newLine(&grid);
auto label = new StaticText(line, rect_t{}, TR_INTERNAL_MODULE, 0,
COLOR_THEME_PRIMARY1); COLOR_THEME_PRIMARY1);
auto internalModule = new Choice(this, grid.getFieldSlot(),STR_INTERNAL_MODULE_PROTOCOLS, MODULE_TYPE_NONE, MODULE_TYPE_COUNT - 1, lv_obj_set_style_pad_left(label->getLvObj(), lv_dpx(8), LV_PART_MAIN);
auto internalModule = new Choice(line, rect_t{},STR_INTERNAL_MODULE_PROTOCOLS, MODULE_TYPE_NONE, MODULE_TYPE_COUNT - 1,
GET_DEFAULT(g_eeGeneral.internalModule), GET_DEFAULT(g_eeGeneral.internalModule),
[=](int moduleType) { [=](int moduleType) {
if (g_model.moduleData[INTERNAL_MODULE].type != moduleType) { if (g_model.moduleData[INTERNAL_MODULE].type != moduleType) {
@@ -300,12 +315,13 @@ class InternalModuleWindow : public FormGroup {
internalModule->setAvailableHandler([](int module){ internalModule->setAvailableHandler([](int module){
return isInternalModuleSupported(module); return isInternalModuleSupported(module);
}); });
grid.nextLine(); line = newLine(&grid);
#if defined(CROSSFIRE) #if defined(CROSSFIRE)
if (isInternalModuleCrossfire()) { if (isInternalModuleCrossfire()) {
new StaticText(this, grid.getLabelSlot(true), STR_BAUDRATE, 0,COLOR_THEME_PRIMARY1); auto label = new StaticText(line, rect_t{}, STR_BAUDRATE, 0,COLOR_THEME_PRIMARY1);
new Choice(this, grid.getFieldSlot(), STR_CRSF_BAUDRATE, 0,CROSSFIRE_MAX_INTERNAL_BAUDRATE, lv_obj_set_style_pad_left(label->getLvObj(), lv_dpx(8), LV_PART_MAIN);
new Choice(line, rect_t{}, STR_CRSF_BAUDRATE, 0,CROSSFIRE_MAX_INTERNAL_BAUDRATE,
[=]() -> int { [=]() -> int {
return CROSSFIRE_STORE_TO_INDEX(g_eeGeneral.internalModuleBaudrate); return CROSSFIRE_STORE_TO_INDEX(g_eeGeneral.internalModuleBaudrate);
}, },
@@ -314,12 +330,7 @@ class InternalModuleWindow : public FormGroup {
SET_DIRTY(); SET_DIRTY();
restartModule(INTERNAL_MODULE); restartModule(INTERNAL_MODULE);
}); });
grid.nextLine(); line = newLine(&grid);
#if defined(USB_SERIAL)
// If USB-VCP was off, set it to CLI to enable passthrough flashing
if (serialGetMode(SP_VCP) == UART_MODE_NONE)
serialSetMode(SP_VCP, UART_MODE_CLI);
#endif
} }
#endif #endif
getParent()->moveWindowsTop(top() + 1, adjustHeight()); getParent()->moveWindowsTop(top() + 1, adjustHeight());
@@ -341,17 +352,14 @@ class InternalModuleWindow : public FormGroup {
void RadioHardwarePage::build(FormWindow * window) void RadioHardwarePage::build(FormWindow * window)
{ {
FormGridLayout grid; window->setFlexLayout();
#if LCD_W > LCD_H FlexGridLayout grid(col_three_dsc, row_dsc, 2);
grid.setLabelWidth(180);
#else auto line = window->newLine(&grid);
grid.setLabelWidth(130);
#endif
grid.spacer(PAGE_PADDING);
// Calibration // Calibration
new StaticText(window, grid.getLabelSlot(), STR_INPUTS, 0, COLOR_THEME_PRIMARY1 | FONT(BOLD)); new StaticText(line, rect_t{}, STR_INPUTS, 0, COLOR_THEME_PRIMARY1 | FONT(BOLD));
auto calib = new TextButton(window, grid.getFieldSlot(), STR_CALIBRATION); auto calib = new TextButton(line, rect_t{}, STR_CALIBRATION);
calib->setPressHandler([=]() -> uint8_t { calib->setPressHandler([=]() -> uint8_t {
// auto calibrationPage = // auto calibrationPage =
new RadioCalibrationPage(); new RadioCalibrationPage();
@@ -360,21 +368,24 @@ void RadioHardwarePage::build(FormWindow * window)
// }); // });
return 0; return 0;
}); });
grid.nextLine(); line = window->newLine(&grid);
// Sticks // Sticks
new Subtitle(window, grid.getLineSlot(), STR_STICKS, 0, COLOR_THEME_PRIMARY1); new Subtitle(line, rect_t{}, STR_STICKS, 0, COLOR_THEME_PRIMARY1);
grid.nextLine(); line = window->newLine(&grid);
for (int i = 0; i < NUM_STICKS; i++) { for (int i = 0; i < NUM_STICKS; i++) {
new StaticText(window, grid.getLabelSlot(true), TEXT_AT_INDEX(STR_VSRCRAW, (i + 1)), 0, COLOR_THEME_PRIMARY1); auto label = new StaticText(line, rect_t{}, TEXT_AT_INDEX(STR_VSRCRAW, (i + 1)), 0, COLOR_THEME_PRIMARY1);
new RadioTextEdit(window, grid.getFieldSlot(2,0), g_eeGeneral.anaNames[i], LEN_ANA_NAME); lv_obj_set_style_pad_left(label->getLvObj(), lv_dpx(8), LV_PART_MAIN);
grid.nextLine(); auto textEdit = new RadioTextEdit(line, rect_t{}, g_eeGeneral.anaNames[i], LEN_ANA_NAME);
lv_obj_set_style_grid_cell_x_align(textEdit->getLvObj(), LV_GRID_ALIGN_STRETCH, 0);
line = window->newLine(&grid);
} }
#if defined(STICK_DEAD_ZONE) #if defined(STICK_DEAD_ZONE)
new StaticText(window, grid.getLabelSlot(true), STR_DEAD_ZONE); auto text = new StaticText(line, rect_t{}, STR_DEAD_ZONE);
lv_obj_set_style_pad_left(text->getLvObj(), lv_dpx(8), LV_PART_MAIN);
auto choice = auto choice =
new Choice(window, grid.getFieldSlot(2,0), 0, 7, new Choice(line, rect_t{}, 0, 7,
GET_DEFAULT(g_eeGeneral.stickDeadZone), [=](uint8_t newValue) { GET_DEFAULT(g_eeGeneral.stickDeadZone), [=](uint8_t newValue) {
g_eeGeneral.stickDeadZone = newValue; g_eeGeneral.stickDeadZone = newValue;
SET_DIRTY(); SET_DIRTY();
@@ -382,12 +393,12 @@ void RadioHardwarePage::build(FormWindow * window)
choice->setTextHandler([](uint8_t value) { choice->setTextHandler([](uint8_t value) {
return std::to_string(value ? 2 << (value - 1) : 0); return std::to_string(value ? 2 << (value - 1) : 0);
}); });
grid.nextLine(); line = window->newLine(&grid);
#endif #endif
// Pots // Pots
new Subtitle(window, grid.getLineSlot(), STR_POTS, 0, COLOR_THEME_PRIMARY1); new Subtitle(line, rect_t{}, STR_POTS, 0, COLOR_THEME_PRIMARY1);
grid.nextLine(); line = window->newLine(&grid);
for (int i = 0; i < NUM_POTS; i++) { for (int i = 0; i < NUM_POTS; i++) {
// Display EX3 & EX4 (= last two pots) only when FlySky gimbals are present // Display EX3 & EX4 (= last two pots) only when FlySky gimbals are present
#if !defined(SIMU) && defined(RADIO_FAMILY_T16) #if !defined(SIMU) && defined(RADIO_FAMILY_T16)
@@ -395,9 +406,12 @@ void RadioHardwarePage::build(FormWindow * window)
continue; continue;
#endif #endif
new StaticText(window, grid.getLabelSlot(true), TEXT_AT_INDEX(STR_VSRCRAW, (i + NUM_STICKS + 1)), 0, COLOR_THEME_PRIMARY1); auto label = new StaticText(line, rect_t{}, TEXT_AT_INDEX(STR_VSRCRAW, (i + NUM_STICKS + 1)), 0, COLOR_THEME_PRIMARY1);
new RadioTextEdit(window, grid.getFieldSlot(2,0), g_eeGeneral.anaNames[i + NUM_STICKS], LEN_ANA_NAME); lv_obj_set_style_pad_left(label->getLvObj(), lv_dpx(8), LV_PART_MAIN);
new Choice(window, grid.getFieldSlot(2,1), STR_POTTYPES, POT_NONE, POT_WITHOUT_DETENT,
auto textEdit = new RadioTextEdit(line, rect_t{}, g_eeGeneral.anaNames[i + NUM_STICKS], LEN_ANA_NAME);
lv_obj_set_style_grid_cell_x_align(textEdit->getLvObj(), LV_GRID_ALIGN_STRETCH, 0);
new Choice(line, rect_t{}, STR_POTTYPES, POT_NONE, POT_WITHOUT_DETENT,
[=]() -> int { [=]() -> int {
return bfGet<uint32_t>(g_eeGeneral.potsConfig, 2*i, 2); return bfGet<uint32_t>(g_eeGeneral.potsConfig, 2*i, 2);
}, },
@@ -405,18 +419,21 @@ void RadioHardwarePage::build(FormWindow * window)
g_eeGeneral.potsConfig = bfSet<uint32_t>(g_eeGeneral.potsConfig, newValue, 2*i, 2); g_eeGeneral.potsConfig = bfSet<uint32_t>(g_eeGeneral.potsConfig, newValue, 2*i, 2);
SET_DIRTY(); SET_DIRTY();
}); });
grid.nextLine(); line = window->newLine(&grid);
} }
// Sliders // Sliders
new Subtitle(window, grid.getLineSlot(), STR_SLIDERS, 0, COLOR_THEME_PRIMARY1); #if (NUM_SLIDERS > 0)
grid.nextLine(); new Subtitle(line, rect_t{}, STR_SLIDERS, 0, COLOR_THEME_PRIMARY1);
line = window->newLine(&grid);
for (int i = 0; i < NUM_SLIDERS; i++) { for (int i = 0; i < NUM_SLIDERS; i++) {
const int idx = i + NUM_STICKS + NUM_POTS; const int idx = i + NUM_STICKS + NUM_POTS;
new StaticText(window, grid.getLabelSlot(true), TEXT_AT_INDEX(STR_VSRCRAW, idx + 1), 0, COLOR_THEME_PRIMARY1); auto label = new StaticText(line, rect_t{}, TEXT_AT_INDEX(STR_VSRCRAW, idx + 1), 0, COLOR_THEME_PRIMARY1);
new RadioTextEdit(window, grid.getFieldSlot(2, 0), g_eeGeneral.anaNames[idx], LEN_ANA_NAME); lv_obj_set_style_pad_left(label->getLvObj(), lv_dpx(8), LV_PART_MAIN);
auto textEdit = new RadioTextEdit(line, rect_t{}, g_eeGeneral.anaNames[idx], LEN_ANA_NAME);
lv_obj_set_style_grid_cell_x_align(textEdit->getLvObj(), LV_GRID_ALIGN_STRETCH, 0);
new Choice( new Choice(
window, grid.getFieldSlot(2, 1), STR_SLIDERTYPES, SLIDER_NONE, window, rect_t{}, STR_SLIDERTYPES, SLIDER_NONE,
SLIDER_WITH_DETENT, SLIDER_WITH_DETENT,
[=]() -> int { [=]() -> int {
uint8_t mask = (0x01 << i); uint8_t mask = (0x01 << i);
@@ -428,16 +445,19 @@ void RadioHardwarePage::build(FormWindow * window)
g_eeGeneral.slidersConfig |= (newValue << i); g_eeGeneral.slidersConfig |= (newValue << i);
SET_DIRTY(); SET_DIRTY();
}); });
grid.nextLine(); line = window->newLine(&grid);
} }
#endif
// Switches // Switches
new Subtitle(window, grid.getLineSlot(), STR_SWITCHES, 0, COLOR_THEME_PRIMARY1); new Subtitle(line, rect_t{}, STR_SWITCHES, 0, COLOR_THEME_PRIMARY1);
grid.nextLine(); line = window->newLine(&grid);
for (int i = 0; i < NUM_SWITCHES; i++) { for (int i = 0; i < NUM_SWITCHES; i++) {
new SwitchDynamicLabel(window, grid.getLabelSlot(true), i); auto label = new SwitchDynamicLabel(line, rect_t{}, i);
new RadioTextEdit(window, grid.getFieldSlot(2, 0), g_eeGeneral.switchNames[i], LEN_SWITCH_NAME); lv_obj_set_style_pad_left(label->getLvObj(), lv_dpx(8), LV_PART_MAIN);
new Choice(window, grid.getFieldSlot(2, 1), STR_SWTYPES, SWITCH_NONE, SWITCH_TYPE_MAX(i), auto textEdit = new RadioTextEdit(line, rect_t{}, g_eeGeneral.switchNames[i], LEN_SWITCH_NAME);
lv_obj_set_style_grid_cell_x_align(textEdit->getLvObj(), LV_GRID_ALIGN_STRETCH, 0);
new Choice(line, rect_t{}, STR_SWTYPES, SWITCH_NONE, SWITCH_TYPE_MAX(i),
[=]() -> int { [=]() -> int {
return SWITCH_CONFIG(i); return SWITCH_CONFIG(i);
}, },
@@ -446,58 +466,74 @@ void RadioHardwarePage::build(FormWindow * window)
g_eeGeneral.switchConfig = (g_eeGeneral.switchConfig & ~mask) | ((swconfig_t(newValue) & 0x03) << (2 * i)); g_eeGeneral.switchConfig = (g_eeGeneral.switchConfig & ~mask) | ((swconfig_t(newValue) & 0x03) << (2 * i));
SET_DIRTY(); SET_DIRTY();
}); });
grid.nextLine(); line = window->newLine(&grid);
} }
// Bat calibration // Bat calibration
new StaticText(window, grid.getLabelSlot(), STR_BATT_CALIB, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_BATT_CALIB, 0, COLOR_THEME_PRIMARY1);
auto batCal = new NumberEdit(window, grid.getFieldSlot(1,0), -127, 127, GET_SET_DEFAULT(g_eeGeneral.txVoltageCalibration)); auto batCal = new NumberEdit(line, rect_t{}, -127, 127, GET_SET_DEFAULT(g_eeGeneral.txVoltageCalibration));
batCal->setDisplayHandler([](int32_t value) { batCal->setDisplayHandler([](int32_t value) {
return formatNumberAsString(getBatteryVoltage(), PREC2, 0, nullptr, "V"); return formatNumberAsString(getBatteryVoltage(), PREC2, 0, nullptr, "V");
}); });
batCal->setWindowFlags(REFRESH_ALWAYS); batCal->setWindowFlags(REFRESH_ALWAYS);
grid.nextLine(); line = window->newLine(&grid);
// RTC Batt display // RTC Batt display
new StaticText(window, grid.getLabelSlot(), STR_RTC_BATT, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_RTC_BATT, 0, COLOR_THEME_PRIMARY1);
new DynamicNumber<uint16_t>(window, grid.getFieldSlot(1,0), [] { new DynamicNumber<uint16_t>(line, rect_t{}, [] {
return getRTCBatteryVoltage(); return getRTCBatteryVoltage();
}, COLOR_THEME_PRIMARY1 | PREC2, nullptr, "V"); }, COLOR_THEME_PRIMARY1 | PREC2, nullptr, "V");
grid.nextLine(); line = window->newLine(&grid);
// RTC Batt check enable // RTC Batt check enable
new StaticText(window, grid.getLabelSlot(), STR_RTC_CHECK, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_RTC_CHECK, 0, COLOR_THEME_PRIMARY1);
new CheckBox(window, grid.getFieldSlot(1,0), GET_SET_INVERTED(g_eeGeneral.disableRtcWarning )); new CheckBox(line, rect_t{}, GET_SET_INVERTED(g_eeGeneral.disableRtcWarning ));
grid.nextLine(); line = window->newLine(&grid);
#if defined(HARDWARE_INTERNAL_MODULE) #if defined(HARDWARE_INTERNAL_MODULE)
new Subtitle(window, grid.getLineSlot(), TR_INTERNALRF, 0, COLOR_THEME_PRIMARY1); new Subtitle(line, rect_t{}, TR_INTERNALRF, 0, COLOR_THEME_PRIMARY1);
grid.nextLine(); line = window->newLine(&grid);
grid.addWindow(new InternalModuleWindow(window, {0, grid.getWindowHeight(), LCD_W, 0})); lv_obj_set_style_pad_left(line->getLvObj(), 0, LV_PART_MAIN);
lv_obj_set_style_pad_right(line->getLvObj(), 0, LV_PART_MAIN);
// Date and Time
grid.setColSpan(2);
new InternalModuleWindow(line, rect_t{});
grid.setColSpan(1);
line = window->newLine(&grid);
#endif #endif
#if defined(BLUETOOTH) #if defined(BLUETOOTH)
// Bluetooth mode // Bluetooth mode
{ {
new Subtitle(window, grid.getLineSlot(), STR_BLUETOOTH, 0, COLOR_THEME_PRIMARY1); new Subtitle(line, rect_t{}, STR_BLUETOOTH, 0, COLOR_THEME_PRIMARY1);
grid.nextLine(); line = window->newLine(&grid);
grid.addWindow(new BluetoothConfigWindow(window, {0, grid.getWindowHeight(), LCD_W, 0})); lv_obj_set_style_pad_left(line->getLvObj(), 0, LV_PART_MAIN);
lv_obj_set_style_pad_right(line->getLvObj(), 0, LV_PART_MAIN);
grid.setColSpan(2);
new BluetoothConfigWindow(line, rect_t{});
grid.setColSpan(1);
line = window->newLine(&grid);
} }
#endif #endif
new Subtitle(window, grid.getLineSlot(), STR_AUX_SERIAL_MODE, 0, new Subtitle(line, rect_t{}, STR_AUX_SERIAL_MODE, 0,
COLOR_THEME_PRIMARY1); COLOR_THEME_PRIMARY1);
grid.nextLine(); line = window->newLine(&grid);
grid.addWindow(new SerialConfigWindow(window, {0, grid.getWindowHeight(), LCD_W, 0})); lv_obj_set_style_pad_left(line->getLvObj(), 0, LV_PART_MAIN);
lv_obj_set_style_pad_right(line->getLvObj(), 0, LV_PART_MAIN);
grid.setColSpan(2);
new SerialConfigWindow(line, rect_t{});
grid.setColSpan(1);
line = window->newLine(&grid);
// ADC filter // ADC filter
new StaticText(window, grid.getLabelSlot(), STR_JITTER_FILTER, 0, COLOR_THEME_PRIMARY1); new StaticText(line, rect_t{}, STR_JITTER_FILTER, 0, COLOR_THEME_PRIMARY1);
new CheckBox(window, grid.getFieldSlot(1,0), GET_SET_INVERTED(g_eeGeneral.noJitterFilter)); new CheckBox(line, rect_t{}, GET_SET_INVERTED(g_eeGeneral.noJitterFilter));
grid.nextLine(); line = window->newLine(&grid);
// Debugs // Debugs
new StaticText(window, grid.getLabelSlot(), STR_DEBUG, 0, COLOR_THEME_PRIMARY1 | FONT(BOLD)); new StaticText(line, rect_t{}, STR_DEBUG, 0, COLOR_THEME_PRIMARY1 | FONT(BOLD));
auto debugAnas = new TextButton(window, grid.getFieldSlot(2, 0), STR_ANALOGS_BTN); auto debugAnas = new TextButton(line, rect_t{}, STR_ANALOGS_BTN);
debugAnas->setPressHandler([=]() -> uint8_t { debugAnas->setPressHandler([=]() -> uint8_t {
// auto debugAnalogsPage = // auto debugAnalogsPage =
new RadioAnalogsDiagsViewPageGroup(); new RadioAnalogsDiagsViewPageGroup();
@@ -507,7 +543,7 @@ void RadioHardwarePage::build(FormWindow * window)
return 0; return 0;
}); });
auto debugKeys = new TextButton(window, grid.getFieldSlot(2, 1), STR_KEYS_BTN); auto debugKeys = new TextButton(line, rect_t{}, STR_KEYS_BTN);
debugKeys->setPressHandler([=]() -> uint8_t { debugKeys->setPressHandler([=]() -> uint8_t {
// auto debugKeysPage = // auto debugKeysPage =
new RadioKeyDiagsPage(); new RadioKeyDiagsPage();
@@ -516,11 +552,11 @@ void RadioHardwarePage::build(FormWindow * window)
// }); // });
return 0; return 0;
}); });
grid.nextLine(); line = window->newLine(&grid);
// extra bottom padding if touchscreen // extra bottom padding if touchscreen
#if defined HARDWARE_TOUCH #if defined HARDWARE_TOUCH
new StaticText(window, grid.getLabelSlot()); new StaticText(line, rect_t{});
#endif #endif
} }