Skip to content

Commit

Permalink
Move RTC reading to utility function
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielosorio committed May 29, 2023
1 parent bb9cc1e commit d14d954
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions wakie.ino
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,7 @@ void setup() {
}

void loop() {
tmElements_t tm;

if (RTC.read(tm)) {
currentHour = tm.Hour;
currentMinute = tm.Minute;
currentWeekday = tm.Wday;
currentDay = tm.Day;
currentMonth = tm.Month;
currentYear = tm.Year;
} else {
Serial.print("[DS1307] Read error!");
}
readRtc();

if (currentMinute != lastMinute) {
lastMinute = currentMinute;
Expand Down Expand Up @@ -118,6 +107,21 @@ void buttonInterrupt() {
}
}

void readRtc() {
tmElements_t tm;

if (RTC.read(tm)) {
currentHour = tm.Hour;
currentMinute = tm.Minute;
currentWeekday = tm.Wday;
currentDay = tm.Day;
currentMonth = tm.Month;
currentYear = tm.Year;
} else {
Serial.print("[DS1307] Read error!");
}
}

void renderDisplay() {
char formatOutput[2]; // Buffer to process number formatting

Expand Down

0 comments on commit d14d954

Please sign in to comment.