mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
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
This commit is contained in:
parent
5b8873bf33
commit
95dfc489b5
9 changed files with 64 additions and 2 deletions
|
@ -105,6 +105,10 @@ radio_remote
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_RDS_CAP)
|
||||||
|
rds
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_RECORDING)
|
#if defined(HAVE_RECORDING)
|
||||||
recording
|
recording
|
||||||
#if defined(HAVE_LINE_IN)
|
#if defined(HAVE_LINE_IN)
|
||||||
|
|
|
@ -16229,3 +16229,20 @@
|
||||||
*: "Prefer Image File"
|
*: "Prefer Image File"
|
||||||
</voice>
|
</voice>
|
||||||
</phrase>
|
</phrase>
|
||||||
|
<phrase>
|
||||||
|
id: LANG_FM_SYNC_RDS_TIME
|
||||||
|
desc: in radio screen and Settings
|
||||||
|
user: core
|
||||||
|
<source>
|
||||||
|
*: none
|
||||||
|
rds: "Sync RDS Time"
|
||||||
|
</source>
|
||||||
|
<dest>
|
||||||
|
*: none
|
||||||
|
rds: "Sync RDS Time"
|
||||||
|
</dest>
|
||||||
|
<voice>
|
||||||
|
*: none
|
||||||
|
rds: "Sync RDS Time"
|
||||||
|
</voice>
|
||||||
|
</phrase>
|
||||||
|
|
|
@ -87,6 +87,9 @@ MENUITEM_FUNCTION(presetclear_item, 0, ID2P(LANG_FM_PRESET_CLEAR),
|
||||||
|
|
||||||
MENUITEM_SETTING(set_region, &global_settings.fm_region, NULL);
|
MENUITEM_SETTING(set_region, &global_settings.fm_region, NULL);
|
||||||
MENUITEM_SETTING(force_mono, &global_settings.fm_force_mono, NULL);
|
MENUITEM_SETTING(force_mono, &global_settings.fm_force_mono, NULL);
|
||||||
|
#if defined(HAVE_RDS_CAP) && defined(CONFIG_RTC)
|
||||||
|
MENUITEM_SETTING(sync_rds_time, &global_settings.sync_rds_time, NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef FM_MODE
|
#ifndef FM_MODE
|
||||||
extern int radio_mode;
|
extern int radio_mode;
|
||||||
|
@ -146,6 +149,9 @@ MAKE_MENU(radio_settings_menu, ID2P(LANG_FM_MENU), NULL,
|
||||||
#endif
|
#endif
|
||||||
#ifdef FM_RECORDING_SETTINGS
|
#ifdef FM_RECORDING_SETTINGS
|
||||||
&recsettings_item,
|
&recsettings_item,
|
||||||
|
#endif
|
||||||
|
#if defined(HAVE_RDS_CAP) && defined(CONFIG_RTC)
|
||||||
|
&sync_rds_time,
|
||||||
#endif
|
#endif
|
||||||
&scan_presets_item);
|
&scan_presets_item);
|
||||||
|
|
||||||
|
|
|
@ -242,6 +242,9 @@ static int time_menu_callback(int action,
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(HAVE_RDS_CAP) && defined(CONFIG_RTC)
|
||||||
|
MENUITEM_SETTING(sync_rds_time, &global_settings.sync_rds_time, NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
MAKE_MENU(time_menu, ID2P(LANG_TIME_MENU), time_menu_callback, Icon_NOICON,
|
MAKE_MENU(time_menu, ID2P(LANG_TIME_MENU), time_menu_callback, Icon_NOICON,
|
||||||
&time_set,
|
&time_set,
|
||||||
|
@ -250,6 +253,9 @@ MAKE_MENU(time_menu, ID2P(LANG_TIME_MENU), time_menu_callback, Icon_NOICON,
|
||||||
#if defined(HAVE_RECORDING) || CONFIG_TUNER
|
#if defined(HAVE_RECORDING) || CONFIG_TUNER
|
||||||
&alarm_wake_up_screen,
|
&alarm_wake_up_screen,
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
#if defined(HAVE_RDS_CAP) && defined(CONFIG_RTC)
|
||||||
|
&sync_rds_time,
|
||||||
#endif
|
#endif
|
||||||
&timeformat);
|
&timeformat);
|
||||||
|
|
||||||
|
|
|
@ -458,6 +458,9 @@ struct user_settings
|
||||||
unsigned char rfms_file[MAX_FILENAME+1]; /* last remote-fms */
|
unsigned char rfms_file[MAX_FILENAME+1]; /* last remote-fms */
|
||||||
#endif
|
#endif
|
||||||
#endif /* CONFIG_TUNER */
|
#endif /* CONFIG_TUNER */
|
||||||
|
#if defined(HAVE_RDS_CAP) && defined(CONFIG_RTC)
|
||||||
|
bool sync_rds_time; /* use RDS time to set the clock */
|
||||||
|
#endif
|
||||||
|
|
||||||
/* misc options */
|
/* misc options */
|
||||||
#ifndef HAVE_WHEEL_ACCELERATION
|
#ifndef HAVE_WHEEL_ACCELERATION
|
||||||
|
|
|
@ -1096,6 +1096,9 @@ const struct settings_list settings[] = {
|
||||||
false, "force fm mono", toggle_mono_mode),
|
false, "force fm mono", toggle_mono_mode),
|
||||||
SYSTEM_SETTING(NVRAM(4), last_frequency, 0),
|
SYSTEM_SETTING(NVRAM(4), last_frequency, 0),
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(HAVE_RDS_CAP) && defined(CONFIG_RTC)
|
||||||
|
OFFON_SETTING(0, sync_rds_time, LANG_FM_SYNC_RDS_TIME, false, "sync_rds_time", NULL),
|
||||||
|
#endif
|
||||||
|
|
||||||
#if BATTERY_TYPES_COUNT > 1
|
#if BATTERY_TYPES_COUNT > 1
|
||||||
CHOICE_SETTING(0, battery_type, LANG_BATTERY_TYPE, 0, "battery type",
|
CHOICE_SETTING(0, battery_type, LANG_BATTERY_TYPE, 0, "battery type",
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
#include <kernel.h>
|
#include <kernel.h>
|
||||||
#include "rds.h"
|
#include "rds.h"
|
||||||
#include "time.h"
|
#include "time.h"
|
||||||
|
#include "timefuncs.h"
|
||||||
|
#include "settings.h"
|
||||||
#include "string-extra.h"
|
#include "string-extra.h"
|
||||||
|
|
||||||
#define TIMED_OUT(tick) \
|
#define TIMED_OUT(tick) \
|
||||||
|
@ -225,6 +227,18 @@ void rds_sync(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rds_set_time(time_t time)
|
||||||
|
{
|
||||||
|
ct_data = time;
|
||||||
|
#ifdef CONFIG_RTC
|
||||||
|
if (ct_data && global_settings.sync_rds_time) {
|
||||||
|
struct tm *tm = gmtime(&ct_data);
|
||||||
|
|
||||||
|
set_time(tm);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#if (CONFIG_RDS & RDS_CFG_PROCESS)
|
#if (CONFIG_RDS & RDS_CFG_PROCESS)
|
||||||
/* handles a group 0 packet, returns true if a new message was received */
|
/* handles a group 0 packet, returns true if a new message was received */
|
||||||
static void handle_group0(const uint16_t data[4])
|
static void handle_group0(const uint16_t data[4])
|
||||||
|
@ -367,7 +381,7 @@ static void handle_group4a(const uint16_t data[4])
|
||||||
seconds += hour * 3600;
|
seconds += hour * 3600;
|
||||||
seconds += minute * 60;
|
seconds += minute * 60;
|
||||||
seconds += ((offset_sig == 0) ? offset_abs : -offset_abs) * 1800;
|
seconds += ((offset_sig == 0) ? offset_abs : -offset_abs) * 1800;
|
||||||
ct_data = seconds;
|
rds_set_time(seconds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,7 +442,7 @@ void rds_push_info(enum rds_info_id info_id, uintptr_t data, size_t size)
|
||||||
SET_TIMEOUT(rt_copy_tmo, TEXT_TIMEOUT);
|
SET_TIMEOUT(rt_copy_tmo, TEXT_TIMEOUT);
|
||||||
break;
|
break;
|
||||||
case RDS_INFO_CT:
|
case RDS_INFO_CT:
|
||||||
ct_data = (time_t)data;
|
rds_set_time((time_t)data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:;
|
default:;
|
||||||
|
|
|
@ -370,6 +370,10 @@
|
||||||
force fm mono
|
force fm mono
|
||||||
& off, on & N/A\\
|
& off, on & N/A\\
|
||||||
}%
|
}%
|
||||||
|
\opt{rds}{
|
||||||
|
sync RDS time
|
||||||
|
& off, on & N/A\\
|
||||||
|
}%
|
||||||
|
|
||||||
\bottomrule
|
\bottomrule
|
||||||
\end{longtable}
|
\end{longtable}
|
||||||
|
|
|
@ -21,4 +21,9 @@ if voice support is enabled.
|
||||||
}%\opt{recording,radio}
|
}%\opt{recording,radio}
|
||||||
}%\opt{alarm}
|
}%\opt{alarm}
|
||||||
\item[Time Format:] Choose 12 or 24 hour clock.
|
\item[Time Format:] Choose 12 or 24 hour clock.
|
||||||
|
\opt{rds}{
|
||||||
|
\item[Sync RDS time:]
|
||||||
|
If this option is enabled, your clock will be kept in sync with the time provided
|
||||||
|
by Radio Data System (RDS) if the currently selected station provides it.
|
||||||
|
}%\opt{rds}
|
||||||
\end{description}
|
\end{description}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue