-
Notifications
You must be signed in to change notification settings - Fork 0
/
status-light.cpp
48 lines (33 loc) · 1.24 KB
/
status-light.cpp
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
45
46
47
48
#include "spdlog/spdlog.h"
#include "server/gpio/gpio.h"
#include "server/eventloop/events/types.h"
#include "server/eventloop/event.h"
#include "server/metrics/StatusLights.h"
#include "server/namespace-stuffs.h"
namespace creatures {
extern std::shared_ptr<GPIO> gpioPins;
extern std::shared_ptr<StatusLights> statusLights;
/**
* Turns one of the status lights on or off via an event
*
* @param frameNumber frame number to schedule this event for
* @param light An enum from StatusLight
* @param on Should the light be on?
*/
StatusLightEvent::StatusLightEvent(framenum_t frameNumber, StatusLight light, bool on)
: EventBase(frameNumber), light(light), on(on) {}
void StatusLightEvent::executeImpl() {
std::string lightName;
switch(light) {
case StatusLight::Animation:
gpioPins->playingAnimation(on);
statusLights->animationLightOn = on;
lightName = "Animation";
break;
default:
warn("Unhandled light in StatusLightEvent: {}", static_cast<int>(light));
return;
}
debug("Turning status light {} {}", lightName, on ? "on" : "off");
}
}