diff options
Diffstat (limited to 'apps/screens.c')
-rw-r--r-- | apps/screens.c | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/apps/screens.c b/apps/screens.c index 032fd0b60d..5cc3cc15ec 100644 --- a/apps/screens.c +++ b/apps/screens.c | |||
@@ -56,6 +56,7 @@ | |||
56 | #include "quickscreen.h" | 56 | #include "quickscreen.h" |
57 | #include "pcmbuf.h" | 57 | #include "pcmbuf.h" |
58 | #include "list.h" | 58 | #include "list.h" |
59 | #include "yesno.h" | ||
59 | 60 | ||
60 | #ifdef HAVE_LCD_BITMAP | 61 | #ifdef HAVE_LCD_BITMAP |
61 | #include <bitmaps/usblogo.h> | 62 | #include <bitmaps/usblogo.h> |
@@ -1300,3 +1301,98 @@ bool set_rating(void) | |||
1300 | action_signalscreenchange(); | 1301 | action_signalscreenchange(); |
1301 | return false; | 1302 | return false; |
1302 | } | 1303 | } |
1304 | |||
1305 | |||
1306 | bool view_runtime(void) | ||
1307 | { | ||
1308 | char s[32]; | ||
1309 | bool done = false; | ||
1310 | int state = 1; | ||
1311 | int i; | ||
1312 | int key; | ||
1313 | unsigned char *lines[]={str(LANG_CLEAR_TIME)}; | ||
1314 | struct text_message message={(char **)lines, 1}; | ||
1315 | |||
1316 | while(!done) | ||
1317 | { | ||
1318 | int y[NB_SCREENS]={0}; | ||
1319 | int t; | ||
1320 | |||
1321 | FOR_NB_SCREENS(i) | ||
1322 | { | ||
1323 | screens[i].clear_display(); | ||
1324 | #ifdef HAVE_LCD_BITMAP | ||
1325 | if (screens[i].nb_lines >4) | ||
1326 | { | ||
1327 | screens[i].puts(0, y[i]++, str(LANG_RUNNING_TIME)); | ||
1328 | } | ||
1329 | #endif | ||
1330 | } | ||
1331 | |||
1332 | if (state & 1) { | ||
1333 | #ifdef CONFIG_CHARGING | ||
1334 | if (charger_inserted() | ||
1335 | #ifdef HAVE_USB_POWER | ||
1336 | || usb_powered() | ||
1337 | #endif | ||
1338 | ) | ||
1339 | { | ||
1340 | global_settings.runtime = 0; | ||
1341 | } | ||
1342 | else | ||
1343 | #endif | ||
1344 | { | ||
1345 | global_settings.runtime += ((current_tick - lasttime) / HZ); | ||
1346 | } | ||
1347 | lasttime = current_tick; | ||
1348 | |||
1349 | t = global_settings.runtime; | ||
1350 | FOR_NB_SCREENS(i) | ||
1351 | screens[i].puts(0, y[i]++, str(LANG_CURRENT_TIME)); | ||
1352 | } | ||
1353 | else { | ||
1354 | t = global_settings.topruntime; | ||
1355 | FOR_NB_SCREENS(i) | ||
1356 | screens[i].puts(0, y[i]++, str(LANG_TOP_TIME)); | ||
1357 | } | ||
1358 | snprintf(s, sizeof(s), "%dh %dm %ds", | ||
1359 | t / 3600, (t % 3600) / 60, t % 60); | ||
1360 | gui_syncstatusbar_draw(&statusbars, true); | ||
1361 | FOR_NB_SCREENS(i) | ||
1362 | { | ||
1363 | screens[i].puts(0, y[i]++, s); | ||
1364 | #if defined(HAVE_LCD_BITMAP) | ||
1365 | screens[i].update(); | ||
1366 | #endif | ||
1367 | } | ||
1368 | |||
1369 | /* Wait for a key to be pushed */ | ||
1370 | key = get_action(CONTEXT_STD,HZ); | ||
1371 | switch(key) { | ||
1372 | case ACTION_STD_CANCEL: | ||
1373 | done = true; | ||
1374 | break; | ||
1375 | |||
1376 | case ACTION_STD_NEXT: | ||
1377 | case ACTION_STD_PREV: | ||
1378 | state = (state==1)?2:1; | ||
1379 | break; | ||
1380 | |||
1381 | case ACTION_STD_OK: | ||
1382 | if(gui_syncyesno_run(&message, NULL, NULL)==YESNO_YES) | ||
1383 | { | ||
1384 | if ( state == 1 ) | ||
1385 | global_settings.runtime = 0; | ||
1386 | else | ||
1387 | global_settings.topruntime = 0; | ||
1388 | } | ||
1389 | break; | ||
1390 | default: | ||
1391 | if(default_event_handler(key) == SYS_USB_CONNECTED) | ||
1392 | return true; | ||
1393 | break; | ||
1394 | } | ||
1395 | } | ||
1396 | action_signalscreenchange(); | ||
1397 | return false; | ||
1398 | } | ||