-
Notifications
You must be signed in to change notification settings - Fork 0
/
rtc.ino
28 lines (22 loc) · 825 Bytes
/
rtc.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
void initRtc(){
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
while (1);
}
if (! rtc.isrunning()) {
Serial.println("RTC is NOT running!");
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
}
}
void checkClockButtons(){
if(digitalRead(SET_CLOCK_HOUR_PIN) == HIGH && lastKeyPressedTime+keyDelay<millis()){
rtc.adjust(DateTime(now.year(), now.month(), now.day(), now.hour()<23?now.hour()+1:0, now.minute(), now.second()));
now = rtc.now();
lastKeyPressedTime = millis();
}
if(digitalRead(SET_CLOCK_MINUTE_PIN) == HIGH && lastKeyPressedTime+keyDelay<millis()){
rtc.adjust(DateTime(now.year(), now.month(), now.day(), now.hour(), now.minute()<59?now.minute()+1:0, now.second()));
now = rtc.now();
lastKeyPressedTime = millis();
}
}