1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2003 Zakk Roberts
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
23 #include "clock_bitmaps.h"
24 #include "clock_settings.h"
25 #include "clock_menu.h"
26 #include "lib/playback_control.h"
28 /* Option structs (possible selections per each option) */
29 static const struct opt_items noyes_text
[] = {
34 static const struct opt_items backlight_settings_text
[] = {
36 { "Use Rockbox Setting", -1 },
40 static const struct opt_items idle_poweroff_text
[] = {
45 static const struct opt_items date_format_text
[] = {
48 { "European (D-M-Y)", -1 },
49 { "Japanese (Y-M-D)", -1 },
52 static const struct opt_items hour_format_text
[] = {
58 * Select a mode, returs true when the mode has been selected
59 * (we go back to clock display then)
61 static bool menu_mode_selector(void){
62 MENUITEM_STRINGLIST(menu
,"Mode Selector",NULL
, "Analog",
64 if(rb
->do_menu(&menu
, &clock_settings
.mode
, NULL
, false) >=0)
69 /**********************
70 * Analog settings menu
71 *********************/
72 static void menu_analog_settings(void)
74 int selection
=0, result
=0;
76 MENUITEM_STRINGLIST(menu
,"Analog Mode Settings",NULL
,"Show Date",
77 "Show Second Hand","Show Border");
80 result
=rb
->do_menu(&menu
, &selection
, NULL
, false);
83 rb
->set_option("Show Date", &clock_settings
.analog
.show_date
,
84 BOOL
, noyes_text
, 2, NULL
);
87 rb
->set_option("Show Second Hand",
88 &clock_settings
.analog
.show_seconds
,
89 BOOL
, noyes_text
, 2, NULL
);
92 rb
->set_option("Show Border",
93 &clock_settings
.analog
.show_border
,
94 BOOL
, noyes_text
, 2, NULL
);
100 /***********************
101 * Digital settings menu
102 **********************/
103 static void menu_digital_settings(void){
104 int selection
=0, result
=0;
106 MENUITEM_STRINGLIST(menu
,"Digital Mode Settings",NULL
,"Show Seconds",
110 result
=rb
->do_menu(&menu
, &selection
, NULL
, false);
113 rb
->set_option("Show Seconds",
114 &clock_settings
.digital
.show_seconds
,
115 BOOL
, noyes_text
, 2, NULL
);
118 rb
->set_option("Blinking Colon",
119 &clock_settings
.digital
.blinkcolon
,
120 BOOL
, noyes_text
, 2, NULL
);
126 /***********************************************************
127 * Confirm resetting of settings, used in general_settings()
128 **********************************************************/
129 static void confirm_reset(void){
132 rb
->set_option("Reset all settings?", &result
, INT
, noyes_text
, 2, NULL
);
134 if(result
== 1){ /* reset! */
135 clock_settings_reset(&clock_settings
);
136 rb
->splash(HZ
, "Settings reset!");
139 rb
->splash(HZ
, "Settings NOT reset.");
142 /************************************
143 * General settings. Reset, save, etc
144 ***********************************/
145 static void menu_general_settings(void){
146 int selection
=0, result
=0;
148 MENUITEM_STRINGLIST(menu
,"General Settings",NULL
,
149 "Hour Format","Date Format","Show Counter",
150 "Reset Settings","Save Settings Now",
151 "Save On Exit","Backlight Settings",
152 "Idle Poweroff (temporary)");
155 result
=rb
->do_menu(&menu
, &selection
, NULL
, false);
158 rb
->set_option("Hour format",
159 &clock_settings
.general
.hour_format
,
160 INT
, hour_format_text
, 2, NULL
);
163 rb
->set_option("Date format",
164 &clock_settings
.general
.date_format
,
165 INT
, date_format_text
, 4, NULL
);
168 rb
->set_option("Show Counter", &clock_settings
.general
.show_counter
,
169 BOOL
, noyes_text
, 2, NULL
);
176 save_settings_wo_gui();
177 rb
->splash(HZ
, "Settings saved");
181 rb
->set_option("Save On Exit",
182 &clock_settings
.general
.save_settings
,
183 BOOL
, noyes_text
, 2, NULL
);
185 /* if we no longer save on exit,
186 we better save now to remember that */
187 if(!clock_settings
.general
.save_settings
)
188 save_settings_wo_gui();
191 rb
->set_option("Backlight Settings",
192 &clock_settings
.general
.backlight
,
193 INT
, backlight_settings_text
, 3, NULL
);
194 apply_backlight_setting(clock_settings
.general
.backlight
);
198 rb
->set_option("Idle Poweroff (temporary)",
199 &clock_settings
.general
.idle_poweroff
,
200 BOOL
, idle_poweroff_text
, 2, NULL
);
209 bool main_menu(void){
212 bool exit_clock
=false;
214 MENUITEM_STRINGLIST(menu
,"Clock Menu",NULL
,"View Clock","Mode Selector",
215 "Mode Settings","General Settings","Playback Control",
219 switch(rb
->do_menu(&menu
, &selection
, NULL
, false)){
225 done
=menu_mode_selector();
229 switch(clock_settings
.mode
){
230 case ANALOG
: menu_analog_settings();break;
231 case DIGITAL
: menu_digital_settings();break;
232 case BINARY
: /* no settings */;break;
237 menu_general_settings();
241 playback_control(NULL
);