summaryrefslogtreecommitdiff
path: root/apps/gui/wps_debug.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/gui/wps_debug.c')
-rw-r--r--apps/gui/wps_debug.c407
1 files changed, 407 insertions, 0 deletions
diff --git a/apps/gui/wps_debug.c b/apps/gui/wps_debug.c
new file mode 100644
index 0000000000..4532151d71
--- /dev/null
+++ b/apps/gui/wps_debug.c
@@ -0,0 +1,407 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 Nicolas Pennequin, Dan Everton, Matthias Mohr
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#ifdef DEBUG
21
22#include <stdio.h>
23#include <string.h>
24#include "gwps.h"
25#include "debug.h"
26
27void dump_wps_tokens(struct wps_data *data)
28{
29 int i, j;
30 int indent = 0;
31 char buf[64];
32 bool next;
33
34 /* Dump parsed WPS */
35 for(i = 0; i < data->num_tokens && i < WPS_MAX_TOKENS; i++) {
36
37 next = data->tokens[i].next;
38
39 switch(data->tokens[i].type) {
40 case WPS_TOKEN_UNKNOWN:
41 snprintf(buf, sizeof(buf), "Unknown token");
42 break;
43 case WPS_TOKEN_CHARACTER:
44 snprintf(buf, sizeof(buf), "Character '%c'",
45 data->tokens[i].value.c);
46 break;
47
48 case WPS_TOKEN_STRING:
49 snprintf(buf, sizeof(buf), "String '%s'",
50 data->strings[data->tokens[i].value.i]);
51 break;
52
53 case WPS_TOKEN_EOL:
54 snprintf(buf, sizeof(buf), "%s", "EOL");
55 break;
56
57#ifdef HAVE_LCD_BITMAP
58 case WPS_TOKEN_ALIGN_LEFT:
59 snprintf(buf, sizeof(buf), "%s", "align left");
60 break;
61
62 case WPS_TOKEN_ALIGN_CENTER:
63 snprintf(buf, sizeof(buf), "%s", "align center");
64 break;
65
66 case WPS_TOKEN_ALIGN_RIGHT:
67 snprintf(buf, sizeof(buf), "%s", "align right");
68 break;
69#endif
70
71 case WPS_TOKEN_CONDITIONAL:
72 snprintf(buf, sizeof(buf), "%s, %d options", "conditional",
73 data->tokens[i].value.i);
74 break;
75
76 case WPS_TOKEN_CONDITIONAL_START:
77 snprintf(buf, sizeof(buf), "%s, next cond: %d",
78 "conditional start", data->tokens[i].value.i);
79 indent++;
80 break;
81
82 case WPS_TOKEN_CONDITIONAL_OPTION:
83 snprintf(buf, sizeof(buf), "%s, next cond: %d",
84 "conditional option", data->tokens[i].value.i);
85 break;
86
87 case WPS_TOKEN_CONDITIONAL_END:
88 snprintf(buf, sizeof(buf), "%s", "conditional end");
89 indent--;
90 break;
91
92#ifdef HAVE_LCD_BITMAP
93 case WPS_TOKEN_IMAGE_PRELOAD:
94 snprintf(buf, sizeof(buf), "%s", "preload image");
95 break;
96
97 case WPS_TOKEN_IMAGE_PRELOAD_DISPLAY:
98 snprintf(buf, sizeof(buf), "%s %d", "display preloaded image",
99 data->tokens[i].value.i);
100 break;
101
102 case WPS_TOKEN_IMAGE_DISPLAY:
103 snprintf(buf, sizeof(buf), "%s", "display image");
104 break;
105#endif
106
107#ifdef HAS_BUTTON_HOLD
108 case WPS_TOKEN_MAIN_HOLD:
109 snprintf(buf, sizeof(buf), "%s", "mode hold");
110 break;
111#endif
112
113#ifdef HAS_REMOTE_BUTTON_HOLD
114 case WPS_TOKEN_REMOTE_HOLD:
115 snprintf(buf, sizeof(buf), "%s", "mode remote hold");
116 break;
117#endif
118
119 case WPS_TOKEN_REPEAT_MODE:
120 snprintf(buf, sizeof(buf), "%s", "mode repeat");
121 break;
122
123 case WPS_TOKEN_PLAYBACK_STATUS:
124 snprintf(buf, sizeof(buf), "%s", "mode playback");
125 break;
126
127#if CONFIG_RTC
128 case WPS_TOKEN_RTC_DAY_OF_MONTH:
129 case WPS_TOKEN_RTC_DAY_OF_MONTH_BLANK_PADDED:
130 case WPS_TOKEN_RTC_HOUR_24_ZERO_PADDED:
131 case WPS_TOKEN_RTC_HOUR_24:
132 case WPS_TOKEN_RTC_HOUR_12_ZERO_PADDED:
133 case WPS_TOKEN_RTC_HOUR_12:
134 case WPS_TOKEN_RTC_MONTH:
135 case WPS_TOKEN_RTC_MINUTE:
136 case WPS_TOKEN_RTC_SECOND:
137 case WPS_TOKEN_RTC_YEAR_2_DIGITS:
138 case WPS_TOKEN_RTC_YEAR_4_DIGITS:
139 case WPS_TOKEN_RTC_AM_PM_UPPER:
140 case WPS_TOKEN_RTC_AM_PM_LOWER:
141 case WPS_TOKEN_RTC_WEEKDAY_NAME:
142 case WPS_TOKEN_RTC_MONTH_NAME:
143 case WPS_TOKEN_RTC_DAY_OF_WEEK_START_MON:
144 case WPS_TOKEN_RTC_DAY_OF_WEEK_START_SUN:
145 case WPS_TOKEN_RTC:
146 snprintf(buf, sizeof(buf), "%s %c", "real-time clock tag:",
147 data->tokens[i].value.c);
148 break;
149#endif
150
151#ifdef HAVE_LCD_BITMAP
152 case WPS_TOKEN_IMAGE_BACKDROP:
153 snprintf(buf, sizeof(buf), "%s", "backdrop image");
154 break;
155
156 case WPS_TOKEN_IMAGE_PROGRESS_BAR:
157 snprintf(buf, sizeof(buf), "%s", "progressbar bitmap");
158 break;
159
160
161 case WPS_TOKEN_STATUSBAR_ENABLED:
162 snprintf(buf, sizeof(buf), "%s", "statusbar enable");
163 break;
164
165 case WPS_TOKEN_STATUSBAR_DISABLED:
166 snprintf(buf, sizeof(buf), "%s", "statusbar disable");
167 break;
168
169 case WPS_TOKEN_PEAKMETER:
170 snprintf(buf, sizeof(buf), "%s", "peakmeter");
171 break;
172#endif
173
174 case WPS_TOKEN_PROGRESSBAR:
175 snprintf(buf, sizeof(buf), "%s", "progressbar");
176 break;
177
178#ifdef HAVE_LCD_CHARCELLS
179 case WPS_TOKEN_PLAYER_PROGRESSBAR:
180 snprintf(buf, sizeof(buf), "%s", "full line progressbar");
181 break;
182#endif
183
184 case WPS_TOKEN_TRACK_TIME_ELAPSED:
185 snprintf(buf, sizeof(buf), "%s", "time elapsed in track");
186 break;
187
188 case WPS_TOKEN_PLAYLIST_ENTRIES:
189 snprintf(buf, sizeof(buf), "%s", "number of entries in playlist");
190 break;
191
192 case WPS_TOKEN_PLAYLIST_NAME:
193 snprintf(buf, sizeof(buf), "%s", "playlist name");
194 break;
195
196 case WPS_TOKEN_PLAYLIST_POSITION:
197 snprintf(buf, sizeof(buf), "%s", "position in playlist");
198 break;
199
200 case WPS_TOKEN_TRACK_TIME_REMAINING:
201 snprintf(buf, sizeof(buf), "%s", "time remaining in track");
202 break;
203
204 case WPS_TOKEN_PLAYLIST_SHUFFLE:
205 snprintf(buf, sizeof(buf), "%s", "playlist shuffle mode");
206 break;
207
208 case WPS_TOKEN_TRACK_LENGTH:
209 snprintf(buf, sizeof(buf), "%s", "track length");
210 break;
211
212 case WPS_TOKEN_VOLUME:
213 snprintf(buf, sizeof(buf), "%s", "volume");
214 break;
215
216 case WPS_TOKEN_METADATA_ARTIST:
217 snprintf(buf, sizeof(buf), "%s%s", next ? "next " : "",
218 "track artist");
219 break;
220
221 case WPS_TOKEN_METADATA_COMPOSER:
222 snprintf(buf, sizeof(buf), "%s%s", next ? "next " : "",
223 "track composer");
224 break;
225
226 case WPS_TOKEN_METADATA_ALBUM:
227 snprintf(buf, sizeof(buf), "%s%s", next ? "next " : "",
228 "track album");
229 break;
230
231 case WPS_TOKEN_METADATA_GENRE:
232 snprintf(buf, sizeof(buf), "%s%s", next ? "next " : "",
233 "track genre");
234 break;
235
236 case WPS_TOKEN_METADATA_TRACK_NUMBER:
237 snprintf(buf, sizeof(buf), "%s%s", next ? "next " : "",
238 "track number");
239 break;
240
241 case WPS_TOKEN_METADATA_TRACK_TITLE:
242 snprintf(buf, sizeof(buf), "%s%s", next ? "next " : "",
243 "track title");
244 break;
245
246 case WPS_TOKEN_METADATA_VERSION:
247 snprintf(buf, sizeof(buf), "%s%s", next ? "next " : "",
248 "track ID3 version");
249 break;
250
251 case WPS_TOKEN_METADATA_YEAR:
252 snprintf(buf, sizeof(buf), "%s%s", next ? "next " : "",
253 "track year");
254 break;
255
256 case WPS_TOKEN_BATTERY_PERCENT:
257 snprintf(buf, sizeof(buf), "%s", "battery percentage");
258 break;
259
260 case WPS_TOKEN_BATTERY_VOLTS:
261 snprintf(buf, sizeof(buf), "%s", "battery voltage");
262 break;
263
264 case WPS_TOKEN_BATTERY_TIME:
265 snprintf(buf, sizeof(buf), "%s", "battery time left");
266 break;
267
268 case WPS_TOKEN_BATTERY_CHARGER_CONNECTED:
269 snprintf(buf, sizeof(buf), "%s", "battery charger connected");
270 break;
271
272 case WPS_TOKEN_BATTERY_CHARGING:
273 snprintf(buf, sizeof(buf), "%s", "battery charging");
274 break;
275
276 case WPS_TOKEN_FILE_BITRATE:
277 snprintf(buf, sizeof(buf), "%s%s", next ? "next " : "",
278 "file bitrate");
279 break;
280
281 case WPS_TOKEN_FILE_CODEC:
282 snprintf(buf, sizeof(buf), "%s%s", next ? "next " : "",
283 "file codec");
284 break;
285
286 case WPS_TOKEN_FILE_FREQUENCY:
287 snprintf(buf, sizeof(buf), "%s%s", next ? "next " : "",
288 "file audio frequency");
289 break;
290
291 case WPS_TOKEN_FILE_NAME:
292 snprintf(buf, sizeof(buf), "%s%s", next ? "next " : "",
293 "file name");
294 break;
295
296 case WPS_TOKEN_FILE_NAME_WITH_EXTENSION:
297 snprintf(buf, sizeof(buf), "%s%s", next ? "next " : "",
298 "file name with extension");
299 break;
300
301 case WPS_TOKEN_FILE_PATH:
302 snprintf(buf, sizeof(buf), "%s%s", next ? "next " : "",
303 "file path");
304 break;
305
306 case WPS_TOKEN_FILE_SIZE:
307 snprintf(buf, sizeof(buf), "%s%s", next ? "next " : "",
308 "file size");
309 break;
310
311 case WPS_TOKEN_FILE_VBR:
312 snprintf(buf, sizeof(buf), "%s%s", next ? "next " : "",
313 "file is vbr");
314 break;
315
316 case WPS_TOKEN_FILE_DIRECTORY:
317 snprintf(buf, sizeof(buf), "%s%s: %d", next ? "next " : "",
318 "file directory, level",
319 data->tokens[i].value.i);
320 break;
321
322 case WPS_TOKEN_SCROLL:
323 snprintf(buf, sizeof(buf), "%s", "scrolling line");
324 break;
325
326 case WPS_TOKEN_SUBLINE_TIMEOUT:
327 snprintf(buf, sizeof(buf), "%s: %d", "subline timeout value",
328 data->tokens[i].value.i);
329 break;
330
331 case WPS_TOKEN_SUBLINE_SEPARATOR:
332 snprintf(buf, sizeof(buf), "%s", "subline separator");
333 break;
334
335 default:
336 snprintf(buf, sizeof(buf), "%s (code: %d)", "FIXME",
337 data->tokens[i].type);
338 break;
339 }
340
341 for(j = 0; j < indent; j++) {
342 DEBUGF("\t");
343 }
344
345 DEBUGF("[%03d] = %s\n", i, buf);
346 }
347 DEBUGF("\n");
348}
349
350void print_line_info(struct wps_data *data)
351{
352 int line, subline;
353
354 DEBUGF("line/subline start indexes :\n");
355 for (line = 0; line < data->num_lines; line++)
356 {
357 DEBUGF("%2d. ", line);
358 for (subline = 0; subline < data->num_sublines[line]; subline++)
359 {
360 DEBUGF("%3d ", data->format_lines[line][subline]);
361 }
362 DEBUGF("\n");
363 }
364
365 DEBUGF("\n");
366
367 DEBUGF("subline time multipliers :\n");
368 for (line = 0; line < data->num_lines; line++)
369 {
370 DEBUGF("%2d. ", line);
371 for (subline = 0; subline < data->num_sublines[line]; subline++)
372 {
373 DEBUGF("%3d ", data->time_mult[line][subline]);
374 }
375 DEBUGF("\n");
376 }
377
378}
379
380void print_wps_strings(struct wps_data *data)
381{
382 DEBUGF("strings :\n");
383 int i, len = 0;
384 for (i=0; i < data->num_strings; i++)
385 {
386 len += strlen(data->strings[i]);
387 DEBUGF("%2d: '%s'\n", i, data->strings[i]);
388 }
389 DEBUGF("total length : %d\n", len);
390 DEBUGF("\n");
391}
392
393#ifdef HAVE_LCD_BITMAP
394void print_img_cond_indexes(struct wps_data *data)
395{
396 DEBUGF("image conditional indexes :\n");
397 int i;
398 for (i=0; i < MAX_IMAGES; i++)
399 {
400 if (data->img[i].cond_index)
401 DEBUGF("%2d: %d\n", i, data->img[i].cond_index);
402 }
403 DEBUGF("\n");
404}
405#endif /*HAVE_LCD_BITMAP */
406
407#endif /* DEBUG */