Leakage sensor
|
The metronome. More...
#include <metronome.hpp>
Public Member Functions | |
Metronome (int cycleDuration, bool skipMissedCycles=true) | |
Constructor. *. | |
auto | waitForNextCycle () -> void |
The metronome.
A helper class that let's you manage (somewhat) constant durations of your loop() function. Define a cycleDuration and call waitForNextCycle() at the end of your loop. Easy, isn't it? :)
|
inline |
Constructor. *.
cycleDuration | The duration of one cycle of the loop. |
skipMissedCycles | In case a cycle has been missed - due to stuff happening within the loop taking more time than the defined cycle duration - this bool defines whether the missed cycle should be skipped or not. In this case true will make metronome's waitForNextCycle just wait until the next regular cycle, thereby skipping at least one cycle, whereas false will make metronome's waitForNextCycle return immediately and thereby trigger the next iteration of the loop in order to make up the delay. |
skipMissedCycles
= false
in conjunction with a loop that usually takes more time than cycleDuration
will lead to a growing delay that can never be made up. void Metronome::waitForNextCycle | ( | ) | -> void |
Blocks until the next cycle starts. Might return immediately if the Metronome has been configured NOT to skip missed cycles ( skipMissedCycles
= false
). See Metronome(int, bool).