New General Settings submenu: Startup/Shutdown

A dedicated submenu for items which are run at startup, or initiate a shutdown.

Currently containing: Start Screen, Idle Poweroff, Sleep Timer & Start Sleep Timer on Boot.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31435 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Nick Peskett 2011-12-26 08:26:38 +00:00
parent 3bc771d669
commit 2ecaca91f0
11 changed files with 179 additions and 169 deletions

View file

@ -12965,3 +12965,17 @@
*: "Glyphs To Cache" *: "Glyphs To Cache"
</voice> </voice>
</phrase> </phrase>
<phrase>
id: LANG_STARTUP_SHUTDOWN
desc: in the general settings menu
user: core
<source>
*: "Startup/Shutdown"
</source>
<dest>
*: "Startup/Shutdown"
</dest>
<voice>
*: "Startup/Shutdown"
</voice>
</phrase>

View file

@ -38,7 +38,6 @@ extern const struct menu_item_ex
sound_settings, /* sound_menu.c */ sound_settings, /* sound_menu.c */
settings_menu_item, /* settings_menu.c */ settings_menu_item, /* settings_menu.c */
bookmark_settings_menu, bookmark_settings_menu,
sleep_timer_call, /* main_menu.c */
playlist_settings, /* playlist_menu.c */ playlist_settings, /* playlist_menu.c */
equalizer_menu, /* eq_menu.c */ equalizer_menu, /* eq_menu.c */
#ifdef AUDIOHW_HAVE_EQ #ifdef AUDIOHW_HAVE_EQ

View file

@ -374,97 +374,11 @@ static bool show_info(void)
MENUITEM_FUNCTION(show_info_item, 0, ID2P(LANG_ROCKBOX_INFO), MENUITEM_FUNCTION(show_info_item, 0, ID2P(LANG_ROCKBOX_INFO),
(menu_function)show_info, NULL, NULL, Icon_NOICON); (menu_function)show_info, NULL, NULL, Icon_NOICON);
/* sleep Menu */
const char* sleep_timer_formatter(char* buffer, size_t buffer_size,
int value, const char* unit)
{
(void) unit;
int minutes, hours;
if (value) {
hours = value / 60;
minutes = value - (hours * 60);
snprintf(buffer, buffer_size, "%d:%02d", hours, minutes);
return buffer;
} else {
return str(LANG_OFF);
}
}
static void sleep_timer_set(int minutes)
{
if (minutes)
global_settings.sleeptimer_duration = minutes;
set_sleep_timer(minutes * 60);
}
static int sleep_timer(void)
{
int minutes = global_settings.sleeptimer_duration;
if (get_sleep_timer())
sleep_timer_set(0);
else
set_int(str(LANG_SLEEP_TIMER), "", UNIT_MIN, &minutes,
&sleep_timer_set, 5, 0, 300, sleep_timer_formatter);
return 0;
}
static int seconds_to_min(int secs)
{
return (secs + 10) / 60; /* round up for 50+ seconds */
}
static char* sleep_timer_getname(int selected_item, void * data, char *buffer)
{
(void)selected_item;
(void)data;
int sec = get_sleep_timer();
char timer_buf[10];
/* we have no sprintf, so MAX_PATH is a guess */
if (sec > 0)
{ /* show cancel and countdown if running */
snprintf(buffer, MAX_PATH, "%s (%s)", str(LANG_SLEEP_TIMER_CANCEL_CURRENT),
sleep_timer_formatter(timer_buf, sizeof(timer_buf), seconds_to_min(sec), NULL));
}
else
snprintf(buffer, MAX_PATH, "%s", str(LANG_SLEEP_TIMER));
return buffer;
}
static int sleep_timer_voice(int selected_item, void*data)
{
(void)selected_item;
(void)data;
int seconds = get_sleep_timer();
if (seconds > 0)
{
long talk_ids[] = {
LANG_SLEEP_TIMER_CANCEL_CURRENT,
VOICE_PAUSE,
seconds_to_min(seconds) | UNIT_MIN << UNIT_SHIFT,
TALK_FINAL_ID
};
talk_idarray(talk_ids, true);
}
else
talk_id(LANG_SLEEP_TIMER, true);
return 0;
}
#if CONFIG_RTC #if CONFIG_RTC
int time_screen(void* ignored); int time_screen(void* ignored);
MENUITEM_FUNCTION(timedate_item, MENU_FUNC_CHECK_RETVAL, ID2P(LANG_TIME_MENU), MENUITEM_FUNCTION(timedate_item, MENU_FUNC_CHECK_RETVAL, ID2P(LANG_TIME_MENU),
time_screen, NULL, NULL, Icon_Menu_setting ); time_screen, NULL, NULL, Icon_Menu_setting );
#endif #endif
MENUITEM_FUNCTION_DYNTEXT(sleep_timer_call, 0, sleep_timer, NULL, sleep_timer_getname,
sleep_timer_voice, NULL, NULL, Icon_Menu_setting);
/* make it look like a setting to the user */
#if CONFIG_RTC == 0
MENUITEM_SETTING(sleeptimer_on_startup,
&global_settings.sleeptimer_on_startup, NULL);
#endif
MENUITEM_FUNCTION(show_credits_item, 0, ID2P(LANG_CREDITS), MENUITEM_FUNCTION(show_credits_item, 0, ID2P(LANG_CREDITS),
(menu_function)show_credits, NULL, NULL, Icon_NOICON); (menu_function)show_credits, NULL, NULL, Icon_NOICON);
@ -511,8 +425,6 @@ MAKE_MENU(main_menu_, ID2P(LANG_SETTINGS), mainmenu_callback,
#endif #endif
#if CONFIG_RTC #if CONFIG_RTC
&timedate_item, &timedate_item,
#else
&sleep_timer_call, &sleeptimer_on_startup,
#endif #endif
&manage_settings, &manage_settings,
); );

