-
Notifications
You must be signed in to change notification settings - Fork 6
/
timer.cpp
32 lines (26 loc) · 825 Bytes
/
timer.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
/* Yeelight Smart Switch App for ESP8266
* * Timers support
* (c) DNS 2021
*/
#include "MySystem.h" // System-level definitions
#include "BulbManager.h" // Bulb manager
using namespace ds;
// Timer handler
void myTimerHandler(const TimerAbsolute* timer) {
String reason("Timer \"");
reason += timer->getAction();
reason += "\" fired";
if (timer->getAction() == "light on") {
bulb_manager.processEvent(BulbManager::EVENT_ON, reason);
}
else
if (timer->getAction() == "light off") {
bulb_manager.processEvent(BulbManager::EVENT_OFF, reason);
}
else
if (timer->getAction() == "light toggle") {
bulb_manager.processEvent(BulbManager::EVENT_FLIP, reason);
}
}
// Install handler
void (*System::timerHandler)(const TimerAbsolute*) = myTimerHandler;