1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2007 Nicolas Pennequin
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 ****************************************************************************/
24 #include "screen_access.h"
25 #include "statusbar.h"
28 /* constants used in line_type and as refresh_mode for wps_refresh */
29 #define WPS_REFRESH_STATIC (1u<<0) /* line doesn't change over time */
30 #define WPS_REFRESH_DYNAMIC (1u<<1) /* line may change (e.g. time flag) */
31 #define WPS_REFRESH_SCROLL (1u<<2) /* line scrolls */
32 #define WPS_REFRESH_PLAYER_PROGRESS (1u<<3) /* line contains a progress bar */
33 #define WPS_REFRESH_PEAK_METER (1u<<4) /* line contains a peak meter */
34 #define WPS_REFRESH_STATUSBAR (1u<<5) /* refresh statusbar */
35 #define WPS_REFRESH_ALL (0xffffffffu) /* to refresh all line types */
37 /* to refresh only those lines that change over time */
38 #define WPS_REFRESH_NON_STATIC (WPS_REFRESH_DYNAMIC| \
39 WPS_REFRESH_PLAYER_PROGRESS| \
40 WPS_REFRESH_PEAK_METER)
42 #define WPS_ALIGN_RIGHT 32
43 #define WPS_ALIGN_CENTER 64
44 #define WPS_ALIGN_LEFT 128
48 /* albumart definitions */
49 #define WPS_ALBUMART_NONE 0 /* WPS does not contain AA tag */
50 #define WPS_ALBUMART_CHECK 1 /* WPS contains AA conditional tag */
51 #define WPS_ALBUMART_LOAD 2 /* WPS contains AA tag */
53 #define WPS_ALBUMART_ALIGN_RIGHT 1 /* x align: right */
54 #define WPS_ALBUMART_ALIGN_CENTER 2 /* x/y align: center */
55 #define WPS_ALBUMART_ALIGN_LEFT 4 /* x align: left */
56 #define WPS_ALBUMART_ALIGN_TOP 1 /* y align: top */
57 #define WPS_ALBUMART_ALIGN_BOTTOM 4 /* y align: bottom */
59 #endif /* HAVE_ALBUMART */
63 #ifdef HAVE_LCD_BITMAP
66 struct viewport
* vp
; /* The viewport to display this image in */
67 short int x
; /* x-pos */
68 short int y
; /* y-pos */
69 short int num_subimages
; /* number of sub-images */
70 short int subimage_height
; /* height of each sub-image */
71 short int display
; /* -1 for no display, 0..n to display a subimage */
72 bool loaded
; /* load state */
73 bool always_display
; /* not using the preload/display mechanism */
79 /* >=0: explicitly set in the tag -> y-coord within the viewport
80 <0 : not set in the tag -> negated 1-based line number within
81 the viewport. y-coord will be computed based on the font height */
97 #ifdef HAVE_LCD_BITMAP
99 #define MAX_IMAGES (26*2) /* a-z and A-Z */
100 #define MAX_PROGRESSBARS 3
102 /* The image buffer is big enough to store one full-screen native bitmap,
103 plus two full-screen mono bitmaps. */
105 #define IMG_BUFSIZE ((LCD_HEIGHT*LCD_WIDTH*LCD_DEPTH/8) \
106 + (2*LCD_HEIGHT*LCD_WIDTH/8))
108 #define WPS_MAX_VIEWPORTS 24
109 #define WPS_MAX_LINES ((LCD_HEIGHT/5+1) * 2)
110 #define WPS_MAX_SUBLINES (WPS_MAX_LINES*3)
111 #define WPS_MAX_TOKENS 1024
112 #define WPS_MAX_STRINGS 128
113 #define STRING_BUFFER_SIZE 1024
114 #define WPS_MAX_COND_LEVEL 10
118 #define WPS_MAX_VIEWPORTS 2
119 #define WPS_MAX_LINES 2
120 #define WPS_MAX_SUBLINES 12
121 #define WPS_MAX_TOKENS 64
122 #define WPS_MAX_STRINGS 32
123 #define STRING_BUFFER_SIZE 64
124 #define WPS_MAX_COND_LEVEL 5
128 #define SUBLINE_RESET -1
130 enum wps_parse_error
{
132 PARSE_FAIL_UNCLOSED_COND
,
133 PARSE_FAIL_INVALID_CHAR
,
134 PARSE_FAIL_COND_SYNTAX_ERROR
,
135 PARSE_FAIL_COND_INVALID_PARAM
,
136 PARSE_FAIL_LIMITS_EXCEEDED
,
139 enum wps_token_type
{
140 WPS_NO_TOKEN
, /* for WPS tags we don't want to save as tokens */
148 WPS_TOKEN_ALIGN_LEFT
,
149 WPS_TOKEN_ALIGN_CENTER
,
150 WPS_TOKEN_ALIGN_RIGHT
,
153 WPS_TOKEN_SUBLINE_TIMEOUT
,
156 WPS_TOKEN_BATTERY_PERCENT
,
157 WPS_TOKEN_BATTERY_VOLTS
,
158 WPS_TOKEN_BATTERY_TIME
,
159 WPS_TOKEN_BATTERY_CHARGER_CONNECTED
,
160 WPS_TOKEN_BATTERY_CHARGING
,
161 WPS_TOKEN_BATTERY_SLEEPTIME
,
164 #if (CONFIG_CODEC != MAS3507D)
165 WPS_TOKEN_SOUND_PITCH
,
167 #if (CONFIG_CODEC == SWCODEC)
168 WPS_TOKEN_REPLAYGAIN
,
174 /* The begin/end values allow us to know if a token is an RTC one.
175 New RTC tokens should be added between the markers. */
177 WPS_TOKENS_RTC_BEGIN
, /* just the start marker, not an actual token */
179 WPS_TOKEN_RTC_DAY_OF_MONTH
,
180 WPS_TOKEN_RTC_DAY_OF_MONTH_BLANK_PADDED
,
181 WPS_TOKEN_RTC_12HOUR_CFG
,
182 WPS_TOKEN_RTC_HOUR_24_ZERO_PADDED
,
183 WPS_TOKEN_RTC_HOUR_24
,
184 WPS_TOKEN_RTC_HOUR_12_ZERO_PADDED
,
185 WPS_TOKEN_RTC_HOUR_12
,
187 WPS_TOKEN_RTC_MINUTE
,
188 WPS_TOKEN_RTC_SECOND
,
189 WPS_TOKEN_RTC_YEAR_2_DIGITS
,
190 WPS_TOKEN_RTC_YEAR_4_DIGITS
,
191 WPS_TOKEN_RTC_AM_PM_UPPER
,
192 WPS_TOKEN_RTC_AM_PM_LOWER
,
193 WPS_TOKEN_RTC_WEEKDAY_NAME
,
194 WPS_TOKEN_RTC_MONTH_NAME
,
195 WPS_TOKEN_RTC_DAY_OF_WEEK_START_MON
,
196 WPS_TOKEN_RTC_DAY_OF_WEEK_START_SUN
,
198 WPS_TOKENS_RTC_END
, /* just the end marker, not an actual token */
201 WPS_TOKEN_CONDITIONAL
,
202 WPS_TOKEN_CONDITIONAL_START
,
203 WPS_TOKEN_CONDITIONAL_OPTION
,
204 WPS_TOKEN_CONDITIONAL_END
,
208 WPS_TOKEN_DATABASE_PLAYCOUNT
,
209 WPS_TOKEN_DATABASE_RATING
,
210 WPS_TOKEN_DATABASE_AUTOSCORE
,
214 WPS_TOKEN_FILE_BITRATE
,
215 WPS_TOKEN_FILE_CODEC
,
216 WPS_TOKEN_FILE_FREQUENCY
,
217 WPS_TOKEN_FILE_FREQUENCY_KHZ
,
219 WPS_TOKEN_FILE_NAME_WITH_EXTENSION
,
223 WPS_TOKEN_FILE_DIRECTORY
,
225 #ifdef HAVE_LCD_BITMAP
227 WPS_TOKEN_IMAGE_BACKDROP
,
228 WPS_TOKEN_IMAGE_PROGRESS_BAR
,
229 WPS_TOKEN_IMAGE_PRELOAD
,
230 WPS_TOKEN_IMAGE_PRELOAD_DISPLAY
,
231 WPS_TOKEN_IMAGE_DISPLAY
,
236 WPS_TOKEN_ALBUMART_DISPLAY
,
237 WPS_TOKEN_ALBUMART_FOUND
,
241 WPS_TOKEN_METADATA_ARTIST
,
242 WPS_TOKEN_METADATA_COMPOSER
,
243 WPS_TOKEN_METADATA_ALBUM_ARTIST
,
244 WPS_TOKEN_METADATA_GROUPING
,
245 WPS_TOKEN_METADATA_ALBUM
,
246 WPS_TOKEN_METADATA_GENRE
,
247 WPS_TOKEN_METADATA_DISC_NUMBER
,
248 WPS_TOKEN_METADATA_TRACK_NUMBER
,
249 WPS_TOKEN_METADATA_TRACK_TITLE
,
250 WPS_TOKEN_METADATA_VERSION
,
251 WPS_TOKEN_METADATA_YEAR
,
252 WPS_TOKEN_METADATA_COMMENT
,
255 WPS_TOKEN_REPEAT_MODE
,
256 WPS_TOKEN_PLAYBACK_STATUS
,
260 #ifdef HAS_REMOTE_BUTTON_HOLD
261 WPS_TOKEN_REMOTE_HOLD
,
265 WPS_TOKEN_PROGRESSBAR
,
266 #ifdef HAVE_LCD_CHARCELLS
267 WPS_TOKEN_PLAYER_PROGRESSBAR
,
270 #ifdef HAVE_LCD_BITMAP
279 WPS_TOKEN_TRACK_ELAPSED_PERCENT
,
280 WPS_TOKEN_TRACK_TIME_ELAPSED
,
281 WPS_TOKEN_TRACK_TIME_REMAINING
,
282 WPS_TOKEN_TRACK_LENGTH
,
285 WPS_TOKEN_PLAYLIST_ENTRIES
,
286 WPS_TOKEN_PLAYLIST_NAME
,
287 WPS_TOKEN_PLAYLIST_POSITION
,
288 WPS_TOKEN_PLAYLIST_SHUFFLE
,
290 #if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
295 /* Viewport display */
299 WPS_TOKEN_BUTTON_VOLUME
,
306 unsigned char type
; /* enough to store the token type */
308 /* Whether the tag (e.g. track name or the album) refers the
309 current or the next song (false=current, true=next) */
318 /* Description of a subline on the WPS */
321 /* Index of the first token for this subline in the token array.
322 Tokens of this subline end where tokens for the next subline
324 unsigned short first_token_idx
;
326 /* Bit or'ed WPS_REFRESH_xxx */
327 unsigned char line_type
;
329 /* How long the subline should be displayed, in 10ths of sec */
330 unsigned char time_mult
;
333 /* Description of a line on the WPS. A line is a set of sublines.
334 A subline is displayed for a certain amount of time. After that,
335 the next subline of the line is displayed. And so on. */
338 /* Number of sublines in this line */
339 signed char num_sublines
;
341 /* Number (0-based) of the subline within this line currently being displayed */
342 signed char curr_subline
;
344 /* Index of the first subline of this line in the subline array.
345 Sublines for this line end where sublines for the next line begin. */
346 unsigned short first_subline_idx
;
348 /* When the next subline of this line should be displayed
349 (absolute time value in ticks) */
350 long subline_expire_time
;
353 #define VP_DRAW_HIDEABLE 0x1
354 #define VP_DRAW_HIDDEN 0x2
355 #define VP_DRAW_WASHIDDEN 0x4
356 struct wps_viewport
{
357 struct viewport vp
; /* The LCD viewport struct */
358 struct progressbar
*pb
;
359 /* Indexes of the first and last lines belonging to this viewport in the
361 int first_line
, last_line
;
367 this struct holds all necessary data which describes the
368 viewable content of a wps */
371 #ifdef HAVE_LCD_BITMAP
372 struct gui_img img
[MAX_IMAGES
];
373 unsigned char img_buf
[IMG_BUFSIZE
];
374 unsigned char* img_buf_ptr
;
379 struct progressbar progressbar
[MAX_PROGRESSBARS
];
380 short progressbar_count
;
382 bool peak_meter_enabled
;
385 /* Album art support */
386 unsigned char wps_uses_albumart
; /* WPS_ALBUMART_NONE, _CHECK, _LOAD */
389 unsigned char albumart_xalign
; /* WPS_ALBUMART_ALIGN_LEFT, _CENTER, _RIGHT */
390 unsigned char albumart_yalign
; /* WPS_ALBUMART_ALIGN_TOP, _CENTER, _BOTTOM */
391 short albumart_max_width
;
392 short albumart_max_height
;
394 int albumart_cond_index
;
397 #else /*HAVE_LCD_CHARCELLS */
398 unsigned short wps_progress_pat
[8];
399 bool full_line_progressbar
;
402 #ifdef HAVE_REMOTE_LCD
406 /* Number of lines in the WPS. During WPS parsing, this is
407 the index of the line being parsed. */
410 /* Number of viewports in the WPS */
412 struct wps_viewport viewports
[WPS_MAX_VIEWPORTS
];
414 struct wps_line lines
[WPS_MAX_LINES
];
416 /* Total number of sublines in the WPS. During WPS parsing, this is
417 the index of the subline where the parsed tokens are added to. */
419 struct wps_subline sublines
[WPS_MAX_SUBLINES
];
421 /* Total number of tokens in the WPS. During WPS parsing, this is
422 the index of the token being parsed. */
424 struct wps_token tokens
[WPS_MAX_TOKENS
];
426 char string_buffer
[STRING_BUFFER_SIZE
];
427 char *strings
[WPS_MAX_STRINGS
];
432 /* tick the volume button was last pressed */
433 unsigned int button_time_volume
;
436 /* initial setup of wps_data */
437 void wps_data_init(struct wps_data
*wps_data
);
439 /* to setup up the wps-data from a format-buffer (isfile = false)
440 from a (wps-)file (isfile = true)*/
441 bool wps_data_load(struct wps_data
*wps_data
,
442 struct screen
*display
,
446 /* Redraw statusbars if necessary */
447 void gwps_draw_statusbars(void);
449 /* Returns the index of the subline in the subline array
450 line - 0-based line number
451 subline - 0-based subline number within the line
453 int wps_subline_index(struct wps_data
*wps_data
, int line
, int subline
);
455 /* Returns the index of the first subline's token in the token array
456 line - 0-based line number
457 subline - 0-based subline number within the line
459 int wps_first_token_index(struct wps_data
*data
, int line
, int subline
);
461 /* Returns the index of the last subline's token in the token array.
462 line - 0-based line number
463 subline - 0-based subline number within the line
465 int wps_last_token_index(struct wps_data
*data
, int line
, int subline
);
470 holds the data which belongs to the current played track,
471 the track which will be played afterwards, current path to the track
472 and some status infos */
478 bool wps_time_countup
;
479 struct mp3entry
* id3
;
480 struct mp3entry
* nid3
;
485 /* change the ff/rew-status
486 if ff_rew = true then we are in skipping mode
487 else we are in normal mode */
488 /* void wps_state_update_ff_rew(bool ff_rew); Currently unused */
490 /* change the tag-information of the current played track
491 and the following track */
492 /* void wps_state_update_id3_nid3(struct mp3entry *id3, struct mp3entry *nid3); Currently unused */
496 defines a wps with its data, state,
497 and the screen on which the wps-content should be drawn */
500 struct screen
*display
;
501 struct wps_data
*data
;
502 struct wps_state
*state
;
507 long gui_wps_show(void);
509 /* currently only on wps_state is needed */
510 extern struct wps_state wps_state
;
511 extern struct gui_wps gui_wps
[NB_SCREENS
];
513 void gui_sync_wps_init(void);
516 /* gives back if WPS contains an albumart tag */
517 bool gui_sync_wps_uses_albumart(void);