diff options
author | Björn Stenberg <bjorn@haxx.se> | 2002-07-15 11:02:12 +0000 |
---|---|---|
committer | Björn Stenberg <bjorn@haxx.se> | 2002-07-15 11:02:12 +0000 |
commit | 6b25f79af039b8b367b4fff8c3aadac1cca0ab7d (patch) | |
tree | b7d5c1d8c38bb0166370096922528347e34f1fa9 | |
parent | 5e2898f3d4d1bdd832334225a2ffbd9f121dabca (diff) | |
download | rockbox-6b25f79af039b8b367b4fff8c3aadac1cca0ab7d.tar.gz rockbox-6b25f79af039b8b367b4fff8c3aadac1cca0ab7d.zip |
Settings are now saved in RTC RAM on Recorder (Heikki Hannikainen).
Introduced debug menu (Heikki Hannikainen).
Cleaned up settings API.
Added scroll_speed init.
Moved dbg_ports() and dbg_rtc() from firmware/debug.c to apps/debug_menu.c
Made panic buffer static.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1347 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/main.c | 13 | ||||
-rw-r--r-- | apps/main_menu.c | 21 | ||||
-rw-r--r-- | apps/settings.c | 302 | ||||
-rw-r--r-- | apps/settings.h | 17 | ||||
-rw-r--r-- | apps/settings_menu.c | 1 | ||||
-rw-r--r-- | apps/sound_menu.c | 1 | ||||
-rw-r--r-- | firmware/debug.c | 179 | ||||
-rw-r--r-- | firmware/debug.h | 3 | ||||
-rw-r--r-- | firmware/panic.c | 2 | ||||
-rw-r--r-- | firmware/usb.c | 3 |
10 files changed, 307 insertions, 235 deletions
diff --git a/apps/main.c b/apps/main.c index 816df5c10f..2062efa347 100644 --- a/apps/main.c +++ b/apps/main.c | |||
@@ -41,6 +41,7 @@ | |||
41 | #include "thread.h" | 41 | #include "thread.h" |
42 | #include "settings.h" | 42 | #include "settings.h" |
43 | #include "backlight.h" | 43 | #include "backlight.h" |
44 | #include "debug_menu.h" | ||
44 | 45 | ||
45 | #include "version.h" | 46 | #include "version.h" |
46 | 47 | ||
@@ -63,7 +64,7 @@ void init(void) | |||
63 | init_threads(); | 64 | init_threads(); |
64 | lcd_init(); | 65 | lcd_init(); |
65 | show_logo(); | 66 | show_logo(); |
66 | reset_settings(&global_settings); | 67 | settings_reset(); |
67 | sleep(HZ/2); | 68 | sleep(HZ/2); |
68 | } | 69 | } |
69 | 70 | ||
@@ -81,7 +82,7 @@ void init(void) | |||
81 | system_init(); | 82 | system_init(); |
82 | kernel_init(); | 83 | kernel_init(); |
83 | 84 | ||
84 | reset_settings(&global_settings); | 85 | settings_reset(); |
85 | 86 | ||
86 | dmalloc_initialize(); | 87 | dmalloc_initialize(); |
87 | bmalloc_add_pool(poolstart, poolend-poolstart); | 88 | bmalloc_add_pool(poolstart, poolend-poolstart); |
@@ -114,12 +115,12 @@ void init(void) | |||
114 | lcd_puts(0, 1, str); | 115 | lcd_puts(0, 1, str); |
115 | lcd_puts(0, 3, "Press ON to debug"); | 116 | lcd_puts(0, 3, "Press ON to debug"); |
116 | lcd_update(); | 117 | lcd_update(); |
117 | while(button_get(true) != BUTTON_ON) {}; | 118 | while(button_get(true) != BUTTON_ON); |
118 | dbg_ports(); | 119 | dbg_ports(); |
119 | #endif | 120 | #endif |
120 | panicf("ata: %d", rc); | 121 | panicf("ata: %d", rc); |
121 | } | 122 | } |
122 | 123 | ||
123 | pinfo = disk_init(); | 124 | pinfo = disk_init(); |
124 | if (!pinfo) | 125 | if (!pinfo) |
125 | panicf("disk: NULL"); | 126 | panicf("disk: NULL"); |
@@ -128,6 +129,10 @@ void init(void) | |||
128 | if(rc) | 129 | if(rc) |
129 | panicf("mount: %d",rc); | 130 | panicf("mount: %d",rc); |
130 | 131 | ||
132 | settings_load(); | ||
133 | global_settings.total_boots++; | ||
134 | settings_save(); | ||
135 | |||
131 | mpeg_init( global_settings.volume, | 136 | mpeg_init( global_settings.volume, |
132 | global_settings.bass, | 137 | global_settings.bass, |
133 | global_settings.treble ); | 138 | global_settings.treble ); |
diff --git a/apps/main_menu.c b/apps/main_menu.c index e231a22033..de09897baa 100644 --- a/apps/main_menu.c +++ b/apps/main_menu.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include "kernel.h" | 25 | #include "kernel.h" |
26 | #include "main_menu.h" | 26 | #include "main_menu.h" |
27 | #include "version.h" | 27 | #include "version.h" |
28 | #include "debug.h" | 28 | #include "debug_menu.h" |
29 | #include "sprintf.h" | 29 | #include "sprintf.h" |
30 | #include <string.h> | 30 | #include <string.h> |
31 | #include "playlist.h" | 31 | #include "playlist.h" |
@@ -116,11 +116,25 @@ void show_credits(void) | |||
116 | sleep((HZ*2)/10); | 116 | sleep((HZ*2)/10); |
117 | 117 | ||
118 | if (button_get(false)) | 118 | if (button_get(false)) |
119 | return; | 119 | return; |
120 | } | 120 | } |
121 | roll_credits(); | 121 | roll_credits(); |
122 | } | 122 | } |
123 | 123 | ||
124 | void show_info(void) | ||
125 | { | ||
126 | char s[32]; | ||
127 | |||
128 | lcd_clear_display(); | ||
129 | lcd_puts(0, 0, "Rockbox info:"); | ||
130 | /* TODO: add disk size/usage info, battery charge etc here? */ | ||
131 | snprintf(s, sizeof(s), "Booted: %d times", global_settings.total_boots); | ||
132 | lcd_puts(0, 2, s); | ||
133 | lcd_update(); | ||
134 | |||
135 | button_get(true); | ||
136 | } | ||
137 | |||
124 | void main_menu(void) | 138 | void main_menu(void) |
125 | { | 139 | { |
126 | int m; | 140 | int m; |
@@ -133,9 +147,10 @@ void main_menu(void) | |||
133 | { "Games", games_menu }, | 147 | { "Games", games_menu }, |
134 | { "Screensavers", screensavers_menu }, | 148 | { "Screensavers", screensavers_menu }, |
135 | #endif | 149 | #endif |
150 | { "Info", show_info }, | ||
136 | { "Version", show_credits }, | 151 | { "Version", show_credits }, |
137 | #ifndef SIMULATOR | 152 | #ifndef SIMULATOR |
138 | { "Debug (keep out!)", dbg_ports }, | 153 | { "Debug (keep out!)", debug_menu }, |
139 | #endif | 154 | #endif |
140 | }; | 155 | }; |
141 | 156 | ||
diff --git a/apps/settings.c b/apps/settings.c index 5d33ad8f50..58633396bf 100644 --- a/apps/settings.c +++ b/apps/settings.c | |||
@@ -8,6 +8,7 @@ | |||
8 | * $Id$ | 8 | * $Id$ |
9 | * | 9 | * |
10 | * Copyright (C) 2002 by wavey@wavey.org | 10 | * Copyright (C) 2002 by wavey@wavey.org |
11 | * RTC config saving code (C) 2002 by hessu@hes.iki.fi | ||
11 | * | 12 | * |
12 | * All files in this archive are subject to the GNU General Public License. | 13 | * 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 | * See the file COPYING in the source tree root for full license agreement. |
@@ -26,84 +27,309 @@ | |||
26 | #include "button.h" | 27 | #include "button.h" |
27 | #include "lcd.h" | 28 | #include "lcd.h" |
28 | #include "mpeg.h" | 29 | #include "mpeg.h" |
30 | #include "string.h" | ||
29 | 31 | ||
30 | struct user_settings global_settings; | 32 | struct user_settings global_settings; |
31 | 33 | ||
34 | #ifdef HAVE_RTC | ||
35 | |||
36 | /******************************************** | ||
37 | |||
38 | Config block as saved on the battery-packed RTC user RAM memory block | ||
39 | of 44 bytes, starting at offset 0x14 of the RTC memory space. | ||
40 | |||
41 | offset abs | ||
42 | 0x00 0x14 "Roc" header signature: 0x52 0x6f 0x63 | ||
43 | 0x03 0x17 <version byte: 0x0> | ||
44 | 0x04 0x18 <volume byte> | ||
45 | 0x05 0x19 <balance byte> | ||
46 | 0x06 0x1a <bass byte> | ||
47 | 0x07 0x1b <treble byte> | ||
48 | 0x08 0x1c <loudness byte> | ||
49 | 0x09 0x1d <bass boost byte> | ||
50 | 0x0a 0x1e <contrast byte> | ||
51 | 0x0b 0x1f <backlight byte> | ||
52 | 0x0c 0x20 <poweroff timer byte> | ||
53 | 0x0d 0x21 <resume settings byte> | ||
54 | 0x0e 0x22 <shuffle mode & directory filter byte> | ||
55 | 0x0f 0x23 <scroll speed & WPS display byte> | ||
56 | 0x10 0x24 <playlist options byte> | ||
57 | |||
58 | <all unused space filled with 0xff> | ||
59 | |||
60 | the geeky but useless statistics part: | ||
61 | 0x24 <total uptime in seconds: 32 bits uint, actually unused for now> | ||
62 | 0x28 <boots: 16 bits uint> | ||
63 | |||
64 | 0x2a <checksum 2 bytes: xor of 0x0-0x29> | ||
65 | |||
66 | Config memory is reset to 0xff and initialized with 'factory defaults' if | ||
67 | a valid header & checksum is not found. Config version number is only | ||
68 | increased when information is _relocated_ or space is _reused_ so that old | ||
69 | versions can read and modify configuration changed by new versions. New | ||
70 | versions should check for the value of '0xff' in each config memory | ||
71 | location used, and reset the setting in question with a factory default if | ||
72 | needed. Memory locations not used by a given version should not be | ||
73 | modified unless the header & checksum test fails. | ||
74 | |||
75 | *************************************/ | ||
76 | |||
77 | #include "rtc.h" | ||
78 | static unsigned char rtc_config_block[44]; | ||
79 | |||
80 | /* | ||
81 | * Calculates the checksum for the config block and places it in the given 2-byte buffer | ||
82 | */ | ||
83 | |||
84 | static void calculate_config_checksum(unsigned char *cksum) | ||
85 | { | ||
86 | unsigned char *p; | ||
87 | cksum[0] = cksum[1] = 0; | ||
88 | |||
89 | for (p = rtc_config_block; | ||
90 | p < rtc_config_block + sizeof(rtc_config_block) - 2; | ||
91 | p++) | ||
92 | { | ||
93 | cksum[0] = cksum[0] ^ *p; | ||
94 | p++; | ||
95 | cksum[1] = cksum[1] ^ *p; | ||
96 | } | ||
97 | } | ||
98 | |||
99 | /* | ||
100 | * initialize the config block buffer | ||
101 | */ | ||
102 | static void init_config_buffer( void ) | ||
103 | { | ||
104 | DEBUGF( "init_config_buffer()\n" ); | ||
105 | |||
106 | /* reset to 0xff - all unused */ | ||
107 | memset(rtc_config_block, 0xff, sizeof(rtc_config_block)); | ||
108 | /* insert header */ | ||
109 | rtc_config_block[0] = 'R'; | ||
110 | rtc_config_block[1] = 'o'; | ||
111 | rtc_config_block[2] = 'c'; | ||
112 | rtc_config_block[3] = 0x0; /* config block version number */ | ||
113 | } | ||
114 | |||
115 | /* | ||
116 | * save the config block buffer on the RTC RAM | ||
117 | */ | ||
118 | static int save_config_buffer( void ) | ||
119 | { | ||
120 | unsigned char addr = 0x14; | ||
121 | int r; | ||
122 | unsigned char *p; | ||
123 | |||
124 | DEBUGF( "save_config_buffer()\n" ); | ||
125 | |||
126 | /* update the checksum in the end of the block before saving */ | ||
127 | calculate_config_checksum(rtc_config_block + sizeof(rtc_config_block) - 2); | ||
128 | |||
129 | /* FIXME: okay, it _would_ be cleaner and faster to implement rtc_write so | ||
130 | that it would write a number of bytes at a time since the RTC chip | ||
131 | supports that, but this will have to do for now 8-) */ | ||
132 | for (p = rtc_config_block; | ||
133 | p < rtc_config_block + sizeof(rtc_config_block); | ||
134 | p++) | ||
135 | { | ||
136 | r = rtc_write(addr, *p); | ||
137 | if (r) { | ||
138 | DEBUGF( "save_config_buffer: rtc_write failed at addr 0x%02x: %d\n", addr, r ); | ||
139 | return r; | ||
140 | } | ||
141 | addr++; | ||
142 | } | ||
143 | |||
144 | return 0; | ||
145 | } | ||
146 | |||
32 | /* | 147 | /* |
33 | * persist all runtime user settings to disk | 148 | * load the config block buffer from the RTC RAM |
34 | */ | 149 | */ |
35 | int persist_all_settings( void ) | 150 | static int load_config_buffer( void ) |
36 | { | 151 | { |
152 | unsigned char addr = 0x14; | ||
153 | unsigned char cksum[2]; | ||
154 | unsigned char *p; | ||
155 | |||
156 | DEBUGF( "load_config_buffer()\n" ); | ||
157 | |||
158 | /* FIXME: the same comment applies here as for rtc_write */ | ||
159 | for (p = rtc_config_block; | ||
160 | p < rtc_config_block + sizeof(rtc_config_block); | ||
161 | p++) | ||
162 | { | ||
163 | *p = rtc_read(addr); | ||
164 | addr++; | ||
165 | } | ||
166 | |||
167 | /* calculate the checksum, check it and the header */ | ||
168 | calculate_config_checksum(cksum); | ||
169 | |||
170 | if (rtc_config_block[0x0] == 'R' | ||
171 | && rtc_config_block[0x1] == 'o' | ||
172 | && rtc_config_block[0x2] == 'c' | ||
173 | && rtc_config_block[0x3] == 0x0 | ||
174 | && cksum[0] == rtc_config_block[0x2a] | ||
175 | && cksum[1] == rtc_config_block[0x2b]) { | ||
176 | DEBUGF( "load_config_buffer: header & checksum test ok" ); | ||
177 | return 0; /* header and checksum is valid */ | ||
178 | } | ||
179 | |||
180 | /* if checksum is not valid, initialize the config buffer to all-unused */ | ||
181 | DEBUGF( "load_config_buffer: header & checksum test failed" ); | ||
182 | init_config_buffer(); | ||
37 | return 1; | 183 | return 1; |
38 | } | 184 | } |
39 | 185 | ||
186 | #endif /* HAVE_RTC */ | ||
187 | |||
40 | /* | 188 | /* |
41 | * persist all the playlist information to disk | 189 | * persist all runtime user settings to disk or RTC RAM |
42 | */ | 190 | */ |
43 | int persist_all_playlist_info( void ) | 191 | int settings_save( void ) |
44 | { | 192 | { |
193 | DEBUGF( "settings_save()\n" ); | ||
194 | |||
195 | #ifdef HAVE_RTC | ||
196 | /* update the config block buffer with current | ||
197 | settings and save the block in the RTC */ | ||
198 | rtc_config_block[0x4] = (unsigned char)global_settings.volume; | ||
199 | rtc_config_block[0x5] = (unsigned char)global_settings.balance; | ||
200 | rtc_config_block[0x6] = (unsigned char)global_settings.bass; | ||
201 | rtc_config_block[0x7] = (unsigned char)global_settings.treble; | ||
202 | rtc_config_block[0x8] = (unsigned char)global_settings.loudness; | ||
203 | rtc_config_block[0x9] = (unsigned char)global_settings.bass_boost; | ||
204 | |||
205 | rtc_config_block[0xa] = (unsigned char)global_settings.contrast; | ||
206 | rtc_config_block[0xb] = (unsigned char)global_settings.backlight; | ||
207 | rtc_config_block[0xc] = (unsigned char)global_settings.poweroff; | ||
208 | rtc_config_block[0xd] = (unsigned char)global_settings.resume; | ||
209 | |||
210 | rtc_config_block[0xe] = (unsigned char) | ||
211 | ((global_settings.playlist_shuffle & 1) | | ||
212 | ((global_settings.mp3filter & 1) << 1)); | ||
213 | |||
214 | rtc_config_block[0xf] = (unsigned char) | ||
215 | ((global_settings.scroll_speed << 3) | | ||
216 | (global_settings.wps_display & 7)); | ||
217 | |||
218 | memcpy(&rtc_config_block[0x24], &global_settings.total_uptime, 4); | ||
219 | memcpy(&rtc_config_block[0x28], &global_settings.total_boots, 2); | ||
220 | |||
221 | save_config_buffer(); | ||
222 | #endif /* HAVE_RTC */ | ||
223 | |||
45 | return 1; | 224 | return 1; |
46 | } | 225 | } |
47 | 226 | ||
48 | /* | 227 | /* |
49 | * load settings from disk | 228 | * load settings from disk or RTC RAM |
50 | */ | 229 | */ |
51 | void reload_all_settings( struct user_settings *settings ) | 230 | void settings_load(void) |
52 | { | 231 | { |
232 | #ifdef HAVE_RTC | ||
233 | unsigned char c; | ||
234 | #endif | ||
235 | |||
53 | DEBUGF( "reload_all_settings()\n" ); | 236 | DEBUGF( "reload_all_settings()\n" ); |
54 | 237 | ||
55 | /* this is a TEMP stub version */ | ||
56 | |||
57 | /* populate settings with default values */ | 238 | /* populate settings with default values */ |
239 | settings_reset(); | ||
58 | 240 | ||
59 | reset_settings( settings ); | 241 | #ifdef HAVE_RTC |
242 | /* load the buffer from the RTC (resets it to all-unused if the block | ||
243 | is invalid) and decode the settings which are set in the block */ | ||
244 | if (!load_config_buffer()) { | ||
245 | if (rtc_config_block[0x4] != 0xFF) | ||
246 | global_settings.volume = rtc_config_block[0x4]; | ||
247 | if (rtc_config_block[0x5] != 0xFF) | ||
248 | global_settings.balance = rtc_config_block[0x5]; | ||
249 | if (rtc_config_block[0x6] != 0xFF) | ||
250 | global_settings.bass = rtc_config_block[0x6]; | ||
251 | if (rtc_config_block[0x7] != 0xFF) | ||
252 | global_settings.treble = rtc_config_block[0x7]; | ||
253 | if (rtc_config_block[0x8] != 0xFF) | ||
254 | global_settings.loudness = rtc_config_block[0x8]; | ||
255 | if (rtc_config_block[0x9] != 0xFF) | ||
256 | global_settings.bass_boost = rtc_config_block[0x9]; | ||
257 | |||
258 | if (rtc_config_block[0xa] != 0xFF) | ||
259 | global_settings.contrast = rtc_config_block[0xa]; | ||
260 | if (rtc_config_block[0xb] != 0xFF) | ||
261 | global_settings.backlight = rtc_config_block[0xb]; | ||
262 | if (rtc_config_block[0xc] != 0xFF) | ||
263 | global_settings.poweroff = rtc_config_block[0xc]; | ||
264 | if (rtc_config_block[0xd] != 0xFF) | ||
265 | global_settings.resume = rtc_config_block[0xd]; | ||
266 | if (rtc_config_block[0xe] != 0xFF) { | ||
267 | global_settings.playlist_shuffle = rtc_config_block[0xe] & 1; | ||
268 | global_settings.mp3filter = (rtc_config_block[0xe] >> 1) & 1; | ||
269 | } | ||
270 | |||
271 | c = rtc_config_block[0xf] >> 3; | ||
272 | if (c != 31) | ||
273 | global_settings.scroll_speed = c; | ||
274 | |||
275 | c = rtc_config_block[0xf] & 7; | ||
276 | if (c != 7) | ||
277 | global_settings.wps_display = c; | ||
278 | |||
279 | if (rtc_config_block[0x24] != 0xFF) | ||
280 | memcpy(&global_settings.total_uptime, &rtc_config_block[0x24], 4); | ||
281 | if (rtc_config_block[0x28] != 0xFF) | ||
282 | memcpy(&global_settings.total_boots, &rtc_config_block[0x28], 2); | ||
283 | } | ||
284 | |||
285 | #endif /* HAVE_RTC */ | ||
60 | } | 286 | } |
61 | 287 | ||
62 | /* | 288 | /* |
63 | * reset all settings to their default value | 289 | * reset all settings to their default value |
64 | */ | 290 | */ |
65 | void reset_settings( struct user_settings *settings ) { | 291 | void settings_reset(void) { |
66 | 292 | ||
67 | DEBUGF( "reset_settings()\n" ); | 293 | DEBUGF( "settings_reset()\n" ); |
68 | 294 | ||
69 | settings->volume = mpeg_sound_default(SOUND_VOLUME); | 295 | global_settings.volume = mpeg_sound_default(SOUND_VOLUME); |
70 | settings->balance = DEFAULT_BALANCE_SETTING; | 296 | global_settings.balance = DEFAULT_BALANCE_SETTING; |
71 | settings->bass = mpeg_sound_default(SOUND_BASS); | 297 | global_settings.bass = mpeg_sound_default(SOUND_BASS); |
72 | settings->treble = mpeg_sound_default(SOUND_TREBLE); | 298 | global_settings.treble = mpeg_sound_default(SOUND_TREBLE); |
73 | settings->loudness = DEFAULT_LOUDNESS_SETTING; | 299 | global_settings.loudness = DEFAULT_LOUDNESS_SETTING; |
74 | settings->bass_boost = DEFAULT_BASS_BOOST_SETTING; | 300 | global_settings.bass_boost = DEFAULT_BASS_BOOST_SETTING; |
75 | settings->contrast = DEFAULT_CONTRAST_SETTING; | 301 | global_settings.contrast = DEFAULT_CONTRAST_SETTING; |
76 | settings->poweroff = DEFAULT_POWEROFF_SETTING; | 302 | global_settings.poweroff = DEFAULT_POWEROFF_SETTING; |
77 | settings->backlight = DEFAULT_BACKLIGHT_SETTING; | 303 | global_settings.backlight = DEFAULT_BACKLIGHT_SETTING; |
78 | settings->wps_display = DEFAULT_WPS_DISPLAY; | 304 | global_settings.wps_display = DEFAULT_WPS_DISPLAY; |
79 | settings->mp3filter = true; | 305 | global_settings.mp3filter = true; |
80 | settings->playlist_shuffle = false; | 306 | global_settings.playlist_shuffle = false; |
307 | global_settings.total_boots = 0; | ||
308 | global_settings.total_uptime = 0; | ||
309 | global_settings.scroll_speed = 8; | ||
81 | } | 310 | } |
82 | 311 | ||
83 | 312 | ||
84 | /* | 313 | /* |
85 | * dump the list of current settings | 314 | * dump the list of current settings |
86 | */ | 315 | */ |
87 | void display_current_settings( struct user_settings *settings ) | 316 | void settings_display(void) |
88 | { | 317 | { |
89 | #ifdef DEBUG | 318 | #ifdef DEBUG |
90 | DEBUGF( "\ndisplay_current_settings()\n" ); | 319 | DEBUGF( "\nsettings_display()\n" ); |
91 | 320 | ||
92 | DEBUGF( "\nvolume:\t\t%d\nbalance:\t%d\nbass:\t\t%d\ntreble:\t\t%d\nloudness:\t%d\nbass boost:\t%d\n", | 321 | DEBUGF( "\nvolume:\t\t%d\nbalance:\t%d\nbass:\t\t%d\ntreble:\t\t%d\nloudness:\t%d\nbass boost:\t%d\n", |
93 | settings->volume, | 322 | global_settings.volume, |
94 | settings->balance, | 323 | global_settings.balance, |
95 | settings->bass, | 324 | global_settings.bass, |
96 | settings->treble, | 325 | global_settings.treble, |
97 | settings->loudness, | 326 | global_settings.loudness, |
98 | settings->bass_boost ); | 327 | global_settings.bass_boost ); |
99 | 328 | ||
100 | DEBUGF( "contrast:\t%d\npoweroff:\t%d\nbacklight:\t%d\n", | 329 | DEBUGF( "contrast:\t%d\npoweroff:\t%d\nbacklight:\t%d\n", |
101 | settings->contrast, | 330 | global_settings.contrast, |
102 | settings->poweroff, | 331 | global_settings.poweroff, |
103 | settings->backlight ); | 332 | global_settings.backlight ); |
104 | #else | ||
105 | /* Get rid of warning */ | ||
106 | settings = settings; | ||
107 | #endif | 333 | #endif |
108 | } | 334 | } |
109 | 335 | ||
diff --git a/apps/settings.h b/apps/settings.h index 5f67b3b1bc..d47c9b8a83 100644 --- a/apps/settings.h +++ b/apps/settings.h | |||
@@ -54,20 +54,23 @@ struct user_settings | |||
54 | 54 | ||
55 | int loop_playlist; /* do we return to top of playlist at end? */ | 55 | int loop_playlist; /* do we return to top of playlist at end? */ |
56 | bool mp3filter; | 56 | bool mp3filter; |
57 | int scroll_speed; | 57 | int scroll_speed; /* long texts scrolling speed: 1-20 */ |
58 | bool playlist_shuffle; | 58 | bool playlist_shuffle; |
59 | 59 | ||
60 | /* while playing screen settings */ | 60 | /* while playing screen settings */ |
61 | int wps_display; | 61 | int wps_display; /* 0=id3, 1=file, 2=parse */ |
62 | 62 | ||
63 | /* geeky persistent statistics */ | ||
64 | unsigned short total_boots; /* how many times the device has been booted */ | ||
65 | unsigned int total_uptime; /* total uptime since rockbox was first booted */ | ||
63 | }; | 66 | }; |
64 | 67 | ||
65 | /* prototypes */ | 68 | /* prototypes */ |
66 | 69 | ||
67 | int persist_all_settings( void ); | 70 | int settings_save(void); |
68 | void reload_all_settings( struct user_settings *settings ); | 71 | void settings_load(void); |
69 | void reset_settings( struct user_settings *settings ); | 72 | void settings_reset(void); |
70 | void display_current_settings( struct user_settings *settings ); | 73 | void settings_display(void); |
71 | 74 | ||
72 | void set_bool(char* string, bool* variable ); | 75 | void set_bool(char* string, bool* variable ); |
73 | void set_option(char* string, int* variable, char* options[], int numoptions ); | 76 | void set_option(char* string, int* variable, char* options[], int numoptions ); |
diff --git a/apps/settings_menu.c b/apps/settings_menu.c index a27f4feac1..f910d52c1f 100644 --- a/apps/settings_menu.c +++ b/apps/settings_menu.c | |||
@@ -76,4 +76,5 @@ void settings_menu(void) | |||
76 | m=menu_init( items, sizeof items / sizeof(struct menu_items) ); | 76 | m=menu_init( items, sizeof items / sizeof(struct menu_items) ); |
77 | menu_run(m); | 77 | menu_run(m); |
78 | menu_exit(m); | 78 | menu_exit(m); |
79 | settings_save(); | ||
79 | } | 80 | } |
diff --git a/apps/sound_menu.c b/apps/sound_menu.c index cbfc7a714e..a9111bbaed 100644 --- a/apps/sound_menu.c +++ b/apps/sound_menu.c | |||
@@ -130,4 +130,5 @@ void sound_menu(void) | |||
130 | m=menu_init( items, sizeof items / sizeof(struct menu_items) ); | 130 | m=menu_init( items, sizeof items / sizeof(struct menu_items) ); |
131 | menu_run(m); | 131 | menu_run(m); |
132 | menu_exit(m); | 132 | menu_exit(m); |
133 | settings_save(); | ||
133 | } | 134 | } |
diff --git a/firmware/debug.c b/firmware/debug.c index a7923ac237..83eb149706 100644 --- a/firmware/debug.c +++ b/firmware/debug.c | |||
@@ -29,12 +29,7 @@ static char debugbuf[200]; | |||
29 | 29 | ||
30 | #ifndef SIMULATOR /* allow non archos platforms to display output */ | 30 | #ifndef SIMULATOR /* allow non archos platforms to display output */ |
31 | #include "kernel.h" | 31 | #include "kernel.h" |
32 | #include "button.h" | ||
33 | #include "system.h" | 32 | #include "system.h" |
34 | #include "lcd.h" | ||
35 | #include "adc.h" | ||
36 | #include "mas.h" | ||
37 | #include "power.h" | ||
38 | 33 | ||
39 | void debug_init(void) | 34 | void debug_init(void) |
40 | { | 35 | { |
@@ -214,180 +209,6 @@ void debugf(char *fmt, ...) | |||
214 | #endif | 209 | #endif |
215 | } | 210 | } |
216 | 211 | ||
217 | /*---------------------------------------------------*/ | ||
218 | /* SPECIAL DEBUG STUFF */ | ||
219 | /*---------------------------------------------------*/ | ||
220 | extern int ata_device; | ||
221 | extern int ata_io_address; | ||
222 | |||
223 | #ifdef ARCHOS_RECORDER | ||
224 | /* Test code!!! */ | ||
225 | void dbg_ports(void) | ||
226 | { | ||
227 | unsigned short porta; | ||
228 | unsigned short portb; | ||
229 | unsigned char portc; | ||
230 | char buf[32]; | ||
231 | int button; | ||
232 | int battery_voltage; | ||
233 | int batt_int, batt_frac; | ||
234 | bool charge_status = false; | ||
235 | bool ide_status = true; | ||
236 | |||
237 | lcd_clear_display(); | ||
238 | |||
239 | while(1) | ||
240 | { | ||
241 | porta = PADR; | ||
242 | portb = PBDR; | ||
243 | portc = PCDR; | ||
244 | |||
245 | snprintf(buf, 32, "PADR: %04x", porta); | ||
246 | lcd_puts(0, 0, buf); | ||
247 | snprintf(buf, 32, "PBDR: %04x", portb); | ||
248 | lcd_puts(0, 1, buf); | ||
249 | |||
250 | snprintf(buf, 32, "AN0: %03x AN4: %03x", adc_read(0), adc_read(4)); | ||
251 | lcd_puts(0, 2, buf); | ||
252 | snprintf(buf, 32, "AN1: %03x AN5: %03x", adc_read(1), adc_read(5)); | ||
253 | lcd_puts(0, 3, buf); | ||
254 | snprintf(buf, 32, "AN2: %03x AN6: %03x", adc_read(2), adc_read(6)); | ||
255 | lcd_puts(0, 4, buf); | ||
256 | snprintf(buf, 32, "AN3: %03x AN7: %03x", adc_read(3), adc_read(7)); | ||
257 | lcd_puts(0, 5, buf); | ||
258 | |||
259 | battery_voltage = (adc_read(6) * BATTERY_SCALE_FACTOR) / 10000; | ||
260 | batt_int = battery_voltage / 100; | ||
261 | batt_frac = battery_voltage % 100; | ||
262 | |||
263 | snprintf(buf, 32, "Batt: %d.%02dV %d%% ", batt_int, batt_frac, | ||
264 | battery_level()); | ||
265 | lcd_puts(0, 6, buf); | ||
266 | |||
267 | snprintf(buf, 32, "ATA: %s, 0x%x", | ||
268 | ata_device?"slave":"master", ata_io_address); | ||
269 | lcd_puts(0, 7, buf); | ||
270 | |||
271 | lcd_update(); | ||
272 | sleep(HZ/10); | ||
273 | |||
274 | button = button_get(false); | ||
275 | |||
276 | switch(button) | ||
277 | { | ||
278 | case BUTTON_ON: | ||
279 | charge_status = charge_status?false:true; | ||
280 | charger_enable(charge_status); | ||
281 | break; | ||
282 | |||
283 | case BUTTON_UP: | ||
284 | ide_status = ide_status?false:true; | ||
285 | ide_power_enable(ide_status); | ||
286 | break; | ||
287 | |||
288 | case BUTTON_OFF: | ||
289 | charger_enable(false); | ||
290 | ide_power_enable(true); | ||
291 | return; | ||
292 | } | ||
293 | } | ||
294 | } | ||
295 | #else | ||
296 | void dbg_ports(void) | ||
297 | { | ||
298 | unsigned short porta; | ||
299 | unsigned short portb; | ||
300 | unsigned char portc; | ||
301 | char buf[32]; | ||
302 | unsigned long crc_count; | ||
303 | int button; | ||
304 | int battery_voltage; | ||
305 | int batt_int, batt_frac; | ||
306 | int currval = 0; | ||
307 | |||
308 | lcd_clear_display(); | ||
309 | |||
310 | while(1) | ||
311 | { | ||
312 | porta = PADR; | ||
313 | portb = PBDR; | ||
314 | portc = PCDR; | ||
315 | |||
316 | switch(currval) | ||
317 | { | ||
318 | case 0: | ||
319 | snprintf(buf, 32, "PADR: %04x ", porta); | ||
320 | break; | ||
321 | case 1: | ||
322 | snprintf(buf, 32, "PBDR: %04x ", portb); | ||
323 | break; | ||
324 | case 2: | ||
325 | snprintf(buf, 32, "AN0: %03x ", adc_read(0)); | ||
326 | break; | ||
327 | case 3: | ||
328 | snprintf(buf, 32, "AN1: %03x ", adc_read(1)); | ||
329 | break; | ||
330 | case 4: | ||
331 | snprintf(buf, 32, "AN2: %03x ", adc_read(2)); | ||
332 | break; | ||
333 | case 5: | ||
334 | snprintf(buf, 32, "AN3: %03x ", adc_read(3)); | ||
335 | break; | ||
336 | case 6: | ||
337 | snprintf(buf, 32, "AN4: %03x ", adc_read(4)); | ||
338 | break; | ||
339 | case 7: | ||
340 | snprintf(buf, 32, "AN5: %03x ", adc_read(5)); | ||
341 | break; | ||
342 | case 8: | ||
343 | snprintf(buf, 32, "AN6: %03x ", adc_read(6)); | ||
344 | break; | ||
345 | case 9: | ||
346 | snprintf(buf, 32, "AN7: %03x ", adc_read(7)); | ||
347 | break; | ||
348 | case 10: | ||
349 | snprintf(buf, 32, "%s, 0x%x ", | ||
350 | ata_device?"slv":"mst", ata_io_address); | ||
351 | break; | ||
352 | case 11: | ||
353 | mas_readmem(MAS_BANK_D0, 0x303, &crc_count, 1); | ||
354 | |||
355 | snprintf(buf, 32, "CRC: %d ", crc_count); | ||
356 | break; | ||
357 | } | ||
358 | lcd_puts(0, 0, buf); | ||
359 | |||
360 | battery_voltage = (adc_read(6) * BATTERY_SCALE_FACTOR) / 10000; | ||
361 | batt_int = battery_voltage / 100; | ||
362 | batt_frac = battery_voltage % 100; | ||
363 | |||
364 | snprintf(buf, 32, "Batt: %d.%02dV", batt_int, batt_frac); | ||
365 | lcd_puts(0, 1, buf); | ||
366 | |||
367 | sleep(HZ/5); | ||
368 | |||
369 | button = button_get(false); | ||
370 | |||
371 | switch(button) | ||
372 | { | ||
373 | case BUTTON_STOP: | ||
374 | return; | ||
375 | |||
376 | case BUTTON_LEFT: | ||
377 | currval--; | ||
378 | if(currval < 0) | ||
379 | currval = 11; | ||
380 | break; | ||
381 | |||
382 | case BUTTON_RIGHT: | ||
383 | currval++; | ||
384 | if(currval > 11) | ||
385 | currval = 0; | ||
386 | break; | ||
387 | } | ||
388 | } | ||
389 | } | ||
390 | #endif | ||
391 | 212 | ||
392 | #else /* SIMULATOR code coming up */ | 213 | #else /* SIMULATOR code coming up */ |
393 | 214 | ||
diff --git a/firmware/debug.h b/firmware/debug.h index 2f984ee55e..876b8511a6 100644 --- a/firmware/debug.h +++ b/firmware/debug.h | |||
@@ -21,9 +21,6 @@ | |||
21 | 21 | ||
22 | extern void debug_init(void); | 22 | extern void debug_init(void); |
23 | extern void debugf(char* fmt,...); | 23 | extern void debugf(char* fmt,...); |
24 | #ifndef SIMULATOR | ||
25 | extern void dbg_ports(void); | ||
26 | #endif | ||
27 | 24 | ||
28 | #ifdef __GNUC__ | 25 | #ifdef __GNUC__ |
29 | 26 | ||
diff --git a/firmware/panic.c b/firmware/panic.c index f34ac07f4f..95519ce621 100644 --- a/firmware/panic.c +++ b/firmware/panic.c | |||
@@ -23,7 +23,7 @@ | |||
23 | #include "lcd.h" | 23 | #include "lcd.h" |
24 | #include "debug.h" | 24 | #include "debug.h" |
25 | 25 | ||
26 | char panic_buf[128]; | 26 | static char panic_buf[128]; |
27 | 27 | ||
28 | /* | 28 | /* |
29 | * "Dude. This is pretty fucked-up, right here." | 29 | * "Dude. This is pretty fucked-up, right here." |
diff --git a/firmware/usb.c b/firmware/usb.c index 1e45cd34b8..3732d83df6 100644 --- a/firmware/usb.c +++ b/firmware/usb.c | |||
@@ -32,6 +32,9 @@ | |||
32 | #include "button.h" | 32 | #include "button.h" |
33 | #include "sprintf.h" | 33 | #include "sprintf.h" |
34 | 34 | ||
35 | #ifdef ARCHOS_RECORDER | ||
36 | extern void dbg_ports(void); | ||
37 | #endif | ||
35 | 38 | ||
36 | #define USB_REALLY_BRAVE | 39 | #define USB_REALLY_BRAVE |
37 | 40 | ||