Experimenting with USER
[kugel-rb.git] / apps / settings.h
blob8d602f17ac284636933584941ebd02c92f8e0470
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
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__
23 #include <stdbool.h>
24 #include "config.h"
25 #include "file.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 /* data structures */
38 #define RESUME_OFF 0
39 #define RESUME_ASK 1
40 #define RESUME_ASK_ONCE 2
41 #define RESUME_ON 3
43 #define BOOKMARK_NO 0
44 #define BOOKMARK_YES 1
45 #define BOOKMARK_ASK 2
46 #define BOOKMARK_UNIQUE_ONLY 2
47 #define BOOKMARK_RECENT_ONLY_YES 3
48 #define BOOKMARK_RECENT_ONLY_ASK 4
49 #define FF_REWIND_1000 0
50 #define FF_REWIND_2000 1
51 #define FF_REWIND_3000 2
52 #define FF_REWIND_4000 3
53 #define FF_REWIND_5000 4
54 #define FF_REWIND_6000 5
55 #define FF_REWIND_8000 6
56 #define FF_REWIND_10000 7
57 #define FF_REWIND_15000 8
58 #define FF_REWIND_20000 9
59 #define FF_REWIND_25000 10
60 #define FF_REWIND_30000 11
61 #define FF_REWIND_45000 12
62 #define FF_REWIND_60000 13
65 struct user_settings
67 /* audio settings */
69 int volume; /* audio output volume: 0-100 0=off 100=max */
70 int balance; /* stereo balance: 0-100 0=left 50=bal 100=right */
71 int bass; /* bass eq: 0-100 0=off 100=max */
72 int treble; /* treble eq: 0-100 0=low 100=high */
73 int loudness; /* loudness eq: 0-100 0=off 100=max */
74 int bass_boost; /* bass boost eq: 0-100 0=off 100=max */
75 int avc; /* auto volume correct: 0=disable, 1=2s 2=4s 3=8s */
76 int channel_config; /* Stereo, Mono, Mono left, Mono right */
78 int rec_quality; /* 0-7 */
79 int rec_source; /* 0=mic, 1=line, 2=S/PDIF */
80 int rec_frequency; /* 0 = 44.1kHz
81 1 = 48kHz
82 2 = 32kHz
83 3 = 22.05kHz
84 4 = 24kHz
85 5 = 16kHz */
86 int rec_channels; /* 0=Stereo, 1=Mono */
87 int rec_mic_gain; /* 0-15 */
88 int rec_left_gain; /* 0-15 */
89 int rec_right_gain; /* 0-15 */
90 bool rec_editable; /* true means that the bit reservoir is off */
92 /* note: timesplit setting is not saved */
93 int rec_timesplit; /* 0 = off,
94 1 = 00:05, 2 = 00:10, 3 = 00:15, 4 = 00:30
95 5 = 01:00, 6 = 02:00, 7 = 04:00, 8 = 06:00
96 9 = 08:00, 10= 10:00, 11= 12:00, 12= 18:00,
97 13= 24:00 */
99 int rec_prerecord_time; /* In seconds, 0-30, 0 means OFF */
100 int rec_directory; /* 0=base dir, 1=current dir */
102 /* device settings */
104 int contrast; /* lcd contrast: 0-63 0=low 63=high */
105 bool invert; /* invert display */
106 bool invert_cursor; /* invert the current file in dir browser and menu
107 instead of using the default cursor */
108 bool flip_display; /* turn display (and button layout) by 180 degrees */
109 int poweroff; /* power off timer */
110 int backlight_timeout; /* backlight off timeout: 0-18 0=never,
111 1=always,
112 then according to timeout_values[] */
113 bool backlight_on_when_charging;
114 bool discharge; /* maintain charge of at least: false = 85%, true = 10% */
115 bool trickle_charge; /* do trickle charging: 0=off, 1=on */
116 int battery_capacity; /* in mAh */
118 /* resume settings */
120 int resume; /* resume option: 0=off, 1=ask, 2=on */
121 int resume_index; /* index in playlist (-1 for no active resume) */
122 int resume_first_index; /* index of first track in playlist */
123 int resume_offset; /* byte offset in mp3 file */
124 int resume_seed; /* shuffle seed (-1=no resume shuffle 0=sorted
125 >0=shuffled) */
127 unsigned char font_file[MAX_FILENAME+1]; /* last font */
128 unsigned char wps_file[MAX_FILENAME+1]; /* last wps */
129 unsigned char lang_file[MAX_FILENAME+1]; /* last language */
131 /* misc options */
133 int repeat_mode; /* 0=off 1=repeat all 2=repeat one */
134 int dirfilter; /* 0=display all, 1=only supported, 2=only music */
135 bool sort_case; /* dir sort order: 0=case insensitive, 1=sensitive */
136 int volume_type; /* how volume is displayed: 0=graphic, 1=percent */
137 int battery_type; /* how battery is displayed: 0=graphic, 1=percent */
138 int timeformat; /* time format: 0=24 hour clock, 1=12 hour clock */
139 int scroll_speed; /* long texts scrolling speed: 1-30 */
140 bool playlist_shuffle;
141 bool play_selected; /* Plays selected file even in shuffle mode */
142 int ff_rewind_min_step; /* FF/Rewind minimum step size */
143 int ff_rewind_accel; /* FF/Rewind acceleration (in seconds per doubling) */
144 int disk_spindown; /* time until disk spindown, in seconds (0=off) */
145 bool disk_poweroff; /* whether to cut disk power after spindown or not */
146 int buffer_margin; /* MP3 buffer watermark margin, in seconds */
148 int peak_meter_release; /* units per read out */
149 int peak_meter_hold; /* hold time for peak meter in 1/100 s */
150 int peak_meter_clip_hold; /* hold time for clips */
151 bool peak_meter_dbfs; /* show linear or dbfs values */
152 bool peak_meter_performance; /* true: high performance, else save energy*/
153 int peak_meter_min; /* range minimum */
154 int peak_meter_max; /* range maximum */
155 bool car_adapter_mode; /* 0=off 1=on */
157 /* show status bar */
158 bool statusbar; /* 0=hide, 1=show */
160 /* show button bar */
161 bool buttonbar; /* 0=hide, 1=show */
163 /* show scroll bar */
164 bool scrollbar; /* 0=hide, 1=show */
166 /* goto current song when exiting WPS */
167 bool browse_current; /* 1=goto current song,
168 0=goto previous location */
170 int runtime; /* current runtime since last charge */
171 int topruntime; /* top known runtime */
173 int bidir_limit; /* bidir scroll length limit */
174 int scroll_delay; /* delay (in 1/10s) before starting scroll */
175 int scroll_step; /* pixels to advance per update */
177 /* auto bookmark settings */
178 int autoloadbookmark; /* auto load option: 0=off, 1=ask, 2=on */
179 int autocreatebookmark; /* auto create option: 0=off, 1=ask, 2=on */
180 int usemrb; /* use MRB list: 0=No, 1=Yes*/
181 #ifdef HAVE_LCD_CHARCELLS
182 int jump_scroll; /* Fast jump when scrolling */
183 int jump_scroll_delay; /* Delay between jump scroll screens */
184 #endif
185 bool fade_on_stop; /* fade on pause/unpause/stop */
186 bool caption_backlight; /* turn on backlight at end and start of track */
188 #ifdef HAVE_FMRADIO
189 int fm_freq_step; /* Frequency step for manual tuning, in kHz */
190 bool fm_force_mono; /* Forces Mono mode if true */
191 bool fm_full_range; /* Enables full 10MHz-160MHz range if true, else
192 only 88MHz-108MHz */
193 #endif
195 int max_files_in_dir; /* Max entries in directory (file browser) */
196 int max_files_in_playlist; /* Max entries in playlist */
197 bool show_icons; /* 0=hide 1=show */
198 int recursive_dir_insert; /* should directories be inserted recursively */
200 bool line_in; /* false=off, true=active */
202 /* playlist viewer settings */
203 bool playlist_viewer_icons; /* display icons on viewer */
204 bool playlist_viewer_indices; /* display playlist indices on viewer */
205 int playlist_viewer_track_display; /* how to display tracks in viewer */
207 /* voice UI settings */
208 bool talk_menu; /* enable voice UI */
209 int talk_dir; /* talkbox mode: 0=off 1=number 2=clip@enter 3=clip@hover */
210 int talk_file; /* voice filename mode: 0=off, 1=number, other t.b.d. */
213 enum optiontype { INT, BOOL };
215 struct opt_items {
216 char* string;
217 int voice_id;
220 /* prototypes */
222 int settings_save(void);
223 void settings_load(void);
224 void settings_reset(void);
225 void settings_apply(void);
226 void settings_apply_pm_range(void);
227 void settings_display(void);
229 bool settings_load_config(char* file);
230 bool settings_save_config(void);
231 bool set_bool_options(char* string, bool* variable,
232 char* yes_str, int yes_voice,
233 char* no_str, int no_voice,
234 void (*function)(bool));
236 bool set_bool(char* string, bool* variable );
237 bool set_option(char* string, void* variable, enum optiontype type,
238 struct opt_items* options, int numoptions, void (*function)(int));
239 bool set_int(char* string, char* unit, int voice_unit, int* variable,
240 void (*function)(int), int step, int min, int max );
241 bool set_time_screen(char* string, struct tm *tm);
242 int read_line(int fd, char* buffer, int buffer_size);
243 void set_file(char* filename, char* setting, int maxlen);
245 #ifdef HAVE_MAS3587F
246 unsigned int rec_timesplit_seconds(void);
247 #endif
249 /* global settings */
250 extern struct user_settings global_settings;
251 /* name of directory where configuration, fonts and other data
252 * files are stored */
253 extern char rockboxdir[];
254 extern long lasttime;
256 /* Recording base directory */
257 extern char rec_base_directory[];
259 /* system defines */
261 #ifdef HAVE_LCD_CHARCELLS
262 #define MAX_CONTRAST_SETTING 31
263 #define DEFAULT_CONTRAST_SETTING 30
264 #else
265 #define MAX_CONTRAST_SETTING 63
266 #define DEFAULT_CONTRAST_SETTING 38
267 #endif
268 #define MIN_CONTRAST_SETTING 5
269 #define DEFAULT_INVERT_SETTING false
270 #define DEFAULT_INVERT_CURSOR_SETTING false
271 #define DEFAULT_POWEROFF_SETTING 0
272 #define DEFAULT_BACKLIGHT_TIMEOUT_SETTING 5
273 #define DEFAULT_BACKLIGHT_ON_WHEN_CHARGING_SETTING 0
274 #define DEFAULT_FF_REWIND_MIN_STEP FF_REWIND_1000
275 #define DEFAULT_FF_REWIND_ACCEL_SETTING 3
277 /* repeat mode options */
278 enum { REPEAT_OFF, REPEAT_ALL, REPEAT_ONE, NUM_REPEAT_MODES };
280 /* dir filter options */
281 /* Note: Any new filter modes need to be added before NUM_FILTER_MODES.
282 * Any new rockbox browse filter modes (accessible through the menu)
283 * must be added after NUM_FILTER_MODES. */
284 enum { SHOW_ALL, SHOW_SUPPORTED, SHOW_MUSIC, SHOW_PLAYLIST, NUM_FILTER_MODES,
285 SHOW_WPS, SHOW_CFG, SHOW_LNG, SHOW_MOD, SHOW_FONT, SHOW_PLUGINS};
287 /* recursive dir insert options */
288 enum { RECURSE_OFF, RECURSE_ON, RECURSE_ASK };
290 #endif /* __SETTINGS_H__ */