Added Benjamin Metzlers bookmarking feature (patch #669440)
[kugel-rb.git] / apps / settings_menu.c
bloba96c88c68186e0801a867e13c191faeb98f918ba
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>
25 #include "lcd.h"
26 #include "menu.h"
27 #include "mpeg.h"
28 #include "button.h"
29 #include "kernel.h"
30 #include "thread.h"
31 #include "sprintf.h"
32 #include "settings.h"
33 #include "settings_menu.h"
34 #include "backlight.h"
35 #include "playlist.h" /* for playlist_shuffle */
36 #include "fat.h" /* For dotfile settings */
37 #include "powermgmt.h"
38 #include "rtc.h"
39 #include "ata.h"
40 #include "tree.h"
41 #include "screens.h"
42 #ifdef HAVE_LCD_BITMAP
43 #include "peakmeter.h"
44 #endif
45 #include "lang.h"
46 #ifdef HAVE_MAS3507D
47 void dac_line_in(bool enable);
48 #endif
50 static bool car_adapter_mode(void)
52 return set_bool_options( str(LANG_CAR_ADAPTER_MODE),
53 &global_settings.car_adapter_mode,
54 str(LANG_SET_BOOL_YES),
55 str(LANG_SET_BOOL_NO),
56 set_car_adapter_mode);
59 static bool contrast(void)
61 return set_int( str(LANG_CONTRAST), "", &global_settings.contrast,
62 lcd_set_contrast, 1, MIN_CONTRAST_SETTING,
63 MAX_CONTRAST_SETTING );
66 static bool caption_backlight(void)
68 bool rc = set_bool( str(LANG_CAPTION_BACKLIGHT),
69 &global_settings.caption_backlight);
71 return rc;
74 /**
75 * Menu to set icon visibility
77 static bool show_icons(void)
79 return set_bool( str(LANG_SHOW_ICONS), &global_settings.show_icons );
82 #ifdef HAVE_LCD_BITMAP
84 /**
85 * Menu to set LCD Mode (normal/inverse)
87 static bool invert(void)
89 bool rc = set_bool_options(str(LANG_INVERT),
90 &global_settings.invert,
91 str(LANG_INVERT_LCD_INVERSE),
92 str(LANG_INVERT_LCD_NORMAL),
93 lcd_set_invert_display);
94 return rc;
97 /**
98 * Menu to set Line Selector Type (Pointer/Bar)
100 static bool invert_cursor(void)
102 return set_bool_options(str(LANG_INVERT_CURSOR),
103 &global_settings.invert_cursor,
104 str(LANG_INVERT_CURSOR_BAR),
105 str(LANG_INVERT_CURSOR_POINTER),
106 NULL);
110 * Menu to turn the display+buttons by 180 degrees
112 static bool flip_display(void)
114 bool rc = set_bool( str(LANG_FLIP_DISPLAY),
115 &global_settings.flip_display);
117 button_set_flip(global_settings.flip_display);
118 lcd_set_flip(global_settings.flip_display);
120 return rc;
124 * Menu to configure the battery display on status bar
126 static bool battery_type(void)
128 char* names[] = { str(LANG_DISPLAY_GRAPHIC),
129 str(LANG_DISPLAY_NUMERIC) };
131 return set_option( str(LANG_BATTERY_DISPLAY),
132 &global_settings.battery_type, INT, names, 2, NULL);
136 * Menu to configure the volume display on status bar
138 static bool volume_type(void)
140 char* names[] = { str(LANG_DISPLAY_GRAPHIC),
141 str(LANG_DISPLAY_NUMERIC) };
143 return set_option( str(LANG_VOLUME_DISPLAY), &global_settings.volume_type,
144 INT, names, 2, NULL);
147 #ifdef PM_DEBUG
148 static bool peak_meter_fps_menu(void) {
149 bool retval = false;
150 retval = set_int( "Refresh rate", "/s",
151 &peak_meter_fps,
152 NULL, 1, 5, 40);
153 return retval;
155 #endif /* PM_DEBUG */
158 * Menu to set the hold time of normal peaks.
160 static bool peak_meter_hold(void) {
161 bool retval = false;
162 char* names[] = { str(LANG_OFF),
163 "200 ms ", "300 ms ", "500 ms ", "1 s ", "2 s ",
164 "3 s ", "4 s ", "5 s ", "6 s ", "7 s",
165 "8 s", "9 s", "10 s", "15 s", "20 s",
166 "30 s", "1 min"
168 retval = set_option( str(LANG_PM_PEAK_HOLD),
169 &global_settings.peak_meter_hold, INT, names,
170 18, NULL);
172 peak_meter_init_times(global_settings.peak_meter_release,
173 global_settings.peak_meter_hold,
174 global_settings.peak_meter_clip_hold);
176 return retval;
180 * Menu to set the hold time of clips.
182 static bool peak_meter_clip_hold(void) {
183 bool retval = false;
185 char* names[] = { str(LANG_PM_ETERNAL),
186 "1s ", "2s ", "3s ", "4s ", "5s ",
187 "6s ", "7s ", "8s ", "9s ", "10s",
188 "15s", "20s", "25s", "30s", "45s",
189 "60s", "90s", "2min", "3min", "5min",
190 "10min", "20min", "45min", "90min"
193 retval = set_option( str(LANG_PM_CLIP_HOLD),
194 &global_settings.peak_meter_clip_hold, INT, names,
195 25, peak_meter_set_clip_hold);
197 peak_meter_init_times(global_settings.peak_meter_release,
198 global_settings.peak_meter_hold,
199 global_settings.peak_meter_clip_hold);
201 return retval;
205 * Menu to set the release time of the peak meter.
207 static bool peak_meter_release(void) {
208 bool retval = false;
210 /* The range of peak_meter_release is restricted so that it
211 fits into a 7 bit number. The 8th bit is used for storing
212 something else in the rtc ram.
213 Also, the max value is 0x7e, since the RTC value 0xff is reserved */
214 retval = set_int( str(LANG_PM_RELEASE), str(LANG_PM_UNITS_PER_READ),
215 &global_settings.peak_meter_release,
216 NULL, 1, 1, 0x7e);
218 peak_meter_init_times(global_settings.peak_meter_release,
219 global_settings.peak_meter_hold,
220 global_settings.peak_meter_clip_hold);
222 return retval;
226 * Menu to select wether the scale of the meter
227 * displays dBfs of linear values.
229 static bool peak_meter_scale(void) {
230 bool retval = false;
231 bool use_dbfs = global_settings.peak_meter_dbfs;
232 retval = set_bool_options(str(LANG_PM_SCALE),
233 &use_dbfs,
234 str(LANG_PM_DBFS), str(LANG_PM_LINEAR),
235 NULL);
237 /* has the user really changed the scale? */
238 if (use_dbfs != global_settings.peak_meter_dbfs) {
240 /* store the change */
241 global_settings.peak_meter_dbfs = use_dbfs;
242 peak_meter_set_use_dbfs(use_dbfs);
244 /* If the user changed the scale mode the meaning of
245 peak_meter_min (peak_meter_max) has changed. Thus we have
246 to convert the values stored in global_settings. */
247 if (use_dbfs) {
249 /* we only store -dBfs */
250 global_settings.peak_meter_min = -peak_meter_get_min() / 100;
251 global_settings.peak_meter_max = -peak_meter_get_max() / 100;
252 } else {
253 int max;
255 /* linear percent */
256 global_settings.peak_meter_min = peak_meter_get_min();
258 /* converting dBfs -> percent results in a precision loss.
259 I assume that the user doesn't bother that conversion
260 dBfs <-> percent isn't symmetrical for odd values but that
261 he wants 0 dBfs == 100%. Thus I 'correct' the percent value
262 resulting from dBfs -> percent manually here */
263 max = peak_meter_get_max();
264 global_settings.peak_meter_max = max < 99 ? max : 100;
266 settings_apply_pm_range();
268 return retval;
272 * Adjust the min value of the value range that
273 * the peak meter shall visualize.
275 static bool peak_meter_min(void) {
276 bool retval = false;
277 if (global_settings.peak_meter_dbfs) {
279 /* for dBfs scale */
280 int range_max = -global_settings.peak_meter_max;
281 int min = -global_settings.peak_meter_min;
283 retval = set_int(str(LANG_PM_MIN), str(LANG_PM_DBFS),
284 &min, NULL, 1, -89, range_max);
286 global_settings.peak_meter_min = - min;
289 /* for linear scale */
290 else {
291 int min = global_settings.peak_meter_min;
293 retval = set_int(str(LANG_PM_MIN), "%",
294 &min, NULL,
295 1, 0, global_settings.peak_meter_max - 1);
297 global_settings.peak_meter_min = (unsigned char)min;
300 settings_apply_pm_range();
301 return retval;
306 * Adjust the max value of the value range that
307 * the peak meter shall visualize.
309 static bool peak_meter_max(void) {
310 bool retval = false;
311 if (global_settings.peak_meter_dbfs) {
313 /* for dBfs scale */
314 int range_min = -global_settings.peak_meter_min;
315 int max = -global_settings.peak_meter_max;;
317 retval = set_int(str(LANG_PM_MAX), str(LANG_PM_DBFS),
318 &max, NULL, 1, range_min, 0);
320 global_settings.peak_meter_max = - max;
324 /* for linear scale */
325 else {
326 int max = global_settings.peak_meter_max;
328 retval = set_int(str(LANG_PM_MAX), "%",
329 &max, NULL,
330 1, global_settings.peak_meter_min + 1, 100);
332 global_settings.peak_meter_max = (unsigned char)max;
335 settings_apply_pm_range();
336 return retval;
340 * Menu to select wether the meter is in
341 * precision or in energy saver mode
343 static bool peak_meter_performance(void) {
344 bool retval = false;
345 retval = set_bool_options(str(LANG_PM_PERFORMANCE),
346 &global_settings.peak_meter_performance,
347 str(LANG_PM_HIGH_PERFORMANCE), str(LANG_PM_ENERGY_SAVER),
348 NULL);
350 if (global_settings.peak_meter_performance) {
351 peak_meter_fps = 25;
352 } else {
353 peak_meter_fps = 20;
355 return retval;
359 * Menu to configure the peak meter
361 static bool peak_meter_menu(void)
363 int m;
364 bool result;
366 struct menu_items items[] = {
367 { str(LANG_PM_RELEASE) , peak_meter_release },
368 { str(LANG_PM_PEAK_HOLD), peak_meter_hold },
369 { str(LANG_PM_CLIP_HOLD), peak_meter_clip_hold },
370 { str(LANG_PM_PERFORMANCE), peak_meter_performance },
371 #ifdef PM_DEBUG
372 { "Refresh rate" , peak_meter_fps_menu },
373 #endif
374 { str(LANG_PM_SCALE) , peak_meter_scale },
375 { str(LANG_PM_MIN) , peak_meter_min },
376 { str(LANG_PM_MAX) , peak_meter_max },
379 m=menu_init( items, sizeof(items) / sizeof(*items) );
380 result = menu_run(m);
381 menu_exit(m);
382 return result;
384 #endif /* HAVE_LCD_BITMAP */
386 static bool shuffle(void)
388 return set_bool( str(LANG_SHUFFLE), &global_settings.playlist_shuffle );
391 static bool repeat_mode(void)
393 bool result;
394 char* names[] = { str(LANG_OFF),
395 str(LANG_REPEAT_ALL),
396 str(LANG_REPEAT_ONE) };
398 int old_repeat = global_settings.repeat_mode;
400 result = set_option( str(LANG_REPEAT), &global_settings.repeat_mode,
401 INT, names, 3, NULL );
403 if (old_repeat != global_settings.repeat_mode)
404 mpeg_flush_and_reload_tracks();
406 return result;
409 static bool play_selected(void)
411 return set_bool( str(LANG_PLAY_SELECTED), &global_settings.play_selected );
414 static bool dir_filter(void)
416 char* names[] = { str(LANG_FILTER_ALL),
417 str(LANG_FILTER_SUPPORTED),
418 str(LANG_FILTER_MUSIC),
419 str(LANG_FILTER_PLAYLIST) };
421 return set_option( str(LANG_FILTER), &global_settings.dirfilter, INT,
422 names, 4, NULL );
425 static bool sort_case(void)
427 return set_bool( str(LANG_SORT_CASE), &global_settings.sort_case );
430 static bool resume(void)
432 char* names[] = { str(LANG_SET_BOOL_NO),
433 str(LANG_RESUME_SETTING_ASK),
434 str(LANG_RESUME_SETTING_ASK_ONCE),
435 str(LANG_SET_BOOL_YES) };
437 return set_option( str(LANG_RESUME), &global_settings.resume, INT,
438 names, 4, NULL );
441 static bool autocreatebookmark(void)
443 char* names[] = { str(LANG_SET_BOOL_NO),
444 str(LANG_SET_BOOL_YES),
445 str(LANG_RESUME_SETTING_ASK),
446 str(LANG_BOOKMARK_SETTINGS_RECENT_ONLY_YES),
447 str(LANG_BOOKMARK_SETTINGS_RECENT_ONLY_ASK) };
449 return set_option( str(LANG_BOOKMARK_SETTINGS_AUTOCREATE),
450 &global_settings.autocreatebookmark, INT,
451 names, 5, NULL );
454 static bool autoloadbookmark(void)
456 char* names[] = { str(LANG_SET_BOOL_NO),
457 str(LANG_SET_BOOL_YES),
458 str(LANG_RESUME_SETTING_ASK) };
460 return set_option( str(LANG_BOOKMARK_SETTINGS_AUTOLOAD),
461 &global_settings.autoloadbookmark, INT,
462 names, 3, NULL );
465 static bool useMRB(void)
467 char* names[] = { str(LANG_SET_BOOL_NO),
468 str(LANG_SET_BOOL_YES),
469 str(LANG_BOOKMARK_SETTINGS_UNIQUE_ONLY)};
471 return set_option( str(LANG_BOOKMARK_SETTINGS_MAINTAIN_RECENT_BOOKMARKS),
472 &global_settings.usemrb, INT,
473 names, 3, NULL );
475 static bool backlight_on_when_charging(void)
477 bool result = set_bool(str(LANG_BACKLIGHT_ON_WHEN_CHARGING),
478 &global_settings.backlight_on_when_charging);
479 backlight_set_on_when_charging(global_settings.backlight_on_when_charging);
480 return result;
483 static bool backlight_timer(void)
485 char* names[] = { str(LANG_OFF), str(LANG_ON),
486 "1s ", "2s ", "3s ", "4s ", "5s ",
487 "6s ", "7s ", "8s ", "9s ", "10s",
488 "15s", "20s", "25s", "30s", "45s",
489 "60s", "90s"};
491 return set_option(str(LANG_BACKLIGHT), &global_settings.backlight_timeout,
492 INT, names, 19, backlight_set_timeout );
495 static bool poweroff_idle_timer(void)
497 char* names[] = { str(LANG_OFF),
498 "1m ", "2m ", "3m ", "4m ", "5m ",
499 "6m ", "7m ", "8m ", "9m ", "10m",
500 "15m", "30m", "45m", "60m"};
502 return set_option(str(LANG_POWEROFF_IDLE), &global_settings.poweroff,
503 INT, names, 15, set_poweroff_timeout);
506 static bool scroll_speed(void)
508 return set_int(str(LANG_SCROLL), "Hz", &global_settings.scroll_speed,
509 &lcd_scroll_speed, 1, 1, 10 );
513 static bool scroll_delay(void)
515 int dummy = global_settings.scroll_delay * (HZ/10);
516 int rc = set_int(str(LANG_SCROLL_DELAY), "ms", &dummy,
517 &lcd_scroll_delay, 100, 0, 2500 );
518 global_settings.scroll_delay = dummy / (HZ/10);
519 return rc;
522 #ifdef HAVE_LCD_BITMAP
523 static bool scroll_step(void)
525 return set_int(str(LANG_SCROLL_STEP_EXAMPLE), "pixels",
526 &global_settings.scroll_step,
527 &lcd_scroll_step, 1, 1, LCD_WIDTH );
529 #endif
531 static bool bidir_limit(void)
533 return set_int(str(LANG_BIDIR_SCROLL), "%", &global_settings.bidir_limit,
534 &lcd_bidir_scroll, 25, 0, 200 );
537 #ifdef HAVE_LCD_CHARCELLS
538 static bool jump_scroll(void)
540 char* names[] = { str(LANG_OFF), str(LANG_ONE_TIME), "2",
541 "3", "4", str(LANG_ALWAYS)};
542 bool ret;
543 ret=set_option(str(LANG_JUMP_SCROLL), &global_settings.jump_scroll,
544 INT, names, 6, lcd_jump_scroll);
545 return ret;
547 static bool jump_scroll_delay(void)
549 int dummy = global_settings.jump_scroll_delay * (HZ/10);
550 int rc = set_int(str(LANG_JUMP_SCROLL_DELAY), "ms", &dummy,
551 &lcd_jump_scroll_delay, 100, 0, 2500 );
552 global_settings.jump_scroll_delay = dummy / (HZ/10);
553 return rc;
555 #endif
557 #ifndef SIMULATOR
559 * Menu to set the battery capacity
561 static bool battery_capacity(void)
563 return set_int(str(LANG_BATTERY_CAPACITY), "mAh", &global_settings.battery_capacity,
564 &set_battery_capacity, 50, 1500, BATTERY_CAPACITY_MAX );
566 #endif
568 #ifdef HAVE_CHARGE_CTRL
569 static bool deep_discharge(void)
571 bool result;
572 result = set_bool( str(LANG_DISCHARGE), &global_settings.discharge );
573 charge_restart_level = global_settings.discharge ?
574 CHARGE_RESTART_LO : CHARGE_RESTART_HI;
575 return result;
577 static bool trickle_charge(void)
579 bool result;
580 result = set_bool( str(LANG_TRICKLE_CHARGE), &global_settings.trickle_charge );
581 enable_trickle_charge(global_settings.trickle_charge);
582 return result;
584 #endif
586 #ifdef HAVE_LCD_BITMAP
587 static bool timedate_set(void)
589 int timedate[7]; /* hour,minute,second,year,month,day,dayofweek */
590 bool result;
592 #ifdef HAVE_RTC
593 timedate[0] = rtc_read(0x03); /* hour */
594 timedate[1] = rtc_read(0x02); /* minute */
595 timedate[2] = rtc_read(0x01); /* second */
596 timedate[3] = rtc_read(0x07); /* year */
597 timedate[4] = rtc_read(0x06); /* month */
598 timedate[5] = rtc_read(0x05); /* day */
600 /* day of week not read, calculated in set_time() */
601 /* hour */
602 timedate[0] = ((timedate[0] & 0x30) >> 4) * 10 + (timedate[0] & 0x0f);
603 /* minute */
604 timedate[1] = ((timedate[1] & 0x70) >> 4) * 10 + (timedate[1] & 0x0f);
605 /* second */
606 timedate[2] = ((timedate[2] & 0x70) >> 4) * 10 + (timedate[2] & 0x0f);
607 /* year */
608 timedate[3] = ((timedate[3] & 0xf0) >> 4) * 10 + (timedate[3] & 0x0f);
609 /* month */
610 timedate[4] = ((timedate[4] & 0x10) >> 4) * 10 + (timedate[4] & 0x0f);
611 /* day */
612 timedate[5] = ((timedate[5] & 0x30) >> 4) * 10 + (timedate[5] & 0x0f);
614 /* do some range checks */
615 /* This prevents problems with time/date setting after a power loss */
616 if (timedate[0] < 0 || timedate[0] > 23 ||
617 timedate[1] < 0 || timedate[1] > 59 ||
618 timedate[2] < 0 || timedate[2] > 59 ||
619 timedate[3] < 0 || timedate[3] > 99 ||
620 timedate[4] < 1 || timedate[4] > 12 ||
621 timedate[5] < 1 || timedate[5] > 31)
623 /* hour */
624 timedate[0] = 0;
625 /* minute */
626 timedate[1] = 0;
627 /* second */
628 timedate[2] = 0;
629 /* year */
630 timedate[3] = 3;
631 /* month */
632 timedate[4] = 1;
633 /* day */
634 timedate[5] = 1;
636 #endif
638 result = set_time(str(LANG_TIME),timedate);
640 #ifdef HAVE_RTC
641 if(timedate[0] != -1) {
642 /* hour */
643 timedate[0] = ((timedate[0]/10) << 4 | timedate[0]%10) & 0x3f;
644 /* minute */
645 timedate[1] = ((timedate[1]/10) << 4 | timedate[1]%10) & 0x7f;
646 /* second */
647 timedate[2] = ((timedate[2]/10) << 4 | timedate[2]%10) & 0x7f;
648 /* year */
649 timedate[3] = ((timedate[3]/10) << 4 | timedate[3]%10) & 0xff;
650 /* month */
651 timedate[4] = ((timedate[4]/10) << 4 | timedate[4]%10) & 0x1f;
652 /* day */
653 timedate[5] = ((timedate[5]/10) << 4 | timedate[5]%10) & 0x3f;
655 rtc_write(0x03, timedate[0] | (rtc_read(0x03) & 0xc0)); /* hour */
656 rtc_write(0x02, timedate[1] | (rtc_read(0x02) & 0x80)); /* minute */
657 rtc_write(0x01, timedate[2] | (rtc_read(0x01) & 0x80)); /* second */
658 rtc_write(0x07, timedate[3]); /* year */
659 rtc_write(0x06, timedate[4] | (rtc_read(0x06) & 0xe0)); /* month */
660 rtc_write(0x05, timedate[5] | (rtc_read(0x05) & 0xc0)); /* day */
661 rtc_write(0x04, timedate[6] | (rtc_read(0x04) & 0xf8)); /* dayofweek */
662 rtc_write(0x00, 0x00); /* 0.1 + 0.01 seconds */
664 #endif
665 return result;
668 static bool timeformat_set(void)
670 char* names[] = { str(LANG_24_HOUR_CLOCK),
671 str(LANG_12_HOUR_CLOCK) };
673 return set_option(str(LANG_TIMEFORMAT), &global_settings.timeformat,
674 INT, names, 2, NULL);
676 #endif
678 static bool spindown(void)
680 return set_int(str(LANG_SPINDOWN), "s", &global_settings.disk_spindown,
681 ata_spindown, 1, 3, 254 );
684 #ifdef HAVE_MAS3507D
685 static bool line_in(void)
687 bool rc = set_bool(str(LANG_LINE_IN), &global_settings.line_in);
688 dac_line_in(global_settings.line_in);
689 return rc;
691 #endif
693 #ifdef HAVE_ATA_POWER_OFF
694 static bool poweroff(void)
696 bool rc = set_bool(str(LANG_POWEROFF), &global_settings.disk_poweroff);
697 ata_poweroff(global_settings.disk_poweroff);
698 return rc;
700 #endif
702 static bool max_files_in_dir(void)
704 return set_int(str(LANG_MAX_FILES_IN_DIR), "",
705 &global_settings.max_files_in_dir,
706 NULL, 50, 50, 10000 );
709 static bool max_files_in_playlist(void)
711 return set_int(str(LANG_MAX_FILES_IN_PLAYLIST), "",
712 &global_settings.max_files_in_playlist,
713 NULL, 1000, 1000, 20000 );
716 static bool buffer_margin(void)
718 return set_int(str(LANG_MP3BUFFER_MARGIN), "s",
719 &global_settings.buffer_margin,
720 mpeg_set_buffer_margin, 1, 0, 7 );
723 static bool ff_rewind_min_step(void)
725 char* names[] = { "1s", "2s", "3s", "4s",
726 "5s", "6s", "8s", "10s",
727 "15s", "20s", "25s", "30s",
728 "45s", "60s" };
730 return set_option(str(LANG_FFRW_STEP), &global_settings.ff_rewind_min_step,
731 INT, names, 14, NULL );
734 static bool set_fade_on_stop(void)
736 return set_bool( str(LANG_FADE_ON_STOP), &global_settings.fade_on_stop );
740 static bool ff_rewind_accel(void)
742 char* names[] = { str(LANG_OFF), "2x/1s", "2x/2s", "2x/3s",
743 "2x/4s", "2x/5s", "2x/6s", "2x/7s",
744 "2x/8s", "2x/9s", "2x/10s", "2x/11s",
745 "2x/12s", "2x/13s", "2x/14s", "2x/15s", };
747 return set_option(str(LANG_FFRW_ACCEL), &global_settings.ff_rewind_accel,
748 INT, names, 16, NULL );
751 static bool browse_current(void)
753 return set_bool( str(LANG_FOLLOW), &global_settings.browse_current );
756 static bool custom_wps_browse(void)
758 return rockbox_browse(ROCKBOX_DIR, SHOW_WPS);
761 static bool custom_cfg_browse(void)
763 return rockbox_browse(ROCKBOX_DIR, SHOW_CFG);
766 static bool language_browse(void)
768 return rockbox_browse(ROCKBOX_DIR LANG_DIR, SHOW_LNG);
771 #ifdef HAVE_RECORDER_KEYPAD
772 static bool font_browse(void)
774 return rockbox_browse(ROCKBOX_DIR FONT_DIR, SHOW_FONT);
776 #endif
778 #ifdef HAVE_LCD_BITMAP
779 static bool scroll_bar(void)
781 return set_bool( str(LANG_SCROLL_BAR), &global_settings.scrollbar );
784 static bool status_bar(void)
786 return set_bool( str(LANG_STATUS_BAR), &global_settings.statusbar );
788 #endif
790 static bool playback_settings_menu(void)
792 int m;
793 bool result;
795 struct menu_items items[] = {
796 { str(LANG_SHUFFLE), shuffle },
797 { str(LANG_REPEAT), repeat_mode },
798 { str(LANG_PLAY_SELECTED), play_selected },
799 { str(LANG_RESUME), resume },
800 { str(LANG_FFRW_STEP), ff_rewind_min_step },
801 { str(LANG_FFRW_ACCEL), ff_rewind_accel },
802 { str(LANG_MP3BUFFER_MARGIN), buffer_margin },
803 { str(LANG_FADE_ON_STOP), set_fade_on_stop },
806 bool old_shuffle = global_settings.playlist_shuffle;
808 m=menu_init( items, sizeof(items) / sizeof(*items) );
809 result = menu_run(m);
810 menu_exit(m);
812 if (old_shuffle != global_settings.playlist_shuffle)
814 if (global_settings.playlist_shuffle)
816 playlist_randomise(current_tick, true);
818 else
820 playlist_sort(true);
823 return result;
826 static bool bookmark_settings_menu(void)
828 int m;
829 bool result;
831 struct menu_items items[] = {
832 { str(LANG_BOOKMARK_SETTINGS_AUTOCREATE), autocreatebookmark},
833 { str(LANG_BOOKMARK_SETTINGS_AUTOLOAD), autoloadbookmark},
834 { str(LANG_BOOKMARK_SETTINGS_MAINTAIN_RECENT_BOOKMARKS), useMRB},
837 m=menu_init( items, sizeof items / sizeof(struct menu_items) );
838 result = menu_run(m);
839 menu_exit(m);
841 return result;
843 static bool reset_settings(void)
845 bool done=false;
846 int line;
848 lcd_clear_display();
850 #ifdef HAVE_LCD_CHARCELLS
851 line = 0;
852 #else
853 line = 1;
854 lcd_puts(0,0,str(LANG_RESET_ASK_RECORDER));
855 #endif
856 lcd_puts(0,line,str(LANG_RESET_CONFIRM));
857 lcd_puts(0,line+1,str(LANG_RESET_CANCEL));
859 lcd_update();
861 while(!done) {
862 switch(button_get(true)) {
863 case BUTTON_PLAY:
864 settings_reset();
865 settings_apply();
866 lcd_clear_display();
867 lcd_puts(0,1,str(LANG_RESET_DONE_CLEAR));
868 done = true;
869 break;
871 #ifdef HAVE_LCD_BITMAP
872 case BUTTON_OFF:
873 #else
874 case BUTTON_STOP:
875 #endif
876 lcd_clear_display();
877 lcd_puts(0,1,str(LANG_RESET_DONE_CANCEL));
878 done = true;
879 break;
881 case SYS_USB_CONNECTED:
882 usb_screen();
883 return true;
887 lcd_puts(0,0,str(LANG_RESET_DONE_SETTING));
888 lcd_update();
889 sleep(HZ);
890 return false;
893 static bool fileview_settings_menu(void)
895 int m;
896 bool result;
898 struct menu_items items[] = {
899 { str(LANG_CASE_MENU), sort_case },
900 { str(LANG_FILTER), dir_filter },
901 { str(LANG_FOLLOW), browse_current },
904 m=menu_init( items, sizeof(items) / sizeof(*items) );
905 result = menu_run(m);
906 menu_exit(m);
907 return result;
911 static bool scroll_settings_menu(void)
913 int m;
914 bool result;
916 struct menu_items items[] = {
917 { str(LANG_SCROLL_SPEED), scroll_speed },
918 { str(LANG_SCROLL_DELAY), scroll_delay },
919 #ifdef HAVE_LCD_BITMAP
920 { str(LANG_SCROLL_STEP), scroll_step },
921 #endif
922 { str(LANG_BIDIR_SCROLL), bidir_limit },
923 #ifdef HAVE_LCD_CHARCELLS
924 { str(LANG_JUMP_SCROLL), jump_scroll },
925 { str(LANG_JUMP_SCROLL_DELAY), jump_scroll_delay },
926 #endif
929 m=menu_init( items, sizeof(items) / sizeof(*items) );
930 result = menu_run(m);
931 menu_exit(m);
932 return result;
937 static bool display_settings_menu(void)
939 int m;
940 bool result;
942 struct menu_items items[] = {
943 { str(LANG_SCROLL_MENU), scroll_settings_menu },
944 { str(LANG_BACKLIGHT), backlight_timer },
945 { str(LANG_BACKLIGHT_ON_WHEN_CHARGING), backlight_on_when_charging },
946 { str(LANG_CONTRAST), contrast },
947 #ifdef HAVE_LCD_BITMAP
948 { str(LANG_SCROLL_BAR), scroll_bar },
949 { str(LANG_STATUS_BAR), status_bar },
950 { str(LANG_INVERT), invert },
951 { str(LANG_INVERT_CURSOR), invert_cursor },
952 { str(LANG_FLIP_DISPLAY), flip_display },
953 { str(LANG_PM_MENU), peak_meter_menu },
954 { str(LANG_VOLUME_DISPLAY), volume_type },
955 { str(LANG_BATTERY_DISPLAY), battery_type },
956 #endif
957 { str(LANG_SHOW_ICONS), show_icons },
958 { str(LANG_CAPTION_BACKLIGHT), caption_backlight },
961 m=menu_init( items, sizeof(items) / sizeof(*items) );
962 result = menu_run(m);
963 menu_exit(m);
964 return result;
967 static bool system_settings_menu(void)
969 int m;
970 bool result;
972 struct menu_items items[] = {
973 { str(LANG_SPINDOWN), spindown },
974 #ifdef HAVE_MAS3507D
975 { str(LANG_LINE_IN), line_in },
976 #endif
977 #ifdef HAVE_ATA_POWER_OFF
978 { str(LANG_POWEROFF), poweroff },
979 #endif
980 { str(LANG_MAX_FILES_IN_DIR), max_files_in_dir },
981 { str(LANG_MAX_FILES_IN_PLAYLIST), max_files_in_playlist },
982 #ifndef SIMULATOR
983 { str(LANG_BATTERY_CAPACITY), battery_capacity },
984 #endif
985 #ifdef HAVE_CHARGE_CTRL
986 { str(LANG_DISCHARGE), deep_discharge },
987 { str(LANG_TRICKLE_CHARGE), trickle_charge },
988 #endif
989 #ifdef HAVE_LCD_BITMAP
990 { str(LANG_TIME), timedate_set },
991 { str(LANG_TIMEFORMAT), timeformat_set },
992 #endif
993 { str(LANG_POWEROFF_IDLE), poweroff_idle_timer },
994 { str(LANG_CAR_ADAPTER_MODE), car_adapter_mode },
995 { str(LANG_RESET), reset_settings },
998 m=menu_init( items, sizeof(items) / sizeof(*items) );
999 result = menu_run(m);
1000 menu_exit(m);
1001 return result;
1004 bool settings_menu(void)
1006 int m;
1007 bool result;
1009 struct menu_items items[] = {
1010 { str(LANG_PLAYBACK), playback_settings_menu },
1011 { str(LANG_CUSTOM_CFG), custom_cfg_browse },
1012 { str(LANG_WHILE_PLAYING), custom_wps_browse },
1013 { str(LANG_LANGUAGE), language_browse },
1014 { str(LANG_FILE), fileview_settings_menu },
1015 { str(LANG_DISPLAY), display_settings_menu },
1016 #ifdef HAVE_RECORDER_KEYPAD
1017 { str(LANG_CUSTOM_FONT), font_browse },
1018 #endif
1019 { str(LANG_SYSTEM), system_settings_menu },
1020 { str(LANG_BOOKMARK_SETTINGS),bookmark_settings_menu },
1021 { str(LANG_SAVE_SETTINGS), settings_save_config },
1024 m=menu_init( items, sizeof(items) / sizeof(*items) );
1025 result = menu_run(m);
1026 menu_exit(m);
1027 return result;