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"
38 #if CONFIG_CODEC == SWCODEC
42 #include "alarm_menu.h"
51 /***********************************/
55 static void tagcache_rebuild_with_splash(void)
58 gui_syncsplash(HZ
*2, ID2P(LANG_TAGCACHE_FORCE_UPDATE_SPLASH
));
61 static void tagcache_update_with_splash(void)
64 gui_syncsplash(HZ
*2, ID2P(LANG_TAGCACHE_FORCE_UPDATE_SPLASH
));
67 #ifdef HAVE_TC_RAMCACHE
68 MENUITEM_SETTING(tagcache_ram
, &global_settings
.tagcache_ram
, NULL
);
70 MENUITEM_SETTING(tagcache_autoupdate
, &global_settings
.tagcache_autoupdate
, NULL
);
71 MENUITEM_FUNCTION(tc_init
, 0, ID2P(LANG_TAGCACHE_FORCE_UPDATE
),
72 (int(*)(void))tagcache_rebuild_with_splash
,
73 NULL
, NULL
, Icon_NOICON
);
74 MENUITEM_FUNCTION(tc_update
, 0, ID2P(LANG_TAGCACHE_UPDATE
),
75 (int(*)(void))tagcache_update_with_splash
,
76 NULL
, NULL
, Icon_NOICON
);
77 MENUITEM_SETTING(runtimedb
, &global_settings
.runtimedb
, NULL
);
78 MENUITEM_FUNCTION(tc_export
, 0, ID2P(LANG_TAGCACHE_EXPORT
),
79 (int(*)(void))tagtree_export
, NULL
,
81 MENUITEM_FUNCTION(tc_import
, 0, ID2P(LANG_TAGCACHE_IMPORT
),
82 (int(*)(void))tagtree_import
, NULL
,
84 MAKE_MENU(tagcache_menu
, ID2P(LANG_TAGCACHE
), 0, Icon_NOICON
,
85 #ifdef HAVE_TC_RAMCACHE
88 &tagcache_autoupdate
, &tc_init
, &tc_update
, &runtimedb
,
89 &tc_export
, &tc_import
);
90 #endif /* HAVE_TAGCACHE */
92 /***********************************/
94 /***********************************/
96 static int fileview_callback(int action
,const struct menu_item_ex
*this_item
);
97 MENUITEM_SETTING(sort_case
, &global_settings
.sort_case
, NULL
);
98 MENUITEM_SETTING(sort_dir
, &global_settings
.sort_dir
, fileview_callback
);
99 MENUITEM_SETTING(sort_file
, &global_settings
.sort_file
, fileview_callback
);
100 MENUITEM_SETTING(dirfilter
, &global_settings
.dirfilter
, NULL
);
101 MENUITEM_SETTING(show_filename_ext
, &global_settings
.show_filename_ext
, NULL
);
102 MENUITEM_SETTING(browse_current
, &global_settings
.browse_current
, NULL
);
103 #ifdef HAVE_LCD_BITMAP
104 MENUITEM_SETTING(show_path_in_browser
, &global_settings
.show_path_in_browser
, NULL
);
106 static int fileview_callback(int action
,const struct menu_item_ex
*this_item
)
109 int *variable
= this_item
->variable
;
112 case ACTION_ENTER_MENUITEM
: /* on entering an item */
115 case ACTION_EXIT_MENUITEM
: /* on exit */
116 if (*variable
!= oldval
)
117 reload_directory(); /* force reload if this has changed */
123 MAKE_MENU(file_menu
, ID2P(LANG_FILE
), 0, Icon_file_view_menu
,
124 &sort_case
, &sort_dir
, &sort_file
,
125 &dirfilter
, &show_filename_ext
, &browse_current
,
126 #ifdef HAVE_LCD_BITMAP
127 &show_path_in_browser
131 /***********************************/
134 /***********************************/
138 #if BATTERY_CAPACITY_INC > 0
139 MENUITEM_SETTING(battery_capacity
, &global_settings
.battery_capacity
, NULL
);
141 #if BATTERY_TYPES_COUNT > 1
142 MENUITEM_SETTING(battery_type
, &global_settings
.battery_type
, NULL
);
144 #ifdef HAVE_USB_POWER
146 static int usbcharging_callback(int action
,const struct menu_item_ex
*this_item
)
151 case ACTION_EXIT_MENUITEM
: /* on exit */
152 usb_charging_enable(global_settings
.usb_charging
);
157 MENUITEM_SETTING(usb_charging
, &global_settings
.usb_charging
, usbcharging_callback
);
160 MAKE_MENU(battery_menu
, ID2P(LANG_BATTERY_MENU
), 0, Icon_NOICON
,
161 #if BATTERY_CAPACITY_INC > 0
164 #if BATTERY_TYPES_COUNT > 1
167 #ifdef HAVE_USB_POWER
174 #ifndef HAVE_FLASH_STORAGE
175 MENUITEM_SETTING(disk_spindown
, &global_settings
.disk_spindown
, NULL
);
178 static int dircache_callback(int action
,const struct menu_item_ex
*this_item
)
183 case ACTION_EXIT_MENUITEM
: /* on exit */
184 switch (global_settings
.dircache
)
187 if (!dircache_is_enabled())
188 gui_syncsplash(HZ
*2, ID2P(LANG_PLEASE_REBOOT
));
191 if (dircache_is_enabled())
199 MENUITEM_SETTING(dircache
, &global_settings
.dircache
, dircache_callback
);
201 #if defined(HAVE_DIRCACHE) || !defined(HAVE_FLASH_STORAGE)
202 MAKE_MENU(disk_menu
, ID2P(LANG_DISK_MENU
), 0, Icon_NOICON
,
203 #ifndef HAVE_FLASH_STORAGE
214 static int timedate_set(void)
219 /* Make a local copy of the time struct */
220 memcpy(&tm
, get_time(), sizeof(struct tm
));
222 /* do some range checks */
223 /* This prevents problems with time/date setting after a power loss */
224 if (!valid_time(&tm
))
226 /* Macros to convert a 2-digit string to a decimal constant.
227 (YEAR), MONTH and DAY are set by the date command, which outputs
228 DAY as 00..31 and MONTH as 01..12. The leading zero would lead to
229 misinterpretation as an octal constant. */
230 #define S100(x) 1 ## x
231 #define C2DIG2DEC(x) (S100(x)-100)
236 tm
.tm_mday
= C2DIG2DEC(DAY
);
237 tm
.tm_mon
= C2DIG2DEC(MONTH
)-1;
239 tm
.tm_year
= YEAR
-1900;
242 result
= (int)set_time_screen(str(LANG_SET_TIME
), &tm
);
244 if(tm
.tm_year
!= -1) {
250 MENUITEM_FUNCTION(time_set
, 0, ID2P(LANG_SET_TIME
),
251 timedate_set
, NULL
, NULL
, Icon_NOICON
);
252 MENUITEM_SETTING(timeformat
, &global_settings
.timeformat
, NULL
);
253 MAKE_MENU(time_menu
, ID2P(LANG_TIME_MENU
), 0, Icon_NOICON
, &time_set
, &timeformat
);
257 MENUITEM_SETTING(poweroff
, &global_settings
.poweroff
, NULL
);
259 #ifdef HAVE_RTC_ALARM
260 MENUITEM_FUNCTION(alarm_screen_call
, 0, ID2P(LANG_ALARM_MOD_ALARM_MENU
),
261 (menu_function
)alarm_screen
, NULL
, NULL
, Icon_NOICON
);
262 #if CONFIG_TUNER || defined(HAVE_RECORDING)
264 #if CONFIG_TUNER && !defined(HAVE_RECORDING)
265 /* This need only be shown if we dont have recording, because if we do
266 then always show the setting item, because there will always be at least
268 static int alarm_callback(int action
,const struct menu_item_ex
*this_item
)
273 case ACTION_REQUEST_MENUITEM
:
274 if (radio_hardware_present() == 0)
275 return ACTION_EXIT_MENUITEM
;
281 #define alarm_callback NULL
282 #endif /* CONFIG_TUNER && !HAVE_RECORDING */
283 /* have to do this manually because the setting screen
284 doesnt handle variable item count */
285 static int alarm_setting(void)
287 struct opt_items items
[ALARM_START_COUNT
];
289 items
[i
].string
= str(LANG_RESUME_PLAYBACK
);
290 items
[i
].voice_id
= LANG_RESUME_PLAYBACK
;
293 if (radio_hardware_present())
295 items
[i
].string
= str(LANG_FM_RADIO
);
296 items
[i
].voice_id
= LANG_FM_RADIO
;
300 #ifdef HAVE_RECORDING
301 items
[i
].string
= str(LANG_RECORDING
);
302 items
[i
].voice_id
= LANG_RECORDING
;
305 return set_option(str(LANG_ALARM_WAKEUP_SCREEN
),
306 &global_settings
.alarm_wake_up_screen
,
307 INT
, items
, i
, NULL
);
310 MENUITEM_FUNCTION(alarm_wake_up_screen
, 0, ID2P(LANG_ALARM_WAKEUP_SCREEN
),
311 alarm_setting
, NULL
, alarm_callback
, Icon_Menu_setting
);
312 #endif /* CONFIG_TUNER || defined(HAVE_RECORDING) */
313 #endif /* HAVE_RTC_ALARM */
316 MENUITEM_SETTING(max_files_in_dir
, &global_settings
.max_files_in_dir
, NULL
);
317 MENUITEM_SETTING(max_files_in_playlist
, &global_settings
.max_files_in_playlist
, NULL
);
318 MAKE_MENU(limits_menu
, ID2P(LANG_LIMITS_MENU
), 0, Icon_NOICON
,
319 &max_files_in_dir
, &max_files_in_playlist
);
323 #if CONFIG_CODEC == SWCODEC
324 MENUITEM_SETTING(keyclick
, &global_settings
.keyclick
, NULL
);
325 MENUITEM_SETTING(keyclick_repeats
, &global_settings
.keyclick_repeats
, NULL
);
326 MAKE_MENU(keyclick_menu
, ID2P(LANG_KEYCLICK
), 0, Icon_NOICON
,
327 &keyclick
, &keyclick_repeats
);
331 #if CONFIG_CODEC == MAS3507D
332 void dac_line_in(bool enable
);
333 static int linein_callback(int action
,const struct menu_item_ex
*this_item
)
338 case ACTION_EXIT_MENUITEM
: /* on exit */
340 dac_line_in(global_settings
.line_in
);
346 MENUITEM_SETTING(line_in
, &global_settings
.line_in
, linein_callback
);
349 MENUITEM_SETTING(car_adapter_mode
, &global_settings
.car_adapter_mode
, NULL
);
351 MENUITEM_SETTING(start_screen
, &global_settings
.start_in_screen
, NULL
);
353 #ifdef HAVE_BUTTON_LIGHT
354 MENUITEM_SETTING(buttonlight_timeout
, &global_settings
.buttonlight_timeout
, NULL
);
357 #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
358 MENUITEM_SETTING(buttonlight_brightness
, &global_settings
.buttonlight_brightness
, NULL
);
362 MAKE_MENU(system_menu
, ID2P(LANG_SYSTEM
),
365 #if (BATTERY_CAPACITY_INC > 0) || (BATTERY_TYPES_COUNT > 1)
368 #if defined(HAVE_DIRCACHE) || !defined(HAVE_FLASH_STORAGE)
375 #ifdef HAVE_RTC_ALARM
377 #if defined(HAVE_RECORDING) || CONFIG_TUNER
378 &alarm_wake_up_screen
,
382 #if CONFIG_CODEC == MAS3507D
388 #ifdef HAVE_BUTTON_LIGHT
389 &buttonlight_timeout
,
391 #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
392 &buttonlight_brightness
,
394 #if CONFIG_CODEC == SWCODEC
400 /***********************************/
403 /***********************************/
405 static int bmark_callback(int action
,const struct menu_item_ex
*this_item
)
410 case ACTION_EXIT_MENUITEM
: /* on exit */
411 if(global_settings
.autocreatebookmark
== BOOKMARK_RECENT_ONLY_YES
||
412 global_settings
.autocreatebookmark
== BOOKMARK_RECENT_ONLY_ASK
)
414 if(global_settings
.usemrb
== BOOKMARK_NO
)
415 global_settings
.usemrb
= BOOKMARK_YES
;
422 MENUITEM_SETTING(autocreatebookmark
,
423 &global_settings
.autocreatebookmark
, bmark_callback
);
424 MENUITEM_SETTING(autoloadbookmark
, &global_settings
.autoloadbookmark
, NULL
);
425 MENUITEM_SETTING(usemrb
, &global_settings
.usemrb
, NULL
);
426 MAKE_MENU(bookmark_settings_menu
, ID2P(LANG_BOOKMARK_SETTINGS
), 0,
428 &autocreatebookmark
, &autoloadbookmark
, &usemrb
);
430 /***********************************/
432 /***********************************/
434 static int talk_callback(int action
,const struct menu_item_ex
*this_item
);
435 MENUITEM_SETTING(talk_menu_item
, &global_settings
.talk_menu
, NULL
);
436 MENUITEM_SETTING(talk_dir_item
, &global_settings
.talk_dir
, NULL
);
437 MENUITEM_SETTING(talk_dir_clip_item
, &global_settings
.talk_dir_clip
, talk_callback
);
438 MENUITEM_SETTING(talk_file_item
, &global_settings
.talk_file
, NULL
);
439 MENUITEM_SETTING(talk_file_clip_item
, &global_settings
.talk_file_clip
, talk_callback
);
440 static int talk_callback(int action
,const struct menu_item_ex
*this_item
)
442 static int oldval
= 0;
445 case ACTION_ENTER_MENUITEM
:
446 oldval
= global_settings
.talk_file_clip
;
448 case ACTION_EXIT_MENUITEM
:
449 #if CONFIG_CODEC == SWCODEC
450 audio_set_crossfade(global_settings
.crossfade
);
452 if (this_item
== &talk_dir_clip_item
)
454 if (!oldval
&& global_settings
.talk_file_clip
)
456 /* force reload if newly talking thumbnails,
457 because the clip presence is cached only if enabled */
464 MENUITEM_SETTING(talk_filetype_item
, &global_settings
.talk_filetype
, NULL
);
465 MENUITEM_SETTING(talk_battery_level_item
,
466 &global_settings
.talk_battery_level
, NULL
);
467 MAKE_MENU(voice_settings_menu
, ID2P(LANG_VOICE
), 0, Icon_Voice
,
468 &talk_menu_item
, &talk_dir_item
, &talk_dir_clip_item
,
469 &talk_file_item
, &talk_file_clip_item
, &talk_filetype_item
,
470 &talk_battery_level_item
);
472 /***********************************/
474 /***********************************/
476 /***********************************/
478 static int language_browse(void)
480 return (int)rockbox_browse(LANG_DIR
, SHOW_LNG
);
482 MENUITEM_FUNCTION(browse_langs
, 0, ID2P(LANG_LANGUAGE
), language_browse
,
483 NULL
, NULL
, Icon_Language
);
485 MAKE_MENU(settings_menu_item
, ID2P(LANG_GENERAL_SETTINGS
), 0,
486 Icon_General_settings_menu
,
487 &playback_menu_item
, &playlist_settings
, &file_menu
,
491 &display_menu
, &system_menu
,
492 &bookmark_settings_menu
, &browse_langs
, &voice_settings_menu
495 /***********************************/