sqfmi / Watchy

Watchy - An Open Source E-Ink Smartwatch
http://www.sqfmi.com
MIT License
1.83k stars 319 forks source link

Time Set #237

Open MartMarq opened 12 months ago

MartMarq commented 12 months ago

Hello! I am new and don't know much about C++ Watchy is running too fast, about 14 seconds a day. Is there a way to reset once a day actual time to actual time minus 14 seconds?

MartMarq commented 11 months ago

OK, found myself the answer.

I've added this code into Watchy_7_SEG.cpp

` if (currentTime.Hour == 00 && currentTime.Minute == 30){

    RTC.read(currentTime);
    int8_t sekunde = currentTime.Second;
    int8_t minute = currentTime.Minute;
    int8_t hour = currentTime.Hour;
    int8_t day = currentTime.Day;
    int8_t month = currentTime.Month;
    int8_t year = tmYearToY2k(currentTime.Year);

    delay(15000);

    tmElements_t tm;
    tm.Month = month;
    tm.Day = day;
    tm.Year = y2kYearToTm(year);
    tm.Hour = hour;
    tm.Minute = minute ;
    tm.Second = sekunde;

    RTC.set(tm);

     }`

Once a day (at 00:30) it reads the system time, waits for 15 seconds (delay (15000)) and writes the system time (from 15 seconds ago) to RTC. If your Watchy runs eg 20 seconds to fast within 24 hours, just replace the 15000 in delay by 20000 and so on. If it runs too slow you don't need the delay, just add some seconds (eg 5) in the line tm.Second = sekunde + 5;

With this I don't need WIFI any longer to synchronise the system time, because now it runs (nearly) perfect.