Move to new folder in preparation for more controllers
This commit is contained in:
parent
bcea2ee550
commit
ae3c20b59d
18 changed files with 59 additions and 4 deletions
|
@ -1,48 +0,0 @@
|
|||
#ifndef LedManager_cpp
|
||||
#define LedManager_cpp
|
||||
|
||||
#include "LED.cpp"
|
||||
#include "TimerManager.cpp"
|
||||
#include <map>
|
||||
#include <functional>
|
||||
|
||||
class LedManager {
|
||||
TimerManager *_timers;
|
||||
std::map<int, LED *> _leds;
|
||||
|
||||
public:
|
||||
LedManager(TimerManager *timers) {
|
||||
_timers = timers;
|
||||
}
|
||||
|
||||
void registerLEDs(int id, LED *leds) {
|
||||
_leds[id] = leds;
|
||||
_timers->add(id, [&]() { leds->off(); });
|
||||
}
|
||||
|
||||
void loop() {
|
||||
for (auto iterator = _leds.begin(); iterator != _leds.end(); ++iterator) {
|
||||
auto leds = iterator->second;
|
||||
leds->loop();
|
||||
}
|
||||
}
|
||||
|
||||
void setLedProperties(int id, bool on, float brightness, unsigned long timer) {
|
||||
if (!_leds.count(id))
|
||||
return;
|
||||
|
||||
auto led = _leds.find(id)->second;
|
||||
|
||||
led->setBrightness(brightness);
|
||||
|
||||
if (on)
|
||||
led->on();
|
||||
else
|
||||
led->off();
|
||||
|
||||
if (timer > 0)
|
||||
_timers->reset(id, timer);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue