Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time Set #237

Open
MartMarq opened this issue Jul 11, 2023 · 1 comment
Open

Time Set #237

MartMarq opened this issue Jul 11, 2023 · 1 comment

Comments

@MartMarq
Copy link

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant