From 67cb93e643718066ec9074e411def110f8912d4b Mon Sep 17 00:00:00 2001 From: pelgraine <140762863+pelgraine@users.noreply.github.com> Date: Tue, 17 Feb 2026 19:52:44 +1100 Subject: [PATCH] update uittasks to enable keyboard pulse light notification --- examples/companion_radio/ui-new/UITask.cpp | 22 ++++++++++++++++++++++ examples/companion_radio/ui-new/UITask.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/examples/companion_radio/ui-new/UITask.cpp b/examples/companion_radio/ui-new/UITask.cpp index 8539a7f1..44809123 100644 --- a/examples/companion_radio/ui-new/UITask.cpp +++ b/examples/companion_radio/ui-new/UITask.cpp @@ -825,6 +825,12 @@ void UITask::begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* no vibration.begin(); #endif + // Keyboard backlight for message flash notifications +#ifdef KB_BL_PIN + pinMode(KB_BL_PIN, OUTPUT); + digitalWrite(KB_BL_PIN, LOW); +#endif + ui_started_at = millis(); _alert_expiry = 0; @@ -925,6 +931,14 @@ void UITask::newMsg(uint8_t path_len, const char* from_name, const char* text, i _next_refresh = 100; // trigger refresh } } + + // Keyboard flash notification +#ifdef KB_BL_PIN + if (_node_prefs->kb_flash_notify) { + digitalWrite(KB_BL_PIN, HIGH); + _kb_flash_off_at = millis() + 200; // 200ms flash + } +#endif } void UITask::userLedHandler() { @@ -1060,6 +1074,14 @@ void UITask::loop() { userLedHandler(); + // Turn off keyboard flash after timeout +#ifdef KB_BL_PIN + if (_kb_flash_off_at && millis() >= _kb_flash_off_at) { + digitalWrite(KB_BL_PIN, LOW); + _kb_flash_off_at = 0; + } +#endif + #ifdef PIN_BUZZER if (buzzer.isPlaying()) buzzer.loop(); #endif diff --git a/examples/companion_radio/ui-new/UITask.h b/examples/companion_radio/ui-new/UITask.h index d12b140b..372d06aa 100644 --- a/examples/companion_radio/ui-new/UITask.h +++ b/examples/companion_radio/ui-new/UITask.h @@ -32,6 +32,7 @@ class UITask : public AbstractUITask { GenericVibration vibration; #endif unsigned long _next_refresh, _auto_off; + unsigned long _kb_flash_off_at; // Keyboard flash turn-off timer NodePrefs* _node_prefs; char _alert[80]; unsigned long _alert_expiry; @@ -74,6 +75,7 @@ public: UITask(mesh::MainBoard* board, BaseSerialInterface* serial) : AbstractUITask(board, serial), _display(NULL), _sensors(NULL) { next_batt_chck = _next_refresh = 0; + _kb_flash_off_at = 0; ui_started_at = 0; curr = NULL; }