1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2007 Jonathan Gordon
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
29 #include "sound_menu.h"
30 #include "exported_menus.h"
37 #include "powermgmt.h"
39 #include "alarm_menu.h"
45 /***********************************/
49 static void tagcache_rebuild_with_splash(void)
52 gui_syncsplash(HZ
*2, ID2P(LANG_TAGCACHE_FORCE_UPDATE_SPLASH
));
55 static void tagcache_update_with_splash(void)
58 gui_syncsplash(HZ
*2, ID2P(LANG_TAGCACHE_FORCE_UPDATE_SPLASH
));
61 #ifdef HAVE_TC_RAMCACHE
62 MENUITEM_SETTING(tagcache_ram
, &global_settings
.tagcache_ram
, NULL
);
64 MENUITEM_SETTING(tagcache_autoupdate
, &global_settings
.tagcache_autoupdate
, NULL
);
65 MENUITEM_FUNCTION(tc_init
, 0, ID2P(LANG_TAGCACHE_FORCE_UPDATE
),
66 (int(*)(void))tagcache_rebuild_with_splash
,
67 NULL
, NULL
, Icon_NOICON
);
68 MENUITEM_FUNCTION(tc_update
, 0, ID2P(LANG_TAGCACHE_UPDATE
),
69 (int(*)(void))tagcache_update_with_splash
,
70 NULL
, NULL
, Icon_NOICON
);
71 MENUITEM_SETTING(runtimedb
, &global_settings
.runtimedb
, NULL
);
72 MENUITEM_FUNCTION(tc_export
, 0, ID2P(LANG_TAGCACHE_EXPORT
),
73 (int(*)(void))tagtree_export
, NULL
,
75 MENUITEM_FUNCTION(tc_import
, 0, ID2P(LANG_TAGCACHE_IMPORT
),
76 (int(*)(void))tagtree_import
, NULL
,
78 MAKE_MENU(tagcache_menu
, ID2P(LANG_TAGCACHE
), 0, Icon_NOICON
,
79 #ifdef HAVE_TC_RAMCACHE
82 &tagcache_autoupdate
, &tc_init
, &tc_update
, &runtimedb
,
83 &tc_export
, &tc_import
);
84 #endif /* HAVE_TAGCACHE */
86 /***********************************/
88 /***********************************/
90 static int fileview_callback(int action
,const struct menu_item_ex
*this_item
);
91 MENUITEM_SETTING(sort_case
, &global_settings
.sort_case
, NULL
);
92 MENUITEM_SETTING(sort_dir
, &global_settings
.sort_dir
, fileview_callback
);
93 MENUITEM_SETTING(sort_file
, &global_settings
.sort_file
, fileview_callback
);
94 MENUITEM_SETTING(dirfilter
, &global_settings
.dirfilter
, NULL
);
95 MENUITEM_SETTING(show_filename_ext
, &global_settings
.show_filename_ext
, NULL
);
96 MENUITEM_SETTING(browse_current
, &global_settings
.browse_current
, NULL
);
97 #ifdef HAVE_LCD_BITMAP
98 MENUITEM_SETTING(show_path_in_browser
, &global_settings
.show_path_in_browser
, NULL
);
100 static int fileview_callback(int action
,const struct menu_item_ex
*this_item
)
103 int *variable
= this_item
->variable
;
106 case ACTION_ENTER_MENUITEM
: /* on entering an item */
109 case ACTION_EXIT_MENUITEM
: /* on exit */
110 if (*variable
!= oldval
)
111 reload_directory(); /* force reload if this has changed */
117 MAKE_MENU(file_menu
, ID2P(LANG_FILE
), 0, Icon_file_view_menu
,
118 &sort_case
, &sort_dir
, &sort_file
,
119 &dirfilter
, &show_filename_ext
, &browse_current
,
120 #ifdef HAVE_LCD_BITMAP
121 &show_path_in_browser
125 /***********************************/
128 /***********************************/
132 #if BATTERY_CAPACITY_INC > 0
133 MENUITEM_SETTING(battery_capacity
, &global_settings
.battery_capacity
, NULL
);
135 #if BATTERY_TYPES_COUNT > 1
136 MENUITEM_SETTING(battery_type
, &global_settings
.battery_type
, NULL
);
138 #ifdef HAVE_USB_POWER
140 static int usbcharging_callback(int action
,const struct menu_item_ex
*this_item
)
145 case ACTION_EXIT_MENUITEM
: /* on exit */
146 usb_charging_enable(global_settings
.usb_charging
);
151 MENUITEM_SETTING(usb_charging
, &global_settings
.usb_charging
, usbcharging_callback
);
154 MAKE_MENU(battery_menu
, ID2P(LANG_BATTERY_MENU
), 0, Icon_NOICON
,
155 #if BATTERY_CAPACITY_INC > 0
158 #if BATTERY_TYPES_COUNT > 1
161 #ifdef HAVE_USB_POWER
168 #ifndef HAVE_FLASH_STORAGE
169 MENUITEM_SETTING(disk_spindown
, &global_settings
.disk_spindown
, NULL
);
172 static int dircache_callback(int action
,const struct menu_item_ex
*this_item
)
177 case ACTION_EXIT_MENUITEM
: /* on exit */
178 switch (global_settings
.dircache
)
181 if (!dircache_is_enabled())
182 gui_syncsplash(HZ
*2, ID2P(LANG_PLEASE_REBOOT
));
185 if (dircache_is_enabled())
193 MENUITEM_SETTING(dircache
, &global_settings
.dircache
, dircache_callback
);
195 #if defined(HAVE_DIRCACHE) || !defined(HAVE_FLASH_STORAGE)
196 MAKE_MENU(disk_menu
, ID2P(LANG_DISK_MENU
), 0, Icon_NOICON
,
197 #ifndef HAVE_FLASH_STORAGE
208 static int timedate_set(void)
213 /* Make a local copy of the time struct */
214 memcpy(&tm
, get_time(), sizeof(struct tm
));
216 /* do some range checks */
217 /* This prevents problems with time/date setting after a power loss */
218 if (!valid_time(&tm
))
220 /* Macros to convert a 2-digit string to a decimal constant.
221 (YEAR), MONTH and DAY are set by the date command, which outputs
222 DAY as 00..31 and MONTH as 01..12. The leading zero would lead to
223 misinterpretation as an octal constant. */
224 #define S100(x) 1 ## x
225 #define C2DIG2DEC(x) (S100(x)-100)
230 tm
.tm_mday
= C2DIG2DEC(DAY
);
231 tm
.tm_mon
= C2DIG2DEC(MONTH
)-1;
233 tm
.tm_year
= YEAR
-1900;
236 result
= (int)set_time_screen(str(LANG_SET_TIME
), &tm
);
238 if(tm
.tm_year
!= -1) {
244 MENUITEM_FUNCTION(time_set
, 0, ID2P(LANG_SET_TIME
),
245 timedate_set
, NULL
, NULL
, Icon_NOICON
);
246 MENUITEM_SETTING(timeformat
, &global_settings
.timeformat
, NULL
);
247 MAKE_MENU(time_menu
, ID2P(LANG_TIME_MENU
), 0, Icon_NOICON
, &time_set
, &timeformat
);
251 MENUITEM_SETTING(poweroff
, &global_settings
.poweroff
, NULL
);
253 #ifdef HAVE_RTC_ALARM
254 MENUITEM_FUNCTION(alarm_screen_call
, 0, ID2P(LANG_ALARM_MOD_ALARM_MENU
),
255 (menu_function
)alarm_screen
, NULL
, NULL
, Icon_NOICON
);
256 #if CONFIG_TUNER || defined(HAVE_RECORDING)
258 #if CONFIG_TUNER && !defined(HAVE_RECORDING)
259 /* This need only be shown if we dont have recording, because if we do
260 then always show the setting item, because there will always be at least
262 static int alarm_callback(int action
,const struct menu_item_ex
*this_item
)
267 case ACTION_REQUEST_MENUITEM
:
268 if (radio_hardware_present() == 0)
269 return ACTION_EXIT_MENUITEM
;
275 #define alarm_callback NULL
276 #endif /* CONFIG_TUNER && !HAVE_RECORDING */
277 /* have to do this manually because the setting screen
278 doesnt handle variable item count */
279 static int alarm_setting(void)
281 struct opt_items items
[ALARM_START_COUNT
];
283 items
[i
].string
= str(LANG_RESUME_PLAYBACK
);
284 items
[i
].voice_id
= LANG_RESUME_PLAYBACK
;
287 if (radio_hardware_present())
289 items
[i
].string
= str(LANG_FM_RADIO
);
290 items
[i
].voice_id
= LANG_FM_RADIO
;
294 #ifdef HAVE_RECORDING
295 items
[i
].string
= str(LANG_RECORDING
);
296 items
[i
].voice_id
= LANG_RECORDING
;
299 return set_option(str(LANG_ALARM_WAKEUP_SCREEN
),
300 &global_settings
.alarm_wake_up_screen
,
301 INT
, items
, i
, NULL
);
304 MENUITEM_FUNCTION(alarm_wake_up_screen
, 0, ID2P(LANG_ALARM_WAKEUP_SCREEN
),
305 alarm_setting
, NULL
, alarm_callback
, Icon_Menu_setting
);
306 #endif /* CONFIG_TUNER || defined(HAVE_RECORDING) */
307 #endif /* HAVE_RTC_ALARM */
310 MENUITEM_SETTING(max_files_in_dir
, &global_settings
.max_files_in_dir
, NULL
);
311 MENUITEM_SETTING(max_files_in_playlist
, &global_settings
.max_files_in_playlist
, NULL
);
312 MAKE_MENU(limits_menu
, ID2P(LANG_LIMITS_MENU
), 0, Icon_NOICON
,
313 &max_files_in_dir
, &max_files_in_playlist
);
317 #if CONFIG_CODEC == SWCODEC
318 MENUITEM_SETTING(keyclick
, &global_settings
.keyclick
, NULL
);
319 MENUITEM_SETTING(keyclick_repeats
, &global_settings
.keyclick_repeats
, NULL
);
320 MAKE_MENU(keyclick_menu
, ID2P(LANG_KEYCLICK
), 0, Icon_NOICON
,
321 &keyclick
, &keyclick_repeats
);
325 #if CONFIG_CODEC == MAS3507D
326 void dac_line_in(bool enable
);
327 static int linein_callback(int action
,const struct menu_item_ex
*this_item
)
332 case ACTION_EXIT_MENUITEM
: /* on exit */
334 dac_line_in(global_settings
.line_in
);
340 MENUITEM_SETTING(line_in
, &global_settings
.line_in
, linein_callback
);
343 MENUITEM_SETTING(car_adapter_mode
, &global_settings
.car_adapter_mode
, NULL
);
345 MENUITEM_SETTING(start_screen
, &global_settings
.start_in_screen
, NULL
);
347 #ifdef HAVE_BUTTON_LIGHT
348 MENUITEM_SETTING(buttonlight_timeout
, &global_settings
.buttonlight_timeout
, NULL
);
351 #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
352 MENUITEM_SETTING(buttonlight_brightness
, &global_settings
.buttonlight_brightness
, NULL
);
356 MAKE_MENU(system_menu
, ID2P(LANG_SYSTEM
),
359 #if (BATTERY_CAPACITY_INC > 0) || (BATTERY_TYPES_COUNT > 1)
362 #if defined(HAVE_DIRCACHE) || !defined(HAVE_FLASH_STORAGE)
369 #ifdef HAVE_RTC_ALARM
371 #if defined(HAVE_RECORDING) || CONFIG_TUNER
372 &alarm_wake_up_screen
,
376 #if CONFIG_CODEC == MAS3507D
382 #ifdef HAVE_BUTTON_LIGHT
383 &buttonlight_timeout
,
385 #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
386 &buttonlight_brightness
,
388 #if CONFIG_CODEC == SWCODEC
394 /***********************************/
397 /***********************************/
399 static int bmark_callback(int action
,const struct menu_item_ex
*this_item
)
404 case ACTION_EXIT_MENUITEM
: /* on exit */
405 if(global_settings
.autocreatebookmark
== BOOKMARK_RECENT_ONLY_YES
||
406 global_settings
.autocreatebookmark
== BOOKMARK_RECENT_ONLY_ASK
)
408 if(global_settings
.usemrb
== BOOKMARK_NO
)
409 global_settings
.usemrb
= BOOKMARK_YES
;
416 MENUITEM_SETTING(autocreatebookmark
,
417 &global_settings
.autocreatebookmark
, bmark_callback
);
418 MENUITEM_SETTING(autoloadbookmark
, &global_settings
.autoloadbookmark
, NULL
);
419 MENUITEM_SETTING(usemrb
, &global_settings
.usemrb
, NULL
);
420 MAKE_MENU(bookmark_settings_menu
, ID2P(LANG_BOOKMARK_SETTINGS
), 0,
422 &autocreatebookmark
, &autoloadbookmark
, &usemrb
);
424 /***********************************/
426 /***********************************/
428 static int talk_callback(int action
,const struct menu_item_ex
*this_item
);
429 MENUITEM_SETTING(talk_menu_item
, &global_settings
.talk_menu
, NULL
);
430 MENUITEM_SETTING(talk_dir_item
, &global_settings
.talk_dir
, NULL
);
431 MENUITEM_SETTING(talk_dir_clip_item
, &global_settings
.talk_dir_clip
, talk_callback
);
432 MENUITEM_SETTING(talk_file_item
, &global_settings
.talk_file
, NULL
);
433 MENUITEM_SETTING(talk_file_clip_item
, &global_settings
.talk_file_clip
, talk_callback
);
434 static int talk_callback(int action
,const struct menu_item_ex
*this_item
)
436 static int oldval
= 0;
439 case ACTION_ENTER_MENUITEM
:
440 oldval
= global_settings
.talk_file_clip
;
442 case ACTION_EXIT_MENUITEM
:
443 #if CONFIG_CODEC == SWCODEC
444 audio_set_crossfade(global_settings
.crossfade
);
446 if (this_item
== &talk_dir_clip_item
)
448 if (!oldval
&& global_settings
.talk_file_clip
)
450 /* force reload if newly talking thumbnails,
451 because the clip presence is cached only if enabled */
458 MENUITEM_SETTING(talk_filetype_item
, &global_settings
.talk_filetype
, NULL
);
459 MENUITEM_SETTING(talk_battery_level_item
,
460 &global_settings
.talk_battery_level
, NULL
);
461 MAKE_MENU(voice_settings_menu
, ID2P(LANG_VOICE
), 0, Icon_Voice
,
462 &talk_menu_item
, &talk_dir_item
, &talk_dir_clip_item
,
463 &talk_file_item
, &talk_file_clip_item
, &talk_filetype_item
,
464 &talk_battery_level_item
);
466 /***********************************/
468 /***********************************/
470 /***********************************/
472 static int language_browse(void)
474 return (int)rockbox_browse(LANG_DIR
, SHOW_LNG
);
476 MENUITEM_FUNCTION(browse_langs
, 0, ID2P(LANG_LANGUAGE
), language_browse
,
477 NULL
, NULL
, Icon_Language
);
479 MAKE_MENU(settings_menu_item
, ID2P(LANG_GENERAL_SETTINGS
), 0,
480 Icon_General_settings_menu
,
481 &playback_menu_item
, &playlist_settings
, &file_menu
,
485 &display_menu
, &system_menu
,
486 &bookmark_settings_menu
, &browse_langs
, &voice_settings_menu
489 /***********************************/