1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 Robert Hak
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
32 #include "settings_menu.h"
33 #include "backlight.h"
34 #include "playlist.h" /* for playlist_shuffle */
35 #include "fat.h" /* For dotfile settings */
36 #include "powermgmt.h"
41 static Menu
show_hidden_files(void)
43 set_bool_options( str(LANG_HIDDEN
), &global_settings
.show_hidden_files
,
44 str(LANG_HIDDEN_SHOW
), str(LANG_HIDDEN_HIDE
) );
48 static Menu
contrast(void)
50 set_int( str(LANG_CONTRAST
), "", &global_settings
.contrast
,
51 lcd_set_contrast
, 1, 0, MAX_CONTRAST_SETTING
);
55 #ifndef HAVE_RECORDER_KEYPAD
56 static Menu
shuffle(void)
58 set_bool( str(LANG_SHUFFLE
), &global_settings
.playlist_shuffle
);
63 static Menu
play_selected(void)
65 set_bool( str(LANG_PLAY_SELECTED
), &global_settings
.play_selected
);
69 static Menu
mp3_filter(void)
71 set_bool( str(LANG_MP3FILTER
), &global_settings
.mp3filter
);
75 static Menu
sort_case(void)
77 set_bool( str(LANG_SORT_CASE
), &global_settings
.sort_case
);
81 static Menu
resume(void)
83 char* names
[] = { str(LANG_OFF
),
84 str(LANG_RESUME_SETTING_ASK
),
86 set_option( str(LANG_RESUME
), &global_settings
.resume
, names
, 3, NULL
);
90 static Menu
backlight_timer(void)
92 char* names
[] = { str(LANG_OFF
), str(LANG_ON
),
93 "1s ", "2s ", "3s ", "4s ", "5s ",
94 "6s ", "7s ", "8s ", "9s ", "10s",
95 "15s", "20s", "25s", "30s", "45s",
97 set_option(str(LANG_BACKLIGHT
), &global_settings
.backlight
, names
, 19,
102 static Menu
scroll_speed(void)
104 set_int(str(LANG_SCROLL
), "", &global_settings
.scroll_speed
,
105 &lcd_scroll_speed
, 1, 1, 30 );
109 #ifdef HAVE_CHARGE_CTRL
110 static Menu
deep_discharge(void)
112 set_bool( str(LANG_DISCHARGE
), &global_settings
.discharge
);
113 charge_restart_level
= global_settings
.discharge
?
114 CHARGE_RESTART_LO
: CHARGE_RESTART_HI
;
119 #ifdef HAVE_LCD_BITMAP
120 static Menu
timedate_set(void)
122 int timedate
[7]; /* hour,minute,second,year,month,day,dayofweek */
125 timedate
[0] = rtc_read(0x03); /* hour */
126 timedate
[1] = rtc_read(0x02); /* minute */
127 timedate
[2] = rtc_read(0x01); /* second */
128 timedate
[3] = rtc_read(0x07); /* year */
129 timedate
[4] = rtc_read(0x06); /* month */
130 timedate
[5] = rtc_read(0x05); /* day */
131 /* day of week not read, calculated */
133 timedate
[0] = ((timedate
[0] & 0x30) >> 4) * 10 + (timedate
[0] & 0x0f);
135 timedate
[1] = ((timedate
[1] & 0x70) >> 4) * 10 + (timedate
[1] & 0x0f);
137 timedate
[2] = ((timedate
[2] & 0x70) >> 4) * 10 + (timedate
[2] & 0x0f);
139 timedate
[3] = ((timedate
[3] & 0xf0) >> 4) * 10 + (timedate
[3] & 0x0f);
141 timedate
[4] = ((timedate
[4] & 0x10) >> 4) * 10 + (timedate
[4] & 0x0f);
143 timedate
[5] = ((timedate
[5] & 0x30) >> 4) * 10 + (timedate
[5] & 0x0f);
144 #else /* SIMULATOR */
159 set_time(str(LANG_TIME
),timedate
);
162 if(timedate
[0] != -1) {
164 timedate
[0] = ((timedate
[0]/10) << 4 | timedate
[0]%10) & 0x3f;
166 timedate
[1] = ((timedate
[1]/10) << 4 | timedate
[1]%10) & 0x7f;
168 timedate
[2] = ((timedate
[2]/10) << 4 | timedate
[2]%10) & 0x7f;
170 timedate
[3] = ((timedate
[3]/10) << 4 | timedate
[3]%10) & 0xff;
172 timedate
[4] = ((timedate
[4]/10) << 4 | timedate
[4]%10) & 0x1f;
174 timedate
[5] = ((timedate
[5]/10) << 4 | timedate
[5]%10) & 0x3f;
176 rtc_write(0x03, timedate
[0] | (rtc_read(0x03) & 0xc0)); /* hour */
177 rtc_write(0x02, timedate
[1] | (rtc_read(0x02) & 0x80)); /* minute */
178 rtc_write(0x01, timedate
[2] | (rtc_read(0x01) & 0x80)); /* second */
179 rtc_write(0x07, timedate
[3]); /* year */
180 rtc_write(0x06, timedate
[4] | (rtc_read(0x06) & 0xe0)); /* month */
181 rtc_write(0x05, timedate
[5] | (rtc_read(0x05) & 0xc0)); /* day */
182 rtc_write(0x04, timedate
[6] | (rtc_read(0x04) & 0xf8)); /* dayofweek */
183 rtc_write(0x00, 0x00); /* 0.1 + 0.01 seconds */
190 static Menu
spindown(void)
192 set_int(str(LANG_SPINDOWN
), "s", &global_settings
.disk_spindown
,
193 ata_spindown
, 1, 3, 254 );
197 static Menu
ff_rewind_min_step(void)
199 char* names
[] = { "1s", "2s", "3s", "4s",
200 "5s", "6s", "8s", "10s",
201 "15s", "20s", "25s", "30s",
203 set_option(str(LANG_FFRW_STEP
), &global_settings
.ff_rewind_min_step
,
208 static Menu
ff_rewind_accel(void)
210 char* names
[] = { str(LANG_OFF
), "2x/1s", "2x/2s", "2x/3s",
211 "2x/4s", "2x/5s", "2x/6s", "2x/7s",
212 "2x/8s", "2x/9s", "2x/10s", "2x/11s",
213 "2x/12s", "2x/13s", "2x/14s", "2x/15s", };
214 set_option(str(LANG_FFRW_ACCEL
), &global_settings
.ff_rewind_accel
,
219 static Menu
browse_current(void)
221 set_bool( str(LANG_FOLLOW
), &global_settings
.browse_current
);
225 Menu
playback_settings_menu(void)
230 struct menu_items items
[] = {
231 #ifndef HAVE_RECORDER_KEYPAD
232 { str(LANG_SHUFFLE
), shuffle
},
234 { str(LANG_PLAY_SELECTED
), play_selected
},
235 { str(LANG_RESUME
), resume
},
236 { str(LANG_FFRW_STEP
), ff_rewind_min_step
},
237 { str(LANG_FFRW_ACCEL
), ff_rewind_accel
},
240 bool old_shuffle
= global_settings
.playlist_shuffle
;
242 m
=menu_init( items
, sizeof items
/ sizeof(struct menu_items
) );
243 result
= menu_run(m
);
246 if (old_shuffle
!= global_settings
.playlist_shuffle
)
248 if (global_settings
.playlist_shuffle
)
250 randomise_playlist(current_tick
);
260 static Menu
reset_settings(void)
265 #ifdef HAVE_LCD_CHARCELLS
266 lcd_puts(0,0,str(LANG_RESET_ASK_PLAYER
));
267 lcd_puts(0,1,str(LANG_RESET_CONFIRM_PLAYER
));
269 lcd_puts(0,0,str(LANG_RESET_ASK_RECORDER
));
270 lcd_puts(0,1,str(LANG_RESET_CONFIRM_RECORDER
));
271 lcd_puts(0,2,str(LANG_RESET_CANCEL_RECORDER
));
274 button
= button_get(true);
275 if (button
== BUTTON_PLAY
) {
278 lcd_puts(0,0,str(LANG_RESET_DONE_SETTING
));
279 lcd_puts(0,1,str(LANG_RESET_DONE_CLEAR
));
285 lcd_puts(0,0,str(LANG_RESET_DONE_CANCEL
));
292 static Menu
fileview_settings_menu(void)
297 struct menu_items items
[] = {
298 { str(LANG_CASE_MENU
), sort_case
},
299 { str(LANG_MP3FILTER
), mp3_filter
},
300 { str(LANG_HIDDEN
), show_hidden_files
},
301 { str(LANG_FOLLOW
), browse_current
},
304 m
=menu_init( items
, sizeof items
/ sizeof(struct menu_items
) );
305 result
= menu_run(m
);
310 static Menu
display_settings_menu(void)
315 struct menu_items items
[] = {
316 { str(LANG_SCROLL_MENU
), scroll_speed
},
317 { str(LANG_BACKLIGHT
), backlight_timer
},
318 { str(LANG_CONTRAST
), contrast
},
321 m
=menu_init( items
, sizeof items
/ sizeof(struct menu_items
) );
322 result
= menu_run(m
);
327 static Menu
system_settings_menu(void)
332 struct menu_items items
[] = {
333 { str(LANG_SPINDOWN
), spindown
},
334 #ifdef HAVE_CHARGE_CTRL
335 { str(LANG_DISCHARGE
), deep_discharge
},
337 #ifdef HAVE_LCD_BITMAP
338 { str(LANG_TIME
), timedate_set
},
340 { str(LANG_RESET
), reset_settings
},
343 m
=menu_init( items
, sizeof items
/ sizeof(struct menu_items
) );
344 result
= menu_run(m
);
349 Menu
settings_menu(void)
354 struct menu_items items
[] = {
355 { str(LANG_PLAYBACK
), playback_settings_menu
},
356 { str(LANG_FILE
), fileview_settings_menu
},
357 { str(LANG_DISPLAY
), display_settings_menu
},
358 { str(LANG_SYSTEM
), system_settings_menu
},
361 m
=menu_init( items
, sizeof items
/ sizeof(struct menu_items
) );
362 result
= menu_run(m
);