1
0
Fork 0
forked from len0rd/rockbox

make the runtime view nicer.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13100 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Dominik Riebeling 2007-04-10 20:56:15 +00:00
parent 851ffe5528
commit 339d812062

View file

@ -1255,103 +1255,74 @@ bool browse_id3(void)
} }
} }
static char* runtime_get_data(int selected_item, void* data, char* buffer)
{
(void) data;
unsigned char *headers[] = {str(LANG_RUNNING_TIME), str(LANG_TOP_TIME) };
int t;
if(!(selected_item%2))
return headers[selected_item/2];
if(selected_item/2) t = global_status.topruntime;
else t = global_status.runtime;
snprintf(buffer, 16, "%dh %dm %ds",
t / 3600, (t % 3600) / 60, t % 60);
return buffer;
}
bool view_runtime(void) bool view_runtime(void)
{ {
char s[32];
bool done = false;
int state = 1;
int i;
int key;
unsigned char *lines[]={str(LANG_CLEAR_TIME)}; unsigned char *lines[]={str(LANG_CLEAR_TIME)};
struct text_message message={(char **)lines, 1}; struct text_message message={(char **)lines, 1};
#if defined(HAVE_LCD_BITMAP) struct gui_synclist lists;
FOR_NB_SCREENS(i) int action;
{ gui_synclist_init(&lists, runtime_get_data, NULL, false, 2);
if(global_settings.statusbar) #if !defined(HAVE_LCD_CHARCELLS)
screens[i].setmargins(0, STATUSBAR_HEIGHT); gui_synclist_set_title(&lists, str(LANG_RUNNING_TIME), NOICON);
else #else
screens[i].setmargins(0, 0); gui_synclist_set_title(&lists, NULL, NOICON);
}
#endif #endif
while(!done) gui_synclist_set_icon_callback(&lists, NULL);
gui_synclist_set_nb_items(&lists, 4);
action_signalscreenchange();
while(1)
{ {
int y[NB_SCREENS]={0};
int t;
FOR_NB_SCREENS(i)
{
screens[i].clear_display();
#ifdef HAVE_LCD_BITMAP
if (screens[i].nb_lines >4)
{
screens[i].puts(0, y[i]++, str(LANG_RUNNING_TIME));
}
#endif
}
if (state & 1) {
#if CONFIG_CHARGING #if CONFIG_CHARGING
if (charger_inserted() if (charger_inserted()
#ifdef HAVE_USB_POWER #ifdef HAVE_USB_POWER
|| usb_powered() || usb_powered()
#endif #endif
) )
{
global_status.runtime = 0;
}
else
#endif
{
global_status.runtime += ((current_tick - lasttime) / HZ);
}
lasttime = current_tick;
t = global_status.runtime;
FOR_NB_SCREENS(i)
screens[i].puts(0, y[i]++, str(LANG_CURRENT_TIME));
}
else {
t = global_status.topruntime;
FOR_NB_SCREENS(i)
screens[i].puts(0, y[i]++, str(LANG_TOP_TIME));
}
snprintf(s, sizeof(s), "%dh %dm %ds",
t / 3600, (t % 3600) / 60, t % 60);
gui_syncstatusbar_draw(&statusbars, true);
FOR_NB_SCREENS(i)
{ {
screens[i].puts(0, y[i]++, s); global_status.runtime = 0;
screens[i].update();
} }
else
/* Wait for a key to be pushed */ #endif
key = get_action(CONTEXT_STD,HZ); {
switch(key) { global_status.runtime += ((current_tick - lasttime) / HZ);
case ACTION_STD_CANCEL: }
done = true; lasttime = current_tick;
break; gui_synclist_draw(&lists);
gui_syncstatusbar_draw(&statusbars, true);
case ACTION_STD_NEXT: action = get_action(CONTEXT_STD, HZ);
case ACTION_STD_PREV: gui_synclist_do_button(&lists, action, LIST_WRAP_UNLESS_HELD);
state = (state==1)?2:1; if(action == ACTION_STD_CANCEL)
break; break;
if(action == ACTION_STD_OK) {
case ACTION_STD_OK: if(gui_syncyesno_run(&message, NULL, NULL)==YESNO_YES)
if(gui_syncyesno_run(&message, NULL, NULL)==YESNO_YES) {
{ if (!(gui_synclist_get_sel_pos(&lists)/2))
if ( state == 1 ) global_status.runtime = 0;
global_status.runtime = 0; else
else global_status.topruntime = 0;
global_status.topruntime = 0; }
}
break;
default:
if(default_event_handler(key) == SYS_USB_CONNECTED)
return true;
break;
} }
} }
action_signalscreenchange(); action_signalscreenchange();
return false; return false;
} }