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