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"
29 #include "settings_list.h"
40 #if defined(SIMULATOR) || defined(__PCTOOL__)
41 extern bool debug_wps
;
42 extern int wps_verbose_level
;
45 static char *next_str(bool next
) {
46 return next
? "next " : "";
49 static char *get_token_desc(struct wps_token
*token
, char *buf
,
50 int bufsize
, struct wps_data
*data
)
52 #ifndef HAVE_LCD_BITMAP
53 (void)data
; /* kill charcell warning */
55 bool next
= token
->next
;
60 snprintf(buf
, bufsize
, "No token");
63 case WPS_TOKEN_UNKNOWN
:
64 snprintf(buf
, bufsize
, "Unknown token");
67 case WPS_TOKEN_CHARACTER
:
68 if (token
->value
.c
== '\n')
69 snprintf(buf
, bufsize
, "Character '\\n'");
71 snprintf(buf
, bufsize
, "Character '%c'",
75 case WPS_TOKEN_STRING
:
76 snprintf(buf
, bufsize
, "String '%s'",
77 (char*)token
->value
.data
);
79 case WPS_TOKEN_TRANSLATEDSTRING
:
80 snprintf(buf
, bufsize
, "String ID '%d'", token
->value
.i
);
83 #ifdef HAVE_LCD_BITMAP
84 case WPS_TOKEN_ALIGN_LEFT
:
85 snprintf(buf
, bufsize
, "align left");
88 case WPS_TOKEN_ALIGN_CENTER
:
89 snprintf(buf
, bufsize
, "align center");
92 case WPS_TOKEN_ALIGN_RIGHT
:
93 snprintf(buf
, bufsize
, "align right");
97 case WPS_TOKEN_SUBLINE_TIMEOUT
:
98 snprintf(buf
, bufsize
, "subline timeout value: %d",
102 case WPS_TOKEN_CONDITIONAL
:
103 snprintf(buf
, bufsize
, "conditional, %d options",
107 case WPS_TOKEN_CONDITIONAL_START
:
108 snprintf(buf
, bufsize
, "conditional start, next cond: %d",
112 case WPS_TOKEN_CONDITIONAL_OPTION
:
113 snprintf(buf
, bufsize
, "conditional option, next cond: %d",
117 case WPS_TOKEN_CONDITIONAL_END
:
118 snprintf(buf
, bufsize
, "conditional end");
121 #ifdef HAVE_LCD_BITMAP
122 case WPS_TOKEN_IMAGE_PRELOAD
:
123 snprintf(buf
, bufsize
, "preload image");
126 case WPS_TOKEN_IMAGE_PRELOAD_DISPLAY
:
128 char subimage
= '\0';
129 char label
= token
->value
.i
&0xFF;
130 struct gui_img
*img
= find_image(label
, data
);
131 if (img
&& img
->num_subimages
> 1)
132 subimage
= 'a' + (token
->value
.i
>>8);
133 snprintf(buf
, bufsize
, "display preloaded image '%c%c'",
138 case WPS_TOKEN_IMAGE_DISPLAY
:
139 snprintf(buf
, bufsize
, "display image");
143 #ifdef HAS_BUTTON_HOLD
144 case WPS_TOKEN_MAIN_HOLD
:
145 snprintf(buf
, bufsize
, "mode hold");
149 #ifdef HAS_REMOTE_BUTTON_HOLD
150 case WPS_TOKEN_REMOTE_HOLD
:
151 snprintf(buf
, bufsize
, "mode remote hold");
155 case WPS_TOKEN_REPEAT_MODE
:
156 snprintf(buf
, bufsize
, "mode repeat");
159 case WPS_TOKEN_PLAYBACK_STATUS
:
160 snprintf(buf
, bufsize
, "mode playback");
163 case WPS_TOKEN_RTC_PRESENT
:
164 snprintf(buf
, bufsize
, "rtc: present?");
166 case WPS_TOKEN_RTC_DAY_OF_MONTH
:
167 snprintf(buf
, bufsize
, "rtc: day of month (01..31)");
169 case WPS_TOKEN_RTC_DAY_OF_MONTH_BLANK_PADDED
:
170 snprintf(buf
, bufsize
,
171 "rtc: day of month, blank padded ( 1..31)");
173 case WPS_TOKEN_RTC_HOUR_24_ZERO_PADDED
:
174 snprintf(buf
, bufsize
, "rtc: hour (00..23)");
176 case WPS_TOKEN_RTC_HOUR_24
:
177 snprintf(buf
, bufsize
, "rtc: hour ( 0..23)");
179 case WPS_TOKEN_RTC_HOUR_12_ZERO_PADDED
:
180 snprintf(buf
, bufsize
, "rtc: hour (01..12)");
182 case WPS_TOKEN_RTC_HOUR_12
:
183 snprintf(buf
, bufsize
, "rtc: hour ( 1..12)");
185 case WPS_TOKEN_RTC_MONTH
:
186 snprintf(buf
, bufsize
, "rtc: month (01..12)");
188 case WPS_TOKEN_RTC_MINUTE
:
189 snprintf(buf
, bufsize
, "rtc: minute (00..59)");
191 case WPS_TOKEN_RTC_SECOND
:
192 snprintf(buf
, bufsize
, "rtc: second (00..59)");
194 case WPS_TOKEN_RTC_YEAR_2_DIGITS
:
195 snprintf(buf
, bufsize
,
196 "rtc: last two digits of year (00..99)");
198 case WPS_TOKEN_RTC_YEAR_4_DIGITS
:
199 snprintf(buf
, bufsize
, "rtc: year (1970...)");
201 case WPS_TOKEN_RTC_AM_PM_UPPER
:
202 snprintf(buf
, bufsize
,
203 "rtc: upper case AM or PM indicator");
205 case WPS_TOKEN_RTC_AM_PM_LOWER
:
206 snprintf(buf
, bufsize
,
207 "rtc: lower case am or pm indicator");
209 case WPS_TOKEN_RTC_WEEKDAY_NAME
:
210 snprintf(buf
, bufsize
,
211 "rtc: abbreviated weekday name (Sun..Sat)");
213 case WPS_TOKEN_RTC_MONTH_NAME
:
214 snprintf(buf
, bufsize
,
215 "rtc: abbreviated month name (Jan..Dec)");
217 case WPS_TOKEN_RTC_DAY_OF_WEEK_START_MON
:
218 snprintf(buf
, bufsize
,
219 "rtc: day of week (1..7); 1 is Monday");
221 case WPS_TOKEN_RTC_DAY_OF_WEEK_START_SUN
:
222 snprintf(buf
, bufsize
,
223 "rtc: day of week (0..6); 0 is Sunday");
226 #if (CONFIG_CODEC == SWCODEC)
227 case WPS_TOKEN_CROSSFADE
:
228 snprintf(buf
, bufsize
, "crossfade");
231 case WPS_TOKEN_REPLAYGAIN
:
232 snprintf(buf
, bufsize
, "replaygain");
237 case WPS_TOKEN_ALBUMART_DISPLAY
:
238 snprintf(buf
, bufsize
, "album art display");
241 case WPS_TOKEN_ALBUMART_FOUND
:
242 snprintf(buf
, bufsize
, "%strack album art conditional",
247 #ifdef HAVE_LCD_BITMAP
248 case WPS_TOKEN_IMAGE_BACKDROP
:
249 snprintf(buf
, bufsize
, "backdrop image");
252 case WPS_TOKEN_IMAGE_PROGRESS_BAR
:
253 snprintf(buf
, bufsize
, "progressbar bitmap");
256 case WPS_TOKEN_PEAKMETER
:
257 snprintf(buf
, bufsize
, "peakmeter");
261 case WPS_TOKEN_PROGRESSBAR
:
262 snprintf(buf
, bufsize
, "progressbar");
265 #ifdef HAVE_LCD_CHARCELLS
266 case WPS_TOKEN_PLAYER_PROGRESSBAR
:
267 snprintf(buf
, bufsize
, "full line progressbar");
271 case WPS_TOKEN_TRACK_TIME_ELAPSED
:
272 snprintf(buf
, bufsize
, "time elapsed in track");
275 case WPS_TOKEN_TRACK_ELAPSED_PERCENT
:
276 snprintf(buf
, bufsize
, "played percentage of track");
279 case WPS_TOKEN_PLAYLIST_ENTRIES
:
280 snprintf(buf
, bufsize
, "number of entries in playlist");
283 case WPS_TOKEN_PLAYLIST_NAME
:
284 snprintf(buf
, bufsize
, "playlist name");
287 case WPS_TOKEN_PLAYLIST_POSITION
:
288 snprintf(buf
, bufsize
, "position in playlist");
291 case WPS_TOKEN_TRACK_TIME_REMAINING
:
292 snprintf(buf
, bufsize
, "time remaining in track");
295 case WPS_TOKEN_PLAYLIST_SHUFFLE
:
296 snprintf(buf
, bufsize
, "playlist shuffle mode");
299 case WPS_TOKEN_TRACK_LENGTH
:
300 snprintf(buf
, bufsize
, "track length");
303 case WPS_TOKEN_VOLUME
:
304 snprintf(buf
, bufsize
, "volume");
307 case WPS_TOKEN_METADATA_ARTIST
:
308 snprintf(buf
, bufsize
, "%strack artist",
312 case WPS_TOKEN_METADATA_COMPOSER
:
313 snprintf(buf
, bufsize
, "%strack composer",
317 case WPS_TOKEN_METADATA_ALBUM
:
318 snprintf(buf
, bufsize
, "%strack album",
322 case WPS_TOKEN_METADATA_GROUPING
:
323 snprintf(buf
, bufsize
, "%strack grouping",
327 case WPS_TOKEN_METADATA_GENRE
:
328 snprintf(buf
, bufsize
, "%strack genre",
332 case WPS_TOKEN_METADATA_DISC_NUMBER
:
333 snprintf(buf
, bufsize
, "%strack disc", next_str(next
));
336 case WPS_TOKEN_METADATA_TRACK_NUMBER
:
337 snprintf(buf
, bufsize
, "%strack number",
341 case WPS_TOKEN_METADATA_TRACK_TITLE
:
342 snprintf(buf
, bufsize
, "%strack title",
346 case WPS_TOKEN_METADATA_VERSION
:
347 snprintf(buf
, bufsize
, "%strack ID3 version",
351 case WPS_TOKEN_METADATA_ALBUM_ARTIST
:
352 snprintf(buf
, bufsize
, "%strack album artist",
356 case WPS_TOKEN_METADATA_COMMENT
:
357 snprintf(buf
, bufsize
, "%strack comment",
361 case WPS_TOKEN_METADATA_YEAR
:
362 snprintf(buf
, bufsize
, "%strack year", next_str(next
));
366 case WPS_TOKEN_DATABASE_PLAYCOUNT
:
367 snprintf(buf
, bufsize
, "track playcount (database)");
370 case WPS_TOKEN_DATABASE_RATING
:
371 snprintf(buf
, bufsize
, "track rating (database)");
374 case WPS_TOKEN_DATABASE_AUTOSCORE
:
375 snprintf(buf
, bufsize
, "track autoscore (database)");
379 case WPS_TOKEN_BATTERY_PERCENT
:
380 snprintf(buf
, bufsize
, "battery percentage");
383 case WPS_TOKEN_BATTERY_VOLTS
:
384 snprintf(buf
, bufsize
, "battery voltage");
387 case WPS_TOKEN_BATTERY_TIME
:
388 snprintf(buf
, bufsize
, "battery time left");
391 case WPS_TOKEN_BATTERY_CHARGER_CONNECTED
:
392 snprintf(buf
, bufsize
, "battery charger connected");
395 case WPS_TOKEN_BATTERY_CHARGING
:
396 snprintf(buf
, bufsize
, "battery charging");
399 case WPS_TOKEN_BATTERY_SLEEPTIME
:
400 snprintf(buf
, bufsize
, "sleep timer");
403 case WPS_TOKEN_FILE_BITRATE
:
404 snprintf(buf
, bufsize
, "%sfile bitrate", next_str(next
));
407 case WPS_TOKEN_FILE_CODEC
:
408 snprintf(buf
, bufsize
, "%sfile codec", next_str(next
));
411 case WPS_TOKEN_FILE_FREQUENCY
:
412 snprintf(buf
, bufsize
, "%sfile audio frequency in Hz",
416 case WPS_TOKEN_FILE_FREQUENCY_KHZ
:
417 snprintf(buf
, bufsize
, "%sfile audio frequency in KHz",
421 case WPS_TOKEN_FILE_NAME
:
422 snprintf(buf
, bufsize
, "%sfile name", next_str(next
));
425 case WPS_TOKEN_FILE_NAME_WITH_EXTENSION
:
426 snprintf(buf
, bufsize
, "%sfile name with extension",
430 case WPS_TOKEN_FILE_PATH
:
431 snprintf(buf
, bufsize
, "%sfile path", next_str(next
));
434 case WPS_TOKEN_FILE_SIZE
:
435 snprintf(buf
, bufsize
, "%sfile size", next_str(next
));
438 case WPS_TOKEN_FILE_VBR
:
439 snprintf(buf
, bufsize
, "%sfile is vbr", next_str(next
));
442 case WPS_TOKEN_FILE_DIRECTORY
:
443 snprintf(buf
, bufsize
, "%sfile directory, level: %d",
444 next_str(next
), token
->value
.i
);
447 #if (CONFIG_CODEC != MAS3507D)
448 case WPS_TOKEN_SOUND_PITCH
:
449 snprintf(buf
, bufsize
, "pitch value");
453 #if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
454 case WPS_TOKEN_VLED_HDD
:
455 snprintf(buf
, bufsize
, "display virtual HDD LED");
458 case WPS_VIEWPORT_ENABLE
:
459 snprintf(buf
, bufsize
, "enable VP: %c",
460 (char)token
->value
.i
);
462 case WPS_TOKEN_BUTTON_VOLUME
:
463 snprintf(buf
, bufsize
, "Volume button timeout: %d",
466 case WPS_TOKEN_SETTING
:
467 snprintf(buf
, bufsize
, "Setting value: '%s'",
468 settings
[token
->value
.i
].cfg_name
);
471 snprintf(buf
, bufsize
, "FIXME (code: %d)",
479 #if defined(SIMULATOR) || defined(__PCTOOL__)
480 static void dump_skin(struct wps_data
*data
)
486 struct skin_token_list
*viewport_list
;
487 for (viewport_list
= data
->viewports
;
488 viewport_list
; viewport_list
= viewport_list
->next
)
490 struct skin_viewport
*skin_viewport
=
491 (struct skin_viewport
*)viewport_list
->token
->value
.data
;
493 DEBUGF("Viewport: '%c'\n", skin_viewport
->label
);
494 struct skin_line
*line
;
495 for (line
= skin_viewport
->lines
; line
; line
= line
->next
)
497 struct skin_subline
*subline
;
499 for(subline
= &line
->sublines
; subline
; subline
= subline
->next
)
501 DEBUGF(" Subline: tokens %d => %d",
502 subline
->first_token_idx
,subline
->last_token_idx
);
503 if (subline
->line_type
& WPS_REFRESH_SCROLL
)
504 DEBUGF(", scrolled");
505 else if (subline
->line_type
& WPS_REFRESH_PLAYER_PROGRESS
)
506 DEBUGF(", progressbar");
507 else if (subline
->line_type
& WPS_REFRESH_PEAK_METER
)
508 DEBUGF(", peakmeter");
511 for (i
= subline
->first_token_idx
; i
<= subline
->last_token_idx
; i
++)
513 struct wps_token
*token
= &data
->tokens
[i
];
514 get_token_desc(token
, buf
, sizeof(buf
), data
);
519 case WPS_TOKEN_CONDITIONAL_START
:
523 case WPS_TOKEN_CONDITIONAL_END
:
531 if (wps_verbose_level
> 2)
533 for(j
= 0; j
< indent
; j
++) {
537 DEBUGF("[%3d] = (%2d) %s\n", i
, token
->type
, buf
);
546 void print_debug_info(struct wps_data
*data
, enum wps_parse_error fail
, int line
)
548 #if defined(SIMULATOR) || defined(__PCTOOL__)
549 if (debug_wps
&& wps_verbose_level
)
553 #endif /* SIMULATOR */
555 if (data
->num_tokens
>= WPS_MAX_TOKENS
- 1) {
556 DEBUGF("Warning: Max number of tokens was reached (%d)\n",
560 if (fail
!= PARSE_OK
)
564 DEBUGF("ERR: Failed parsing on line %d : ", line
);
570 case PARSE_FAIL_UNCLOSED_COND
:
571 DEBUGF("ERR: Unclosed conditional");
574 case PARSE_FAIL_INVALID_CHAR
:
575 DEBUGF("ERR: Unexpected conditional char after token %d: \"%s\"",
577 get_token_desc(&data
->tokens
[data
->num_tokens
-1], buf
, sizeof(buf
), data
)
581 case PARSE_FAIL_COND_SYNTAX_ERROR
:
582 DEBUGF("ERR: Conditional syntax error after token %d: \"%s\"",
584 get_token_desc(&data
->tokens
[data
->num_tokens
-1], buf
, sizeof(buf
), data
)
588 case PARSE_FAIL_COND_INVALID_PARAM
:
589 DEBUGF("ERR: Invalid parameter list for token %d: \"%s\"",
591 get_token_desc(&data
->tokens
[data
->num_tokens
], buf
, sizeof(buf
), data
)
595 case PARSE_FAIL_LIMITS_EXCEEDED
:
596 DEBUGF("ERR: Limits exceeded");
603 void debug_skin_usage(void)
605 if (wps_verbose_level
> 1)
606 DEBUGF("Skin buffer usage: %lu/%lu\n", (unsigned long)skin_buffer_usage(),
607 (unsigned long)(skin_buffer_usage() + skin_buffer_freespace()));
611 #endif /* DEBUG || SIMULATOR */