Fix statLoopCounter overflow

This commit is contained in:
fvanroie 2021-10-19 16:50:53 +02:00
parent 2e7a772668
commit 35975131b3
2 changed files with 10 additions and 2 deletions

View File

@ -29,7 +29,7 @@ uint8_t mainLoopCounter = 0;
unsigned long mainLastLoopTime = 0; unsigned long mainLastLoopTime = 0;
#ifdef HASP_USE_STAT_COUNTER #ifdef HASP_USE_STAT_COUNTER
uint8_t statLoopCounter = 0; // measures the average looptime uint16_t statLoopCounter = 0; // measures the average looptime
#endif #endif
void setup() void setup()

View File

@ -46,6 +46,10 @@ bool isRunning = 1;
uint8_t mainLoopCounter = 0; uint8_t mainLoopCounter = 0;
unsigned long mainLastLoopTime = 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_width;
extern uint16_t tft_height; extern uint16_t tft_height;
@ -168,6 +172,10 @@ void loop()
custom_loop(); custom_loop();
#endif #endif
#ifdef HASP_USE_STAT_COUNTER
statLoopCounter++; // measures the average looptime
#endif
/* Timer Loop */ /* Timer Loop */
if(millis() - mainLastLoopTime >= 1000) { if(millis() - mainLastLoopTime >= 1000) {
/* Runs Every Second */ /* Runs Every Second */
@ -179,7 +187,7 @@ void loop()
#endif #endif
#if defined(HASP_USE_CUSTOM) #if defined(HASP_USE_CUSTOM)
custom_every_second(); custom_every_second();
#endif #endif
/* Runs Every 5 Seconds */ /* Runs Every 5 Seconds */