blob: 90ad191d1cd009983a1b84152e4b95353aed459f [file] [log] [blame]
Robert Hak84a6ba22002-06-24 21:39:48 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 Robert Hak
11 *
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.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "config.h"
21
22#include <stdio.h>
23#include <stdbool.h>
Linus Nielsen Feltzing7ddf0d62004-04-20 10:23:57 +000024#include <string.h>
Justin Heinerb5025a82002-08-31 04:58:35 +000025
Robert Hak84a6ba22002-06-24 21:39:48 +000026#include "lcd.h"
27#include "menu.h"
28#include "mpeg.h"
Linus Nielsen Feltzing8a237a82005-04-04 12:06:29 +000029#include "audio.h"
Robert Hak84a6ba22002-06-24 21:39:48 +000030#include "button.h"
31#include "kernel.h"
Björn Stenbergc4d8d972003-02-14 09:44:34 +000032#include "thread.h"
Robert Hak84a6ba22002-06-24 21:39:48 +000033#include "sprintf.h"
Robert Hak84a6ba22002-06-24 21:39:48 +000034#include "settings.h"
35#include "settings_menu.h"
36#include "backlight.h"
Robert Hakea8a4cf2002-10-14 09:12:52 +000037#include "playlist.h" /* for playlist_shuffle */
Daniel Stenberg053d9042002-08-22 15:47:30 +000038#include "fat.h" /* For dotfile settings */
Björn Stenbergfe375a02004-01-14 14:42:31 +000039#include "sleeptimer.h"
Heikki Hannikainen6eb42542002-08-06 10:52:51 +000040#include "powermgmt.h"
Markus Braun3181f682002-08-09 12:38:45 +000041#include "rtc.h"
Björn Stenberg457b8a02002-08-26 13:21:14 +000042#include "ata.h"
Björn Stenbergde5477c2003-09-29 21:26:53 +000043#include "tree.h"
Robert Hak8f4c5042002-10-14 11:55:20 +000044#include "screens.h"
Jörg Hohensohnfa97f162004-03-19 22:15:53 +000045#include "talk.h"
Linus Nielsen Feltzing7ddf0d62004-04-20 10:23:57 +000046#include "timefuncs.h"
Linus Nielsen Feltzingade5d7b2004-07-26 16:06:59 +000047#include "misc.h"
Linus Nielsen Feltzing8782bc82005-07-01 09:42:39 +000048#include "power.h"
Jens Arnold8102f3d2005-07-02 10:50:42 +000049#include "database.h"
Linus Nielsen Feltzing8782bc82005-07-01 09:42:39 +000050
Daniel Stenbergf7c3ffa2002-09-27 10:18:48 +000051#ifdef HAVE_LCD_BITMAP
Linus Nielsen Feltzingbb572c42002-09-27 09:31:31 +000052#include "peakmeter.h"
Daniel Stenbergf7c3ffa2002-09-27 10:18:48 +000053#endif
Björn Stenberg505eca72002-09-18 14:08:05 +000054#include "lang.h"
Jörg Hohensohn593cc002004-09-28 22:13:26 +000055#if CONFIG_HWCODEC == MAS3507D
Linus Nielsen Feltzing54a7e202003-11-04 00:18:19 +000056void dac_line_in(bool enable);
Linus Nielsen Feltzingc22b4112003-11-03 23:36:36 +000057#endif
Björn Stenbergfe375a02004-01-14 14:42:31 +000058#ifdef HAVE_ALARM_MOD
59#include "alarm_menu.h"
60#endif
Robert Hak84a6ba22002-06-24 21:39:48 +000061
Christian Gmeiner7c1879b2005-04-15 12:08:49 +000062#ifdef HAVE_REMOTE_LCD
63#include "lcd-remote.h"
64#endif
65
Linus Nielsen Feltzing6271b2b2005-06-09 09:47:00 +000066#if CONFIG_HWCODEC == MASNONE
Miika Pekkarinen20b38972005-07-13 12:48:22 +000067#include "pcmbuf.h"
Linus Nielsen Feltzing6271b2b2005-06-09 09:47:00 +000068#include "pcm_playback.h"
69#endif
70
Jens Arnoldccfa4cd2004-10-10 01:25:32 +000071#ifdef HAVE_CHARGING
Björn Stenbergb1c429e2003-10-17 14:49:00 +000072static bool car_adapter_mode(void)
73{
74 return set_bool_options( str(LANG_CAR_ADAPTER_MODE),
75 &global_settings.car_adapter_mode,
Jörg Hohensohn42ffbf92004-03-15 08:27:51 +000076 STR(LANG_SET_BOOL_YES),
77 STR(LANG_SET_BOOL_NO),
Linus Nielsen Feltzing3d217812005-04-06 11:12:22 +000078 NULL);
Björn Stenbergb1c429e2003-10-17 14:49:00 +000079}
Jens Arnoldccfa4cd2004-10-10 01:25:32 +000080#endif
Björn Stenbergb1c429e2003-10-17 14:49:00 +000081
Jens Arnold61b9d342005-06-20 17:03:09 +000082/**
83 * Menu to set icon visibility
84 */
85static bool show_icons(void)
Linus Nielsen Feltzing638184f2002-08-13 11:10:11 +000086{
Jens Arnold61b9d342005-06-20 17:03:09 +000087 return set_bool( str(LANG_SHOW_ICONS), &global_settings.show_icons );
Linus Nielsen Feltzing638184f2002-08-13 11:10:11 +000088}
89
Christian Gmeiner7c1879b2005-04-15 12:08:49 +000090#ifdef HAVE_REMOTE_LCD
91static bool remote_contrast(void)
92{
93 return set_int( str(LANG_CONTRAST), "", UNIT_INT,
94 &global_settings.remote_contrast,
95 lcd_remote_set_contrast, 1, MIN_CONTRAST_SETTING,
96 MAX_CONTRAST_SETTING );
97}
98
99static bool remote_invert(void)
100{
101 bool rc = set_bool_options(str(LANG_INVERT),
102 &global_settings.remote_invert,
103 STR(LANG_INVERT_LCD_INVERSE),
104 STR(LANG_INVERT_LCD_NORMAL),
105 lcd_remote_set_invert_display);
106 return rc;
107}
Jens Arnoldbd1bb5f2005-06-17 21:43:00 +0000108
109static bool remote_flip_display(void)
110{
111 bool rc = set_bool( str(LANG_FLIP_DISPLAY),
112 &global_settings.remote_flip_display);
113
114 lcd_remote_set_flip(global_settings.remote_flip_display);
115 lcd_remote_update();
116
117 return rc;
118}
Christian Gmeiner7c1879b2005-04-15 12:08:49 +0000119#endif
120
Jörg Hohensohnfee86172004-12-18 10:29:47 +0000121#ifdef CONFIG_BACKLIGHT
Björn Stenberg8d4471d2003-04-24 08:27:11 +0000122static bool caption_backlight(void)
123{
124 bool rc = set_bool( str(LANG_CAPTION_BACKLIGHT),
125 &global_settings.caption_backlight);
126
127 return rc;
128}
Jens Arnold61b9d342005-06-20 17:03:09 +0000129
130#ifdef HAVE_CHARGING
131static bool backlight_on_when_charging(void)
132{
133 bool result = set_bool(str(LANG_BACKLIGHT_ON_WHEN_CHARGING),
134 &global_settings.backlight_on_when_charging);
135 backlight_set_on_when_charging(global_settings.backlight_on_when_charging);
136 return result;
137}
Jens Arnolda1a08d02004-10-09 19:56:27 +0000138#endif
Björn Stenberg8d4471d2003-04-24 08:27:11 +0000139
Jens Arnold61b9d342005-06-20 17:03:09 +0000140static bool backlight_timer(void)
Björn Stenbergd1a6fa12003-06-05 09:38:26 +0000141{
Jens Arnold61b9d342005-06-20 17:03:09 +0000142 static const struct opt_items names[] = {
143 { STR(LANG_OFF) },
144 { STR(LANG_ON) },
145 { "1s ", TALK_ID(1, UNIT_SEC) },
146 { "2s ", TALK_ID(2, UNIT_SEC) },
147 { "3s ", TALK_ID(3, UNIT_SEC) },
148 { "4s ", TALK_ID(4, UNIT_SEC) },
149 { "5s ", TALK_ID(5, UNIT_SEC) },
150 { "6s ", TALK_ID(6, UNIT_SEC) },
151 { "7s ", TALK_ID(7, UNIT_SEC) },
152 { "8s ", TALK_ID(8, UNIT_SEC) },
153 { "9s ", TALK_ID(9, UNIT_SEC) },
154 { "10s", TALK_ID(10, UNIT_SEC) },
155 { "15s", TALK_ID(15, UNIT_SEC) },
156 { "20s", TALK_ID(20, UNIT_SEC) },
157 { "25s", TALK_ID(25, UNIT_SEC) },
158 { "30s", TALK_ID(30, UNIT_SEC) },
159 { "45s", TALK_ID(45, UNIT_SEC) },
160 { "60s", TALK_ID(60, UNIT_SEC) },
161 { "90s", TALK_ID(90, UNIT_SEC) }
162 };
163 return set_option(str(LANG_BACKLIGHT), &global_settings.backlight_timeout,
164 INT, names, 19, backlight_set_timeout );
165}
166
167#if CONFIG_BACKLIGHT == BL_IRIVER
168static bool backlight_fade_in(void)
169{
170 static const struct opt_items names[] = {
171 { STR(LANG_OFF) },
172 { "500ms", TALK_ID(500, UNIT_MS) },
173 { "1s", TALK_ID(1, UNIT_SEC) },
174 { "2s", TALK_ID(2, UNIT_SEC) },
175 };
176 return set_option(str(LANG_BACKLIGHT_FADE_IN),
177 &global_settings.backlight_fade_in,
178 INT, names, 4, backlight_set_fade_in );
179}
180
181static bool backlight_fade_out(void)
182{
183 static const struct opt_items names[] = {
184 { STR(LANG_OFF) },
185 { "500ms", TALK_ID(500, UNIT_MS) },
186 { "1s", TALK_ID(1, UNIT_SEC) },
187 { "2s", TALK_ID(2, UNIT_SEC) },
188 { "3s", TALK_ID(3, UNIT_SEC) },
189 { "4s", TALK_ID(4, UNIT_SEC) },
190 { "5s", TALK_ID(5, UNIT_SEC) },
191 { "10s", TALK_ID(10, UNIT_SEC) },
192 };
193 return set_option(str(LANG_BACKLIGHT_FADE_OUT),
194 &global_settings.backlight_fade_out,
195 INT, names, 8, backlight_set_fade_out );
196}
197#endif
198#endif /* CONFIG_BACKLIGHT */
199
200#ifdef HAVE_REMOTE_LCD
201
202static bool remote_backlight_timer(void)
203{
204 static const struct opt_items names[] = {
205 { STR(LANG_OFF) },
206 { STR(LANG_ON) },
207 { "1s ", TALK_ID(1, UNIT_SEC) },
208 { "2s ", TALK_ID(2, UNIT_SEC) },
209 { "3s ", TALK_ID(3, UNIT_SEC) },
210 { "4s ", TALK_ID(4, UNIT_SEC) },
211 { "5s ", TALK_ID(5, UNIT_SEC) },
212 { "6s ", TALK_ID(6, UNIT_SEC) },
213 { "7s ", TALK_ID(7, UNIT_SEC) },
214 { "8s ", TALK_ID(8, UNIT_SEC) },
215 { "9s ", TALK_ID(9, UNIT_SEC) },
216 { "10s", TALK_ID(10, UNIT_SEC) },
217 { "15s", TALK_ID(15, UNIT_SEC) },
218 { "20s", TALK_ID(20, UNIT_SEC) },
219 { "25s", TALK_ID(25, UNIT_SEC) },
220 { "30s", TALK_ID(30, UNIT_SEC) },
221 { "45s", TALK_ID(45, UNIT_SEC) },
222 { "60s", TALK_ID(60, UNIT_SEC) },
223 { "90s", TALK_ID(90, UNIT_SEC) }
224 };
225 return set_option(str(LANG_BACKLIGHT), &global_settings.remote_backlight_timeout,
226 INT, names, 19, remote_backlight_set_timeout );
227}
228
229#endif /* HAVE_REMOTE_LCD */
230
231static bool contrast(void)
232{
233 return set_int( str(LANG_CONTRAST), "", UNIT_INT,
234 &global_settings.contrast,
235 lcd_set_contrast, 1, MIN_CONTRAST_SETTING,
236 MAX_CONTRAST_SETTING );
Björn Stenbergd1a6fa12003-06-05 09:38:26 +0000237}
238
Linus Nielsen Feltzingbb572c42002-09-27 09:31:31 +0000239#ifdef HAVE_LCD_BITMAP
Robert Hakda407262002-10-26 05:46:53 +0000240
Björn Stenbergd1a6fa12003-06-05 09:38:26 +0000241 /**
242 * Menu to set LCD Mode (normal/inverse)
243 */
Björn Stenbergb1079202003-02-27 14:22:30 +0000244static bool invert(void)
245{
Björn Stenberg233b7f32003-04-24 13:13:16 +0000246 bool rc = set_bool_options(str(LANG_INVERT),
247 &global_settings.invert,
Jörg Hohensohn42ffbf92004-03-15 08:27:51 +0000248 STR(LANG_INVERT_LCD_INVERSE),
249 STR(LANG_INVERT_LCD_NORMAL),
Björn Stenberg26712d52003-06-05 11:11:10 +0000250 lcd_set_invert_display);
Björn Stenberg233b7f32003-04-24 13:13:16 +0000251 return rc;
Björn Stenbergb1079202003-02-27 14:22:30 +0000252}
253
Björn Stenbergd1a6fa12003-06-05 09:38:26 +0000254/**
Jens Arnold61b9d342005-06-20 17:03:09 +0000255 * Menu to turn the display+buttons by 180 degrees
256 */
257static bool flip_display(void)
258{
259 bool rc = set_bool( str(LANG_FLIP_DISPLAY),
260 &global_settings.flip_display);
261
262 button_set_flip(global_settings.flip_display);
263 lcd_set_flip(global_settings.flip_display);
264
265 return rc;
266}
267
268/**
Björn Stenbergd1a6fa12003-06-05 09:38:26 +0000269 * Menu to set Line Selector Type (Pointer/Bar)
270 */
Linus Nielsen Feltzinge43b78a2003-04-16 00:12:31 +0000271static bool invert_cursor(void)
272{
Björn Stenberg233b7f32003-04-24 13:13:16 +0000273 return set_bool_options(str(LANG_INVERT_CURSOR),
274 &global_settings.invert_cursor,
Jörg Hohensohn42ffbf92004-03-15 08:27:51 +0000275 STR(LANG_INVERT_CURSOR_BAR),
276 STR(LANG_INVERT_CURSOR_POINTER),
Björn Stenberg26712d52003-06-05 11:11:10 +0000277 NULL);
Linus Nielsen Feltzinge43b78a2003-04-16 00:12:31 +0000278}
279
Robert Hakda407262002-10-26 05:46:53 +0000280/**
281 * Menu to configure the battery display on status bar
282 */
Jens Arnold9d42e2b2005-01-30 13:48:44 +0000283static bool battery_display(void)
Robert Hakda407262002-10-26 05:46:53 +0000284{
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +0000285 static const struct opt_items names[] = {
Jörg Hohensohn42ffbf92004-03-15 08:27:51 +0000286 { STR(LANG_DISPLAY_GRAPHIC) },
287 { STR(LANG_DISPLAY_NUMERIC) }
288 };
Robert Hakda407262002-10-26 05:46:53 +0000289 return set_option( str(LANG_BATTERY_DISPLAY),
Jens Arnold9d42e2b2005-01-30 13:48:44 +0000290 &global_settings.battery_display, INT, names, 2, NULL);
Robert Hakda407262002-10-26 05:46:53 +0000291}
292
293/**
294 * Menu to configure the volume display on status bar
295 */
296static bool volume_type(void)
297{
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +0000298 static const struct opt_items names[] = {
Jörg Hohensohn42ffbf92004-03-15 08:27:51 +0000299 { STR(LANG_DISPLAY_GRAPHIC) },
300 { STR(LANG_DISPLAY_NUMERIC) }
301 };
Robert Hakda407262002-10-26 05:46:53 +0000302 return set_option( str(LANG_VOLUME_DISPLAY), &global_settings.volume_type,
Björn Stenberg26712d52003-06-05 11:11:10 +0000303 INT, names, 2, NULL);
Robert Hakda407262002-10-26 05:46:53 +0000304}
305
Linus Nielsen Feltzingfd0cc3b2002-10-29 12:09:15 +0000306#ifdef PM_DEBUG
307static bool peak_meter_fps_menu(void) {
308 bool retval = false;
Jörg Hohensohnbeec2e92004-03-20 16:49:58 +0000309 retval = set_int( "Refresh rate", "/s", UNIT_PER_SEC,
Linus Nielsen Feltzingfd0cc3b2002-10-29 12:09:15 +0000310 &peak_meter_fps,
311 NULL, 1, 5, 40);
312 return retval;
313}
314#endif /* PM_DEBUG */
315
Linus Nielsen Feltzingbb572c42002-09-27 09:31:31 +0000316/**
317 * Menu to set the hold time of normal peaks.
318 */
Linus Nielsen Feltzingfd0cc3b2002-10-29 12:09:15 +0000319static bool peak_meter_hold(void) {
320 bool retval = false;
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +0000321 static const struct opt_items names[] = {
Jörg Hohensohn42ffbf92004-03-15 08:27:51 +0000322 { STR(LANG_OFF) },
Jörg Hohensohnfa97f162004-03-19 22:15:53 +0000323 { "200 ms " , TALK_ID(200, UNIT_MS) },
324 { "300 ms " , TALK_ID(300, UNIT_MS) },
325 { "500 ms " , TALK_ID(500, UNIT_MS) },
326 { "1 s" , TALK_ID(1, UNIT_SEC) },
327 { "2 s" , TALK_ID(2, UNIT_SEC) },
328 { "3 s" , TALK_ID(3, UNIT_SEC) },
329 { "4 s" , TALK_ID(4, UNIT_SEC) },
330 { "5 s" , TALK_ID(5, UNIT_SEC) },
331 { "6 s" , TALK_ID(6, UNIT_SEC) },
332 { "7 s" , TALK_ID(7, UNIT_SEC) },
333 { "8 s" , TALK_ID(8, UNIT_SEC) },
334 { "9 s" , TALK_ID(9, UNIT_SEC) },
335 { "10 s" , TALK_ID(10, UNIT_SEC) },
336 { "15 s" , TALK_ID(15, UNIT_SEC) },
337 { "20 s" , TALK_ID(20, UNIT_SEC) },
338 { "30 s" , TALK_ID(30, UNIT_SEC) },
339 { "1 min" , TALK_ID(1, UNIT_MIN) }
Linus Nielsen Feltzingbb572c42002-09-27 09:31:31 +0000340 };
Björn Stenberg26712d52003-06-05 11:11:10 +0000341 retval = set_option( str(LANG_PM_PEAK_HOLD),
342 &global_settings.peak_meter_hold, INT, names,
343 18, NULL);
Linus Nielsen Feltzingfd0cc3b2002-10-29 12:09:15 +0000344
345 peak_meter_init_times(global_settings.peak_meter_release,
346 global_settings.peak_meter_hold,
347 global_settings.peak_meter_clip_hold);
348
349 return retval;
Linus Nielsen Feltzingbb572c42002-09-27 09:31:31 +0000350}
351
352/**
353 * Menu to set the hold time of clips.
354 */
Linus Nielsen Feltzingfd0cc3b2002-10-29 12:09:15 +0000355static bool peak_meter_clip_hold(void) {
356 bool retval = false;
357
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +0000358 static const struct opt_items names[] = {
Jörg Hohensohn42ffbf92004-03-15 08:27:51 +0000359 { STR(LANG_PM_ETERNAL) },
Jörg Hohensohnfa97f162004-03-19 22:15:53 +0000360 { "1s " , TALK_ID(1, UNIT_SEC) },
361 { "2s " , TALK_ID(2, UNIT_SEC) },
362 { "3s " , TALK_ID(3, UNIT_SEC) },
363 { "4s " , TALK_ID(4, UNIT_SEC) },
364 { "5s " , TALK_ID(5, UNIT_SEC) },
365 { "6s " , TALK_ID(6, UNIT_SEC) },
366 { "7s " , TALK_ID(7, UNIT_SEC) },
367 { "8s " , TALK_ID(8, UNIT_SEC) },
368 { "9s " , TALK_ID(9, UNIT_SEC) },
369 { "10s" , TALK_ID(10, UNIT_SEC) },
370 { "15s" , TALK_ID(15, UNIT_SEC) },
371 { "20s" , TALK_ID(20, UNIT_SEC) },
372 { "25s" , TALK_ID(25, UNIT_SEC) },
373 { "30s" , TALK_ID(30, UNIT_SEC) },
374 { "45s" , TALK_ID(45, UNIT_SEC) },
375 { "60s" , TALK_ID(60, UNIT_SEC) },
376 { "90s" , TALK_ID(90, UNIT_SEC) },
377 { "2min" , TALK_ID(2, UNIT_MIN) },
378 { "3min" , TALK_ID(3, UNIT_MIN) },
379 { "5min" , TALK_ID(5, UNIT_MIN) },
380 { "10min" , TALK_ID(10, UNIT_MIN) },
381 { "20min" , TALK_ID(20, UNIT_MIN) },
382 { "45min" , TALK_ID(45, UNIT_MIN) },
383 { "90min" , TALK_ID(90, UNIT_MIN) }
Linus Nielsen Feltzingbb572c42002-09-27 09:31:31 +0000384 };
Linus Nielsen Feltzingfd0cc3b2002-10-29 12:09:15 +0000385 retval = set_option( str(LANG_PM_CLIP_HOLD),
Björn Stenberg26712d52003-06-05 11:11:10 +0000386 &global_settings.peak_meter_clip_hold, INT, names,
387 25, peak_meter_set_clip_hold);
Linus Nielsen Feltzingfd0cc3b2002-10-29 12:09:15 +0000388
389 peak_meter_init_times(global_settings.peak_meter_release,
390 global_settings.peak_meter_hold,
391 global_settings.peak_meter_clip_hold);
392
393 return retval;
Linus Nielsen Feltzingbb572c42002-09-27 09:31:31 +0000394}
395
396/**
397 * Menu to set the release time of the peak meter.
398 */
Linus Nielsen Feltzingfd0cc3b2002-10-29 12:09:15 +0000399static bool peak_meter_release(void) {
400 bool retval = false;
401
402 /* The range of peak_meter_release is restricted so that it
403 fits into a 7 bit number. The 8th bit is used for storing
404 something else in the rtc ram.
405 Also, the max value is 0x7e, since the RTC value 0xff is reserved */
Jens Arnold359ef772004-11-19 01:13:33 +0000406 retval = set_int( str(LANG_PM_RELEASE), str(LANG_PM_UNITS_PER_READ),
407 LANG_PM_UNITS_PER_READ,
408 &global_settings.peak_meter_release,
409 NULL, 1, 1, 0x7e);
Linus Nielsen Feltzingfd0cc3b2002-10-29 12:09:15 +0000410
411 peak_meter_init_times(global_settings.peak_meter_release,
412 global_settings.peak_meter_hold,
413 global_settings.peak_meter_clip_hold);
414
415 return retval;
416}
417
418/**
419 * Menu to select wether the scale of the meter
420 * displays dBfs of linear values.
421 */
422static bool peak_meter_scale(void) {
423 bool retval = false;
424 bool use_dbfs = global_settings.peak_meter_dbfs;
425 retval = set_bool_options(str(LANG_PM_SCALE),
426 &use_dbfs,
Jörg Hohensohn42ffbf92004-03-15 08:27:51 +0000427 STR(LANG_PM_DBFS), STR(LANG_PM_LINEAR),
Björn Stenberg26712d52003-06-05 11:11:10 +0000428 NULL);
Linus Nielsen Feltzingfd0cc3b2002-10-29 12:09:15 +0000429
430 /* has the user really changed the scale? */
431 if (use_dbfs != global_settings.peak_meter_dbfs) {
432
433 /* store the change */
434 global_settings.peak_meter_dbfs = use_dbfs;
435 peak_meter_set_use_dbfs(use_dbfs);
436
437 /* If the user changed the scale mode the meaning of
438 peak_meter_min (peak_meter_max) has changed. Thus we have
439 to convert the values stored in global_settings. */
440 if (use_dbfs) {
441
442 /* we only store -dBfs */
443 global_settings.peak_meter_min = -peak_meter_get_min() / 100;
444 global_settings.peak_meter_max = -peak_meter_get_max() / 100;
445 } else {
446 int max;
447
448 /* linear percent */
449 global_settings.peak_meter_min = peak_meter_get_min();
450
451 /* converting dBfs -> percent results in a precision loss.
452 I assume that the user doesn't bother that conversion
453 dBfs <-> percent isn't symmetrical for odd values but that
454 he wants 0 dBfs == 100%. Thus I 'correct' the percent value
455 resulting from dBfs -> percent manually here */
456 max = peak_meter_get_max();
457 global_settings.peak_meter_max = max < 99 ? max : 100;
458 }
459 settings_apply_pm_range();
460 }
461 return retval;
462}
463
464/**
465 * Adjust the min value of the value range that
466 * the peak meter shall visualize.
467 */
468static bool peak_meter_min(void) {
469 bool retval = false;
470 if (global_settings.peak_meter_dbfs) {
471
472 /* for dBfs scale */
473 int range_max = -global_settings.peak_meter_max;
474 int min = -global_settings.peak_meter_min;
475
Jörg Hohensohnbeec2e92004-03-20 16:49:58 +0000476 retval = set_int(str(LANG_PM_MIN), str(LANG_PM_DBFS), UNIT_DB,
Linus Nielsen Feltzingfd0cc3b2002-10-29 12:09:15 +0000477 &min, NULL, 1, -89, range_max);
478
479 global_settings.peak_meter_min = - min;
480 }
481
482 /* for linear scale */
483 else {
484 int min = global_settings.peak_meter_min;
485
Jörg Hohensohnbeec2e92004-03-20 16:49:58 +0000486 retval = set_int(str(LANG_PM_MIN), "%", UNIT_PERCENT,
Linus Nielsen Feltzingfd0cc3b2002-10-29 12:09:15 +0000487 &min, NULL,
488 1, 0, global_settings.peak_meter_max - 1);
489
490 global_settings.peak_meter_min = (unsigned char)min;
491 }
492
493 settings_apply_pm_range();
494 return retval;
495}
496
497
498/**
499 * Adjust the max value of the value range that
500 * the peak meter shall visualize.
501 */
502static bool peak_meter_max(void) {
503 bool retval = false;
504 if (global_settings.peak_meter_dbfs) {
505
506 /* for dBfs scale */
507 int range_min = -global_settings.peak_meter_min;
508 int max = -global_settings.peak_meter_max;;
509
Jörg Hohensohnbeec2e92004-03-20 16:49:58 +0000510 retval = set_int(str(LANG_PM_MAX), str(LANG_PM_DBFS), UNIT_DB,
Linus Nielsen Feltzingfd0cc3b2002-10-29 12:09:15 +0000511 &max, NULL, 1, range_min, 0);
512
513 global_settings.peak_meter_max = - max;
514
515 }
516
517 /* for linear scale */
518 else {
519 int max = global_settings.peak_meter_max;
520
Jörg Hohensohnbeec2e92004-03-20 16:49:58 +0000521 retval = set_int(str(LANG_PM_MAX), "%", UNIT_PERCENT,
Linus Nielsen Feltzingfd0cc3b2002-10-29 12:09:15 +0000522 &max, NULL,
523 1, global_settings.peak_meter_min + 1, 100);
524
525 global_settings.peak_meter_max = (unsigned char)max;
526 }
527
528 settings_apply_pm_range();
529 return retval;
530}
531
532/**
533 * Menu to select wether the meter is in
534 * precision or in energy saver mode
535 */
536static bool peak_meter_performance(void) {
537 bool retval = false;
538 retval = set_bool_options(str(LANG_PM_PERFORMANCE),
539 &global_settings.peak_meter_performance,
Jörg Hohensohn42ffbf92004-03-15 08:27:51 +0000540 STR(LANG_PM_HIGH_PERFORMANCE), STR(LANG_PM_ENERGY_SAVER),
Björn Stenberg26712d52003-06-05 11:11:10 +0000541 NULL);
Linus Nielsen Feltzingfd0cc3b2002-10-29 12:09:15 +0000542
543 if (global_settings.peak_meter_performance) {
544 peak_meter_fps = 25;
545 } else {
546 peak_meter_fps = 20;
547 }
548 return retval;
Linus Nielsen Feltzingbb572c42002-09-27 09:31:31 +0000549}
550
551/**
552 * Menu to configure the peak meter
553 */
554static bool peak_meter_menu(void)
555{
556 int m;
557 bool result;
558
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +0000559 static const struct menu_item items[] = {
560 { ID2P(LANG_PM_RELEASE) , peak_meter_release },
561 { ID2P(LANG_PM_PEAK_HOLD), peak_meter_hold },
562 { ID2P(LANG_PM_CLIP_HOLD), peak_meter_clip_hold },
563 { ID2P(LANG_PM_PERFORMANCE), peak_meter_performance },
Linus Nielsen Feltzingfd0cc3b2002-10-29 12:09:15 +0000564#ifdef PM_DEBUG
Jörg Hohensohn4f36ea82004-03-14 21:33:53 +0000565 { "Refresh rate" , -1 , peak_meter_fps_menu },
Linus Nielsen Feltzingfd0cc3b2002-10-29 12:09:15 +0000566#endif
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +0000567 { ID2P(LANG_PM_SCALE) , peak_meter_scale },
568 { ID2P(LANG_PM_MIN) , peak_meter_min },
569 { ID2P(LANG_PM_MAX) , peak_meter_max },
Linus Nielsen Feltzingbb572c42002-09-27 09:31:31 +0000570 };
Linus Nielsen Feltzing77936e62004-03-16 13:44:56 +0000571
572 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
573 NULL, NULL, NULL );
Linus Nielsen Feltzingbb572c42002-09-27 09:31:31 +0000574 result = menu_run(m);
575 menu_exit(m);
576 return result;
577}
Linus Nielsen Feltzingfd0cc3b2002-10-29 12:09:15 +0000578#endif /* HAVE_LCD_BITMAP */
Linus Nielsen Feltzingbb572c42002-09-27 09:31:31 +0000579
Björn Stenbergb1b8bd42002-09-24 17:22:12 +0000580static bool shuffle(void)
Robert Hak84a6ba22002-06-24 21:39:48 +0000581{
Björn Stenbergb1b8bd42002-09-24 17:22:12 +0000582 return set_bool( str(LANG_SHUFFLE), &global_settings.playlist_shuffle );
Björn Stenberg60b356e2002-06-27 01:08:11 +0000583}
Björn Stenberga6d0abb2002-10-04 08:48:20 +0000584
585static bool repeat_mode(void)
586{
587 bool result;
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +0000588 static const struct opt_items names[] = {
Jörg Hohensohn42ffbf92004-03-15 08:27:51 +0000589 { STR(LANG_OFF) },
590 { STR(LANG_REPEAT_ALL) },
Hardeep Sidhu74d082c2005-06-25 04:46:25 +0000591 { STR(LANG_REPEAT_ONE) },
592 { STR(LANG_SHUFFLE) },
Jörg Hohensohn42ffbf92004-03-15 08:27:51 +0000593 };
Björn Stenberga6d0abb2002-10-04 08:48:20 +0000594 int old_repeat = global_settings.repeat_mode;
595
596 result = set_option( str(LANG_REPEAT), &global_settings.repeat_mode,
Hardeep Sidhu74d082c2005-06-25 04:46:25 +0000597 INT, names, 4, NULL );
Björn Stenberga6d0abb2002-10-04 08:48:20 +0000598
Hardeep Sidhua6abe762005-07-07 23:50:16 +0000599 if (old_repeat != global_settings.repeat_mode &&
600 (audio_status() & AUDIO_STATUS_PLAY))
Linus Nielsen Feltzing8a237a82005-04-04 12:06:29 +0000601 audio_flush_and_reload_tracks();
Björn Stenberga6d0abb2002-10-04 08:48:20 +0000602
603 return result;
604}
Robert Hak84a6ba22002-06-24 21:39:48 +0000605
Björn Stenbergb1b8bd42002-09-24 17:22:12 +0000606static bool play_selected(void)
Linus Nielsen Feltzing25316c52002-09-18 10:13:09 +0000607{
Björn Stenbergb1b8bd42002-09-24 17:22:12 +0000608 return set_bool( str(LANG_PLAY_SELECTED), &global_settings.play_selected );
Linus Nielsen Feltzing25316c52002-09-18 10:13:09 +0000609}
610
Björn Stenberga7dcf912002-09-24 19:12:09 +0000611static bool dir_filter(void)
Björn Stenberg60b356e2002-06-27 01:08:11 +0000612{
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +0000613 static const struct opt_items names[] = {
Jörg Hohensohn42ffbf92004-03-15 08:27:51 +0000614 { STR(LANG_FILTER_ALL) },
615 { STR(LANG_FILTER_SUPPORTED) },
616 { STR(LANG_FILTER_MUSIC) },
Björn Stenbergfc53fd72005-01-17 11:37:36 +0000617 { STR(LANG_FILTER_PLAYLIST) },
618 { STR(LANG_FILTER_ID3DB) }
Jörg Hohensohn42ffbf92004-03-15 08:27:51 +0000619 };
Björn Stenberg26712d52003-06-05 11:11:10 +0000620 return set_option( str(LANG_FILTER), &global_settings.dirfilter, INT,
Björn Stenbergfc53fd72005-01-17 11:37:36 +0000621 names, 5, NULL );
Robert Hak84a6ba22002-06-24 21:39:48 +0000622}
623
Björn Stenbergb1b8bd42002-09-24 17:22:12 +0000624static bool sort_case(void)
Linus Nielsen Feltzingc132c482002-07-22 16:39:17 +0000625{
Björn Stenbergb1b8bd42002-09-24 17:22:12 +0000626 return set_bool( str(LANG_SORT_CASE), &global_settings.sort_case );
Linus Nielsen Feltzingc132c482002-07-22 16:39:17 +0000627}
628
Jörg Hohensohn5c8a2f52004-06-22 09:16:44 +0000629static bool sort_file(void)
630{
Jörg Hohensohnd79b1f52004-06-23 07:28:35 +0000631 int oldval = global_settings.sort_file;
632 bool ret;
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +0000633 static const struct opt_items names[] = {
Jörg Hohensohn5c8a2f52004-06-22 09:16:44 +0000634 { STR(LANG_SORT_ALPHA) },
635 { STR(LANG_SORT_DATE) },
636 { STR(LANG_SORT_DATE_REVERSE) },
637 { STR(LANG_SORT_TYPE) }
638 };
Jörg Hohensohnd79b1f52004-06-23 07:28:35 +0000639 ret = set_option( str(LANG_SORT_FILE), &global_settings.sort_file, INT,
Jörg Hohensohn5c8a2f52004-06-22 09:16:44 +0000640 names, 4, NULL );
Jörg Hohensohnd79b1f52004-06-23 07:28:35 +0000641 if (global_settings.sort_file != oldval)
642 reload_directory(); /* force reload if this has changed */
643 return ret;
Jörg Hohensohn5c8a2f52004-06-22 09:16:44 +0000644}
645
646static bool sort_dir(void)
647{
Jörg Hohensohnd79b1f52004-06-23 07:28:35 +0000648 int oldval = global_settings.sort_dir;
649 bool ret;
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +0000650 static const struct opt_items names[] = {
Jörg Hohensohn5c8a2f52004-06-22 09:16:44 +0000651 { STR(LANG_SORT_ALPHA) },
652 { STR(LANG_SORT_DATE) },
653 { STR(LANG_SORT_DATE_REVERSE) }
654 };
Jörg Hohensohnd79b1f52004-06-23 07:28:35 +0000655 ret = set_option( str(LANG_SORT_DIR), &global_settings.sort_dir, INT,
Jörg Hohensohn5c8a2f52004-06-22 09:16:44 +0000656 names, 3, NULL );
Jörg Hohensohnd79b1f52004-06-23 07:28:35 +0000657 if (global_settings.sort_dir != oldval)
658 reload_directory(); /* force reload if this has changed */
659 return ret;
Jörg Hohensohn5c8a2f52004-06-22 09:16:44 +0000660}
661
Björn Stenbergb1b8bd42002-09-24 17:22:12 +0000662static bool resume(void)
Björn Stenberg6224cdb2002-08-16 14:41:47 +0000663{
Christi Scarborough9e8918b2005-06-29 12:23:09 +0000664 return set_bool( str(LANG_RESUME), &global_settings.resume);
Björn Stenberg6224cdb2002-08-16 14:41:47 +0000665}
666
Linus Nielsen Feltzing8782bc82005-07-01 09:42:39 +0000667#ifdef HAVE_SPDIF_POWER
668static bool spdif(void)
669{
670 bool rc = set_bool_options(str(LANG_SPDIF_ENABLE),
671 &global_settings.spdif_enable,
672 STR(LANG_ON),
673 STR(LANG_OFF),
674 spdif_power_enable);
675 return rc;
676}
677#endif
678
Björn Stenberga108ec22004-01-14 00:13:04 +0000679static bool autocreatebookmark(void)
680{
Henrik Backee7353562004-04-19 17:51:47 +0000681 bool retval = false;
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +0000682 static const struct opt_items names[] = {
Jörg Hohensohn42ffbf92004-03-15 08:27:51 +0000683 { STR(LANG_SET_BOOL_NO) },
684 { STR(LANG_SET_BOOL_YES) },
685 { STR(LANG_RESUME_SETTING_ASK) },
686 { STR(LANG_BOOKMARK_SETTINGS_RECENT_ONLY_YES) },
687 { STR(LANG_BOOKMARK_SETTINGS_RECENT_ONLY_ASK) }
688 };
Henrik Backee7353562004-04-19 17:51:47 +0000689
690 retval = set_option( str(LANG_BOOKMARK_SETTINGS_AUTOCREATE),
Björn Stenberga108ec22004-01-14 00:13:04 +0000691 &global_settings.autocreatebookmark, INT,
692 names, 5, NULL );
Henrik Backee7353562004-04-19 17:51:47 +0000693 if(global_settings.autocreatebookmark == BOOKMARK_RECENT_ONLY_YES ||
694 global_settings.autocreatebookmark == BOOKMARK_RECENT_ONLY_ASK)
695 {
696 if(global_settings.usemrb == BOOKMARK_NO)
697 global_settings.usemrb = BOOKMARK_YES;
698
699 }
700 return retval;
Björn Stenberga108ec22004-01-14 00:13:04 +0000701}
702
703static bool autoloadbookmark(void)
704{
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +0000705 static const struct opt_items names[] = {
Jörg Hohensohn42ffbf92004-03-15 08:27:51 +0000706 { STR(LANG_SET_BOOL_NO) },
707 { STR(LANG_SET_BOOL_YES) },
708 { STR(LANG_RESUME_SETTING_ASK) }
709 };
Björn Stenberga108ec22004-01-14 00:13:04 +0000710 return set_option( str(LANG_BOOKMARK_SETTINGS_AUTOLOAD),
711 &global_settings.autoloadbookmark, INT,
712 names, 3, NULL );
713}
714
715static bool useMRB(void)
716{
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +0000717 static const struct opt_items names[] = {
Jörg Hohensohn42ffbf92004-03-15 08:27:51 +0000718 { STR(LANG_SET_BOOL_NO) },
719 { STR(LANG_SET_BOOL_YES) },
720 { STR(LANG_BOOKMARK_SETTINGS_UNIQUE_ONLY) }
721 };
Björn Stenberga108ec22004-01-14 00:13:04 +0000722 return set_option( str(LANG_BOOKMARK_SETTINGS_MAINTAIN_RECENT_BOOKMARKS),
723 &global_settings.usemrb, INT,
724 names, 3, NULL );
725}
Jens Arnolda1a08d02004-10-09 19:56:27 +0000726
Björn Stenbergb1b8bd42002-09-24 17:22:12 +0000727static bool poweroff_idle_timer(void)
Linus Nielsen Feltzing083a6db2002-09-23 11:42:48 +0000728{
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +0000729 static const struct opt_items names[] = {
Jörg Hohensohn42ffbf92004-03-15 08:27:51 +0000730 { STR(LANG_OFF) },
Jörg Hohensohnfa97f162004-03-19 22:15:53 +0000731 { "1m ", TALK_ID(1, UNIT_MIN) },
732 { "2m ", TALK_ID(2, UNIT_MIN) },
733 { "3m ", TALK_ID(3, UNIT_MIN) },
734 { "4m ", TALK_ID(4, UNIT_MIN) },
735 { "5m ", TALK_ID(5, UNIT_MIN) },
736 { "6m ", TALK_ID(6, UNIT_MIN) },
737 { "7m ", TALK_ID(7, UNIT_MIN) },
738 { "8m ", TALK_ID(8, UNIT_MIN) },
739 { "9m ", TALK_ID(9, UNIT_MIN) },
740 { "10m", TALK_ID(10, UNIT_MIN) },
741 { "15m", TALK_ID(15, UNIT_MIN) },
742 { "30m", TALK_ID(30, UNIT_MIN) },
743 { "45m", TALK_ID(45, UNIT_MIN) },
744 { "60m", TALK_ID(60, UNIT_MIN) }
Jörg Hohensohn42ffbf92004-03-15 08:27:51 +0000745 };
Björn Stenbergb1b8bd42002-09-24 17:22:12 +0000746 return set_option(str(LANG_POWEROFF_IDLE), &global_settings.poweroff,
Björn Stenberg26712d52003-06-05 11:11:10 +0000747 INT, names, 15, set_poweroff_timeout);
Linus Nielsen Feltzing083a6db2002-09-23 11:42:48 +0000748}
749
Björn Stenbergb1b8bd42002-09-24 17:22:12 +0000750static bool scroll_speed(void)
Robert Hak84a6ba22002-06-24 21:39:48 +0000751{
Jens Arnold566eae22004-10-15 20:30:29 +0000752 return set_int(str(LANG_SCROLL), "", UNIT_INT,
753 &global_settings.scroll_speed,
754 &lcd_scroll_speed, 1, 0, 15 );
Robert Hak048fa132002-12-12 17:20:37 +0000755}
756
757
758static bool scroll_delay(void)
759{
760 int dummy = global_settings.scroll_delay * (HZ/10);
Jörg Hohensohnbeec2e92004-03-20 16:49:58 +0000761 int rc = set_int(str(LANG_SCROLL_DELAY), "ms", UNIT_MS,
762 &dummy,
Robert Hak89d8f762002-12-12 20:34:30 +0000763 &lcd_scroll_delay, 100, 0, 2500 );
Robert Hak048fa132002-12-12 17:20:37 +0000764 global_settings.scroll_delay = dummy / (HZ/10);
765 return rc;
Robert Hak84a6ba22002-06-24 21:39:48 +0000766}
767
Björn Stenberga2e98c12002-12-12 15:20:37 +0000768#ifdef HAVE_LCD_BITMAP
769static bool scroll_step(void)
770{
Jörg Hohensohnbeec2e92004-03-20 16:49:58 +0000771 return set_int(str(LANG_SCROLL_STEP_EXAMPLE), "pixels", UNIT_PIXEL,
Björn Stenberga2e98c12002-12-12 15:20:37 +0000772 &global_settings.scroll_step,
773 &lcd_scroll_step, 1, 1, LCD_WIDTH );
774}
Mats Lidellc65dadf2003-01-14 10:48:01 +0000775#endif
Björn Stenberga2e98c12002-12-12 15:20:37 +0000776
Björn Stenberga2e98c12002-12-12 15:20:37 +0000777static bool bidir_limit(void)
778{
Jörg Hohensohnbeec2e92004-03-20 16:49:58 +0000779 return set_int(str(LANG_BIDIR_SCROLL), "%", UNIT_PERCENT,
780 &global_settings.bidir_limit,
Björn Stenberga2e98c12002-12-12 15:20:37 +0000781 &lcd_bidir_scroll, 25, 0, 200 );
782}
Björn Stenberga2e98c12002-12-12 15:20:37 +0000783
Kjell Ericson53f156a2003-05-22 06:42:14 +0000784#ifdef HAVE_LCD_CHARCELLS
785static bool jump_scroll(void)
786{
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +0000787 static const struct opt_items names[] = {
Jörg Hohensohn42ffbf92004-03-15 08:27:51 +0000788 { STR(LANG_OFF) },
789 { STR(LANG_ONE_TIME) },
Jörg Hohensohnfa97f162004-03-19 22:15:53 +0000790 { "2", TALK_ID(2, UNIT_INT) },
791 { "3", TALK_ID(3, UNIT_INT) },
792 { "4", TALK_ID(4, UNIT_INT) },
Jörg Hohensohn42ffbf92004-03-15 08:27:51 +0000793 { STR(LANG_ALWAYS) }
794 };
Kjell Ericson6143eeb2003-05-27 12:54:11 +0000795 bool ret;
796 ret=set_option(str(LANG_JUMP_SCROLL), &global_settings.jump_scroll,
Björn Stenberg26712d52003-06-05 11:11:10 +0000797 INT, names, 6, lcd_jump_scroll);
Kjell Ericson6143eeb2003-05-27 12:54:11 +0000798 return ret;
799}
800static bool jump_scroll_delay(void)
801{
802 int dummy = global_settings.jump_scroll_delay * (HZ/10);
Jörg Hohensohnbeec2e92004-03-20 16:49:58 +0000803 int rc = set_int(str(LANG_JUMP_SCROLL_DELAY), "ms", UNIT_MS,
804 &dummy,
Kjell Ericson6143eeb2003-05-27 12:54:11 +0000805 &lcd_jump_scroll_delay, 100, 0, 2500 );
806 global_settings.jump_scroll_delay = dummy / (HZ/10);
807 return rc;
Kjell Ericson53f156a2003-05-22 06:42:14 +0000808}
809#endif
810
Uwe Freese0bf70e62002-12-16 22:58:48 +0000811#ifndef SIMULATOR
Uwe Freese4cff0302002-12-15 18:12:00 +0000812/**
813 * Menu to set the battery capacity
814 */
Uwe Freese0bf70e62002-12-16 22:58:48 +0000815static bool battery_capacity(void)
816{
Jörg Hohensohnbeec2e92004-03-20 16:49:58 +0000817 return set_int(str(LANG_BATTERY_CAPACITY), "mAh", UNIT_MAH,
818 &global_settings.battery_capacity,
Jens Arnoldfe324562004-10-10 10:28:21 +0000819 &set_battery_capacity, 50, BATTERY_CAPACITY_MIN,
820 BATTERY_CAPACITY_MAX );
Uwe Freese4cff0302002-12-15 18:12:00 +0000821}
Jens Arnold91846a12005-01-30 16:25:46 +0000822
823#if BATTERY_TYPES_COUNT > 1
824static bool battery_type(void)
825{
826 static const struct opt_items names[] = {
827 { STR(LANG_BATTERY_TYPE_ALKALINE) },
828 { STR(LANG_BATTERY_TYPE_NIMH) }
829 };
830
831 return set_option(str(LANG_BATTERY_TYPE), &global_settings.battery_type,
832 INT, names, 2, set_battery_type);
833}
834#endif
Uwe Freese0bf70e62002-12-16 22:58:48 +0000835#endif
Uwe Freese4cff0302002-12-15 18:12:00 +0000836
Björn Stenbergfe375a02004-01-14 14:42:31 +0000837#ifdef HAVE_RTC
Björn Stenbergb1b8bd42002-09-24 17:22:12 +0000838static bool timedate_set(void)
Markus Braun3181f682002-08-09 12:38:45 +0000839{
Linus Nielsen Feltzing7ddf0d62004-04-20 10:23:57 +0000840 struct tm tm;
Björn Stenbergb1b8bd42002-09-24 17:22:12 +0000841 bool result;
Markus Braun3181f682002-08-09 12:38:45 +0000842
Linus Nielsen Feltzing7ddf0d62004-04-20 10:23:57 +0000843 /* Make a local copy of the time struct */
844 memcpy(&tm, get_time(), sizeof(struct tm));
Markus Braun44ee2ab2003-05-27 14:28:08 +0000845
846 /* do some range checks */
847 /* This prevents problems with time/date setting after a power loss */
Linus Nielsen Feltzing7ddf0d62004-04-20 10:23:57 +0000848 if (!valid_time(&tm))
Markus Braun44ee2ab2003-05-27 14:28:08 +0000849 {
850 /* hour */
Linus Nielsen Feltzing7ddf0d62004-04-20 10:23:57 +0000851 tm.tm_hour = 0;
852 tm.tm_min = 0;
853 tm.tm_sec = 0;
854 tm.tm_mday = 1;
855 tm.tm_mon = 0;
856 tm.tm_wday = 1;
857 tm.tm_year = 100;
Markus Braun44ee2ab2003-05-27 14:28:08 +0000858 }
Markus Braun3181f682002-08-09 12:38:45 +0000859
Linus Nielsen Feltzing7ddf0d62004-04-20 10:23:57 +0000860 result = set_time_screen(str(LANG_TIME), &tm);
Markus Braun3181f682002-08-09 12:38:45 +0000861
Linus Nielsen Feltzing7ddf0d62004-04-20 10:23:57 +0000862 if(tm.tm_year != -1) {
863 set_time(&tm);
Markus Braun3181f682002-08-09 12:38:45 +0000864 }
Björn Stenbergb1b8bd42002-09-24 17:22:12 +0000865 return result;
Markus Braun3181f682002-08-09 12:38:45 +0000866}
Markus Braun22a7a2d2002-10-14 12:50:20 +0000867
868static bool timeformat_set(void)
869{
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +0000870 static const struct opt_items names[] = {
Jörg Hohensohn42ffbf92004-03-15 08:27:51 +0000871 { STR(LANG_24_HOUR_CLOCK) },
872 { STR(LANG_12_HOUR_CLOCK) }
873 };
Björn Stenberg26712d52003-06-05 11:11:10 +0000874 return set_option(str(LANG_TIMEFORMAT), &global_settings.timeformat,
875 INT, names, 2, NULL);
Markus Braun22a7a2d2002-10-14 12:50:20 +0000876}
Markus Braun3181f682002-08-09 12:38:45 +0000877#endif
878
Jens Arnolddd937dc2004-10-09 22:04:47 +0000879#ifndef HAVE_MMC
Björn Stenbergb1b8bd42002-09-24 17:22:12 +0000880static bool spindown(void)
Björn Stenberg457b8a02002-08-26 13:21:14 +0000881{
Jörg Hohensohnbeec2e92004-03-20 16:49:58 +0000882 return set_int(str(LANG_SPINDOWN), "s", UNIT_SEC,
883 &global_settings.disk_spindown,
Björn Stenbergb1b8bd42002-09-24 17:22:12 +0000884 ata_spindown, 1, 3, 254 );
Björn Stenberg05704972002-08-14 19:23:34 +0000885}
886
Daniel Stenberg39c54742002-11-29 07:05:46 +0000887#ifdef HAVE_ATA_POWER_OFF
Björn Stenberg2b77b4f2002-11-28 22:46:19 +0000888static bool poweroff(void)
889{
890 bool rc = set_bool(str(LANG_POWEROFF), &global_settings.disk_poweroff);
891 ata_poweroff(global_settings.disk_poweroff);
892 return rc;
893}
Jens Arnolddd937dc2004-10-09 22:04:47 +0000894#endif /* HAVE_ATA_POWEROFF */
895#endif /* !HAVE_MMC */
896
897#if CONFIG_HWCODEC == MAS3507D
898static bool line_in(void)
899{
900 bool rc = set_bool(str(LANG_LINE_IN), &global_settings.line_in);
901 dac_line_in(global_settings.line_in);
902 return rc;
903}
Daniel Stenberg39c54742002-11-29 07:05:46 +0000904#endif
Björn Stenberg2b77b4f2002-11-28 22:46:19 +0000905
Linus Nielsen Feltzing20d031f2003-05-09 16:01:21 +0000906static bool max_files_in_dir(void)
907{
Jörg Hohensohnbeec2e92004-03-20 16:49:58 +0000908 return set_int(str(LANG_MAX_FILES_IN_DIR), "", UNIT_INT,
Linus Nielsen Feltzing20d031f2003-05-09 16:01:21 +0000909 &global_settings.max_files_in_dir,
910 NULL, 50, 50, 10000 );
911}
912
913static bool max_files_in_playlist(void)
914{
Jörg Hohensohnbeec2e92004-03-20 16:49:58 +0000915 return set_int(str(LANG_MAX_FILES_IN_PLAYLIST), "", UNIT_INT,
Linus Nielsen Feltzing20d031f2003-05-09 16:01:21 +0000916 &global_settings.max_files_in_playlist,
Linus Nielsen Feltzing2ce9ba52003-05-09 21:59:04 +0000917 NULL, 1000, 1000, 20000 );
Linus Nielsen Feltzing20d031f2003-05-09 16:01:21 +0000918}
919
Linus Nielsen Feltzingb8ff5f82002-12-05 13:09:51 +0000920static bool buffer_margin(void)
921{
Jörg Hohensohnbeec2e92004-03-20 16:49:58 +0000922 return set_int(str(LANG_MP3BUFFER_MARGIN), "s", UNIT_SEC,
Linus Nielsen Feltzingb8ff5f82002-12-05 13:09:51 +0000923 &global_settings.buffer_margin,
Linus Nielsen Feltzing8a237a82005-04-04 12:06:29 +0000924 audio_set_buffer_margin, 1, 0, 7 );
Linus Nielsen Feltzingb8ff5f82002-12-05 13:09:51 +0000925}
926
Linus Nielsen Feltzing20d031f2003-05-09 16:01:21 +0000927static bool ff_rewind_min_step(void)
Eric Linenberg7eb27112002-09-04 03:38:37 +0000928{
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +0000929 static const struct opt_items names[] = {
Jörg Hohensohnfa97f162004-03-19 22:15:53 +0000930 { "1s", TALK_ID(1, UNIT_SEC) },
931 { "2s", TALK_ID(2, UNIT_SEC) },
932 { "3s", TALK_ID(3, UNIT_SEC) },
933 { "4s", TALK_ID(4, UNIT_SEC) },
934 { "5s", TALK_ID(5, UNIT_SEC) },
935 { "6s", TALK_ID(6, UNIT_SEC) },
936 { "8s", TALK_ID(8, UNIT_SEC) },
937 { "10s", TALK_ID(10, UNIT_SEC) },
938 { "15s", TALK_ID(15, UNIT_SEC) },
939 { "20s", TALK_ID(20, UNIT_SEC) },
940 { "25s", TALK_ID(25, UNIT_SEC) },
941 { "30s", TALK_ID(30, UNIT_SEC) },
942 { "45s", TALK_ID(45, UNIT_SEC) },
943 { "60s", TALK_ID(60, UNIT_SEC) }
Jörg Hohensohn42ffbf92004-03-15 08:27:51 +0000944 };
Björn Stenbergb1b8bd42002-09-24 17:22:12 +0000945 return set_option(str(LANG_FFRW_STEP), &global_settings.ff_rewind_min_step,
Björn Stenberg26712d52003-06-05 11:11:10 +0000946 INT, names, 14, NULL );
Eric Linenberg7eb27112002-09-04 03:38:37 +0000947}
948
Björn Stenberge2628d92003-02-14 15:54:52 +0000949static bool set_fade_on_stop(void)
950{
951 return set_bool( str(LANG_FADE_ON_STOP), &global_settings.fade_on_stop );
952}
953
954
Björn Stenbergb1b8bd42002-09-24 17:22:12 +0000955static bool ff_rewind_accel(void)
Justin Heiner8097ee62002-08-29 05:41:35 +0000956{
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +0000957 static const struct opt_items names[] = {
Jörg Hohensohn42ffbf92004-03-15 08:27:51 +0000958 { STR(LANG_OFF) },
Jörg Hohensohnfa97f162004-03-19 22:15:53 +0000959 { "2x/1s", TALK_ID(1, UNIT_SEC) },
960 { "2x/2s", TALK_ID(2, UNIT_SEC) },
961 { "2x/3s", TALK_ID(3, UNIT_SEC) },
962 { "2x/4s", TALK_ID(4, UNIT_SEC) },
963 { "2x/5s", TALK_ID(5, UNIT_SEC) },
964 { "2x/6s", TALK_ID(6, UNIT_SEC) },
965 { "2x/7s", TALK_ID(7, UNIT_SEC) },
966 { "2x/8s", TALK_ID(8, UNIT_SEC) },
967 { "2x/9s", TALK_ID(9, UNIT_SEC) },
968 { "2x/10s", TALK_ID(10, UNIT_SEC) },
969 { "2x/11s", TALK_ID(11, UNIT_SEC) },
970 { "2x/12s", TALK_ID(12, UNIT_SEC) },
971 { "2x/13s", TALK_ID(13, UNIT_SEC) },
972 { "2x/14s", TALK_ID(14, UNIT_SEC) },
973 { "2x/15s", TALK_ID(15, UNIT_SEC) }
Jörg Hohensohn42ffbf92004-03-15 08:27:51 +0000974 };
Björn Stenbergb1b8bd42002-09-24 17:22:12 +0000975 return set_option(str(LANG_FFRW_ACCEL), &global_settings.ff_rewind_accel,
Björn Stenberg26712d52003-06-05 11:11:10 +0000976 INT, names, 16, NULL );
Justin Heiner8097ee62002-08-29 05:41:35 +0000977}
Eric Linenberg65240762002-08-28 19:34:07 +0000978
Björn Stenbergb1b8bd42002-09-24 17:22:12 +0000979static bool browse_current(void)
Eric Linenbergecca1232002-09-09 14:25:39 +0000980{
Björn Stenbergb1b8bd42002-09-24 17:22:12 +0000981 return set_bool( str(LANG_FOLLOW), &global_settings.browse_current );
Eric Linenbergecca1232002-09-09 14:25:39 +0000982}
983
Björn Stenbergde5477c2003-09-29 21:26:53 +0000984static bool custom_wps_browse(void)
985{
986 return rockbox_browse(ROCKBOX_DIR, SHOW_WPS);
987}
988
989static bool custom_cfg_browse(void)
990{
991 return rockbox_browse(ROCKBOX_DIR, SHOW_CFG);
992}
993
994static bool language_browse(void)
995{
Jens Arnold3badc7d2005-01-17 23:55:55 +0000996 return rockbox_browse(ROCKBOX_DIR LANG_DIR, SHOW_LNG);
Björn Stenbergde5477c2003-09-29 21:26:53 +0000997}
998
Jörg Hohensohn3aa99e12004-03-27 00:11:01 +0000999static bool voice_menus(void)
1000{
1001 bool ret;
1002 bool temp = global_settings.talk_menu;
1003 /* work on a temp variable first, avoid "life" disabling */
1004 ret = set_bool( str(LANG_VOICE_MENU), &temp );
1005 global_settings.talk_menu = temp;
1006 return ret;
1007}
1008
Jörg Hohensohnd4844202004-10-06 21:37:46 +00001009/* this is used 2 times below, so it saves memory to put it in global scope */
1010static const struct opt_items voice_names[] = {
1011 { STR(LANG_OFF) },
1012 { STR(LANG_VOICE_NUMBER) },
1013 { STR(LANG_VOICE_SPELL) },
1014 { STR(LANG_VOICE_DIR_HOVER) }
1015};
1016
Jörg Hohensohn3aa99e12004-03-27 00:11:01 +00001017static bool voice_dirs(void)
1018{
Jörg Hohensohn3aa99e12004-03-27 00:11:01 +00001019 return set_option( str(LANG_VOICE_DIR),
Jörg Hohensohnd4844202004-10-06 21:37:46 +00001020 &global_settings.talk_dir, INT, voice_names, 4, NULL);
Jörg Hohensohn3aa99e12004-03-27 00:11:01 +00001021}
1022
1023static bool voice_files(void)
1024{
Jörg Hohensohn40ae63b2004-10-21 18:34:48 +00001025 int oldval = global_settings.talk_file;
1026 bool ret;
1027 ret = set_option( str(LANG_VOICE_FILE),
Jörg Hohensohnd4844202004-10-06 21:37:46 +00001028 &global_settings.talk_file, INT, voice_names, 4, NULL);
Jörg Hohensohn40ae63b2004-10-21 18:34:48 +00001029 if (oldval != 3 && global_settings.talk_file == 3)
1030 { /* force reload if newly talking thumbnails,
1031 because the clip presence is cached only if enabled */
1032 reload_directory();
1033 }
1034 return ret;
Jörg Hohensohn3aa99e12004-03-27 00:11:01 +00001035}
1036
1037static bool voice_menu(void)
1038{
1039 int m;
1040 bool result;
1041
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001042 static const struct menu_item items[] = {
1043 { ID2P(LANG_VOICE_MENU), voice_menus },
1044 { ID2P(LANG_VOICE_DIR), voice_dirs },
1045 { ID2P(LANG_VOICE_FILE), voice_files }
Jörg Hohensohn3aa99e12004-03-27 00:11:01 +00001046 };
1047
1048 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
1049 NULL, NULL, NULL);
1050 result = menu_run(m);
1051 menu_exit(m);
1052 return result;
1053}
1054
Björn Stenbergfe375a02004-01-14 14:42:31 +00001055#ifdef HAVE_LCD_BITMAP
Björn Stenbergde5477c2003-09-29 21:26:53 +00001056static bool font_browse(void)
1057{
Daniel Stenberg0f689582004-01-08 12:40:25 +00001058 return rockbox_browse(ROCKBOX_DIR FONT_DIR, SHOW_FONT);
Björn Stenbergde5477c2003-09-29 21:26:53 +00001059}
Björn Stenbergde5477c2003-09-29 21:26:53 +00001060
Jörg Hohensohn459abc22003-04-21 12:39:36 +00001061static bool scroll_bar(void)
1062{
1063 return set_bool( str(LANG_SCROLL_BAR), &global_settings.scrollbar );
1064}
1065
1066static bool status_bar(void)
1067{
1068 return set_bool( str(LANG_STATUS_BAR), &global_settings.statusbar );
1069}
Linus Nielsen Feltzing77936e62004-03-16 13:44:56 +00001070
Jens Arnold1f0908d2004-10-09 20:54:15 +00001071#if CONFIG_KEYPAD == RECORDER_PAD
Linus Nielsen Feltzing77936e62004-03-16 13:44:56 +00001072static bool button_bar(void)
1073{
1074 return set_bool( str(LANG_BUTTON_BAR), &global_settings.buttonbar );
1075}
Jens Arnold1f0908d2004-10-09 20:54:15 +00001076#endif /* CONFIG_KEYPAD == RECORDER_PAD */
1077#endif /* HAVE_LCD_BITMAP */
Jörg Hohensohn459abc22003-04-21 12:39:36 +00001078
Björn Stenbergfe375a02004-01-14 14:42:31 +00001079static bool ff_rewind_settings_menu(void)
1080{
1081 int m;
1082 bool result;
1083
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001084 static const struct menu_item items[] = {
1085 { ID2P(LANG_FFRW_STEP), ff_rewind_min_step },
1086 { ID2P(LANG_FFRW_ACCEL), ff_rewind_accel },
Björn Stenbergfe375a02004-01-14 14:42:31 +00001087 };
1088
Linus Nielsen Feltzing77936e62004-03-16 13:44:56 +00001089 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
1090 NULL, NULL, NULL);
Björn Stenbergfe375a02004-01-14 14:42:31 +00001091 result = menu_run(m);
1092 menu_exit(m);
1093
1094 return result;
1095}
1096
Linus Nielsen Feltzing4cdcbb92004-07-27 19:20:51 +00001097static bool id3_order(void)
1098{
1099 return set_bool_options( str(LANG_ID3_ORDER),
1100 &global_settings.id3_v1_first,
1101 STR(LANG_ID3_V1_FIRST),
1102 STR(LANG_ID3_V2_FIRST),
1103 mpeg_id3_options);
1104}
1105
Linus Nielsen Feltzing6271b2b2005-06-09 09:47:00 +00001106#if CONFIG_HWCODEC == MASNONE
1107static bool crossfade(void)
1108{
1109 bool rc = set_bool( str(LANG_CROSSFADE), &global_settings.crossfade );
1110#ifndef SIMULATOR
Miika Pekkarinen20b38972005-07-13 12:48:22 +00001111 pcmbuf_crossfade_enable(global_settings.crossfade);
Linus Nielsen Feltzing6271b2b2005-06-09 09:47:00 +00001112#endif
1113 return rc;
1114}
1115#endif
1116
Hardeep Sidhu71d22812005-07-01 11:25:16 +00001117static bool next_folder(void)
1118{
1119 return set_bool( str(LANG_NEXT_FOLDER), &global_settings.next_folder );
1120}
1121
Jens Arnold8102f3d2005-07-02 10:50:42 +00001122static bool runtimedb(void)
1123{
1124 bool rc;
1125 bool old = global_settings.runtimedb;
1126
1127 rc = set_bool_options( str(LANG_RUNTIMEDB_ACTIVE),
1128 &global_settings.runtimedb,
1129 STR(LANG_SET_BOOL_YES),
1130 STR(LANG_SET_BOOL_NO),
1131 NULL);
1132 if (old && !global_settings.runtimedb)
1133 rundb_shutdown();
1134 if (!old && global_settings.runtimedb)
1135 rundb_init();
1136
1137 return rc;
1138}
1139
Björn Stenbergb1b8bd42002-09-24 17:22:12 +00001140static bool playback_settings_menu(void)
Eric Linenbergc5b645b2002-09-05 04:42:12 +00001141{
1142 int m;
Björn Stenbergb1b8bd42002-09-24 17:22:12 +00001143 bool result;
Eric Linenbergc5b645b2002-09-05 04:42:12 +00001144
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001145 static const struct menu_item items[] = {
1146 { ID2P(LANG_SHUFFLE), shuffle },
1147 { ID2P(LANG_REPEAT), repeat_mode },
1148 { ID2P(LANG_PLAY_SELECTED), play_selected },
1149 { ID2P(LANG_RESUME), resume },
1150 { ID2P(LANG_WIND_MENU), ff_rewind_settings_menu },
1151 { ID2P(LANG_MP3BUFFER_MARGIN), buffer_margin },
1152 { ID2P(LANG_FADE_ON_STOP), set_fade_on_stop },
Linus Nielsen Feltzing6271b2b2005-06-09 09:47:00 +00001153#if CONFIG_HWCODEC == MASNONE
1154 { ID2P(LANG_CROSSFADE), crossfade },
1155#endif
Linus Nielsen Feltzing8782bc82005-07-01 09:42:39 +00001156#ifdef HAVE_SPDIF_POWER
1157 { ID2P(LANG_SPDIF_ENABLE), spdif },
1158#endif
Linus Nielsen Feltzing4cdcbb92004-07-27 19:20:51 +00001159 { ID2P(LANG_ID3_ORDER), id3_order },
Hardeep Sidhu71d22812005-07-01 11:25:16 +00001160 { ID2P(LANG_NEXT_FOLDER), next_folder },
Jens Arnold8102f3d2005-07-02 10:50:42 +00001161 { ID2P(LANG_RUNTIMEDB_ACTIVE), runtimedb },
Robert Hak84a6ba22002-06-24 21:39:48 +00001162 };
Björn Stenberg505eca72002-09-18 14:08:05 +00001163
Daniel Stenberg360ae3e2002-08-02 13:20:03 +00001164 bool old_shuffle = global_settings.playlist_shuffle;
Björn Stenbergfe375a02004-01-14 14:42:31 +00001165
Linus Nielsen Feltzing77936e62004-03-16 13:44:56 +00001166 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
1167 NULL, NULL, NULL);
Daniel Stenbergb2850762002-08-23 12:32:52 +00001168 result = menu_run(m);
Robert Hak84a6ba22002-06-24 21:39:48 +00001169 menu_exit(m);
Daniel Stenberg360ae3e2002-08-02 13:20:03 +00001170
Jens Arnoldd6587f92005-05-01 19:13:47 +00001171 if ((old_shuffle != global_settings.playlist_shuffle)
1172 && (audio_status() & AUDIO_STATUS_PLAY))
Daniel Stenberg360ae3e2002-08-02 13:20:03 +00001173 {
1174 if (global_settings.playlist_shuffle)
1175 {
Hardeep Sidhu107ebc52004-01-26 17:05:21 +00001176 playlist_randomise(NULL, current_tick, true);
Daniel Stenberg360ae3e2002-08-02 13:20:03 +00001177 }
1178 else
1179 {
Hardeep Sidhu107ebc52004-01-26 17:05:21 +00001180 playlist_sort(NULL, true);
Daniel Stenberg360ae3e2002-08-02 13:20:03 +00001181 }
1182 }
Daniel Stenbergb2850762002-08-23 12:32:52 +00001183 return result;
Robert Hak84a6ba22002-06-24 21:39:48 +00001184}
Eric Linenbergc5b645b2002-09-05 04:42:12 +00001185
Björn Stenberga108ec22004-01-14 00:13:04 +00001186static bool bookmark_settings_menu(void)
1187{
1188 int m;
1189 bool result;
1190
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001191 static const struct menu_item items[] = {
1192 { ID2P(LANG_BOOKMARK_SETTINGS_AUTOCREATE), autocreatebookmark},
1193 { ID2P(LANG_BOOKMARK_SETTINGS_AUTOLOAD), autoloadbookmark},
1194 { ID2P(LANG_BOOKMARK_SETTINGS_MAINTAIN_RECENT_BOOKMARKS), useMRB},
Björn Stenberga108ec22004-01-14 00:13:04 +00001195 };
1196
Linus Nielsen Feltzing77936e62004-03-16 13:44:56 +00001197 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
1198 NULL, NULL, NULL);
Björn Stenberga108ec22004-01-14 00:13:04 +00001199 result = menu_run(m);
1200 menu_exit(m);
1201
1202 return result;
1203}
Björn Stenbergb1b8bd42002-09-24 17:22:12 +00001204static bool reset_settings(void)
Justin Heiner2f9b54b2002-09-06 07:00:20 +00001205{
Robert Hakea8a4cf2002-10-14 09:12:52 +00001206 bool done=false;
1207 int line;
Linus Nielsen Feltzingade5d7b2004-07-26 16:06:59 +00001208 int button;
Robert Hakea8a4cf2002-10-14 09:12:52 +00001209
1210 lcd_clear_display();
1211
1212#ifdef HAVE_LCD_CHARCELLS
1213 line = 0;
1214#else
1215 line = 1;
1216 lcd_puts(0,0,str(LANG_RESET_ASK_RECORDER));
1217#endif
1218 lcd_puts(0,line,str(LANG_RESET_CONFIRM));
1219 lcd_puts(0,line+1,str(LANG_RESET_CANCEL));
1220
1221 lcd_update();
Robert Hakea8a4cf2002-10-14 09:12:52 +00001222
1223 while(!done) {
Linus Nielsen Feltzingade5d7b2004-07-26 16:06:59 +00001224 button = button_get(true);
1225 switch(button) {
Björn Stenberg6c33c512004-09-19 21:58:37 +00001226 case SETTINGS_OK:
1227 settings_reset();
1228 settings_apply();
1229 lcd_clear_display();
1230 lcd_puts(0,1,str(LANG_RESET_DONE_CLEAR));
1231 done = true;
1232 break;
Robert Hakea8a4cf2002-10-14 09:12:52 +00001233
Björn Stenberg6c33c512004-09-19 21:58:37 +00001234 case SETTINGS_CANCEL:
1235 lcd_clear_display();
1236 lcd_puts(0,1,str(LANG_RESET_DONE_CANCEL));
1237 done = true;
1238 break;
Robert Hakea8a4cf2002-10-14 09:12:52 +00001239
Björn Stenberg6c33c512004-09-19 21:58:37 +00001240 default:
1241 if(default_event_handler(button) == SYS_USB_CONNECTED)
1242 return true;
Robert Hakea8a4cf2002-10-14 09:12:52 +00001243 }
Justin Heiner2f9b54b2002-09-06 07:00:20 +00001244 }
Robert Hakea8a4cf2002-10-14 09:12:52 +00001245
1246 lcd_puts(0,0,str(LANG_RESET_DONE_SETTING));
1247 lcd_update();
1248 sleep(HZ);
1249 return false;
Justin Heiner2f9b54b2002-09-06 07:00:20 +00001250}
1251
Björn Stenbergb1b8bd42002-09-24 17:22:12 +00001252static bool fileview_settings_menu(void)
Eric Linenbergc5b645b2002-09-05 04:42:12 +00001253{
1254 int m;
Björn Stenbergb1b8bd42002-09-24 17:22:12 +00001255 bool result;
Eric Linenbergc5b645b2002-09-05 04:42:12 +00001256
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001257 static const struct menu_item items[] = {
1258 { ID2P(LANG_SORT_CASE), sort_case },
1259 { ID2P(LANG_SORT_DIR), sort_dir },
1260 { ID2P(LANG_SORT_FILE), sort_file },
1261 { ID2P(LANG_FILTER), dir_filter },
1262 { ID2P(LANG_FOLLOW), browse_current },
1263 { ID2P(LANG_SHOW_ICONS), show_icons },
Eric Linenbergc5b645b2002-09-05 04:42:12 +00001264 };
1265
Linus Nielsen Feltzing77936e62004-03-16 13:44:56 +00001266 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
1267 NULL, NULL, NULL);
Eric Linenbergc5b645b2002-09-05 04:42:12 +00001268 result = menu_run(m);
1269 menu_exit(m);
1270 return result;
1271}
1272
Robert Hak65002e82002-12-12 16:56:19 +00001273
1274static bool scroll_settings_menu(void)
1275{
1276 int m;
1277 bool result;
1278
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001279 static const struct menu_item items[] = {
1280 { ID2P(LANG_SCROLL_SPEED), scroll_speed },
1281 { ID2P(LANG_SCROLL_DELAY), scroll_delay },
Robert Hak65002e82002-12-12 16:56:19 +00001282#ifdef HAVE_LCD_BITMAP
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001283 { ID2P(LANG_SCROLL_STEP), scroll_step },
Robert Hak65002e82002-12-12 16:56:19 +00001284#endif
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001285 { ID2P(LANG_BIDIR_SCROLL), bidir_limit },
Kjell Ericson53f156a2003-05-22 06:42:14 +00001286#ifdef HAVE_LCD_CHARCELLS
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001287 { ID2P(LANG_JUMP_SCROLL), jump_scroll },
1288 { ID2P(LANG_JUMP_SCROLL_DELAY), jump_scroll_delay },
Kjell Ericson53f156a2003-05-22 06:42:14 +00001289#endif
Robert Hak65002e82002-12-12 16:56:19 +00001290 };
1291
Linus Nielsen Feltzing77936e62004-03-16 13:44:56 +00001292 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
1293 NULL, NULL, NULL);
Robert Hak65002e82002-12-12 16:56:19 +00001294 result = menu_run(m);
1295 menu_exit(m);
1296 return result;
1297}
1298
Björn Stenbergfe375a02004-01-14 14:42:31 +00001299static bool lcd_settings_menu(void)
1300{
1301 int m;
1302 bool result;
1303
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001304 static const struct menu_item items[] = {
Jörg Hohensohnfee86172004-12-18 10:29:47 +00001305#ifdef CONFIG_BACKLIGHT
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001306 { ID2P(LANG_BACKLIGHT), backlight_timer },
Jörg Hohensohnfee86172004-12-18 10:29:47 +00001307#ifdef HAVE_CHARGING
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001308 { ID2P(LANG_BACKLIGHT_ON_WHEN_CHARGING), backlight_on_when_charging },
Jens Arnolda1a08d02004-10-09 19:56:27 +00001309#endif
Jörg Hohensohnfee86172004-12-18 10:29:47 +00001310 { ID2P(LANG_CAPTION_BACKLIGHT), caption_backlight },
Jens Arnold61b9d342005-06-20 17:03:09 +00001311#if CONFIG_BACKLIGHT == BL_IRIVER
1312 { ID2P(LANG_BACKLIGHT_FADE_IN), backlight_fade_in },
1313 { ID2P(LANG_BACKLIGHT_FADE_OUT), backlight_fade_out },
1314#endif
Jörg Hohensohnfee86172004-12-18 10:29:47 +00001315#endif /* CONFIG_BACKLIGHT */
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001316 { ID2P(LANG_CONTRAST), contrast },
Björn Stenbergfe375a02004-01-14 14:42:31 +00001317#ifdef HAVE_LCD_BITMAP
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001318 { ID2P(LANG_INVERT), invert },
1319 { ID2P(LANG_FLIP_DISPLAY), flip_display },
1320 { ID2P(LANG_INVERT_CURSOR), invert_cursor },
Björn Stenbergfe375a02004-01-14 14:42:31 +00001321#endif
1322 };
1323
Linus Nielsen Feltzing77936e62004-03-16 13:44:56 +00001324 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
1325 NULL, NULL, NULL);
Björn Stenbergfe375a02004-01-14 14:42:31 +00001326 result = menu_run(m);
1327 menu_exit(m);
1328 return result;
1329}
1330
Christian Gmeiner7c1879b2005-04-15 12:08:49 +00001331#ifdef HAVE_REMOTE_LCD
1332static bool lcd_remote_settings_menu(void)
1333{
1334 int m;
1335 bool result;
1336
1337 static const struct menu_item items[] = {
Christian Gmeiner7477c092005-05-30 00:00:22 +00001338 { ID2P(LANG_BACKLIGHT), remote_backlight_timer },
Christian Gmeiner7c1879b2005-04-15 12:08:49 +00001339 { ID2P(LANG_CONTRAST), remote_contrast },
1340 { ID2P(LANG_INVERT), remote_invert },
Jens Arnoldbd1bb5f2005-06-17 21:43:00 +00001341 { ID2P(LANG_FLIP_DISPLAY), remote_flip_display },
1342/* { ID2P(LANG_INVERT_CURSOR), invert_cursor },*/
Christian Gmeiner7c1879b2005-04-15 12:08:49 +00001343 };
1344
1345 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
1346 NULL, NULL, NULL);
1347 result = menu_run(m);
1348 menu_exit(m);
1349 return result;
1350}
1351#endif
1352
Björn Stenbergfe375a02004-01-14 14:42:31 +00001353#ifdef HAVE_LCD_BITMAP
1354static bool bars_settings_menu(void)
1355{
1356 int m;
1357 bool result;
1358
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001359 static const struct menu_item items[] = {
1360 { ID2P(LANG_SCROLL_BAR), scroll_bar },
1361 { ID2P(LANG_STATUS_BAR), status_bar },
Jens Arnold1f0908d2004-10-09 20:54:15 +00001362#if CONFIG_KEYPAD == RECORDER_PAD
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001363 { ID2P(LANG_BUTTON_BAR), button_bar },
Jens Arnold1f0908d2004-10-09 20:54:15 +00001364#endif
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001365 { ID2P(LANG_VOLUME_DISPLAY), volume_type },
Jens Arnold9d42e2b2005-01-30 13:48:44 +00001366 { ID2P(LANG_BATTERY_DISPLAY), battery_display },
Björn Stenbergfe375a02004-01-14 14:42:31 +00001367 };
1368
Linus Nielsen Feltzing77936e62004-03-16 13:44:56 +00001369 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
1370 NULL, NULL, NULL);
Björn Stenbergfe375a02004-01-14 14:42:31 +00001371 result = menu_run(m);
1372 menu_exit(m);
1373 return result;
1374}
1375#endif
Robert Hak65002e82002-12-12 16:56:19 +00001376
1377
Björn Stenbergb1b8bd42002-09-24 17:22:12 +00001378static bool display_settings_menu(void)
Eric Linenbergc5b645b2002-09-05 04:42:12 +00001379{
1380 int m;
Björn Stenbergb1b8bd42002-09-24 17:22:12 +00001381 bool result;
Eric Linenbergc5b645b2002-09-05 04:42:12 +00001382
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001383 static const struct menu_item items[] = {
Linus Nielsen Feltzingbb572c42002-09-27 09:31:31 +00001384#ifdef HAVE_LCD_BITMAP
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001385 { ID2P(LANG_CUSTOM_FONT), font_browse },
Linus Nielsen Feltzingbb572c42002-09-27 09:31:31 +00001386#endif
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001387 { ID2P(LANG_WHILE_PLAYING), custom_wps_browse },
1388 { ID2P(LANG_LCD_MENU), lcd_settings_menu },
Christian Gmeiner7c1879b2005-04-15 12:08:49 +00001389#ifdef HAVE_REMOTE_LCD
1390 { ID2P(LANG_LCD_REMOTE_MENU), lcd_remote_settings_menu },
1391#endif
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001392 { ID2P(LANG_SCROLL_MENU), scroll_settings_menu },
Björn Stenbergfe375a02004-01-14 14:42:31 +00001393#ifdef HAVE_LCD_BITMAP
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001394 { ID2P(LANG_BARS_MENU), bars_settings_menu },
1395 { ID2P(LANG_PM_MENU), peak_meter_menu },
Björn Stenbergfe375a02004-01-14 14:42:31 +00001396#endif
Eric Linenbergc5b645b2002-09-05 04:42:12 +00001397 };
Björn Stenbergfe375a02004-01-14 14:42:31 +00001398
Linus Nielsen Feltzing77936e62004-03-16 13:44:56 +00001399 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
1400 NULL, NULL, NULL);
Eric Linenbergc5b645b2002-09-05 04:42:12 +00001401 result = menu_run(m);
1402 menu_exit(m);
1403 return result;
1404}
1405
Björn Stenbergfe375a02004-01-14 14:42:31 +00001406
1407static bool firmware_browse(void)
1408{
1409 return rockbox_browse(ROCKBOX_DIR, SHOW_MOD);
1410}
1411
1412static bool battery_settings_menu(void)
1413{
1414 int m;
1415 bool result;
1416
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001417 static const struct menu_item items[] = {
Björn Stenbergfe375a02004-01-14 14:42:31 +00001418#ifndef SIMULATOR
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001419 { ID2P(LANG_BATTERY_CAPACITY), battery_capacity },
Jens Arnold91846a12005-01-30 16:25:46 +00001420#if BATTERY_TYPES_COUNT > 1
1421 { ID2P(LANG_BATTERY_TYPE), battery_type },
1422#endif
Jörg Hohensohn00898c62004-06-14 07:23:48 +00001423#else
1424#ifndef HAVE_CHARGE_CTRL
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001425 { "Dummy", NULL }, /* to have an entry at all, in the simulator */
Jörg Hohensohn00898c62004-06-14 07:23:48 +00001426#endif
Björn Stenbergfe375a02004-01-14 14:42:31 +00001427#endif
1428 };
1429
Linus Nielsen Feltzing77936e62004-03-16 13:44:56 +00001430 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
1431 NULL, NULL, NULL);
Björn Stenbergfe375a02004-01-14 14:42:31 +00001432 result = menu_run(m);
1433 menu_exit(m);
1434 return result;
1435}
1436
Jens Arnolddd937dc2004-10-09 22:04:47 +00001437#ifndef HAVE_MMC
Björn Stenbergfe375a02004-01-14 14:42:31 +00001438static bool disk_settings_menu(void)
1439{
1440 int m;
1441 bool result;
1442
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001443 static const struct menu_item items[] = {
1444 { ID2P(LANG_SPINDOWN), spindown },
Björn Stenbergfe375a02004-01-14 14:42:31 +00001445#ifdef HAVE_ATA_POWER_OFF
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001446 { ID2P(LANG_POWEROFF), poweroff },
Björn Stenbergfe375a02004-01-14 14:42:31 +00001447#endif
1448 };
1449
Linus Nielsen Feltzing77936e62004-03-16 13:44:56 +00001450 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
1451 NULL, NULL, NULL);
Björn Stenbergfe375a02004-01-14 14:42:31 +00001452 result = menu_run(m);
1453 menu_exit(m);
1454 return result;
1455}
Jens Arnolddd937dc2004-10-09 22:04:47 +00001456#endif /* !HAVE_MMC */
Björn Stenbergfe375a02004-01-14 14:42:31 +00001457
Jörg Hohensohn24c7c042004-09-10 10:51:54 +00001458#ifdef HAVE_RTC
Björn Stenbergfe375a02004-01-14 14:42:31 +00001459static bool time_settings_menu(void)
1460{
1461 int m;
1462 bool result;
1463
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001464 static const struct menu_item items[] = {
1465 { ID2P(LANG_TIME), timedate_set },
1466 { ID2P(LANG_TIMEFORMAT), timeformat_set },
Björn Stenbergfe375a02004-01-14 14:42:31 +00001467 };
1468
Linus Nielsen Feltzing77936e62004-03-16 13:44:56 +00001469 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
1470 NULL, NULL, NULL);
Björn Stenbergfe375a02004-01-14 14:42:31 +00001471 result = menu_run(m);
1472 menu_exit(m);
1473 return result;
1474}
1475#endif
1476
Christi Scarboroughd0ec0ce2005-07-04 09:24:31 +00001477bool manage_settings_menu(void)
Björn Stenbergfe375a02004-01-14 14:42:31 +00001478{
1479 int m;
1480 bool result;
1481
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001482 static const struct menu_item items[] = {
1483 { ID2P(LANG_CUSTOM_CFG), custom_cfg_browse },
1484 { ID2P(LANG_FIRMWARE), firmware_browse },
1485 { ID2P(LANG_RESET), reset_settings },
1486 { ID2P(LANG_SAVE_SETTINGS), settings_save_config },
Björn Stenbergfe375a02004-01-14 14:42:31 +00001487 };
1488
Linus Nielsen Feltzing77936e62004-03-16 13:44:56 +00001489 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
1490 NULL, NULL, NULL);
Björn Stenbergfe375a02004-01-14 14:42:31 +00001491 result = menu_run(m);
1492 menu_exit(m);
1493 return result;
1494}
1495
1496static bool limits_settings_menu(void)
1497{
1498 int m;
1499 bool result;
1500
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001501 static const struct menu_item items[] = {
1502 { ID2P(LANG_MAX_FILES_IN_DIR), max_files_in_dir },
1503 { ID2P(LANG_MAX_FILES_IN_PLAYLIST), max_files_in_playlist },
Björn Stenbergfe375a02004-01-14 14:42:31 +00001504 };
1505
Linus Nielsen Feltzing77936e62004-03-16 13:44:56 +00001506 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
1507 NULL, NULL, NULL);
Björn Stenbergfe375a02004-01-14 14:42:31 +00001508 result = menu_run(m);
1509 menu_exit(m);
1510 return result;
1511}
1512
1513
Björn Stenbergb1b8bd42002-09-24 17:22:12 +00001514static bool system_settings_menu(void)
Eric Linenbergc5b645b2002-09-05 04:42:12 +00001515{
1516 int m;
Björn Stenbergb1b8bd42002-09-24 17:22:12 +00001517 bool result;
Eric Linenbergc5b645b2002-09-05 04:42:12 +00001518
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001519 static const struct menu_item items[] = {
1520 { ID2P(LANG_BATTERY_MENU), battery_settings_menu },
Jens Arnolddd937dc2004-10-09 22:04:47 +00001521#ifndef HAVE_MMC
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001522 { ID2P(LANG_DISK_MENU), disk_settings_menu },
Jens Arnolddd937dc2004-10-09 22:04:47 +00001523#endif
Björn Stenbergfe375a02004-01-14 14:42:31 +00001524#ifdef HAVE_RTC
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001525 { ID2P(LANG_TIME_MENU), time_settings_menu },
Björn Stenbergfe375a02004-01-14 14:42:31 +00001526#endif
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001527 { ID2P(LANG_POWEROFF_IDLE), poweroff_idle_timer },
1528 { ID2P(LANG_SLEEP_TIMER), sleeptimer_screen },
Björn Stenberga73cc6a2004-01-15 08:25:42 +00001529#ifdef HAVE_ALARM_MOD
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001530 { ID2P(LANG_ALARM_MOD_ALARM_MENU), alarm_screen },
Björn Stenberga73cc6a2004-01-15 08:25:42 +00001531#endif
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001532 { ID2P(LANG_LIMITS_MENU), limits_settings_menu },
Jörg Hohensohn593cc002004-09-28 22:13:26 +00001533#if CONFIG_HWCODEC == MAS3507D
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001534 { ID2P(LANG_LINE_IN), line_in },
Linus Nielsen Feltzingc22b4112003-11-03 23:36:36 +00001535#endif
Jens Arnoldccfa4cd2004-10-10 01:25:32 +00001536#ifdef HAVE_CHARGING
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001537 { ID2P(LANG_CAR_ADAPTER_MODE), car_adapter_mode },
Jens Arnoldccfa4cd2004-10-10 01:25:32 +00001538#endif
Eric Linenbergc5b645b2002-09-05 04:42:12 +00001539 };
Björn Stenbergfe375a02004-01-14 14:42:31 +00001540
Linus Nielsen Feltzing77936e62004-03-16 13:44:56 +00001541 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
1542 NULL, NULL, NULL);
Eric Linenbergc5b645b2002-09-05 04:42:12 +00001543 result = menu_run(m);
1544 menu_exit(m);
1545 return result;
1546}
Björn Stenberg94afb542002-09-07 12:28:46 +00001547
Björn Stenbergb1b8bd42002-09-24 17:22:12 +00001548bool settings_menu(void)
Björn Stenberg94afb542002-09-07 12:28:46 +00001549{
1550 int m;
Björn Stenbergb1b8bd42002-09-24 17:22:12 +00001551 bool result;
Björn Stenberg94afb542002-09-07 12:28:46 +00001552
Jörg Hohensohnb1403ee2004-07-23 23:01:20 +00001553 static const struct menu_item items[] = {
1554 { ID2P(LANG_PLAYBACK), playback_settings_menu },
1555 { ID2P(LANG_FILE), fileview_settings_menu },
1556 { ID2P(LANG_DISPLAY), display_settings_menu },
1557 { ID2P(LANG_SYSTEM), system_settings_menu },
1558 { ID2P(LANG_BOOKMARK_SETTINGS),bookmark_settings_menu },
1559 { ID2P(LANG_LANGUAGE), language_browse },
1560 { ID2P(LANG_VOICE), voice_menu },
Björn Stenberg94afb542002-09-07 12:28:46 +00001561 };
1562
Linus Nielsen Feltzing77936e62004-03-16 13:44:56 +00001563 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
1564 NULL, NULL, NULL);
Björn Stenberg94afb542002-09-07 12:28:46 +00001565 result = menu_run(m);
1566 menu_exit(m);
1567 return result;
1568}