⏱️ Updates timing macro

This commit is contained in:
Rune Harlyk
2024-08-02 17:29:59 +02:00
parent e7f78c52da
commit 0854061e36
+2 -2
View File
@@ -7,9 +7,9 @@
#define EXECUTE_EVERY_N_MS(n, code) \
do { \
static volatile unsigned long UNIQUE_VAR(lastExecution_) = ULONG_MAX; \
static volatile unsigned long UNIQUE_VAR(lastExecution_) = 0; \
unsigned long currentMillis = millis(); \
if (currentMillis - UNIQUE_VAR(lastExecution_) >= n) { \
if (UNIQUE_VAR(lastExecution_) == 0 || currentMillis - UNIQUE_VAR(lastExecution_) >= n) { \
code; \
UNIQUE_VAR(lastExecution_) = currentMillis; \
} \