From 35975131b3eda9376b1f0b823429ee55e48e9ca9 Mon Sep 17 00:00:00 2001 From: fvanroie <15969459+fvanroie@users.noreply.github.com> Date: Tue, 19 Oct 2021 16:50:53 +0200 Subject: [PATCH] Fix statLoopCounter overflow --- src/main_arduino.cpp | 2 +- src/main_sdl2.cpp | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main_arduino.cpp b/src/main_arduino.cpp index 441d66d5..b6dfdc63 100644 --- a/src/main_arduino.cpp +++ b/src/main_arduino.cpp @@ -29,7 +29,7 @@ uint8_t mainLoopCounter = 0; unsigned long mainLastLoopTime = 0; #ifdef HASP_USE_STAT_COUNTER -uint8_t statLoopCounter = 0; // measures the average looptime +uint16_t statLoopCounter = 0; // measures the average looptime #endif void setup() diff --git a/src/main_sdl2.cpp b/src/main_sdl2.cpp index 1d3456ae..6a7e5501 100644 --- a/src/main_sdl2.cpp +++ b/src/main_sdl2.cpp @@ -46,6 +46,10 @@ bool isRunning = 1; uint8_t mainLoopCounter = 0; unsigned long mainLastLoopTime = 0; +#ifdef HASP_USE_STAT_COUNTER +uint16_t statLoopCounter = 0; // measures the average looptime +#endif + extern uint16_t tft_width; extern uint16_t tft_height; @@ -168,6 +172,10 @@ void loop() custom_loop(); #endif +#ifdef HASP_USE_STAT_COUNTER + statLoopCounter++; // measures the average looptime +#endif + /* Timer Loop */ if(millis() - mainLastLoopTime >= 1000) { /* Runs Every Second */ @@ -179,7 +187,7 @@ void loop() #endif #if defined(HASP_USE_CUSTOM) - custom_every_second(); + custom_every_second(); #endif /* Runs Every 5 Seconds */