-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRingClock.cpp
More file actions
46 lines (38 loc) · 958 Bytes
/
Copy pathRingClock.cpp
File metadata and controls
46 lines (38 loc) · 958 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
45
46
#include "RingClock.h"
#include "patterns/SplashPattern.h"
RingClock::RingClock(
unsigned long leds[][3],
unsigned int ledCount,
unsigned int displayedHours
) :
leds{leds},
ledCount{ledCount},
displayedHours{displayedHours},
ledsPerHour{ledCount/displayedHours}
{}
RingClock::~RingClock() {
delete currentPattern;
}
void RingClock::init() {
currentPattern = new SplashPattern(this);
currentPattern->init();
}
void RingClock::setPattern(ClockPattern * pattern) {
if ( currentPattern ) {
delete currentPattern;
}
currentPattern = pattern;
currentPattern->init();
}
void RingClock::tick(const clock_time_t time) {
now = time;
// Copy now to last for the first run
if ( firstRun ) {
last = now;
firstRun = false;
}
// Update the current clock pattern
currentPattern->tick();
// Save last time to detect changes in the pattern classes
last = now;
}