View file

@ -215,9 +215,6 @@ MAKE_MENU(disk_menu, ID2P(LANG_DISK_MENU), 0, Icon_NOICON,
); );
#endif #endif
/* System menu */
MENUITEM_SETTING(poweroff, &global_settings.poweroff, NULL);
/* Limits menu */ /* Limits menu */
MENUITEM_SETTING(max_files_in_dir, &global_settings.max_files_in_dir, NULL); MENUITEM_SETTING(max_files_in_dir, &global_settings.max_files_in_dir, NULL);
MENUITEM_SETTING(max_files_in_playlist, &global_settings.max_files_in_playlist, NULL); MENUITEM_SETTING(max_files_in_playlist, &global_settings.max_files_in_playlist, NULL);
@ -276,7 +273,6 @@ MENUITEM_SETTING(accessory_supply, &global_settings.accessory_supply, NULL);
#ifdef HAVE_LINEOUT_POWEROFF #ifdef HAVE_LINEOUT_POWEROFF
MENUITEM_SETTING(lineout_onoff, &global_settings.lineout_active, NULL); MENUITEM_SETTING(lineout_onoff, &global_settings.lineout_active, NULL);
#endif #endif
MENUITEM_SETTING(start_screen, &global_settings.start_in_screen, NULL);
#ifdef USB_ENABLE_HID #ifdef USB_ENABLE_HID
MENUITEM_SETTING(usb_hid, &global_settings.usb_hid, NULL); MENUITEM_SETTING(usb_hid, &global_settings.usb_hid, NULL);
MENUITEM_SETTING(usb_keypad_mode, &global_settings.usb_keypad_mode, NULL); MENUITEM_SETTING(usb_keypad_mode, &global_settings.usb_keypad_mode, NULL);
@ -303,14 +299,12 @@ MENUITEM_SETTING(touchpad_sensitivity, &global_settings.touchpad_sensitivity, NU
MAKE_MENU(system_menu, ID2P(LANG_SYSTEM), MAKE_MENU(system_menu, ID2P(LANG_SYSTEM),
0, Icon_System_menu, 0, Icon_System_menu,
&start_screen,
#if (BATTERY_CAPACITY_INC > 0) || (BATTERY_TYPES_COUNT > 1) #if (BATTERY_CAPACITY_INC > 0) || (BATTERY_TYPES_COUNT > 1)
&battery_menu, &battery_menu,
#endif #endif
#if defined(HAVE_DIRCACHE) || defined(HAVE_DISK_STORAGE) #if defined(HAVE_DIRCACHE) || defined(HAVE_DISK_STORAGE)
&disk_menu, &disk_menu,
#endif #endif
&poweroff,
&limits_menu, &limits_menu,
#ifdef HAVE_MORSE_INPUT #ifdef HAVE_MORSE_INPUT
&morse_input, &morse_input,
@ -354,6 +348,108 @@ MAKE_MENU(system_menu, ID2P(LANG_SYSTEM),
/* SYSTEM MENU */ /* SYSTEM MENU */
/***********************************/ /***********************************/
/***********************************/
/* STARTUP/SHUTDOWN MENU */
/* sleep timer option */
const char* sleep_timer_formatter(char* buffer, size_t buffer_size,
int value, const char* unit)
{
(void) unit;
int minutes, hours;
if (value) {
hours = value / 60;
minutes = value - (hours * 60);
snprintf(buffer, buffer_size, "%d:%02d", hours, minutes);
return buffer;
} else {
return str(LANG_OFF);
}
}
static void sleep_timer_set(int minutes)
{
if (minutes)
global_settings.sleeptimer_duration = minutes;
set_sleep_timer(minutes * 60);
}
static int sleep_timer(void)
{
int minutes = global_settings.sleeptimer_duration;
if (get_sleep_timer())
sleep_timer_set(0);
else
set_int(str(LANG_SLEEP_TIMER), "", UNIT_MIN, &minutes,
&sleep_timer_set, 5, 0, 300, sleep_timer_formatter);
return 0;
}
static int seconds_to_min(int secs)
{
return (secs + 10) / 60; /* round up for 50+ seconds */
}
static char* sleep_timer_getname(int selected_item, void * data, char *buffer)
{
(void)selected_item;
(void)data;
int sec = get_sleep_timer();
char timer_buf[10];
/* we have no sprintf, so MAX_PATH is a guess */
if (sec > 0)
{ /* show cancel and countdown if running */
snprintf(buffer, MAX_PATH, "%s (%s)",
str(LANG_SLEEP_TIMER_CANCEL_CURRENT),
sleep_timer_formatter(timer_buf, sizeof(timer_buf),
seconds_to_min(sec), NULL));
}
else
snprintf(buffer, MAX_PATH, "%s", str(LANG_SLEEP_TIMER));
return buffer;
}
static int sleep_timer_voice(int selected_item, void*data)
{
(void)selected_item;
(void)data;
int seconds = get_sleep_timer();
if (seconds > 0)
{
long talk_ids[] = {
LANG_SLEEP_TIMER_CANCEL_CURRENT,
VOICE_PAUSE,
seconds_to_min(seconds) | UNIT_MIN << UNIT_SHIFT,
TALK_FINAL_ID
};
talk_idarray(talk_ids, true);
}
else
talk_id(LANG_SLEEP_TIMER, true);
return 0;
}
MENUITEM_SETTING(start_screen, &global_settings.start_in_screen, NULL);
MENUITEM_SETTING(poweroff, &global_settings.poweroff, NULL);
MENUITEM_FUNCTION_DYNTEXT(sleep_timer_call, 0, sleep_timer, NULL,
sleep_timer_getname, sleep_timer_voice, NULL, NULL,
Icon_Menu_setting);
/* make it look like a setting to the user */
MENUITEM_SETTING(sleeptimer_on_startup,
&global_settings.sleeptimer_on_startup, NULL);
MAKE_MENU(startup_shutdown_menu, ID2P(LANG_STARTUP_SHUTDOWN),
0, Icon_System_menu,
&start_screen,
&poweroff,
&sleep_timer_call,
&sleeptimer_on_startup
);
/* STARTUP/SHUTDOWN MENU */
/***********************************/
/***********************************/ /***********************************/
/* BOOKMARK MENU */ /* BOOKMARK MENU */
@ -513,6 +609,7 @@ MAKE_MENU(settings_menu_item, ID2P(LANG_GENERAL_SETTINGS), 0,
&tagcache_menu, &tagcache_menu,
#endif #endif
&display_menu, &system_menu, &display_menu, &system_menu,
&startup_shutdown_menu,
&bookmark_settings_menu, &bookmark_settings_menu,
#ifdef HAVE_TAGCACHE #ifdef HAVE_TAGCACHE
#if CONFIG_CODEC == SWCODEC #if CONFIG_CODEC == SWCODEC

View file

@ -28,10 +28,8 @@
#include "lang.h" #include "lang.h"
#include "action.h" #include "action.h"
#include "settings.h" #include "settings.h"
#include "powermgmt.h"
#include "menu.h" #include "menu.h"
#include "misc.h" #include "misc.h"
#include "exported_menus.h"
#include "keyboard.h" #include "keyboard.h"
#include "talk.h" #include "talk.h"
#include "time.h" #include "time.h"
@ -136,8 +134,6 @@ MENUITEM_FUNCTION(alarm_wake_up_screen, 0, ID2P(LANG_ALARM_WAKEUP_SCREEN),
#endif /* CONFIG_TUNER || defined(HAVE_RECORDING) */ #endif /* CONFIG_TUNER || defined(HAVE_RECORDING) */
#endif /* HAVE_RTC_ALARM */ #endif /* HAVE_RTC_ALARM */
MENUITEM_SETTING(sleeptimer_on_startup,
&global_settings.sleeptimer_on_startup, NULL);
void talk_timedate(void) void talk_timedate(void)
{ {
@ -237,14 +233,14 @@ static int time_menu_callback(int action,
MAKE_MENU(time_menu, ID2P(LANG_TIME_MENU), time_menu_callback, Icon_NOICON, MAKE_MENU(time_menu, ID2P(LANG_TIME_MENU), time_menu_callback, Icon_NOICON,
&time_set, &sleep_timer_call, &time_set,
#ifdef HAVE_RTC_ALARM #ifdef HAVE_RTC_ALARM
&alarm_screen_call, &alarm_screen_call,
#if defined(HAVE_RECORDING) || CONFIG_TUNER #if defined(HAVE_RECORDING) || CONFIG_TUNER
&alarm_wake_up_screen, &alarm_wake_up_screen,
#endif #endif
#endif #endif
&sleeptimer_on_startup, &timeformat); &timeformat);
int time_screen(void* ignored) int time_screen(void* ignored)
{ {

View file

@ -14,6 +14,7 @@
\input{configure_rockbox/database.tex} \input{configure_rockbox/database.tex}
\input{configure_rockbox/display_options.tex} \input{configure_rockbox/display_options.tex}
\input{configure_rockbox/system_options.tex} \input{configure_rockbox/system_options.tex}
\input{configure_rockbox/startup_shutdown_options.tex}
\input{configure_rockbox/bookmarking.tex} \input{configure_rockbox/bookmarking.tex}
\opt{tagcache}{\opt{swcodec}{ \opt{tagcache}{\opt{swcodec}{
\input{configure_rockbox/autoresume.tex} \input{configure_rockbox/autoresume.tex}
@ -21,12 +22,6 @@
\input{configure_rockbox/language.tex} \input{configure_rockbox/language.tex}
\input{configure_rockbox/voice.tex} \input{configure_rockbox/voice.tex}
\input{configure_rockbox/hotkey_settings.tex} \input{configure_rockbox/hotkey_settings.tex}
\nopt{rtc}{
\section{\label{ref:sleep_timer}Sleep Timer}
\begin{description}
\input{configure_rockbox/sleep_timer.tex}
\end{description}
}
\chapter{Theme Settings} \chapter{Theme Settings}
\label{ref:configure_rockbox_themes} \label{ref:configure_rockbox_themes}
@ -38,15 +33,6 @@
\input{configure_rockbox/recording_settings.tex} \input{configure_rockbox/recording_settings.tex}
} }
\nopt{rtc}{
\chapter{Sleep Timer related settings}
\label{ref:SleepTimerRelatedSettings}
These settings control the behaviour of the sleep timer.
\begin{description}
\input{configure_rockbox/sleep_timer.tex}
\end{description}
}
\opt{rtc}{ \opt{rtc}{
\chapter{Time and Date} \chapter{Time and Date}
\input{configure_rockbox/time_and_date.tex} \input{configure_rockbox/time_and_date.tex}

View file

@ -1,13 +0,0 @@
% $Id:$ %
\item[Sleep Timer:]
The \setting{Sleep Timer} powers off your \dap{} after playing for a given
time.
Shown when the \setting{Sleep Timer} is inactive, it can be set from
\setting{Off} to 5 hours in 5 minute steps.
While the \setting{Sleep Timer} is reset on boot, the value selected is
retained and will be used as the default from then on.
\item[Cancel Sleep Timer (h:mm):]
Shown when the \setting{Sleep Timer} is active, this option disables the
current \setting{Sleep Timer}.
\item[Start Sleep Timer On Boot:]
If set, a \setting{Sleep Timer} will be initiated when the device starts.

View file

@ -0,0 +1,57 @@
% $Id$ %
\section{\label{ref:StartupShutdownOptions}Startup/Shutdown}
The \setting{Startup/Shutdown} sub menu allows you to configure items which
are run at startup, or initiate a shutdown when conditions are met.
\subsection{Start Screen}
Set the screen that Rockbox will start in. The default is the main menu but
the following options are available:
% almost all items in the main menu with a few exceptions
\begin{description}
\item[Previous Screen.] Start Rockbox in the same screen as when it was
shut off.
\item[Main Menu.] Show the main menu.
\item[Files.] Display the file browser, starting in the root directory of
your \dap.
\item[Database.] Show the default database view.
\item[Resume Playback.] Go to the WPS and and resume playback from where
it was before turning off (if there is a playlist to resume).
\item[Settings.] Display the main settings menu.
\opt{recording}{
\item[Recording.] Start the \dap{} in the recording screen
(recording does not start automatically).
}
\opt{radio}{
\item[FM Radio.] Go to the radio screen and start playing.
}
\item[Recent Bookmarks.] Show the list of recent bookmarks as
described in \reference{ref:Bookmarkconfigactual}. Bookmarking needs
to be enabled.
\end{description}
\subsection{\label{ref:IdlePoweroffSetting}Idle Poweroff}
Rockbox can be configured to turn off power after the unit has been idle for
a defined number of minutes. The \dap{} is idle when playback is stopped or
paused. It is not idle while the USB or charger is connected
\opt{recording}{, or while recording}.
Settings are either \setting{Off} or 1 to 10 minutes in 1 minute steps. Then
15, 30, 45 or 60 minutes are available.
\subsection{Sleep Timer}
The \setting{Sleep Timer} powers off your \dap{} after a given time, whether
playing or not.
\begin{description}
\item[Sleep Timer:]
Shown when the \setting{Sleep Timer} is inactive, it can be set from
\setting{Off} to 5 hours in 5 minute steps.
While the \setting{Sleep Timer} is reset on boot, the value selected is
retained and will be used as the default from then on.
\item[Cancel Sleep Timer (h:mm):]
Shown when the \setting{Sleep Timer} is active, this option disables the
current \setting{Sleep Timer}.
\item[Start Sleep Timer On Boot:]
If set, a \setting{Sleep Timer} will be initiated when the device
starts.
\end{description}

View file

@ -1,27 +1,5 @@
% $Id$ % % $Id$ %
\section{\label{ref:SystemOptions}System} \section{\label{ref:SystemOptions}System}
\subsection{Start Screen}
Set the screen that Rockbox will start in. The default is the main menu but
the following options are available: % almost all items in the main menu with a few exceptions
\begin{description}
\item[Previous Screen.] Start Rockbox in the same screen as when it was shut off.
\item[Main Menu.] Show the main menu.
\item[Files.] Display the file browser, starting in the root directory of your \dap.
\item[Database.] Show the default database view.
\item[Resume Playback.] Go to the WPS and and resume playback from where it was
before turning off (if there is a playlist to resume).
\item[Settings.] Display the main settings menu.
\opt{recording}{%
\item[Recording.] Start the \dap{} in the recording screen
(recording does not start automatically).
}
\opt{radio}{%
\item[FM Radio.] Go to the radio screen and start playing.
}
\item[Recent Bookmarks.] Show the list of recent bookmarks as
described in \reference{ref:Bookmarkconfigactual}. Bookmarking needs
to be enabled.
\end{description}
\nopt{sansa}%will probably be there on Sansas one day - exclude it the simple way without specific option \nopt{sansa}%will probably be there on Sansas one day - exclude it the simple way without specific option
{\nopt{sansaAMS}{ {\nopt{sansaAMS}{
@ -112,15 +90,6 @@
\end{description} \end{description}
} % \opt{dircache,HAVE_DISK_STORAGE} } % \opt{dircache,HAVE_DISK_STORAGE}
\subsection{Idle Poweroff}
Rockbox can be configured to turn off power after the unit has been idle for a
defined number of minutes. The \dap{} is idle when playback is stopped or
paused. It is not idle while the USB or charger is connected
\opt{recording}{, or while recording}.
Settings are either \setting{Off} or 1 to 10 minutes in 1 minute steps. Then
15, 30, 45 or 60 minutes are available.
\subsection{Limits} \subsection{Limits}
This sub menu relates to limits in the Rockbox operating system. This sub menu relates to limits in the Rockbox operating system.
\begin{description} \begin{description}
@ -167,7 +136,8 @@ This sub menu relates to limits in the Rockbox operating system.
is turned off. If the \setting{Car Adapter Mode} is set to \setting{On}, is turned off. If the \setting{Car Adapter Mode} is set to \setting{On},
Rockbox will pause playback when the external power off condition is Rockbox will pause playback when the external power off condition is
detected. Rockbox will then shutdown the \dap{} after the length of time set detected. Rockbox will then shutdown the \dap{} after the length of time set
in the \setting{Idle Poweroff} setting (see above). in the \setting{Idle Poweroff} setting
(see \reference{ref:IdlePoweroffSetting}).
If power to the DC in jack is turned back on before the \emph{Idle Poweroff} If power to the DC in jack is turned back on before the \emph{Idle Poweroff}
function has shut the \dap{} off, playback will be resumed 5 seconds after function has shut the \dap{} off, playback will be resumed 5 seconds after
the power is applied. This delay is to allow for the time while the car the power is applied. This delay is to allow for the time while the car

View file

@ -18,6 +18,5 @@ if voice support is enabled.
This option controls what the \dap{} does when it is woken up by the alarm. This option controls what the \dap{} does when it is woken up by the alarm.
}%\opt{recording,radio} }%\opt{recording,radio}
}%\opt{alarm} }%\opt{alarm}
\input{configure_rockbox/sleep_timer.tex}
\item[Time Format:] Choose 12 or 24 hour clock. \item[Time Format:] Choose 12 or 24 hour clock.
\end{description} \end{description}

View file

@ -144,13 +144,6 @@ to recording. The details of this menu are covered in detail in
\reference{ref:Recordingsettings}. \reference{ref:Recordingsettings}.
} }
\nopt{rtc}{
\subsection{Sleep Timer related Settings}
The \setting{Sleep Timer} related settings allow you to configure the sleep timer
which powers off your \dap{} after playing for a given time.
The details of this menu are covered in detail in \reference{ref:SleepTimerRelatedSettings}.
}
\subsection{Manage Settings} \subsection{Manage Settings}
The \setting{Manage Settings} option allows the saving and re-loading of user The \setting{Manage Settings} option allows the saving and re-loading of user
configuration settings, browsing the hard drive for alternate firmwares, and finally configuration settings, browsing the hard drive for alternate firmwares, and finally