summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/main_menu.c9
-rw-r--r--apps/screens.c2
-rw-r--r--firmware/export/powermgmt.h1
-rw-r--r--firmware/powermgmt.c17
4 files changed, 21 insertions, 8 deletions
diff --git a/apps/main_menu.c b/apps/main_menu.c
index 68d6699cd5..87518cff28 100644
--- a/apps/main_menu.c
+++ b/apps/main_menu.c
@@ -361,6 +361,13 @@ bool info_menu(void)
361 return result; 361 return result;
362} 362}
363 363
364#ifdef HAVE_LCD_CHARCELLS
365static void do_shutdown(void)
366{
367 sys_poweroff(false);
368}
369#endif
370
364bool main_menu(void) 371bool main_menu(void)
365{ 372{
366 int m; 373 int m;
@@ -405,7 +412,7 @@ bool main_menu(void)
405 412
406#ifdef HAVE_LCD_CHARCELLS 413#ifdef HAVE_LCD_CHARCELLS
407 items[i].desc = ID2P(LANG_SHUTDOWN); 414 items[i].desc = ID2P(LANG_SHUTDOWN);
408 items[i++].function = clean_shutdown; 415 items[i++].function = do_shutdown;
409#endif 416#endif
410 417
411 m=menu_init( items, i, NULL, NULL, NULL, NULL ); 418 m=menu_init( items, i, NULL, NULL, NULL, NULL );
diff --git a/apps/screens.c b/apps/screens.c
index e188d341d8..6d9b299c54 100644
--- a/apps/screens.c
+++ b/apps/screens.c
@@ -1253,7 +1253,7 @@ bool shutdown_screen(void)
1253 switch(button) 1253 switch(button)
1254 { 1254 {
1255 case BUTTON_OFF: 1255 case BUTTON_OFF:
1256 clean_shutdown(); 1256 sys_poweroff(false);
1257 break; 1257 break;
1258 1258
1259 default: 1259 default:
diff --git a/firmware/export/powermgmt.h b/firmware/export/powermgmt.h
index 29ef9eba95..e32867a188 100644
--- a/firmware/export/powermgmt.h
+++ b/firmware/export/powermgmt.h
@@ -130,5 +130,6 @@ int get_sleep_timer(void);
130void set_car_adapter_mode(bool setting); 130void set_car_adapter_mode(bool setting);
131void reset_poweroff_timer(void); 131void reset_poweroff_timer(void);
132void shutdown_hw(void); 132void shutdown_hw(void);
133void sys_poweroff(bool halt);
133 134
134#endif 135#endif
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c
index 519785f9c6..fdc77f680b 100644
--- a/firmware/powermgmt.c
+++ b/firmware/powermgmt.c
@@ -44,6 +44,7 @@
44#ifdef HAVE_UDA1380 44#ifdef HAVE_UDA1380
45#include "uda1380.h" 45#include "uda1380.h"
46#endif 46#endif
47#include "logf.h"
47 48
48/* 49/*
49 * Define DEBUG_FILE to create a csv (spreadsheet) with battery information 50 * Define DEBUG_FILE to create a csv (spreadsheet) with battery information
@@ -389,7 +390,7 @@ static void handle_auto_poweroff(void)
389 if(TIME_AFTER(current_tick, last_event_tick + timeout) && 390 if(TIME_AFTER(current_tick, last_event_tick + timeout) &&
390 TIME_AFTER(current_tick, last_disk_activity + timeout)) 391 TIME_AFTER(current_tick, last_disk_activity + timeout))
391 { 392 {
392 shutdown_hw(); 393 sys_poweroff(true);
393 } 394 }
394 } 395 }
395 else 396 else
@@ -412,11 +413,7 @@ static void handle_auto_poweroff(void)
412#endif 413#endif
413 { 414 {
414 DEBUGF("Sleep timer timeout. Shutting off...\n"); 415 DEBUGF("Sleep timer timeout. Shutting off...\n");
415 /* Make sure that the disk isn't spinning when 416 sys_poweroff(true);
416 we cut the power */
417 while(ata_disk_is_active())
418 sleep(HZ);
419 shutdown_hw();
420 } 417 }
421 } 418 }
422 } 419 }
@@ -877,6 +874,14 @@ void powermgmt_init(void)
877 874
878#endif /* SIMULATOR */ 875#endif /* SIMULATOR */
879 876
877void sys_poweroff(bool halt)
878{
879 logf("sys_poweroff(%d)", halt);
880 queue_post(&button_queue, SYS_POWEROFF, NULL);
881 while(halt)
882 yield();
883}
884
880/* Various hardware housekeeping tasks relating to shutting down the jukebox */ 885/* Various hardware housekeeping tasks relating to shutting down the jukebox */
881void shutdown_hw(void) 886void shutdown_hw(void)
882{ 887{