From 63985162972dc9e760a435a9f2a919e234bb65ba Mon Sep 17 00:00:00 2001 From: cyberman54 Date: Sun, 14 Aug 2022 15:49:32 +0200 Subject: [PATCH] sanitize display code --- src/display.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/display.cpp b/src/display.cpp index 06f87ea7..0b902355 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -151,6 +151,7 @@ void dp_refresh(bool nextPage) { #ifndef HAS_BUTTON static uint32_t framecounter = 0; + const uint32_t flip_threshold = DISPLAYCYCLE * 1000 / DISPLAYREFRESH_MS; #endif // if display is switched off we don't refresh it to relax cpu @@ -165,7 +166,7 @@ void dp_refresh(bool nextPage) { #ifndef HAS_BUTTON // auto flip page if we are in unattended mode - if ((++framecounter) > (DISPLAYCYCLE * 1000 / DISPLAYREFRESH_MS)) { + if (++framecounter > flip_threshold) { framecounter = 0; nextPage = true; }