1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 by wavey@wavey.org
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 #ifndef __SETTINGS_H__
21 #define __SETTINGS_H__
26 #include "timefuncs.h"
28 #define ROCKBOX_DIR "/.rockbox"
29 #define FONT_DIR "/fonts"
30 #define LANG_DIR "/langs"
31 #define PLUGIN_DIR ROCKBOX_DIR"/rocks"
32 #define REC_BASE_DIR "/recordings"
34 #define MAX_FILENAME 20
36 /* button definitions */
37 #if CONFIG_KEYPAD == RECORDER_PAD
38 #define SETTINGS_INC BUTTON_UP
39 #define SETTINGS_DEC BUTTON_DOWN
40 #define SETTINGS_OK BUTTON_PLAY
41 #define SETTINGS_OK2 BUTTON_LEFT
42 #define SETTINGS_CANCEL BUTTON_OFF
43 #define SETTINGS_CANCEL2 BUTTON_F1
45 #elif CONFIG_KEYPAD == PLAYER_PAD
46 #define SETTINGS_INC BUTTON_RIGHT
47 #define SETTINGS_DEC BUTTON_LEFT
48 #define SETTINGS_OK BUTTON_PLAY
49 #define SETTINGS_CANCEL BUTTON_STOP
50 #define SETTINGS_CANCEL2 BUTTON_MENU
52 #elif CONFIG_KEYPAD == ONDIO_PAD
53 #define SETTINGS_INC BUTTON_UP
54 #define SETTINGS_DEC BUTTON_DOWN
55 #define SETTINGS_OK BUTTON_RIGHT
56 #define SETTINGS_OK2 BUTTON_LEFT
57 #define SETTINGS_CANCEL BUTTON_MENU
65 #define RESUME_ASK_ONCE 2
69 #define BOOKMARK_YES 1
70 #define BOOKMARK_ASK 2
71 #define BOOKMARK_UNIQUE_ONLY 2
72 #define BOOKMARK_RECENT_ONLY_YES 3
73 #define BOOKMARK_RECENT_ONLY_ASK 4
74 #define FF_REWIND_1000 0
75 #define FF_REWIND_2000 1
76 #define FF_REWIND_3000 2
77 #define FF_REWIND_4000 3
78 #define FF_REWIND_5000 4
79 #define FF_REWIND_6000 5
80 #define FF_REWIND_8000 6
81 #define FF_REWIND_10000 7
82 #define FF_REWIND_15000 8
83 #define FF_REWIND_20000 9
84 #define FF_REWIND_25000 10
85 #define FF_REWIND_30000 11
86 #define FF_REWIND_45000 12
87 #define FF_REWIND_60000 13
90 /* These define "virtual pointers", which could either be a literal string,
91 or a mean a string ID if the pointer is in a certain range.
92 This helps to save space for menus and options. */
94 #define VIRT_SIZE 0xFFFF /* more than enough for our string ID range */
96 /* a space which is defined in stubs.c */
97 extern unsigned char vp_dummy
[VIRT_SIZE
];
98 #define VIRT_PTR vp_dummy
100 /* a location where we won't store strings, 0 is the fastest */
101 #define VIRT_PTR ((unsigned char*)0)
104 /* form a "virtual pointer" out of a language ID */
105 #define ID2P(id) (VIRT_PTR + id)
107 /* resolve a pointer which could be a virtualized ID or a literal */
108 #define P2STR(p) ((p>=VIRT_PTR && p<=VIRT_PTR+VIRT_SIZE) ? str(p-VIRT_PTR) : p)
110 /* get the string ID from a virtual pointer, -1 if not virtual */
111 #define P2ID(p) ((p>=VIRT_PTR && p<=VIRT_PTR+VIRT_SIZE) ? p-VIRT_PTR : -1)
118 int volume
; /* audio output volume: 0-100 0=off 100=max */
119 int balance
; /* stereo balance: 0-100 0=left 50=bal 100=right */
120 int bass
; /* bass eq: 0-100 0=off 100=max */
121 int treble
; /* treble eq: 0-100 0=low 100=high */
122 int loudness
; /* loudness eq: 0-100 0=off 100=max */
123 int avc
; /* auto volume correct: 0=off, 1=20ms, 2=2s 3=4s 4=8s */
124 int channel_config
; /* Stereo, Mono, Mono left, Mono right */
125 int mdb_strength
; /* 0-127dB */
126 int mdb_harmonics
; /* 0-100% */
127 int mdb_center
; /* 20-300Hz */
128 int mdb_shape
; /* 50-300Hz */
129 bool mdb_enable
; /* true/false */
130 bool superbass
; /* true/false */
132 int rec_quality
; /* 0-7 */
133 int rec_source
; /* 0=mic, 1=line, 2=S/PDIF */
134 int rec_frequency
; /* 0 = 44.1kHz
140 int rec_channels
; /* 0=Stereo, 1=Mono */
141 int rec_mic_gain
; /* 0-15 */
142 int rec_left_gain
; /* 0-15 */
143 int rec_right_gain
; /* 0-15 */
144 bool rec_editable
; /* true means that the bit reservoir is off */
146 /* note: timesplit setting is not saved */
147 int rec_timesplit
; /* 0 = off,
148 1 = 00:05, 2 = 00:10, 3 = 00:15, 4 = 00:30
149 5 = 01:00, 6 = 02:00, 7 = 04:00, 8 = 06:00
150 9 = 08:00, 10= 10:00, 11= 12:00, 12= 18:00,
153 int rec_prerecord_time
; /* In seconds, 0-30, 0 means OFF */
154 int rec_directory
; /* 0=base dir, 1=current dir */
156 /* device settings */
158 int contrast
; /* lcd contrast: 0-63 0=low 63=high */
159 bool invert
; /* invert display */
160 bool invert_cursor
; /* invert the current file in dir browser and menu
161 instead of using the default cursor */
162 bool flip_display
; /* turn display (and button layout) by 180 degrees */
163 int poweroff
; /* power off timer */
164 int backlight_timeout
; /* backlight off timeout: 0-18 0=never,
166 then according to timeout_values[] */
167 bool backlight_on_when_charging
;
168 bool discharge
; /* maintain charge of at least: false = 85%, true = 10% */
169 bool trickle_charge
; /* do trickle charging: 0=off, 1=on */
170 int battery_capacity
; /* in mAh */
172 /* resume settings */
174 int resume
; /* resume option: 0=off, 1=ask, 2=on */
175 int resume_index
; /* index in playlist (-1 for no active resume) */
176 int resume_first_index
; /* index of first track in playlist */
177 int resume_offset
; /* byte offset in mp3 file */
178 int resume_seed
; /* shuffle seed (-1=no resume shuffle 0=sorted
181 unsigned char font_file
[MAX_FILENAME
+1]; /* last font */
182 unsigned char wps_file
[MAX_FILENAME
+1]; /* last wps */
183 unsigned char lang_file
[MAX_FILENAME
+1]; /* last language */
187 int repeat_mode
; /* 0=off 1=repeat all 2=repeat one */
188 int dirfilter
; /* 0=display all, 1=only supported, 2=only music */
189 bool sort_case
; /* dir sort order: 0=case insensitive, 1=sensitive */
190 int volume_type
; /* how volume is displayed: 0=graphic, 1=percent */
191 int battery_type
; /* how battery is displayed: 0=graphic, 1=percent */
192 int timeformat
; /* time format: 0=24 hour clock, 1=12 hour clock */
193 int scroll_speed
; /* long texts scrolling speed: 1-30 */
194 bool playlist_shuffle
;
195 bool play_selected
; /* Plays selected file even in shuffle mode */
196 int ff_rewind_min_step
; /* FF/Rewind minimum step size */
197 int ff_rewind_accel
; /* FF/Rewind acceleration (in seconds per doubling) */
198 int disk_spindown
; /* time until disk spindown, in seconds (0=off) */
199 bool disk_poweroff
; /* whether to cut disk power after spindown or not */
200 int buffer_margin
; /* MP3 buffer watermark margin, in seconds */
202 int peak_meter_release
; /* units per read out */
203 int peak_meter_hold
; /* hold time for peak meter in 1/100 s */
204 int peak_meter_clip_hold
; /* hold time for clips */
205 bool peak_meter_dbfs
; /* show linear or dbfs values */
206 bool peak_meter_performance
; /* true: high performance, else save energy*/
207 int peak_meter_min
; /* range minimum */
208 int peak_meter_max
; /* range maximum */
209 bool car_adapter_mode
; /* 0=off 1=on */
211 /* show status bar */
212 bool statusbar
; /* 0=hide, 1=show */
214 /* show button bar */
215 bool buttonbar
; /* 0=hide, 1=show */
217 /* show scroll bar */
218 bool scrollbar
; /* 0=hide, 1=show */
220 /* goto current song when exiting WPS */
221 bool browse_current
; /* 1=goto current song,
222 0=goto previous location */
224 int runtime
; /* current runtime since last charge */
225 int topruntime
; /* top known runtime */
227 int bidir_limit
; /* bidir scroll length limit */
228 int scroll_delay
; /* delay (in 1/10s) before starting scroll */
229 int scroll_step
; /* pixels to advance per update */
231 /* auto bookmark settings */
232 int autoloadbookmark
; /* auto load option: 0=off, 1=ask, 2=on */
233 int autocreatebookmark
; /* auto create option: 0=off, 1=ask, 2=on */
234 int usemrb
; /* use MRB list: 0=No, 1=Yes*/
235 #ifdef HAVE_LCD_CHARCELLS
236 int jump_scroll
; /* Fast jump when scrolling */
237 int jump_scroll_delay
; /* Delay between jump scroll screens */
239 bool fade_on_stop
; /* fade on pause/unpause/stop */
240 bool caption_backlight
; /* turn on backlight at end and start of track */
243 int fm_freq_step
; /* Frequency step for manual tuning, in kHz */
244 bool fm_force_mono
; /* Forces Mono mode if true */
245 bool fm_full_range
; /* Enables full 10MHz-160MHz range if true, else
247 int last_frequency
; /* Last frequency for resuming, in FREQ_STEP units,
248 relative to MIN_FREQ */
251 int max_files_in_dir
; /* Max entries in directory (file browser) */
252 int max_files_in_playlist
; /* Max entries in playlist */
253 bool show_icons
; /* 0=hide 1=show */
254 int recursive_dir_insert
; /* should directories be inserted recursively */
256 bool line_in
; /* false=off, true=active */
258 bool id3_v1_first
; /* true = ID3V1 has prio over ID3V2 tag */
260 /* playlist viewer settings */
261 bool playlist_viewer_icons
; /* display icons on viewer */
262 bool playlist_viewer_indices
; /* display playlist indices on viewer */
263 int playlist_viewer_track_display
; /* how to display tracks in viewer */
265 /* voice UI settings */
266 bool talk_menu
; /* enable voice UI */
267 int talk_dir
; /* talkbox mode: 0=off 1=number 2=clip@enter 3=clip@hover */
268 int talk_file
; /* voice filename mode: 0=off, 1=number, other t.b.d. */
270 /* file browser sorting */
271 int sort_file
; /* 0=alpha, 1=date, 2=date (new first), 3=type */
272 int sort_dir
; /* 0=alpha, 1=date (old first), 2=date (new first) */
275 enum optiontype
{ INT
, BOOL
};
278 unsigned const char* string
;
284 void settings_calc_config_sector(void);
285 int settings_save(void);
286 void settings_load(int which
);
287 void settings_reset(void);
288 void sound_settings_apply(void);
289 void settings_apply(void);
290 void settings_apply_pm_range(void);
291 void settings_display(void);
293 bool settings_load_config(const char* file
);
294 bool settings_save_config(void);
295 bool set_bool_options(const char* string
, bool* variable
,
296 const char* yes_str
, int yes_voice
,
297 const char* no_str
, int no_voice
,
298 void (*function
)(bool));
300 bool set_bool(const char* string
, bool* variable
);
301 bool set_option(const char* string
, void* variable
, enum optiontype type
,
302 const struct opt_items
* options
, int numoptions
, void (*function
)(int));
303 bool set_int(const char* string
, const char* unit
, int voice_unit
, int* variable
,
304 void (*function
)(int), int step
, int min
, int max
);
305 bool set_time_screen(const char* string
, struct tm
*tm
);
306 int read_line(int fd
, char* buffer
, int buffer_size
);
307 void set_file(char* filename
, char* setting
, int maxlen
);
309 #if CONFIG_HWCODEC == MAS3587F
310 unsigned int rec_timesplit_seconds(void);
313 /* global settings */
314 extern struct user_settings global_settings
;
315 /* name of directory where configuration, fonts and other data
316 * files are stored */
317 extern long lasttime
;
319 /* Recording base directory */
320 extern const char rec_base_directory
[];
324 #ifdef HAVE_LCD_CHARCELLS
325 #define MAX_CONTRAST_SETTING 31
326 #define DEFAULT_CONTRAST_SETTING 30
328 #define MAX_CONTRAST_SETTING 63
329 #define DEFAULT_CONTRAST_SETTING 38
331 #define MIN_CONTRAST_SETTING 5
333 /* argument bits for settings_load() */
334 #define SETTINGS_RTC 1 /* only the settings from the RTC nonvolatile RAM */
335 #define SETTINGS_HD 2 /* only the settings fron the disk sector */
336 #define SETTINGS_ALL 3 /* both */
338 /* repeat mode options */
339 enum { REPEAT_OFF
, REPEAT_ALL
, REPEAT_ONE
, NUM_REPEAT_MODES
};
341 /* dir filter options */
342 /* Note: Any new filter modes need to be added before NUM_FILTER_MODES.
343 * Any new rockbox browse filter modes (accessible through the menu)
344 * must be added after NUM_FILTER_MODES. */
345 enum { SHOW_ALL
, SHOW_SUPPORTED
, SHOW_MUSIC
, SHOW_PLAYLIST
, NUM_FILTER_MODES
,
346 SHOW_WPS
, SHOW_CFG
, SHOW_LNG
, SHOW_MOD
, SHOW_FONT
, SHOW_PLUGINS
};
348 /* recursive dir insert options */
349 enum { RECURSE_OFF
, RECURSE_ON
, RECURSE_ASK
};
351 #endif /* __SETTINGS_H__ */