diff options
author | Wolfram Sang <wsa@the-dreams.de> | 2021-11-25 22:18:44 +0100 |
---|---|---|
committer | Wolfram Sang <wsa@the-dreams.de> | 2022-02-07 22:04:10 +0100 |
commit | 95dfc489b5a602f68202b206c434f8485e9d3915 (patch) | |
tree | e19441973a90fa10d2f990de2ebb10459b713215 /firmware/drivers | |
parent | 5b8873bf333add9ec7208901c62bbd30ad7ea8c3 (diff) | |
download | rockbox-95dfc489b5a602f68202b206c434f8485e9d3915.tar.gz rockbox-95dfc489b5a602f68202b206c434f8485e9d3915.zip |
sync clock with RDS time
Tested with my SansaClip+. I don't think this will need extra battery
but let me know if I am wrong.
Change-Id: I287dae134113e0f8a138af68f5087b8ea45b0f4c
Diffstat (limited to 'firmware/drivers')
-rw-r--r-- | firmware/drivers/rds.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/firmware/drivers/rds.c b/firmware/drivers/rds.c index 2d8466ae36..9e37b6591c 100644 --- a/firmware/drivers/rds.c +++ b/firmware/drivers/rds.c | |||
@@ -25,6 +25,8 @@ | |||
25 | #include <kernel.h> | 25 | #include <kernel.h> |
26 | #include "rds.h" | 26 | #include "rds.h" |
27 | #include "time.h" | 27 | #include "time.h" |
28 | #include "timefuncs.h" | ||
29 | #include "settings.h" | ||
28 | #include "string-extra.h" | 30 | #include "string-extra.h" |
29 | 31 | ||
30 | #define TIMED_OUT(tick) \ | 32 | #define TIMED_OUT(tick) \ |
@@ -225,6 +227,18 @@ void rds_sync(void) | |||
225 | } | 227 | } |
226 | } | 228 | } |
227 | 229 | ||
230 | void rds_set_time(time_t time) | ||
231 | { | ||
232 | ct_data = time; | ||
233 | #ifdef CONFIG_RTC | ||
234 | if (ct_data && global_settings.sync_rds_time) { | ||
235 | struct tm *tm = gmtime(&ct_data); | ||
236 | |||
237 | set_time(tm); | ||
238 | } | ||
239 | #endif | ||
240 | } | ||
241 | |||
228 | #if (CONFIG_RDS & RDS_CFG_PROCESS) | 242 | #if (CONFIG_RDS & RDS_CFG_PROCESS) |
229 | /* handles a group 0 packet, returns true if a new message was received */ | 243 | /* handles a group 0 packet, returns true if a new message was received */ |
230 | static void handle_group0(const uint16_t data[4]) | 244 | static void handle_group0(const uint16_t data[4]) |
@@ -367,7 +381,7 @@ static void handle_group4a(const uint16_t data[4]) | |||
367 | seconds += hour * 3600; | 381 | seconds += hour * 3600; |
368 | seconds += minute * 60; | 382 | seconds += minute * 60; |
369 | seconds += ((offset_sig == 0) ? offset_abs : -offset_abs) * 1800; | 383 | seconds += ((offset_sig == 0) ? offset_abs : -offset_abs) * 1800; |
370 | ct_data = seconds; | 384 | rds_set_time(seconds); |
371 | } | 385 | } |
372 | } | 386 | } |
373 | 387 | ||
@@ -428,7 +442,7 @@ void rds_push_info(enum rds_info_id info_id, uintptr_t data, size_t size) | |||
428 | SET_TIMEOUT(rt_copy_tmo, TEXT_TIMEOUT); | 442 | SET_TIMEOUT(rt_copy_tmo, TEXT_TIMEOUT); |
429 | break; | 443 | break; |
430 | case RDS_INFO_CT: | 444 | case RDS_INFO_CT: |
431 | ct_data = (time_t)data; | 445 | rds_set_time((time_t)data); |
432 | break; | 446 | break; |
433 | 447 | ||
434 | default:; | 448 | default:; |