diff options
| -rw-r--r-- | apps/misc.c | 5 | ||||
| -rw-r--r-- | apps/tree.c | 26 | ||||
| -rw-r--r-- | firmware/drivers/button.c | 11 | ||||
| -rw-r--r-- | firmware/export/config-fmrecorder.h | 3 | ||||
| -rw-r--r-- | firmware/export/config-ondiofm.h | 3 | ||||
| -rw-r--r-- | firmware/export/config-ondiosp.h | 3 |
6 files changed, 35 insertions, 16 deletions
diff --git a/apps/misc.c b/apps/misc.c index 96d23a8..5be6264 100644 --- a/apps/misc.c +++ b/apps/misc.c @@ -217,6 +217,7 @@ bool clean_shutdown(void) { lcd_clear_display(); splash(0, true, str(LANG_SHUTTINGDOWN)); + sleep(HZ); mpeg_stop(); ata_flush(); ata_spindown(1); @@ -239,6 +240,10 @@ int default_event_handler(int event) #endif usb_screen(); return SYS_USB_CONNECTED; + case SYS_POWEROFF: + if (!clean_shutdown()) + return SYS_POWEROFF; + break; } return 0; } diff --git a/apps/tree.c b/apps/tree.c index 1a92dfd..03c7d2c 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -946,21 +946,25 @@ static bool dirbrowse(const char *root, const int *dirfilter) break; #ifdef TREE_OFF +#ifndef HAVE_SW_POWEROFF case TREE_OFF: - /* Stop the music if it is playing, else show the shutdown - screen */ - if(mpeg_status()) - mpeg_stop(); - else { - if (!charger_inserted()) { - shutdown_screen(); - } else { - charging_splash(); + if (*dirfilter < NUM_FILTER_MODES) + { + /* Stop the music if it is playing, else show the shutdown + screen */ + if(mpeg_status()) + mpeg_stop(); + else { + if (!charger_inserted()) { + shutdown_screen(); + } else { + charging_splash(); + } + restore = true; } - restore = true; } break; - +#endif case TREE_OFF | BUTTON_REPEAT: if (charger_inserted()) { charging_splash(); diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c index 607e72e..0cfe1d1 100644 --- a/firmware/drivers/button.c +++ b/firmware/drivers/button.c @@ -54,7 +54,7 @@ static bool flipped; /* bottons can be flipped to match the LCD flip */ #define REPEAT_INTERVAL_FINISH 5 /* Number of repeated keys before shutting off */ -#define POWEROFF_COUNT 40 +#define POWEROFF_COUNT 10 static int button_read(void); @@ -116,12 +116,13 @@ static void button_tick(void) repeat_count++; - /* Shutdown if we have a device which doesn't shut - down easily with the OFF key */ -#ifdef HAVE_POWEROFF_ON_PB5 + /* Send a SYS_POWEROFF event if we have a device + which doesn't shut down easily with the OFF + key */ +#ifdef HAVE_SW_POWEROFF if(btn == BUTTON_OFF && !charger_inserted() && repeat_count > POWEROFF_COUNT) - power_off(); + queue_post(&button_queue, SYS_POWEROFF, NULL); #endif } } diff --git a/firmware/export/config-fmrecorder.h b/firmware/export/config-fmrecorder.h index aec31c2..0903e66 100644 --- a/firmware/export/config-fmrecorder.h +++ b/firmware/export/config-fmrecorder.h @@ -73,4 +73,7 @@ /* Define this for LCD backlight available */ #define HAVE_BACKLIGHT +/* Define this if you have a software controlled poweroff */ +#define HAVE_SW_POWEROFF + #endif /* SIMULATOR */ diff --git a/firmware/export/config-ondiofm.h b/firmware/export/config-ondiofm.h index f7cff94..437f868 100644 --- a/firmware/export/config-ondiofm.h +++ b/firmware/export/config-ondiofm.h @@ -70,4 +70,7 @@ /* Define this if the MAS SIBI line can be controlled via PB8 */ #define HAVE_MAS_SIBI_CONTROL +/* Define this if you have a software controlled poweroff */ +#define HAVE_SW_POWEROFF + #endif /* SIMULATOR */ diff --git a/firmware/export/config-ondiosp.h b/firmware/export/config-ondiosp.h index 111787f..9bf29f1 100644 --- a/firmware/export/config-ondiosp.h +++ b/firmware/export/config-ondiosp.h @@ -64,4 +64,7 @@ /* Define this if the MAS SIBI line can be controlled via PB8 */ #define HAVE_MAS_SIBI_CONTROL +/* Define this if you have a software controlled poweroff */ +#define HAVE_SW_POWEROFF + #endif /* SIMULATOR */ |