Move components to lib folder

This commit is contained in:
Robert Marshall 2022-09-08 13:20:51 +01:00
parent ae3c20b59d
commit b9b68f08cb
8 changed files with 1 additions and 0 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