diff options
Diffstat (limited to 'apps/menus/main_menu.c')
-rw-r--r-- | apps/menus/main_menu.c | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/apps/menus/main_menu.c b/apps/menus/main_menu.c index 130d0bc2d5..cefc395b3d 100644 --- a/apps/menus/main_menu.c +++ b/apps/menus/main_menu.c | |||
@@ -374,97 +374,11 @@ static bool show_info(void) | |||
374 | MENUITEM_FUNCTION(show_info_item, 0, ID2P(LANG_ROCKBOX_INFO), | 374 | MENUITEM_FUNCTION(show_info_item, 0, ID2P(LANG_ROCKBOX_INFO), |
375 | (menu_function)show_info, NULL, NULL, Icon_NOICON); | 375 | (menu_function)show_info, NULL, NULL, Icon_NOICON); |
376 | 376 | ||
377 | |||
378 | /* sleep Menu */ | ||
379 | const char* sleep_timer_formatter(char* buffer, size_t buffer_size, | ||
380 | int value, const char* unit) | ||
381 | { | ||
382 | (void) unit; | ||
383 | int minutes, hours; | ||
384 | |||
385 | if (value) { | ||
386 | hours = value / 60; | ||
387 | minutes = value - (hours * 60); | ||
388 | snprintf(buffer, buffer_size, "%d:%02d", hours, minutes); | ||
389 | return buffer; | ||
390 | } else { | ||
391 | return str(LANG_OFF); | ||
392 | } | ||
393 | } | ||
394 | |||
395 | static void sleep_timer_set(int minutes) | ||
396 | { | ||
397 | if (minutes) | ||
398 | global_settings.sleeptimer_duration = minutes; | ||
399 | set_sleep_timer(minutes * 60); | ||
400 | } | ||
401 | |||
402 | static int sleep_timer(void) | ||
403 | { | ||
404 | int minutes = global_settings.sleeptimer_duration; | ||
405 | if (get_sleep_timer()) | ||
406 | sleep_timer_set(0); | ||
407 | else | ||
408 | set_int(str(LANG_SLEEP_TIMER), "", UNIT_MIN, &minutes, | ||
409 | &sleep_timer_set, 5, 0, 300, sleep_timer_formatter); | ||
410 | return 0; | ||
411 | } | ||
412 | |||
413 | static int seconds_to_min(int secs) | ||
414 | { | ||
415 | return (secs + 10) / 60; /* round up for 50+ seconds */ | ||
416 | } | ||
417 | |||
418 | static char* sleep_timer_getname(int selected_item, void * data, char *buffer) | ||
419 | { | ||
420 | (void)selected_item; | ||
421 | (void)data; | ||
422 | int sec = get_sleep_timer(); | ||
423 | char timer_buf[10]; | ||
424 | /* we have no sprintf, so MAX_PATH is a guess */ | ||
425 | if (sec > 0) | ||
426 | { /* show cancel and countdown if running */ | ||
427 | snprintf(buffer, MAX_PATH, "%s (%s)", str(LANG_SLEEP_TIMER_CANCEL_CURRENT), | ||
428 | sleep_timer_formatter(timer_buf, sizeof(timer_buf), seconds_to_min(sec), NULL)); | ||
429 | } | ||
430 | else | ||
431 | snprintf(buffer, MAX_PATH, "%s", str(LANG_SLEEP_TIMER)); | ||
432 | |||
433 | return buffer; | ||
434 | } | ||
435 | |||
436 | static int sleep_timer_voice(int selected_item, void*data) | ||
437 | { | ||
438 | (void)selected_item; | ||
439 | (void)data; | ||
440 | int seconds = get_sleep_timer(); | ||
441 | if (seconds > 0) | ||
442 | { | ||
443 | long talk_ids[] = { | ||
444 | LANG_SLEEP_TIMER_CANCEL_CURRENT, | ||
445 | VOICE_PAUSE, | ||
446 | seconds_to_min(seconds) | UNIT_MIN << UNIT_SHIFT, | ||
447 | TALK_FINAL_ID | ||
448 | }; | ||
449 | talk_idarray(talk_ids, true); | ||
450 | } | ||
451 | else | ||
452 | talk_id(LANG_SLEEP_TIMER, true); | ||
453 | return 0; | ||
454 | } | ||
455 | |||
456 | #if CONFIG_RTC | 377 | #if CONFIG_RTC |
457 | int time_screen(void* ignored); | 378 | int time_screen(void* ignored); |
458 | MENUITEM_FUNCTION(timedate_item, MENU_FUNC_CHECK_RETVAL, ID2P(LANG_TIME_MENU), | 379 | MENUITEM_FUNCTION(timedate_item, MENU_FUNC_CHECK_RETVAL, ID2P(LANG_TIME_MENU), |
459 | time_screen, NULL, NULL, Icon_Menu_setting ); | 380 | time_screen, NULL, NULL, Icon_Menu_setting ); |
460 | #endif | 381 | #endif |
461 | MENUITEM_FUNCTION_DYNTEXT(sleep_timer_call, 0, sleep_timer, NULL, sleep_timer_getname, | ||
462 | sleep_timer_voice, NULL, NULL, Icon_Menu_setting); | ||
463 | /* make it look like a setting to the user */ | ||
464 | #if CONFIG_RTC == 0 | ||
465 | MENUITEM_SETTING(sleeptimer_on_startup, | ||
466 | &global_settings.sleeptimer_on_startup, NULL); | ||
467 | #endif | ||
468 | 382 | ||
469 | MENUITEM_FUNCTION(show_credits_item, 0, ID2P(LANG_CREDITS), | 383 | MENUITEM_FUNCTION(show_credits_item, 0, ID2P(LANG_CREDITS), |
470 | (menu_function)show_credits, NULL, NULL, Icon_NOICON); | 384 | (menu_function)show_credits, NULL, NULL, Icon_NOICON); |
@@ -511,8 +425,6 @@ MAKE_MENU(main_menu_, ID2P(LANG_SETTINGS), mainmenu_callback, | |||
511 | #endif | 425 | #endif |
512 | #if CONFIG_RTC | 426 | #if CONFIG_RTC |
513 | &timedate_item, | 427 | &timedate_item, |
514 | #else | ||
515 | &sleep_timer_call, &sleeptimer_on_startup, | ||
516 | #endif | 428 | #endif |
517 | &manage_settings, | 429 | &manage_settings, |
518 | ); | 430 | ); |