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 ****************************************************************************/
22 /* This stuff is for the wps engine only.. anyone caught using this outside
23 * of apps/gui/wps_engine will be shot on site! */
25 #ifndef _WPS_ENGINE_INTERNALS_
26 #define _WPS_ENGINE_INTERNALS_
27 /* Timeout unit expressed in HZ. In WPS, all timeouts are given in seconds
28 (possibly with a decimal fraction) but stored as integer values.
29 E.g. 2.5 is stored as 25. This means 25 tenth of a second, i.e. 25 units.
31 #define TIMEOUT_UNIT (HZ/10) /* I.e. 0.1 sec */
32 #define DEFAULT_SUBLINE_TIME_MULTIPLIER 20 /* In TIMEOUT_UNIT's */
37 /* TODO: sort this mess out */
39 #include "screen_access.h"
40 #include "statusbar.h"
43 /* constants used in line_type and as refresh_mode for wps_refresh */
44 #define WPS_REFRESH_STATIC (1u<<0) /* line doesn't change over time */
45 #define WPS_REFRESH_DYNAMIC (1u<<1) /* line may change (e.g. time flag) */
46 #define WPS_REFRESH_SCROLL (1u<<2) /* line scrolls */
47 #define WPS_REFRESH_PLAYER_PROGRESS (1u<<3) /* line contains a progress bar */
48 #define WPS_REFRESH_PEAK_METER (1u<<4) /* line contains a peak meter */
49 #define WPS_REFRESH_STATUSBAR (1u<<5) /* refresh statusbar */
50 #define WPS_REFRESH_ALL (0xffffffffu) /* to refresh all line types */
52 /* to refresh only those lines that change over time */
53 #define WPS_REFRESH_NON_STATIC (WPS_REFRESH_DYNAMIC| \
54 WPS_REFRESH_PLAYER_PROGRESS| \
55 WPS_REFRESH_PEAK_METER)
57 #define WPS_ALIGN_RIGHT 32
58 #define WPS_ALIGN_CENTER 64
59 #define WPS_ALIGN_LEFT 128
63 /* albumart definitions */
64 #define WPS_ALBUMART_NONE 0 /* WPS does not contain AA tag */
65 #define WPS_ALBUMART_CHECK 1 /* WPS contains AA conditional tag */
66 #define WPS_ALBUMART_LOAD 2 /* WPS contains AA tag */
68 #define WPS_ALBUMART_ALIGN_RIGHT 1 /* x align: right */
69 #define WPS_ALBUMART_ALIGN_CENTER 2 /* x/y align: center */
70 #define WPS_ALBUMART_ALIGN_LEFT 4 /* x align: left */
71 #define WPS_ALBUMART_ALIGN_TOP 1 /* y align: top */
72 #define WPS_ALBUMART_ALIGN_BOTTOM 4 /* y align: bottom */
74 #endif /* HAVE_ALBUMART */
78 #ifdef HAVE_LCD_BITMAP
81 struct viewport
* vp
; /* The viewport to display this image in */
82 short int x
; /* x-pos */
83 short int y
; /* y-pos */
84 short int num_subimages
; /* number of sub-images */
85 short int subimage_height
; /* height of each sub-image */
86 short int display
; /* -1 for no display, 0..n to display a subimage */
87 bool loaded
; /* load state */
88 bool always_display
; /* not using the preload/display mechanism */
94 /* >=0: explicitly set in the tag -> y-coord within the viewport
95 <0 : not set in the tag -> negated 1-based line number within
96 the viewport. y-coord will be computed based on the font height */
100 /*progressbar image*/
114 #ifdef HAVE_LCD_BITMAP
116 #define MAX_IMAGES (26*2) /* a-z and A-Z */
117 #define MAX_PROGRESSBARS 3
119 /* The image buffer is big enough to store one full-screen native bitmap,
120 plus two full-screen mono bitmaps. */
122 #define IMG_BUFSIZE ((LCD_HEIGHT*LCD_WIDTH*LCD_DEPTH/8) \
123 + (2*LCD_HEIGHT*LCD_WIDTH/8))
125 #define WPS_MAX_VIEWPORTS 24
126 #define WPS_MAX_LINES ((LCD_HEIGHT/5+1) * 2)
127 #define WPS_MAX_SUBLINES (WPS_MAX_LINES*3)
128 #define WPS_MAX_TOKENS 1024
129 #define WPS_MAX_STRINGS 128
130 #define STRING_BUFFER_SIZE 1024
131 #define WPS_MAX_COND_LEVEL 10
135 #define WPS_MAX_VIEWPORTS 2
136 #define WPS_MAX_LINES 2
137 #define WPS_MAX_SUBLINES 12
138 #define WPS_MAX_TOKENS 64
139 #define WPS_MAX_STRINGS 32
140 #define STRING_BUFFER_SIZE 64
141 #define WPS_MAX_COND_LEVEL 5
145 #define SUBLINE_RESET -1
147 enum wps_parse_error
{
149 PARSE_FAIL_UNCLOSED_COND
,
150 PARSE_FAIL_INVALID_CHAR
,
151 PARSE_FAIL_COND_SYNTAX_ERROR
,
152 PARSE_FAIL_COND_INVALID_PARAM
,
153 PARSE_FAIL_LIMITS_EXCEEDED
,
156 enum wps_token_type
{
157 WPS_NO_TOKEN
, /* for WPS tags we don't want to save as tokens */
165 WPS_TOKEN_ALIGN_LEFT
,
166 WPS_TOKEN_ALIGN_CENTER
,
167 WPS_TOKEN_ALIGN_RIGHT
,
170 WPS_TOKEN_SUBLINE_TIMEOUT
,
173 WPS_TOKEN_BATTERY_PERCENT
,
174 WPS_TOKEN_BATTERY_VOLTS
,
175 WPS_TOKEN_BATTERY_TIME
,
176 WPS_TOKEN_BATTERY_CHARGER_CONNECTED
,
177 WPS_TOKEN_BATTERY_CHARGING
,
178 WPS_TOKEN_BATTERY_SLEEPTIME
,
181 #if (CONFIG_CODEC != MAS3507D)
182 WPS_TOKEN_SOUND_PITCH
,
184 #if (CONFIG_CODEC == SWCODEC)
185 WPS_TOKEN_REPLAYGAIN
,
191 WPS_TOKEN_RTC_PRESENT
,
193 /* The begin/end values allow us to know if a token is an RTC one.
194 New RTC tokens should be added between the markers. */
196 WPS_TOKENS_RTC_BEGIN
, /* just the start marker, not an actual token */
198 WPS_TOKEN_RTC_DAY_OF_MONTH
,
199 WPS_TOKEN_RTC_DAY_OF_MONTH_BLANK_PADDED
,
200 WPS_TOKEN_RTC_12HOUR_CFG
,
201 WPS_TOKEN_RTC_HOUR_24_ZERO_PADDED
,
202 WPS_TOKEN_RTC_HOUR_24
,
203 WPS_TOKEN_RTC_HOUR_12_ZERO_PADDED
,
204 WPS_TOKEN_RTC_HOUR_12
,
206 WPS_TOKEN_RTC_MINUTE
,
207 WPS_TOKEN_RTC_SECOND
,
208 WPS_TOKEN_RTC_YEAR_2_DIGITS
,
209 WPS_TOKEN_RTC_YEAR_4_DIGITS
,
210 WPS_TOKEN_RTC_AM_PM_UPPER
,
211 WPS_TOKEN_RTC_AM_PM_LOWER
,
212 WPS_TOKEN_RTC_WEEKDAY_NAME
,
213 WPS_TOKEN_RTC_MONTH_NAME
,
214 WPS_TOKEN_RTC_DAY_OF_WEEK_START_MON
,
215 WPS_TOKEN_RTC_DAY_OF_WEEK_START_SUN
,
217 WPS_TOKENS_RTC_END
, /* just the end marker, not an actual token */
220 WPS_TOKEN_CONDITIONAL
,
221 WPS_TOKEN_CONDITIONAL_START
,
222 WPS_TOKEN_CONDITIONAL_OPTION
,
223 WPS_TOKEN_CONDITIONAL_END
,
227 WPS_TOKEN_DATABASE_PLAYCOUNT
,
228 WPS_TOKEN_DATABASE_RATING
,
229 WPS_TOKEN_DATABASE_AUTOSCORE
,
233 WPS_TOKEN_FILE_BITRATE
,
234 WPS_TOKEN_FILE_CODEC
,
235 WPS_TOKEN_FILE_FREQUENCY
,
236 WPS_TOKEN_FILE_FREQUENCY_KHZ
,
238 WPS_TOKEN_FILE_NAME_WITH_EXTENSION
,
242 WPS_TOKEN_FILE_DIRECTORY
,
244 #ifdef HAVE_LCD_BITMAP
246 WPS_TOKEN_IMAGE_BACKDROP
,
247 WPS_TOKEN_IMAGE_PROGRESS_BAR
,
248 WPS_TOKEN_IMAGE_PRELOAD
,
249 WPS_TOKEN_IMAGE_PRELOAD_DISPLAY
,
250 WPS_TOKEN_IMAGE_DISPLAY
,
255 WPS_TOKEN_ALBUMART_DISPLAY
,
256 WPS_TOKEN_ALBUMART_FOUND
,
260 WPS_TOKEN_METADATA_ARTIST
,
261 WPS_TOKEN_METADATA_COMPOSER
,
262 WPS_TOKEN_METADATA_ALBUM_ARTIST
,
263 WPS_TOKEN_METADATA_GROUPING
,
264 WPS_TOKEN_METADATA_ALBUM
,
265 WPS_TOKEN_METADATA_GENRE
,
266 WPS_TOKEN_METADATA_DISC_NUMBER
,
267 WPS_TOKEN_METADATA_TRACK_NUMBER
,
268 WPS_TOKEN_METADATA_TRACK_TITLE
,
269 WPS_TOKEN_METADATA_VERSION
,
270 WPS_TOKEN_METADATA_YEAR
,
271 WPS_TOKEN_METADATA_COMMENT
,
274 WPS_TOKEN_REPEAT_MODE
,
275 WPS_TOKEN_PLAYBACK_STATUS
,
279 #ifdef HAS_REMOTE_BUTTON_HOLD
280 WPS_TOKEN_REMOTE_HOLD
,
284 WPS_TOKEN_PROGRESSBAR
,
285 #ifdef HAVE_LCD_CHARCELLS
286 WPS_TOKEN_PLAYER_PROGRESSBAR
,
289 #ifdef HAVE_LCD_BITMAP
298 WPS_TOKEN_TRACK_ELAPSED_PERCENT
,
299 WPS_TOKEN_TRACK_TIME_ELAPSED
,
300 WPS_TOKEN_TRACK_TIME_REMAINING
,
301 WPS_TOKEN_TRACK_LENGTH
,
304 WPS_TOKEN_PLAYLIST_ENTRIES
,
305 WPS_TOKEN_PLAYLIST_NAME
,
306 WPS_TOKEN_PLAYLIST_POSITION
,
307 WPS_TOKEN_PLAYLIST_SHUFFLE
,
309 #if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
314 /* Viewport display */
318 WPS_TOKEN_BUTTON_VOLUME
,
326 unsigned char type
; /* enough to store the token type */
328 /* Whether the tag (e.g. track name or the album) refers the
329 current or the next song (false=current, true=next) */
338 /* Description of a subline on the WPS */
341 /* Index of the first token for this subline in the token array.
342 Tokens of this subline end where tokens for the next subline
344 unsigned short first_token_idx
;
346 /* Bit or'ed WPS_REFRESH_xxx */
347 unsigned char line_type
;
349 /* How long the subline should be displayed, in 10ths of sec */
350 unsigned char time_mult
;
353 /* Description of a line on the WPS. A line is a set of sublines.
354 A subline is displayed for a certain amount of time. After that,
355 the next subline of the line is displayed. And so on. */
358 /* Number of sublines in this line */
359 signed char num_sublines
;
361 /* Number (0-based) of the subline within this line currently being displayed */
362 signed char curr_subline
;
364 /* Index of the first subline of this line in the subline array.
365 Sublines for this line end where sublines for the next line begin. */
366 unsigned short first_subline_idx
;
368 /* When the next subline of this line should be displayed
369 (absolute time value in ticks) */
370 long subline_expire_time
;
373 #define VP_DRAW_HIDEABLE 0x1
374 #define VP_DRAW_HIDDEN 0x2
375 #define VP_DRAW_WASHIDDEN 0x4
376 struct wps_viewport
{
377 struct viewport vp
; /* The LCD viewport struct */
378 struct progressbar
*pb
;
379 /* Indexes of the first and last lines belonging to this viewport in the
381 int first_line
, last_line
;
386 #ifdef HAVE_TOUCHSCREEN
388 struct wps_viewport
* wvp
;/* The viewport this region is in */
389 short int x
; /* x-pos */
390 short int y
; /* y-pos */
391 short int width
; /* width */
392 short int height
; /* height */
393 bool repeat
; /* requires the area be held for the action */
394 int action
; /* action this button will return */
396 #define MAX_TOUCHREGIONS 15
399 this struct holds all necessary data which describes the
400 viewable content of a wps */
403 #ifdef HAVE_LCD_BITMAP
404 struct gui_img img
[MAX_IMAGES
];
405 unsigned char img_buf
[IMG_BUFSIZE
];
406 unsigned char* img_buf_ptr
;
411 struct progressbar progressbar
[MAX_PROGRESSBARS
];
412 short progressbar_count
;
414 bool peak_meter_enabled
;
417 /* Album art support */
418 unsigned char wps_uses_albumart
; /* WPS_ALBUMART_NONE, _CHECK, _LOAD */
421 unsigned char albumart_xalign
; /* WPS_ALBUMART_ALIGN_LEFT, _CENTER, _RIGHT */
422 unsigned char albumart_yalign
; /* WPS_ALBUMART_ALIGN_TOP, _CENTER, _BOTTOM */
423 short albumart_max_width
;
424 short albumart_max_height
;
426 int albumart_cond_index
;
429 #else /*HAVE_LCD_CHARCELLS */
430 unsigned short wps_progress_pat
[8];
431 bool full_line_progressbar
;
434 #ifdef HAVE_TOUCHSCREEN
435 struct touchregion touchregion
[MAX_TOUCHREGIONS
];
436 short touchregion_count
;
439 #ifdef HAVE_REMOTE_LCD
443 /* Number of lines in the WPS. During WPS parsing, this is
444 the index of the line being parsed. */
447 /* Number of viewports in the WPS */
449 struct wps_viewport viewports
[WPS_MAX_VIEWPORTS
];
451 struct wps_line lines
[WPS_MAX_LINES
];
453 /* Total number of sublines in the WPS. During WPS parsing, this is
454 the index of the subline where the parsed tokens are added to. */
456 struct wps_subline sublines
[WPS_MAX_SUBLINES
];
458 /* Total number of tokens in the WPS. During WPS parsing, this is
459 the index of the token being parsed. */
461 struct wps_token tokens
[WPS_MAX_TOKENS
];
463 char string_buffer
[STRING_BUFFER_SIZE
];
464 char *strings
[WPS_MAX_STRINGS
];
469 /* tick the volume button was last pressed */
470 unsigned int button_time_volume
;
474 /* Redraw statusbars if necessary */
475 void gwps_draw_statusbars(void);
477 /* Returns the index of the subline in the subline array
478 line - 0-based line number
479 subline - 0-based subline number within the line
481 int wps_subline_index(struct wps_data
*wps_data
, int line
, int subline
);
483 /* Returns the index of the first subline's token in the token array
484 line - 0-based line number
485 subline - 0-based subline number within the line
487 int wps_first_token_index(struct wps_data
*data
, int line
, int subline
);
489 /* Returns the index of the last subline's token in the token array.
490 line - 0-based line number
491 subline - 0-based subline number within the line
493 int wps_last_token_index(struct wps_data
*data
, int line
, int subline
);
498 holds the data which belongs to the current played track,
499 the track which will be played afterwards, current path to the track
500 and some status infos */
506 bool wps_time_countup
;
507 struct mp3entry
* id3
;
508 struct mp3entry
* nid3
;
513 /* change the ff/rew-status
514 if ff_rew = true then we are in skipping mode
515 else we are in normal mode */
516 /* void wps_state_update_ff_rew(bool ff_rew); Currently unused */
518 /* change the tag-information of the current played track
519 and the following track */
520 /* void wps_state_update_id3_nid3(struct mp3entry *id3, struct mp3entry *nid3); Currently unused */
524 defines a wps with its data, state,
525 and the screen on which the wps-content should be drawn */
528 struct screen
*display
;
529 struct wps_data
*data
;
530 struct wps_state
*state
;
536 /***** wps_tokens.c ******/
538 const char *get_token_value(struct gui_wps
*gwps
,
539 struct wps_token
*token
,
540 char *buf
, int buf_size
,