A very small amount of work on Manager class
This commit is contained in:
56
include/Manager.h
Normal file
56
include/Manager.h
Normal file
@@ -0,0 +1,56 @@
|
||||
#ifndef MANAGER_H
|
||||
#define MANAGER_H
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <LinkedList.h>
|
||||
#include <LEDHAL.h>
|
||||
#include <AnimationBase.h>
|
||||
|
||||
class Manager {
|
||||
public:
|
||||
Manager() {}
|
||||
virtual ~Manager() {} // TODO Cleanup linked lists?
|
||||
|
||||
void addLEDs(LEDHAL* hal) {
|
||||
// TODO Duplicate name checks
|
||||
|
||||
ledHALs.add(hal);
|
||||
}
|
||||
|
||||
LEDHAL* removeLEDsByName(char* name) {
|
||||
for(uint16_t i = 0; i < ledHALs.size(); i++) {
|
||||
if(strcmp(ledHALs.get(i)->getLEDName(), name) == 0) {
|
||||
return ledHALs.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void addAnimation(AnimationBase* animation) {
|
||||
// TODO Duplicate name checks
|
||||
|
||||
animations.add(animation);
|
||||
}
|
||||
|
||||
AnimationBase* removeAnimationByName(char* name) {
|
||||
for(uint16_t i = 0; i < animations.size(); i++) {
|
||||
return animations.remove(i);
|
||||
}
|
||||
}
|
||||
|
||||
void update() {
|
||||
for(uint16_t i = 0; i < animations.size(); i++) {
|
||||
animations.get(i)->update();
|
||||
}
|
||||
|
||||
for(uint16_t i = 0; i < ledHALs.size(); i++) {
|
||||
ledHALs.get(i)->show();
|
||||
}
|
||||
}
|
||||
private:
|
||||
LinkedList<LEDHAL*>
|
||||
ledHALs;
|
||||
LinkedList<AnimationBase*>
|
||||
animations;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user