1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2007 Nicolas Pennequin, Dan Everton, Matthias Mohr
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #if defined(DEBUG) || defined(SIMULATOR)
27 #include "wps_internals.h"
28 #include "skin_buffer.h"
39 #if defined(SIMULATOR) || defined(__PCTOOL__)
40 extern bool debug_wps
;
41 extern int wps_verbose_level
;
44 static char *next_str(bool next
) {
45 return next
? "next " : "";
48 static char *get_token_desc(struct wps_token
*token
, char *buf
,
49 int bufsize
, struct wps_data
*data
)
51 bool next
= token
->next
;
56 snprintf(buf
, bufsize
, "No token");
59 case WPS_TOKEN_UNKNOWN
:
60 snprintf(buf
, bufsize
, "Unknown token");
63 case WPS_TOKEN_CHARACTER
:
64 if (token
->value
.c
== '\n')
65 snprintf(buf
, bufsize
, "Character '\\n'");
67 snprintf(buf
, bufsize
, "Character '%c'",
71 case WPS_TOKEN_STRING
:
72 snprintf(buf
, bufsize
, "String '%s'",
73 (char*)token
->value
.data
);
76 #ifdef HAVE_LCD_BITMAP
77 case WPS_TOKEN_ALIGN_LEFT
:
78 snprintf(buf
, bufsize
, "align left");
81 case WPS_TOKEN_ALIGN_CENTER
:
82 snprintf(buf
, bufsize
, "align center");
85 case WPS_TOKEN_ALIGN_RIGHT
:
86 snprintf(buf
, bufsize
, "align right");
90 case WPS_TOKEN_SUBLINE_TIMEOUT
:
91 snprintf(buf
, bufsize
, "subline timeout value: %d",
95 case WPS_TOKEN_CONDITIONAL
:
96 snprintf(buf
, bufsize
, "conditional, %d options",
100 case WPS_TOKEN_CONDITIONAL_START
:
101 snprintf(buf
, bufsize
, "conditional start, next cond: %d",
105 case WPS_TOKEN_CONDITIONAL_OPTION
:
106 snprintf(buf
, bufsize
, "conditional option, next cond: %d",
110 case WPS_TOKEN_CONDITIONAL_END
:
111 snprintf(buf
, bufsize
, "conditional end");
114 #ifdef HAVE_LCD_BITMAP
115 case WPS_TOKEN_IMAGE_PRELOAD
:
116 snprintf(buf
, bufsize
, "preload image");
119 case WPS_TOKEN_IMAGE_PRELOAD_DISPLAY
:
121 char subimage
= '\0';
122 char label
= token
->value
.i
&0xFF;
123 struct gui_img
*img
= find_image(label
, data
);
124 if (img
&& img
->num_subimages
> 1)
125 subimage
= 'a' + (token
->value
.i
>>8);
126 snprintf(buf
, bufsize
, "display preloaded image '%c%c'",
131 case WPS_TOKEN_IMAGE_DISPLAY
:
132 snprintf(buf
, bufsize
, "display image");
136 #ifdef HAS_BUTTON_HOLD
137 case WPS_TOKEN_MAIN_HOLD
:
138 snprintf(buf
, bufsize
, "mode hold");
142 #ifdef HAS_REMOTE_BUTTON_HOLD
143 case WPS_TOKEN_REMOTE_HOLD
:
144 snprintf(buf
, bufsize
, "mode remote hold");
148 case WPS_TOKEN_REPEAT_MODE
:
149 snprintf(buf
, bufsize
, "mode repeat");
152 case WPS_TOKEN_PLAYBACK_STATUS
:
153 snprintf(buf
, bufsize
, "mode playback");
156 case WPS_TOKEN_RTC_DAY_OF_MONTH
:
157 snprintf(buf
, bufsize
, "rtc: day of month (01..31)");
159 case WPS_TOKEN_RTC_DAY_OF_MONTH_BLANK_PADDED
:
160 snprintf(buf
, bufsize
,
161 "rtc: day of month, blank padded ( 1..31)");
163 case WPS_TOKEN_RTC_HOUR_24_ZERO_PADDED
:
164 snprintf(buf
, bufsize
, "rtc: hour (00..23)");
166 case WPS_TOKEN_RTC_HOUR_24
:
167 snprintf(buf
, bufsize
, "rtc: hour ( 0..23)");
169 case WPS_TOKEN_RTC_HOUR_12_ZERO_PADDED
:
170 snprintf(buf
, bufsize
, "rtc: hour (01..12)");
172 case WPS_TOKEN_RTC_HOUR_12
:
173 snprintf(buf
, bufsize
, "rtc: hour ( 1..12)");
175 case WPS_TOKEN_RTC_MONTH
:
176 snprintf(buf
, bufsize
, "rtc: month (01..12)");
178 case WPS_TOKEN_RTC_MINUTE
:
179 snprintf(buf
, bufsize
, "rtc: minute (00..59)");
181 case WPS_TOKEN_RTC_SECOND
:
182 snprintf(buf
, bufsize
, "rtc: second (00..59)");
184 case WPS_TOKEN_RTC_YEAR_2_DIGITS
:
185 snprintf(buf
, bufsize
,
186 "rtc: last two digits of year (00..99)");
188 case WPS_TOKEN_RTC_YEAR_4_DIGITS
:
189 snprintf(buf
, bufsize
, "rtc: year (1970...)");
191 case WPS_TOKEN_RTC_AM_PM_UPPER
:
192 snprintf(buf
, bufsize
,
193 "rtc: upper case AM or PM indicator");
195 case WPS_TOKEN_RTC_AM_PM_LOWER
:
196 snprintf(buf
, bufsize
,
197 "rtc: lower case am or pm indicator");
199 case WPS_TOKEN_RTC_WEEKDAY_NAME
:
200 snprintf(buf
, bufsize
,
201 "rtc: abbreviated weekday name (Sun..Sat)");
203 case WPS_TOKEN_RTC_MONTH_NAME
:
204 snprintf(buf
, bufsize
,
205 "rtc: abbreviated month name (Jan..Dec)");
207 case WPS_TOKEN_RTC_DAY_OF_WEEK_START_MON
:
208 snprintf(buf
, bufsize
,
209 "rtc: day of week (1..7); 1 is Monday");
211 case WPS_TOKEN_RTC_DAY_OF_WEEK_START_SUN
:
212 snprintf(buf
, bufsize
,
213 "rtc: day of week (0..6); 0 is Sunday");
216 #if (CONFIG_CODEC == SWCODEC)
217 case WPS_TOKEN_CROSSFADE
:
218 snprintf(buf
, bufsize
, "crossfade");
221 case WPS_TOKEN_REPLAYGAIN
:
222 snprintf(buf
, bufsize
, "replaygain");
227 case WPS_TOKEN_ALBUMART_DISPLAY
:
228 snprintf(buf
, bufsize
, "album art display");
231 case WPS_TOKEN_ALBUMART_FOUND
:
232 snprintf(buf
, bufsize
, "%strack album art conditional",
237 #ifdef HAVE_LCD_BITMAP
238 case WPS_TOKEN_IMAGE_BACKDROP
:
239 snprintf(buf
, bufsize
, "backdrop image");
242 case WPS_TOKEN_IMAGE_PROGRESS_BAR
:
243 snprintf(buf
, bufsize
, "progressbar bitmap");
246 case WPS_TOKEN_PEAKMETER
:
247 snprintf(buf
, bufsize
, "peakmeter");
251 case WPS_TOKEN_PROGRESSBAR
:
252 snprintf(buf
, bufsize
, "progressbar");
255 #ifdef HAVE_LCD_CHARCELLS
256 case WPS_TOKEN_PLAYER_PROGRESSBAR
:
257 snprintf(buf
, bufsize
, "full line progressbar");
261 case WPS_TOKEN_TRACK_TIME_ELAPSED
:
262 snprintf(buf
, bufsize
, "time elapsed in track");
265 case WPS_TOKEN_TRACK_ELAPSED_PERCENT
:
266 snprintf(buf
, bufsize
, "played percentage of track");
269 case WPS_TOKEN_PLAYLIST_ENTRIES
:
270 snprintf(buf
, bufsize
, "number of entries in playlist");
273 case WPS_TOKEN_PLAYLIST_NAME
:
274 snprintf(buf
, bufsize
, "playlist name");
277 case WPS_TOKEN_PLAYLIST_POSITION
:
278 snprintf(buf
, bufsize
, "position in playlist");
281 case WPS_TOKEN_TRACK_TIME_REMAINING
:
282 snprintf(buf
, bufsize
, "time remaining in track");
285 case WPS_TOKEN_PLAYLIST_SHUFFLE
:
286 snprintf(buf
, bufsize
, "playlist shuffle mode");
289 case WPS_TOKEN_TRACK_LENGTH
:
290 snprintf(buf
, bufsize
, "track length");
293 case WPS_TOKEN_VOLUME
:
294 snprintf(buf
, bufsize
, "volume");
297 case WPS_TOKEN_METADATA_ARTIST
:
298 snprintf(buf
, bufsize
, "%strack artist",
302 case WPS_TOKEN_METADATA_COMPOSER
:
303 snprintf(buf
, bufsize
, "%strack composer",
307 case WPS_TOKEN_METADATA_ALBUM
:
308 snprintf(buf
, bufsize
, "%strack album",
312 case WPS_TOKEN_METADATA_GROUPING
:
313 snprintf(buf
, bufsize
, "%strack grouping",
317 case WPS_TOKEN_METADATA_GENRE
:
318 snprintf(buf
, bufsize
, "%strack genre",
322 case WPS_TOKEN_METADATA_DISC_NUMBER
:
323 snprintf(buf
, bufsize
, "%strack disc", next_str(next
));
326 case WPS_TOKEN_METADATA_TRACK_NUMBER
:
327 snprintf(buf
, bufsize
, "%strack number",
331 case WPS_TOKEN_METADATA_TRACK_TITLE
:
332 snprintf(buf
, bufsize
, "%strack title",
336 case WPS_TOKEN_METADATA_VERSION
:
337 snprintf(buf
, bufsize
, "%strack ID3 version",
341 case WPS_TOKEN_METADATA_ALBUM_ARTIST
:
342 snprintf(buf
, bufsize
, "%strack album artist",
346 case WPS_TOKEN_METADATA_COMMENT
:
347 snprintf(buf
, bufsize
, "%strack comment",
351 case WPS_TOKEN_METADATA_YEAR
:
352 snprintf(buf
, bufsize
, "%strack year", next_str(next
));
356 case WPS_TOKEN_DATABASE_PLAYCOUNT
:
357 snprintf(buf
, bufsize
, "track playcount (database)");
360 case WPS_TOKEN_DATABASE_RATING
:
361 snprintf(buf
, bufsize
, "track rating (database)");
364 case WPS_TOKEN_DATABASE_AUTOSCORE
:
365 snprintf(buf
, bufsize
, "track autoscore (database)");
369 case WPS_TOKEN_BATTERY_PERCENT
:
370 snprintf(buf
, bufsize
, "battery percentage");
373 case WPS_TOKEN_BATTERY_VOLTS
:
374 snprintf(buf
, bufsize
, "battery voltage");
377 case WPS_TOKEN_BATTERY_TIME
:
378 snprintf(buf
, bufsize
, "battery time left");
381 case WPS_TOKEN_BATTERY_CHARGER_CONNECTED
:
382 snprintf(buf
, bufsize
, "battery charger connected");
385 case WPS_TOKEN_BATTERY_CHARGING
:
386 snprintf(buf
, bufsize
, "battery charging");
389 case WPS_TOKEN_BATTERY_SLEEPTIME
:
390 snprintf(buf
, bufsize
, "sleep timer");
393 case WPS_TOKEN_FILE_BITRATE
:
394 snprintf(buf
, bufsize
, "%sfile bitrate", next_str(next
));
397 case WPS_TOKEN_FILE_CODEC
:
398 snprintf(buf
, bufsize
, "%sfile codec", next_str(next
));
401 case WPS_TOKEN_FILE_FREQUENCY
:
402 snprintf(buf
, bufsize
, "%sfile audio frequency in Hz",
406 case WPS_TOKEN_FILE_FREQUENCY_KHZ
:
407 snprintf(buf
, bufsize
, "%sfile audio frequency in KHz",
411 case WPS_TOKEN_FILE_NAME
:
412 snprintf(buf
, bufsize
, "%sfile name", next_str(next
));
415 case WPS_TOKEN_FILE_NAME_WITH_EXTENSION
:
416 snprintf(buf
, bufsize
, "%sfile name with extension",
420 case WPS_TOKEN_FILE_PATH
:
421 snprintf(buf
, bufsize
, "%sfile path", next_str(next
));
424 case WPS_TOKEN_FILE_SIZE
:
425 snprintf(buf
, bufsize
, "%sfile size", next_str(next
));
428 case WPS_TOKEN_FILE_VBR
:
429 snprintf(buf
, bufsize
, "%sfile is vbr", next_str(next
));
432 case WPS_TOKEN_FILE_DIRECTORY
:
433 snprintf(buf
, bufsize
, "%sfile directory, level: %d",
434 next_str(next
), token
->value
.i
);
437 #if (CONFIG_CODEC != MAS3507D)
438 case WPS_TOKEN_SOUND_PITCH
:
439 snprintf(buf
, bufsize
, "pitch value");
443 #if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
444 case WPS_TOKEN_VLED_HDD
:
445 snprintf(buf
, bufsize
, "display virtual HDD LED");
448 case WPS_VIEWPORT_ENABLE
:
449 snprintf(buf
, bufsize
, "enable VP:%d",
452 case WPS_TOKEN_BUTTON_VOLUME
:
453 snprintf(buf
, bufsize
, "Volume button timeout:%d",
457 snprintf(buf
, bufsize
, "FIXME (code: %d)",
465 #if defined(SIMULATOR) || defined(__PCTOOL__)
466 static void dump_wps_tokens(struct wps_data
*data
)
468 struct wps_token
*token
;
473 /* Dump parsed WPS */
474 for (i
= 0, token
= data
->tokens
; i
< data
->num_tokens
; i
++, token
++)
476 get_token_desc(token
, buf
, sizeof(buf
), data
);
481 case WPS_TOKEN_CONDITIONAL_START
:
485 case WPS_TOKEN_CONDITIONAL_END
:
493 if (wps_verbose_level
> 2)
495 for(j
= 0; j
< indent
; j
++) {
499 DEBUGF("[%3d] = (%2d) %s\n", i
, token
->type
, buf
);
504 static void print_line_info(struct wps_data
*data
)
506 struct skin_line
*line
;
507 struct skin_subline
*subline
;
508 if (wps_verbose_level
> 0)
510 struct skin_token_list
*viewport_list
;
511 for (viewport_list
= data
->viewports
;
512 viewport_list
; viewport_list
= viewport_list
->next
)
514 struct skin_viewport
*v
=
515 (struct skin_viewport
*)viewport_list
->token
->value
.data
;
516 DEBUGF("vp Label:'%c' Hidden flags:%x\n", v
->label
, v
->hidden_flags
);
518 DEBUGF("Number of tokens : %d\n", data
->num_tokens
);
522 if (wps_verbose_level
> 1)
525 struct skin_token_list
*viewport_list
;
526 for (viewport_list
= data
->viewports
;
527 viewport_list
; viewport_list
= viewport_list
->next
)
529 struct skin_viewport
*v
=
530 (struct skin_viewport
*)viewport_list
->token
->value
.data
;
531 DEBUGF("Viewport '%c' - +%d+%d (%dx%d)\n",v
->label
, v
->vp
.x
, v
->vp
.y
,
532 v
->vp
.width
, v
->vp
.height
);
533 for (line
= v
->lines
; line
; line
= line
->next
, line_number
++)
535 DEBUGF("Line %2d\n", line_number
);
536 int subline_number
= 0;
537 subline
= &line
->sublines
;
540 DEBUGF(" Subline %d: first_token=%3d, last_token=%3d",
541 subline_number
, subline
->first_token_idx
,subline
->last_token_idx
);
543 if (subline
->line_type
& WPS_REFRESH_SCROLL
)
544 DEBUGF(", scrolled");
545 else if (subline
->line_type
& WPS_REFRESH_PLAYER_PROGRESS
)
546 DEBUGF(", progressbar");
547 else if (subline
->line_type
& WPS_REFRESH_PEAK_METER
)
548 DEBUGF(", peakmeter");
551 subline
= subline
->next
;
562 void print_debug_info(struct wps_data
*data
, enum wps_parse_error fail
, int line
)
564 #if defined(SIMULATOR) || defined(__PCTOOL__)
565 if (debug_wps
&& wps_verbose_level
)
567 dump_wps_tokens(data
);
568 print_line_info(data
);
570 #endif /* SIMULATOR */
572 if (data
->num_tokens
>= WPS_MAX_TOKENS
- 1) {
573 DEBUGF("Warning: Max number of tokens was reached (%d)\n",
577 if (fail
!= PARSE_OK
)
581 DEBUGF("ERR: Failed parsing on line %d : ", line
);
587 case PARSE_FAIL_UNCLOSED_COND
:
588 DEBUGF("ERR: Unclosed conditional");
591 case PARSE_FAIL_INVALID_CHAR
:
592 DEBUGF("ERR: Unexpected conditional char after token %d: \"%s\"",
594 get_token_desc(&data
->tokens
[data
->num_tokens
-1], buf
, sizeof(buf
), data
)
598 case PARSE_FAIL_COND_SYNTAX_ERROR
:
599 DEBUGF("ERR: Conditional syntax error after token %d: \"%s\"",
601 get_token_desc(&data
->tokens
[data
->num_tokens
-1], buf
, sizeof(buf
), data
)
605 case PARSE_FAIL_COND_INVALID_PARAM
:
606 DEBUGF("ERR: Invalid parameter list for token %d: \"%s\"",
608 get_token_desc(&data
->tokens
[data
->num_tokens
], buf
, sizeof(buf
), data
)
612 case PARSE_FAIL_LIMITS_EXCEEDED
:
613 DEBUGF("ERR: Limits exceeded");
620 void debug_skin_usage(void)
622 if (wps_verbose_level
> 1)
623 DEBUGF("Skin buffer usage: %lu/%lu\n", (unsigned long)skin_buffer_usage(),
624 (unsigned long)(skin_buffer_usage() + skin_buffer_freespace()));
628 #endif /* DEBUG || SIMULATOR */