Last active
November 14, 2020 17:30
-
-
Save bathoryr/5530205af8d7179b59a964c5f4adc523 to your computer and use it in GitHub Desktop.
Macro to simplify periodic function call by regular interval in Arduino loop()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define CALL_LOOP(TIME, FUNC) {static unsigned long cnt_##FUNC_##TIME_counter;\ | |
if (millis() - cnt_##FUNC_##TIME_counter > (TIME)) {\ | |
cnt_##FUNC_##TIME_counter = millis();\ | |
FUNC();}\ | |
} | |
void TestFunc() | |
{ | |
} | |
void loop() | |
{ | |
CALL_LOOP(5000, TestFunc); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment