diff options
Diffstat (limited to 'apps/menus/main_menu.c')
-rw-r--r-- | apps/menus/main_menu.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/apps/menus/main_menu.c b/apps/menus/main_menu.c index d986436311..d8b471889e 100644 --- a/apps/menus/main_menu.c +++ b/apps/menus/main_menu.c | |||
@@ -341,6 +341,40 @@ static bool show_info(void) | |||
341 | } | 341 | } |
342 | MENUITEM_FUNCTION(show_info_item, ID2P(LANG_INFO_MENU), | 342 | MENUITEM_FUNCTION(show_info_item, ID2P(LANG_INFO_MENU), |
343 | (menu_function)show_info, NULL, NOICON); | 343 | (menu_function)show_info, NULL, NOICON); |
344 | |||
345 | |||
346 | /* sleep Menu */ | ||
347 | static void sleep_timer_formatter(char* buffer, int buffer_size, int value, | ||
348 | const char* unit) | ||
349 | { | ||
350 | int minutes, hours; | ||
351 | |||
352 | (void) unit; | ||
353 | |||
354 | if (value) { | ||
355 | hours = value / 60; | ||
356 | minutes = value - (hours * 60); | ||
357 | snprintf(buffer, buffer_size, "%d:%02d", hours, minutes); | ||
358 | } else { | ||
359 | snprintf(buffer, buffer_size, "%s", str(LANG_OFF)); | ||
360 | } | ||
361 | } | ||
362 | |||
363 | static void sleep_timer_set(int minutes) | ||
364 | { | ||
365 | set_sleep_timer(minutes * 60); | ||
366 | } | ||
367 | |||
368 | static int sleep_timer(void) | ||
369 | { | ||
370 | int minutes = (get_sleep_timer() + 59) / 60; /* round up */ | ||
371 | return (int)set_int(str(LANG_SLEEP_TIMER), "", UNIT_MIN, &minutes, | ||
372 | &sleep_timer_set, -5, 300, 0, sleep_timer_formatter); | ||
373 | } | ||
374 | |||
375 | MENUITEM_FUNCTION(sleep_timer_call, ID2P(LANG_SLEEP_TIMER), sleep_timer, | ||
376 | NULL, bitmap_icons_6x8[Icon_Menu_setting]); /* make it look like a | ||
377 | setting to the user */ | ||
344 | MENUITEM_FUNCTION(show_credits_item, ID2P(LANG_VERSION), | 378 | MENUITEM_FUNCTION(show_credits_item, ID2P(LANG_VERSION), |
345 | (menu_function)show_credits, NULL, NOICON); | 379 | (menu_function)show_credits, NULL, NOICON); |
346 | MENUITEM_FUNCTION(show_runtime_item, ID2P(LANG_RUNNING_TIME), | 380 | MENUITEM_FUNCTION(show_runtime_item, ID2P(LANG_RUNNING_TIME), |
@@ -359,7 +393,8 @@ MENUITEM_FUNCTION(logfdump_item, "logfdump",(int (*)(void)) logfdump, NULL, NOIC | |||
359 | #endif | 393 | #endif |
360 | 394 | ||
361 | MAKE_MENU(info_menu, ID2P(LANG_INFO), 0, bitmap_icons_6x8[Icon_Questionmark], | 395 | MAKE_MENU(info_menu, ID2P(LANG_INFO), 0, bitmap_icons_6x8[Icon_Questionmark], |
362 | &show_info_item, &show_credits_item, &show_runtime_item, | 396 | &show_info_item, &show_credits_item, &show_runtime_item, |
397 | &sleep_timer_call, | ||
363 | #ifndef SIMULATOR | 398 | #ifndef SIMULATOR |
364 | &debug_menu_item | 399 | &debug_menu_item |
365 | #else | 400 | #else |