Simplify setup and control of LEDs

This commit is contained in:
Robert Marshall 2022-08-18 21:46:04 +01:00
parent e03aae9d4d
commit 9a25b41aaf
5 changed files with 58 additions and 43 deletions

View file

@ -1,19 +1,20 @@
#include <map>
#include <functional>
#include "Timer.cpp"
class TimerManager{
std::map<std::string, Timer*> _timers;
std::map<int, Timer*> _timers;
public:
void add(std::string name, void (*callback)(void)){
_timers[name] = new Timer(callback);
void add(int id, std::function<void()> callback){
_timers[id] = new Timer(callback);
}
void reset(std::string name, unsigned long interval){
if (!_timers.count(name))
void reset(int id, unsigned long interval){
if (!_timers.count(id))
return;
_timers.find(name)->second->reset(interval);
_timers.find(id)->second->reset(interval);
}
void loop(){