plugins trade talk_value for talk_value_decimal

talk_value is just talk_value_decimal with 0 decimals

lets add the extended function instead

static inline int talk_val(long n, int unit, bool enqueue)
{
    #define NODECIMALS 0
    return rb->talk_value_decimal(n, unit, NODECIMALS, enqueue);
}

Change-Id: Iaba3d2f95785f2e1855e294ccf099a977bb6cb20
This commit is contained in:
William Wilgus 2021-08-18 01:23:26 -04:00 committed by William Wilgus
parent 4cbb5b4201
commit 24e8fa317e
6 changed files with 24 additions and 13 deletions

View File

@ -439,7 +439,7 @@ static const struct plugin_api rockbox_api = {
talk_file_or_spell, talk_file_or_spell,
talk_dir_or_spell, talk_dir_or_spell,
talk_number, talk_number,
talk_value, talk_value_decimal,
talk_spell, talk_spell,
talk_time, talk_time,
talk_date, talk_date,

View File

@ -495,7 +495,7 @@ struct plugin_api {
int (*talk_dir_or_spell)(const char* filename, int (*talk_dir_or_spell)(const char* filename,
const long *prefix_ids, bool enqueue); const long *prefix_ids, bool enqueue);
int (*talk_number)(long n, bool enqueue); int (*talk_number)(long n, bool enqueue);
int (*talk_value)(long n, int unit, bool enqueue); int (*talk_value_decimal)(long n, int unit, int decimals, bool enqueue);
int (*talk_spell)(const char* spell, bool enqueue); int (*talk_spell)(const char* spell, bool enqueue);
void (*talk_time)(const struct tm *tm, bool enqueue); void (*talk_time)(const struct tm *tm, bool enqueue);
void (*talk_date)(const struct tm *tm, bool enqueue); void (*talk_date)(const struct tm *tm, bool enqueue);

View File

@ -185,6 +185,11 @@ static void config_reset_voice(void)
} }
/****************** helper fuctions ******************/ /****************** helper fuctions ******************/
static inline int talk_val(long n, int unit, bool enqueue)
{
#define NODECIMALS 0
return rb->talk_value_decimal(n, unit, NODECIMALS, enqueue);
}
void announce(void) void announce(void)
{ {
@ -658,7 +663,7 @@ static unsigned char* voice_info_group(unsigned char* current_token, bool testin
if (current_char == 'T') if (current_char == 'T')
{ {
runtime = rb->global_status->runtime; runtime = rb->global_status->runtime;
rb->talk_value(runtime, UNIT_TIME, true); talk_val(runtime, UNIT_TIME, true);
} }
/* prefix suffix connectives */ /* prefix suffix connectives */
else if (current_char == '1') else if (current_char == '1')
@ -669,7 +674,7 @@ static unsigned char* voice_info_group(unsigned char* current_token, bool testin
{ {
if (current_char == 'S') if (current_char == 'S')
{ {
rb->talk_value(sleep_remaining, UNIT_TIME, true); talk_val(sleep_remaining, UNIT_TIME, true);
} }
/* prefix suffix connectives */ /* prefix suffix connectives */
else if (current_char == '2') else if (current_char == '2')
@ -704,15 +709,15 @@ static unsigned char* voice_info_group(unsigned char* current_token, bool testin
if (current_char == 'E') if (current_char == 'E')
{ {
rb->talk_value(elapsed_length, UNIT_TIME, true); talk_val(elapsed_length, UNIT_TIME, true);
} }
else if (current_char == 'L') else if (current_char == 'L')
{ {
rb->talk_value(track_length, UNIT_TIME, true); talk_val(track_length, UNIT_TIME, true);
} }
else if (current_char == 'R') else if (current_char == 'R')
{ {
rb->talk_value(track_remaining, UNIT_TIME, true); talk_val(track_remaining, UNIT_TIME, true);
} }
else if (current_char == 'T' && id3->title) else if (current_char == 'T' && id3->title)
{ {
@ -797,11 +802,11 @@ static unsigned char* voice_info_group(unsigned char* current_token, bool testin
if (current_char == 'P') if (current_char == 'P')
{ {
rb->talk_value(rb->battery_level(), UNIT_PERCENT, true); talk_val(rb->battery_level(), UNIT_PERCENT, true);
} }
else if (current_char == 'M') else if (current_char == 'M')
{ {
rb->talk_value(rb->battery_time() * 60, UNIT_TIME, true); talk_val(rb->battery_time() * 60, UNIT_TIME, true);
} }
/* prefix suffix connectives */ /* prefix suffix connectives */
else if (current_char == '1') else if (current_char == '1')

View File

@ -470,6 +470,12 @@ static bool mpeg_set_int(const char *string, const char *unit,
return usb; return usb;
} }
static inline int talk_val(long n, int unit, bool enqueue)
{
#define NODECIMALS 0
return rb->talk_value_decimal(n, unit, NODECIMALS, enqueue);
}
static int32_t backlight_brightness_getlang(int value, int unit) static int32_t backlight_brightness_getlang(int value, int unit)
{ {
if (value < 0) if (value < 0)
@ -988,8 +994,8 @@ static int get_start_time(uint32_t duration)
mpegplayer_iram_preserve(); mpegplayer_iram_preserve();
#endif #endif
rb->talk_disable(false); rb->talk_disable(false);
rb->talk_value(resume_time / TS_SECOND, UNIT_TIME, false); talk_val(resume_time / TS_SECOND, UNIT_TIME, false);
rb->talk_value(resume_time * 100 / duration, UNIT_PERCENT, true); talk_val(resume_time * 100 / duration, UNIT_PERCENT, true);
} }
sliding = false; sliding = false;
} }

View File

@ -334,7 +334,7 @@ static int speak_property_selection(int selected_item, void *data)
rb->talk_time(&tm, true); rb->talk_time(&tm, true);
break; break;
case LANG_PROPERTIES_DURATION: case LANG_PROPERTIES_DURATION:
rb->talk_value(nseconds, UNIT_TIME, true); rb->talk_value_decimal(nseconds, UNIT_TIME, 0, true);
break; break;
case LANG_PROPERTIES_SUBDIRS: case LANG_PROPERTIES_SUBDIRS:
rb->talk_number(dps->dc, true); rb->talk_number(dps->dc, true);

View File

@ -37,7 +37,7 @@ static void xingupdate(int percent)
long now = *(rb->current_tick) / HZ; long now = *(rb->current_tick) / HZ;
if (now - last_talk >= 5) if (now - last_talk >= 5)
{ {
rb->talk_value(percent, UNIT_PERCENT, false); rb->talk_value_decimal(percent, UNIT_PERCENT, 0, false);
last_talk = now; last_talk = now;
} }
} }