summaryrefslogtreecommitdiff
path: root/apps/gui/wps_debug.c
blob: 48aadc627d02e18f38c5a5ab0d251e8115f5bab4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
/***************************************************************************
 *             __________               __   ___.
 *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
 *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
 *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
 *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
 *                     \/            \/     \/    \/            \/
 * $Id$
 *
 * Copyright (C) 2007 Nicolas Pennequin, Dan Everton, Matthias Mohr
 *
 * All files in this archive are subject to the GNU General Public License.
 * See the file COPYING in the source tree root for full license agreement.
 *
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
 * KIND, either express or implied.
 *
 ****************************************************************************/

#ifdef DEBUG

#include <stdio.h>
#include <string.h>
#include "gwps.h"
#include "debug.h"

void dump_wps_tokens(struct wps_data *data)
{
    int i, j;
    int indent = 0;
    char buf[64];
    bool next;

    /* Dump parsed WPS */
    for(i = 0; i < data->num_tokens && i < WPS_MAX_TOKENS; i++) {

        next = data->tokens[i].next;

        switch(data->tokens[i].type) {
            case WPS_TOKEN_UNKNOWN:
                snprintf(buf, sizeof(buf), "Unknown token");
                break;
            case WPS_TOKEN_CHARACTER:
                snprintf(buf, sizeof(buf), "Character '%c'",
                         data->tokens[i].value.c);
                break;

            case WPS_TOKEN_STRING:
                snprintf(buf, sizeof(buf), "String '%s'",
                         data->strings[data->tokens[i].value.i]);
                break;

            case WPS_TOKEN_EOL:
                snprintf(buf, sizeof(buf), "%s", "EOL");
                break;

#ifdef HAVE_LCD_BITMAP
            case WPS_TOKEN_ALIGN_LEFT:
                snprintf(buf, sizeof(buf), "%s", "align left");
                break;

            case WPS_TOKEN_ALIGN_CENTER:
                snprintf(buf, sizeof(buf), "%s", "align center");
                break;

            case WPS_TOKEN_ALIGN_RIGHT:
                snprintf(buf, sizeof(buf), "%s", "align right");
                break;
#endif

            case WPS_TOKEN_CONDITIONAL:
            snprintf(buf, sizeof(buf), "%s, %d options", "conditional",
                     data->tokens[i].value.i);
                break;

            case WPS_TOKEN_CONDITIONAL_START:
                snprintf(buf, sizeof(buf), "%s, next cond: %d",
                         "conditional start", data->tokens[i].value.i);
                indent++;
                break;

            case WPS_TOKEN_CONDITIONAL_OPTION:
                snprintf(buf, sizeof(buf), "%s, next cond: %d",
                         "conditional option", data->tokens[i].value.i);
                break;

            case WPS_TOKEN_CONDITIONAL_END:
                snprintf(buf, sizeof(buf), "%s", "conditional end");
                indent--;
                break;

#ifdef HAVE_LCD_BITMAP
            case WPS_TOKEN_IMAGE_PRELOAD:
                snprintf(buf, sizeof(buf), "%s", "preload image");
                break;

            case WPS_TOKEN_IMAGE_PRELOAD_DISPLAY:
                snprintf(buf, sizeof(buf), "%s %d", "display preloaded image",
                         data->tokens[i].value.i);
                break;

            case WPS_TOKEN_IMAGE_DISPLAY:
                snprintf(buf, sizeof(buf), "%s", "display image");
                break;
#endif

#ifdef HAS_BUTTON_HOLD
            case WPS_TOKEN_MAIN_HOLD:
                snprintf(buf, sizeof(buf), "%s", "mode hold");
                break;
#endif

#ifdef HAS_REMOTE_BUTTON_HOLD
            case WPS_TOKEN_REMOTE_HOLD:
                snprintf(buf, sizeof(buf), "%s", "mode remote hold");
                break;
#endif

            case WPS_TOKEN_REPEAT_MODE:
                snprintf(buf, sizeof(buf), "%s", "mode repeat");
                break;

            case WPS_TOKEN_PLAYBACK_STATUS:
                snprintf(buf, sizeof(buf), "%s", "mode playback");
                break;

#if CONFIG_RTC
            case WPS_TOKEN_RTC_DAY_OF_MONTH:
            case WPS_TOKEN_RTC_DAY_OF_MONTH_BLANK_PADDED:
            case WPS_TOKEN_RTC_HOUR_24_ZERO_PADDED:
            case WPS_TOKEN_RTC_HOUR_24:
            case WPS_TOKEN_RTC_HOUR_12_ZERO_PADDED:
            case WPS_TOKEN_RTC_HOUR_12:
            case WPS_TOKEN_RTC_MONTH:
            case WPS_TOKEN_RTC_MINUTE:
            case WPS_TOKEN_RTC_SECOND:
            case WPS_TOKEN_RTC_YEAR_2_DIGITS:
            case WPS_TOKEN_RTC_YEAR_4_DIGITS:
            case WPS_TOKEN_RTC_AM_PM_UPPER:
            case WPS_TOKEN_RTC_AM_PM_LOWER:
            case WPS_TOKEN_RTC_WEEKDAY_NAME:
            case WPS_TOKEN_RTC_MONTH_NAME:
            case WPS_TOKEN_RTC_DAY_OF_WEEK_START_MON:
            case WPS_TOKEN_RTC_DAY_OF_WEEK_START_SUN:
            case WPS_TOKEN_RTC:
            snprintf(buf, sizeof(buf), "%s %c", "real-time clock tag:",
                     data->tokens[i].value.c);
                break;
#endif

#ifdef HAVE_LCD_BITMAP
            case WPS_TOKEN_IMAGE_BACKDROP:
                snprintf(buf, sizeof(buf), "%s", "backdrop image");
                break;

            case WPS_TOKEN_IMAGE_PROGRESS_BAR:
                snprintf(buf, sizeof(buf), "%s", "progressbar bitmap");
                break;


            case WPS_TOKEN_STATUSBAR_ENABLED:
                snprintf(buf, sizeof(buf), "%s", "statusbar enable");
                break;

            case WPS_TOKEN_STATUSBAR_DISABLED:
                snprintf(buf, sizeof(buf), "%s", "statusbar disable");
                break;

            case WPS_TOKEN_PEAKMETER:
                snprintf(buf, sizeof(buf), "%s", "peakmeter");
                break;
#endif

            case WPS_TOKEN_PROGRESSBAR:
                snprintf(buf, sizeof(buf), "%s", "progressbar");
                break;

#ifdef HAVE_LCD_CHARCELLS
            case WPS_TOKEN_PLAYER_PROGRESSBAR:
                snprintf(buf, sizeof(buf), "%s", "full line progressbar");
                break;
#endif

            case WPS_TOKEN_TRACK_TIME_ELAPSED:
                snprintf(buf, sizeof(buf), "%s", "time elapsed in track");
                break;

            case WPS_TOKEN_PLAYLIST_ENTRIES:
                snprintf(buf, sizeof(buf), "%s", "number of entries in playlist");
                break;

            case WPS_TOKEN_PLAYLIST_NAME:
                snprintf(buf, sizeof(buf), "%s", "playlist name");
                break;

            case WPS_TOKEN_PLAYLIST_POSITION:
                snprintf(buf, sizeof(buf), "%s", "position in playlist");
                break;

            case WPS_TOKEN_TRACK_TIME_REMAINING:
                snprintf(buf, sizeof(buf), "%s", "time remaining in track");
                break;

            case WPS_TOKEN_PLAYLIST_SHUFFLE:
                snprintf(buf, sizeof(buf), "%s", "playlist shuffle mode");
                break;

            case WPS_TOKEN_TRACK_LENGTH:
                snprintf(buf, sizeof(buf), "%s", "track length");
                break;

            case WPS_TOKEN_VOLUME:
                snprintf(buf, sizeof(buf), "%s", "volume");
                break;

            case WPS_TOKEN_METADATA_ARTIST:
                snprintf(buf, sizeof(buf), "%s%s", next ? "next " : "",
                         "track artist");
                break;

            case WPS_TOKEN_METADATA_COMPOSER:
                snprintf(buf, sizeof(buf), "%s%s", next ? "next " : "",
                         "track composer");
                break;

            case WPS_TOKEN_METADATA_ALBUM:
                snprintf(buf, sizeof(buf), "%s%s", next ? "next " : "",
                         "track album");
                break;

            case WPS_TOKEN_METADATA_GENRE:
                snprintf(buf, sizeof(buf), "%s%s", next ? "next " : "",
                         "track genre");
                break;

            case WPS_TOKEN_METADATA_TRACK_NUMBER:
                snprintf(buf, sizeof(buf), "%s%s", next ? "next " : "",
                         "track number");
                break;

            case WPS_TOKEN_METADATA_TRACK_TITLE:
                snprintf(buf, sizeof(buf), "%s%s", next ? "next " : "",
                         "track title");
                break;

            case WPS_TOKEN_METADATA_VERSION:
                snprintf(buf, sizeof(buf), "%s%s", next ? "next " : "",
                         "track ID3 version");
                break;

            case WPS_TOKEN_METADATA_YEAR:
                snprintf(buf, sizeof(buf), "%s%s", next ? "next " : "",
                         "track year");
                break;

            case WPS_TOKEN_BATTERY_PERCENT:
                snprintf(buf, sizeof(buf), "%s", "battery percentage");
                break;

            case WPS_TOKEN_BATTERY_VOLTS:
                snprintf(buf, sizeof(buf), "%s", "battery voltage");
                break;

            case WPS_TOKEN_BATTERY_TIME:
                snprintf(buf, sizeof(buf), "%s", "battery time left");
                break;

            case WPS_TOKEN_BATTERY_CHARGER_CONNECTED:
                snprintf(buf, sizeof(buf), "%s", "battery charger connected");
                break;

            case WPS_TOKEN_BATTERY_CHARGING:
                snprintf(buf, sizeof(buf), "%s", "battery charging");
                break;

            case WPS_TOKEN_FILE_BITRATE:
                snprintf(buf, sizeof(buf), "%s%s", next ? "next " : "",
                         "file bitrate");
                break;

            case WPS_TOKEN_FILE_CODEC:
                snprintf(buf, sizeof(buf), "%s%s", next ? "next " : "",
                         "file codec");
                break;

            case WPS_TOKEN_FILE_FREQUENCY:
                snprintf(buf, sizeof(buf), "%s%s", next ? "next " : "",
                         "file audio frequency");
                break;

            case WPS_TOKEN_FILE_NAME:
                snprintf(buf, sizeof(buf), "%s%s", next ? "next " : "",
                         "file name");
                break;

            case WPS_TOKEN_FILE_NAME_WITH_EXTENSION:
                snprintf(buf, sizeof(buf), "%s%s", next ? "next " : "",
                         "file name with extension");
                break;

            case WPS_TOKEN_FILE_PATH:
                snprintf(buf, sizeof(buf), "%s%s", next ? "next " : "",
                         "file path");
                break;

            case WPS_TOKEN_FILE_SIZE:
                snprintf(buf, sizeof(buf), "%s%s", next ? "next " : "",
                         "file size");
                break;

            case WPS_TOKEN_FILE_VBR:
                snprintf(buf, sizeof(buf), "%s%s", next ? "next " : "",
                         "file is vbr");
                break;

            case WPS_TOKEN_FILE_DIRECTORY:
                snprintf(buf, sizeof(buf), "%s%s: %d", next ? "next " : "",
                         "file directory, level",
                         data->tokens[i].value.i);
                break;

            case WPS_TOKEN_SCROLL:
                snprintf(buf, sizeof(buf), "%s", "scrolling line");
                break;

            case WPS_TOKEN_SUBLINE_TIMEOUT:
                snprintf(buf, sizeof(buf), "%s: %d", "subline timeout value",
                         data->tokens[i].value.i);
                break;

            case WPS_TOKEN_SUBLINE_SEPARATOR:
                snprintf(buf, sizeof(buf), "%s", "subline separator");
                break;

            default:
                snprintf(buf, sizeof(buf), "%s (code: %d)", "FIXME",
                         data->tokens[i].type);
                break;
        }

        for(j = 0; j < indent; j++) {
            DEBUGF("\t");
        }

        DEBUGF("[%03d] = %s\n", i, buf);
    }
    DEBUGF("\n");
}

