1
0
Fork 0
forked from len0rd/rockbox

Added two simple battery runtime meters (current + top). 'Current' resets automatically when the charger cable is connected, or manually by pressing PLAY in the viewer. We are now officially out of RTC space.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2897 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Björn Stenberg 2002-12-02 16:07:56 +00:00
parent 7249c8807c
commit ae22de285e
3 changed files with 113 additions and 2 deletions

View file

@ -38,6 +38,7 @@
#include "font.h"
#include "disk.h"
#include "mpeg.h"
#include "settings.h"
#ifdef HAVE_LCD_BITMAP
#include "widgets.h"
#include "peakmeter.h"
@ -1005,6 +1006,80 @@ bool dbg_mas_info(void)
}
#endif
static bool view_runtime(void)
{
char s[32];
bool done = false;
int state = 1;
while(!done)
{
int y=0;
int t;
int key;
lcd_clear_display();
#ifdef HAVE_LCD_BITMAP
lcd_puts(0, y++, "Running time:");
y++;
#endif
if (state & 1) {
t = global_settings.runtime;
lcd_puts(0, y++, "Current time");
}
else {
t = global_settings.topruntime;
lcd_puts(0, y++, "Top time");
}
snprintf(s, sizeof(s), "%dh %dm %ds",
t / 3600, (t % 3600) / 60, t % 60);
lcd_puts(0, y++, s);
lcd_update();
/* Wait for a key to be pushed */
key = button_get_w_tmo(HZ*5);
switch(key) {
#ifdef HAVE_PLAYER_KEYPAD
case BUTTON_STOP | BUTTON_REL:
#else
case BUTTON_OFF | BUTTON_REL:
#endif
done = true;
break;
case BUTTON_LEFT:
case BUTTON_RIGHT:
if (state == 1)
state = 2;
else
state = 1;
break;
case BUTTON_PLAY:
lcd_clear_display();
lcd_puts(0,0,"Clear time?");
lcd_puts(0,1,"PLAY = Yes");
lcd_update();
while (1) {
key = button_get_w_tmo(HZ*10);
if ( key & BUTTON_REL )
continue;
if ( key == BUTTON_PLAY ) {
if ( state == 1 )
global_settings.runtime = 0;
else
global_settings.topruntime = 0;
}
break;
}
break;
}
}
return false;
}
bool debug_menu(void)
{
int m;
@ -1036,6 +1111,7 @@ bool debug_menu(void)
{ "pm histogram", peak_meter_histogram},
#endif /* PM_DEBUG */
#endif /* HAVE_LCD_BITMAP */
{ "View runtime", view_runtime },
};
m=menu_init( items, sizeof items / sizeof(struct menu_items) );