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 1 /* line doesn't change over time */
30 #define WPS_REFRESH_DYNAMIC 2 /* line may change (e.g. time flag) */
31 #define WPS_REFRESH_SCROLL 4 /* line scrolls */
32 #define WPS_REFRESH_PLAYER_PROGRESS 8 /* line contains a progress bar */
33 #define WPS_REFRESH_PEAK_METER 16 /* line contains a peak meter */
34 #define WPS_REFRESH_ALL 0xff /* to refresh all line types */
35 /* to refresh only those lines that change over time */
36 #define WPS_REFRESH_NON_STATIC (WPS_REFRESH_ALL & ~WPS_REFRESH_STATIC & ~WPS_REFRESH_SCROLL)
39 #define WPS_ALIGN_RIGHT 32
40 #define WPS_ALIGN_CENTER 64
41 #define WPS_ALIGN_LEFT 128
45 /* albumart definitions */
46 #define WPS_ALBUMART_NONE 0 /* WPS does not contain AA tag */
47 #define WPS_ALBUMART_CHECK 1 /* WPS contains AA conditional tag */
48 #define WPS_ALBUMART_LOAD 2 /* WPS contains AA tag */
50 #define WPS_ALBUMART_ALIGN_RIGHT WPS_ALIGN_RIGHT /* x align: right */
51 #define WPS_ALBUMART_ALIGN_CENTER WPS_ALIGN_CENTER /* x/y align: center */
52 #define WPS_ALBUMART_ALIGN_LEFT WPS_ALIGN_LEFT /* x align: left */
53 #define WPS_ALBUMART_ALIGN_TOP WPS_ALIGN_RIGHT /* y align: top */
54 #define WPS_ALBUMART_ALIGN_BOTTOM WPS_ALIGN_LEFT /* y align: bottom */
55 #define WPS_ALBUMART_INCREASE 8 /* increase if smaller */
56 #define WPS_ALBUMART_DECREASE 16 /* decrease if larger */
58 #endif /* HAVE_ALBUMART */
62 #ifdef HAVE_LCD_BITMAP
65 struct viewport
* vp
; /* The viewport to display this image in */
66 short int x
; /* x-pos */
67 short int y
; /* y-pos */
68 short int num_subimages
; /* number of sub-images */
69 short int subimage_height
; /* height of each sub-image */
70 short int display
; /* -1 for no display, 0..n to display a subimage */
71 bool loaded
; /* load state */
72 bool always_display
; /* not using the preload/display mechanism */
93 #ifdef HAVE_LCD_BITMAP
95 #define MAX_IMAGES (26*2) /* a-z and A-Z */
96 #define MAX_PROGRESSBARS 3
98 /* The image buffer is big enough to store one full-screen native bitmap,
99 plus two full-screen mono bitmaps. */
101 #define IMG_BUFSIZE ((LCD_HEIGHT*LCD_WIDTH*LCD_DEPTH/8) \
102 + (2*LCD_HEIGHT*LCD_WIDTH/8))
104 #define WPS_MAX_VIEWPORTS 24
105 #define WPS_MAX_LINES ((LCD_HEIGHT/5+1) * 2)
106 #define WPS_MAX_SUBLINES (WPS_MAX_LINES*3)
107 #define WPS_MAX_TOKENS 1024
108 #define WPS_MAX_STRINGS 128
109 #define STRING_BUFFER_SIZE 1024
110 #define WPS_MAX_COND_LEVEL 10
114 #define WPS_MAX_VIEWPORTS 2
115 #define WPS_MAX_LINES 2
116 #define WPS_MAX_SUBLINES 12
117 #define WPS_MAX_TOKENS 64
118 #define WPS_MAX_STRINGS 32
119 #define STRING_BUFFER_SIZE 64
120 #define WPS_MAX_COND_LEVEL 5
124 #define DEFAULT_SUBLINE_TIME_MULTIPLIER 20 /* (10ths of sec) */
125 #define BASE_SUBLINE_TIME 10 /* base time that multiplier is applied to
126 (1/HZ sec, or 100ths of sec) */
127 #define SUBLINE_RESET -1
129 enum wps_parse_error
{
131 PARSE_FAIL_UNCLOSED_COND
,
132 PARSE_FAIL_INVALID_CHAR
,
133 PARSE_FAIL_COND_SYNTAX_ERROR
,
134 PARSE_FAIL_COND_INVALID_PARAM
,
135 PARSE_FAIL_LIMITS_EXCEEDED
,
138 enum wps_token_type
{
139 WPS_NO_TOKEN
, /* for WPS tags we don't want to save as tokens */
147 WPS_TOKEN_ALIGN_LEFT
,
148 WPS_TOKEN_ALIGN_CENTER
,
149 WPS_TOKEN_ALIGN_RIGHT
,
152 WPS_TOKEN_SUBLINE_TIMEOUT
,
155 WPS_TOKEN_BATTERY_PERCENT
,
156 WPS_TOKEN_BATTERY_VOLTS
,
157 WPS_TOKEN_BATTERY_TIME
,
158 WPS_TOKEN_BATTERY_CHARGER_CONNECTED
,
159 WPS_TOKEN_BATTERY_CHARGING
,
160 WPS_TOKEN_BATTERY_SLEEPTIME
,
163 #if (CONFIG_CODEC != MAS3507D)
164 WPS_TOKEN_SOUND_PITCH
,
166 #if (CONFIG_CODEC == SWCODEC)
167 WPS_TOKEN_REPLAYGAIN
,
173 /* The begin/end values allow us to know if a token is an RTC one.
174 New RTC tokens should be added between the markers. */
176 WPS_TOKENS_RTC_BEGIN
, /* just the start marker, not an actual token */
178 WPS_TOKEN_RTC_DAY_OF_MONTH
,
179 WPS_TOKEN_RTC_DAY_OF_MONTH_BLANK_PADDED
,
180 WPS_TOKEN_RTC_12HOUR_CFG
,
181 WPS_TOKEN_RTC_HOUR_24_ZERO_PADDED
,
182 WPS_TOKEN_RTC_HOUR_24
,
183 WPS_TOKEN_RTC_HOUR_12_ZERO_PADDED
,
184 WPS_TOKEN_RTC_HOUR_12
,
186 WPS_TOKEN_RTC_MINUTE
,
187 WPS_TOKEN_RTC_SECOND
,
188 WPS_TOKEN_RTC_YEAR_2_DIGITS
,
189 WPS_TOKEN_RTC_YEAR_4_DIGITS
,
190 WPS_TOKEN_RTC_AM_PM_UPPER
,
191 WPS_TOKEN_RTC_AM_PM_LOWER
,
192 WPS_TOKEN_RTC_WEEKDAY_NAME
,
193 WPS_TOKEN_RTC_MONTH_NAME
,
194 WPS_TOKEN_RTC_DAY_OF_WEEK_START_MON
,
195 WPS_TOKEN_RTC_DAY_OF_WEEK_START_SUN
,
197 WPS_TOKENS_RTC_END
, /* just the end marker, not an actual token */
200 WPS_TOKEN_CONDITIONAL
,
201 WPS_TOKEN_CONDITIONAL_START
,
202 WPS_TOKEN_CONDITIONAL_OPTION
,
203 WPS_TOKEN_CONDITIONAL_END
,
207 WPS_TOKEN_DATABASE_PLAYCOUNT
,
208 WPS_TOKEN_DATABASE_RATING
,
209 WPS_TOKEN_DATABASE_AUTOSCORE
,
213 WPS_TOKEN_FILE_BITRATE
,
214 WPS_TOKEN_FILE_CODEC
,
215 WPS_TOKEN_FILE_FREQUENCY
,
216 WPS_TOKEN_FILE_FREQUENCY_KHZ
,
218 WPS_TOKEN_FILE_NAME_WITH_EXTENSION
,
222 WPS_TOKEN_FILE_DIRECTORY
,
224 #ifdef HAVE_LCD_BITMAP
226 WPS_TOKEN_IMAGE_BACKDROP
,
227 WPS_TOKEN_IMAGE_PROGRESS_BAR
,
228 WPS_TOKEN_IMAGE_PRELOAD
,
229 WPS_TOKEN_IMAGE_PRELOAD_DISPLAY
,
230 WPS_TOKEN_IMAGE_DISPLAY
,
235 WPS_TOKEN_ALBUMART_DISPLAY
,
236 WPS_TOKEN_ALBUMART_FOUND
,
240 WPS_TOKEN_METADATA_ARTIST
,
241 WPS_TOKEN_METADATA_COMPOSER
,
242 WPS_TOKEN_METADATA_ALBUM_ARTIST
,
243 WPS_TOKEN_METADATA_GROUPING
,
244 WPS_TOKEN_METADATA_ALBUM
,
245 WPS_TOKEN_METADATA_GENRE
,
246 WPS_TOKEN_METADATA_DISC_NUMBER
,
247 WPS_TOKEN_METADATA_TRACK_NUMBER
,
248 WPS_TOKEN_METADATA_TRACK_TITLE
,
249 WPS_TOKEN_METADATA_VERSION
,
250 WPS_TOKEN_METADATA_YEAR
,
251 WPS_TOKEN_METADATA_COMMENT
,
254 WPS_TOKEN_REPEAT_MODE
,
255 WPS_TOKEN_PLAYBACK_STATUS
,
259 #ifdef HAS_REMOTE_BUTTON_HOLD
260 WPS_TOKEN_REMOTE_HOLD
,
264 WPS_TOKEN_PROGRESSBAR
,
265 #ifdef HAVE_LCD_CHARCELLS
266 WPS_TOKEN_PLAYER_PROGRESSBAR
,
269 #ifdef HAVE_LCD_BITMAP
278 WPS_TOKEN_TRACK_ELAPSED_PERCENT
,
279 WPS_TOKEN_TRACK_TIME_ELAPSED
,
280 WPS_TOKEN_TRACK_TIME_REMAINING
,
281 WPS_TOKEN_TRACK_LENGTH
,
284 WPS_TOKEN_PLAYLIST_ENTRIES
,
285 WPS_TOKEN_PLAYLIST_NAME
,
286 WPS_TOKEN_PLAYLIST_POSITION
,
287 WPS_TOKEN_PLAYLIST_SHUFFLE
,
289 #if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
294 /* Viewport display */
298 WPS_TOKEN_BUTTON_VOLUME
302 unsigned char type
; /* enough to store the token type */
304 /* Whether the tag (e.g. track name or the album) refers the
305 current or the next song (false=current, true=next) */
314 /* Description of a subline on the WPS */
317 /* Index of the first token for this subline in the token array.
318 Tokens of this subline end where tokens for the next subline
320 unsigned short first_token_idx
;
322 /* Bit or'ed WPS_REFRESH_xxx */
323 unsigned char line_type
;
325 /* How long the subline should be displayed, in 10ths of sec */
326 unsigned char time_mult
;
329 /* Description of a line on the WPS. A line is a set of sublines.
330 A subline is displayed for a certain amount of time. After that,
331 the next subline of the line is displayed. And so on. */
334 /* Number of sublines in this line */
335 signed char num_sublines
;
337 /* Number (0-based) of the subline within this line currently being displayed */
338 signed char curr_subline
;
340 /* Index of the first subline of this line in the subline array.
341 Sublines for this line end where sublines for the next line begin. */
342 unsigned short first_subline_idx
;
344 /* When the next subline of this line should be displayed
345 (absolute time value in ticks) */
346 long subline_expire_time
;
349 #define VP_DRAW_HIDEABLE 0x1
350 #define VP_DRAW_HIDDEN 0x2
351 #define VP_DRAW_WASHIDDEN 0x4
352 struct wps_viewport
{
353 struct viewport vp
; /* The LCD viewport struct */
354 struct progressbar
*pb
;
355 /* Indexes of the first and last lines belonging to this viewport in the
357 int first_line
, last_line
;
363 this struct holds all necessary data which describes the
364 viewable content of a wps */
367 #ifdef HAVE_LCD_BITMAP
368 struct gui_img img
[MAX_IMAGES
];
369 unsigned char img_buf
[IMG_BUFSIZE
];
370 unsigned char* img_buf_ptr
;
375 struct progressbar progressbar
[MAX_PROGRESSBARS
];
376 short progressbar_count
;
378 bool peak_meter_enabled
;
381 /* Album art support */
382 unsigned char wps_uses_albumart
; /* WPS_ALBUMART_NONE, _CHECK, _LOAD */
385 unsigned short albumart_xalign
; /* WPS_ALBUMART_ALIGN_LEFT, _CENTER, _RIGHT,
386 + .._INCREASE, + .._DECREASE */
387 unsigned short albumart_yalign
; /* WPS_ALBUMART_ALIGN_TOP, _CENTER, _BOTTOM,
388 + .._INCREASE, + .._DECREASE */
389 short albumart_max_width
;
390 short albumart_max_height
;
392 int albumart_cond_index
;
395 #else /*HAVE_LCD_CHARCELLS */
396 unsigned short wps_progress_pat
[8];
397 bool full_line_progressbar
;
400 #ifdef HAVE_REMOTE_LCD
404 /* Number of lines in the WPS. During WPS parsing, this is
405 the index of the line being parsed. */
408 /* Number of viewports in the WPS */
410 struct wps_viewport viewports
[WPS_MAX_VIEWPORTS
];
412 struct wps_line lines
[WPS_MAX_LINES
];
414 /* Total number of sublines in the WPS. During WPS parsing, this is
415 the index of the subline where the parsed tokens are added to. */
417 struct wps_subline sublines
[WPS_MAX_SUBLINES
];
419 /* Total number of tokens in the WPS. During WPS parsing, this is
420 the index of the token being parsed. */
422 struct wps_token tokens
[WPS_MAX_TOKENS
];
424 char string_buffer
[STRING_BUFFER_SIZE
];
425 char *strings
[WPS_MAX_STRINGS
];
430 /* tick the volume button was last pressed */
431 unsigned int button_time_volume
;
434 /* initial setup of wps_data */
435 void wps_data_init(struct wps_data
*wps_data
);
437 /* to setup up the wps-data from a format-buffer (isfile = false)
438 from a (wps-)file (isfile = true)*/
439 bool wps_data_load(struct wps_data
*wps_data
,
440 struct screen
*display
,
444 /* Returns the index of the subline in the subline array
445 line - 0-based line number
446 subline - 0-based subline number within the line
448 int wps_subline_index(struct wps_data
*wps_data
, int line
, int subline
);
450 /* Returns the index of the first subline's token in the token array
451 line - 0-based line number
452 subline - 0-based subline number within the line
454 int wps_first_token_index(struct wps_data
*data
, int line
, int subline
);
456 /* Returns the index of the last subline's token in the token array.
457 line - 0-based line number
458 subline - 0-based subline number within the line
460 int wps_last_token_index(struct wps_data
*data
, int line
, int subline
);
465 holds the data which belongs to the current played track,
466 the track which will be played afterwards, current path to the track
467 and some status infos */
473 bool wps_time_countup
;
474 struct mp3entry
* id3
;
475 struct mp3entry
* nid3
;
476 char current_track_path
[MAX_PATH
];
480 /* change the ff/rew-status
481 if ff_rew = true then we are in skipping mode
482 else we are in normal mode */
483 /* void wps_state_update_ff_rew(bool ff_rew); Currently unused */
485 /* change the tag-information of the current played track
486 and the following track */
487 /* void wps_state_update_id3_nid3(struct mp3entry *id3, struct mp3entry *nid3); Currently unused */
491 defines a wps with its data, state,
492 and the screen on which the wps-content should be drawn */
495 struct screen
*display
;
496 struct wps_data
*data
;
497 struct wps_state
*state
;
498 struct gui_statusbar
*statusbar
;
503 long gui_wps_show(void);
505 /* currently only on wps_state is needed */
506 extern struct wps_state wps_state
;
507 extern struct gui_wps gui_wps
[NB_SCREENS
];
509 void gui_sync_wps_init(void);
510 void gui_sync_wps_screen_init(void);
513 /* gives back if WPS contains an albumart tag */
514 bool gui_sync_wps_uses_albumart(void);