-
Notifications
You must be signed in to change notification settings - Fork 412
DS3231 RTC driver embedded in "local clock" (PR#1729) #1792
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
base: main
Are you sure you want to change the base?
Conversation
use original obk_config.h - only renaming functions - to see filesizes
…pp into Split_NTP_new
…GetArgInteger(0) for epoch Change user_main.c to use xticks as uptime for g_secondsElapsed
…pp into Split_NTP_new
…y with g_secondsElapesd++ here ...
remove additional defines for W800 used for testing
Seems much better, 30 seconds difference in one day (used to be over 10 minutes off in 12 hours)
|
same on ALT_N. Let me try BK7238, which you've already listed as working |
You are absolutely right, shame on me - will fix the "usage" (year is only "uint8_t, so any value > 255 will result in strange behaviour, as you already found out ...) I must admit, I didn't test all commands again, so reading the already set RTC made me mark it "working". |
|
No shame. All good. :) |
Switch to internal time functions to reduce flash usage (avoid gmtime and mktime)
|
Updated source - now (to test) driver is again enabled for all platforms. Also changed DS3231 code to use internal time implementation (obktime) so size should be lower now (not needing time.h). |
|
checking: what should be considered a successful test? driver starts, time and date sets OK, unplug all so battery keeps time, re-power OBK and check time is as expected? Leave for x period on battery alone then check correct time/date? 1 day, 1 hour, 5 mins etc etc |
|
I think it would be sufficient to test features in general. So the main test would be: are all images working at all - did I break anything basic. An then we need to test, if all clock related functions do still work: Is NTP working? For this I have a LN882H plug running with this version for some time now (though no RTC inside) with additionally enabled features ENABLE_CLOCK_DST, ENABLE_CLOCK_SUNRISE_SUNSET and ENABLE_CALENDAR_EVENTS. Sure, latest changes are not tested for a longer period, but it did work fine with prevoius version for a month or so. All features I use are working: Clock is set by NTP and can be changed with "clock_settime" (until next NTP event will change it back) Can you or @openshwprojects think of some other useful tests? |
|
That would be great to test, but is it worth all the work for all platforms - you might be the first to try it anyway, for most of theese features are not enabled for most of the platforms: SUNRISE_SUNSET is present only in Windows simulator and Beken Don't get me wrong, I really appreciate your huge amount of work!! |
|
well, the less there is to do the better. I get bored easily! I could do the flash, boot, run driver, set time, check time is still set after power-cycle? dunno? startup/autoexec are columns because either N or BK7238 (mental note to go check again and note which) would just bootloop and then go into safe mode with startup command. |
|
I think this small set of tests will suffice in this case. Just to be sure, the image is working - maybe only ESP8266 would be good to test also with MQTT, I think I recall I had to do some special handling there to print the local time ... Ah, yes, in "src/mqtt/new_mqtt.c" |
|
struggling to get any i2c detection on 8266 at the moment, with any build. but i see a BMP: https://www.elektroda.com/rtvforum/topic4128678-30.html don't suppose you remember pins used? |
For ESP8266 remember the "shifted" upper IO numbers due to "missing" IO6-IO8 and IO11. |
|
Mqtt should show actual time on the device somewhere... |
…urrentTime()" switch to obktime instead of time.h "gmtime"
change "deviceclock.c" to set DS3231 RTC on every clock set command if driver is running, so e.g. every NTP update will also adjust RTC time
…ceclock whenever clock is set. so DS3231 driver can ste the clock, if needed - using "force" will force setting (no supprise ;-))
|
Thank you so much, the latest changes are no basic ones, just keeping up to date with "main" branch and some small additions. Changing how/when a driver function is called should not enforce a complete new set of tests, if we know, it works as expected on some platforms here.. |
|
oh sure, no worries. There are so many platforms now! RTL8721DA doesn't seem to work, but then I can't detect any i2c it seems. using PB18/PB19 and PB20/PB21. Not a popular platform anyway yet. image boots fine though |










Driver enabled for W800 ATM.
enabling driver with
#define ENABLE_DRIVER_DS3231starting driver with
startdriver DS3231 <CLK-Pin> <DATA-Pin> <optional: sync clock>optional last argument "sync clock":
0: do nothing
1: on driver start set device clock to RTC
2: set device clock regularly to RTC - so RTC is "clock master"