Move to new folder in preparation for more controllers

This commit is contained in:
Robert Marshall 2022-09-08 13:11:16 +01:00
parent bcea2ee550
commit ae3c20b59d
18 changed files with 59 additions and 4 deletions

View file

@ -1,38 +0,0 @@
#ifndef Timer_cpp
#define Timer_cpp
#include <Arduino.h>
#include <functional>
class Timer{
private:
unsigned long _interval, _lastTick;
std::function<void()> _callback;
bool _running;
public:
Timer(std::function<void()> callback){
_callback = callback;
_running = false;
}
void reset(unsigned long interval){
_interval = interval;
_lastTick = millis();
_running = true;
}
void loop(){
if (!_running)
return;
unsigned long tick = millis();
if (tick - _lastTick >= _interval){
_callback();
_running = false;
}
}
};
#endif