UI improvements

This commit is contained in:
Raphael Coeffic
2022-03-20 16:30:58 +01:00
parent f1dc564c76
commit 074a141d81
10 changed files with 75 additions and 35 deletions
+54 -26
View File
@@ -197,6 +197,56 @@ class BluetoothConfigWindow : public FormGroup
};
#endif
class SerialConfigWindow : public FormGroup
{
public:
SerialConfigWindow(FormWindow *parent, const rect_t &rect) :
FormGroup(parent, rect, FORWARD_SCROLL | FORM_FORWARD_FOCUS)
{
update();
}
void update()
{
FormGridLayout grid;
#if LCD_W > LCD_H
grid.setLabelWidth(180);
#else
grid.setLabelWidth(130);
#endif
clear();
bool display_ttl_warning = false;
for (uint8_t port_nr = 0; port_nr < MAX_SERIAL_PORTS; port_nr++) {
auto port = serialGetPort(port_nr);
if (!port || !port->name) continue;
display_ttl_warning = true;
new StaticText(this, grid.getLabelSlot(true), port->name, 0,
COLOR_THEME_PRIMARY1);
auto aux = new Choice(
this, grid.getFieldSlot(), STR_AUX_SERIAL_MODES, 0,
UART_MODE_MAX, [=]() { return serialGetMode(port_nr); },
[=](int value) {
serialSetMode(port_nr, value);
serialInit(port_nr, value);
SET_DIRTY();
});
aux->setAvailableHandler(
[=](int value) { return isSerialModeAvailable(port_nr, value); });
grid.nextLine();
}
if (display_ttl_warning) {
new StaticText(this, grid.getFieldSlot(), STR_TTL_WARNING, 0,
COLOR_THEME_WARNING);
grid.nextLine();
}
getParent()->moveWindowsTop(top() + 1, adjustHeight());
}
};
void restartExternalModule()
{
if (!IS_EXTERNAL_MODULE_ON()) {
@@ -373,32 +423,10 @@ void RadioHardwarePage::build(FormWindow * window)
}
#endif
bool display_ttl_warning = false;
for (uint8_t port_nr = 0; port_nr < MAX_SERIAL_PORTS; port_nr++) {
auto port = serialGetPort(port_nr);
if (!port) continue;
display_ttl_warning = true;
new StaticText(window, grid.getLabelSlot(), STR_AUX_SERIAL_MODE, 0,
COLOR_THEME_PRIMARY1);
auto aux = new Choice(
window, grid.getFieldSlot(1, 0), STR_AUX_SERIAL_MODES, 0, UART_MODE_MAX,
[=]() { return serialGetMode(port_nr); },
[=](int value) {
serialSetMode(port_nr, value);
serialInit(port_nr, value);
SET_DIRTY();
});
aux->setAvailableHandler(
[=](int value) { return isAuxModeAvailable(port_nr, value); });
grid.nextLine();
}
if (display_ttl_warning) {
new StaticText(window, grid.getFieldSlot(1, 0), STR_TTL_WARNING, 0,
COLOR_THEME_WARNING);
grid.nextLine();
}
new Subtitle(window, grid.getLineSlot(), STR_AUX_SERIAL_MODE, 0,
COLOR_THEME_PRIMARY1);
grid.nextLine();
grid.addWindow(new SerialConfigWindow(window, {0, grid.getWindowHeight(), LCD_W, 0}));
// ADC filter
new StaticText(window, grid.getLabelSlot(), STR_JITTER_FILTER, 0, COLOR_THEME_PRIMARY1);
+1 -1
View File
@@ -375,7 +375,7 @@ int hasSerialMode(int mode)
return -1;
}
bool isAuxModeAvailable(uint8_t port_nr, int mode)
bool isSerialModeAvailable(uint8_t port_nr, int mode)
{
auto p = hasSerialMode(mode);
if (p >= 0 && p != port_nr) return false;
+1 -1
View File
@@ -86,7 +86,7 @@ bool isSourceAvailableInCustomSwitches(int source);
bool isSourceAvailableInResetSpecialFunction(int index);
bool isSourceAvailableInGlobalResetSpecialFunction(int index);
bool isSwitchAvailable(int swtch, SwitchContext context);
bool isAuxModeAvailable(uint8_t port_nr, int mode);
bool isSerialModeAvailable(uint8_t port_nr, int mode);
int hasSerialMode(int mode);
bool isSwitchAvailableInLogicalSwitches(int swtch);
bool isSwitchAvailableInCustomFunctions(int swtch);
+1
View File
@@ -26,6 +26,7 @@
typedef void etx_pwr_driver;
typedef struct {
const char* name;
const etx_serial_driver_t* uart;
void (*set_pwr)(uint8_t on);
} etx_serial_port_t;
+4
View File
@@ -82,6 +82,10 @@ void postRadioSettingsLoad()
setDefaultOwnerId();
}
#endif
#if defined(PCBX12S)
// AUX2 is hardwired to AUX2 on X12S
serialSetMode(SP_AUX2, UART_MODE_GPS);
#endif
}
#if defined(EXTERNAL_ANTENNA) && defined(INTERNAL_MODULE_PXX1)
@@ -309,6 +309,7 @@ static const etx_serial_driver_t usbSerialDriver = {
};
const etx_serial_port_t UsbSerialPort = {
"VCP",
&usbSerialDriver,
nullptr,
};
+1 -1
View File
@@ -54,6 +54,7 @@ set(INTERNAL_MODULES PXX1;PXX2;MULTI;CRSF CACHE STRING "Internal modules")
# VCP CLI
set(ENABLE_SERIAL_PASSTHROUGH ON CACHE BOOL "Enable serial passthrough")
set(CLI ON CACHE BOOL "Enable CLI")
set(AUX_SERIAL ON)
if (PCB STREQUAL X10)
set(PCBREV "STD" CACHE STRING "PCB Revision")
@@ -100,7 +101,6 @@ if (PCB STREQUAL X10)
set(USB_CHARGER YES)
set(DEFAULT_THEME "DARKBLUE")
set(SBUS_TRAINER ON)
set(AUX_SERIAL ON)
add_definitions(-DMANUFACTURER_RADIOMASTER)
if (NOT BLUETOOTH)
set(AUX2_SERIAL ON)
+8
View File
@@ -349,6 +349,7 @@ void set_aux_pwr(uint8_t on)
}
const etx_serial_port_t auxSerialPort = {
"AUX1",
&AuxSerialDriver,
set_aux_pwr,
};
@@ -366,6 +367,13 @@ void set_aux2_pwr(uint8_t on)
}
const etx_serial_port_t aux2SerialPort = {
#if !defined(PCBX12S)
"AUX2",
#else
// AUX2 is hardwired to the internal GPS
// on the X12S, let's hide the setting
nullptr,
#endif
&Aux2SerialDriver,
set_aux2_pwr,
};
+3 -6
View File
@@ -747,21 +747,18 @@ void rtcSetTime(const struct gtm * t)
}
#if defined(USB_SERIAL)
const etx_serial_port_t UsbSerialPort = {
nullptr,
nullptr,
};
const etx_serial_port_t UsbSerialPort = { "VCP", nullptr, nullptr };
#endif
#if defined(AUX_SERIAL)
const etx_serial_port_t auxSerialPort = { nullptr, nullptr };
const etx_serial_port_t auxSerialPort = { "AUX1", nullptr, nullptr };
#define AUX_SERIAL_PORT &auxSerialPort
#else
#define AUX_SERIAL_PORT nullptr
#endif
#if defined(AUX2_SERIAL)
const etx_serial_port_t aux2SerialPort = { nullptr, nullptr };
const etx_serial_port_t aux2SerialPort = { "AUX2", nullptr, nullptr };
#define AUX2_SERIAL_PORT &aux2SerialPort
#else
#define AUX2_SERIAL_PORT nullptr
+1
View File
@@ -419,6 +419,7 @@ void initJackDetect(void)
#if defined(AUX_SERIAL)
const etx_serial_port_t auxSerialPort = {
"AUX1",
&AuxSerialDriver,
nullptr
};