Index: apps/screens.c
===================================================================
--- apps/screens.c (revision 14494)
+++ apps/screens.c (working copy)
@@ -1126,7 +1126,7 @@
switch(button)
{
case ACTION_STD_CANCEL:
- sys_poweroff();
+ sys_poweroff(false);
break;
/* do nothing here, because ACTION_NONE might be caused
Index: apps/plugins/battery_bench.c
===================================================================
--- apps/plugins/battery_bench.c (revision 14494)
+++ apps/plugins/battery_bench.c (working copy)
@@ -345,6 +345,7 @@
in_usb_mode = false;
rb->usb_acknowledge(SYS_USB_DISCONNECTED_ACK);
break;
+ case SYS_REBOOT:
case SYS_POWEROFF:
exit = 1;
break;
Index: apps/plugins/solitaire.c
===================================================================
--- apps/plugins/solitaire.c (revision 14494)
+++ apps/plugins/solitaire.c (working copy)
@@ -1579,6 +1579,7 @@
}
break;
+ case SYS_REBOOT:
case SYS_POWEROFF:
return SOLITAIRE_QUIT;
Index: apps/plugins/lib/oldmenuapi.c
===================================================================
--- apps/plugins/lib/oldmenuapi.c (revision 14494)
+++ apps/plugins/lib/oldmenuapi.c (working copy)
@@ -114,6 +114,7 @@
case ACTION_STD_CANCEL:
case ACTION_STD_MENU:
+ case SYS_REBOOT:
case SYS_POWEROFF:
exit = true;
break;
Index: apps/lang/english.lang
===================================================================
--- apps/lang/english.lang (revision 14494)
+++ apps/lang/english.lang (working copy)
@@ -6840,16 +6840,13 @@
desc: in main menu
user:
- *: none
- soft_shutdown: "Shut down"
+ *: "Shut down"
- *: none
- soft_shutdown: "Shut down"
+ *: "Shut down"
- *: none
- soft_shutdown: "Shut down"
+ *: "Shut down"
@@ -11241,3 +11241,46 @@
usbstack: "Device Driver"
+\ No newline at end of file
+
+ id: LANG_POWER
+ desc: in root menu
+ user:
+
+ *: "Power"
+
+
+ *: "Power"
+
+
+ *: "Power"
+
+
+
+ id: LANG_REBOOT
+ desc: in power menu
+ user:
+
+ *: "Reboot"
+
+
+ *: "Reboot"
+
+
+ *: "Reboot"
+
+
+
+ id: LANG_REBOOTING
+ desc: reboot splash
+ user:
+
+ *: "Rebooting..."
+
+
+ *: "Rebooting..."
+
+
+ *: ""
+
+
Index: apps/gui/gwps.c
===================================================================
--- apps/gui/gwps.c (revision 14494)
+++ apps/gui/gwps.c (working copy)
@@ -625,6 +625,16 @@
exit = true;
break;
#endif
+ case SYS_REBOOT:
+#if LCD_DEPTH > 1
+ show_main_backdrop();
+#endif
+#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
+ show_remote_main_backdrop();
+#endif
+ default_event_handler(SYS_POWEROFF);
+ break;
+
case SYS_POWEROFF:
#if LCD_DEPTH > 1
show_main_backdrop();
Index: apps/menus/power_menu.c
===================================================================
--- apps/menus/power_menu.c (revision 0)
+++ apps/menus/power_menu.c (revision 0)
@@ -0,0 +1,102 @@
+
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id: $
+ *
+ * Copyright (C) 2007 Jonathan Gordon
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include
+#include
+#include
+#include
+#include "sprintf.h"
+#include "config.h"
+#include "lang.h"
+#include "action.h"
+#include "settings.h"
+#include "menu.h"
+#include "exported_menus.h"
+#include "screens.h"
+#include "powermgmt.h"
+#include "power.h"
+#include "talk.h"
+
+static void sleep_timer_formatter(char* buffer, size_t buffer_size, int value,
+ const char* unit)
+{
+ int minutes, hours;
+
+ (void) unit;
+
+ if (value) {
+ hours = value / 60;
+ minutes = value - (hours * 60);
+ snprintf(buffer, buffer_size, "%d:%02d", hours, minutes);
+ } else {
+ snprintf(buffer, buffer_size, "%s", str(LANG_OFF));
+ }
+}
+
+static void sleep_timer_set(int minutes)
+{
+ set_sleep_timer(minutes * 60);
+}
+
+static int sleep_timer(void)
+{
+ int minutes = (get_sleep_timer() + 59) / 60; /* round up */
+ return (int)set_int(str(LANG_SLEEP_TIMER), "", UNIT_MIN, &minutes,
+ &sleep_timer_set, -5, 300, 0, sleep_timer_formatter);
+}
+
+static int do_shutdown(void)
+{
+#if CONFIG_CHARGING
+ if (charger_inserted())
+ charging_splash();
+ else
+#endif
+ sys_poweroff(false);
+ return 0;
+}
+
+static int do_reboot(void)
+{
+#if CONFIG_CHARGING
+ if (charger_inserted())
+ charging_splash();
+ else
+#endif
+ sys_poweroff(true);
+ return 0;
+}
+
+MENUITEM_FUNCTION(sleep_timer_call, 0, ID2P(LANG_SLEEP_TIMER), sleep_timer,
+ NULL, NULL, Icon_Menu_setting); /* make it look like a
+ setting to the user */
+MENUITEM_FUNCTION(do_reboot_item, 0, ID2P(LANG_REBOOT),
+ do_reboot, NULL, NULL, Icon_NOICON);
+
+MENUITEM_FUNCTION(do_shutdown_item, 0, ID2P(LANG_SHUTDOWN),
+ do_shutdown, NULL, NULL, Icon_NOICON);
+
+MAKE_MENU(power_options, ID2P(LANG_POWER), 0, Icon_NOICON,
+ &sleep_timer_call, &do_reboot_item, &do_shutdown_item);
+
+bool power_menu(void)
+{
+ return do_menu(&power_options, NULL);
+}
Index: apps/menus/exported_menus.h
===================================================================
--- apps/menus/exported_menus.h (revision 14494)
+++ apps/menus/exported_menus.h (working copy)
@@ -36,6 +36,7 @@
playlist_options, /* playlist_menu.c */
equalizer_menu, /* eq_menu.c */
info_menu, /* info_menu.c */
+ power_options; /* power_menu.c */
theme_menu; /* theme_menu.c */
#ifdef HAVE_WM8758
Index: apps/menus/main_menu.c
===================================================================
--- apps/menus/main_menu.c (revision 14494)
+++ apps/menus/main_menu.c (working copy)
@@ -405,39 +405,6 @@
MENUITEM_FUNCTION(show_info_item, 0, ID2P(LANG_ROCKBOX_INFO),
(menu_function)show_info, NULL, NULL, Icon_NOICON);
-
-/* sleep Menu */
-static void sleep_timer_formatter(char* buffer, size_t buffer_size, int value,
- const char* unit)
-{
- int minutes, hours;
-
- (void) unit;
-
- if (value) {
- hours = value / 60;
- minutes = value - (hours * 60);
- snprintf(buffer, buffer_size, "%d:%02d", hours, minutes);
- } else {
- snprintf(buffer, buffer_size, "%s", str(LANG_OFF));
- }
-}
-
-static void sleep_timer_set(int minutes)
-{
- set_sleep_timer(minutes * 60);
-}
-
-static int sleep_timer(void)
-{
- int minutes = (get_sleep_timer() + 59) / 60; /* round up */
- return (int)set_int(str(LANG_SLEEP_TIMER), "", UNIT_MIN, &minutes,
- &sleep_timer_set, -5, 300, 0, sleep_timer_formatter);
-}
-
-MENUITEM_FUNCTION(sleep_timer_call, 0, ID2P(LANG_SLEEP_TIMER), sleep_timer,
- NULL, NULL, Icon_Menu_setting); /* make it look like a
- setting to the user */
MENUITEM_FUNCTION(show_credits_item, 0, ID2P(LANG_VERSION),
(menu_function)show_credits, NULL, NULL, Icon_NOICON);
MENUITEM_FUNCTION(show_runtime_item, 0, ID2P(LANG_RUNNING_TIME),
@@ -447,7 +414,7 @@
MAKE_MENU(info_menu, ID2P(LANG_SYSTEM), 0, Icon_Questionmark,
&show_info_item, &show_credits_item, &show_runtime_item,
- &sleep_timer_call, &debug_menu_item);
+ &debug_menu_item);
/* INFO MENU */
/***********************************/
Index: apps/tagcache.c
===================================================================
--- apps/tagcache.c (revision 14494)
+++ apps/tagcache.c (working copy)
@@ -3383,6 +3383,7 @@
switch (ev.id)
{
case Q_STOP_SCAN:
+ case SYS_REBOOT:
case SYS_POWEROFF:
case SYS_USB_CONNECTED:
/* Put the event back into the queue. */
@@ -4061,6 +4062,7 @@
case Q_STOP_SCAN:
break ;
+ case SYS_REBOOT:
case SYS_POWEROFF:
break ;
Index: apps/features.txt
===================================================================
--- apps/features.txt (revision 14494)
+++ apps/features.txt (working copy)
@@ -124,10 +124,6 @@
scrollwheel
#endif
-#if defined(ARCHOS_RECORDER) || defined(ARCHOS_PLAYER)
-soft_shutdown
-#endif
-
#if defined(HAVE_SPDIF_POWER)
spdif_power
#endif
Index: apps/SOURCES
===================================================================
--- apps/SOURCES (revision 14494)
+++ apps/SOURCES (working copy)
@@ -22,6 +22,7 @@
#endif
menus/settings_menu.c
menus/sound_menu.c
+menus/power_menu.c
misc.c
onplay.c
playlist.c
Index: apps/root_menu.c
===================================================================
--- apps/root_menu.c (revision 14494)
+++ apps/root_menu.c (working copy)
@@ -25,13 +25,11 @@
#include "root_menu.h"
#include "lang.h"
#include "settings.h"
-#include "screens.h"
#include "kernel.h"
#include "debug.h"
#include "misc.h"
#include "rolo.h"
#include "powermgmt.h"
-#include "power.h"
#include "talk.h"
#include "audio.h"
#include "hotswap.h"
@@ -376,20 +374,7 @@
MENUITEM_RETURNVALUE(bookmarks, ID2P(LANG_BOOKMARK_MENU_RECENT_BOOKMARKS),
GO_TO_RECENTBMARKS, item_callback,
Icon_Bookmark);
-#ifdef HAVE_LCD_CHARCELLS
-static int do_shutdown(void)
-{
-#if CONFIG_CHARGING
- if (charger_inserted())
- charging_splash();
- else
-#endif
- sys_poweroff();
- return 0;
-}
-MENUITEM_FUNCTION(do_shutdown_item, 0, ID2P(LANG_SHUTDOWN),
- do_shutdown, NULL, NULL, Icon_NOICON);
-#endif
+
MAKE_MENU(root_menu_, ID2P(LANG_ROCKBOX_TITLE),
item_callback, Icon_Rockbox,
&bookmarks, &file_browser,
@@ -403,11 +388,7 @@
#if CONFIG_TUNER
&fm,
#endif
- &playlist_options, &rocks_browser, &info_menu
-
-#ifdef HAVE_LCD_CHARCELLS
- ,&do_shutdown_item
-#endif
+ &playlist_options, &rocks_browser, &info_menu, &power_options
);
int item_callback(int action, const struct menu_item_ex *this_item)
Index: apps/misc.c
===================================================================
--- apps/misc.c (revision 14494)
+++ apps/misc.c (working copy)
@@ -598,9 +598,10 @@
tree_restore();
}
-static bool clean_shutdown(void (*callback)(void *), void *parameter)
+static bool clean_shutdown(bool reboot, void (*callback)(void *), void *parameter)
{
#ifdef SIMULATOR
+ (void)reboot;
(void)callback;
(void)parameter;
bookmark_autobookmark();
@@ -633,7 +634,12 @@
}
#endif
if (battery_level() > 10)
- gui_syncsplash(0, str(LANG_SHUTTINGDOWN));
+ {
+ if (reboot)
+ gui_syncsplash(0, str(LANG_REBOOTING));
+ else
+ gui_syncsplash(0, str(LANG_SHUTTINGDOWN));
+ }
else
{
msg_id = LANG_WARNING_BATTERY_LOW;
@@ -714,7 +720,7 @@
dircache_disable();
#endif
- shutdown_hw();
+ shutdown_hw(reboot);
}
#endif
return false;
@@ -881,9 +887,13 @@
}
return SYS_USB_CONNECTED;
case SYS_POWEROFF:
- if (!clean_shutdown(callback, parameter))
+ if (!clean_shutdown(false, callback, parameter))
return SYS_POWEROFF;
break;
+ case SYS_REBOOT:
+ if (!clean_shutdown(true, callback, parameter))
+ return SYS_REBOOT;
+ break;
#if CONFIG_CHARGING
case SYS_CHARGER_CONNECTED:
car_adapter_mode_processing(true);
Index: firmware/export/kernel.h
===================================================================
--- firmware/export/kernel.h (revision 14494)
+++ firmware/export/kernel.h (working copy)
@@ -59,8 +59,9 @@
#define SYS_USB_DISCONNECTED MAKE_SYS_EVENT(SYS_EVENT_CLS_USB, 2)
#define SYS_USB_DISCONNECTED_ACK MAKE_SYS_EVENT(SYS_EVENT_CLS_USB, 3)
#define SYS_POWEROFF MAKE_SYS_EVENT(SYS_EVENT_CLS_POWER, 0)
-#define SYS_CHARGER_CONNECTED MAKE_SYS_EVENT(SYS_EVENT_CLS_POWER, 1)
-#define SYS_CHARGER_DISCONNECTED MAKE_SYS_EVENT(SYS_EVENT_CLS_POWER, 2)
+#define SYS_REBOOT MAKE_SYS_EVENT(SYS_EVENT_CLS_POWER, 1)
+#define SYS_CHARGER_CONNECTED MAKE_SYS_EVENT(SYS_EVENT_CLS_POWER, 2)
+#define SYS_CHARGER_DISCONNECTED MAKE_SYS_EVENT(SYS_EVENT_CLS_POWER, 3)
#define SYS_FS_CHANGED MAKE_SYS_EVENT(SYS_EVENT_CLS_FILESYS, 0)
#define SYS_HOTSWAP_INSERTED MAKE_SYS_EVENT(SYS_EVENT_CLS_PLUG, 0)
#define SYS_HOTSWAP_EXTRACTED MAKE_SYS_EVENT(SYS_EVENT_CLS_PLUG, 1)
Index: firmware/export/powermgmt.h
===================================================================
--- firmware/export/powermgmt.h (revision 14494)
+++ firmware/export/powermgmt.h (working copy)
@@ -172,7 +172,7 @@
void set_car_adapter_mode(bool setting);
void reset_poweroff_timer(void);
void cancel_shutdown(void);
-void shutdown_hw(void);
-void sys_poweroff(void);
+void shutdown_hw(bool reboot);
+void sys_poweroff(bool reboot);
#endif
Index: firmware/backlight.c
===================================================================
--- firmware/backlight.c (revision 14494)
+++ firmware/backlight.c (working copy)
@@ -539,6 +539,7 @@
break;
#endif
+ case SYS_REBOOT:
case SYS_POWEROFF: /* Lock backlight on poweroff so it doesn't */
locked = true; /* go off before power is actually cut. */
/* fall through */
Index: firmware/target/coldfire/iaudio/pcf50606-iaudio.c
===================================================================
--- firmware/target/coldfire/iaudio/pcf50606-iaudio.c (revision 14494)
+++ firmware/target/coldfire/iaudio/pcf50606-iaudio.c (working copy)
@@ -115,7 +115,7 @@
{
/* ONKEY1S */
if (GPIO_READ & 0x02000000)
- sys_poweroff(); /* main ONKEY */
+ sys_poweroff(false); /* main ONKEY */
else
pcf50606_reset_timeout(); /* remote ONKEY */
}
Index: firmware/powermgmt.c
===================================================================
--- firmware/powermgmt.c (revision 14494)
+++ firmware/powermgmt.c (working copy)
@@ -493,7 +493,7 @@
if(battery_millivolts < battery_level_shutoff[battery_type]) {
if(!shutdown_timeout) {
backlight_on();
- sys_poweroff();
+ sys_poweroff(false);
}
}
#endif
@@ -510,7 +510,7 @@
if(TIME_AFTER(current_tick, last_event_tick + timeout) &&
TIME_AFTER(current_tick, last_disk_activity + timeout))
{
- sys_poweroff();
+ sys_poweroff(false);
}
}
else
@@ -533,7 +533,7 @@
#endif
{
DEBUGF("Sleep timer timeout. Shutting off...\n");
- sys_poweroff();
+ sys_poweroff(false);
}
}
}
@@ -721,7 +721,7 @@
#ifndef NO_LOW_BATTERY_SHUTDOWN
if (!shutdown_timeout &&
(battery_millivolts < battery_level_shutoff[battery_type]))
- sys_poweroff();
+ sys_poweroff(false);
else
#endif
avgbat += battery_millivolts - (avgbat / BATT_AVE_SAMPLES);
@@ -1110,7 +1110,7 @@
#endif /* SIMULATOR */
-void sys_poweroff(void)
+void sys_poweroff(bool reboot)
{
logf("sys_poweroff()");
/* If the main thread fails to shut down the system, we will force a
@@ -1127,7 +1127,10 @@
shutdown_timeout += HZ*20;
}
- queue_broadcast(SYS_POWEROFF, 0);
+ if (reboot)
+ queue_broadcast(SYS_REBOOT, 0);
+ else
+ queue_broadcast(SYS_POWEROFF, 0);
}
void cancel_shutdown(void)
@@ -1144,9 +1147,11 @@
}
/* Various hardware housekeeping tasks relating to shutting down the jukebox */
-void shutdown_hw(void)
+void shutdown_hw(bool reboot)
{
-#ifndef SIMULATOR
+#ifdef SIMULATOR
+(void)reboot;
+#else
#if defined(DEBUG_FILE) && (CONFIG_CHARGING == CHARGING_CONTROL)
if(fd >= 0) {
close(fd);
@@ -1185,6 +1190,9 @@
eeprom chips are quite slow and might be still writing the last
byte. */
sleep(HZ/4);
- power_off();
-#endif /* #ifndef SIMULATOR */
+ if (reboot)
+ system_reboot();
+ else
+ power_off();
+#endif /* #ifdef SIMULATOR */
}
Index: firmware/drivers/button.c
===================================================================
--- firmware/drivers/button.c (revision 14494)
+++ firmware/drivers/button.c (working copy)
@@ -182,7 +182,7 @@
{
/* Tell the main thread that it's time to
power off */
- sys_poweroff();
+ sys_poweroff(false);
/* Safety net for players without hardware
poweroff */
Index: flash/bootbox/main.c
===================================================================
--- flash/bootbox/main.c (revision 14494)
+++ flash/bootbox/main.c (working copy)
@@ -138,9 +138,9 @@
{
button = button_get(true);
if (button == SYS_POWEROFF)
- {
power_off();
- }
+ else if (button == SYS_REBOOT)
+ system_reboot();
} while (button != SYS_USB_CONNECTED);
usb_screen();
system_reboot();