HAVE_ADJUSTABLE_CPU_FREQ isn't defined for simulators, so we don't have to check...
[Rockbox.git] / apps / settings_menu.c
blob04f8c0c9af8dc5e926f29e7f1971159ac73fbff9
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
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 ****************************************************************************/
20 #include "config.h"
22 #include <stdio.h>
23 #include <stdbool.h>
24 #include <string.h>
26 #include "lcd.h"
27 #include "menu.h"
28 #include "mpeg.h"
29 #include "audio.h"
30 #include "button.h"
31 #include "kernel.h"
32 #include "thread.h"
33 #include "sprintf.h"
34 #include "settings.h"
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"
40 #include "rtc.h"
41 #include "ata.h"
42 #include "tree.h"
43 #include "screens.h"
44 #include "talk.h"
45 #include "timefuncs.h"
46 #include "misc.h"
47 #include "abrepeat.h"
48 #include "power.h"
49 #include "database.h"
50 #include "dir.h"
51 #include "dircache.h"
52 #include "tagcache.h"
53 #include "rbunicode.h"
54 #include "splash.h"
55 #include "yesno.h"
56 #include "list.h"
57 #include "color_picker.h"
59 #ifdef HAVE_LCD_BITMAP
60 #include "peakmeter.h"
61 #endif
62 #include "lang.h"
63 #if CONFIG_CODEC == MAS3507D
64 void dac_line_in(bool enable);
65 #endif
66 #ifdef HAVE_ALARM_MOD
67 #include "alarm_menu.h"
68 #endif
70 #ifdef HAVE_REMOTE_LCD
71 #include "lcd-remote.h"
72 #endif
74 #if CONFIG_CODEC == SWCODEC
75 #include "pcmbuf.h"
76 #include "pcm_playback.h"
77 #include "dsp.h"
78 #endif
80 #ifdef HAVE_CHARGING
81 static bool car_adapter_mode(void)
83 return set_bool( str(LANG_CAR_ADAPTER_MODE),
84 &global_settings.car_adapter_mode );
86 #endif
88 /**
89 * Menu to set icon visibility
91 static bool show_icons(void)
93 return set_bool( (char *)str(LANG_SHOW_ICONS), &global_settings.show_icons );
96 /**
97 * Menu to set the option to scroll paginated
99 static bool scroll_paginated(void)
101 return set_bool( (char *)str(LANG_SCROLL_PAGINATED), &global_settings.scroll_paginated );
104 #ifdef HAVE_REMOTE_LCD
105 static bool remote_contrast(void)
107 return set_int( str(LANG_CONTRAST), "", UNIT_INT,
108 &global_settings.remote_contrast,
109 lcd_remote_set_contrast, 1, MIN_CONTRAST_SETTING,
110 MAX_CONTRAST_SETTING, NULL );
113 static bool remote_invert(void)
115 bool rc = set_bool_options((char *)str(LANG_INVERT),
116 &global_settings.remote_invert,
117 (char *)STR(LANG_INVERT_LCD_INVERSE),
118 STR(LANG_INVERT_LCD_NORMAL),
119 lcd_remote_set_invert_display);
120 return rc;
123 static bool remote_flip_display(void)
125 bool rc = set_bool( (char *)str(LANG_FLIP_DISPLAY),
126 &global_settings.remote_flip_display);
128 lcd_remote_set_flip(global_settings.remote_flip_display);
129 lcd_remote_update();
131 return rc;
134 #ifdef HAVE_REMOTE_LCD_TICKING
135 static bool remote_reduce_ticking(void)
137 bool rc = set_bool( str(LANG_REDUCE_TICKING),
138 &global_settings.remote_reduce_ticking);
140 lcd_remote_emireduce(global_settings.remote_reduce_ticking);
142 return rc;
144 #endif
145 #endif
147 #ifdef CONFIG_BACKLIGHT
148 static const struct opt_items backlight_timeouts[] = {
149 { STR(LANG_OFF) },
150 { STR(LANG_ON) },
151 { (unsigned char *)"1s ", TALK_ID(1, UNIT_SEC) },
152 { (unsigned char *)"2s ", TALK_ID(2, UNIT_SEC) },
153 { (unsigned char *)"3s ", TALK_ID(3, UNIT_SEC) },
154 { (unsigned char *)"4s ", TALK_ID(4, UNIT_SEC) },
155 { (unsigned char *)"5s ", TALK_ID(5, UNIT_SEC) },
156 { (unsigned char *)"6s ", TALK_ID(6, UNIT_SEC) },
157 { (unsigned char *)"7s ", TALK_ID(7, UNIT_SEC) },
158 { (unsigned char *)"8s ", TALK_ID(8, UNIT_SEC) },
159 { (unsigned char *)"9s ", TALK_ID(9, UNIT_SEC) },
160 { (unsigned char *)"10s", TALK_ID(10, UNIT_SEC) },
161 { (unsigned char *)"15s", TALK_ID(15, UNIT_SEC) },
162 { (unsigned char *)"20s", TALK_ID(20, UNIT_SEC) },
163 { (unsigned char *)"25s", TALK_ID(25, UNIT_SEC) },
164 { (unsigned char *)"30s", TALK_ID(30, UNIT_SEC) },
165 { (unsigned char *)"45s", TALK_ID(45, UNIT_SEC) },
166 { (unsigned char *)"60s", TALK_ID(60, UNIT_SEC) },
167 { (unsigned char *)"90s", TALK_ID(90, UNIT_SEC) }
170 static bool caption_backlight(void)
172 return set_bool( (char *)str(LANG_CAPTION_BACKLIGHT),
173 &global_settings.caption_backlight);
176 #ifdef HAVE_CHARGING
177 static bool backlight_timer_plugged(void)
179 return set_option((char *)str(LANG_BACKLIGHT_ON_WHEN_CHARGING),
180 &global_settings.backlight_timeout_plugged,
181 INT, backlight_timeouts, 19,
182 backlight_set_timeout_plugged );
184 #endif
186 static bool backlight_timer(void)
188 return set_option((char *)str(LANG_BACKLIGHT),
189 &global_settings.backlight_timeout,
190 INT, backlight_timeouts, 19,
191 backlight_set_timeout );
194 #if defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR)
195 static bool backlight_fade_in(void)
197 static const struct opt_items names[] = {
198 { STR(LANG_OFF) },
199 { (unsigned char *)"500ms", TALK_ID(500, UNIT_MS) },
200 { (unsigned char *)"1s", TALK_ID(1, UNIT_SEC) },
201 { (unsigned char *)"2s", TALK_ID(2, UNIT_SEC) },
203 return set_option(str(LANG_BACKLIGHT_FADE_IN),
204 &global_settings.backlight_fade_in,
205 INT, names, 4, backlight_set_fade_in );
208 static bool backlight_fade_out(void)
210 static const struct opt_items names[] = {
211 { STR(LANG_OFF) },
212 { (unsigned char *)"500ms", TALK_ID(500, UNIT_MS) },
213 { (unsigned char *)"1s", TALK_ID(1, UNIT_SEC) },
214 { (unsigned char *)"2s", TALK_ID(2, UNIT_SEC) },
215 { (unsigned char *)"3s", TALK_ID(3, UNIT_SEC) },
216 { (unsigned char *)"4s", TALK_ID(4, UNIT_SEC) },
217 { (unsigned char *)"5s", TALK_ID(5, UNIT_SEC) },
218 { (unsigned char *)"10s", TALK_ID(10, UNIT_SEC) },
220 return set_option(str(LANG_BACKLIGHT_FADE_OUT),
221 &global_settings.backlight_fade_out,
222 INT, names, 8, backlight_set_fade_out );
224 #endif
225 #endif /* CONFIG_BACKLIGHT */
227 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
228 static bool brightness(void)
230 return set_int( str(LANG_BRIGHTNESS), "", UNIT_INT,
231 &global_settings.brightness,
232 backlight_set_brightness, 1, MIN_BRIGHTNESS_SETTING,
233 MAX_BRIGHTNESS_SETTING, NULL );
235 #endif
237 #ifdef HAVE_REMOTE_LCD
239 static bool remote_backlight_timer(void)
241 return set_option((char *)str(LANG_BACKLIGHT),
242 &global_settings.remote_backlight_timeout,
243 INT, backlight_timeouts, 19,
244 remote_backlight_set_timeout );
247 #ifdef HAVE_CHARGING
248 static bool remote_backlight_timer_plugged(void)
250 return set_option((char *)str(LANG_BACKLIGHT_ON_WHEN_CHARGING),
251 &global_settings.remote_backlight_timeout_plugged,
252 INT, backlight_timeouts, 19,
253 remote_backlight_set_timeout_plugged );
255 #endif
257 static bool remote_caption_backlight(void)
259 return set_bool((char *)str(LANG_CAPTION_BACKLIGHT),
260 &global_settings.remote_caption_backlight);
262 #endif /* HAVE_REMOTE_LCD */
264 #ifndef HAVE_LCD_COLOR
265 static bool contrast(void)
267 return set_int( str(LANG_CONTRAST), "", UNIT_INT,
268 &global_settings.contrast,
269 lcd_set_contrast, 1, MIN_CONTRAST_SETTING,
270 MAX_CONTRAST_SETTING, NULL );
272 #endif /* HAVE_LCD_COLOR */
274 #ifdef HAVE_LCD_BITMAP
275 #ifndef HAVE_LCD_COLOR
277 * Menu to set LCD Mode (normal/inverse)
279 static bool invert(void)
281 bool rc = set_bool_options(str(LANG_INVERT),
282 &global_settings.invert,
283 (char *)STR(LANG_INVERT_LCD_INVERSE),
284 STR(LANG_INVERT_LCD_NORMAL),
285 lcd_set_invert_display);
286 return rc;
288 #endif /* HAVE_LCD_COLOR */
290 #ifdef HAVE_LCD_FLIP
292 * Menu to turn the display+buttons by 180 degrees
294 static bool flip_display(void)
296 bool rc = set_bool( str(LANG_FLIP_DISPLAY),
297 &global_settings.flip_display);
299 button_set_flip(global_settings.flip_display);
300 lcd_set_flip(global_settings.flip_display);
302 return rc;
304 #endif /* HAVE_LCD_FLIP */
307 * Menu to set Line Selector Type (Pointer/Bar)
309 static bool invert_cursor(void)
311 return set_bool_options(str(LANG_INVERT_CURSOR),
312 &global_settings.invert_cursor,
313 STR(LANG_INVERT_CURSOR_BAR),
314 STR(LANG_INVERT_CURSOR_POINTER),
315 NULL);
318 #ifdef HAVE_LCD_COLOR
320 * Menu to clear the backdrop image
322 static bool clear_main_backdrop(void)
324 global_settings.backdrop_file[0]=0;
325 lcd_set_backdrop(NULL);
326 return false;
330 * Menu for fore/back colors
332 static bool set_fg_color(void)
334 bool res;
336 res = set_color(&screens[SCREEN_MAIN],str(LANG_FOREGROUND_COLOR),
337 &global_settings.fg_color,global_settings.bg_color);
339 screens[SCREEN_MAIN].set_foreground(global_settings.fg_color);
341 return res;
344 static bool set_bg_color(void)
346 bool res;
348 res = set_color(&screens[SCREEN_MAIN],str(LANG_BACKGROUND_COLOR),
349 &global_settings.bg_color,global_settings.fg_color);
351 screens[SCREEN_MAIN].set_background(global_settings.bg_color);
353 return res;
356 static bool reset_color(void)
358 global_settings.fg_color = LCD_DEFAULT_FG;
359 global_settings.bg_color = LCD_DEFAULT_BG;
361 screens[SCREEN_MAIN].set_foreground(global_settings.fg_color);
362 screens[SCREEN_MAIN].set_background(global_settings.bg_color);
363 return false;
365 #endif
368 * Menu to configure the battery display on status bar
370 static bool battery_display(void)
372 static const struct opt_items names[] = {
373 { STR(LANG_DISPLAY_GRAPHIC) },
374 { STR(LANG_DISPLAY_NUMERIC) }
376 return set_option( str(LANG_BATTERY_DISPLAY),
377 &global_settings.battery_display, INT, names, 2, NULL);
381 * Menu to configure the volume display on status bar
383 static bool volume_type(void)
385 static const struct opt_items names[] = {
386 { STR(LANG_DISPLAY_GRAPHIC) },
387 { STR(LANG_DISPLAY_NUMERIC) }
389 return set_option( str(LANG_VOLUME_DISPLAY), &global_settings.volume_type,
390 INT, names, 2, NULL);
394 * Menu to set the hold time of normal peaks.
396 static bool peak_meter_hold(void) {
397 bool retval = false;
398 static const struct opt_items names[] = {
399 { STR(LANG_OFF) },
400 { "200 ms " , TALK_ID(200, UNIT_MS) },
401 { "300 ms " , TALK_ID(300, UNIT_MS) },
402 { "500 ms " , TALK_ID(500, UNIT_MS) },
403 { "1 s" , TALK_ID(1, UNIT_SEC) },
404 { "2 s" , TALK_ID(2, UNIT_SEC) },
405 { "3 s" , TALK_ID(3, UNIT_SEC) },
406 { "4 s" , TALK_ID(4, UNIT_SEC) },
407 { "5 s" , TALK_ID(5, UNIT_SEC) },
408 { "6 s" , TALK_ID(6, UNIT_SEC) },
409 { "7 s" , TALK_ID(7, UNIT_SEC) },
410 { "8 s" , TALK_ID(8, UNIT_SEC) },
411 { "9 s" , TALK_ID(9, UNIT_SEC) },
412 { "10 s" , TALK_ID(10, UNIT_SEC) },
413 { "15 s" , TALK_ID(15, UNIT_SEC) },
414 { "20 s" , TALK_ID(20, UNIT_SEC) },
415 { "30 s" , TALK_ID(30, UNIT_SEC) },
416 { "1 min" , TALK_ID(1, UNIT_MIN) }
418 retval = set_option( str(LANG_PM_PEAK_HOLD),
419 &global_settings.peak_meter_hold, INT, names,
420 18, NULL);
422 peak_meter_init_times(global_settings.peak_meter_release,
423 global_settings.peak_meter_hold,
424 global_settings.peak_meter_clip_hold);
426 return retval;
430 * Menu to set the hold time of clips.
432 static bool peak_meter_clip_hold(void) {
433 bool retval = false;
435 static const struct opt_items names[] = {
436 { STR(LANG_PM_ETERNAL) },
437 { "1s " , TALK_ID(1, UNIT_SEC) },
438 { "2s " , TALK_ID(2, UNIT_SEC) },
439 { "3s " , TALK_ID(3, UNIT_SEC) },
440 { "4s " , TALK_ID(4, UNIT_SEC) },
441 { "5s " , TALK_ID(5, UNIT_SEC) },
442 { "6s " , TALK_ID(6, UNIT_SEC) },
443 { "7s " , TALK_ID(7, UNIT_SEC) },
444 { "8s " , TALK_ID(8, UNIT_SEC) },
445 { "9s " , TALK_ID(9, UNIT_SEC) },
446 { "10s" , TALK_ID(10, UNIT_SEC) },
447 { "15s" , TALK_ID(15, UNIT_SEC) },
448 { "20s" , TALK_ID(20, UNIT_SEC) },
449 { "25s" , TALK_ID(25, UNIT_SEC) },
450 { "30s" , TALK_ID(30, UNIT_SEC) },
451 { "45s" , TALK_ID(45, UNIT_SEC) },
452 { "60s" , TALK_ID(60, UNIT_SEC) },
453 { "90s" , TALK_ID(90, UNIT_SEC) },
454 { "2min" , TALK_ID(2, UNIT_MIN) },
455 { "3min" , TALK_ID(3, UNIT_MIN) },
456 { "5min" , TALK_ID(5, UNIT_MIN) },
457 { "10min" , TALK_ID(10, UNIT_MIN) },
458 { "20min" , TALK_ID(20, UNIT_MIN) },
459 { "45min" , TALK_ID(45, UNIT_MIN) },
460 { "90min" , TALK_ID(90, UNIT_MIN) }
462 retval = set_option( str(LANG_PM_CLIP_HOLD),
463 &global_settings.peak_meter_clip_hold, INT, names,
464 25, peak_meter_set_clip_hold);
466 peak_meter_init_times(global_settings.peak_meter_release,
467 global_settings.peak_meter_hold,
468 global_settings.peak_meter_clip_hold);
470 return retval;
474 * Menu to set the release time of the peak meter.
476 static bool peak_meter_release(void) {
477 bool retval = false;
479 /* The range of peak_meter_release is restricted so that it
480 fits into a 7 bit number. The 8th bit is used for storing
481 something else in the rtc ram.
482 Also, the max value is 0x7e, since the RTC value 0xff is reserved */
483 retval = set_int( str(LANG_PM_RELEASE), str(LANG_PM_UNITS_PER_READ),
484 LANG_PM_UNITS_PER_READ,
485 &global_settings.peak_meter_release,
486 NULL, 1, 1, 0x7e, NULL);
488 peak_meter_init_times(global_settings.peak_meter_release,
489 global_settings.peak_meter_hold,
490 global_settings.peak_meter_clip_hold);
492 return retval;
496 * Menu to select wether the scale of the meter
497 * displays dBfs of linear values.
499 static bool peak_meter_scale(void) {
500 bool retval = false;
501 bool use_dbfs = global_settings.peak_meter_dbfs;
502 retval = set_bool_options(str(LANG_PM_SCALE),
503 &use_dbfs,
504 STR(LANG_PM_DBFS), STR(LANG_PM_LINEAR),
505 NULL);
507 /* has the user really changed the scale? */
508 if (use_dbfs != global_settings.peak_meter_dbfs) {
510 /* store the change */
511 global_settings.peak_meter_dbfs = use_dbfs;
512 peak_meter_set_use_dbfs(use_dbfs);
514 /* If the user changed the scale mode the meaning of
515 peak_meter_min (peak_meter_max) has changed. Thus we have
516 to convert the values stored in global_settings. */
517 if (use_dbfs) {
519 /* we only store -dBfs */
520 global_settings.peak_meter_min = -peak_meter_get_min() / 100;
521 global_settings.peak_meter_max = -peak_meter_get_max() / 100;
522 } else {
523 int max;
525 /* linear percent */
526 global_settings.peak_meter_min = peak_meter_get_min();
528 /* converting dBfs -> percent results in a precision loss.
529 I assume that the user doesn't bother that conversion
530 dBfs <-> percent isn't symmetrical for odd values but that
531 he wants 0 dBfs == 100%. Thus I 'correct' the percent value
532 resulting from dBfs -> percent manually here */
533 max = peak_meter_get_max();
534 global_settings.peak_meter_max = max < 99 ? max : 100;
536 settings_apply_pm_range();
538 return retval;
542 * Adjust the min value of the value range that
543 * the peak meter shall visualize.
545 static bool peak_meter_min(void) {
546 bool retval = false;
547 if (global_settings.peak_meter_dbfs) {
549 /* for dBfs scale */
550 int range_max = -global_settings.peak_meter_max;
551 int min = -global_settings.peak_meter_min;
553 retval = set_int(str(LANG_PM_MIN), str(LANG_PM_DBFS), UNIT_DB,
554 &min, NULL, 1, -89, range_max, NULL);
556 global_settings.peak_meter_min = - min;
559 /* for linear scale */
560 else {
561 int min = global_settings.peak_meter_min;
563 retval = set_int(str(LANG_PM_MIN), "%", UNIT_PERCENT,
564 &min, NULL,
565 1, 0, global_settings.peak_meter_max - 1, NULL);
567 global_settings.peak_meter_min = (unsigned char)min;
570 settings_apply_pm_range();
571 return retval;
576 * Adjust the max value of the value range that
577 * the peak meter shall visualize.
579 static bool peak_meter_max(void) {
580 bool retval = false;
581 if (global_settings.peak_meter_dbfs) {
583 /* for dBfs scale */
584 int range_min = -global_settings.peak_meter_min;
585 int max = -global_settings.peak_meter_max;;
587 retval = set_int(str(LANG_PM_MAX), str(LANG_PM_DBFS), UNIT_DB,
588 &max, NULL, 1, range_min, 0, NULL);
590 global_settings.peak_meter_max = - max;
594 /* for linear scale */
595 else {
596 int max = global_settings.peak_meter_max;
598 retval = set_int(str(LANG_PM_MAX), "%", UNIT_PERCENT,
599 &max, NULL,
600 1, global_settings.peak_meter_min + 1, 100, NULL);
602 global_settings.peak_meter_max = (unsigned char)max;
605 settings_apply_pm_range();
606 return retval;
610 * Menu to configure the peak meter
612 static bool peak_meter_menu(void)
614 int m;
615 bool result;
617 static const struct menu_item items[] = {
618 { ID2P(LANG_PM_RELEASE) , peak_meter_release },
619 { ID2P(LANG_PM_PEAK_HOLD), peak_meter_hold },
620 { ID2P(LANG_PM_CLIP_HOLD), peak_meter_clip_hold },
621 { ID2P(LANG_PM_SCALE) , peak_meter_scale },
622 { ID2P(LANG_PM_MIN) , peak_meter_min },
623 { ID2P(LANG_PM_MAX) , peak_meter_max },
626 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
627 NULL, NULL, NULL );
628 result = menu_run(m);
629 menu_exit(m);
630 return result;
632 #endif /* HAVE_LCD_BITMAP */
634 static bool shuffle(void)
636 return set_bool( str(LANG_SHUFFLE), &global_settings.playlist_shuffle );
639 static bool repeat_mode(void)
641 bool result;
642 static const struct opt_items names[] = {
643 { STR(LANG_OFF) },
644 { STR(LANG_REPEAT_ALL) },
645 { STR(LANG_REPEAT_ONE) },
646 { STR(LANG_SHUFFLE) },
647 #if (AB_REPEAT_ENABLE == 1)
648 { STR(LANG_REPEAT_AB) }
649 #endif
651 int old_repeat = global_settings.repeat_mode;
653 result = set_option( str(LANG_REPEAT), &global_settings.repeat_mode,
654 INT, names, NUM_REPEAT_MODES, NULL );
656 if (old_repeat != global_settings.repeat_mode &&
657 (audio_status() & AUDIO_STATUS_PLAY))
658 audio_flush_and_reload_tracks();
660 return result;
663 static bool play_selected(void)
665 return set_bool( str(LANG_PLAY_SELECTED), &global_settings.play_selected );
668 static bool dir_filter(void)
670 static const struct opt_items names[] = {
671 { STR(LANG_FILTER_ALL) },
672 { STR(LANG_FILTER_SUPPORTED) },
673 { STR(LANG_FILTER_MUSIC) },
674 { STR(LANG_FILTER_PLAYLIST) },
675 { STR(LANG_FILTER_ID3DB) }
677 return set_option( str(LANG_FILTER), &global_settings.dirfilter, INT,
678 names, 5, NULL );
681 static bool sort_case(void)
683 return set_bool( str(LANG_SORT_CASE), &global_settings.sort_case );
686 static bool sort_file(void)
688 int oldval = global_settings.sort_file;
689 bool ret;
690 static const struct opt_items names[] = {
691 { STR(LANG_SORT_ALPHA) },
692 { STR(LANG_SORT_DATE) },
693 { STR(LANG_SORT_DATE_REVERSE) },
694 { STR(LANG_SORT_TYPE) }
696 ret = set_option( str(LANG_SORT_FILE), &global_settings.sort_file, INT,
697 names, 4, NULL );
698 if (global_settings.sort_file != oldval)
699 reload_directory(); /* force reload if this has changed */
700 return ret;
703 static bool sort_dir(void)
705 int oldval = global_settings.sort_dir;
706 bool ret;
707 static const struct opt_items names[] = {
708 { STR(LANG_SORT_ALPHA) },
709 { STR(LANG_SORT_DATE) },
710 { STR(LANG_SORT_DATE_REVERSE) }
712 ret = set_option( str(LANG_SORT_DIR), &global_settings.sort_dir, INT,
713 names, 3, NULL );
714 if (global_settings.sort_dir != oldval)
715 reload_directory(); /* force reload if this has changed */
716 return ret;
719 static bool resume(void)
721 return set_bool( str(LANG_RESUME), &global_settings.resume);
724 #ifdef HAVE_SPDIF_POWER
725 static bool spdif(void)
727 bool rc = set_bool_options(str(LANG_SPDIF_ENABLE),
728 &global_settings.spdif_enable,
729 STR(LANG_ON),
730 STR(LANG_OFF),
731 spdif_power_enable);
732 return rc;
734 #endif
736 static bool autocreatebookmark(void)
738 bool retval = false;
739 static const struct opt_items names[] = {
740 { STR(LANG_SET_BOOL_NO) },
741 { STR(LANG_SET_BOOL_YES) },
742 { STR(LANG_RESUME_SETTING_ASK) },
743 { STR(LANG_BOOKMARK_SETTINGS_RECENT_ONLY_YES) },
744 { STR(LANG_BOOKMARK_SETTINGS_RECENT_ONLY_ASK) }
747 retval = set_option( str(LANG_BOOKMARK_SETTINGS_AUTOCREATE),
748 &global_settings.autocreatebookmark, INT,
749 names, 5, NULL );
750 if(global_settings.autocreatebookmark == BOOKMARK_RECENT_ONLY_YES ||
751 global_settings.autocreatebookmark == BOOKMARK_RECENT_ONLY_ASK)
753 if(global_settings.usemrb == BOOKMARK_NO)
754 global_settings.usemrb = BOOKMARK_YES;
757 return retval;
760 static bool autoloadbookmark(void)
762 static const struct opt_items names[] = {
763 { STR(LANG_SET_BOOL_NO) },
764 { STR(LANG_SET_BOOL_YES) },
765 { STR(LANG_RESUME_SETTING_ASK) }
767 return set_option( str(LANG_BOOKMARK_SETTINGS_AUTOLOAD),
768 &global_settings.autoloadbookmark, INT,
769 names, 3, NULL );
772 static bool useMRB(void)
774 static const struct opt_items names[] = {
775 { STR(LANG_SET_BOOL_NO) },
776 { STR(LANG_SET_BOOL_YES) },
777 { STR(LANG_BOOKMARK_SETTINGS_UNIQUE_ONLY) }
779 return set_option( str(LANG_BOOKMARK_SETTINGS_MAINTAIN_RECENT_BOOKMARKS),
780 &global_settings.usemrb, INT,
781 names, 3, NULL );
784 static bool poweroff_idle_timer(void)
786 static const struct opt_items names[] = {
787 { STR(LANG_OFF) },
788 { "1m ", TALK_ID(1, UNIT_MIN) },
789 { "2m ", TALK_ID(2, UNIT_MIN) },
790 { "3m ", TALK_ID(3, UNIT_MIN) },
791 { "4m ", TALK_ID(4, UNIT_MIN) },
792 { "5m ", TALK_ID(5, UNIT_MIN) },
793 { "6m ", TALK_ID(6, UNIT_MIN) },
794 { "7m ", TALK_ID(7, UNIT_MIN) },
795 { "8m ", TALK_ID(8, UNIT_MIN) },
796 { "9m ", TALK_ID(9, UNIT_MIN) },
797 { "10m", TALK_ID(10, UNIT_MIN) },
798 { "15m", TALK_ID(15, UNIT_MIN) },
799 { "30m", TALK_ID(30, UNIT_MIN) },
800 { "45m", TALK_ID(45, UNIT_MIN) },
801 { "60m", TALK_ID(60, UNIT_MIN) }
803 return set_option(str(LANG_POWEROFF_IDLE), &global_settings.poweroff,
804 INT, names, 15, set_poweroff_timeout);
807 static void sleep_timer_formatter(char* buffer, int buffer_size, int value,
808 const char* unit)
810 int minutes, hours;
812 (void) unit;
814 if (value) {
815 hours = value / 60;
816 minutes = value - (hours * 60);
817 snprintf(buffer, buffer_size, "%d:%02d", hours, minutes);
818 } else {
819 snprintf(buffer, buffer_size, "%s", str(LANG_OFF));
823 static void sleep_timer_set(int minutes)
825 set_sleep_timer(minutes * 60);
828 static bool sleep_timer(void)
830 int minutes = (get_sleep_timer() + 59) / 60; /* round up */
832 return set_int(str(LANG_SLEEP_TIMER), "", UNIT_MIN, &minutes,
833 &sleep_timer_set, 5, 0, 300, sleep_timer_formatter);
836 static bool scroll_speed(void)
838 return set_int(str(LANG_SCROLL), "", UNIT_INT,
839 &global_settings.scroll_speed,
840 &lcd_scroll_speed, 1, 0, 15, NULL );
843 static bool scroll_delay(void)
845 int dummy = global_settings.scroll_delay * (HZ/10);
846 int rc = set_int(str(LANG_SCROLL_DELAY), "ms", UNIT_MS,
847 &dummy,
848 &lcd_scroll_delay, 100, 0, 2500, NULL );
849 global_settings.scroll_delay = dummy / (HZ/10);
850 return rc;
853 #ifdef HAVE_LCD_BITMAP
854 static bool screen_scroll(void)
856 bool rc = set_bool( str(LANG_SCREEN_SCROLL_VIEW), &global_settings.offset_out_of_view);
857 gui_list_screen_scroll_out_of_view(global_settings.offset_out_of_view);
858 return rc;
861 static bool screen_scroll_step(void)
863 return set_int(str(LANG_SCREEN_SCROLL_STEP), str(LANG_PIXELS), UNIT_PIXEL,
864 &global_settings.screen_scroll_step,
865 &gui_list_screen_scroll_step, 1, 1, LCD_WIDTH, NULL );
868 static bool scroll_step(void)
870 return set_int(str(LANG_SCROLL_STEP_EXAMPLE), str(LANG_PIXELS), UNIT_PIXEL,
871 &global_settings.scroll_step,
872 &lcd_scroll_step, 1, 1, LCD_WIDTH, NULL );
874 #endif
876 static bool bidir_limit(void)
878 return set_int(str(LANG_BIDIR_SCROLL), "%", UNIT_PERCENT,
879 &global_settings.bidir_limit,
880 &lcd_bidir_scroll, 25, 0, 200, NULL );
883 #ifdef HAVE_LCD_CHARCELLS
884 static bool jump_scroll(void)
886 static const struct opt_items names[] = {
887 { STR(LANG_OFF) },
888 { STR(LANG_ONE_TIME) },
889 { "2", TALK_ID(2, UNIT_INT) },
890 { "3", TALK_ID(3, UNIT_INT) },
891 { "4", TALK_ID(4, UNIT_INT) },
892 { STR(LANG_ALWAYS) }
894 bool ret;
895 ret=set_option(str(LANG_JUMP_SCROLL), &global_settings.jump_scroll,
896 INT, names, 6, lcd_jump_scroll);
897 return ret;
899 static bool jump_scroll_delay(void)
901 int dummy = global_settings.jump_scroll_delay * (HZ/10);
902 int rc = set_int(str(LANG_JUMP_SCROLL_DELAY), "ms", UNIT_MS,
903 &dummy,
904 &lcd_jump_scroll_delay, 100, 0, 2500, NULL );
905 global_settings.jump_scroll_delay = dummy / (HZ/10);
906 return rc;
908 #endif
910 #ifndef SIMULATOR
912 * Menu to set the battery capacity
914 static bool battery_capacity(void)
916 return set_int(str(LANG_BATTERY_CAPACITY), "mAh", UNIT_MAH,
917 &global_settings.battery_capacity,
918 &set_battery_capacity, 50, BATTERY_CAPACITY_MIN,
919 BATTERY_CAPACITY_MAX, NULL );
922 #if BATTERY_TYPES_COUNT > 1
923 static bool battery_type(void)
925 static const struct opt_items names[] = {
926 { STR(LANG_BATTERY_TYPE_ALKALINE) },
927 { STR(LANG_BATTERY_TYPE_NIMH) }
930 return set_option(str(LANG_BATTERY_TYPE), &global_settings.battery_type,
931 INT, names, 2, set_battery_type);
933 #endif
934 #endif
936 #ifdef CONFIG_RTC
937 static bool timedate_set(void)
939 struct tm tm;
940 bool result;
942 /* Make a local copy of the time struct */
943 memcpy(&tm, get_time(), sizeof(struct tm));
945 /* do some range checks */
946 /* This prevents problems with time/date setting after a power loss */
947 if (!valid_time(&tm))
949 /* hour */
950 tm.tm_hour = 0;
951 tm.tm_min = 0;
952 tm.tm_sec = 0;
953 tm.tm_mday = 1;
954 tm.tm_mon = 0;
955 tm.tm_wday = 1;
956 tm.tm_year = 100;
959 result = set_time_screen(str(LANG_TIME), &tm);
961 if(tm.tm_year != -1) {
962 set_time(&tm);
964 return result;
967 static bool timeformat_set(void)
969 static const struct opt_items names[] = {
970 { STR(LANG_24_HOUR_CLOCK) },
971 { STR(LANG_12_HOUR_CLOCK) }
973 return set_option(str(LANG_TIMEFORMAT), &global_settings.timeformat,
974 INT, names, 2, NULL);
976 #endif
978 #ifndef HAVE_MMC
979 static bool spindown(void)
981 return set_int(str(LANG_SPINDOWN), "s", UNIT_SEC,
982 &global_settings.disk_spindown,
983 ata_spindown, 1, 3, 254, NULL );
986 #ifdef HAVE_ATA_POWER_OFF
987 static bool poweroff(void)
989 bool rc = set_bool(str(LANG_POWEROFF), &global_settings.disk_poweroff);
990 ata_poweroff(global_settings.disk_poweroff);
991 return rc;
993 #endif /* HAVE_ATA_POWEROFF */
994 #endif /* !HAVE_MMC */
996 #if CONFIG_CODEC == MAS3507D
997 static bool line_in(void)
999 bool rc = set_bool(str(LANG_LINE_IN), &global_settings.line_in);
1000 #ifndef SIMULATOR
1001 dac_line_in(global_settings.line_in);
1002 #endif
1003 return rc;
1005 #endif
1007 static bool max_files_in_dir(void)
1009 return set_int(str(LANG_MAX_FILES_IN_DIR), "", UNIT_INT,
1010 &global_settings.max_files_in_dir,
1011 NULL, 50, 50, 10000, NULL );
1014 static bool max_files_in_playlist(void)
1016 return set_int(str(LANG_MAX_FILES_IN_PLAYLIST), "", UNIT_INT,
1017 &global_settings.max_files_in_playlist,
1018 NULL, 1000, 1000, 20000, NULL );
1021 #if CONFIG_CODEC == SWCODEC
1022 static bool buffer_margin(void)
1024 int ret;
1025 static const struct opt_items names[] = {
1026 { "5s", TALK_ID(5, UNIT_SEC) },
1027 { "15s", TALK_ID(15, UNIT_SEC) },
1028 { "30s", TALK_ID(30, UNIT_SEC) },
1029 { "1min", TALK_ID(1, UNIT_MIN) },
1030 { "2min", TALK_ID(2, UNIT_MIN) },
1031 { "3min", TALK_ID(3, UNIT_MIN) },
1032 { "5min", TALK_ID(5, UNIT_MIN) },
1033 { "10min", TALK_ID(10, UNIT_MIN) }
1036 ret = set_option(str(LANG_MP3BUFFER_MARGIN), &global_settings.buffer_margin,
1037 INT, names, 8, NULL);
1038 audio_set_buffer_margin(global_settings.buffer_margin);
1040 return ret;
1042 #else
1043 static bool buffer_margin(void)
1045 return set_int(str(LANG_MP3BUFFER_MARGIN), "s", UNIT_SEC,
1046 &global_settings.buffer_margin,
1047 audio_set_buffer_margin, 1, 0, 7, NULL );
1049 #endif
1051 static bool ff_rewind_min_step(void)
1053 static const struct opt_items names[] = {
1054 { "1s", TALK_ID(1, UNIT_SEC) },
1055 { "2s", TALK_ID(2, UNIT_SEC) },
1056 { "3s", TALK_ID(3, UNIT_SEC) },
1057 { "4s", TALK_ID(4, UNIT_SEC) },
1058 { "5s", TALK_ID(5, UNIT_SEC) },
1059 { "6s", TALK_ID(6, UNIT_SEC) },
1060 { "8s", TALK_ID(8, UNIT_SEC) },
1061 { "10s", TALK_ID(10, UNIT_SEC) },
1062 { "15s", TALK_ID(15, UNIT_SEC) },
1063 { "20s", TALK_ID(20, UNIT_SEC) },
1064 { "25s", TALK_ID(25, UNIT_SEC) },
1065 { "30s", TALK_ID(30, UNIT_SEC) },
1066 { "45s", TALK_ID(45, UNIT_SEC) },
1067 { "60s", TALK_ID(60, UNIT_SEC) }
1069 return set_option(str(LANG_FFRW_STEP), &global_settings.ff_rewind_min_step,
1070 INT, names, 14, NULL );
1073 static bool set_fade_on_stop(void)
1075 return set_bool( str(LANG_FADE_ON_STOP), &global_settings.fade_on_stop );
1078 static bool set_party_mode(void)
1080 return set_bool( str(LANG_PARTY_MODE), &global_settings.party_mode );
1083 #ifdef CONFIG_BACKLIGHT
1084 static bool set_bl_filter_first_keypress(void)
1086 bool result = set_bool( str(LANG_BACKLIGHT_FILTER_FIRST_KEYPRESS),
1087 &global_settings.bl_filter_first_keypress );
1088 set_backlight_filter_keypress(global_settings.bl_filter_first_keypress);
1089 return result;
1091 #ifdef HAVE_REMOTE_LCD
1092 static bool set_remote_bl_filter_first_keypress(void)
1094 bool result = set_bool( str(LANG_BACKLIGHT_FILTER_FIRST_KEYPRESS),
1095 &global_settings.remote_bl_filter_first_keypress );
1096 set_remote_backlight_filter_keypress(global_settings.remote_bl_filter_first_keypress);
1097 return result;
1099 #endif
1100 #endif
1102 static bool ff_rewind_accel(void)
1104 static const struct opt_items names[] = {
1105 { STR(LANG_OFF) },
1106 { "2x/1s", TALK_ID(1, UNIT_SEC) },
1107 { "2x/2s", TALK_ID(2, UNIT_SEC) },
1108 { "2x/3s", TALK_ID(3, UNIT_SEC) },
1109 { "2x/4s", TALK_ID(4, UNIT_SEC) },
1110 { "2x/5s", TALK_ID(5, UNIT_SEC) },
1111 { "2x/6s", TALK_ID(6, UNIT_SEC) },
1112 { "2x/7s", TALK_ID(7, UNIT_SEC) },
1113 { "2x/8s", TALK_ID(8, UNIT_SEC) },
1114 { "2x/9s", TALK_ID(9, UNIT_SEC) },
1115 { "2x/10s", TALK_ID(10, UNIT_SEC) },
1116 { "2x/11s", TALK_ID(11, UNIT_SEC) },
1117 { "2x/12s", TALK_ID(12, UNIT_SEC) },
1118 { "2x/13s", TALK_ID(13, UNIT_SEC) },
1119 { "2x/14s", TALK_ID(14, UNIT_SEC) },
1120 { "2x/15s", TALK_ID(15, UNIT_SEC) }
1122 return set_option(str(LANG_FFRW_ACCEL), &global_settings.ff_rewind_accel,
1123 INT, names, 16, NULL );
1126 static bool browse_current(void)
1128 return set_bool( str(LANG_FOLLOW), &global_settings.browse_current );
1131 static bool custom_wps_browse(void)
1133 return rockbox_browse(WPS_DIR, SHOW_WPS);
1136 #ifdef HAVE_REMOTE_LCD
1137 static bool custom_remote_wps_browse(void)
1139 return rockbox_browse(WPS_DIR, SHOW_RWPS);
1141 #endif
1143 static bool custom_cfg_browse(void)
1145 return rockbox_browse(ROCKBOX_DIR, SHOW_CFG);
1148 static bool language_browse(void)
1150 return rockbox_browse(ROCKBOX_DIR LANG_DIR, SHOW_LNG);
1153 static bool voice_menus(void)
1155 bool ret;
1156 bool temp = global_settings.talk_menu;
1157 /* work on a temp variable first, avoid "life" disabling */
1158 ret = set_bool( str(LANG_VOICE_MENU), &temp );
1159 global_settings.talk_menu = temp;
1160 return ret;
1163 /* this is used 2 times below, so it saves memory to put it in global scope */
1164 static const struct opt_items voice_names[] = {
1165 { STR(LANG_OFF) },
1166 { STR(LANG_VOICE_NUMBER) },
1167 { STR(LANG_VOICE_SPELL) },
1168 { STR(LANG_VOICE_DIR_HOVER) }
1171 static bool voice_dirs(void)
1173 return set_option( str(LANG_VOICE_DIR),
1174 &global_settings.talk_dir, INT, voice_names, 4, NULL);
1177 static bool voice_files(void)
1179 int oldval = global_settings.talk_file;
1180 bool ret;
1181 ret = set_option( str(LANG_VOICE_FILE),
1182 &global_settings.talk_file, INT, voice_names, 4, NULL);
1183 if (oldval != 3 && global_settings.talk_file == 3)
1184 { /* force reload if newly talking thumbnails,
1185 because the clip presence is cached only if enabled */
1186 reload_directory();
1188 return ret;
1191 static bool voice_menu(void)
1193 int m;
1194 bool result;
1196 static const struct menu_item items[] = {
1197 { ID2P(LANG_VOICE_MENU), voice_menus },
1198 { ID2P(LANG_VOICE_DIR), voice_dirs },
1199 { ID2P(LANG_VOICE_FILE), voice_files }
1202 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
1203 NULL, NULL, NULL);
1204 result = menu_run(m);
1205 menu_exit(m);
1206 return result;
1209 #ifdef HAVE_LCD_BITMAP
1210 static bool font_browse(void)
1212 return rockbox_browse(ROCKBOX_DIR FONT_DIR, SHOW_FONT);
1215 static bool scroll_bar(void)
1217 return set_bool( str(LANG_SCROLL_BAR), &global_settings.scrollbar );
1220 static bool status_bar(void)
1222 return set_bool( str(LANG_STATUS_BAR), &global_settings.statusbar );
1225 #if CONFIG_KEYPAD == RECORDER_PAD
1226 static bool button_bar(void)
1228 return set_bool( str(LANG_BUTTON_BAR), &global_settings.buttonbar );
1230 #endif /* CONFIG_KEYPAD == RECORDER_PAD */
1231 #endif /* HAVE_LCD_BITMAP */
1233 static bool ff_rewind_settings_menu(void)
1235 int m;
1236 bool result;
1238 static const struct menu_item items[] = {
1239 { ID2P(LANG_FFRW_STEP), ff_rewind_min_step },
1240 { ID2P(LANG_FFRW_ACCEL), ff_rewind_accel },
1243 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
1244 NULL, NULL, NULL);
1245 result = menu_run(m);
1246 menu_exit(m);
1248 return result;
1251 static bool id3_order(void)
1253 return set_bool_options( str(LANG_ID3_ORDER),
1254 &global_settings.id3_v1_first,
1255 STR(LANG_ID3_V1_FIRST),
1256 STR(LANG_ID3_V2_FIRST),
1257 mpeg_id3_options);
1260 static bool next_folder(void)
1262 return set_bool( str(LANG_NEXT_FOLDER), &global_settings.next_folder );
1265 static bool runtimedb(void)
1267 bool rc;
1268 // bool old = global_settings.runtimedb;
1270 rc = set_bool( str(LANG_RUNTIMEDB_ACTIVE),
1271 &global_settings.runtimedb );
1272 /* if (old && !global_settings.runtimedb)
1273 rundb_shutdown();
1274 if (!old && global_settings.runtimedb)
1275 rundb_init();
1277 return rc;
1280 static bool codepage_setting(void)
1282 static const struct opt_items names[] = {
1283 { STR(LANG_CODEPAGE_LATIN1) },
1284 { STR(LANG_CODEPAGE_GREEK) },
1285 { STR(LANG_CODEPAGE_HEBREW) },
1286 { STR(LANG_CODEPAGE_CYRILLIC) },
1287 { STR(LANG_CODEPAGE_THAI) },
1288 { STR(LANG_CODEPAGE_ARABIC) },
1289 { STR(LANG_CODEPAGE_TURKISH) },
1290 { STR(LANG_CODEPAGE_LATIN_EXTENDED) },
1291 { STR(LANG_CODEPAGE_JAPANESE) },
1292 { STR(LANG_CODEPAGE_SIMPLIFIED) },
1293 { STR(LANG_CODEPAGE_KOREAN) },
1294 { STR(LANG_CODEPAGE_TRADITIONAL) },
1295 { STR(LANG_CODEPAGE_UTF8) },
1297 return set_option(str(LANG_DEFAULT_CODEPAGE),
1298 &global_settings.default_codepage,
1299 INT, names, 13, set_codepage );
1302 #if CONFIG_CODEC == SWCODEC
1303 static bool replaygain(void)
1305 bool result = set_bool(str(LANG_REPLAYGAIN_ENABLE),
1306 &global_settings.replaygain);
1308 dsp_set_replaygain(true);
1309 return result;
1312 static bool replaygain_mode(void)
1314 static const struct opt_items names[] = {
1315 { STR(LANG_TRACK_GAIN) },
1316 { STR(LANG_ALBUM_GAIN) },
1317 { STR(LANG_SHUFFLE_GAIN) },
1319 bool result = set_option(str(LANG_REPLAYGAIN_MODE),
1320 &global_settings.replaygain_type, INT, names, 3, NULL);
1322 dsp_set_replaygain(true);
1323 return result;
1326 static bool replaygain_noclip(void)
1328 bool result = set_bool(str(LANG_REPLAYGAIN_NOCLIP),
1329 &global_settings.replaygain_noclip);
1331 dsp_set_replaygain(true);
1332 return result;
1335 void replaygain_preamp_format(char* buffer, int buffer_size, int value,
1336 const char* unit)
1338 int v = abs(value);
1340 snprintf(buffer, buffer_size, "%s%d.%d %s", value < 0 ? "-" : "",
1341 v / 10, v % 10, unit);
1344 static bool replaygain_preamp(void)
1346 bool result = set_int(str(LANG_REPLAYGAIN_PREAMP), str(LANG_UNIT_DB),
1347 UNIT_DB, &global_settings.replaygain_preamp, NULL, 1, -120, 120,
1348 replaygain_preamp_format);
1350 dsp_set_replaygain(true);
1351 return result;
1354 static bool replaygain_settings_menu(void)
1356 int m;
1357 bool result;
1359 static const struct menu_item items[] = {
1360 { ID2P(LANG_REPLAYGAIN_ENABLE), replaygain },
1361 { ID2P(LANG_REPLAYGAIN_NOCLIP), replaygain_noclip },
1362 { ID2P(LANG_REPLAYGAIN_MODE), replaygain_mode },
1363 { ID2P(LANG_REPLAYGAIN_PREAMP), replaygain_preamp },
1366 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
1367 NULL, NULL, NULL);
1368 result = menu_run(m);
1369 menu_exit(m);
1370 return result;
1373 static bool crossfade(void)
1375 static const struct opt_items names[] = {
1376 { STR(LANG_OFF) },
1377 { STR(LANG_SHUFFLE) },
1378 { STR(LANG_TRACKSKIP) },
1379 { STR(LANG_ALWAYS) },
1382 bool ret;
1384 ret=set_option( str(LANG_CROSSFADE_ENABLE),
1385 &global_settings.crossfade, INT, names, 4, NULL);
1387 audio_set_crossfade(global_settings.crossfade);
1389 return ret;
1392 static bool crossfade_fade_in_delay(void)
1394 bool ret;
1396 ret = set_int(str(LANG_CROSSFADE_FADE_IN_DELAY), "s", UNIT_SEC,
1397 &global_settings.crossfade_fade_in_delay,
1398 NULL, 1, 0, 7, NULL );
1399 audio_set_crossfade(global_settings.crossfade);
1400 return ret;
1403 static bool crossfade_fade_out_delay(void)
1405 bool ret;
1407 ret = set_int(str(LANG_CROSSFADE_FADE_OUT_DELAY), "s", UNIT_SEC,
1408 &global_settings.crossfade_fade_out_delay,
1409 NULL, 1, 0, 7, NULL );
1410 audio_set_crossfade(global_settings.crossfade);
1411 return ret;
1414 static bool crossfade_fade_in_duration(void)
1416 bool ret;
1418 ret = set_int(str(LANG_CROSSFADE_FADE_IN_DURATION), "s", UNIT_SEC,
1419 &global_settings.crossfade_fade_in_duration,
1420 NULL, 1, 0, 15, NULL );
1421 audio_set_crossfade(global_settings.crossfade);
1422 return ret;
1425 static bool crossfade_fade_out_duration(void)
1427 bool ret;
1429 ret = set_int(str(LANG_CROSSFADE_FADE_OUT_DURATION), "s", UNIT_SEC,
1430 &global_settings.crossfade_fade_out_duration,
1431 NULL, 1, 0, 15, NULL );
1432 audio_set_crossfade(global_settings.crossfade);
1433 return ret;
1436 static bool crossfade_fade_out_mixmode(void)
1438 static const struct opt_items names[] = {
1439 { STR(LANG_CROSSFADE) },
1440 { STR(LANG_MIX) },
1442 bool ret;
1443 ret=set_option( str(LANG_CROSSFADE_FADE_OUT_MODE),
1444 &global_settings.crossfade_fade_out_mixmode, INT, names, 2, NULL);
1446 return ret;
1450 * Menu to configure the crossfade settings.
1452 static bool crossfade_settings_menu(void)
1454 int m;
1455 bool result;
1457 static const struct menu_item items[] = {
1458 { ID2P(LANG_CROSSFADE_ENABLE), crossfade },
1459 { ID2P(LANG_CROSSFADE_FADE_IN_DELAY), crossfade_fade_in_delay },
1460 { ID2P(LANG_CROSSFADE_FADE_IN_DURATION), crossfade_fade_in_duration },
1461 { ID2P(LANG_CROSSFADE_FADE_OUT_DELAY), crossfade_fade_out_delay },
1462 { ID2P(LANG_CROSSFADE_FADE_OUT_DURATION), crossfade_fade_out_duration },
1463 { ID2P(LANG_CROSSFADE_FADE_OUT_MODE), crossfade_fade_out_mixmode },
1466 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
1467 NULL, NULL, NULL);
1468 result = menu_run(m);
1469 menu_exit(m);
1470 return result;
1473 static bool beep(void)
1475 static const struct opt_items names[] = {
1476 { STR(LANG_OFF) },
1477 { STR(LANG_WEAK) },
1478 { STR(LANG_MODERATE) },
1479 { STR(LANG_STRONG) },
1481 bool ret;
1482 ret=set_option( str(LANG_BEEP),
1483 &global_settings.beep, INT, names, 4, NULL);
1485 return ret;
1487 #endif
1490 #ifdef HAVE_DIRCACHE
1491 static bool dircache(void)
1493 bool result = set_bool_options(str(LANG_DIRCACHE_ENABLE),
1494 &global_settings.dircache,
1495 STR(LANG_ON),
1496 STR(LANG_OFF),
1497 NULL);
1499 if (!dircache_is_enabled() && global_settings.dircache)
1500 gui_syncsplash(HZ*2, true, str(LANG_DIRCACHE_REBOOT));
1502 if (!result)
1503 dircache_disable();
1505 return result;
1508 static bool tagcache_ram(void)
1510 bool result = set_bool_options(str(LANG_TAGCACHE),
1511 &global_settings.tagcache_ram,
1512 STR(LANG_TAGCACHE_RAM),
1513 STR(LANG_TAGCACHE_DISK),
1514 NULL);
1516 return result;
1518 #endif /* HAVE_DIRCACHE */
1520 static bool playback_settings_menu(void)
1522 int m;
1523 bool result;
1525 static const struct menu_item items[] = {
1526 { ID2P(LANG_SHUFFLE), shuffle },
1527 { ID2P(LANG_REPEAT), repeat_mode },
1528 { ID2P(LANG_PLAY_SELECTED), play_selected },
1529 { ID2P(LANG_RESUME), resume },
1530 { ID2P(LANG_WIND_MENU), ff_rewind_settings_menu },
1531 { ID2P(LANG_MP3BUFFER_MARGIN), buffer_margin },
1532 { ID2P(LANG_FADE_ON_STOP), set_fade_on_stop },
1533 { ID2P(LANG_PARTY_MODE), set_party_mode },
1534 #if CONFIG_CODEC == SWCODEC
1535 { ID2P(LANG_CROSSFADE), crossfade_settings_menu },
1536 { ID2P(LANG_REPLAYGAIN), replaygain_settings_menu },
1537 { ID2P(LANG_BEEP), beep },
1538 #endif
1539 #ifdef HAVE_SPDIF_POWER
1540 { ID2P(LANG_SPDIF_ENABLE), spdif },
1541 #endif
1542 { ID2P(LANG_ID3_ORDER), id3_order },
1543 { ID2P(LANG_NEXT_FOLDER), next_folder },
1544 #ifdef HAVE_DIRCACHE
1545 { ID2P(LANG_TAGCACHE), tagcache_ram },
1546 #endif
1547 { ID2P(LANG_TAGCACHE_FORCE_UPDATE), tagcache_force_update },
1548 { ID2P(LANG_RUNTIMEDB_ACTIVE), runtimedb },
1551 bool old_shuffle = global_settings.playlist_shuffle;
1553 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
1554 NULL, NULL, NULL);
1555 result = menu_run(m);
1556 menu_exit(m);
1558 if ((old_shuffle != global_settings.playlist_shuffle)
1559 && (audio_status() & AUDIO_STATUS_PLAY))
1561 #if CONFIG_CODEC == SWCODEC
1562 dsp_set_replaygain(true);
1563 #endif
1565 if (global_settings.playlist_shuffle)
1567 playlist_randomise(NULL, current_tick, true);
1569 else
1571 playlist_sort(NULL, true);
1574 return result;
1577 static bool bookmark_settings_menu(void)
1579 int m;
1580 bool result;
1582 static const struct menu_item items[] = {
1583 { ID2P(LANG_BOOKMARK_SETTINGS_AUTOCREATE), autocreatebookmark},
1584 { ID2P(LANG_BOOKMARK_SETTINGS_AUTOLOAD), autoloadbookmark},
1585 { ID2P(LANG_BOOKMARK_SETTINGS_MAINTAIN_RECENT_BOOKMARKS), useMRB},
1588 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
1589 NULL, NULL, NULL);
1590 result = menu_run(m);
1591 menu_exit(m);
1593 return result;
1595 static bool reset_settings(void)
1597 unsigned char *lines[]={str(LANG_RESET_ASK_RECORDER)};
1598 unsigned char *yes_lines[]={
1599 str(LANG_RESET_DONE_SETTING),
1600 str(LANG_RESET_DONE_CLEAR)
1602 unsigned char *no_lines[]={yes_lines[0], str(LANG_RESET_DONE_CANCEL)};
1603 struct text_message message={(char **)lines, 1};
1604 struct text_message yes_message={(char **)yes_lines, 2};
1605 struct text_message no_message={(char **)no_lines, 2};
1607 switch(gui_syncyesno_run(&message, &yes_message, &no_message))
1609 case YESNO_YES:
1610 settings_reset();
1611 settings_apply();
1612 break;
1613 case YESNO_NO:
1614 break;
1615 case YESNO_USB:
1616 return true;
1618 return false;
1621 static bool fileview_settings_menu(void)
1623 int m;
1624 bool result;
1626 static const struct menu_item items[] = {
1627 { ID2P(LANG_SORT_CASE), sort_case },
1628 { ID2P(LANG_SORT_DIR), sort_dir },
1629 { ID2P(LANG_SORT_FILE), sort_file },
1630 { ID2P(LANG_FILTER), dir_filter },
1631 { ID2P(LANG_FOLLOW), browse_current },
1632 { ID2P(LANG_SHOW_ICONS), show_icons },
1635 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
1636 NULL, NULL, NULL);
1637 result = menu_run(m);
1638 menu_exit(m);
1639 return result;
1643 static bool scroll_settings_menu(void)
1645 int m;
1646 bool result;
1648 static const struct menu_item items[] = {
1649 { ID2P(LANG_SCROLL_SPEED), scroll_speed },
1650 { ID2P(LANG_SCROLL_DELAY), scroll_delay },
1651 #ifdef HAVE_LCD_BITMAP
1652 { ID2P(LANG_SCROLL_STEP), scroll_step },
1653 #endif
1654 { ID2P(LANG_BIDIR_SCROLL), bidir_limit },
1655 #ifdef HAVE_LCD_CHARCELLS
1656 { ID2P(LANG_JUMP_SCROLL), jump_scroll },
1657 { ID2P(LANG_JUMP_SCROLL_DELAY), jump_scroll_delay },
1658 #endif
1659 #ifdef HAVE_LCD_BITMAP
1660 { ID2P(LANG_SCREEN_SCROLL_VIEW), screen_scroll },
1661 { ID2P(LANG_SCREEN_SCROLL_STEP), screen_scroll_step },
1662 #endif
1663 { ID2P(LANG_SCROLL_PAGINATED), scroll_paginated },
1666 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
1667 NULL, NULL, NULL);
1668 result = menu_run(m);
1669 menu_exit(m);
1670 return result;
1673 static bool lcd_settings_menu(void)
1675 int m;
1676 bool result;
1678 static const struct menu_item items[] = {
1679 #ifdef CONFIG_BACKLIGHT
1680 { ID2P(LANG_BACKLIGHT), backlight_timer },
1681 #ifdef HAVE_CHARGING
1682 { ID2P(LANG_BACKLIGHT_ON_WHEN_CHARGING), backlight_timer_plugged },
1683 #endif
1684 { ID2P(LANG_CAPTION_BACKLIGHT), caption_backlight },
1685 #if defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR)
1686 { ID2P(LANG_BACKLIGHT_FADE_IN), backlight_fade_in },
1687 { ID2P(LANG_BACKLIGHT_FADE_OUT), backlight_fade_out },
1688 #endif
1689 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
1690 { ID2P(LANG_BRIGHTNESS), brightness },
1691 #endif
1692 { ID2P(LANG_BACKLIGHT_FILTER_FIRST_KEYPRESS), set_bl_filter_first_keypress },
1693 #endif /* CONFIG_BACKLIGHT */
1694 #ifndef HAVE_LCD_COLOR
1695 { ID2P(LANG_CONTRAST), contrast },
1696 #endif
1697 #ifdef HAVE_LCD_BITMAP
1698 #ifndef HAVE_LCD_COLOR
1699 { ID2P(LANG_INVERT), invert },
1700 #endif
1701 #ifdef HAVE_LCD_FLIP
1702 { ID2P(LANG_FLIP_DISPLAY), flip_display },
1703 #endif
1704 { ID2P(LANG_INVERT_CURSOR), invert_cursor },
1705 #endif
1706 #ifdef HAVE_LCD_COLOR
1707 { ID2P(LANG_CLEAR_BACKDROP), clear_main_backdrop },
1708 { ID2P(LANG_BACKGROUND_COLOR), set_bg_color },
1709 { ID2P(LANG_FOREGROUND_COLOR), set_fg_color },
1710 { ID2P(LANG_RESET_COLORS), reset_color },
1711 #endif
1714 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
1715 NULL, NULL, NULL);
1716 result = menu_run(m);
1717 menu_exit(m);
1718 return result;
1721 #ifdef HAVE_REMOTE_LCD
1722 static bool lcd_remote_settings_menu(void)
1724 int m;
1725 bool result;
1727 static const struct menu_item items[] = {
1728 { ID2P(LANG_BACKLIGHT), remote_backlight_timer },
1729 #ifdef HAVE_CHARGING
1730 { ID2P(LANG_BACKLIGHT_ON_WHEN_CHARGING),
1731 remote_backlight_timer_plugged },
1732 #endif
1733 { ID2P(LANG_CAPTION_BACKLIGHT), remote_caption_backlight },
1734 { ID2P(LANG_BACKLIGHT_FILTER_FIRST_KEYPRESS), set_remote_bl_filter_first_keypress },
1735 { ID2P(LANG_CONTRAST), remote_contrast },
1736 { ID2P(LANG_INVERT), remote_invert },
1737 { ID2P(LANG_FLIP_DISPLAY), remote_flip_display },
1738 #ifdef HAVE_REMOTE_LCD_TICKING
1739 { ID2P(LANG_REDUCE_TICKING), remote_reduce_ticking },
1740 #endif
1743 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
1744 NULL, NULL, NULL);
1745 result = menu_run(m);
1746 menu_exit(m);
1747 return result;
1749 #endif
1751 #ifdef HAVE_LCD_BITMAP
1752 static bool bars_settings_menu(void)
1754 int m;
1755 bool result;
1757 static const struct menu_item items[] = {
1758 { ID2P(LANG_SCROLL_BAR), scroll_bar },
1759 { ID2P(LANG_STATUS_BAR), status_bar },
1760 #if CONFIG_KEYPAD == RECORDER_PAD
1761 { ID2P(LANG_BUTTON_BAR), button_bar },
1762 #endif
1763 { ID2P(LANG_VOLUME_DISPLAY), volume_type },
1764 { ID2P(LANG_BATTERY_DISPLAY), battery_display },
1767 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
1768 NULL, NULL, NULL);
1769 result = menu_run(m);
1770 menu_exit(m);
1771 return result;
1773 #endif
1776 static bool display_settings_menu(void)
1778 int m;
1779 bool result;
1781 static const struct menu_item items[] = {
1782 #ifdef HAVE_LCD_BITMAP
1783 { ID2P(LANG_CUSTOM_FONT), font_browse },
1784 #endif
1785 { ID2P(LANG_WHILE_PLAYING), custom_wps_browse },
1786 #ifdef HAVE_REMOTE_LCD
1787 { ID2P(LANG_REMOTE_WHILE_PLAYING), custom_remote_wps_browse },
1788 #endif
1789 { ID2P(LANG_LCD_MENU), lcd_settings_menu },
1790 #ifdef HAVE_REMOTE_LCD
1791 { ID2P(LANG_LCD_REMOTE_MENU), lcd_remote_settings_menu },
1792 #endif
1793 { ID2P(LANG_SCROLL_MENU), scroll_settings_menu },
1794 #ifdef HAVE_LCD_BITMAP
1795 { ID2P(LANG_BARS_MENU), bars_settings_menu },
1796 { ID2P(LANG_PM_MENU), peak_meter_menu },
1797 #endif
1798 { ID2P(LANG_DEFAULT_CODEPAGE), codepage_setting },
1801 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
1802 NULL, NULL, NULL);
1803 result = menu_run(m);
1804 menu_exit(m);
1805 return result;
1809 static bool firmware_browse(void)
1811 return rockbox_browse(ROCKBOX_DIR, SHOW_MOD);
1814 static bool battery_settings_menu(void)
1816 int m;
1817 bool result;
1819 static const struct menu_item items[] = {
1820 #ifndef SIMULATOR
1821 { ID2P(LANG_BATTERY_CAPACITY), battery_capacity },
1822 #if BATTERY_TYPES_COUNT > 1
1823 { ID2P(LANG_BATTERY_TYPE), battery_type },
1824 #endif
1825 #else
1826 #ifndef HAVE_CHARGE_CTRL
1827 { "Dummy", NULL }, /* to have an entry at all, in the simulator */
1828 #endif
1829 #endif
1832 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
1833 NULL, NULL, NULL);
1834 result = menu_run(m);
1835 menu_exit(m);
1836 return result;
1839 #ifndef HAVE_MMC
1840 static bool disk_settings_menu(void)
1842 int m;
1843 bool result;
1845 static const struct menu_item items[] = {
1846 { ID2P(LANG_SPINDOWN), spindown },
1847 #ifdef HAVE_ATA_POWER_OFF
1848 { ID2P(LANG_POWEROFF), poweroff },
1849 #endif
1850 #ifdef HAVE_DIRCACHE
1851 { ID2P(LANG_DIRCACHE_ENABLE), dircache },
1852 #endif
1855 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
1856 NULL, NULL, NULL);
1857 result = menu_run(m);
1858 menu_exit(m);
1859 return result;
1861 #endif /* !HAVE_MMC */
1863 #ifdef CONFIG_RTC
1864 static bool time_settings_menu(void)
1866 int m;
1867 bool result;
1869 static const struct menu_item items[] = {
1870 { ID2P(LANG_TIME), timedate_set },
1871 { ID2P(LANG_TIMEFORMAT), timeformat_set },
1874 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
1875 NULL, NULL, NULL);
1876 result = menu_run(m);
1877 menu_exit(m);
1878 return result;
1880 #endif
1882 bool manage_settings_menu(void)
1884 int m;
1885 bool result;
1887 static const struct menu_item items[] = {
1888 { ID2P(LANG_CUSTOM_CFG), custom_cfg_browse },
1889 { ID2P(LANG_FIRMWARE), firmware_browse },
1890 { ID2P(LANG_RESET), reset_settings },
1891 { ID2P(LANG_SAVE_SETTINGS), settings_save_config },
1894 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
1895 NULL, NULL, NULL);
1896 result = menu_run(m);
1897 menu_exit(m);
1898 return result;
1901 static bool limits_settings_menu(void)
1903 int m;
1904 bool result;
1906 static const struct menu_item items[] = {
1907 { ID2P(LANG_MAX_FILES_IN_DIR), max_files_in_dir },
1908 { ID2P(LANG_MAX_FILES_IN_PLAYLIST), max_files_in_playlist },
1911 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
1912 NULL, NULL, NULL);
1913 result = menu_run(m);
1914 menu_exit(m);
1915 return result;
1919 static bool system_settings_menu(void)
1921 int m;
1922 bool result;
1924 static const struct menu_item items[] = {
1925 { ID2P(LANG_BATTERY_MENU), battery_settings_menu },
1926 #ifndef HAVE_MMC
1927 { ID2P(LANG_DISK_MENU), disk_settings_menu },
1928 #endif
1929 #ifdef CONFIG_RTC
1930 { ID2P(LANG_TIME_MENU), time_settings_menu },
1931 #endif
1932 { ID2P(LANG_POWEROFF_IDLE), poweroff_idle_timer },
1933 { ID2P(LANG_SLEEP_TIMER), sleep_timer },
1934 #ifdef HAVE_ALARM_MOD
1935 { ID2P(LANG_ALARM_MOD_ALARM_MENU), alarm_screen },
1936 #endif
1937 { ID2P(LANG_LIMITS_MENU), limits_settings_menu },
1938 #if CONFIG_CODEC == MAS3507D
1939 { ID2P(LANG_LINE_IN), line_in },
1940 #endif
1941 #ifdef HAVE_CHARGING
1942 { ID2P(LANG_CAR_ADAPTER_MODE), car_adapter_mode },
1943 #endif
1946 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
1947 NULL, NULL, NULL);
1948 result = menu_run(m);
1949 menu_exit(m);
1950 return result;
1953 bool settings_menu(void)
1955 int m;
1956 bool result;
1958 static const struct menu_item items[] = {
1959 { ID2P(LANG_PLAYBACK), playback_settings_menu },
1960 { ID2P(LANG_FILE), fileview_settings_menu },
1961 { ID2P(LANG_DISPLAY), display_settings_menu },
1962 { ID2P(LANG_SYSTEM), system_settings_menu },
1963 { ID2P(LANG_BOOKMARK_SETTINGS),bookmark_settings_menu },
1964 { ID2P(LANG_LANGUAGE), language_browse },
1965 { ID2P(LANG_VOICE), voice_menu },
1968 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
1969 NULL, NULL, NULL);
1970 result = menu_run(m);
1971 menu_exit(m);
1972 return result;