1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 Robert Hak
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 ****************************************************************************/
35 #include "settings_menu.h"
36 #include "backlight.h"
37 #include "playlist.h" /* for playlist_shuffle */
38 #include "fat.h" /* For dotfile settings */
39 #include "powermgmt.h"
45 #include "timefuncs.h"
55 #include "rbunicode.h"
59 #include "color_picker.h"
60 #include "scrobbler.h"
62 #ifdef HAVE_LCD_BITMAP
63 #include "peakmeter.h"
66 #if CONFIG_CODEC == MAS3507D
67 void dac_line_in(bool enable
);
70 #include "alarm_menu.h"
73 #ifdef HAVE_REMOTE_LCD
74 #include "lcd-remote.h"
77 #if CONFIG_CODEC == SWCODEC
79 #include "pcm_playback.h"
87 #ifdef CONFIG_CHARGING
88 static bool car_adapter_mode(void)
90 return set_bool( str(LANG_CAR_ADAPTER_MODE
),
91 &global_settings
.car_adapter_mode
);
96 * Menu to set icon visibility
98 static bool show_icons(void)
100 return set_bool( (char *)str(LANG_SHOW_ICONS
), &global_settings
.show_icons
);
103 static bool show_path(void)
105 static const struct opt_items names
[3] = {
107 { STR(LANG_SHOW_PATH_CURRENT
) },
108 { STR(LANG_SHOW_PATH_FULL
) },
111 return set_option(str(LANG_SHOW_PATH
),
112 &global_settings
.show_path_in_browser
,
113 INT
, names
, 3, NULL
);
117 * Menu to set the option to scroll paginated
119 static bool scroll_paginated(void)
121 return set_bool( (char *)str(LANG_SCROLL_PAGINATED
), &global_settings
.scroll_paginated
);
124 #ifdef HAVE_REMOTE_LCD
125 static bool remote_contrast(void)
127 return set_int( str(LANG_CONTRAST
), "", UNIT_INT
,
128 &global_settings
.remote_contrast
,
129 lcd_remote_set_contrast
, 1, MIN_REMOTE_CONTRAST_SETTING
,
130 MAX_REMOTE_CONTRAST_SETTING
, NULL
);
133 static bool remote_invert(void)
135 bool rc
= set_bool_options((char *)str(LANG_INVERT
),
136 &global_settings
.remote_invert
,
137 (char *)STR(LANG_INVERT_LCD_INVERSE
),
138 STR(LANG_INVERT_LCD_NORMAL
),
139 lcd_remote_set_invert_display
);
143 static bool remote_flip_display(void)
145 bool rc
= set_bool( (char *)str(LANG_FLIP_DISPLAY
),
146 &global_settings
.remote_flip_display
);
148 lcd_remote_set_flip(global_settings
.remote_flip_display
);
154 #ifdef HAVE_REMOTE_LCD_TICKING
155 static bool remote_reduce_ticking(void)
157 bool rc
= set_bool( str(LANG_REDUCE_TICKING
),
158 &global_settings
.remote_reduce_ticking
);
160 lcd_remote_emireduce(global_settings
.remote_reduce_ticking
);
167 #ifdef CONFIG_BACKLIGHT
168 static const struct opt_items backlight_timeouts
[] = {
171 { (unsigned char *)"1s ", TALK_ID(1, UNIT_SEC
) },
172 { (unsigned char *)"2s ", TALK_ID(2, UNIT_SEC
) },
173 { (unsigned char *)"3s ", TALK_ID(3, UNIT_SEC
) },
174 { (unsigned char *)"4s ", TALK_ID(4, UNIT_SEC
) },
175 { (unsigned char *)"5s ", TALK_ID(5, UNIT_SEC
) },
176 { (unsigned char *)"6s ", TALK_ID(6, UNIT_SEC
) },
177 { (unsigned char *)"7s ", TALK_ID(7, UNIT_SEC
) },
178 { (unsigned char *)"8s ", TALK_ID(8, UNIT_SEC
) },
179 { (unsigned char *)"9s ", TALK_ID(9, UNIT_SEC
) },
180 { (unsigned char *)"10s", TALK_ID(10, UNIT_SEC
) },
181 { (unsigned char *)"15s", TALK_ID(15, UNIT_SEC
) },
182 { (unsigned char *)"20s", TALK_ID(20, UNIT_SEC
) },
183 { (unsigned char *)"25s", TALK_ID(25, UNIT_SEC
) },
184 { (unsigned char *)"30s", TALK_ID(30, UNIT_SEC
) },
185 { (unsigned char *)"45s", TALK_ID(45, UNIT_SEC
) },
186 { (unsigned char *)"60s", TALK_ID(60, UNIT_SEC
) },
187 { (unsigned char *)"90s", TALK_ID(90, UNIT_SEC
) }
190 static bool caption_backlight(void)
192 return set_bool( (char *)str(LANG_CAPTION_BACKLIGHT
),
193 &global_settings
.caption_backlight
);
196 #ifdef CONFIG_CHARGING
197 static bool backlight_timer_plugged(void)
199 return set_option((char *)str(LANG_BACKLIGHT_ON_WHEN_CHARGING
),
200 &global_settings
.backlight_timeout_plugged
,
201 INT
, backlight_timeouts
, 19,
202 backlight_set_timeout_plugged
);
206 static bool backlight_timer(void)
208 return set_option((char *)str(LANG_BACKLIGHT
),
209 &global_settings
.backlight_timeout
,
210 INT
, backlight_timeouts
, 19,
211 backlight_set_timeout
);
214 #ifdef HAS_BUTTON_HOLD
215 static bool backlight_on_button_hold(void)
217 static const struct opt_items names
[3] = {
218 { STR(LANG_BACKLIGHT_ON_BUTTON_HOLD_NORMAL
) },
222 return set_option(str(LANG_BACKLIGHT_ON_BUTTON_HOLD
),
223 &global_settings
.backlight_on_button_hold
,
225 backlight_set_on_button_hold
);
227 #endif /* HAS_BUTTON_HOLD */
229 #if defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR)
230 static bool backlight_fade_in(void)
232 static const struct opt_items names
[] = {
234 { (unsigned char *)"500ms", TALK_ID(500, UNIT_MS
) },
235 { (unsigned char *)"1s", TALK_ID(1, UNIT_SEC
) },
236 { (unsigned char *)"2s", TALK_ID(2, UNIT_SEC
) },
238 return set_option(str(LANG_BACKLIGHT_FADE_IN
),
239 &global_settings
.backlight_fade_in
,
240 INT
, names
, 4, backlight_set_fade_in
);
243 static bool backlight_fade_out(void)
245 static const struct opt_items names
[] = {
247 { (unsigned char *)"500ms", TALK_ID(500, UNIT_MS
) },
248 { (unsigned char *)"1s", TALK_ID(1, UNIT_SEC
) },
249 { (unsigned char *)"2s", TALK_ID(2, UNIT_SEC
) },
250 { (unsigned char *)"3s", TALK_ID(3, UNIT_SEC
) },
251 { (unsigned char *)"4s", TALK_ID(4, UNIT_SEC
) },
252 { (unsigned char *)"5s", TALK_ID(5, UNIT_SEC
) },
253 { (unsigned char *)"10s", TALK_ID(10, UNIT_SEC
) },
255 return set_option(str(LANG_BACKLIGHT_FADE_OUT
),
256 &global_settings
.backlight_fade_out
,
257 INT
, names
, 8, backlight_set_fade_out
);
261 #ifdef HAVE_LCD_SLEEP
262 static bool lcd_sleep_after_backlight_off(void)
264 static const struct opt_items names
[] = {
265 { STR(LANG_ALWAYS
) },
267 { (unsigned char *)"5s", TALK_ID(5, UNIT_SEC
) },
268 { (unsigned char *)"10s", TALK_ID(10, UNIT_SEC
) },
269 { (unsigned char *)"15s", TALK_ID(15, UNIT_SEC
) },
270 { (unsigned char *)"20s", TALK_ID(20, UNIT_SEC
) },
271 { (unsigned char *)"30s", TALK_ID(30, UNIT_SEC
) },
272 { (unsigned char *)"45s", TALK_ID(45, UNIT_SEC
) },
273 { (unsigned char *)"60s", TALK_ID(60, UNIT_SEC
) },
274 { (unsigned char *)"90s", TALK_ID(90, UNIT_SEC
) },
277 return set_option(str(LANG_LCD_SLEEP_AFTER_BACKLIGHT_OFF
),
278 &global_settings
.lcd_sleep_after_backlight_off
,
280 lcd_set_sleep_after_backlight_off
);
282 #endif /* HAVE_LCD_SLEEP */
283 #endif /* CONFIG_BACKLIGHT */
285 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
286 static bool brightness(void)
288 return set_int( str(LANG_BRIGHTNESS
), "", UNIT_INT
,
289 &global_settings
.brightness
,
290 backlight_set_brightness
, 1, MIN_BRIGHTNESS_SETTING
,
291 MAX_BRIGHTNESS_SETTING
, NULL
);
295 #ifdef HAVE_REMOTE_LCD
297 static bool remote_backlight_timer(void)
299 return set_option((char *)str(LANG_BACKLIGHT
),
300 &global_settings
.remote_backlight_timeout
,
301 INT
, backlight_timeouts
, 19,
302 remote_backlight_set_timeout
);
305 #ifdef CONFIG_CHARGING
306 static bool remote_backlight_timer_plugged(void)
308 return set_option((char *)str(LANG_BACKLIGHT_ON_WHEN_CHARGING
),
309 &global_settings
.remote_backlight_timeout_plugged
,
310 INT
, backlight_timeouts
, 19,
311 remote_backlight_set_timeout_plugged
);
313 #endif /* HAVE_REMOTE_LCD */
315 static bool remote_caption_backlight(void)
317 return set_bool((char *)str(LANG_CAPTION_BACKLIGHT
),
318 &global_settings
.remote_caption_backlight
);
321 #ifdef HAS_REMOTE_BUTTON_HOLD
322 static bool remote_backlight_on_button_hold(void)
324 static const struct opt_items names
[3] = {
325 { STR(LANG_BACKLIGHT_ON_BUTTON_HOLD_NORMAL
) },
329 return set_option(str(LANG_BACKLIGHT_ON_BUTTON_HOLD
),
330 &global_settings
.remote_backlight_on_button_hold
,
332 remote_backlight_set_on_button_hold
);
334 #endif /* HAS_BUTTON_HOLD */
336 #endif /* HAVE_REMOTE_LCD */
338 #ifdef HAVE_LCD_CONTRAST
339 static bool contrast(void)
341 return set_int( str(LANG_CONTRAST
), "", UNIT_INT
,
342 &global_settings
.contrast
,
343 lcd_set_contrast
, 1, MIN_CONTRAST_SETTING
,
344 MAX_CONTRAST_SETTING
, NULL
);
346 #endif /* HAVE_LCD_CONTRAST */
348 #ifdef HAVE_LCD_BITMAP
349 #ifdef HAVE_LCD_INVERT
351 * Menu to set LCD Mode (normal/inverse)
353 static bool invert(void)
355 bool rc
= set_bool_options(str(LANG_INVERT
),
356 &global_settings
.invert
,
357 (char *)STR(LANG_INVERT_LCD_INVERSE
),
358 STR(LANG_INVERT_LCD_NORMAL
),
359 lcd_set_invert_display
);
362 #endif /* HAVE_LCD_INVERT */
366 * Menu to turn the display+buttons by 180 degrees
368 static bool flip_display(void)
370 bool rc
= set_bool( str(LANG_FLIP_DISPLAY
),
371 &global_settings
.flip_display
);
373 button_set_flip(global_settings
.flip_display
);
374 lcd_set_flip(global_settings
.flip_display
);
378 #endif /* HAVE_LCD_FLIP */
381 * Menu to set Line Selector Type (Pointer/Bar)
383 static bool invert_cursor(void)
385 bool type
= global_settings
.invert_cursor
;
386 bool rc
= set_bool_options(str(LANG_INVERT_CURSOR
),
388 STR(LANG_INVERT_CURSOR_BAR
),
389 STR(LANG_INVERT_CURSOR_POINTER
),
391 global_settings
.invert_cursor
= type
;
397 * Menu to clear the backdrop image
399 static bool clear_main_backdrop(void)
401 global_settings
.backdrop_file
[0]=0;
402 unload_main_backdrop();
403 show_main_backdrop();
408 #ifdef HAVE_USB_POWER
409 #ifdef CONFIG_CHARGING
414 #ifdef HAVE_LCD_COLOR
416 * Menu for fore/back colors
418 static bool set_fg_color(void)
422 res
= set_color(NULL
,str(LANG_FOREGROUND_COLOR
),
423 &global_settings
.fg_color
,global_settings
.bg_color
);
425 screens
[SCREEN_MAIN
].set_foreground(global_settings
.fg_color
);
430 static bool set_bg_color(void)
434 res
= set_color(NULL
,str(LANG_BACKGROUND_COLOR
),
435 &global_settings
.bg_color
,global_settings
.fg_color
);
437 screens
[SCREEN_MAIN
].set_background(global_settings
.bg_color
);
442 static bool reset_color(void)
444 global_settings
.fg_color
= LCD_DEFAULT_FG
;
445 global_settings
.bg_color
= LCD_DEFAULT_BG
;
447 screens
[SCREEN_MAIN
].set_foreground(global_settings
.fg_color
);
448 screens
[SCREEN_MAIN
].set_background(global_settings
.bg_color
);
453 #ifdef HAVE_USB_POWER
454 #ifdef CONFIG_CHARGING
456 * Menu to switch the USB charging on or off
458 static bool usb_charging(void)
460 bool rc
= set_bool(str(LANG_USB_CHARGING
),
461 &global_settings
.usb_charging
);
462 /* if (usb_charging_enabled() != global_settings.usb_charging) */
463 usb_charging_enable(global_settings
.usb_charging
);
470 * Menu to configure the battery display on status bar
472 static bool battery_display(void)
474 static const struct opt_items names
[] = {
475 { STR(LANG_DISPLAY_GRAPHIC
) },
476 { STR(LANG_DISPLAY_NUMERIC
) }
478 return set_option( str(LANG_BATTERY_DISPLAY
),
479 &global_settings
.battery_display
, INT
, names
, 2, NULL
);
483 * Menu to configure the volume display on status bar
485 static bool volume_type(void)
487 static const struct opt_items names
[] = {
488 { STR(LANG_DISPLAY_GRAPHIC
) },
489 { STR(LANG_DISPLAY_NUMERIC
) }
491 return set_option( str(LANG_VOLUME_DISPLAY
), &global_settings
.volume_type
,
492 INT
, names
, 2, NULL
);
496 * Menu to set the hold time of normal peaks.
498 static bool peak_meter_hold(void) {
500 static const struct opt_items names
[] = {
502 { "200 ms " , TALK_ID(200, UNIT_MS
) },
503 { "300 ms " , TALK_ID(300, UNIT_MS
) },
504 { "500 ms " , TALK_ID(500, UNIT_MS
) },
505 { "1 s" , TALK_ID(1, UNIT_SEC
) },
506 { "2 s" , TALK_ID(2, UNIT_SEC
) },
507 { "3 s" , TALK_ID(3, UNIT_SEC
) },
508 { "4 s" , TALK_ID(4, UNIT_SEC
) },
509 { "5 s" , TALK_ID(5, UNIT_SEC
) },
510 { "6 s" , TALK_ID(6, UNIT_SEC
) },
511 { "7 s" , TALK_ID(7, UNIT_SEC
) },
512 { "8 s" , TALK_ID(8, UNIT_SEC
) },
513 { "9 s" , TALK_ID(9, UNIT_SEC
) },
514 { "10 s" , TALK_ID(10, UNIT_SEC
) },
515 { "15 s" , TALK_ID(15, UNIT_SEC
) },
516 { "20 s" , TALK_ID(20, UNIT_SEC
) },
517 { "30 s" , TALK_ID(30, UNIT_SEC
) },
518 { "1 min" , TALK_ID(1, UNIT_MIN
) }
520 retval
= set_option( str(LANG_PM_PEAK_HOLD
),
521 &global_settings
.peak_meter_hold
, INT
, names
,
524 peak_meter_init_times(global_settings
.peak_meter_release
,
525 global_settings
.peak_meter_hold
,
526 global_settings
.peak_meter_clip_hold
);
532 * Menu to set the hold time of clips.
534 static bool peak_meter_clip_hold(void) {
537 static const struct opt_items names
[] = {
538 { STR(LANG_PM_ETERNAL
) },
539 { "1s " , TALK_ID(1, UNIT_SEC
) },
540 { "2s " , TALK_ID(2, UNIT_SEC
) },
541 { "3s " , TALK_ID(3, UNIT_SEC
) },
542 { "4s " , TALK_ID(4, UNIT_SEC
) },
543 { "5s " , TALK_ID(5, UNIT_SEC
) },
544 { "6s " , TALK_ID(6, UNIT_SEC
) },
545 { "7s " , TALK_ID(7, UNIT_SEC
) },
546 { "8s " , TALK_ID(8, UNIT_SEC
) },
547 { "9s " , TALK_ID(9, UNIT_SEC
) },
548 { "10s" , TALK_ID(10, UNIT_SEC
) },
549 { "15s" , TALK_ID(15, UNIT_SEC
) },
550 { "20s" , TALK_ID(20, UNIT_SEC
) },
551 { "25s" , TALK_ID(25, UNIT_SEC
) },
552 { "30s" , TALK_ID(30, UNIT_SEC
) },
553 { "45s" , TALK_ID(45, UNIT_SEC
) },
554 { "60s" , TALK_ID(60, UNIT_SEC
) },
555 { "90s" , TALK_ID(90, UNIT_SEC
) },
556 { "2min" , TALK_ID(2, UNIT_MIN
) },
557 { "3min" , TALK_ID(3, UNIT_MIN
) },
558 { "5min" , TALK_ID(5, UNIT_MIN
) },
559 { "10min" , TALK_ID(10, UNIT_MIN
) },
560 { "20min" , TALK_ID(20, UNIT_MIN
) },
561 { "45min" , TALK_ID(45, UNIT_MIN
) },
562 { "90min" , TALK_ID(90, UNIT_MIN
) }
564 retval
= set_option( str(LANG_PM_CLIP_HOLD
),
565 &global_settings
.peak_meter_clip_hold
, INT
, names
,
566 25, peak_meter_set_clip_hold
);
568 peak_meter_init_times(global_settings
.peak_meter_release
,
569 global_settings
.peak_meter_hold
,
570 global_settings
.peak_meter_clip_hold
);
576 * Menu to set the release time of the peak meter.
578 static bool peak_meter_release(void) {
581 /* The range of peak_meter_release is restricted so that it
582 fits into a 7 bit number. The 8th bit is used for storing
583 something else in the rtc ram.
584 Also, the max value is 0x7e, since the RTC value 0xff is reserved */
585 retval
= set_int( str(LANG_PM_RELEASE
), str(LANG_PM_UNITS_PER_READ
),
586 LANG_PM_UNITS_PER_READ
,
587 &global_settings
.peak_meter_release
,
588 NULL
, 1, 1, 0x7e, NULL
);
590 peak_meter_init_times(global_settings
.peak_meter_release
,
591 global_settings
.peak_meter_hold
,
592 global_settings
.peak_meter_clip_hold
);
598 * Menu to select wether the scale of the meter
599 * displays dBfs of linear values.
601 static bool peak_meter_scale(void) {
603 bool use_dbfs
= global_settings
.peak_meter_dbfs
;
604 retval
= set_bool_options(str(LANG_PM_SCALE
),
606 STR(LANG_PM_DBFS
), STR(LANG_PM_LINEAR
),
609 /* has the user really changed the scale? */
610 if (use_dbfs
!= global_settings
.peak_meter_dbfs
) {
612 /* store the change */
613 global_settings
.peak_meter_dbfs
= use_dbfs
;
614 peak_meter_set_use_dbfs(use_dbfs
);
616 /* If the user changed the scale mode the meaning of
617 peak_meter_min (peak_meter_max) has changed. Thus we have
618 to convert the values stored in global_settings. */
621 /* we only store -dBfs */
622 global_settings
.peak_meter_min
= -peak_meter_get_min() / 100;
623 global_settings
.peak_meter_max
= -peak_meter_get_max() / 100;
628 global_settings
.peak_meter_min
= peak_meter_get_min();
630 /* converting dBfs -> percent results in a precision loss.
631 I assume that the user doesn't bother that conversion
632 dBfs <-> percent isn't symmetrical for odd values but that
633 he wants 0 dBfs == 100%. Thus I 'correct' the percent value
634 resulting from dBfs -> percent manually here */
635 max
= peak_meter_get_max();
636 global_settings
.peak_meter_max
= max
< 99 ? max
: 100;
638 settings_apply_pm_range();
644 * Adjust the min value of the value range that
645 * the peak meter shall visualize.
647 static bool peak_meter_min(void) {
649 if (global_settings
.peak_meter_dbfs
) {
652 int range_max
= -global_settings
.peak_meter_max
;
653 int min
= -global_settings
.peak_meter_min
;
655 retval
= set_int(str(LANG_PM_MIN
), str(LANG_PM_DBFS
), UNIT_DB
,
656 &min
, NULL
, 1, -89, range_max
, NULL
);
658 global_settings
.peak_meter_min
= - min
;
661 /* for linear scale */
663 int min
= global_settings
.peak_meter_min
;
665 retval
= set_int(str(LANG_PM_MIN
), "%", UNIT_PERCENT
,
667 1, 0, global_settings
.peak_meter_max
- 1, NULL
);
669 global_settings
.peak_meter_min
= (unsigned char)min
;
672 settings_apply_pm_range();
678 * Adjust the max value of the value range that
679 * the peak meter shall visualize.
681 static bool peak_meter_max(void) {
683 if (global_settings
.peak_meter_dbfs
) {
686 int range_min
= -global_settings
.peak_meter_min
;
687 int max
= -global_settings
.peak_meter_max
;;
689 retval
= set_int(str(LANG_PM_MAX
), str(LANG_PM_DBFS
), UNIT_DB
,
690 &max
, NULL
, 1, range_min
, 0, NULL
);
692 global_settings
.peak_meter_max
= - max
;
696 /* for linear scale */
698 int max
= global_settings
.peak_meter_max
;
700 retval
= set_int(str(LANG_PM_MAX
), "%", UNIT_PERCENT
,
702 1, global_settings
.peak_meter_min
+ 1, 100, NULL
);
704 global_settings
.peak_meter_max
= (unsigned char)max
;
707 settings_apply_pm_range();
712 * Menu to configure the peak meter
714 static bool peak_meter_menu(void)
719 static const struct menu_item items
[] = {
720 { ID2P(LANG_PM_RELEASE
) , peak_meter_release
},
721 { ID2P(LANG_PM_PEAK_HOLD
), peak_meter_hold
},
722 { ID2P(LANG_PM_CLIP_HOLD
), peak_meter_clip_hold
},
723 { ID2P(LANG_PM_SCALE
) , peak_meter_scale
},
724 { ID2P(LANG_PM_MIN
) , peak_meter_min
},
725 { ID2P(LANG_PM_MAX
) , peak_meter_max
},
728 m
=menu_init( items
, sizeof(items
) / sizeof(*items
), NULL
,
730 result
= menu_run(m
);
734 #endif /* HAVE_LCD_BITMAP */
736 static bool shuffle(void)
738 return set_bool( str(LANG_SHUFFLE
), &global_settings
.playlist_shuffle
);
741 static bool repeat_mode(void)
744 static const struct opt_items names
[] = {
746 { STR(LANG_REPEAT_ALL
) },
747 { STR(LANG_REPEAT_ONE
) },
748 { STR(LANG_SHUFFLE
) },
749 #if (AB_REPEAT_ENABLE == 1)
750 { STR(LANG_REPEAT_AB
) }
753 int old_repeat
= global_settings
.repeat_mode
;
755 result
= set_option( str(LANG_REPEAT
), &global_settings
.repeat_mode
,
756 INT
, names
, NUM_REPEAT_MODES
, NULL
);
758 if (old_repeat
!= global_settings
.repeat_mode
&&
759 (audio_status() & AUDIO_STATUS_PLAY
))
760 audio_flush_and_reload_tracks();
765 static bool play_selected(void)
767 return set_bool( str(LANG_PLAY_SELECTED
), &global_settings
.play_selected
);
770 static bool dir_filter(void)
772 static const struct opt_items names
[] = {
773 { STR(LANG_FILTER_ALL
) },
774 { STR(LANG_FILTER_SUPPORTED
) },
775 { STR(LANG_FILTER_MUSIC
) },
776 { STR(LANG_FILTER_PLAYLIST
) },
778 { STR(LANG_FILTER_ID3DB
) }
782 return set_option( str(LANG_FILTER
), &global_settings
.dirfilter
, INT
,
785 return set_option( str(LANG_FILTER
), &global_settings
.dirfilter
, INT
,
790 static bool sort_case(void)
792 return set_bool( str(LANG_SORT_CASE
), &global_settings
.sort_case
);
795 static bool sort_file(void)
797 int oldval
= global_settings
.sort_file
;
799 static const struct opt_items names
[] = {
800 { STR(LANG_SORT_ALPHA
) },
801 { STR(LANG_SORT_DATE
) },
802 { STR(LANG_SORT_DATE_REVERSE
) },
803 { STR(LANG_SORT_TYPE
) }
805 ret
= set_option( str(LANG_SORT_FILE
), &global_settings
.sort_file
, INT
,
807 if (global_settings
.sort_file
!= oldval
)
808 reload_directory(); /* force reload if this has changed */
812 static bool sort_dir(void)
814 int oldval
= global_settings
.sort_dir
;
816 static const struct opt_items names
[] = {
817 { STR(LANG_SORT_ALPHA
) },
818 { STR(LANG_SORT_DATE
) },
819 { STR(LANG_SORT_DATE_REVERSE
) }
821 ret
= set_option( str(LANG_SORT_DIR
), &global_settings
.sort_dir
, INT
,
823 if (global_settings
.sort_dir
!= oldval
)
824 reload_directory(); /* force reload if this has changed */
828 static bool resume(void)
830 return set_bool( str(LANG_RESUME
), &global_settings
.resume
);
833 #ifdef HAVE_SPDIF_POWER
834 static bool spdif(void)
836 bool rc
= set_bool_options(str(LANG_SPDIF_ENABLE
),
837 &global_settings
.spdif_enable
,
845 static bool autocreatebookmark(void)
848 static const struct opt_items names
[] = {
849 { STR(LANG_SET_BOOL_NO
) },
850 { STR(LANG_SET_BOOL_YES
) },
851 { STR(LANG_RESUME_SETTING_ASK
) },
852 { STR(LANG_BOOKMARK_SETTINGS_RECENT_ONLY_YES
) },
853 { STR(LANG_BOOKMARK_SETTINGS_RECENT_ONLY_ASK
) }
856 retval
= set_option( str(LANG_BOOKMARK_SETTINGS_AUTOCREATE
),
857 &global_settings
.autocreatebookmark
, INT
,
859 if(global_settings
.autocreatebookmark
== BOOKMARK_RECENT_ONLY_YES
||
860 global_settings
.autocreatebookmark
== BOOKMARK_RECENT_ONLY_ASK
)
862 if(global_settings
.usemrb
== BOOKMARK_NO
)
863 global_settings
.usemrb
= BOOKMARK_YES
;
869 static bool autoloadbookmark(void)
871 static const struct opt_items names
[] = {
872 { STR(LANG_SET_BOOL_NO
) },
873 { STR(LANG_SET_BOOL_YES
) },
874 { STR(LANG_RESUME_SETTING_ASK
) }
876 return set_option( str(LANG_BOOKMARK_SETTINGS_AUTOLOAD
),
877 &global_settings
.autoloadbookmark
, INT
,
881 static bool useMRB(void)
883 static const struct opt_items names
[] = {
884 { STR(LANG_SET_BOOL_NO
) },
885 { STR(LANG_SET_BOOL_YES
) },
886 { STR(LANG_BOOKMARK_SETTINGS_UNIQUE_ONLY
) }
888 return set_option( str(LANG_BOOKMARK_SETTINGS_MAINTAIN_RECENT_BOOKMARKS
),
889 &global_settings
.usemrb
, INT
,
893 static bool poweroff_idle_timer(void)
895 static const struct opt_items names
[] = {
897 { "1m ", TALK_ID(1, UNIT_MIN
) },
898 { "2m ", TALK_ID(2, UNIT_MIN
) },
899 { "3m ", TALK_ID(3, UNIT_MIN
) },
900 { "4m ", TALK_ID(4, UNIT_MIN
) },
901 { "5m ", TALK_ID(5, UNIT_MIN
) },
902 { "6m ", TALK_ID(6, UNIT_MIN
) },
903 { "7m ", TALK_ID(7, UNIT_MIN
) },
904 { "8m ", TALK_ID(8, UNIT_MIN
) },
905 { "9m ", TALK_ID(9, UNIT_MIN
) },
906 { "10m", TALK_ID(10, UNIT_MIN
) },
907 { "15m", TALK_ID(15, UNIT_MIN
) },
908 { "30m", TALK_ID(30, UNIT_MIN
) },
909 { "45m", TALK_ID(45, UNIT_MIN
) },
910 { "60m", TALK_ID(60, UNIT_MIN
) }
912 return set_option(str(LANG_POWEROFF_IDLE
), &global_settings
.poweroff
,
913 INT
, names
, 15, set_poweroff_timeout
);
916 static void sleep_timer_formatter(char* buffer
, int buffer_size
, int value
,
925 minutes
= value
- (hours
* 60);
926 snprintf(buffer
, buffer_size
, "%d:%02d", hours
, minutes
);
928 snprintf(buffer
, buffer_size
, "%s", str(LANG_OFF
));
932 static void sleep_timer_set(int minutes
)
934 set_sleep_timer(minutes
* 60);
937 static bool sleep_timer(void)
939 int minutes
= (get_sleep_timer() + 59) / 60; /* round up */
941 return set_int(str(LANG_SLEEP_TIMER
), "", UNIT_MIN
, &minutes
,
942 &sleep_timer_set
, 5, 0, 300, sleep_timer_formatter
);
945 static bool scroll_speed(void)
947 return set_int(str(LANG_SCROLL
), "", UNIT_INT
,
948 &global_settings
.scroll_speed
,
949 &lcd_scroll_speed
, 1, 0, 15, NULL
);
952 static bool scroll_delay(void)
954 int dummy
= global_settings
.scroll_delay
* (HZ
/10);
955 int rc
= set_int(str(LANG_SCROLL_DELAY
), "ms", UNIT_MS
,
957 &lcd_scroll_delay
, 100, 0, 2500, NULL
);
958 global_settings
.scroll_delay
= dummy
/ (HZ
/10);
962 #ifdef HAVE_REMOTE_LCD
963 static bool remote_scroll_speed(void)
965 return set_int(str(LANG_SCROLL
), "", UNIT_INT
,
966 &global_settings
.remote_scroll_speed
,
967 &lcd_remote_scroll_speed
, 1, 0, 15, NULL
);
970 static bool remote_scroll_step(void)
972 return set_int(str(LANG_SCROLL_STEP_EXAMPLE
), str(LANG_PIXELS
), UNIT_PIXEL
,
973 &global_settings
.remote_scroll_step
,
974 &lcd_remote_scroll_step
, 1, 1, LCD_WIDTH
, NULL
);
977 static bool remote_scroll_delay(void)
979 int dummy
= global_settings
.remote_scroll_delay
* (HZ
/10);
980 int rc
= set_int(str(LANG_SCROLL_DELAY
), "ms", UNIT_MS
,
982 &lcd_remote_scroll_delay
, 100, 0, 2500, NULL
);
983 global_settings
.remote_scroll_delay
= dummy
/ (HZ
/10);
987 static bool remote_bidir_limit(void)
989 return set_int(str(LANG_BIDIR_SCROLL
), "%", UNIT_PERCENT
,
990 &global_settings
.remote_bidir_limit
,
991 &lcd_remote_bidir_scroll
, 25, 0, 200, NULL
);
996 #ifdef HAVE_LCD_BITMAP
997 static bool screen_scroll(void)
999 bool rc
= set_bool( str(LANG_SCREEN_SCROLL_VIEW
), &global_settings
.offset_out_of_view
);
1000 gui_list_screen_scroll_out_of_view(global_settings
.offset_out_of_view
);
1004 static bool screen_scroll_step(void)
1006 return set_int(str(LANG_SCREEN_SCROLL_STEP
), str(LANG_PIXELS
), UNIT_PIXEL
,
1007 &global_settings
.screen_scroll_step
,
1008 &gui_list_screen_scroll_step
, 1, 1, LCD_WIDTH
, NULL
);
1011 static bool scroll_step(void)
1013 return set_int(str(LANG_SCROLL_STEP_EXAMPLE
), str(LANG_PIXELS
), UNIT_PIXEL
,
1014 &global_settings
.scroll_step
,
1015 &lcd_scroll_step
, 1, 1, LCD_WIDTH
, NULL
);
1019 static bool bidir_limit(void)
1021 return set_int(str(LANG_BIDIR_SCROLL
), "%", UNIT_PERCENT
,
1022 &global_settings
.bidir_limit
,
1023 &lcd_bidir_scroll
, 25, 0, 200, NULL
);
1026 #ifdef HAVE_LCD_CHARCELLS
1027 static bool jump_scroll(void)
1029 static const struct opt_items names
[] = {
1031 { STR(LANG_ONE_TIME
) },
1032 { "2", TALK_ID(2, UNIT_INT
) },
1033 { "3", TALK_ID(3, UNIT_INT
) },
1034 { "4", TALK_ID(4, UNIT_INT
) },
1035 { STR(LANG_ALWAYS
) }
1038 ret
=set_option(str(LANG_JUMP_SCROLL
), &global_settings
.jump_scroll
,
1039 INT
, names
, 6, lcd_jump_scroll
);
1042 static bool jump_scroll_delay(void)
1044 int dummy
= global_settings
.jump_scroll_delay
* (HZ
/10);
1045 int rc
= set_int(str(LANG_JUMP_SCROLL_DELAY
), "ms", UNIT_MS
,
1047 &lcd_jump_scroll_delay
, 100, 0, 2500, NULL
);
1048 global_settings
.jump_scroll_delay
= dummy
/ (HZ
/10);
1055 * Menu to set the battery capacity
1057 static bool battery_capacity(void)
1059 return set_int(str(LANG_BATTERY_CAPACITY
), "mAh", UNIT_MAH
,
1060 &global_settings
.battery_capacity
,
1061 &set_battery_capacity
, BATTERY_CAPACITY_INC
, BATTERY_CAPACITY_MIN
,
1062 BATTERY_CAPACITY_MAX
, NULL
);
1065 #if BATTERY_TYPES_COUNT > 1
1066 static bool battery_type(void)
1068 static const struct opt_items names
[] = {
1069 { STR(LANG_BATTERY_TYPE_ALKALINE
) },
1070 { STR(LANG_BATTERY_TYPE_NIMH
) }
1073 return set_option(str(LANG_BATTERY_TYPE
), &global_settings
.battery_type
,
1074 INT
, names
, 2, set_battery_type
);
1080 static bool timedate_set(void)
1085 /* Make a local copy of the time struct */
1086 memcpy(&tm
, get_time(), sizeof(struct tm
));
1088 /* do some range checks */
1089 /* This prevents problems with time/date setting after a power loss */
1090 if (!valid_time(&tm
))
1102 result
= set_time_screen(str(LANG_TIME
), &tm
);
1104 if(tm
.tm_year
!= -1) {
1110 static bool timeformat_set(void)
1112 static const struct opt_items names
[] = {
1113 { STR(LANG_24_HOUR_CLOCK
) },
1114 { STR(LANG_12_HOUR_CLOCK
) }
1116 return set_option(str(LANG_TIMEFORMAT
), &global_settings
.timeformat
,
1117 INT
, names
, 2, NULL
);
1122 static bool spindown(void)
1124 return set_int(str(LANG_SPINDOWN
), "s", UNIT_SEC
,
1125 &global_settings
.disk_spindown
,
1126 ata_spindown
, 1, 3, 254, NULL
);
1129 #endif /* !HAVE_MMC */
1131 #if CONFIG_CODEC == MAS3507D
1132 static bool line_in(void)
1134 bool rc
= set_bool(str(LANG_LINE_IN
), &global_settings
.line_in
);
1136 dac_line_in(global_settings
.line_in
);
1142 static bool max_files_in_dir(void)
1144 return set_int(str(LANG_MAX_FILES_IN_DIR
), "", UNIT_INT
,
1145 &global_settings
.max_files_in_dir
,
1146 NULL
, 50, 50, 10000, NULL
);
1149 static bool max_files_in_playlist(void)
1151 return set_int(str(LANG_MAX_FILES_IN_PLAYLIST
), "", UNIT_INT
,
1152 &global_settings
.max_files_in_playlist
,
1153 NULL
, 1000, 1000, 20000, NULL
);
1156 #if CONFIG_CODEC == SWCODEC
1157 static bool buffer_margin(void)
1160 static const struct opt_items names
[] = {
1161 { "5s", TALK_ID(5, UNIT_SEC
) },
1162 { "15s", TALK_ID(15, UNIT_SEC
) },
1163 { "30s", TALK_ID(30, UNIT_SEC
) },
1164 { "1min", TALK_ID(1, UNIT_MIN
) },
1165 { "2min", TALK_ID(2, UNIT_MIN
) },
1166 { "3min", TALK_ID(3, UNIT_MIN
) },
1167 { "5min", TALK_ID(5, UNIT_MIN
) },
1168 { "10min", TALK_ID(10, UNIT_MIN
) }
1171 ret
= set_option(str(LANG_MP3BUFFER_MARGIN
), &global_settings
.buffer_margin
,
1172 INT
, names
, 8, NULL
);
1173 audio_set_buffer_margin(global_settings
.buffer_margin
);
1178 static bool buffer_margin(void)
1180 return set_int(str(LANG_MP3BUFFER_MARGIN
), "s", UNIT_SEC
,
1181 &global_settings
.buffer_margin
,
1182 audio_set_buffer_margin
, 1, 0, 7, NULL
);
1186 static bool ff_rewind_min_step(void)
1188 static const struct opt_items names
[] = {
1189 { "1s", TALK_ID(1, UNIT_SEC
) },
1190 { "2s", TALK_ID(2, UNIT_SEC
) },
1191 { "3s", TALK_ID(3, UNIT_SEC
) },
1192 { "4s", TALK_ID(4, UNIT_SEC
) },
1193 { "5s", TALK_ID(5, UNIT_SEC
) },
1194 { "6s", TALK_ID(6, UNIT_SEC
) },
1195 { "8s", TALK_ID(8, UNIT_SEC
) },
1196 { "10s", TALK_ID(10, UNIT_SEC
) },
1197 { "15s", TALK_ID(15, UNIT_SEC
) },
1198 { "20s", TALK_ID(20, UNIT_SEC
) },
1199 { "25s", TALK_ID(25, UNIT_SEC
) },
1200 { "30s", TALK_ID(30, UNIT_SEC
) },
1201 { "45s", TALK_ID(45, UNIT_SEC
) },
1202 { "60s", TALK_ID(60, UNIT_SEC
) }
1204 return set_option(str(LANG_FFRW_STEP
), &global_settings
.ff_rewind_min_step
,
1205 INT
, names
, 14, NULL
);
1208 static bool set_fade_on_stop(void)
1210 return set_bool( str(LANG_FADE_ON_STOP
), &global_settings
.fade_on_stop
);
1213 static bool set_party_mode(void)
1215 return set_bool( str(LANG_PARTY_MODE
), &global_settings
.party_mode
);
1218 #ifdef CONFIG_BACKLIGHT
1219 static bool set_bl_filter_first_keypress(void)
1221 bool result
= set_bool( str(LANG_BACKLIGHT_FILTER_FIRST_KEYPRESS
),
1222 &global_settings
.bl_filter_first_keypress
);
1223 set_backlight_filter_keypress(global_settings
.bl_filter_first_keypress
);
1226 #ifdef HAVE_REMOTE_LCD
1227 static bool set_remote_bl_filter_first_keypress(void)
1229 bool result
= set_bool( str(LANG_BACKLIGHT_FILTER_FIRST_KEYPRESS
),
1230 &global_settings
.remote_bl_filter_first_keypress
);
1231 set_remote_backlight_filter_keypress(global_settings
.remote_bl_filter_first_keypress
);
1237 static bool ff_rewind_accel(void)
1239 static const struct opt_items names
[] = {
1241 { "2x/1s", TALK_ID(1, UNIT_SEC
) },
1242 { "2x/2s", TALK_ID(2, UNIT_SEC
) },
1243 { "2x/3s", TALK_ID(3, UNIT_SEC
) },
1244 { "2x/4s", TALK_ID(4, UNIT_SEC
) },
1245 { "2x/5s", TALK_ID(5, UNIT_SEC
) },
1246 { "2x/6s", TALK_ID(6, UNIT_SEC
) },
1247 { "2x/7s", TALK_ID(7, UNIT_SEC
) },
1248 { "2x/8s", TALK_ID(8, UNIT_SEC
) },
1249 { "2x/9s", TALK_ID(9, UNIT_SEC
) },
1250 { "2x/10s", TALK_ID(10, UNIT_SEC
) },
1251 { "2x/11s", TALK_ID(11, UNIT_SEC
) },
1252 { "2x/12s", TALK_ID(12, UNIT_SEC
) },
1253 { "2x/13s", TALK_ID(13, UNIT_SEC
) },
1254 { "2x/14s", TALK_ID(14, UNIT_SEC
) },
1255 { "2x/15s", TALK_ID(15, UNIT_SEC
) }
1257 return set_option(str(LANG_FFRW_ACCEL
), &global_settings
.ff_rewind_accel
,
1258 INT
, names
, 16, NULL
);
1261 static bool browse_current(void)
1263 return set_bool( str(LANG_FOLLOW
), &global_settings
.browse_current
);
1266 static bool custom_wps_browse(void)
1268 return rockbox_browse(WPS_DIR
, SHOW_WPS
);
1271 #ifdef HAVE_REMOTE_LCD
1272 static bool custom_remote_wps_browse(void)
1274 return rockbox_browse(WPS_DIR
, SHOW_RWPS
);
1278 static bool custom_cfg_browse(void)
1280 return rockbox_browse(ROCKBOX_DIR
, SHOW_CFG
);
1283 static bool language_browse(void)
1285 return rockbox_browse(LANG_DIR
, SHOW_LNG
);
1288 static bool voice_menus(void)
1291 bool temp
= global_settings
.talk_menu
;
1292 /* work on a temp variable first, avoid "life" disabling */
1293 ret
= set_bool( str(LANG_VOICE_MENU
), &temp
);
1294 global_settings
.talk_menu
= temp
;
1298 /* this is used 2 times below, so it saves memory to put it in global scope */
1299 static const struct opt_items voice_names
[] = {
1301 { STR(LANG_VOICE_NUMBER
) },
1302 { STR(LANG_VOICE_SPELL
) },
1303 { STR(LANG_VOICE_DIR_HOVER
) }
1306 static bool voice_dirs(void)
1308 bool ret
= set_option( str(LANG_VOICE_DIR
),
1309 &global_settings
.talk_dir
, INT
, voice_names
, 4, NULL
);
1310 #if CONFIG_CODEC == SWCODEC
1311 audio_set_crossfade(global_settings
.crossfade
);
1316 static bool voice_files(void)
1318 int oldval
= global_settings
.talk_file
;
1321 ret
= set_option( str(LANG_VOICE_FILE
),
1322 &global_settings
.talk_file
, INT
, voice_names
, 4, NULL
);
1323 #if CONFIG_CODEC == SWCODEC
1324 audio_set_crossfade(global_settings
.crossfade
);
1326 if (oldval
!= 3 && global_settings
.talk_file
== 3)
1327 { /* force reload if newly talking thumbnails,
1328 because the clip presence is cached only if enabled */
1334 static bool voice_menu(void)
1339 static const struct menu_item items
[] = {
1340 { ID2P(LANG_VOICE_MENU
), voice_menus
},
1341 { ID2P(LANG_VOICE_DIR
), voice_dirs
},
1342 { ID2P(LANG_VOICE_FILE
), voice_files
}
1345 m
=menu_init( items
, sizeof(items
) / sizeof(*items
), NULL
,
1347 result
= menu_run(m
);
1352 #ifdef HAVE_LCD_BITMAP
1353 static bool font_browse(void)
1355 return rockbox_browse(FONT_DIR
, SHOW_FONT
);
1358 static bool scroll_bar(void)
1360 return set_bool( str(LANG_SCROLL_BAR
), &global_settings
.scrollbar
);
1363 static bool status_bar(void)
1365 return set_bool( str(LANG_STATUS_BAR
), &global_settings
.statusbar
);
1368 #if CONFIG_KEYPAD == RECORDER_PAD
1369 static bool button_bar(void)
1371 return set_bool( str(LANG_BUTTON_BAR
), &global_settings
.buttonbar
);
1373 #endif /* CONFIG_KEYPAD == RECORDER_PAD */
1374 #endif /* HAVE_LCD_BITMAP */
1376 static bool ff_rewind_settings_menu(void)
1381 static const struct menu_item items
[] = {
1382 { ID2P(LANG_FFRW_STEP
), ff_rewind_min_step
},
1383 { ID2P(LANG_FFRW_ACCEL
), ff_rewind_accel
},
1386 m
=menu_init( items
, sizeof(items
) / sizeof(*items
), NULL
,
1388 result
= menu_run(m
);
1394 static bool id3_order(void)
1396 return set_bool_options( str(LANG_ID3_ORDER
),
1397 &global_settings
.id3_v1_first
,
1398 STR(LANG_ID3_V1_FIRST
),
1399 STR(LANG_ID3_V2_FIRST
),
1403 static bool next_folder(void)
1405 static const struct opt_items names
[] = {
1406 { STR(LANG_SET_BOOL_NO
) },
1407 { STR(LANG_SET_BOOL_YES
) },
1408 { STR(LANG_RANDOM
) },
1410 return set_option(str(LANG_NEXT_FOLDER
),
1411 &global_settings
.next_folder
,
1412 INT
, names
, 3, NULL
);
1415 static bool audioscrobbler(void)
1417 bool result
= set_bool_options(str(LANG_AUDIOSCROBBLER
),
1418 &global_settings
.audioscrobbler
,
1423 if (!scrobbler_is_enabled() && global_settings
.audioscrobbler
)
1424 gui_syncsplash(HZ
*2, true, str(LANG_PLEASE_REBOOT
));
1426 if(scrobbler_is_enabled() && !global_settings
.audioscrobbler
)
1427 scrobbler_shutdown();
1432 static bool codepage_setting(void)
1434 static const struct opt_items names
[] = {
1435 { STR(LANG_CODEPAGE_LATIN1
) },
1436 { STR(LANG_CODEPAGE_GREEK
) },
1437 { STR(LANG_CODEPAGE_HEBREW
) },
1438 { STR(LANG_CODEPAGE_CYRILLIC
) },
1439 { STR(LANG_CODEPAGE_THAI
) },
1440 { STR(LANG_CODEPAGE_ARABIC
) },
1441 { STR(LANG_CODEPAGE_TURKISH
) },
1442 { STR(LANG_CODEPAGE_LATIN_EXTENDED
) },
1443 { STR(LANG_CODEPAGE_JAPANESE
) },
1444 { STR(LANG_CODEPAGE_SIMPLIFIED
) },
1445 { STR(LANG_CODEPAGE_KOREAN
) },
1446 { STR(LANG_CODEPAGE_TRADITIONAL
) },
1447 { STR(LANG_CODEPAGE_UTF8
) },
1449 return set_option(str(LANG_DEFAULT_CODEPAGE
),
1450 &global_settings
.default_codepage
,
1451 INT
, names
, 13, set_codepage
);
1454 #if CONFIG_CODEC == SWCODEC
1455 static bool replaygain(void)
1457 bool result
= set_bool(str(LANG_REPLAYGAIN_ENABLE
),
1458 &global_settings
.replaygain
);
1460 dsp_set_replaygain(true);
1464 static bool replaygain_mode(void)
1466 static const struct opt_items names
[] = {
1467 { STR(LANG_TRACK_GAIN
) },
1468 { STR(LANG_ALBUM_GAIN
) },
1469 { STR(LANG_SHUFFLE_GAIN
) },
1471 bool result
= set_option(str(LANG_REPLAYGAIN_MODE
),
1472 &global_settings
.replaygain_type
, INT
, names
, 3, NULL
);
1474 dsp_set_replaygain(true);
1478 static bool replaygain_noclip(void)
1480 bool result
= set_bool(str(LANG_REPLAYGAIN_NOCLIP
),
1481 &global_settings
.replaygain_noclip
);
1483 dsp_set_replaygain(true);
1487 static void replaygain_preamp_format(char* buffer
, int buffer_size
, int value
,
1492 snprintf(buffer
, buffer_size
, "%s%d.%d %s", value
< 0 ? "-" : "",
1493 v
/ 10, v
% 10, unit
);
1496 static bool replaygain_preamp(void)
1498 bool result
= set_int(str(LANG_REPLAYGAIN_PREAMP
), str(LANG_UNIT_DB
),
1499 UNIT_DB
, &global_settings
.replaygain_preamp
, NULL
, 1, -120, 120,
1500 replaygain_preamp_format
);
1502 dsp_set_replaygain(true);
1506 static bool replaygain_settings_menu(void)
1511 static const struct menu_item items
[] = {
1512 { ID2P(LANG_REPLAYGAIN_ENABLE
), replaygain
},
1513 { ID2P(LANG_REPLAYGAIN_NOCLIP
), replaygain_noclip
},
1514 { ID2P(LANG_REPLAYGAIN_MODE
), replaygain_mode
},
1515 { ID2P(LANG_REPLAYGAIN_PREAMP
), replaygain_preamp
},
1518 m
=menu_init( items
, sizeof(items
) / sizeof(*items
), NULL
,
1520 result
= menu_run(m
);
1525 static bool crossfade(void)
1527 static const struct opt_items names
[] = {
1529 { STR(LANG_SHUFFLE
) },
1530 { STR(LANG_TRACKSKIP
) },
1531 { STR(LANG_SHUFFLE_TRACKSKIP
) },
1532 { STR(LANG_ALWAYS
) },
1537 ret
=set_option( str(LANG_CROSSFADE_ENABLE
),
1538 &global_settings
.crossfade
, INT
, names
, 5, NULL
);
1539 audio_set_crossfade(global_settings
.crossfade
);
1543 static bool crossfade_fade_in_delay(void)
1547 ret
= set_int(str(LANG_CROSSFADE_FADE_IN_DELAY
), "s", UNIT_SEC
,
1548 &global_settings
.crossfade_fade_in_delay
,
1549 NULL
, 1, 0, 7, NULL
);
1550 audio_set_crossfade(global_settings
.crossfade
);
1554 static bool crossfade_fade_out_delay(void)
1558 ret
= set_int(str(LANG_CROSSFADE_FADE_OUT_DELAY
), "s", UNIT_SEC
,
1559 &global_settings
.crossfade_fade_out_delay
,
1560 NULL
, 1, 0, 7, NULL
);
1561 audio_set_crossfade(global_settings
.crossfade
);
1565 static bool crossfade_fade_in_duration(void)
1569 ret
= set_int(str(LANG_CROSSFADE_FADE_IN_DURATION
), "s", UNIT_SEC
,
1570 &global_settings
.crossfade_fade_in_duration
,
1571 NULL
, 1, 0, 15, NULL
);
1572 audio_set_crossfade(global_settings
.crossfade
);
1576 static bool crossfade_fade_out_duration(void)
1580 ret
= set_int(str(LANG_CROSSFADE_FADE_OUT_DURATION
), "s", UNIT_SEC
,
1581 &global_settings
.crossfade_fade_out_duration
,
1582 NULL
, 1, 0, 15, NULL
);
1583 audio_set_crossfade(global_settings
.crossfade
);
1587 static bool crossfade_fade_out_mixmode(void)
1589 static const struct opt_items names
[] = {
1590 { STR(LANG_CROSSFADE
) },
1594 ret
=set_option( str(LANG_CROSSFADE_FADE_OUT_MODE
),
1595 &global_settings
.crossfade_fade_out_mixmode
, INT
, names
, 2, NULL
);
1601 * Menu to configure the crossfade settings.
1603 static bool crossfade_settings_menu(void)
1608 static const struct menu_item items
[] = {
1609 { ID2P(LANG_CROSSFADE_ENABLE
), crossfade
},
1610 { ID2P(LANG_CROSSFADE_FADE_IN_DELAY
), crossfade_fade_in_delay
},
1611 { ID2P(LANG_CROSSFADE_FADE_IN_DURATION
), crossfade_fade_in_duration
},
1612 { ID2P(LANG_CROSSFADE_FADE_OUT_DELAY
), crossfade_fade_out_delay
},
1613 { ID2P(LANG_CROSSFADE_FADE_OUT_DURATION
), crossfade_fade_out_duration
},
1614 { ID2P(LANG_CROSSFADE_FADE_OUT_MODE
), crossfade_fade_out_mixmode
},
1617 m
=menu_init( items
, sizeof(items
) / sizeof(*items
), NULL
,
1619 result
= menu_run(m
);
1624 static bool beep(void)
1626 static const struct opt_items names
[] = {
1629 { STR(LANG_MODERATE
) },
1630 { STR(LANG_STRONG
) },
1633 ret
=set_option( str(LANG_BEEP
),
1634 &global_settings
.beep
, INT
, names
, 4, NULL
);
1641 #ifdef HAVE_DIRCACHE
1642 static bool dircache(void)
1644 bool result
= set_bool_options(str(LANG_DIRCACHE_ENABLE
),
1645 &global_settings
.dircache
,
1650 if (!dircache_is_enabled() && global_settings
.dircache
)
1651 gui_syncsplash(HZ
*2, true, str(LANG_PLEASE_REBOOT
));
1658 #endif /* HAVE_DIRCACHE */
1660 #ifdef HAVE_TAGCACHE
1661 #ifdef HAVE_TC_RAMCACHE
1662 static bool tagcache_ram(void)
1664 bool result
= set_bool_options(str(LANG_TAGCACHE_RAM
),
1665 &global_settings
.tagcache_ram
,
1666 STR(LANG_SET_BOOL_YES
),
1667 STR(LANG_SET_BOOL_NO
),
1674 static bool tagcache_autoupdate(void)
1676 bool rc
= set_bool_options(str(LANG_TAGCACHE_AUTOUPDATE
),
1677 &global_settings
.tagcache_autoupdate
,
1684 static bool tagcache_runtimedb(void)
1686 bool rc
= set_bool_options(str(LANG_RUNTIMEDB_ACTIVE
),
1687 &global_settings
.runtimedb
,
1694 static bool tagcache_settings_menu(void)
1699 static const struct menu_item items
[] = {
1700 #ifdef HAVE_TC_RAMCACHE
1701 { ID2P(LANG_TAGCACHE_RAM
), tagcache_ram
},
1703 { ID2P(LANG_TAGCACHE_AUTOUPDATE
), tagcache_autoupdate
},
1704 { ID2P(LANG_TAGCACHE_FORCE_UPDATE
), tagcache_rebuild
},
1705 { ID2P(LANG_TAGCACHE_UPDATE
), tagcache_update
},
1706 { ID2P(LANG_RUNTIMEDB_ACTIVE
), tagcache_runtimedb
},
1707 { ID2P(LANG_TAGCACHE_EXPORT
), tagtree_export
},
1708 { ID2P(LANG_TAGCACHE_IMPORT
), tagtree_import
},
1711 m
=menu_init( items
, sizeof(items
) / sizeof(*items
), NULL
,
1713 result
= menu_run(m
);
1719 #ifdef HAVE_HEADPHONE_DETECTION
1720 static bool unplug_mode(void)
1722 static const struct opt_items names
[] = {
1724 { STR(LANG_PAUSE
) },
1725 { STR(LANG_UNPLUG_RESUME
) },
1728 ret
=set_option( str(LANG_UNPLUG
),
1729 &global_settings
.unplug_mode
, INT
, names
, 3, NULL
);
1734 static bool unplug_rw(void)
1738 ret
= set_int(str(LANG_UNPLUG_RW
), "s", UNIT_SEC
,
1739 &global_settings
.unplug_rw
,
1740 NULL
, 1, 0, 15, NULL
);
1741 audio_set_crossfade(global_settings
.unplug_rw
);
1745 static bool unplug_autoresume(void)
1747 return set_bool( str(LANG_UNPLUG_DISABLE_AUTORESUME
),
1748 &global_settings
.unplug_autoresume
);
1751 static bool unplug_menu(void)
1756 static const struct menu_item items
[] = {
1757 { ID2P(LANG_UNPLUG
), unplug_mode
},
1758 { ID2P(LANG_UNPLUG_RW
), unplug_rw
},
1759 { ID2P(LANG_UNPLUG_DISABLE_AUTORESUME
), unplug_autoresume
},
1762 m
=menu_init( items
, sizeof(items
) / sizeof(*items
), NULL
,
1764 result
= menu_run(m
);
1770 static bool playback_settings_menu(void)
1775 static const struct menu_item items
[] = {
1776 { ID2P(LANG_SHUFFLE
), shuffle
},
1777 { ID2P(LANG_REPEAT
), repeat_mode
},
1778 { ID2P(LANG_PLAY_SELECTED
), play_selected
},
1779 { ID2P(LANG_RESUME
), resume
},
1780 { ID2P(LANG_WIND_MENU
), ff_rewind_settings_menu
},
1781 { ID2P(LANG_MP3BUFFER_MARGIN
), buffer_margin
},
1782 { ID2P(LANG_FADE_ON_STOP
), set_fade_on_stop
},
1783 { ID2P(LANG_PARTY_MODE
), set_party_mode
},
1784 #if CONFIG_CODEC == SWCODEC
1785 { ID2P(LANG_CROSSFADE
), crossfade_settings_menu
},
1786 { ID2P(LANG_REPLAYGAIN
), replaygain_settings_menu
},
1787 { ID2P(LANG_BEEP
), beep
},
1789 #ifdef HAVE_SPDIF_POWER
1790 { ID2P(LANG_SPDIF_ENABLE
), spdif
},
1792 { ID2P(LANG_ID3_ORDER
), id3_order
},
1793 { ID2P(LANG_NEXT_FOLDER
), next_folder
},
1794 #ifdef HAVE_HEADPHONE_DETECTION
1795 { ID2P(LANG_UNPLUG
), unplug_menu
},
1797 { ID2P(LANG_AUDIOSCROBBLER
), audioscrobbler
}
1800 bool old_shuffle
= global_settings
.playlist_shuffle
;
1802 m
=menu_init( items
, sizeof(items
) / sizeof(*items
), NULL
,
1804 result
= menu_run(m
);
1807 if ((old_shuffle
!= global_settings
.playlist_shuffle
)
1808 && (audio_status() & AUDIO_STATUS_PLAY
))
1810 #if CONFIG_CODEC == SWCODEC
1811 dsp_set_replaygain(true);
1814 if (global_settings
.playlist_shuffle
)
1816 playlist_randomise(NULL
, current_tick
, true);
1820 playlist_sort(NULL
, true);
1826 static bool bookmark_settings_menu(void)
1831 static const struct menu_item items
[] = {
1832 { ID2P(LANG_BOOKMARK_SETTINGS_AUTOCREATE
), autocreatebookmark
},
1833 { ID2P(LANG_BOOKMARK_SETTINGS_AUTOLOAD
), autoloadbookmark
},
1834 { ID2P(LANG_BOOKMARK_SETTINGS_MAINTAIN_RECENT_BOOKMARKS
), useMRB
},
1837 m
=menu_init( items
, sizeof(items
) / sizeof(*items
), NULL
,
1839 result
= menu_run(m
);
1844 static bool reset_settings(void)
1846 unsigned char *lines
[]={str(LANG_RESET_ASK_RECORDER
)};
1847 unsigned char *yes_lines
[]={
1848 str(LANG_RESET_DONE_SETTING
),
1849 str(LANG_RESET_DONE_CLEAR
)
1851 unsigned char *no_lines
[]={yes_lines
[0], str(LANG_RESET_DONE_CANCEL
)};
1852 struct text_message message
={(char **)lines
, 1};
1853 struct text_message yes_message
={(char **)yes_lines
, 2};
1854 struct text_message no_message
={(char **)no_lines
, 2};
1856 switch(gui_syncyesno_run(&message
, &yes_message
, &no_message
))
1871 static bool fileview_settings_menu(void)
1876 static const struct menu_item items
[] = {
1877 { ID2P(LANG_SORT_CASE
), sort_case
},
1878 { ID2P(LANG_SORT_DIR
), sort_dir
},
1879 { ID2P(LANG_SORT_FILE
), sort_file
},
1880 { ID2P(LANG_FILTER
), dir_filter
},
1881 { ID2P(LANG_FOLLOW
), browse_current
},
1882 { ID2P(LANG_SHOW_ICONS
), show_icons
},
1883 { ID2P(LANG_SHOW_PATH
), show_path
},
1884 #ifdef HAVE_TAGCACHE
1885 { ID2P(LANG_TAGCACHE
), tagcache_settings_menu
},
1889 m
=menu_init( items
, sizeof(items
) / sizeof(*items
), NULL
,
1891 result
= menu_run(m
);
1896 #ifdef HAVE_REMOTE_LCD
1897 static bool remote_scroll_sets(void)
1902 static const struct menu_item items
[] = {
1903 { ID2P(LANG_SCROLL_SPEED
), remote_scroll_speed
},
1904 { ID2P(LANG_SCROLL_DELAY
), remote_scroll_delay
},
1905 { ID2P(LANG_SCROLL_STEP
), remote_scroll_step
},
1906 { ID2P(LANG_BIDIR_SCROLL
), remote_bidir_limit
},
1909 m
=menu_init( items
, sizeof(items
) / sizeof(*items
), NULL
,
1911 result
= menu_run(m
);
1917 static bool scroll_settings_menu(void)
1922 static const struct menu_item items
[] = {
1923 { ID2P(LANG_SCROLL_SPEED
), scroll_speed
},
1924 { ID2P(LANG_SCROLL_DELAY
), scroll_delay
},
1925 #ifdef HAVE_LCD_BITMAP
1926 { ID2P(LANG_SCROLL_STEP
), scroll_step
},
1928 { ID2P(LANG_BIDIR_SCROLL
), bidir_limit
},
1929 #ifdef HAVE_REMOTE_LCD
1930 { ID2P(LANG_REMOTE_SCROLL_SETS
), remote_scroll_sets
},
1932 #ifdef HAVE_LCD_CHARCELLS
1933 { ID2P(LANG_JUMP_SCROLL
), jump_scroll
},
1934 { ID2P(LANG_JUMP_SCROLL_DELAY
), jump_scroll_delay
},
1936 #ifdef HAVE_LCD_BITMAP
1937 { ID2P(LANG_SCREEN_SCROLL_VIEW
), screen_scroll
},
1938 { ID2P(LANG_SCREEN_SCROLL_STEP
), screen_scroll_step
},
1940 { ID2P(LANG_SCROLL_PAGINATED
), scroll_paginated
},
1943 m
=menu_init( items
, sizeof(items
) / sizeof(*items
), NULL
,
1945 result
= menu_run(m
);
1950 static bool lcd_settings_menu(void)
1955 static const struct menu_item items
[] = {
1956 #ifdef CONFIG_BACKLIGHT
1957 { ID2P(LANG_BACKLIGHT
), backlight_timer
},
1958 #ifdef CONFIG_CHARGING
1959 { ID2P(LANG_BACKLIGHT_ON_WHEN_CHARGING
), backlight_timer_plugged
},
1961 #ifdef HAS_BUTTON_HOLD
1962 { ID2P(LANG_BACKLIGHT_ON_BUTTON_HOLD
), backlight_on_button_hold
},
1964 { ID2P(LANG_CAPTION_BACKLIGHT
), caption_backlight
},
1965 #if defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR)
1966 { ID2P(LANG_BACKLIGHT_FADE_IN
), backlight_fade_in
},
1967 { ID2P(LANG_BACKLIGHT_FADE_OUT
), backlight_fade_out
},
1969 { ID2P(LANG_BACKLIGHT_FILTER_FIRST_KEYPRESS
), set_bl_filter_first_keypress
},
1970 #ifdef HAVE_LCD_SLEEP
1971 { ID2P(LANG_LCD_SLEEP_AFTER_BACKLIGHT_OFF
), lcd_sleep_after_backlight_off
},
1973 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
1974 { ID2P(LANG_BRIGHTNESS
), brightness
},
1976 #endif /* CONFIG_BACKLIGHT */
1977 #ifdef HAVE_LCD_CONTRAST
1978 { ID2P(LANG_CONTRAST
), contrast
},
1980 #ifdef HAVE_LCD_BITMAP
1981 #ifdef HAVE_LCD_INVERT
1982 { ID2P(LANG_INVERT
), invert
},
1984 #ifdef HAVE_LCD_FLIP
1985 { ID2P(LANG_FLIP_DISPLAY
), flip_display
},
1987 { ID2P(LANG_INVERT_CURSOR
), invert_cursor
},
1990 { ID2P(LANG_CLEAR_BACKDROP
), clear_main_backdrop
},
1992 #ifdef HAVE_LCD_COLOR
1993 { ID2P(LANG_BACKGROUND_COLOR
), set_bg_color
},
1994 { ID2P(LANG_FOREGROUND_COLOR
), set_fg_color
},
1995 { ID2P(LANG_RESET_COLORS
), reset_color
},
1999 m
=menu_init( items
, sizeof(items
) / sizeof(*items
), NULL
,
2001 result
= menu_run(m
);
2006 #ifdef HAVE_REMOTE_LCD
2007 static bool lcd_remote_settings_menu(void)
2012 static const struct menu_item items
[] = {
2013 { ID2P(LANG_BACKLIGHT
), remote_backlight_timer
},
2014 #ifdef CONFIG_CHARGING
2015 { ID2P(LANG_BACKLIGHT_ON_WHEN_CHARGING
),
2016 remote_backlight_timer_plugged
},
2018 #ifdef HAS_REMOTE_BUTTON_HOLD
2019 { ID2P(LANG_BACKLIGHT_ON_BUTTON_HOLD
), remote_backlight_on_button_hold
},
2021 { ID2P(LANG_CAPTION_BACKLIGHT
), remote_caption_backlight
},
2022 { ID2P(LANG_BACKLIGHT_FILTER_FIRST_KEYPRESS
), set_remote_bl_filter_first_keypress
},
2023 { ID2P(LANG_CONTRAST
), remote_contrast
},
2024 { ID2P(LANG_INVERT
), remote_invert
},
2025 { ID2P(LANG_FLIP_DISPLAY
), remote_flip_display
},
2026 #ifdef HAVE_REMOTE_LCD_TICKING
2027 { ID2P(LANG_REDUCE_TICKING
), remote_reduce_ticking
},
2031 m
=menu_init( items
, sizeof(items
) / sizeof(*items
), NULL
,
2033 result
= menu_run(m
);
2039 #ifdef HAVE_LCD_BITMAP
2040 static bool bars_settings_menu(void)
2045 static const struct menu_item items
[] = {
2046 { ID2P(LANG_SCROLL_BAR
), scroll_bar
},
2047 { ID2P(LANG_STATUS_BAR
), status_bar
},
2048 #if CONFIG_KEYPAD == RECORDER_PAD
2049 { ID2P(LANG_BUTTON_BAR
), button_bar
},
2051 { ID2P(LANG_VOLUME_DISPLAY
), volume_type
},
2052 { ID2P(LANG_BATTERY_DISPLAY
), battery_display
},
2055 m
=menu_init( items
, sizeof(items
) / sizeof(*items
), NULL
,
2057 result
= menu_run(m
);
2064 static bool display_settings_menu(void)
2069 static const struct menu_item items
[] = {
2070 #ifdef HAVE_LCD_BITMAP
2071 { ID2P(LANG_CUSTOM_FONT
), font_browse
},
2073 { ID2P(LANG_WHILE_PLAYING
), custom_wps_browse
},
2074 #ifdef HAVE_REMOTE_LCD
2075 { ID2P(LANG_REMOTE_WHILE_PLAYING
), custom_remote_wps_browse
},
2077 { ID2P(LANG_LCD_MENU
), lcd_settings_menu
},
2078 #ifdef HAVE_REMOTE_LCD
2079 { ID2P(LANG_LCD_REMOTE_MENU
), lcd_remote_settings_menu
},
2081 { ID2P(LANG_SCROLL_MENU
), scroll_settings_menu
},
2082 #ifdef HAVE_LCD_BITMAP
2083 { ID2P(LANG_BARS_MENU
), bars_settings_menu
},
2084 { ID2P(LANG_PM_MENU
), peak_meter_menu
},
2086 { ID2P(LANG_DEFAULT_CODEPAGE
), codepage_setting
},
2089 m
=menu_init( items
, sizeof(items
) / sizeof(*items
), NULL
,
2091 result
= menu_run(m
);
2097 static bool battery_settings_menu(void)
2102 static const struct menu_item items
[] = {
2104 { ID2P(LANG_BATTERY_CAPACITY
), battery_capacity
},
2105 #if BATTERY_TYPES_COUNT > 1
2106 { ID2P(LANG_BATTERY_TYPE
), battery_type
},
2108 #ifdef HAVE_USB_POWER
2109 #ifdef CONFIG_CHARGING
2110 { ID2P(LANG_USB_CHARGING
), usb_charging
},
2114 { "Dummy", NULL
}, /* to have an entry at all, in the simulator */
2118 m
=menu_init( items
, sizeof(items
) / sizeof(*items
), NULL
,
2120 result
= menu_run(m
);
2126 static bool disk_settings_menu(void)
2131 static const struct menu_item items
[] = {
2132 { ID2P(LANG_SPINDOWN
), spindown
},
2133 #ifdef HAVE_DIRCACHE
2134 { ID2P(LANG_DIRCACHE_ENABLE
), dircache
},
2138 m
=menu_init( items
, sizeof(items
) / sizeof(*items
), NULL
,
2140 result
= menu_run(m
);
2144 #endif /* !HAVE_MMC */
2147 static bool time_settings_menu(void)
2152 static const struct menu_item items
[] = {
2153 { ID2P(LANG_TIME
), timedate_set
},
2154 { ID2P(LANG_TIMEFORMAT
), timeformat_set
},
2157 m
=menu_init( items
, sizeof(items
) / sizeof(*items
), NULL
,
2159 result
= menu_run(m
);
2165 bool manage_settings_menu(void)
2170 static const struct menu_item items
[] = {
2171 { ID2P(LANG_CUSTOM_CFG
), custom_cfg_browse
},
2172 { ID2P(LANG_RESET
), reset_settings
},
2173 { ID2P(LANG_SAVE_SETTINGS
), settings_save_config
},
2176 m
=menu_init( items
, sizeof(items
) / sizeof(*items
), NULL
,
2178 result
= menu_run(m
);
2183 static bool limits_settings_menu(void)
2188 static const struct menu_item items
[] = {
2189 { ID2P(LANG_MAX_FILES_IN_DIR
), max_files_in_dir
},
2190 { ID2P(LANG_MAX_FILES_IN_PLAYLIST
), max_files_in_playlist
},
2193 m
=menu_init( items
, sizeof(items
) / sizeof(*items
), NULL
,
2195 result
= menu_run(m
);
2201 static bool system_settings_menu(void)
2206 static const struct menu_item items
[] = {
2207 { ID2P(LANG_BATTERY_MENU
), battery_settings_menu
},
2209 { ID2P(LANG_DISK_MENU
), disk_settings_menu
},
2212 { ID2P(LANG_TIME_MENU
), time_settings_menu
},
2214 { ID2P(LANG_POWEROFF_IDLE
), poweroff_idle_timer
},
2215 { ID2P(LANG_SLEEP_TIMER
), sleep_timer
},
2216 #ifdef HAVE_ALARM_MOD
2217 { ID2P(LANG_ALARM_MOD_ALARM_MENU
), alarm_screen
},
2219 { ID2P(LANG_LIMITS_MENU
), limits_settings_menu
},
2220 #if CONFIG_CODEC == MAS3507D
2221 { ID2P(LANG_LINE_IN
), line_in
},
2223 #ifdef CONFIG_CHARGING
2224 { ID2P(LANG_CAR_ADAPTER_MODE
), car_adapter_mode
},
2228 m
=menu_init( items
, sizeof(items
) / sizeof(*items
), NULL
,
2230 result
= menu_run(m
);
2235 bool settings_menu(void)
2240 static const struct menu_item items
[] = {
2241 { ID2P(LANG_PLAYBACK
), playback_settings_menu
},
2242 { ID2P(LANG_FILE
), fileview_settings_menu
},
2243 { ID2P(LANG_DISPLAY
), display_settings_menu
},
2244 { ID2P(LANG_SYSTEM
), system_settings_menu
},
2245 { ID2P(LANG_BOOKMARK_SETTINGS
),bookmark_settings_menu
},
2246 { ID2P(LANG_LANGUAGE
), language_browse
},
2247 { ID2P(LANG_VOICE
), voice_menu
},
2250 m
=menu_init( items
, sizeof(items
) / sizeof(*items
), NULL
,
2252 result
= menu_run(m
);