mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
Show time, date, and recording directory in the info screen
Patch by Igor Poretsky Change-Id: I5db0d018742c11dd9bf3ca4c9539cd91f94d4c2e
This commit is contained in:
parent
ddf612c84b
commit
4beafe16fa
4 changed files with 172 additions and 2 deletions
|
@ -880,6 +880,13 @@ bool list_do_action(int context, int timeout,
|
||||||
return gui_synclist_do_button(lists, action, wrap);
|
return gui_synclist_do_button(lists, action, wrap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool gui_synclist_item_is_onscreen(struct gui_synclist *lists,
|
||||||
|
enum screen_type screen, int item)
|
||||||
|
{
|
||||||
|
int nb_lines = list_get_nb_lines(lists, screen);
|
||||||
|
return (unsigned)(item - lists->start_item[screen]) < (unsigned) nb_lines;
|
||||||
|
}
|
||||||
|
|
||||||
/* Simple use list implementation */
|
/* Simple use list implementation */
|
||||||
static int simplelist_line_count = 0, simplelist_line_remaining;
|
static int simplelist_line_count = 0, simplelist_line_remaining;
|
||||||
static int simplelist_line_pos;
|
static int simplelist_line_pos;
|
||||||
|
|
|
@ -167,6 +167,8 @@ extern void gui_synclist_set_title(struct gui_synclist * lists, char * title,
|
||||||
enum themable_icons icon);
|
enum themable_icons icon);
|
||||||
extern void gui_synclist_hide_selection_marker(struct gui_synclist *lists,
|
extern void gui_synclist_hide_selection_marker(struct gui_synclist *lists,
|
||||||
bool hide);
|
bool hide);
|
||||||
|
extern bool gui_synclist_item_is_onscreen(struct gui_synclist *lists,
|
||||||
|
enum screen_type screen, int item);
|
||||||
|
|
||||||
#if CONFIG_CODEC == SWCODEC
|
#if CONFIG_CODEC == SWCODEC
|
||||||
extern bool gui_synclist_keyclick_callback(int action, void* data);
|
extern bool gui_synclist_keyclick_callback(int action, void* data);
|
||||||
|
|
|
@ -15242,3 +15242,20 @@ id: VOICE_BAT_BENCH_KEYS
|
||||||
*: "Return"
|
*: "Return"
|
||||||
</voice>
|
</voice>
|
||||||
</phrase>
|
</phrase>
|
||||||
|
<phrase>
|
||||||
|
id: LANG_REC_DIR
|
||||||
|
desc: used in the info screen to show a recording dir
|
||||||
|
user: core
|
||||||
|
<source>
|
||||||
|
*: none
|
||||||
|
recording: "Recording Directory"
|
||||||
|
</source>
|
||||||
|
<dest>
|
||||||
|
*: none
|
||||||
|
recording: "Recording Directory"
|
||||||
|
</dest>
|
||||||
|
<voice>
|
||||||
|
*: none
|
||||||
|
recording: "Recording Directory"
|
||||||
|
</voice>
|
||||||
|
</phrase>
|
||||||
|
|
|
@ -147,7 +147,14 @@ enum infoscreenorder
|
||||||
INFO_DISK1, /* capacity or internal capacity/free on hotswap */
|
INFO_DISK1, /* capacity or internal capacity/free on hotswap */
|
||||||
INFO_DISK2, /* free space or external capacity/free on hotswap */
|
INFO_DISK2, /* free space or external capacity/free on hotswap */
|
||||||
INFO_BUFFER,
|
INFO_BUFFER,
|
||||||
|
#ifdef HAVE_RECORDING
|
||||||
|
INFO_REC_DIR,
|
||||||
|
#endif
|
||||||
INFO_VERSION,
|
INFO_VERSION,
|
||||||
|
#if CONFIG_RTC
|
||||||
|
INFO_DATE,
|
||||||
|
INFO_TIME,
|
||||||
|
#endif
|
||||||
INFO_COUNT
|
INFO_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -155,6 +162,9 @@ static const char* info_getname(int selected_item, void *data,
|
||||||
char *buffer, size_t buffer_len)
|
char *buffer, size_t buffer_len)
|
||||||
{
|
{
|
||||||
struct info_data *info = (struct info_data*)data;
|
struct info_data *info = (struct info_data*)data;
|
||||||
|
#if CONFIG_RTC
|
||||||
|
struct tm *tm;
|
||||||
|
#endif
|
||||||
char s1[32];
|
char s1[32];
|
||||||
#if defined(HAVE_MULTIVOLUME)
|
#if defined(HAVE_MULTIVOLUME)
|
||||||
char s2[32];
|
char s2[32];
|
||||||
|
@ -179,6 +189,46 @@ static const char* info_getname(int selected_item, void *data,
|
||||||
str(LANG_VERSION), rbversion);
|
str(LANG_VERSION), rbversion);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
#if CONFIG_RTC
|
||||||
|
case INFO_TIME:
|
||||||
|
tm = get_time();
|
||||||
|
if (valid_time(tm))
|
||||||
|
{
|
||||||
|
snprintf(buffer, buffer_len, "%02d:%02d:%02d %s",
|
||||||
|
global_settings.timeformat == 0 ? tm->tm_hour :
|
||||||
|
((tm->tm_hour + 11) % 12) + 1,
|
||||||
|
tm->tm_min,
|
||||||
|
tm->tm_sec,
|
||||||
|
global_settings.timeformat == 0 ? "" :
|
||||||
|
tm->tm_hour>11 ? "P" : "A");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
snprintf(buffer, buffer_len, "%s", "--:--:--");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case INFO_DATE:
|
||||||
|
tm = get_time();
|
||||||
|
if (valid_time(tm))
|
||||||
|
{
|
||||||
|
snprintf(buffer, buffer_len, "%s %d %d",
|
||||||
|
str(LANG_MONTH_JANUARY + tm->tm_mon),
|
||||||
|
tm->tm_mday,
|
||||||
|
tm->tm_year+1900);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
snprintf(buffer, buffer_len, "%s", str(LANG_UNKNOWN));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_RECORDING
|
||||||
|
case INFO_REC_DIR:
|
||||||
|
snprintf(buffer, buffer_len, "%s %s", str(LANG_REC_DIR), global_settings.rec_directory);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
case INFO_BUFFER: /* buffer */
|
case INFO_BUFFER: /* buffer */
|
||||||
{
|
{
|
||||||
long kib = audio_buffer_size() >> 10; /* to KiB */
|
long kib = audio_buffer_size() >> 10; /* to KiB */
|
||||||
|
@ -253,6 +303,22 @@ static int info_speak_item(int selected_item, void * data)
|
||||||
{
|
{
|
||||||
struct info_data *info = (struct info_data*)data;
|
struct info_data *info = (struct info_data*)data;
|
||||||
|
|
||||||
|
#if CONFIG_RTC
|
||||||
|
struct tm *tm;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (info->new_data)
|
||||||
|
{
|
||||||
|
volume_size(IF_MV(0,) &info->size, &info->free);
|
||||||
|
#ifdef HAVE_MULTIVOLUME
|
||||||
|
if (volume_ismounted(1))
|
||||||
|
volume_size(1, &info->size2, &info->free2);
|
||||||
|
else
|
||||||
|
info->size2 = 0;
|
||||||
|
#endif
|
||||||
|
info->new_data = false;
|
||||||
|
}
|
||||||
|
|
||||||
switch (selected_item)
|
switch (selected_item)
|
||||||
{
|
{
|
||||||
case INFO_VERSION: /* version */
|
case INFO_VERSION: /* version */
|
||||||
|
@ -260,6 +326,58 @@ static int info_speak_item(int selected_item, void * data)
|
||||||
talk_spell(rbversion, true);
|
talk_spell(rbversion, true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
#if CONFIG_RTC
|
||||||
|
case INFO_TIME:
|
||||||
|
tm = get_time();
|
||||||
|
talk_id(VOICE_CURRENT_TIME, false);
|
||||||
|
if (valid_time(tm))
|
||||||
|
{
|
||||||
|
talk_time(tm, true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
talk_id(LANG_UNKNOWN, true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case INFO_DATE:
|
||||||
|
tm = get_time();
|
||||||
|
if (valid_time(tm))
|
||||||
|
{
|
||||||
|
talk_date(get_time(), true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
talk_id(LANG_UNKNOWN, true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_RECORDING
|
||||||
|
case INFO_REC_DIR:
|
||||||
|
talk_id(LANG_REC_DIR, false);
|
||||||
|
if (global_settings.rec_directory && global_settings.rec_directory[0])
|
||||||
|
{
|
||||||
|
long *pathsep = NULL;
|
||||||
|
char rec_directory[MAX_PATHNAME+1];
|
||||||
|
char *s;
|
||||||
|
strcpy(rec_directory, global_settings.rec_directory);
|
||||||
|
s = rec_directory;
|
||||||
|
if ((strlen(s) > 1) && (s[strlen(s) - 1] == '/'))
|
||||||
|
s[strlen(s) - 1] = 0;
|
||||||
|
while (s)
|
||||||
|
{
|
||||||
|
s = strchr(s + 1, '/');
|
||||||
|
if (s)
|
||||||
|
s[0] = 0;
|
||||||
|
talk_dir_or_spell(rec_directory, pathsep, true);
|
||||||
|
if (s)
|
||||||
|
s[0] = '/';
|
||||||
|
pathsep = TALK_IDARRAY(VOICE_CHAR_SLASH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
case INFO_BUFFER: /* buffer */
|
case INFO_BUFFER: /* buffer */
|
||||||
{
|
{
|
||||||
talk_id(LANG_BUFFER_STAT, false);
|
talk_id(LANG_BUFFER_STAT, false);
|
||||||
|
@ -271,22 +389,38 @@ static int info_speak_item(int selected_item, void * data)
|
||||||
#if CONFIG_CHARGING == CHARGING_SIMPLE
|
#if CONFIG_CHARGING == CHARGING_SIMPLE
|
||||||
/* Only know if plugged */
|
/* Only know if plugged */
|
||||||
if (charger_inserted())
|
if (charger_inserted())
|
||||||
|
{
|
||||||
talk_id(LANG_BATTERY_CHARGE, true);
|
talk_id(LANG_BATTERY_CHARGE, true);
|
||||||
|
if (battery_level() >= 0)
|
||||||
|
talk_value(battery_level(), UNIT_PERCENT, true);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
#elif CONFIG_CHARGING >= CHARGING_MONITOR
|
#elif CONFIG_CHARGING >= CHARGING_MONITOR
|
||||||
#ifdef ARCHOS_RECORDER
|
#ifdef ARCHOS_RECORDER
|
||||||
/* Report the particular algorithm state */
|
/* Report the particular algorithm state */
|
||||||
if (charge_state == CHARGING)
|
if (charge_state == CHARGING)
|
||||||
|
{
|
||||||
talk_id(LANG_BATTERY_CHARGE, true);
|
talk_id(LANG_BATTERY_CHARGE, true);
|
||||||
|
if (battery_level() >= 0)
|
||||||
|
talk_value(battery_level(), UNIT_PERCENT, true);
|
||||||
|
}
|
||||||
else if (charge_state == TOPOFF)
|
else if (charge_state == TOPOFF)
|
||||||
talk_id(LANG_BATTERY_TOPOFF_CHARGE, true);
|
talk_id(LANG_BATTERY_TOPOFF_CHARGE, true);
|
||||||
else if (charge_state == TRICKLE)
|
else if (charge_state == TRICKLE)
|
||||||
|
{
|
||||||
talk_id(LANG_BATTERY_TRICKLE_CHARGE, true);
|
talk_id(LANG_BATTERY_TRICKLE_CHARGE, true);
|
||||||
|
if (battery_level() >= 0)
|
||||||
|
talk_value(battery_level(), UNIT_PERCENT, true);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
#else /* !ARCHOS_RECORDER */
|
#else /* !ARCHOS_RECORDER */
|
||||||
/* Go by what power management reports */
|
/* Go by what power management reports */
|
||||||
if (charging_state())
|
if (charging_state())
|
||||||
|
{
|
||||||
talk_id(LANG_BATTERY_CHARGE, true);
|
talk_id(LANG_BATTERY_CHARGE, true);
|
||||||
|
if (battery_level() >= 0)
|
||||||
|
talk_value(battery_level(), UNIT_PERCENT, true);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
#endif /* ARCHOS_RECORDER */
|
#endif /* ARCHOS_RECORDER */
|
||||||
#endif /* CONFIG_CHARGING = */
|
#endif /* CONFIG_CHARGING = */
|
||||||
|
@ -349,12 +483,22 @@ static int info_action_callback(int action, struct gui_synclist *lists)
|
||||||
splash(0, ID2P(LANG_SCANNING_DISK));
|
splash(0, ID2P(LANG_SCANNING_DISK));
|
||||||
for (i = 0; i < NUM_VOLUMES; i++)
|
for (i = 0; i < NUM_VOLUMES; i++)
|
||||||
volume_recalc_free(IF_MV(i));
|
volume_recalc_free(IF_MV(i));
|
||||||
#else
|
|
||||||
(void) lists;
|
|
||||||
#endif
|
#endif
|
||||||
gui_synclist_speak_item(lists);
|
gui_synclist_speak_item(lists);
|
||||||
return ACTION_REDRAW;
|
return ACTION_REDRAW;
|
||||||
}
|
}
|
||||||
|
#if CONFIG_RTC
|
||||||
|
else if (action == ACTION_NONE)
|
||||||
|
{
|
||||||
|
static int last_redraw = 0;
|
||||||
|
if (gui_synclist_item_is_onscreen(lists, 0, INFO_TIME)
|
||||||
|
&& TIME_AFTER(current_tick, last_redraw + HZ*5))
|
||||||
|
{
|
||||||
|
last_redraw = current_tick;
|
||||||
|
return ACTION_REDRAW;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
static int show_info(void)
|
static int show_info(void)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue