only send a Charging Only interface if nothing else is sent
[kugel-rb.git] / apps / gui / gwps.h
blob70f4c560c61ce1cebcabd73d976fbfed9238c572
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
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 ****************************************************************************/
19 #ifndef _WPS_H
20 #define _WPS_H
22 #include "screen_access.h"
23 #include "statusbar.h"
24 #include "id3.h"
25 #include "playlist.h"
27 /* constants used in line_type and as refresh_mode for wps_refresh */
28 #define WPS_REFRESH_STATIC 1 /* line doesn't change over time */
29 #define WPS_REFRESH_DYNAMIC 2 /* line may change (e.g. time flag) */
30 #define WPS_REFRESH_SCROLL 4 /* line scrolls */
31 #define WPS_REFRESH_PLAYER_PROGRESS 8 /* line contains a progress bar */
32 #define WPS_REFRESH_PEAK_METER 16 /* line contains a peak meter */
33 #define WPS_REFRESH_ALL 0xff /* to refresh all line types */
34 /* to refresh only those lines that change over time */
35 #define WPS_REFRESH_NON_STATIC (WPS_REFRESH_ALL & ~WPS_REFRESH_STATIC & ~WPS_REFRESH_SCROLL)
37 /* alignments */
38 #define WPS_ALIGN_RIGHT 32
39 #define WPS_ALIGN_CENTER 64
40 #define WPS_ALIGN_LEFT 128
42 #ifdef HAVE_ALBUMART
44 /* albumart definitions */
45 #define WPS_ALBUMART_NONE 0 /* WPS does not contain AA tag */
46 #define WPS_ALBUMART_CHECK 1 /* WPS contains AA conditional tag */
47 #define WPS_ALBUMART_LOAD 2 /* WPS contains AA tag */
49 #define WPS_ALBUMART_ALIGN_RIGHT WPS_ALIGN_RIGHT /* x align: right */
50 #define WPS_ALBUMART_ALIGN_CENTER WPS_ALIGN_CENTER /* x/y align: center */
51 #define WPS_ALBUMART_ALIGN_LEFT WPS_ALIGN_LEFT /* x align: left */
52 #define WPS_ALBUMART_ALIGN_TOP WPS_ALIGN_RIGHT /* y align: top */
53 #define WPS_ALBUMART_ALIGN_BOTTOM WPS_ALIGN_LEFT /* y align: bottom */
54 #define WPS_ALBUMART_INCREASE 8 /* increase if smaller */
55 #define WPS_ALBUMART_DECREASE 16 /* decrease if larger */
57 #endif /* HAVE_ALBUMART */
59 /* wps_data*/
61 #ifdef HAVE_LCD_BITMAP
62 struct gui_img{
63 struct bitmap bm;
64 int x; /* x-pos */
65 int y; /* y-pos */
66 bool loaded; /* load state */
67 bool display; /* is to be displayed */
68 bool always_display; /* not using the preload/display mechanism */
71 struct prog_img{ /*progressbar image*/
72 struct bitmap bm;
73 bool have_bitmap_pb;
75 #endif
77 struct align_pos {
78 char* left;
79 char* center;
80 char* right;
83 #ifdef HAVE_LCD_BITMAP
85 #define MAX_IMAGES (26*2) /* a-z and A-Z */
86 #define IMG_BUFSIZE ((LCD_HEIGHT*LCD_WIDTH*LCD_DEPTH/8) \
87 + (2*LCD_HEIGHT*LCD_WIDTH/8))
89 #define WPS_MAX_LINES (LCD_HEIGHT/5+1)
90 #define WPS_MAX_SUBLINES (WPS_MAX_LINES*3)
91 #define WPS_MAX_TOKENS 1024
92 #define WPS_MAX_STRINGS 128
93 #define STRING_BUFFER_SIZE 1024
94 #define WPS_MAX_COND_LEVEL 10
96 #else
98 #define WPS_MAX_LINES 2
99 #define WPS_MAX_SUBLINES 12
100 #define WPS_MAX_TOKENS 64
101 #define WPS_MAX_STRINGS 32
102 #define STRING_BUFFER_SIZE 64
103 #define WPS_MAX_COND_LEVEL 5
105 #endif
107 #define DEFAULT_SUBLINE_TIME_MULTIPLIER 20 /* (10ths of sec) */
108 #define BASE_SUBLINE_TIME 10 /* base time that multiplier is applied to
109 (1/HZ sec, or 100ths of sec) */
110 #define SUBLINE_RESET -1
112 enum wps_token_type {
113 WPS_NO_TOKEN, /* for WPS tags we don't want to save as tokens */
114 WPS_TOKEN_UNKNOWN,
116 /* Markers */
117 WPS_TOKEN_CHARACTER,
118 WPS_TOKEN_STRING,
120 /* Alignment */
121 WPS_TOKEN_ALIGN_LEFT,
122 WPS_TOKEN_ALIGN_CENTER,
123 WPS_TOKEN_ALIGN_RIGHT,
124 WPS_TOKEN_LEFTMARGIN,
126 /* Sublines */
127 WPS_TOKEN_SUBLINE_TIMEOUT,
129 /* Battery */
130 WPS_TOKEN_BATTERY_PERCENT,
131 WPS_TOKEN_BATTERY_VOLTS,
132 WPS_TOKEN_BATTERY_TIME,
133 WPS_TOKEN_BATTERY_CHARGER_CONNECTED,
134 WPS_TOKEN_BATTERY_CHARGING,
135 WPS_TOKEN_BATTERY_SLEEPTIME,
137 /* Sound */
138 #if (CONFIG_CODEC != MAS3507D)
139 WPS_TOKEN_SOUND_PITCH,
140 #endif
141 #if (CONFIG_CODEC == SWCODEC)
142 WPS_TOKEN_REPLAYGAIN,
143 WPS_TOKEN_CROSSFADE,
144 #endif
146 /* Time */
148 /* The begin/end values allow us to know if a token is an RTC one.
149 New RTC tokens should be added between the markers. */
151 WPS_TOKENS_RTC_BEGIN, /* just the start marker, not an actual token */
153 WPS_TOKEN_RTC_DAY_OF_MONTH,
154 WPS_TOKEN_RTC_DAY_OF_MONTH_BLANK_PADDED,
155 WPS_TOKEN_RTC_12HOUR_CFG,
156 WPS_TOKEN_RTC_HOUR_24_ZERO_PADDED,
157 WPS_TOKEN_RTC_HOUR_24,
158 WPS_TOKEN_RTC_HOUR_12_ZERO_PADDED,
159 WPS_TOKEN_RTC_HOUR_12,
160 WPS_TOKEN_RTC_MONTH,
161 WPS_TOKEN_RTC_MINUTE,
162 WPS_TOKEN_RTC_SECOND,
163 WPS_TOKEN_RTC_YEAR_2_DIGITS,
164 WPS_TOKEN_RTC_YEAR_4_DIGITS,
165 WPS_TOKEN_RTC_AM_PM_UPPER,
166 WPS_TOKEN_RTC_AM_PM_LOWER,
167 WPS_TOKEN_RTC_WEEKDAY_NAME,
168 WPS_TOKEN_RTC_MONTH_NAME,
169 WPS_TOKEN_RTC_DAY_OF_WEEK_START_MON,
170 WPS_TOKEN_RTC_DAY_OF_WEEK_START_SUN,
172 WPS_TOKENS_RTC_END, /* just the end marker, not an actual token */
174 /* Conditional */
175 WPS_TOKEN_CONDITIONAL,
176 WPS_TOKEN_CONDITIONAL_START,
177 WPS_TOKEN_CONDITIONAL_OPTION,
178 WPS_TOKEN_CONDITIONAL_END,
180 /* Database */
181 #ifdef HAVE_TAGCACHE
182 WPS_TOKEN_DATABASE_PLAYCOUNT,
183 WPS_TOKEN_DATABASE_RATING,
184 WPS_TOKEN_DATABASE_AUTOSCORE,
185 #endif
187 /* File */
188 WPS_TOKEN_FILE_BITRATE,
189 WPS_TOKEN_FILE_CODEC,
190 WPS_TOKEN_FILE_FREQUENCY,
191 WPS_TOKEN_FILE_FREQUENCY_KHZ,
192 WPS_TOKEN_FILE_NAME,
193 WPS_TOKEN_FILE_NAME_WITH_EXTENSION,
194 WPS_TOKEN_FILE_PATH,
195 WPS_TOKEN_FILE_SIZE,
196 WPS_TOKEN_FILE_VBR,
197 WPS_TOKEN_FILE_DIRECTORY,
199 #ifdef HAVE_LCD_BITMAP
200 /* Image */
201 WPS_TOKEN_IMAGE_BACKDROP,
202 WPS_TOKEN_IMAGE_PROGRESS_BAR,
203 WPS_TOKEN_IMAGE_PRELOAD,
204 WPS_TOKEN_IMAGE_PRELOAD_DISPLAY,
205 WPS_TOKEN_IMAGE_DISPLAY,
206 #endif
208 #ifdef HAVE_ALBUMART
209 /* Albumart */
210 WPS_TOKEN_ALBUMART_DISPLAY,
211 WPS_TOKEN_ALBUMART_FOUND,
212 #endif
214 /* Metadata */
215 WPS_TOKEN_METADATA_ARTIST,
216 WPS_TOKEN_METADATA_COMPOSER,
217 WPS_TOKEN_METADATA_ALBUM_ARTIST,
218 WPS_TOKEN_METADATA_GROUPING,
219 WPS_TOKEN_METADATA_ALBUM,
220 WPS_TOKEN_METADATA_GENRE,
221 WPS_TOKEN_METADATA_DISC_NUMBER,
222 WPS_TOKEN_METADATA_TRACK_NUMBER,
223 WPS_TOKEN_METADATA_TRACK_TITLE,
224 WPS_TOKEN_METADATA_VERSION,
225 WPS_TOKEN_METADATA_YEAR,
226 WPS_TOKEN_METADATA_COMMENT,
228 /* Mode */
229 WPS_TOKEN_REPEAT_MODE,
230 WPS_TOKEN_PLAYBACK_STATUS,
232 WPS_TOKEN_MAIN_HOLD,
234 #ifdef HAS_REMOTE_BUTTON_HOLD
235 WPS_TOKEN_REMOTE_HOLD,
236 #endif
238 /* Progressbar */
239 WPS_TOKEN_PROGRESSBAR,
240 #ifdef HAVE_LCD_CHARCELLS
241 WPS_TOKEN_PLAYER_PROGRESSBAR,
242 #endif
244 #ifdef HAVE_LCD_BITMAP
245 /* Peakmeter */
246 WPS_TOKEN_PEAKMETER,
247 #endif
249 /* Volume level */
250 WPS_TOKEN_VOLUME,
252 /* Current track */
253 WPS_TOKEN_TRACK_ELAPSED_PERCENT,
254 WPS_TOKEN_TRACK_TIME_ELAPSED,
255 WPS_TOKEN_TRACK_TIME_REMAINING,
256 WPS_TOKEN_TRACK_LENGTH,
258 /* Playlist */
259 WPS_TOKEN_PLAYLIST_ENTRIES,
260 WPS_TOKEN_PLAYLIST_NAME,
261 WPS_TOKEN_PLAYLIST_POSITION,
262 WPS_TOKEN_PLAYLIST_SHUFFLE,
264 #if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
265 /* Virtual LED */
266 WPS_TOKEN_VLED_HDD
267 #endif
270 struct wps_token {
271 enum wps_token_type type;
273 /* Whether the tag (e.g. track name or the album) refers the
274 current or the next song (false=current, true=next) */
275 bool next;
277 union {
278 char c;
279 unsigned short i;
280 } value;
283 /* Description of a subline on the WPS */
284 struct wps_subline {
286 /* Index of the first token for this subline in the token array.
287 Tokens of this subline end where tokens for the next subline
288 begin. */
289 unsigned short first_token_idx;
291 /* Bit or'ed WPS_REFRESH_xxx */
292 unsigned char line_type;
294 /* How long the subline should be displayed, in 10ths of sec */
295 unsigned char time_mult;
298 /* Description of a line on the WPS. A line is a set of sublines.
299 A subline is displayed for a certain amount of time. After that,
300 the next subline of the line is displayed. And so on. */
301 struct wps_line {
303 /* Number of sublines in this line */
304 signed char num_sublines;
306 /* Number (0-based) of the subline within this line currently being displayed */
307 signed char curr_subline;
309 /* Index of the first subline of this line in the subline array.
310 Sublines for this line end where sublines for the next line begin. */
311 unsigned short first_subline_idx;
313 /* When the next subline of this line should be displayed
314 (absolute time value in ticks) */
315 long subline_expire_time;
319 /* wps_data
320 this struct holds all necessary data which describes the
321 viewable content of a wps */
322 struct wps_data
324 #ifdef HAVE_LCD_BITMAP
325 struct gui_img img[MAX_IMAGES];
326 struct prog_img progressbar;
327 unsigned char img_buf[IMG_BUFSIZE];
328 unsigned char* img_buf_ptr;
329 int img_buf_free;
330 bool wps_sb_tag;
331 bool show_sb_on_wps;
333 short progress_top;
334 short progress_height;
335 short progress_start;
336 short progress_end;
337 bool peak_meter_enabled;
339 #ifdef HAVE_ALBUMART
340 /* Album art support */
341 unsigned char wps_uses_albumart; /* WPS_ALBUMART_NONE, _CHECK, _LOAD */
342 short albumart_x;
343 short albumart_y;
344 unsigned short albumart_xalign; /* WPS_ALBUMART_ALIGN_LEFT, _CENTER, _RIGHT,
345 + .._INCREASE, + .._DECREASE */
346 unsigned short albumart_yalign; /* WPS_ALBUMART_ALIGN_TOP, _CENTER, _BOTTOM,
347 + .._INCREASE, + .._DECREASE */
348 short albumart_max_width;
349 short albumart_max_height;
351 int albumart_cond_index;
352 #endif
354 #else /*HAVE_LCD_CHARCELLS */
355 unsigned short wps_progress_pat[8];
356 bool full_line_progressbar;
357 #endif
359 #ifdef HAVE_REMOTE_LCD
360 bool remote_wps;
361 #endif
363 /* Number of lines in the WPS. During WPS parsing, this is
364 the index of the line being parsed. */
365 int num_lines;
366 struct wps_line lines[WPS_MAX_LINES];
368 /* Total number of sublines in the WPS. During WPS parsing, this is
369 the index of the subline where the parsed tokens are added to. */
370 int num_sublines;
371 struct wps_subline sublines[WPS_MAX_SUBLINES];
373 /* Total number of tokens in the WPS. During WPS parsing, this is
374 the index of the token being parsed. */
375 int num_tokens;
376 struct wps_token tokens[WPS_MAX_TOKENS];
378 char string_buffer[STRING_BUFFER_SIZE];
379 char *strings[WPS_MAX_STRINGS];
380 int num_strings;
382 bool wps_loaded;
385 /* initial setup of wps_data */
386 void wps_data_init(struct wps_data *wps_data);
388 /* to setup up the wps-data from a format-buffer (isfile = false)
389 from a (wps-)file (isfile = true)*/
390 bool wps_data_load(struct wps_data *wps_data,
391 const char *buf,
392 bool isfile);
394 /* Returns the index of the subline in the subline array
395 line - 0-based line number
396 subline - 0-based subline number within the line
398 int wps_subline_index(struct wps_data *wps_data, int line, int subline);
400 /* Returns the index of the first subline's token in the token array
401 line - 0-based line number
402 subline - 0-based subline number within the line
404 int wps_first_token_index(struct wps_data *data, int line, int subline);
406 /* Returns the index of the last subline's token in the token array.
407 line - 0-based line number
408 subline - 0-based subline number within the line
410 int wps_last_token_index(struct wps_data *data, int line, int subline);
412 /* wps_data end */
414 /* wps_state
415 holds the data which belongs to the current played track,
416 the track which will be played afterwards, current path to the track
417 and some status infos */
418 struct wps_state
420 bool ff_rewind;
421 bool paused;
422 int ff_rewind_count;
423 bool wps_time_countup;
424 struct mp3entry* id3;
425 struct mp3entry* nid3;
426 char current_track_path[MAX_PATH];
430 /* change the ff/rew-status
431 if ff_rew = true then we are in skipping mode
432 else we are in normal mode */
433 /* void wps_state_update_ff_rew(bool ff_rew); Currently unused */
435 /* change the tag-information of the current played track
436 and the following track */
437 /* void wps_state_update_id3_nid3(struct mp3entry *id3, struct mp3entry *nid3); Currently unused */
438 /* wps_state end*/
440 /* gui_wps
441 defines a wps with its data, state,
442 and the screen on which the wps-content should be drawn */
443 struct gui_wps
445 struct screen *display;
446 struct wps_data *data;
447 struct wps_state *state;
448 struct gui_statusbar *statusbar;
451 /* gui_wps end */
453 long gui_wps_show(void);
455 /* currently only on wps_state is needed */
456 extern struct wps_state wps_state;
457 extern struct gui_wps gui_wps[NB_SCREENS];
459 void gui_sync_wps_init(void);
460 void gui_sync_wps_screen_init(void);
462 #ifdef HAVE_ALBUMART
463 /* gives back if WPS contains an albumart tag */
464 bool gui_sync_wps_uses_albumart(void);
465 #endif
467 #endif