A key sent through the Debug Console could turn the screen "off" for a tick

The `key` command stamps the power timer from millis(); the power tick
then compared with its pass's older time, and the unsigned difference read
as 49 days without a key. The screen state went Off for one tick, and the
next key was swallowed as a wake-up: about one remote key in twenty-five.
Keys from the keyboard pass the loop's own time and were never affected.
The same shape as #46. PowerPolicy::update now treats a stamp from the
future as "just now", with a test.

rdbg.py: piped lines written while it was still connecting stayed in
Python's read buffer until the next line arrived (readline() behind
select()). It reads the descriptor directly now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
This commit is contained in:
2026-10-06 10:08:10 +02:00
co-authored by Claude Opus 5.5
parent 4ab873e9f8
commit c868977f1c
3 changed files with 22 additions and 4 deletions
+10
View File
@@ -31,6 +31,15 @@ void test_key_on_off_screen_only_wakes() {
TEST_ASSERT_EQUAL(static_cast<int>(ScreenState::On), static_cast<int>(p.update(70001)));
}
// A key stamped a few milliseconds after the time the same pass updates with must not read as
// 49 days of idleness: the screen stays on, and the next key acts.
void test_activity_stamped_after_the_pass_time_keeps_the_screen_on() {
PowerPolicy p(30000, 60000);
TEST_ASSERT_FALSE(p.activity(10003));
TEST_ASSERT_TRUE(p.update(10000) == ScreenState::On);
TEST_ASSERT_FALSE(p.activity(10050));
}
void test_new_timeouts_apply_immediately() {
PowerPolicy p(30000, 60000);
p.activity(0);
@@ -91,6 +100,7 @@ int main() {
RUN_TEST(test_screen_dims_then_turns_off_after_inactivity);
RUN_TEST(test_key_on_dimmed_screen_wakes_and_still_acts);
RUN_TEST(test_key_on_off_screen_only_wakes);
RUN_TEST(test_activity_stamped_after_the_pass_time_keeps_the_screen_on);
RUN_TEST(test_new_timeouts_apply_immediately);
RUN_TEST(test_notification_lights_an_off_screen_dimmed_until_it_ends);
RUN_TEST(test_notification_does_not_count_as_activity);