diff --git a/simpleclock.ino b/simpleclock.ino index 4547d75..ecd31c6 100644 --- a/simpleclock.ino +++ b/simpleclock.ino @@ -148,8 +148,6 @@ ISR(TIMER1_OVF_vect) void loop() { unsigned long currentMillis = millis(); - char str[4]; - float d; /* * Let's implement time compenstion for individual rtc module time @@ -172,6 +170,7 @@ void loop() mysecond = clock.second; myminute = clock.minute; myhour = clock.hour; + updateTimeStr(myhour, myminute); rtcsync = false; } @@ -210,6 +209,8 @@ void loop() clock.setTime(); } } + + updateTimeStr(myhour, myminute); } if ((currentMillis - previousLightTimer >= refresh_interval) or @@ -257,28 +258,34 @@ void loop() } else if (ambLight < 100) { Display.setBrightness(-15); } - - // make blinking dot - if (myhour > 0) { - if (dot) { - Display.setNumber((myhour * 100 + myminute), 2); - } else { - Display.setNumber((myhour * 100 + myminute)); - } - } else { - /* 0 o'clock is an exception, we don't want to see "00.00", we - want see "0.00" or "0 00", so we have to use this "hack" */ - if (dot) { - d = float(myminute) / 100; - Display.setNumber(d, 2); - } else { - sprintf(str, "%2d%02d", myhour, myminute); - Display.setChars(str); - } - } } Display.refreshDisplay(); } +void updateTimeStr(uint8_t h, uint8_t m) +{ + char str[4]; + float d; + + // make blinking dot + if (h > 0) { + if (dot) { + Display.setNumber((h * 100 + m), 2); + } else { + Display.setNumber((h * 100 + m)); + } + } else { + /* 0 o'clock is an exception, we don't want to see "00.00", we + want see "0.00" or "0 00", so we have to use this "hack" */ + if (dot) { + d = float(m) / 100; + Display.setNumber(d, 2); + } else { + sprintf(str, "%2d%02d", h, m); + Display.setChars(str); + } + } + +} /* vim: set filetype=cpp: */