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
|
|
@ -46,6 +46,7 @@
|
||||||
#include "logfdisp.h"
|
#include "logfdisp.h"
|
||||||
#endif
|
#endif
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
#include "time.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -193,72 +194,12 @@ static bool show_info(void)
|
||||||
#else
|
#else
|
||||||
output_dyn_value(NULL, 0, free, kbyte_units, true);
|
output_dyn_value(NULL, 0, free, kbyte_units, true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CONFIG_RTC
|
#if CONFIG_RTC
|
||||||
{
|
talk_date_time(get_time(), true);
|
||||||
struct tm* tm = get_time();
|
|
||||||
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
|
#endif
|
||||||
}
|
|
||||||
new_info = false;
|
new_info = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
FOR_NB_SCREENS(i)
|
FOR_NB_SCREENS(i)
|
||||||
{
|
{
|
||||||
screens[i].clear_display();
|
screens[i].clear_display();
|
||||||
|
|
|
||||||
65
apps/talk.c
65
apps/talk.c
|
|
@ -864,3 +864,68 @@ void talk_enable_menus(void)
|
||||||
{
|
{
|
||||||
talk_menu_disable--;
|
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
|
||||||
|
|
|
||||||
10
apps/talk.h
10
apps/talk.h
|
|
@ -25,6 +25,7 @@
|
||||||
#define __TALK_H__
|
#define __TALK_H__
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include "time.h"
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
/* See array "unit_voiced" in talk.c function "talk_value" */
|
/* See array "unit_voiced" in talk.c function "talk_value" */
|
||||||
|
|
@ -78,6 +79,15 @@ void talk_disable_menus(void); /* disable voice menus (temporarily, not persiste
|
||||||
void talk_enable_menus(void); /* re-enable voice menus */
|
void talk_enable_menus(void); /* re-enable voice menus */
|
||||||
int do_shutup(void); /* kill voice unconditionally */
|
int do_shutup(void); /* kill voice unconditionally */
|
||||||
|
|
||||||
|
#if CONFIG_RTC
|
||||||
|
/* this is in talk.c which isnt compiled for hwcodec simulator */
|
||||||
|
#if !defined(SIMULATOR) || CONFIG_CODEC == SWCODEC
|
||||||
|
void talk_date_time(struct tm *time, bool speak_current_time_string);
|
||||||
|
#else
|
||||||
|
#define talk_date_time(t, s)
|
||||||
|
#endif
|
||||||
|
#endif /* CONFIG_RTC */
|
||||||
|
|
||||||
/* This (otherwise invalid) ID signals the end of the array. */
|
/* This (otherwise invalid) ID signals the end of the array. */
|
||||||
#define TALK_FINAL_ID LANG_LAST_INDEX_IN_ARRAY
|
#define TALK_FINAL_ID LANG_LAST_INDEX_IN_ARRAY
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue