A very small amount of work on Manager class
This commit is contained in:
@@ -21,7 +21,6 @@ class LEDHAL {
|
|||||||
|
|
||||||
virtual void requestShow() { showRequested = true; }
|
virtual void requestShow() { showRequested = true; }
|
||||||
|
|
||||||
//TODO UnifiedColor should have constants
|
|
||||||
virtual void clearLEDs() {
|
virtual void clearLEDs() {
|
||||||
for(uint16_t i = 0; i < getNumLEDs(); i++) {
|
for(uint16_t i = 0; i < getNumLEDs(); i++) {
|
||||||
setColor(i, CRGB(0, 0, 0));
|
setColor(i, CRGB(0, 0, 0));
|
||||||
|
|||||||
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
|
||||||
18
include/TerribleMap.h
Normal file
18
include/TerribleMap.h
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#ifndef TERRIBLEMAP_H
|
||||||
|
#define TERRIBLEMAP_H
|
||||||
|
|
||||||
|
#include <LinkedList.h>
|
||||||
|
|
||||||
|
template <typename K, typename V>
|
||||||
|
struct Entry {
|
||||||
|
K key;
|
||||||
|
V value;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename K, typename V>
|
||||||
|
class TerribleMap {
|
||||||
|
private:
|
||||||
|
LinkedList<Entry<K,V>> mapList;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -21,6 +21,7 @@ lib_deps =
|
|||||||
adafruit/Adafruit GFX Library@^1.11.9
|
adafruit/Adafruit GFX Library@^1.11.9
|
||||||
arduino-libraries/SD@^1.3.0
|
arduino-libraries/SD@^1.3.0
|
||||||
apechinsky/MemoryFree@^0.3.0
|
apechinsky/MemoryFree@^0.3.0
|
||||||
|
ivanseidel/LinkedList@0.0.0-alpha+sha.dac3874d28
|
||||||
|
|
||||||
[env:mega]
|
[env:mega]
|
||||||
platform = atmelavr
|
platform = atmelavr
|
||||||
@@ -32,6 +33,7 @@ lib_deps =
|
|||||||
adafruit/Adafruit GFX Library@^1.11.9
|
adafruit/Adafruit GFX Library@^1.11.9
|
||||||
arduino-libraries/SD@^1.3.0
|
arduino-libraries/SD@^1.3.0
|
||||||
apechinsky/MemoryFree@^0.3.0
|
apechinsky/MemoryFree@^0.3.0
|
||||||
|
ivanseidel/LinkedList@0.0.0-alpha+sha.dac3874d28
|
||||||
|
|
||||||
[common]
|
[common]
|
||||||
|
|
||||||
@@ -45,3 +47,4 @@ lib_deps =
|
|||||||
pfeerick/elapsedMillis@^1.0.6
|
pfeerick/elapsedMillis@^1.0.6
|
||||||
adafruit/Adafruit GFX Library@^1.11.9
|
adafruit/Adafruit GFX Library@^1.11.9
|
||||||
apechinsky/MemoryFree@^0.3.0
|
apechinsky/MemoryFree@^0.3.0
|
||||||
|
ivanseidel/LinkedList@0.0.0-alpha+sha.dac3874d28
|
||||||
|
|||||||
Reference in New Issue
Block a user