From 825c3096f2ebf839593877529e6d48247d350e6d Mon Sep 17 00:00:00 2001 From: eleksir Date: Sat, 20 Apr 2019 12:04:05 +0300 Subject: [PATCH] Implement software time inaccuracy compensation hack 32768 Hz quartz chrystal resonator tends to be a bit inaccurate giving about 5-10 seconds per day time skew --- simpleclock.ino | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/simpleclock.ino b/simpleclock.ino index 49a12f8..f3ee3c9 100644 --- a/simpleclock.ino +++ b/simpleclock.ino @@ -48,6 +48,8 @@ const int min_btn = A1; bool dot = true; uint8_t minutes; uint8_t hours; +/* time inaccuracy compensation flag */ +uint8_t compflag = 0; void setup() { @@ -125,6 +127,23 @@ void loop() } clock.getTime(); + /* + * Let's implement time compenstion for individual rtc module time + * charachteristics. In in my case quartz resonator as inaccurate as + * +/- about 5-8 seconds per 24 hours, maybe its require more EMI + * sheilding? + */ + + if ((clock.hour == 21) and (clock.minute == 21) and (clock.second == 21) and (compflag == 0)) { + clock.second = 14; + clock.fillByHMS(clock.hour,clock.minute,clock.second); + clock.setTime(); + compflag = 1; + } + + if ((clock.hour == 21) and (clock.minute == 21) and (clock.second == 23) and (compflag == 1)) { + compflag = 0; + } // make blinking dot if (clock.hour > 0)