1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2007 Nicolas Pennequin
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
22 #include "screen_access.h"
23 #include "statusbar.h"
26 /* constants used in line_type and as refresh_mode for wps_refresh */
27 #define WPS_REFRESH_STATIC 1 /* line doesn't change over time */
28 #define WPS_REFRESH_DYNAMIC 2 /* line may change (e.g. time flag) */
29 #define WPS_REFRESH_SCROLL 4 /* line scrolls */
30 #define WPS_REFRESH_PLAYER_PROGRESS 8 /* line contains a progress bar */
31 #define WPS_REFRESH_PEAK_METER 16 /* line contains a peak meter */
32 #define WPS_REFRESH_ALL 0xff /* to refresh all line types */
33 /* to refresh only those lines that change over time */
34 #define WPS_REFRESH_NON_STATIC (WPS_REFRESH_ALL & ~WPS_REFRESH_STATIC & ~WPS_REFRESH_SCROLL)
37 #define WPS_ALIGN_RIGHT 32
38 #define WPS_ALIGN_CENTER 64
39 #define WPS_ALIGN_LEFT 128
43 /* albumart definitions */
44 #define WPS_ALBUMART_NONE 0 /* WPS does not contain AA tag */
45 #define WPS_ALBUMART_CHECK 1 /* WPS contains AA conditional tag */
46 #define WPS_ALBUMART_LOAD 2 /* WPS contains AA tag */
48 #define WPS_ALBUMART_ALIGN_RIGHT WPS_ALIGN_RIGHT /* x align: right */
49 #define WPS_ALBUMART_ALIGN_CENTER WPS_ALIGN_CENTER /* x/y align: center */
50 #define WPS_ALBUMART_ALIGN_LEFT WPS_ALIGN_LEFT /* x align: left */
51 #define WPS_ALBUMART_ALIGN_TOP WPS_ALIGN_RIGHT /* y align: top */
52 #define WPS_ALBUMART_ALIGN_BOTTOM WPS_ALIGN_LEFT /* y align: bottom */
53 #define WPS_ALBUMART_INCREASE 8 /* increase if smaller */
54 #define WPS_ALBUMART_DECREASE 16 /* decrease if larger */
56 #endif /* HAVE_ALBUMART */
60 #ifdef HAVE_LCD_BITMAP
63 struct viewport
* vp
; /* The viewport to display this image in */
64 short int x
; /* x-pos */
65 short int y
; /* y-pos */
66 short int num_subimages
; /* number of sub-images */
67 short int subimage_height
; /* height of each sub-image */
68 short int display
; /* -1 for no display, 0..n to display a subimage */
69 bool loaded
; /* load state */
70 bool always_display
; /* not using the preload/display mechanism */
73 struct prog_img
{ /*progressbar image*/
85 #ifdef HAVE_LCD_BITMAP
87 #define MAX_IMAGES (26*2) /* a-z and A-Z */
89 /* The image buffer is big enough to store one full-screen native bitmap,
90 plus two full-screen mono bitmaps. */
92 #define IMG_BUFSIZE ((LCD_HEIGHT*LCD_WIDTH*LCD_DEPTH/8) \
93 + (2*LCD_HEIGHT*LCD_WIDTH/8))
95 #define WPS_MAX_VIEWPORTS 16
96 #define WPS_MAX_LINES ((LCD_HEIGHT/5+1) * 2)
97 #define WPS_MAX_SUBLINES (WPS_MAX_LINES*3)
98 #define WPS_MAX_TOKENS 1024
99 #define WPS_MAX_STRINGS 128
100 #define STRING_BUFFER_SIZE 1024
101 #define WPS_MAX_COND_LEVEL 10
105 #define WPS_MAX_VIEWPORTS 2
106 #define WPS_MAX_LINES 2
107 #define WPS_MAX_SUBLINES 12
108 #define WPS_MAX_TOKENS 64
109 #define WPS_MAX_STRINGS 32
110 #define STRING_BUFFER_SIZE 64
111 #define WPS_MAX_COND_LEVEL 5
115 #define DEFAULT_SUBLINE_TIME_MULTIPLIER 20 /* (10ths of sec) */
116 #define BASE_SUBLINE_TIME 10 /* base time that multiplier is applied to
117 (1/HZ sec, or 100ths of sec) */
118 #define SUBLINE_RESET -1
120 enum wps_token_type
{
121 WPS_NO_TOKEN
, /* for WPS tags we don't want to save as tokens */
129 WPS_TOKEN_ALIGN_LEFT
,
130 WPS_TOKEN_ALIGN_CENTER
,
131 WPS_TOKEN_ALIGN_RIGHT
,
132 WPS_TOKEN_LEFTMARGIN
,
135 WPS_TOKEN_SUBLINE_TIMEOUT
,
138 WPS_TOKEN_BATTERY_PERCENT
,
139 WPS_TOKEN_BATTERY_VOLTS
,
140 WPS_TOKEN_BATTERY_TIME
,
141 WPS_TOKEN_BATTERY_CHARGER_CONNECTED
,
142 WPS_TOKEN_BATTERY_CHARGING
,
143 WPS_TOKEN_BATTERY_SLEEPTIME
,
146 #if (CONFIG_CODEC != MAS3507D)
147 WPS_TOKEN_SOUND_PITCH
,
149 #if (CONFIG_CODEC == SWCODEC)
150 WPS_TOKEN_REPLAYGAIN
,
156 /* The begin/end values allow us to know if a token is an RTC one.
157 New RTC tokens should be added between the markers. */
159 WPS_TOKENS_RTC_BEGIN
, /* just the start marker, not an actual token */
161 WPS_TOKEN_RTC_DAY_OF_MONTH
,
162 WPS_TOKEN_RTC_DAY_OF_MONTH_BLANK_PADDED
,
163 WPS_TOKEN_RTC_12HOUR_CFG
,
164 WPS_TOKEN_RTC_HOUR_24_ZERO_PADDED
,
165 WPS_TOKEN_RTC_HOUR_24
,
166 WPS_TOKEN_RTC_HOUR_12_ZERO_PADDED
,
167 WPS_TOKEN_RTC_HOUR_12
,
169 WPS_TOKEN_RTC_MINUTE
,
170 WPS_TOKEN_RTC_SECOND
,
171 WPS_TOKEN_RTC_YEAR_2_DIGITS
,
172 WPS_TOKEN_RTC_YEAR_4_DIGITS
,
173 WPS_TOKEN_RTC_AM_PM_UPPER
,
174 WPS_TOKEN_RTC_AM_PM_LOWER
,
175 WPS_TOKEN_RTC_WEEKDAY_NAME
,
176 WPS_TOKEN_RTC_MONTH_NAME
,
177 WPS_TOKEN_RTC_DAY_OF_WEEK_START_MON
,
178 WPS_TOKEN_RTC_DAY_OF_WEEK_START_SUN
,
180 WPS_TOKENS_RTC_END
, /* just the end marker, not an actual token */
183 WPS_TOKEN_CONDITIONAL
,
184 WPS_TOKEN_CONDITIONAL_START
,
185 WPS_TOKEN_CONDITIONAL_OPTION
,
186 WPS_TOKEN_CONDITIONAL_END
,
190 WPS_TOKEN_DATABASE_PLAYCOUNT
,
191 WPS_TOKEN_DATABASE_RATING
,
192 WPS_TOKEN_DATABASE_AUTOSCORE
,
196 WPS_TOKEN_FILE_BITRATE
,
197 WPS_TOKEN_FILE_CODEC
,
198 WPS_TOKEN_FILE_FREQUENCY
,
199 WPS_TOKEN_FILE_FREQUENCY_KHZ
,
201 WPS_TOKEN_FILE_NAME_WITH_EXTENSION
,
205 WPS_TOKEN_FILE_DIRECTORY
,
207 #ifdef HAVE_LCD_BITMAP
209 WPS_TOKEN_IMAGE_BACKDROP
,
210 WPS_TOKEN_IMAGE_PROGRESS_BAR
,
211 WPS_TOKEN_IMAGE_PRELOAD
,
212 WPS_TOKEN_IMAGE_PRELOAD_DISPLAY
,
213 WPS_TOKEN_IMAGE_DISPLAY
,
218 WPS_TOKEN_ALBUMART_DISPLAY
,
219 WPS_TOKEN_ALBUMART_FOUND
,
223 WPS_TOKEN_METADATA_ARTIST
,
224 WPS_TOKEN_METADATA_COMPOSER
,
225 WPS_TOKEN_METADATA_ALBUM_ARTIST
,
226 WPS_TOKEN_METADATA_GROUPING
,
227 WPS_TOKEN_METADATA_ALBUM
,
228 WPS_TOKEN_METADATA_GENRE
,
229 WPS_TOKEN_METADATA_DISC_NUMBER
,
230 WPS_TOKEN_METADATA_TRACK_NUMBER
,
231 WPS_TOKEN_METADATA_TRACK_TITLE
,
232 WPS_TOKEN_METADATA_VERSION
,
233 WPS_TOKEN_METADATA_YEAR
,
234 WPS_TOKEN_METADATA_COMMENT
,
237 WPS_TOKEN_REPEAT_MODE
,
238 WPS_TOKEN_PLAYBACK_STATUS
,
242 #ifdef HAS_REMOTE_BUTTON_HOLD
243 WPS_TOKEN_REMOTE_HOLD
,
247 WPS_TOKEN_PROGRESSBAR
,
248 #ifdef HAVE_LCD_CHARCELLS
249 WPS_TOKEN_PLAYER_PROGRESSBAR
,
252 #ifdef HAVE_LCD_BITMAP
261 WPS_TOKEN_TRACK_ELAPSED_PERCENT
,
262 WPS_TOKEN_TRACK_TIME_ELAPSED
,
263 WPS_TOKEN_TRACK_TIME_REMAINING
,
264 WPS_TOKEN_TRACK_LENGTH
,
267 WPS_TOKEN_PLAYLIST_ENTRIES
,
268 WPS_TOKEN_PLAYLIST_NAME
,
269 WPS_TOKEN_PLAYLIST_POSITION
,
270 WPS_TOKEN_PLAYLIST_SHUFFLE
,
272 #if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
279 unsigned char type
; /* enough to store the token type */
281 /* Whether the tag (e.g. track name or the album) refers the
282 current or the next song (false=current, true=next) */
291 /* Description of a subline on the WPS */
294 /* Index of the first token for this subline in the token array.
295 Tokens of this subline end where tokens for the next subline
297 unsigned short first_token_idx
;
299 /* Bit or'ed WPS_REFRESH_xxx */
300 unsigned char line_type
;
302 /* How long the subline should be displayed, in 10ths of sec */
303 unsigned char time_mult
;
306 /* Description of a line on the WPS. A line is a set of sublines.
307 A subline is displayed for a certain amount of time. After that,
308 the next subline of the line is displayed. And so on. */
311 /* Number of sublines in this line */
312 signed char num_sublines
;
314 /* Number (0-based) of the subline within this line currently being displayed */
315 signed char curr_subline
;
317 /* Index of the first subline of this line in the subline array.
318 Sublines for this line end where sublines for the next line begin. */
319 unsigned short first_subline_idx
;
321 /* When the next subline of this line should be displayed
322 (absolute time value in ticks) */
323 long subline_expire_time
;
326 struct wps_viewport
{
327 struct viewport vp
; /* The LCD viewport struct */
329 /* Indexes of the first and last lines belonging to this viewport in the
331 int first_line
, last_line
;
335 this struct holds all necessary data which describes the
336 viewable content of a wps */
339 #ifdef HAVE_LCD_BITMAP
340 struct gui_img img
[MAX_IMAGES
];
341 struct prog_img progressbar
;
342 unsigned char img_buf
[IMG_BUFSIZE
];
343 unsigned char* img_buf_ptr
;
349 short progress_height
;
350 short progress_start
;
352 bool peak_meter_enabled
;
355 /* Album art support */
356 unsigned char wps_uses_albumart
; /* WPS_ALBUMART_NONE, _CHECK, _LOAD */
359 unsigned short albumart_xalign
; /* WPS_ALBUMART_ALIGN_LEFT, _CENTER, _RIGHT,
360 + .._INCREASE, + .._DECREASE */
361 unsigned short albumart_yalign
; /* WPS_ALBUMART_ALIGN_TOP, _CENTER, _BOTTOM,
362 + .._INCREASE, + .._DECREASE */
363 short albumart_max_width
;
364 short albumart_max_height
;
366 int albumart_cond_index
;
369 #else /*HAVE_LCD_CHARCELLS */
370 unsigned short wps_progress_pat
[8];
371 bool full_line_progressbar
;
374 #ifdef HAVE_REMOTE_LCD
378 /* Number of lines in the WPS. During WPS parsing, this is
379 the index of the line being parsed. */
382 /* Number of viewports in the WPS */
384 struct wps_viewport viewports
[WPS_MAX_VIEWPORTS
];
386 struct wps_line lines
[WPS_MAX_LINES
];
388 /* Total number of sublines in the WPS. During WPS parsing, this is
389 the index of the subline where the parsed tokens are added to. */
391 struct wps_subline sublines
[WPS_MAX_SUBLINES
];
393 /* Total number of tokens in the WPS. During WPS parsing, this is
394 the index of the token being parsed. */
396 struct wps_token tokens
[WPS_MAX_TOKENS
];
398 char string_buffer
[STRING_BUFFER_SIZE
];
399 char *strings
[WPS_MAX_STRINGS
];
405 /* initial setup of wps_data */
406 void wps_data_init(struct wps_data
*wps_data
);
408 /* to setup up the wps-data from a format-buffer (isfile = false)
409 from a (wps-)file (isfile = true)*/
410 bool wps_data_load(struct wps_data
*wps_data
,
411 struct screen
*display
,
415 /* Returns the index of the subline in the subline array
416 line - 0-based line number
417 subline - 0-based subline number within the line
419 int wps_subline_index(struct wps_data
*wps_data
, int line
, int subline
);
421 /* Returns the index of the first subline's token in the token array
422 line - 0-based line number
423 subline - 0-based subline number within the line
425 int wps_first_token_index(struct wps_data
*data
, int line
, int subline
);
427 /* Returns the index of the last subline's token in the token array.
428 line - 0-based line number
429 subline - 0-based subline number within the line
431 int wps_last_token_index(struct wps_data
*data
, int line
, int subline
);
436 holds the data which belongs to the current played track,
437 the track which will be played afterwards, current path to the track
438 and some status infos */
444 bool wps_time_countup
;
445 struct mp3entry
* id3
;
446 struct mp3entry
* nid3
;
447 char current_track_path
[MAX_PATH
];
451 /* change the ff/rew-status
452 if ff_rew = true then we are in skipping mode
453 else we are in normal mode */
454 /* void wps_state_update_ff_rew(bool ff_rew); Currently unused */
456 /* change the tag-information of the current played track
457 and the following track */
458 /* void wps_state_update_id3_nid3(struct mp3entry *id3, struct mp3entry *nid3); Currently unused */
462 defines a wps with its data, state,
463 and the screen on which the wps-content should be drawn */
466 struct screen
*display
;
467 struct wps_data
*data
;
468 struct wps_state
*state
;
469 struct gui_statusbar
*statusbar
;
474 long gui_wps_show(void);
476 /* currently only on wps_state is needed */
477 extern struct wps_state wps_state
;
478 extern struct gui_wps gui_wps
[NB_SCREENS
];
480 void gui_sync_wps_init(void);
481 void gui_sync_wps_screen_init(void);
484 /* gives back if WPS contains an albumart tag */
485 bool gui_sync_wps_uses_albumart(void);