void print_line_info(struct wps_data *data)
{
    int line, subline;

    DEBUGF("line/subline start indexes :\n");
    for (line = 0; line < data->num_lines; line++)
    {
        DEBUGF("%2d. ", line);
        for (subline = 0; subline < data->num_sublines[line]; subline++)
        {
            DEBUGF("%3d ", data->format_lines[line][subline]);
        }
        DEBUGF("\n");
    }

    DEBUGF("subline time multipliers :\n");
    for (line = 0; line < data->num_lines; line++)
    {
        DEBUGF("%2d. ", line);
        for (subline = 0; subline < data->num_sublines[line]; subline++)
        {
            DEBUGF("%3d ", data->time_mult[line][subline]);
        }
        DEBUGF("\n");
    }

    DEBUGF("\n");
}

void print_wps_strings(struct wps_data *data)
{
    DEBUGF("strings :\n");
    int i, len = 0;
    for (i=0; i < data->num_strings; i++)
    {
        len += strlen(data->strings[i]);
        DEBUGF("%2d: '%s'\n", i, data->strings[i]);
    }
    DEBUGF("total length : %d\n", len);
    DEBUGF("\n");
}

#ifdef HAVE_LCD_BITMAP
void print_img_cond_indexes(struct wps_data *data)
{
    DEBUGF("image conditional indexes :\n");
    int i;
    for (i=0; i < MAX_IMAGES; i++)
    {
        if (data->img[i].cond_index)
            DEBUGF("%2d: %d\n", i, data->img[i].cond_index);
    }
    DEBUGF("\n");
}
#endif /*HAVE_LCD_BITMAP */

#endif /* DEBUG */