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 96d23a8388..5be6264fdc 100644 --- a/apps/misc.c +++ b/apps/misc.c | |||
@@ -217,6 +217,7 @@ bool clean_shutdown(void) | |||
217 | { | 217 | { |
218 | lcd_clear_display(); | 218 | lcd_clear_display(); |
219 | splash(0, true, str(LANG_SHUTTINGDOWN)); | 219 | splash(0, true, str(LANG_SHUTTINGDOWN)); |
220 | sleep(HZ); | ||
220 | mpeg_stop(); | 221 | mpeg_stop(); |
221 | ata_flush(); | 222 | ata_flush(); |
222 | ata_spindown(1); | 223 | ata_spindown(1); |
@@ -239,6 +240,10 @@ int default_event_handler(int event) | |||
239 | #endif | 240 | #endif |
240 | usb_screen(); | 241 | usb_screen(); |
241 | return SYS_USB_CONNECTED; | 242 | return SYS_USB_CONNECTED; |
243 | case SYS_POWEROFF: | ||
244 | if (!clean_shutdown()) | ||
245 | return SYS_POWEROFF; | ||
246 | break; | ||
242 | } | 247 | } |
243 | return 0; | 248 | return 0; |
244 | } | 249 | } |
diff --git a/apps/tree.c b/apps/tree.c index 1a92dfd3a9..03c7d2ca37 100644 --- a/apps/tree.c +++ b/apps/tree.c | |||
@@ -946,21 +946,25 @@ static bool dirbrowse(const char *root, const int *dirfilter) | |||
946 | break; | 946 | break; |
947 | 947 | ||
948 | #ifdef TREE_OFF | 948 | #ifdef TREE_OFF |
949 | #ifndef HAVE_SW_POWEROFF | ||
949 | case TREE_OFF: | 950 | case TREE_OFF: |
950 | /* Stop the music if it is playing, else show the shutdown | 951 | if (*dirfilter < NUM_FILTER_MODES) |
951 | screen */ | 952 | { |
952 | if(mpeg_status()) | 953 | /* Stop the music if it is playing, else show the shutdown |
953 | mpeg_stop(); | 954 | screen */ |
954 | else { | 955 | if(mpeg_status()) |
955 | if (!charger_inserted()) { | 956 | mpeg_stop(); |
956 | shutdown_screen(); | 957 | else { |
957 | } else { | 958 | if (!charger_inserted()) { |
958 | charging_splash(); | 959 | shutdown_screen(); |
960 | } else { | ||
961 | charging_splash(); | ||
962 | } | ||
963 | restore = true; | ||
959 | } | 964 | } |
960 | restore = true; | ||
961 | } | 965 | } |
962 | break; | 966 | break; |
963 | 967 | #endif | |
964 | case TREE_OFF | BUTTON_REPEAT: | 968 | case TREE_OFF | BUTTON_REPEAT: |
965 | if (charger_inserted()) { | 969 | if (charger_inserted()) { |
966 | charging_splash(); | 970 | charging_splash(); |
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c index 607e72e09a..0cfe1d1aa0 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 */ | |||
54 | #define REPEAT_INTERVAL_FINISH 5 | 54 | #define REPEAT_INTERVAL_FINISH 5 |
55 | 55 | ||
56 | /* Number of repeated keys before shutting off */ | 56 | /* Number of repeated keys before shutting off */ |
57 | #define POWEROFF_COUNT 40 | 57 | #define POWEROFF_COUNT 10 |
58 | 58 | ||
59 | static int button_read(void); | 59 | static int button_read(void); |
60 | 60 | ||
@@ -116,12 +116,13 @@ static void button_tick(void) | |||
116 | 116 | ||
117 | repeat_count++; | 117 | repeat_count++; |
118 | 118 | ||
119 | /* Shutdown if we have a device which doesn't shut | 119 | /* Send a SYS_POWEROFF event if we have a device |
120 | down easily with the OFF key */ | 120 | which doesn't shut down easily with the OFF |
121 | #ifdef HAVE_POWEROFF_ON_PB5 | 121 | key */ |
122 | #ifdef HAVE_SW_POWEROFF | ||
122 | if(btn == BUTTON_OFF && !charger_inserted() && | 123 | if(btn == BUTTON_OFF && !charger_inserted() && |
123 | repeat_count > POWEROFF_COUNT) | 124 | repeat_count > POWEROFF_COUNT) |
124 | power_off(); | 125 | queue_post(&button_queue, SYS_POWEROFF, NULL); |
125 | #endif | 126 | #endif |
126 | } | 127 | } |
127 | } | 128 | } |
diff --git a/firmware/export/config-fmrecorder.h b/firmware/export/config-fmrecorder.h index aec31c2b84..0903e66c6d 100644 --- a/firmware/export/config-fmrecorder.h +++ b/firmware/export/config-fmrecorder.h | |||
@@ -73,4 +73,7 @@ | |||
73 | /* Define this for LCD backlight available */ | 73 | /* Define this for LCD backlight available */ |
74 | #define HAVE_BACKLIGHT | 74 | #define HAVE_BACKLIGHT |
75 | 75 | ||
76 | /* Define this if you have a software controlled poweroff */ | ||
77 | #define HAVE_SW_POWEROFF | ||
78 | |||
76 | #endif /* SIMULATOR */ | 79 | #endif /* SIMULATOR */ |
diff --git a/firmware/export/config-ondiofm.h b/firmware/export/config-ondiofm.h index f7cff94f5e..437f8682a8 100644 --- a/firmware/export/config-ondiofm.h +++ b/firmware/export/config-ondiofm.h | |||
@@ -70,4 +70,7 @@ | |||
70 | /* Define this if the MAS SIBI line can be controlled via PB8 */ | 70 | /* Define this if the MAS SIBI line can be controlled via PB8 */ |
71 | #define HAVE_MAS_SIBI_CONTROL | 71 | #define HAVE_MAS_SIBI_CONTROL |
72 | 72 | ||
73 | /* Define this if you have a software controlled poweroff */ | ||
74 | #define HAVE_SW_POWEROFF | ||
75 | |||
73 | #endif /* SIMULATOR */ | 76 | #endif /* SIMULATOR */ |
diff --git a/firmware/export/config-ondiosp.h b/firmware/export/config-ondiosp.h index 111787ffc9..9bf29f17a5 100644 --- a/firmware/export/config-ondiosp.h +++ b/firmware/export/config-ondiosp.h | |||
@@ -64,4 +64,7 @@ | |||
64 | /* Define this if the MAS SIBI line can be controlled via PB8 */ | 64 | /* Define this if the MAS SIBI line can be controlled via PB8 */ |
65 | #define HAVE_MAS_SIBI_CONTROL | 65 | #define HAVE_MAS_SIBI_CONTROL |
66 | 66 | ||
67 | /* Define this if you have a software controlled poweroff */ | ||
68 | #define HAVE_SW_POWEROFF | ||
69 | |||
67 | #endif /* SIMULATOR */ | 70 | #endif /* SIMULATOR */ |