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
First try for time keeping without NTP #1152
base: main
Are you sure you want to change the base?
Conversation
…psed synced with RTOS ticks
That's a very interesting concept, I want it merged, but yould you be able to add a #define to enable and disable that? |
Thanks for your feedback. Sure, this would need some effords to make it flexible and configurable.
|
Fix some typos Delete some test code
Add time on index page
added "drv_deviceclock" for general functions moved "drv_ntp_events" to "drv_clock_events" to compile, "driver/drv_deviceclock.c" must be added sdk Makefiles: --- sdk/OpenW800/app/Makefile 2024-03-26 16:04:03.812580727 +0100 +++ sdk/OpenW800/app/Makefile 2024-04-02 21:24:35.486435795 +0200 @@ -30,6 +30,7 @@ CSRCS += $(_SHARED_APP)/hal/w800/hal_pins_w800.c CSRCS += $(_SHARED_APP)/hal/w800/hal_wifi_w800.c CSRCS += $(_SHARED_APP)/httpserver/hass.c +CSRCS += $(_SHARED_APP)/driver/drv_deviceclock.c CSRCS += $(_SHARED_APP)/httpserver/http_fns.c CSRCS += $(_SHARED_APP)/httpserver/http_tcp_server.c CSRCS += $(_SHARED_APP)/httpserver/http_basic_auth.c --- sdk/OpenW600/app/Makefile 2024-03-26 16:04:02.376605773 +0100 +++ sdk/OpenW600/app/Makefile 2024-04-02 21:01:54.011157424 +0200 @@ -47,6 +47,7 @@ CSRCS += $(_SHARED_APP)/driver/drv_httpButtons.c CSRCS += $(_SHARED_APP)/driver/drv_main.c CSRCS += $(_SHARED_APP)/driver/drv_ntp.c +CSRCS += $(_SHARED_APP)/driver/drv_deviceclock.c CSRCS += $(_SHARED_APP)/driver/drv_tasmotaDeviceGroups.c CSRCS += $(_SHARED_APP)/driver/drv_test_drivers.c CSRCS += $(_SHARED_APP)/driver/drv_bridge_driver.c --- sdk/OpenXR809/project/oxr_sharedApp/gcc/Makefile 2024-03-26 16:04:04.420570122 +0100 +++ sdk/OpenXR809/project/oxr_sharedApp/gcc/Makefile 2024-04-02 20:52:18.203372715 +0200 @@ -67,6 +67,7 @@ SRCS += ../shared/src/driver/drv_ntp SRCS += ../shared/src/driver/drv_tuyaMCU SRCS += ../shared/src/driver/drv_uart +SRCS += ../shared/src/driver/drv_deviceclock SRCS += ../shared/src/i2c/drv_i2c_main SRCS += ../shared/src/i2c/drv_i2c_mcp23017
Can I somehow include changes to the Makefiles in sdk? |
some "streamlining" to Javascript code to save some bytes. Displaying time on GUI is done via "status updates" from device So uptime is not so fancy anymore (no start with "just ..." changing with the time) But this saves some bytes in the Javascript Part
I can see you made a lot of updates. Can you change the function names to fit our standard, if not NTP_GetHour then maybe Clock_GetHour, etc? Windows (uised on simulator) has names like GetMiliseconds so we need to use prefixes. The SDK changes are problematic because they need to be done separately, but on the other hand, I can't do the in main tree because the new file created would be missing in main... maybe I can do them manually once you get the basic version working? Is there a correct #define to enable/disable manual timekeeping in obk_config.h ? |
Since often you might not need very exact time, or even can't connect to an NTP server, I tried an different approach for some "easy" time keeping:
If you store the epoch at startup of the device, you can get the actual time by adding "g_secondsElapsed".
Since this is quite unreliable (drifting off 1 to 2 minutes per day) I introduced a function to set it to a more reliable value derived from xTaskGetTickCount() - I hope it is present on all platforms.
ATM its only tested on the one platform I have: LN882H.
Up to now its more like an "extended proof of concept" - probably some bugs inside and even during upload I saw quite some typos ..
"Extended" because it will also respect daylight saving time - for the EU, but this can be extended.
I would be happy to get some feedback, there are quite some aspects to discuss:
E.g. how to implement DST: I have two possible solutions tested:
The second solution is implemented at the moment: Takes some memory and is restricted to the calculated dates.
But it should be quite easy to change/extend it for other zones, if you only have to add dates, but no formula.
And regarding the restricted list - maybe its possible to realize an "update" process
Now I'm at the point to find out, if this is something worth to invest more time:
It won't make sense to put too much afford in this, if it will never make it into the project.