diff options
Diffstat (limited to 'apps/menus')
-rw-r--r-- | apps/menus/exported_menus.h | 1 | ||||
-rw-r--r-- | apps/menus/main_menu.c | 88 | ||||
-rw-r--r-- | apps/menus/settings_menu.c | 109 | ||||
-rw-r--r-- | apps/menus/time_menu.c | 8 |
4 files changed, 105 insertions, 101 deletions
diff --git a/apps/menus/exported_menus.h b/apps/menus/exported_menus.h index c439af1479..568791b1f0 100644 --- a/apps/menus/exported_menus.h +++ b/apps/menus/exported_menus.h | |||
@@ -38,7 +38,6 @@ extern const struct menu_item_ex | |||
38 | sound_settings, /* sound_menu.c */ | 38 | sound_settings, /* sound_menu.c */ |
39 | settings_menu_item, /* settings_menu.c */ | 39 | settings_menu_item, /* settings_menu.c */ |
40 | bookmark_settings_menu, | 40 | bookmark_settings_menu, |
41 | sleep_timer_call, /* main_menu.c */ | ||
42 | playlist_settings, /* playlist_menu.c */ | 41 | playlist_settings, /* playlist_menu.c */ |
43 | equalizer_menu, /* eq_menu.c */ | 42 | equalizer_menu, /* eq_menu.c */ |
44 | #ifdef AUDIOHW_HAVE_EQ | 43 | #ifdef AUDIOHW_HAVE_EQ |
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 | ); |
diff --git a/apps/menus/settings_menu.c b/apps/menus/settings_menu.c index bcb182ebca..cce5dd751d 100644 --- a/apps/menus/settings_menu.c +++ b/apps/menus/settings_menu.c | |||
@@ -215,9 +215,6 @@ MAKE_MENU(disk_menu, ID2P(LANG_DISK_MENU), 0, Icon_NOICON, | |||
215 | ); | 215 | ); |
216 | #endif | 216 | #endif |
217 | 217 | ||
218 | /* System menu */ | ||
219 | MENUITEM_SETTING(poweroff, &global_settings.poweroff, NULL); | ||
220 | |||
221 | /* Limits menu */ | 218 | /* Limits menu */ |
222 | MENUITEM_SETTING(max_files_in_dir, &global_settings.max_files_in_dir, NULL); | 219 | MENUITEM_SETTING(max_files_in_dir, &global_settings.max_files_in_dir, NULL); |
223 | MENUITEM_SETTING(max_files_in_playlist, &global_settings.max_files_in_playlist, NULL); | 220 | MENUITEM_SETTING(max_files_in_playlist, &global_settings.max_files_in_playlist, NULL); |
@@ -276,7 +273,6 @@ MENUITEM_SETTING(accessory_supply, &global_settings.accessory_supply, NULL); | |||
276 | #ifdef HAVE_LINEOUT_POWEROFF | 273 | #ifdef HAVE_LINEOUT_POWEROFF |
277 | MENUITEM_SETTING(lineout_onoff, &global_settings.lineout_active, NULL); | 274 | MENUITEM_SETTING(lineout_onoff, &global_settings.lineout_active, NULL); |
278 | #endif | 275 | #endif |
279 | MENUITEM_SETTING(start_screen, &global_settings.start_in_screen, NULL); | ||
280 | #ifdef USB_ENABLE_HID | 276 | #ifdef USB_ENABLE_HID |
281 | MENUITEM_SETTING(usb_hid, &global_settings.usb_hid, NULL); | 277 | MENUITEM_SETTING(usb_hid, &global_settings.usb_hid, NULL); |
282 | MENUITEM_SETTING(usb_keypad_mode, &global_settings.usb_keypad_mode, NULL); | 278 | MENUITEM_SETTING(usb_keypad_mode, &global_settings.usb_keypad_mode, NULL); |
@@ -303,14 +299,12 @@ MENUITEM_SETTING(touchpad_sensitivity, &global_settings.touchpad_sensitivity, NU | |||
303 | 299 | ||
304 | MAKE_MENU(system_menu, ID2P(LANG_SYSTEM), | 300 | MAKE_MENU(system_menu, ID2P(LANG_SYSTEM), |
305 | 0, Icon_System_menu, | 301 | 0, Icon_System_menu, |
306 | &start_screen, | ||
307 | #if (BATTERY_CAPACITY_INC > 0) || (BATTERY_TYPES_COUNT > 1) | 302 | #if (BATTERY_CAPACITY_INC > 0) || (BATTERY_TYPES_COUNT > 1) |
308 | &battery_menu, | 303 | &battery_menu, |
309 | #endif | 304 | #endif |
310 | #if defined(HAVE_DIRCACHE) || defined(HAVE_DISK_STORAGE) | 305 | #if defined(HAVE_DIRCACHE) || defined(HAVE_DISK_STORAGE) |
311 | &disk_menu, | 306 | &disk_menu, |
312 | #endif | 307 | #endif |
313 | &poweroff, | ||
314 | &limits_menu, | 308 | &limits_menu, |
315 | #ifdef HAVE_MORSE_INPUT | 309 | #ifdef HAVE_MORSE_INPUT |
316 | &morse_input, | 310 | &morse_input, |
@@ -354,6 +348,108 @@ MAKE_MENU(system_menu, ID2P(LANG_SYSTEM), | |||
354 | /* SYSTEM MENU */ | 348 | /* SYSTEM MENU */ |
355 | /***********************************/ | 349 | /***********************************/ |
356 | 350 | ||
351 | /***********************************/ | ||
352 | /* STARTUP/SHUTDOWN MENU */ | ||
353 | |||
354 | /* sleep timer option */ | ||
355 | const char* sleep_timer_formatter(char* buffer, size_t buffer_size, | ||
356 | int value, const char* unit) | ||
357 | { | ||
358 | (void) unit; | ||
359 | int minutes, hours; | ||
360 | |||
361 | if (value) { | ||
362 | hours = value / 60; | ||
363 | minutes = value - (hours * 60); | ||
364 | snprintf(buffer, buffer_size, "%d:%02d", hours, minutes); | ||
365 | return buffer; | ||
366 | } else { | ||
367 | return str(LANG_OFF); | ||
368 | } | ||
369 | } | ||
370 | |||
371 | static void sleep_timer_set(int minutes) | ||
372 | { | ||
373 | if (minutes) | ||
374 | global_settings.sleeptimer_duration = minutes; | ||
375 | set_sleep_timer(minutes * 60); | ||
376 | } | ||
377 | |||
378 | static int sleep_timer(void) | ||
379 | { | ||
380 | int minutes = global_settings.sleeptimer_duration; | ||
381 | if (get_sleep_timer()) | ||
382 | sleep_timer_set(0); | ||
383 | else | ||
384 | set_int(str(LANG_SLEEP_TIMER), "", UNIT_MIN, &minutes, | ||
385 | &sleep_timer_set, 5, 0, 300, sleep_timer_formatter); | ||
386 | return 0; | ||
387 | } | ||
388 | |||
389 | static int seconds_to_min(int secs) | ||
390 | { | ||
391 | return (secs + 10) / 60; /* round up for 50+ seconds */ | ||
392 | } | ||
393 | |||
394 | static char* sleep_timer_getname(int selected_item, void * data, char *buffer) | ||
395 | { | ||
396 | (void)selected_item; | ||
397 | (void)data; | ||
398 | int sec = get_sleep_timer(); | ||
399 | char timer_buf[10]; | ||
400 | /* we have no sprintf, so MAX_PATH is a guess */ | ||
401 | if (sec > 0) | ||
402 | { /* show cancel and countdown if running */ | ||
403 | snprintf(buffer, MAX_PATH, "%s (%s)", | ||
404 | str(LANG_SLEEP_TIMER_CANCEL_CURRENT), | ||
405 | sleep_timer_formatter(timer_buf, sizeof(timer_buf), | ||
406 | seconds_to_min(sec), NULL)); | ||
407 | } | ||
408 | else | ||
409 | snprintf(buffer, MAX_PATH, "%s", str(LANG_SLEEP_TIMER)); | ||
410 | |||
411 | return buffer; | ||
412 | } | ||
413 | |||
414 | static int sleep_timer_voice(int selected_item, void*data) | ||
415 | { | ||
416 | (void)selected_item; | ||
417 | (void)data; | ||
418 | int seconds = get_sleep_timer(); | ||
419 | if (seconds > 0) | ||
420 | { | ||
421 | long talk_ids[] = { | ||
422 | LANG_SLEEP_TIMER_CANCEL_CURRENT, | ||
423 | VOICE_PAUSE, | ||
424 | seconds_to_min(seconds) | UNIT_MIN << UNIT_SHIFT, | ||
425 | TALK_FINAL_ID | ||
426 | }; | ||
427 | talk_idarray(talk_ids, true); | ||
428 | } | ||
429 | else | ||
430 | talk_id(LANG_SLEEP_TIMER, true); | ||
431 | return 0; | ||
432 | } | ||
433 | |||
434 | MENUITEM_SETTING(start_screen, &global_settings.start_in_screen, NULL); | ||
435 | MENUITEM_SETTING(poweroff, &global_settings.poweroff, NULL); | ||
436 | MENUITEM_FUNCTION_DYNTEXT(sleep_timer_call, 0, sleep_timer, NULL, | ||
437 | sleep_timer_getname, sleep_timer_voice, NULL, NULL, | ||
438 | Icon_Menu_setting); | ||
439 | /* make it look like a setting to the user */ | ||
440 | MENUITEM_SETTING(sleeptimer_on_startup, | ||
441 | &global_settings.sleeptimer_on_startup, NULL); | ||
442 | |||
443 | MAKE_MENU(startup_shutdown_menu, ID2P(LANG_STARTUP_SHUTDOWN), | ||
444 | 0, Icon_System_menu, | ||
445 | &start_screen, | ||
446 | &poweroff, | ||
447 | &sleep_timer_call, | ||
448 | &sleeptimer_on_startup | ||
449 | ); | ||
450 | |||
451 | /* STARTUP/SHUTDOWN MENU */ | ||
452 | /***********************************/ | ||
357 | 453 | ||
358 | /***********************************/ | 454 | /***********************************/ |
359 | /* BOOKMARK MENU */ | 455 | /* BOOKMARK MENU */ |
@@ -513,6 +609,7 @@ MAKE_MENU(settings_menu_item, ID2P(LANG_GENERAL_SETTINGS), 0, | |||
513 | &tagcache_menu, | 609 | &tagcache_menu, |
514 | #endif | 610 | #endif |
515 | &display_menu, &system_menu, | 611 | &display_menu, &system_menu, |
612 | &startup_shutdown_menu, | ||
516 | &bookmark_settings_menu, | 613 | &bookmark_settings_menu, |
517 | #ifdef HAVE_TAGCACHE | 614 | #ifdef HAVE_TAGCACHE |
518 | #if CONFIG_CODEC == SWCODEC | 615 | #if CONFIG_CODEC == SWCODEC |
diff --git a/apps/menus/time_menu.c b/apps/menus/time_menu.c index a793809800..1eb4bd68cc 100644 --- a/apps/menus/time_menu.c +++ b/apps/menus/time_menu.c | |||
@@ -28,10 +28,8 @@ | |||
28 | #include "lang.h" | 28 | #include "lang.h" |
29 | #include "action.h" | 29 | #include "action.h" |
30 | #include "settings.h" | 30 | #include "settings.h" |
31 | #include "powermgmt.h" | ||
32 | #include "menu.h" | 31 | #include "menu.h" |
33 | #include "misc.h" | 32 | #include "misc.h" |
34 | #include "exported_menus.h" | ||
35 | #include "keyboard.h" | 33 | #include "keyboard.h" |
36 | #include "talk.h" | 34 | #include "talk.h" |
37 | #include "time.h" | 35 | #include "time.h" |
@@ -136,8 +134,6 @@ MENUITEM_FUNCTION(alarm_wake_up_screen, 0, ID2P(LANG_ALARM_WAKEUP_SCREEN), | |||
136 | #endif /* CONFIG_TUNER || defined(HAVE_RECORDING) */ | 134 | #endif /* CONFIG_TUNER || defined(HAVE_RECORDING) */ |
137 | 135 | ||
138 | #endif /* HAVE_RTC_ALARM */ | 136 | #endif /* HAVE_RTC_ALARM */ |
139 | MENUITEM_SETTING(sleeptimer_on_startup, | ||
140 | &global_settings.sleeptimer_on_startup, NULL); | ||
141 | 137 | ||
142 | void talk_timedate(void) | 138 | void talk_timedate(void) |
143 | { | 139 | { |
@@ -237,14 +233,14 @@ static int time_menu_callback(int action, | |||
237 | 233 | ||
238 | 234 | ||
239 | MAKE_MENU(time_menu, ID2P(LANG_TIME_MENU), time_menu_callback, Icon_NOICON, | 235 | MAKE_MENU(time_menu, ID2P(LANG_TIME_MENU), time_menu_callback, Icon_NOICON, |
240 | &time_set, &sleep_timer_call, | 236 | &time_set, |
241 | #ifdef HAVE_RTC_ALARM | 237 | #ifdef HAVE_RTC_ALARM |
242 | &alarm_screen_call, | 238 | &alarm_screen_call, |
243 | #if defined(HAVE_RECORDING) || CONFIG_TUNER | 239 | #if defined(HAVE_RECORDING) || CONFIG_TUNER |
244 | &alarm_wake_up_screen, | 240 | &alarm_wake_up_screen, |
245 | #endif | 241 | #endif |
246 | #endif | 242 | #endif |
247 | &sleeptimer_on_startup, &timeformat); | 243 | &timeformat); |
248 | 244 | ||
249 | int time_screen(void* ignored) | 245 | int time_screen(void* ignored) |
250 | { | 246 | { |