From facffe9f07459e09ee731b9a1bff4cde5ebe45c1 Mon Sep 17 00:00:00 2001 From: pelgraine <140762863+pelgraine@users.noreply.github.com> Date: Sat, 14 Mar 2026 20:14:13 +1100 Subject: [PATCH] t5s3 settings screen fix for add channels; t5s3 home screen new message screen refresh fix --- examples/companion_radio/main.cpp | 17 +++++++++-- .../companion_radio/ui-new/Settingsscreen.h | 29 +++++++++++++++++++ examples/companion_radio/ui-new/UITask.cpp | 19 ++++++++++++ .../companion_radio/ui-new/virtualkeyboard.h | 1 + 4 files changed, 63 insertions(+), 3 deletions(-) diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index aac3d9a4..ab71db57 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -832,11 +832,22 @@ MyMesh the_mesh(radio_driver, fast_rng, rtc_clock, tables, store } } - // Settings screen: long press on a deletable channel → trigger delete + // Settings screen: context-dependent long press if (ui_task.isOnSettingsScreen()) { SettingsScreen* ss = (SettingsScreen*)ui_task.getSettingsScreen(); - if (ss && ss->isCursorOnDeletableChannel()) { - return 'x'; // Triggers existing X key → EDIT_CONFIRM delete flow + if (ss) { + if (ss->isEditingText()) { + // Open VKB pre-populated with current edit buffer + ui_task.showVirtualKeyboard(VKB_SETTINGS_TEXT, ss->getEditLabel(), + ss->getEditBuf(), SETTINGS_TEXT_BUF - 1); + return 0; + } + if (ss->isEditingNumOrPicker()) { + return 0; // Consume — don't confirm prematurely + } + if (ss->isCursorOnDeletableChannel()) { + return 'x'; // Triggers existing X key → EDIT_CONFIRM delete flow + } } return KEY_ENTER; // All other settings rows: toggle/edit as normal } diff --git a/examples/companion_radio/ui-new/Settingsscreen.h b/examples/companion_radio/ui-new/Settingsscreen.h index 4f6eb457..999346df 100644 --- a/examples/companion_radio/ui-new/Settingsscreen.h +++ b/examples/companion_radio/ui-new/Settingsscreen.h @@ -484,6 +484,35 @@ public: && _editMode == EDIT_NONE; } + // T5S3 VKB integration for text editing (channel name, device name, freq, APN) + bool isEditingText() const { return _editMode == EDIT_TEXT; } + bool isEditingNumOrPicker() const { return _editMode == EDIT_NUMBER || _editMode == EDIT_PICKER; } + const char* getEditBuf() const { return _editBuf; } + + // Get a suitable VKB label for the current text edit field + const char* getEditLabel() const { + if (_cursor < 0 || _cursor >= _numRows) return "Edit"; + switch (_rows[_cursor].type) { + case ROW_NAME: return "Device Name"; + case ROW_ADD_CHANNEL: return "Add Channel"; + case ROW_FREQ: return "Frequency"; + #ifdef HAS_4G_MODEM + case ROW_APN: return "Edit APN"; + #endif + default: return "Edit"; + } + } + + // Fill edit buffer with VKB result and confirm via Enter + void submitEditText(const char* text) { + int len = strlen(text); + if (len >= SETTINGS_TEXT_BUF) len = SETTINGS_TEXT_BUF - 1; + memcpy(_editBuf, text, len); + _editBuf[len] = '\0'; + _editPos = len; + handleKeyInput('\r'); // trigger existing confirm logic + } + // --------------------------------------------------------------------------- // WiFi scan helpers // --------------------------------------------------------------------------- diff --git a/examples/companion_radio/ui-new/UITask.cpp b/examples/companion_radio/ui-new/UITask.cpp index 75f23629..a5251b38 100644 --- a/examples/companion_radio/ui-new/UITask.cpp +++ b/examples/companion_radio/ui-new/UITask.cpp @@ -842,7 +842,11 @@ public: #endif } } +#if defined(LilyGo_T5S3_EPaper_Pro) + return _editing_utc ? 700 : 2000; // Faster refresh for touch-only (no key to force update) +#else return _editing_utc ? 700 : 5000; // match e-ink refresh cycle while editing UTC +#endif } bool handleInput(char c) override { @@ -1274,9 +1278,16 @@ void UITask::newMsg(uint8_t path_len, const char* from_name, const char* text, i #endif if (_display != NULL) { +#if defined(LilyGo_T5S3_EPaper_Pro) + // E-ink: always wake — no backlight cost, and stale image shows wrong MSG count + if (!_display->isOn()) { + _display->turnOn(); + } +#else if (!_display->isOn() && !hasConnection()) { _display->turnOn(); } +#endif if (_display->isOn()) { _auto_off = millis() + AUTO_OFF_MILLIS; // extend the auto-off timer _next_refresh = 100; // trigger refresh @@ -1828,6 +1839,14 @@ void UITask::onVKBSubmit() { if (_screenBeforeVKB) setCurrScreen(_screenBeforeVKB); break; } + case VKB_SETTINGS_TEXT: { + SettingsScreen* ss = (SettingsScreen*)settings_screen; + if (ss) { + ss->submitEditText(text); // Fills buffer + triggers Enter confirm + } + if (_screenBeforeVKB) setCurrScreen(_screenBeforeVKB); + break; + } case VKB_NOTES: { NotesScreen* notes = (NotesScreen*)getNotesScreen(); if (notes && strlen(text) > 0) { diff --git a/examples/companion_radio/ui-new/virtualkeyboard.h b/examples/companion_radio/ui-new/virtualkeyboard.h index 3087514e..262f2228 100644 --- a/examples/companion_radio/ui-new/virtualkeyboard.h +++ b/examples/companion_radio/ui-new/virtualkeyboard.h @@ -29,6 +29,7 @@ enum VKBPurpose { VKB_ADMIN_CLI, // Repeater admin CLI command VKB_NOTES, // Insert text into notes VKB_SETTINGS_NAME, // Edit node name + VKB_SETTINGS_TEXT, // Generic settings text edit (channel name, freq, APN) VKB_WIFI_PASSWORD, // WiFi password entry (settings screen) #ifdef MECK_WEB_READER VKB_WEB_URL, // Web reader URL entry