forked from len0rd/rockbox
Accept FS#7897 with some changes by me. moves the code to talk time/date out of main_menu.c to make it hopefully more useful.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15011 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
32f8c402de
commit
d7d6b780d4
3 changed files with 78 additions and 62 deletions
65
apps/talk.c
65
apps/talk.c
|
|
@ -864,3 +864,68 @@ void talk_enable_menus(void)
|
|||
{
|
||||
talk_menu_disable--;
|
||||
}
|
||||
|
||||
#if CONFIG_RTC
|
||||
void talk_date_time(struct tm *tm, bool speak_current_time_string)
|
||||
{
|
||||
if(talk_menus_enabled ())
|
||||
{
|
||||
if(speak_current_time_string)
|
||||
talk_id(VOICE_CURRENT_TIME, true);
|
||||
if (global_settings.timeformat == 1)
|
||||
{
|
||||
long am_pm_id = VOICE_AM;
|
||||
int hour = tm->tm_hour;
|
||||
|
||||
if (hour >= 12)
|
||||
{
|
||||
am_pm_id = VOICE_PM;
|
||||
hour -= 12;
|
||||
}
|
||||
if (hour == 0)
|
||||
hour = 12;
|
||||
|
||||
talk_number(hour, true);
|
||||
|
||||
/* Voice the minutes */
|
||||
if (tm->tm_min == 0)
|
||||
{
|
||||
/* Say o'clock if the minute is 0. */
|
||||
talk_id(VOICE_OCLOCK, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Pronounce the leading 0 */
|
||||
if(tm->tm_min < 10)
|
||||
{
|
||||
talk_id(VOICE_OH, true);
|
||||
}
|
||||
talk_number(tm->tm_min, true);
|
||||
}
|
||||
talk_id(am_pm_id, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Voice the time in 24 hour format */
|
||||
talk_number(tm->tm_hour, true);
|
||||
if (tm->tm_min == 0)
|
||||
{
|
||||
talk_id(VOICE_HUNDRED, true);
|
||||
talk_id(VOICE_HOUR, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Pronounce the leading 0 */
|
||||
if(tm->tm_min < 10)
|
||||
{
|
||||
talk_id(VOICE_OH, true);
|
||||
}
|
||||
talk_number(tm->tm_min, true);
|
||||
}
|
||||
}
|
||||
talk_id(LANG_MONTH_JANUARY + tm->tm_mon, true);
|
||||
talk_number(tm->tm_mday, true);
|
||||
talk_number(1900 + tm->tm_year, true);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue