-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStep.cpp
More file actions
44 lines (35 loc) · 888 Bytes
/
Step.cpp
File metadata and controls
44 lines (35 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "Step.h"
#include "LED_Controller.h"
#include <Arduino.h>
#include "DEBUG.h"
namespace LEDAnimation {
Step::Step(unsigned long waitTime) : waitTime(waitTime), nextInsert(0), next(nullptr) {
memset(actions, NULL, sizeof(Action) * MAX_LEDS);
}
Step::~Step() {}
Step& Step::operator<<(Action action) {
if (nextInsert < (MAX_LEDS)) {
actions[nextInsert++] = action;
}
return *this;
}
void Step::doActions() {
for (uint8_t i = 0; i < nextInsert; i++) {
LED_Controller* controller = LED_Controller::getInstance();
if (controller != nullptr) {
controller->set(actions[i].pos, actions[i].state);
} else {
DEBUG_PRINT("FATAL: Cannot run step: No controller!\n")
}
}
}
Step* Step::getNext() {
return next;
}
void Step::setNext(Step* const next) {
this->next = next;
}
unsigned long Step::getWait() {
return waitTime;
}
}