From 1eb088a0db2e3f5e3627e95a38efd24ef5f2bff8 Mon Sep 17 00:00:00 2001 From: Jakub <106778416+MarekZegare4@users.noreply.github.com> Date: Thu, 3 Sep 2026 22:59:05 +0200 Subject: [PATCH] fix(sim): add sim_test_disable_screen_timeout() -- no auto-off in the demo NodePrefs::auto_off_secs defaults to 15 -- real power-saving behaviour a battery-powered board needs (screen off, optionally locked, 15s after the last input). UITask::autoOffMillis() treats 0 as "never" and skips that whole branch in UITask::loop() entirely, so there's no separate flag to touch. A demo running on a visitor's screen has no battery to save and no reason to go dark while they're reading it. sim_test_disable_screen_timeout() is a new sim-only hook, same shape as the other sim_test_* boot-time hooks: meshcore-solo-site calls it once after boot. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_018iubftDmKNWmkNnhJRz8UH --- examples/companion_radio/main.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index 9f3f9924..ffd1a4b8 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -466,6 +466,22 @@ extern "C" EMSCRIPTEN_KEEPALIVE int sim_test_set_timezone_hours(int hours) { return 1; } +// auto_off_secs (NodePrefs.h) defaults to 15 -- a real device's screen +// (and, if auto_lock is also set, the UI itself) turns off/locks 15s +// after the last input, real power-saving behaviour a battery-powered +// board actually needs. UITask::autoOffMillis() (ui-new/UITask.h) treats +// 0 as "never" and skips the whole turnOff()/auto_lock branch in +// UITask::loop() entirely -- there's no separate flag to touch. A demo +// running on a visitor's screen has no battery to save and no reason to +// go dark or lock itself while they're reading it. +extern "C" EMSCRIPTEN_KEEPALIVE int sim_test_disable_screen_timeout() { + if (!g_sim_ready) return 0; + NodePrefs* prefs = the_mesh.getNodePrefs(); + if (!prefs) return 0; + prefs->auto_off_secs = 0; + return 1; +} + #ifdef DISPLAY_CLASS // Jumps the on-device UI straight to the DM thread with the first known // ADV_TYPE_CHAT contact (UITask::openContactDM() -- the exact same real