A class to call a function at the main function at regular intervals (using Ticker class)
Dependents: GPS_0002 optWingforHAPS_Eigen hexaTest_Eigen
LoopTicker.cpp
- Committer:
- cocorlow
- Date:
- 2021-01-21
- Revision:
- 0:d9fd30e1ebe4
File content as of revision 0:d9fd30e1ebe4:
#include "mbed.h" #include "LoopTicker.hpp" LoopTicker::LoopTicker() { fptr = NULL; time = 0.0f; updated = false; } void LoopTicker::attach(void (*fptr_)(), float time_) { fptr = fptr_; time = time_; ticker_.attach(this, &LoopTicker::interrupt, time); } void LoopTicker::detach() { fptr = NULL; time = 0.0f; updated = false; ticker_.detach(); } void LoopTicker::loop() { if (updated) { fptr(); updated = false; } } void LoopTicker::interrupt() { updated = true; }