feat(radio): refactor of switch handling to better support customisable switches (#6095)

Co-authored-by: philmoz <phil.a.mitchell@gmail.com>
Co-authored-by: 3djc <3djc@gh.com>
Co-authored-by: elecpower <elecpower@users.noreply.github.com>
This commit is contained in:
philmoz
2025-07-28 12:59:22 +10:00
committed by GitHub
co-authored by philmoz 3djc elecpower
parent 28833f42e6
commit 0c8c39b134
155 changed files with 4538 additions and 2306 deletions
+24 -8
View File
@@ -351,7 +351,7 @@ void drawSmallSwitch(coord_t x, coord_t y, int width, unsigned int index)
}
}
lcdDrawChar(width == 5 ? x + 1 : x, y, 'A' + index, SMLSIZE);
lcdDrawChar(width == 5 ? x + 1 : x, y, switchGetDefaultName(index)[1], SMLSIZE);
y += 7;
if (val <= 0) {
@@ -520,14 +520,25 @@ void menuMainView(event_t event)
// -> 2 columns: one for each side
// -> 4 slots on each side
uint8_t maxSwitch = 0;
uint8_t leftMaxRow = 0;
uint8_t rightMaxRow = 0;
for (uint8_t n = 0; n < switchGetMaxSwitches(); n += 1)
if (SWITCH_EXISTS(n) && !switchIsFlex(n))
if (SWITCH_EXISTS(n) && !switchIsFlex(n) && !switchIsCustomSwitch(n)) {
auto switch_display = switchGetDisplayPosition(n);
if (switch_display.col) {
if (switch_display.row > rightMaxRow)
rightMaxRow = switch_display.row;
} else {
if (switch_display.row > leftMaxRow)
leftMaxRow = switch_display.row;
}
maxSwitch = n + 1;
}
for (int i = 0; i < maxSwitch; ++i) {
if (SWITCH_EXISTS(i) && !switchIsFlex(i)) {
auto switch_display = switchGetDisplayPosition(i);
if (maxSwitch < 7) {
if (leftMaxRow < 3 && rightMaxRow < 3) {
for (int i = 0; i < maxSwitch; ++i) {
if (SWITCH_EXISTS(i) && !switchIsFlex(i) && !switchIsCustomSwitch(i)) {
auto switch_display = switchGetDisplayPosition(i);
coord_t x = switch_display.col == 0 ? 3 * FW + 3 : 18 * FW + 1;
coord_t y = 33 + switch_display.row * FH;
getvalue_t val = getValue(MIXSRC_FIRST_SWITCH + i);
@@ -537,9 +548,14 @@ void menuMainView(event_t event)
: ((val == 0) ? 3 * i + 2 : 3 * i + 3));
drawSwitch(x, y, sw, CENTERED, false);
}
else {
}
}
else {
for (int i = 0; i < maxSwitch; ++i) {
if (SWITCH_EXISTS(i) && !switchIsFlex(i) && !switchIsCustomSwitch(i)) {
auto switch_display = switchGetDisplayPosition(i);
coord_t x = (switch_display.col == 0 ? 8 : 96) + switch_display.row * 5;
if (maxSwitch < 9) x += (switch_display.col == 0 ? 2 : 3);
if (maxSwitch < 9) x += 3;
drawSmallSwitch(x, 5 * FH + 1, 4, i);
}
}