summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/lang/english.lang12
-rw-r--r--apps/main_menu.c7
-rw-r--r--apps/misc.c28
-rw-r--r--apps/misc.h1
-rw-r--r--apps/screens.c39
-rw-r--r--apps/screens.h4
-rw-r--r--apps/tree.c20
-rw-r--r--firmware/export/mp3_playback.h1
-rw-r--r--firmware/mp3_playback.c14
9 files changed, 113 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
2793eng: "Super bass" 2793eng: "Super bass"
2794voice: "Super bass" 2794voice: "Super bass"
2795new: 2795new:
2796
2797id: LANG_SHUTDOWN
2798desc: in main menu
2799eng: "Shut down"
2800voice: "Shut down"
2801new:
2802
2803id: LANG_SHUTTINGDOWN
2804desc: in main menu
2805eng: "Shutting down..."
2806voice: ""
2807new:
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
216bool 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
41bool settings_parseline(char* line, char** name, char** value); 41bool settings_parseline(char* line, char** name, char** value);
42bool 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
1095bool 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
41bool set_time_screen(char* string, struct tm *tm); 41bool set_time_screen(char* string, struct tm *tm);
42#endif 42#endif
43 43
44bool 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
diff --git a/firmware/export/mp3_playback.h b/firmware/export/mp3_playback.h
index b4719b7d9b..9eb1d882ff 100644
--- a/firmware/export/mp3_playback.h
+++ b/firmware/export/mp3_playback.h
@@ -60,6 +60,7 @@ long mp3_get_playtime(void);
60void mp3_reset_playtime(void); 60void mp3_reset_playtime(void);
61bool mp3_is_playing(void); 61bool mp3_is_playing(void);
62unsigned char* mp3_get_pos(void); 62unsigned char* mp3_get_pos(void);
63void mp3_shutdown(void);
63 64
64 65
65#define SOUND_VOLUME 0 66#define SOUND_VOLUME 0
diff --git a/firmware/mp3_playback.c b/firmware/mp3_playback.c
index 44a7eef666..c6f16262a8 100644
--- a/firmware/mp3_playback.c
+++ b/firmware/mp3_playback.c
@@ -1028,6 +1028,20 @@ void mp3_init(int volume, int bass, int treble, int balance, int loudness,
1028 paused = true; 1028 paused = true;
1029} 1029}
1030 1030
1031void mp3_shutdown(void)
1032{
1033#ifndef SIMULATOR
1034#ifdef HAVE_MAS3587F
1035 unsigned long val = 1;
1036 mas_writemem(MAS_BANK_D0, 0x7f9, &val, 1); /* Mute */
1037#endif
1038
1039#ifdef HAVE_MAS3507D
1040 dac_volume(0, 0, false);
1041#endif
1042
1043#endif
1044}
1031 1045
1032/* new functions, to be exported to plugin API */ 1046/* new functions, to be exported to plugin API */
1033 1047