From 43d61a550c6d6924708d4f370d0fa7e7b286db5a Mon Sep 17 00:00:00 2001 From: Todd Herbert Date: Tue, 25 Mar 2025 01:26:25 +1300 Subject: [PATCH] fix: more generous timeout for display updates Previously this was tied to the expected duration of the update, but this didn't account for any delay if our polling thread got held up by an unrelated firmware task. --- src/graphics/niche/Drivers/EInk/EInk.cpp | 4 ++-- src/graphics/niche/Drivers/EInk/EInk.h | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/graphics/niche/Drivers/EInk/EInk.cpp b/src/graphics/niche/Drivers/EInk/EInk.cpp index bdb69bff8..cd2e9dc98 100644 --- a/src/graphics/niche/Drivers/EInk/EInk.cpp +++ b/src/graphics/niche/Drivers/EInk/EInk.cpp @@ -33,7 +33,6 @@ void EInk::beginPolling(uint32_t interval, uint32_t expectedDuration) updateRunning = true; pollingInterval = interval; pollingBegunAt = millis(); - pollingExpectedDuration = expectedDuration; // To minimize load, we can choose to delay polling for a few seconds, if we know roughly how long the update will take // By default, expectedDuration is 0, and we'll start polling immediately @@ -47,7 +46,8 @@ void EInk::beginPolling(uint32_t interval, uint32_t expectedDuration) int32_t EInk::runOnce() { // Check for polling timeout - if (millis() - pollingBegunAt > pollingExpectedDuration * 3) + // Manually set at 10 seconds, in case some big task holds up the firmware's cooperative multitasking + if (millis() - pollingBegunAt > 10000) failed = true; // Handle failure diff --git a/src/graphics/niche/Drivers/EInk/EInk.h b/src/graphics/niche/Drivers/EInk/EInk.h index da81f6b4f..3c51d4f1d 100644 --- a/src/graphics/niche/Drivers/EInk/EInk.h +++ b/src/graphics/niche/Drivers/EInk/EInk.h @@ -50,7 +50,6 @@ class EInk : private concurrency::OSThread bool updateRunning = false; // see EInk::busy() uint32_t pollingInterval = 0; // How often to check if update complete (ms) uint32_t pollingBegunAt = 0; // To timeout during polling - uint32_t pollingExpectedDuration = 0; // To timeout during polling }; } // namespace NicheGraphics::Drivers