summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolfram Sang <wsa@the-dreams.de>2021-11-25 22:18:44 +0100
committerWolfram Sang <wsa@the-dreams.de>2022-02-07 22:04:10 +0100
commit95dfc489b5a602f68202b206c434f8485e9d3915 (patch)
treee19441973a90fa10d2f990de2ebb10459b713215
parent5b8873bf333add9ec7208901c62bbd30ad7ea8c3 (diff)
downloadrockbox-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
-rw-r--r--apps/features.txt4
-rw-r--r--apps/lang/english.lang17
-rw-r--r--apps/menus/radio_menu.c6
-rw-r--r--apps/menus/time_menu.c6
-rw-r--r--apps/settings.h3
-rw-r--r--apps/settings_list.c3
-rw-r--r--firmware/drivers/rds.c18
-rw-r--r--manual/appendix/config_file_options.tex4
-rw-r--r--manual/configure_rockbox/time_and_date.tex5
9 files changed, 64 insertions, 2 deletions
diff --git a/apps/features.txt b/apps/features.txt
index ec2113cbc8..45e06e5e64 100644
--- a/apps/features.txt
+++ b/apps/features.txt
@@ -105,6 +105,10 @@ radio_remote
105#endif 105#endif
106#endif 106#endif
107 107
108#if defined(HAVE_RDS_CAP)
109rds
110#endif
111
108#if defined(HAVE_RECORDING) 112#if defined(HAVE_RECORDING)
109recording 113recording
110#if defined(HAVE_LINE_IN) 114#if defined(HAVE_LINE_IN)
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index 43d73a8445..c951028494 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -16229,3 +16229,20 @@
16229 *: "Prefer Image File" 16229 *: "Prefer Image File"
16230 </voice> 16230 </voice>
16231</phrase> 16231</phrase>
16232<phrase>
16233 id: LANG_FM_SYNC_RDS_TIME
16234 desc: in radio screen and Settings
16235 user: core
16236 <source>
16237 *: none
16238 rds: "Sync RDS Time"
16239 </source>
16240 <dest>
16241 *: none
16242 rds: "Sync RDS Time"
16243 </dest>
16244 <voice>
16245 *: none
16246 rds: "Sync RDS Time"
16247 </voice>
16248</phrase>
diff --git a/apps/menus/radio_menu.c b/apps/menus/radio_menu.c
index a6d259a21d..682cecf2b4 100644
--- a/apps/menus/radio_menu.c
+++ b/apps/menus/radio_menu.c
@@ -87,6 +87,9 @@ MENUITEM_FUNCTION(presetclear_item, 0, ID2P(LANG_FM_PRESET_CLEAR),
87 87
88MENUITEM_SETTING(set_region, &global_settings.fm_region, NULL); 88MENUITEM_SETTING(set_region, &global_settings.fm_region, NULL);
89MENUITEM_SETTING(force_mono, &global_settings.fm_force_mono, NULL); 89MENUITEM_SETTING(force_mono, &global_settings.fm_force_mono, NULL);
90#if defined(HAVE_RDS_CAP) && defined(CONFIG_RTC)
91MENUITEM_SETTING(sync_rds_time, &global_settings.sync_rds_time, NULL);
92#endif
90 93
91#ifndef FM_MODE 94#ifndef FM_MODE
92extern int radio_mode; 95extern int radio_mode;
@@ -147,5 +150,8 @@ MAKE_MENU(radio_settings_menu, ID2P(LANG_FM_MENU), NULL,
147#ifdef FM_RECORDING_SETTINGS 150#ifdef FM_RECORDING_SETTINGS
148 &recsettings_item, 151 &recsettings_item,
149#endif 152#endif
153#if defined(HAVE_RDS_CAP) && defined(CONFIG_RTC)
154 &sync_rds_time,
155#endif
150 &scan_presets_item); 156 &scan_presets_item);
151 157
diff --git a/apps/menus/time_menu.c b/apps/menus/time_menu.c
index edd2e19a2b..674279c01a 100644
--- a/apps/menus/time_menu.c
+++ b/apps/menus/time_menu.c
@@ -242,6 +242,9 @@ static int time_menu_callback(int action,
242 return action; 242 return action;
243} 243}
244 244
245#if defined(HAVE_RDS_CAP) && defined(CONFIG_RTC)
246MENUITEM_SETTING(sync_rds_time, &global_settings.sync_rds_time, NULL);
247#endif
245 248
246MAKE_MENU(time_menu, ID2P(LANG_TIME_MENU), time_menu_callback, Icon_NOICON, 249MAKE_MENU(time_menu, ID2P(LANG_TIME_MENU), time_menu_callback, Icon_NOICON,
247 &time_set, 250 &time_set,
@@ -251,6 +254,9 @@ MAKE_MENU(time_menu, ID2P(LANG_TIME_MENU), time_menu_callback, Icon_NOICON,
251 &alarm_wake_up_screen, 254 &alarm_wake_up_screen,
252#endif 255#endif
253#endif 256#endif
257#if defined(HAVE_RDS_CAP) && defined(CONFIG_RTC)
258 &sync_rds_time,
259#endif
254 &timeformat); 260 &timeformat);
255 261
256int time_screen(void* ignored) 262int time_screen(void* ignored)
diff --git a/apps/settings.h b/apps/settings.h
index 936280ba5a..8ff006d682 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -458,6 +458,9 @@ struct user_settings
458 unsigned char rfms_file[MAX_FILENAME+1]; /* last remote-fms */ 458 unsigned char rfms_file[MAX_FILENAME+1]; /* last remote-fms */
459#endif 459#endif
460#endif /* CONFIG_TUNER */ 460#endif /* CONFIG_TUNER */
461#if defined(HAVE_RDS_CAP) && defined(CONFIG_RTC)
462 bool sync_rds_time; /* use RDS time to set the clock */
463#endif
461 464
462 /* misc options */ 465 /* misc options */
463#ifndef HAVE_WHEEL_ACCELERATION 466#ifndef HAVE_WHEEL_ACCELERATION
diff --git a/apps/settings_list.c b/apps/settings_list.c
index 7b24db22e5..aa2ebbf883 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -1096,6 +1096,9 @@ const struct settings_list settings[] = {
1096 false, "force fm mono", toggle_mono_mode), 1096 false, "force fm mono", toggle_mono_mode),
1097 SYSTEM_SETTING(NVRAM(4), last_frequency, 0), 1097 SYSTEM_SETTING(NVRAM(4), last_frequency, 0),
1098#endif 1098#endif
1099#if defined(HAVE_RDS_CAP) && defined(CONFIG_RTC)
1100 OFFON_SETTING(0, sync_rds_time, LANG_FM_SYNC_RDS_TIME, false, "sync_rds_time", NULL),
1101#endif
1099 1102
1100#if BATTERY_TYPES_COUNT > 1 1103#if BATTERY_TYPES_COUNT > 1
1101 CHOICE_SETTING(0, battery_type, LANG_BATTERY_TYPE, 0, "battery type", 1104 CHOICE_SETTING(0, battery_type, LANG_BATTERY_TYPE, 0, "battery type",
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
230void 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 */
230static void handle_group0(const uint16_t data[4]) 244static 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:;
diff --git a/manual/appendix/config_file_options.tex b/manual/appendix/config_file_options.tex
index 09bc148535..b188c953f8 100644
--- a/manual/appendix/config_file_options.tex
+++ b/manual/appendix/config_file_options.tex
@@ -370,6 +370,10 @@
370 force fm mono 370 force fm mono
371 & off, on & N/A\\ 371 & off, on & N/A\\
372 }% 372 }%
373 \opt{rds}{
374 sync RDS time
375 & off, on & N/A\\
376 }%
373 377
374 \bottomrule 378 \bottomrule
375 \end{longtable} 379 \end{longtable}
diff --git a/manual/configure_rockbox/time_and_date.tex b/manual/configure_rockbox/time_and_date.tex
index aa3f563eed..36da0e6204 100644
--- a/manual/configure_rockbox/time_and_date.tex
+++ b/manual/configure_rockbox/time_and_date.tex
@@ -21,4 +21,9 @@ if voice support is enabled.
21 }%\opt{recording,radio} 21 }%\opt{recording,radio}
22 }%\opt{alarm} 22 }%\opt{alarm}
23 \item[Time Format:] Choose 12 or 24 hour clock. 23 \item[Time Format:] Choose 12 or 24 hour clock.
24 \opt{rds}{
25 \item[Sync RDS time:]
26 If this option is enabled, your clock will be kept in sync with the time provided
27 by Radio Data System (RDS) if the currently selected station provides it.
28 }%\opt{rds}
24\end{description} 29\end{description}