diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2004-07-24 21:26:41 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2004-07-24 21:26:41 +0000 |
commit | 5b5003dcb12b0fe22f497a62d3024f3cf7a10fd1 (patch) | |
tree | effe16b48cdae25b0776df1d0ef87f73c36c5267 /apps | |
parent | 6b8d020876f97a4af01d628ad0de251b103be01c (diff) | |
download | rockbox-5b5003dcb12b0fe22f497a62d3024f3cf7a10fd1.tar.gz rockbox-5b5003dcb12b0fe22f497a62d3024f3cf7a10fd1.zip |
New feature: clean shutdown if you press OFF twice in the file browser, or select "Shut
off" in the main menu. Players only have the menu option, due to lack of keys.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4940 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/lang/english.lang | 12 | ||||
-rw-r--r-- | apps/main_menu.c | 7 | ||||
-rw-r--r-- | apps/misc.c | 28 | ||||
-rw-r--r-- | apps/misc.h | 1 | ||||
-rw-r--r-- | apps/screens.c | 39 | ||||
-rw-r--r-- | apps/screens.h | 4 | ||||
-rw-r--r-- | apps/tree.c | 20 |
7 files changed, 98 insertions, 13 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang index 062c7a0d75..22fbb576d4 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang | |||
@@ -2793,3 +2793,15 @@ desc: in sound settings | |||
2793 | eng: "Super bass" | 2793 | eng: "Super bass" |
2794 | voice: "Super bass" | 2794 | voice: "Super bass" |
2795 | new: | 2795 | new: |
2796 | |||
2797 | id: LANG_SHUTDOWN | ||
2798 | desc: in main menu | ||
2799 | eng: "Shut down" | ||
2800 | voice: "Shut down" | ||
2801 | new: | ||
2802 | |||
2803 | id: LANG_SHUTTINGDOWN | ||
2804 | desc: in main menu | ||
2805 | eng: "Shutting down..." | ||
2806 | voice: "" | ||
2807 | new: | ||
diff --git a/apps/main_menu.c b/apps/main_menu.c index 462d10df0d..991a1681de 100644 --- a/apps/main_menu.c +++ b/apps/main_menu.c | |||
@@ -49,7 +49,7 @@ | |||
49 | #ifdef HAVE_FMRADIO | 49 | #ifdef HAVE_FMRADIO |
50 | #include "radio.h" | 50 | #include "radio.h" |
51 | #endif | 51 | #endif |
52 | 52 | #include "misc.h" | |
53 | #include "lang.h" | 53 | #include "lang.h" |
54 | 54 | ||
55 | #ifdef HAVE_MAS3587F | 55 | #ifdef HAVE_MAS3587F |
@@ -324,7 +324,7 @@ bool main_menu(void) | |||
324 | int i = 0; | 324 | int i = 0; |
325 | 325 | ||
326 | /* main menu */ | 326 | /* main menu */ |
327 | struct menu_item items[8]; | 327 | struct menu_item items[9]; |
328 | 328 | ||
329 | items[i].desc = ID2P(LANG_BOOKMARK_MENU); | 329 | items[i].desc = ID2P(LANG_BOOKMARK_MENU); |
330 | items[i++].function = bookmark_menu; | 330 | items[i++].function = bookmark_menu; |
@@ -356,6 +356,9 @@ bool main_menu(void) | |||
356 | items[i].desc = ID2P(LANG_INFO); | 356 | items[i].desc = ID2P(LANG_INFO); |
357 | items[i++].function = info_menu; | 357 | items[i++].function = info_menu; |
358 | 358 | ||
359 | items[i].desc = ID2P(LANG_SHUTDOWN); | ||
360 | items[i++].function = clean_shutdown; | ||
361 | |||
359 | m=menu_init( items, i, NULL, NULL, NULL, NULL ); | 362 | m=menu_init( items, i, NULL, NULL, NULL, NULL ); |
360 | #ifdef HAVE_LCD_CHARCELLS | 363 | #ifdef HAVE_LCD_CHARCELLS |
361 | status_set_param(true); | 364 | status_set_param(true); |
diff --git a/apps/misc.c b/apps/misc.c index 535cd81814..8bb78f5d64 100644 --- a/apps/misc.c +++ b/apps/misc.c | |||
@@ -17,6 +17,7 @@ | |||
17 | * | 17 | * |
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | #include <ctype.h> | 19 | #include <ctype.h> |
20 | #include "lang.h" | ||
20 | #include "string.h" | 21 | #include "string.h" |
21 | #include "config.h" | 22 | #include "config.h" |
22 | #include "file.h" | 23 | #include "file.h" |
@@ -25,6 +26,13 @@ | |||
25 | #include "errno.h" | 26 | #include "errno.h" |
26 | #include "system.h" | 27 | #include "system.h" |
27 | #include "timefuncs.h" | 28 | #include "timefuncs.h" |
29 | #include "screens.h" | ||
30 | #include "mpeg.h" | ||
31 | #include "mp3_playback.h" | ||
32 | #include "settings.h" | ||
33 | #include "ata.h" | ||
34 | #include "kernel.h" | ||
35 | #include "power.h" | ||
28 | 36 | ||
29 | #define ONE_KILOBYTE 1024 | 37 | #define ONE_KILOBYTE 1024 |
30 | #define ONE_MEGABYTE (1024*1024) | 38 | #define ONE_MEGABYTE (1024*1024) |
@@ -204,3 +212,23 @@ bool settings_parseline(char* line, char** name, char** value) | |||
204 | *value = ptr; | 212 | *value = ptr; |
205 | return true; | 213 | return true; |
206 | } | 214 | } |
215 | |||
216 | bool clean_shutdown(void) | ||
217 | { | ||
218 | lcd_clear_display(); | ||
219 | splash(0, true, str(LANG_SHUTTINGDOWN)); | ||
220 | mpeg_stop(); | ||
221 | settings_save(); | ||
222 | ata_flush(); | ||
223 | ata_spindown(1); | ||
224 | #ifndef SIMULATOR | ||
225 | while(ata_disk_is_active()) | ||
226 | sleep(HZ/10); | ||
227 | if(!charger_inserted()) | ||
228 | { | ||
229 | mp3_shutdown(); | ||
230 | power_off(); | ||
231 | } | ||
232 | #endif | ||
233 | return false; | ||
234 | } | ||
diff --git a/apps/misc.h b/apps/misc.h index df9eba8e55..7815bd2183 100644 --- a/apps/misc.h +++ b/apps/misc.h | |||
@@ -39,5 +39,6 @@ void screen_dump(void); | |||
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | bool settings_parseline(char* line, char** name, char** value); | 41 | bool settings_parseline(char* line, char** name, char** value); |
42 | bool clean_shutdown(void); | ||
42 | 43 | ||
43 | #endif | 44 | #endif |
diff --git a/apps/screens.c b/apps/screens.c index 28d9a48869..c099822525 100644 --- a/apps/screens.c +++ b/apps/screens.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include "adc.h" | 39 | #include "adc.h" |
40 | #include "action.h" | 40 | #include "action.h" |
41 | #include "talk.h" | 41 | #include "talk.h" |
42 | #include "misc.h" | ||
42 | 43 | ||
43 | #ifdef HAVE_LCD_BITMAP | 44 | #ifdef HAVE_LCD_BITMAP |
44 | #define BMPHEIGHT_usb_logo 32 | 45 | #define BMPHEIGHT_usb_logo 32 |
@@ -1090,3 +1091,41 @@ bool set_time_screen(char* string, struct tm *tm) | |||
1090 | return false; | 1091 | return false; |
1091 | } | 1092 | } |
1092 | #endif | 1093 | #endif |
1094 | |||
1095 | bool shutdown_screen(void) | ||
1096 | { | ||
1097 | int button; | ||
1098 | bool done = false; | ||
1099 | |||
1100 | lcd_stop_scroll(); | ||
1101 | |||
1102 | #ifdef HAVE_LCD_CHARCELLS | ||
1103 | splash(0, true, "Push STOP to shut off"); | ||
1104 | #else | ||
1105 | splash(0, true, "Push OFF to shut off"); | ||
1106 | #endif | ||
1107 | while(!done) | ||
1108 | { | ||
1109 | button = button_get_w_tmo(HZ*2); | ||
1110 | switch(button) | ||
1111 | { | ||
1112 | #ifdef HAVE_PLAYER_KEYPAD | ||
1113 | case BUTTON_STOP: | ||
1114 | #else | ||
1115 | case BUTTON_OFF: | ||
1116 | #endif | ||
1117 | clean_shutdown(); | ||
1118 | break; | ||
1119 | |||
1120 | default: | ||
1121 | /* Return if any other button was pushed, or if there | ||
1122 | was a timeout. We ignore RELEASE events, since we may | ||
1123 | have been called by a button down event, and the user might | ||
1124 | not have released the button yet. */ | ||
1125 | if(!(button & BUTTON_REL)) | ||
1126 | done = true; | ||
1127 | break; | ||
1128 | } | ||
1129 | } | ||
1130 | return false; | ||
1131 | } | ||
diff --git a/apps/screens.h b/apps/screens.h index 55b31006ce..b4f293f0ba 100644 --- a/apps/screens.h +++ b/apps/screens.h | |||
@@ -40,6 +40,8 @@ void splash(int ticks, /* how long */ | |||
40 | #ifdef HAVE_RTC | 40 | #ifdef HAVE_RTC |
41 | bool set_time_screen(char* string, struct tm *tm); | 41 | bool set_time_screen(char* string, struct tm *tm); |
42 | #endif | 42 | #endif |
43 | 43 | ||
44 | bool shutdown_screen(void); | ||
45 | |||
44 | #endif | 46 | #endif |
45 | 47 | ||
diff --git a/apps/tree.c b/apps/tree.c index 754e84f508..1faadf69f7 100644 --- a/apps/tree.c +++ b/apps/tree.c | |||
@@ -1012,18 +1012,18 @@ static bool dirbrowse(char *root, int *dirfilter) | |||
1012 | break; | 1012 | break; |
1013 | 1013 | ||
1014 | #ifdef HAVE_RECORDER_KEYPAD | 1014 | #ifdef HAVE_RECORDER_KEYPAD |
1015 | case BUTTON_OFF: | ||
1016 | bookmark_autobookmark(); | ||
1017 | mpeg_stop(); | ||
1018 | status_draw(false); | ||
1019 | restore = true; | ||
1020 | break; | ||
1021 | |||
1022 | case BUTTON_OFF | BUTTON_REL: | 1015 | case BUTTON_OFF | BUTTON_REL: |
1023 | #else | ||
1024 | case BUTTON_STOP | BUTTON_REL: | ||
1025 | #endif | 1016 | #endif |
1026 | settings_save(); | 1017 | /* Stop the music if it is playing, else show the shutdown |
1018 | screen */ | ||
1019 | if(mpeg_status()) | ||
1020 | mpeg_stop(); | ||
1021 | else { | ||
1022 | if (!charger_inserted()) { | ||
1023 | shutdown_screen(); | ||
1024 | restore = true; | ||
1025 | } | ||
1026 | } | ||
1027 | break; | 1027 | break; |
1028 | 1028 | ||
1029 | #ifdef HAVE_RECORDER_KEYPAD | 1029 | #ifdef HAVE_RECORDER_KEYPAD |