-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBinaryClock.ino
44 lines (36 loc) · 1007 Bytes
/
BinaryClock.ino
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
#define DEBUG false
#define REDUCED_BRIGHTNESS true
#define SLEEP_HOUR 22
#define WAKEUP_HOUR 10
#include "ByteFormatter.cpp"
#include "RTC.cpp"
#include "ShiftRegisterOutput.cpp"
ShiftRegisterOutput shiftRegisterOutput;
ByteFormatter byteFormatter;
RTC rtc;
void setup() {
rtc.initRTC();
}
void loop() {
updateTime();
}
void updateTime() {
uint8_t hour = rtc.getHours();
uint8_t minute = rtc.getMinutes();
uint8_t second = rtc.getSeconds();
uint8_t hourByte = byteFormatter.getTimeByte(hour);
uint8_t minuteByte = byteFormatter.getTimeByte(minute);
uint8_t secondByte = byteFormatter.getTimeByte(second);
if (hour > WAKEUP_HOUR && hour < SLEEP_HOUR) {
shiftRegisterOutput.updateShiftOutput(hourByte, minuteByte, secondByte);
if (REDUCED_BRIGHTNESS) {
shiftRegisterOutput.turnOff();
delayMicroseconds(1);
}
} else {
shiftRegisterOutput.turnOff();
}
#if DEBUG
printDebugInformation(hourByte, minuteByte, secondByte, hour, minute, second);
#endif
}