Simplify setup and control of LEDs
This commit is contained in:
parent
e03aae9d4d
commit
9a25b41aaf
5 changed files with 58 additions and 43 deletions
|
@ -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(){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue