diff options
| author | Jonathan Gordon <rockbox@jdgordon.info> | 2007-10-07 08:12:01 +0000 |
|---|---|---|
| committer | Jonathan Gordon <rockbox@jdgordon.info> | 2007-10-07 08:12:01 +0000 |
| commit | d7d6b780d4975ee671b33872c294ff9b0c33227d (patch) | |
| tree | 3318ae620ab997e6be040d586fdd60dcfdf97652 | |
| parent | 32f8c402de64c469bc8416c91d50f7785283f28c (diff) | |
| download | rockbox-d7d6b780d4975ee671b33872c294ff9b0c33227d.zip rockbox-d7d6b780d4975ee671b33872c294ff9b0c33227d.tar.gz rockbox-d7d6b780d4975ee671b33872c294ff9b0c33227d.tar.bz2 rockbox-d7d6b780d4975ee671b33872c294ff9b0c33227d.tar.xz | |
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
| -rw-r--r-- | apps/menus/main_menu.c | 65 | ||||
| -rw-r--r-- | apps/talk.c | 65 | ||||
| -rw-r--r-- | apps/talk.h | 10 |
3 files changed, 78 insertions, 62 deletions
diff --git a/apps/menus/main_menu.c b/apps/menus/main_menu.c index 2dd0899..2e9d0d0 100644 --- a/apps/menus/main_menu.c +++ b/apps/menus/main_menu.c @@ -46,6 +46,7 @@ #include "logfdisp.h" #endif #include "version.h" +#include "time.h" @@ -193,72 +194,12 @@ static bool show_info(void) #else output_dyn_value(NULL, 0, free, kbyte_units, true); #endif - #if CONFIG_RTC - { - 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); - } + talk_date_time(get_time(), true); #endif - } new_info = false; } - +} FOR_NB_SCREENS(i) { screens[i].clear_display(); diff --git a/apps/talk.c b/apps/talk.c index 093ea35..afbbe5c 100644 --- a/apps/talk.c +++ b/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 diff --git a/apps/talk.h b/apps/talk.h index 75ab6fc..a95fc27 100644 --- a/apps/talk.h +++ b/apps/talk.h @@ -25,6 +25,7 @@ #define __TALK_H__ #include <stdbool.h> +#include "time.h" enum { /* 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 */ 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. */ #define TALK_FINAL_ID LANG_LAST_INDEX_IN_ARRAY |