fix(ui-new): on/off written On / Off everywhere, as every other value

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-10-06 14:12:27 +02:00
co-authored by Claude Opus 5.5
parent c4217d8632
commit 608c5b7dad
5 changed files with 16 additions and 15 deletions
+2 -2
View File
@@ -575,7 +575,7 @@ struct NodePrefs { // persisted to file
return S[idx < GPS_AVG_COUNT ? idx : 0]; return S[idx < GPS_AVG_COUNT ? idx : 0];
} }
static const char* gpsAvgLabel(uint8_t idx) { static const char* gpsAvgLabel(uint8_t idx) {
static const char* L[GPS_AVG_COUNT] = { "OFF", "5s", "10s", "30s" }; static const char* L[GPS_AVG_COUNT] = { "Off", "5s", "10s", "30s" };
return L[idx < GPS_AVG_COUNT ? idx : 0]; return L[idx < GPS_AVG_COUNT ? idx : 0];
} }
@@ -586,7 +586,7 @@ struct NodePrefs { // persisted to file
return S[idx < TRAIL_AUTOPAUSE_COUNT ? idx : 0]; return S[idx < TRAIL_AUTOPAUSE_COUNT ? idx : 0];
} }
static const char* trailAutoPauseLabel(uint8_t idx) { static const char* trailAutoPauseLabel(uint8_t idx) {
static const char* L[TRAIL_AUTOPAUSE_COUNT] = { "OFF", "1m", "2m", "5m" }; static const char* L[TRAIL_AUTOPAUSE_COUNT] = { "Off", "1m", "2m", "5m" };
return L[idx < TRAIL_AUTOPAUSE_COUNT ? idx : 0]; return L[idx < TRAIL_AUTOPAUSE_COUNT ? idx : 0];
} }
// Movement under this many metres counts as "stationary" for auto-pause. // Movement under this many metres counts as "stationary" for auto-pause.
@@ -103,7 +103,7 @@ class AdminScreen : public UIScreen {
// Right-column text for the row in _value_editing (freq draws its own editor). // Right-column text for the row in _value_editing (freq draws its own editor).
void formatEditValue(const admin::Field& f, char* buf, size_t n) const { void formatEditValue(const admin::Field& f, char* buf, size_t n) const {
switch (f.kind) { switch (f.kind) {
case admin::K_ONOFF: snprintf(buf, n, "%s", S().value != 0 ? "ON" : "OFF"); break; case admin::K_ONOFF: snprintf(buf, n, "%s", S().value != 0 ? "On" : "Off"); break;
case admin::K_RADIO_BW: snprintf(buf, n, "%.1f", S().radio_bw); break; case admin::K_RADIO_BW: snprintf(buf, n, "%.1f", S().radio_bw); break;
case admin::K_RADIO_SF: snprintf(buf, n, "%d", (int)S().radio_sf); break; case admin::K_RADIO_SF: snprintf(buf, n, "%d", (int)S().radio_sf); break;
case admin::K_RADIO_CR: snprintf(buf, n, "%d", (int)S().radio_cr); break; case admin::K_RADIO_CR: snprintf(buf, n, "%d", (int)S().radio_cr); break;
+2 -2
View File
@@ -87,7 +87,7 @@ class GpioScreen : public UIScreen {
else if (mode == 2 || mode == 3) next = analog_ok ? 4 : 0; else if (mode == 2 || mode == 3) next = analog_ok ? 4 : 0;
else next = 0; // was Analog -> back to OFF else next = 0; // was Analog -> back to OFF
_task->setGpioMode(pin + 1, next); _task->setGpioMode(pin + 1, next);
const char* name = (next == 0) ? "OFF" : (next == 1) ? "Input" : (next == 2) ? "Output" : "Analog"; const char* name = (next == 0) ? "Off" : (next == 1) ? "Input" : (next == 2) ? "Output" : "Analog";
char msg[24]; char msg[24];
snprintf(msg, sizeof(msg), "GPIO%d: %s", pin + 1, name); snprintf(msg, sizeof(msg), "GPIO%d: %s", pin + 1, name);
_task->showAlert(msg, 800); _task->showAlert(msg, 800);
@@ -98,7 +98,7 @@ class GpioScreen : public UIScreen {
bool on = (gpioModeOf(pin) == 3); bool on = (gpioModeOf(pin) == 3);
_task->setGpioMode(pin + 1, on ? 2 : 3); _task->setGpioMode(pin + 1, on ? 2 : 3);
char msg[24]; char msg[24];
snprintf(msg, sizeof(msg), "GPIO%d: %s", pin + 1, on ? "OFF" : "ON"); snprintf(msg, sizeof(msg), "GPIO%d: %s", pin + 1, on ? "Off" : "On");
_task->showAlert(msg, 800); _task->showAlert(msg, 800);
} }
+8 -7
View File
@@ -194,13 +194,14 @@ inline int big(DisplayDriver& d, int x, int y, const char* value, const char* un
} }
inline int bigH(DisplayDriver& d) { return 2 * d.getLineHeight(); } inline int bigH(DisplayDriver& d) { return 2 * d.getLineHeight(); }
// An on/off state, right edge at x_right on a text line at y: the words ON / // An on/off state, right edge at x_right on a text line at y: the words On /
// OFF. (A drawn pill switch read as a battery on the small screens.) `inv` // Off, written as every other value. (A drawn pill switch read as a battery
// draws it in a selected row's colours (dark on the light bar). // on the small screens.) `inv` draws it in a selected row's colours (dark on
inline int switchW(DisplayDriver& d) { return d.getTextWidth("OFF"); } // the light bar).
inline int switchW(DisplayDriver& d) { return d.getTextWidth("Off"); }
inline void toggle(DisplayDriver& d, int x_right, int y, bool on, bool inv = false) { inline void toggle(DisplayDriver& d, int x_right, int y, bool on, bool inv = false) {
d.setColor(inv ? DisplayDriver::DARK : DisplayDriver::LIGHT); d.setColor(inv ? DisplayDriver::DARK : DisplayDriver::LIGHT);
d.drawTextRightAlign(x_right, y, on ? "ON" : "OFF"); d.drawTextRightAlign(x_right, y, on ? "On" : "Off");
} }
// ── List rows (call after drawRowSelection(); text is already in the row's ink) // ── List rows (call after drawRowSelection(); text is already in the row's ink)
@@ -219,8 +220,8 @@ inline int valueRow(DisplayDriver& d, int y, const char* label, const char* valu
const int r = d.drawTextEllipsized(lx, y, right - lx, value, sel); const int r = d.drawTextEllipsized(lx, y, right - lx, value, sel);
return sel && r > 0 ? r : 0; return sel && r > 0 ? r : 0;
} }
// A row from a screen's value formatter: exactly "ON" / "OFF" is a yes/no // A row from a screen's value formatter: exactly "ON" / "OFF" (the marker, not
// setting and gets switchRow(); anything else (an option that can be "Off" // what's shown) is a yes/no setting and gets switchRow(); anything else (an option that can be "Off"
// among numbers included) is a value. Returns valueRow()'s marquee delay. // among numbers included) is a value. Returns valueRow()'s marquee delay.
inline void switchRow(DisplayDriver& d, int y, const char* label, bool on, bool sel, int reserve, int x0 = 2); inline void switchRow(DisplayDriver& d, int y, const char* label, bool on, bool sel, int reserve, int x0 = 2);
inline int listRow(DisplayDriver& d, int y, const char* label, const char* value, bool sel, inline int listRow(DisplayDriver& d, int y, const char* label, const char* value, bool sel,
+3 -3
View File
@@ -2663,7 +2663,7 @@ extern "C" EMSCRIPTEN_KEEPALIVE int sim_buzzer_get_volume() {
// real toggle does: buzzer.quiet(), writes NodePrefs.buzzer_quiet, clears // real toggle does: buzzer.quiet(), writes NodePrefs.buzzer_quiet, clears
// buzzer_auto (manual mute always wins over auto-mute-on-BT-connect, // buzzer_auto (manual mute always wins over auto-mute-on-BT-connect,
// same as pressing it on the device would), the_mesh.savePrefs(), and // same as pressing it on the device would), the_mesh.savePrefs(), and
// the real on-screen "Buzzer: ON/OFF" alert -- so muting from the host // the real on-screen "Buzzer: On/Off" alert -- so muting from the host
// page's button is visibly the same event as muting from the keypad. // page's button is visibly the same event as muting from the keypad.
extern "C" EMSCRIPTEN_KEEPALIVE void sim_buzzer_toggle_quiet() { extern "C" EMSCRIPTEN_KEEPALIVE void sim_buzzer_toggle_quiet() {
if (g_sim_ui_task_for_js) g_sim_ui_task_for_js->toggleBuzzer(); if (g_sim_ui_task_for_js) g_sim_ui_task_for_js->toggleBuzzer();
@@ -3895,7 +3895,7 @@ void UITask::toggleBuzzer() {
soundctl::setMode(_node_prefs, buzzer, on ? soundctl::MODE_ON : soundctl::MODE_OFF, isClientConnected()); soundctl::setMode(_node_prefs, buzzer, on ? soundctl::MODE_ON : soundctl::MODE_OFF, isClientConnected());
if (on) notify(UIEventType::ack); if (on) notify(UIEventType::ack);
the_mesh.savePrefs(); the_mesh.savePrefs();
showAlert(buzzer.isQuiet() ? "Buzzer: OFF" : "Buzzer: ON", 800); showAlert(buzzer.isQuiet() ? "Buzzer: Off" : "Buzzer: On", 800);
_next_refresh = 0; _next_refresh = 0;
#endif #endif
} }
@@ -3915,7 +3915,7 @@ void UITask::cycleBuzzerMode() {
mode = (mode + 1) % soundctl::MODE_COUNT; // ON → OFF → Auto → ON mode = (mode + 1) % soundctl::MODE_COUNT; // ON → OFF → Auto → ON
soundctl::setMode(_node_prefs, buzzer, (uint8_t)mode, isClientConnected()); soundctl::setMode(_node_prefs, buzzer, (uint8_t)mode, isClientConnected());
if (mode == soundctl::MODE_ON) notify(UIEventType::ack); if (mode == soundctl::MODE_ON) notify(UIEventType::ack);
static const char* labels[] = { "Buzzer: ON", "Buzzer: OFF", "Buzzer: Auto" }; static const char* labels[] = { "Buzzer: On", "Buzzer: Off", "Buzzer: Auto" };
showAlert(labels[mode], 800); showAlert(labels[mode], 800);
_next_refresh = 0; _next_refresh = 0;
#endif #endif