Accept FS#7910: spontaneously speak out the battery level when it falls
under 50%, 30% and 15%. Guarded by an option under voice settings. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15422 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
775279b63e
commit
da93299865
8 changed files with 61 additions and 3 deletions
|
@ -11448,3 +11448,17 @@
|
|||
multivolume: "Not present"
|
||||
</voice>
|
||||
</phrase>
|
||||
<phrase>
|
||||
id: LANG_TALK_BATTERY_LEVEL
|
||||
desc: Setting for spontaneous battery level announcement
|
||||
user:
|
||||
<source>
|
||||
*: "Announce Battery Level"
|
||||
</source>
|
||||
<dest>
|
||||
*: "Announce Battery Level"
|
||||
</dest>
|
||||
<voice>
|
||||
*: "Announce Battery Level"
|
||||
</voice>
|
||||
</phrase>
|
||||
|
|
|
@ -443,9 +443,12 @@ static int talk_callback(int action,const struct menu_item_ex *this_item)
|
|||
}
|
||||
return action;
|
||||
}
|
||||
MENUITEM_SETTING(talk_battery_level_item,
|
||||
&global_settings.talk_battery_level, NULL);
|
||||
MAKE_MENU(voice_settings_menu, ID2P(LANG_VOICE), 0, Icon_Voice,
|
||||
&talk_menu_item, &talk_dir_item, &talk_dir_clip_item,
|
||||
&talk_file_item, &talk_file_clip_item);
|
||||
&talk_file_item, &talk_file_clip_item,
|
||||
&talk_battery_level_item);
|
||||
/* VOICE MENU */
|
||||
/***********************************/
|
||||
|
||||
|
|
10
apps/misc.c
10
apps/misc.c
|
@ -857,6 +857,16 @@ long default_event_handler_ex(long event, void (*callback)(void *), void *parame
|
|||
{
|
||||
switch(event)
|
||||
{
|
||||
case SYS_BATTERY_UPDATE:
|
||||
if(global_settings.talk_battery_level)
|
||||
{
|
||||
talk_ids(true, VOICE_PAUSE, VOICE_PAUSE,
|
||||
LANG_BATTERY_TIME,
|
||||
TALK_ID(battery_level(), UNIT_PERCENT),
|
||||
VOICE_PAUSE);
|
||||
talk_force_enqueue_next();
|
||||
}
|
||||
break;
|
||||
case SYS_USB_CONNECTED:
|
||||
if (callback != NULL)
|
||||
callback(parameter);
|
||||
|
|
|
@ -112,12 +112,12 @@
|
|||
#define PLUGIN_MAGIC 0x526F634B /* RocK */
|
||||
|
||||
/* increase this every time the api struct changes */
|
||||
#define PLUGIN_API_VERSION 86
|
||||
#define PLUGIN_API_VERSION 87
|
||||
|
||||
/* update this to latest version if a change to the api struct breaks
|
||||
backwards compatibility (and please take the opportunity to sort in any
|
||||
new function which are "waiting" at the end of the function table) */
|
||||
#define PLUGIN_MIN_API_VERSION 86
|
||||
#define PLUGIN_MIN_API_VERSION 87
|
||||
|
||||
/* plugin return codes */
|
||||
enum plugin_status {
|
||||
|
|
|
@ -529,6 +529,7 @@ struct user_settings
|
|||
bool talk_dir_clip; /* use directory .talk clips */
|
||||
int talk_file; /* voice file mode: 0=off, 1=number, 2=spell */
|
||||
bool talk_file_clip; /* use file .talk clips */
|
||||
bool talk_battery_level;
|
||||
|
||||
/* file browser sorting */
|
||||
int sort_file; /* 0=alpha, 1=date, 2=date (new first), 3=type */
|
||||
|
|
|
@ -753,6 +753,9 @@ const struct settings_list settings[] = {
|
|||
ID2P(LANG_OFF), ID2P(LANG_VOICE_NUMBER),
|
||||
ID2P(LANG_VOICE_SPELL)),
|
||||
OFFON_SETTING(F_TEMPVAR, talk_file_clip, LANG_VOICE_FILE_TALK, false, "talk file clip", NULL),
|
||||
OFFON_SETTING(F_TEMPVAR, talk_battery_level,
|
||||
LANG_TALK_BATTERY_LEVEL, false,
|
||||
"Announce Battery Level", NULL),
|
||||
|
||||
/* file sorting */
|
||||
CHOICE_SETTING(0, sort_file, LANG_SORT_FILE, 0 ,
|
||||
|
|
|
@ -65,6 +65,7 @@
|
|||
#define SYS_POWEROFF MAKE_SYS_EVENT(SYS_EVENT_CLS_POWER, 0)
|
||||
#define SYS_CHARGER_CONNECTED MAKE_SYS_EVENT(SYS_EVENT_CLS_POWER, 1)
|
||||
#define SYS_CHARGER_DISCONNECTED MAKE_SYS_EVENT(SYS_EVENT_CLS_POWER, 2)
|
||||
#define SYS_BATTERY_UPDATE MAKE_SYS_EVENT(SYS_EVENT_CLS_POWER, 3)
|
||||
#define SYS_FS_CHANGED MAKE_SYS_EVENT(SYS_EVENT_CLS_FILESYS, 0)
|
||||
#define SYS_HOTSWAP_INSERTED MAKE_SYS_EVENT(SYS_EVENT_CLS_PLUG, 0)
|
||||
#define SYS_HOTSWAP_EXTRACTED MAKE_SYS_EVENT(SYS_EVENT_CLS_PLUG, 1)
|
||||
|
|
|
@ -80,6 +80,9 @@ static int shutdown_timeout = 0;
|
|||
charge_state_type charge_state; /* charging mode */
|
||||
#endif
|
||||
|
||||
static void send_battery_level_event(void);
|
||||
static int last_sent_battery_level = 100;
|
||||
|
||||
#if CONFIG_CHARGING
|
||||
charger_input_state_type charger_input_state IDATA_ATTR;
|
||||
#endif
|
||||
|
@ -111,6 +114,7 @@ static void battery_status_update(void)
|
|||
batt_level = 100 * (batt_millivolts - BATT_MINMVOLT) / (BATT_MAXMVOLT - BATT_MINMVOLT);
|
||||
batt_time = batt_level * BATT_MAXRUNTIME / 100;
|
||||
}
|
||||
send_battery_level_event();
|
||||
}
|
||||
|
||||
void battery_read_info(int *voltage, int *level)
|
||||
|
@ -459,6 +463,7 @@ static void battery_status_update(void)
|
|||
}
|
||||
|
||||
battery_percent = level;
|
||||
send_battery_level_event();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -638,6 +643,7 @@ static void power_thread_sleep(int ticks)
|
|||
return;
|
||||
case CHARGER_PLUGGED:
|
||||
queue_broadcast(SYS_CHARGER_CONNECTED, 0);
|
||||
last_sent_battery_level = 0;
|
||||
charger_input_state = CHARGER;
|
||||
break;
|
||||
case CHARGER:
|
||||
|
@ -649,6 +655,7 @@ static void power_thread_sleep(int ticks)
|
|||
break;
|
||||
case CHARGER_UNPLUGGED:
|
||||
queue_broadcast(SYS_CHARGER_DISCONNECTED, 0);
|
||||
last_sent_battery_level = 100;
|
||||
charger_input_state = NO_CHARGER;
|
||||
break;
|
||||
case CHARGER_PLUGGED:
|
||||
|
@ -1192,3 +1199,22 @@ void shutdown_hw(void)
|
|||
power_off();
|
||||
#endif /* #ifndef SIMULATOR */
|
||||
}
|
||||
|
||||
/* Send system battery level update events on reaching certain
|
||||
significant levels. */
|
||||
static void send_battery_level_event(void)
|
||||
{
|
||||
int current_level = battery_level();
|
||||
static const int levels[] = { 15, 30, 50, 0 };
|
||||
const int *level = levels;
|
||||
while (*level)
|
||||
{
|
||||
if (current_level <= *level && last_sent_battery_level > *level)
|
||||
{
|
||||
last_sent_battery_level = *level;
|
||||
queue_broadcast(SYS_BATTERY_UPDATE, last_sent_battery_level);
|
||||
break;
|
||||
}
|
||||
level++;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue