Timeline for Can I automatically loop inside a library?
Current License: CC BY-SA 3.0
4 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Sep 12, 2015 at 3:09 | comment | added | Nick Gammon♦ | As another person answered, if it is highly time-sensitive you could use an interrupt (if this is a switch you are checking), or a timer firing periodically (if you need to test something like an analog reading). | |
| Sep 12, 2015 at 3:04 | comment | added | MaxBoehme | Now it is like: void loop() { freqdetec.checkFreq(); if (freqdetec.freqChanged()) { // do stuff } } The benefit from separating it into two calls is first, that it is more obvious what the single calls are doing, and second, I can place the checkFreq() in the beginning of the loop(), to avoid having it cluttered somewhere. | |
| Sep 12, 2015 at 2:59 | comment | added | MaxBoehme | Yes, your are right! That's also the way I decided to go. Though, I tried to achieved this to have a more convenient implementation of the library: This if(ready==true) could theoretically be somewhere in loop(). But my periodically checking is VERY time-sensitive. If I call the function to check in the if(), I have to be sure, that there is no delay which alters the result. | |
| Sep 12, 2015 at 2:47 | history | answered | Nick Gammon♦ | CC BY-SA 3.0 |