1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2005 by Kevin Ferrare
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 ****************************************************************************/
25 #ifdef HAVE_REMOTE_LCD
26 #include <lcd-remote.h>
28 #include <scroll_engine.h>
35 #include "backlight.h"
36 #include "screen_access.h"
39 /* some helper functions to calculate metrics on the fly */
40 static int screen_helper_getcharwidth(void)
42 #ifdef HAVE_LCD_BITMAP
43 return font_get(lcd_getfont())->maxwidth
;
49 static int screen_helper_getcharheight(void)
51 #ifdef HAVE_LCD_BITMAP
52 return font_get(lcd_getfont())->height
;
58 static int screen_helper_getnblines(void)
60 int height
=screens
[0].lcdheight
;
61 #ifdef HAVE_LCD_BITMAP
62 if(global_settings
.statusbar
!= STATUSBAR_OFF
)
63 height
-= STATUSBAR_HEIGHT
;
65 if(global_settings
.buttonbar
&& screens
[0].has_buttonbar
)
66 height
-= BUTTONBAR_HEIGHT
;
69 return height
/ screens
[0].getcharheight();
72 void screen_helper_setfont(int font
)
75 #ifdef HAVE_LCD_BITMAP
77 font
= global_status
.font_id
[SCREEN_MAIN
];
82 #ifdef HAVE_LCD_BITMAP
83 static int screen_helper_getuifont(void)
85 return global_status
.font_id
[SCREEN_MAIN
];
88 static void screen_helper_setuifont(int font
)
90 global_status
.font_id
[SCREEN_MAIN
] = font
;
95 static int screen_helper_remote_getcharwidth(void)
97 #ifdef HAVE_LCD_BITMAP
98 return font_get(lcd_remote_getfont())->maxwidth
;
104 static int screen_helper_remote_getcharheight(void)
106 #ifdef HAVE_LCD_BITMAP
107 return font_get(lcd_remote_getfont())->height
;
113 static int screen_helper_remote_getnblines(void)
115 int height
=screens
[1].lcdheight
;
116 #ifdef HAVE_LCD_BITMAP
117 if(global_settings
.statusbar
!= STATUSBAR_OFF
)
118 height
-= STATUSBAR_HEIGHT
;
119 #ifdef HAVE_BUTTONBAR
120 if(global_settings
.buttonbar
&& screens
[1].has_buttonbar
)
121 height
-= BUTTONBAR_HEIGHT
;
124 return height
/ screens
[1].getcharheight();
127 void screen_helper_remote_setfont(int font
)
130 font
= global_status
.font_id
[SCREEN_REMOTE
];
131 lcd_remote_setfont(font
);
134 static int screen_helper_remote_getuifont(void)
136 #ifdef HAVE_LCD_BITMAP
137 return global_status
.font_id
[SCREEN_REMOTE
];
139 return FONT_SYSFIXED
;
143 static void screen_helper_remote_setuifont(int font
)
145 #ifdef HAVE_LCD_BITMAP
146 global_status
.font_id
[SCREEN_REMOTE
] = font
;
152 struct screen screens
[NB_SCREENS
] =
155 .screen_type
=SCREEN_MAIN
,
157 .lcdheight
=LCD_HEIGHT
,
159 .getnblines
=&screen_helper_getnblines
,
160 #if defined(HAVE_LCD_COLOR)
165 #ifdef HAVE_LCD_BITMAP
166 .pixel_format
=LCD_PIXELFORMAT
,
168 .getcharwidth
=screen_helper_getcharwidth
,
169 .getcharheight
=screen_helper_getcharheight
,
170 #if (CONFIG_LED == LED_VIRTUAL)
172 #elif defined(HAVE_REMOTE_LCD)
175 .set_viewport
=&lcd_set_viewport
,
176 .getwidth
=&lcd_getwidth
,
177 .getheight
=&lcd_getheight
,
178 .getstringsize
=&lcd_getstringsize
,
179 #ifdef HAVE_LCD_BITMAP
180 .setfont
=screen_helper_setfont
,
181 .getuifont
=screen_helper_getuifont
,
182 .setuifont
=screen_helper_setuifont
,
183 .mono_bitmap
=&lcd_mono_bitmap
,
184 .mono_bitmap_part
=&lcd_mono_bitmap_part
,
185 .set_drawmode
=&lcd_set_drawmode
,
186 .bitmap
=(screen_bitmap_func
*)&lcd_bitmap
,
187 .bitmap_part
=(screen_bitmap_part_func
*)&lcd_bitmap_part
,
189 /* No transparency yet for grayscale and mono lcd */
190 .transparent_bitmap
=(screen_bitmap_func
*)&lcd_bitmap
,
191 .transparent_bitmap_part
=(screen_bitmap_part_func
*)&lcd_bitmap_part
,
193 .transparent_bitmap
=(screen_bitmap_func
*)&lcd_bitmap_transparent
,
194 .transparent_bitmap_part
=(screen_bitmap_part_func
*)&lcd_bitmap_transparent_part
,
197 .bmp_part
= &lcd_bmp_part
,
199 #if defined(HAVE_LCD_COLOR) && defined(LCD_REMOTE_DEPTH) && LCD_REMOTE_DEPTH > 1
200 .color_to_native
=&lcd_color_to_native
,
202 .get_background
=&lcd_get_background
,
203 .get_foreground
=&lcd_get_foreground
,
204 .set_background
=&lcd_set_background
,
205 .set_foreground
=&lcd_set_foreground
,
206 #ifdef HAVE_LCD_COLOR
207 .set_selector_start
=&lcd_set_selector_start
,
208 .set_selector_end
=&lcd_set_selector_end
,
209 .set_selector_text
=&lcd_set_selector_text
,
211 #endif /* LCD_DEPTH > 1 */
212 .update_rect
=&lcd_update_rect
,
213 .update_viewport_rect
=&lcd_update_viewport_rect
,
214 .fillrect
=&lcd_fillrect
,
215 .drawrect
=&lcd_drawrect
,
216 .draw_border_viewport
=&lcd_draw_border_viewport
,
217 .fill_viewport
=&lcd_fill_viewport
,
218 .drawpixel
=&lcd_drawpixel
,
219 .drawline
=&lcd_drawline
,
222 .scroll_step
=&lcd_scroll_step
,
223 .puts_style_offset
=&lcd_puts_style_offset
,
224 .puts_style_xyoffset
=&lcd_puts_style_xyoffset
,
225 .puts_scroll_style
=&lcd_puts_scroll_style
,
226 .puts_scroll_style_offset
=&lcd_puts_scroll_style_offset
,
227 .puts_scroll_style_xyoffset
=&lcd_puts_scroll_style_xyoffset
,
228 #endif /* HAVE_LCD_BITMAP */
230 #ifdef HAVE_LCD_CHARCELLS
231 .double_height
=&lcd_double_height
,
233 .get_locked_pattern
=&lcd_get_locked_pattern
,
234 .define_pattern
=&lcd_define_pattern
,
235 .unlock_pattern
=&lcd_unlock_pattern
,
237 #endif /* HAVE_LCD_CHARCELLS */
242 .puts_offset
=&lcd_puts_offset
,
243 .puts_scroll
=&lcd_puts_scroll
,
244 .puts_scroll_offset
=&lcd_puts_scroll_offset
,
245 .scroll_speed
=&lcd_scroll_speed
,
246 .scroll_delay
=&lcd_scroll_delay
,
247 .stop_scroll
=&lcd_stop_scroll
,
248 .clear_display
=&lcd_clear_display
,
249 .clear_viewport
=&lcd_clear_viewport
,
250 .scroll_stop
=&lcd_scroll_stop
,
251 .scroll_stop_line
=&lcd_scroll_stop_line
,
253 .update_viewport
=&lcd_update_viewport
,
254 .backlight_on
=&backlight_on
,
255 .backlight_off
=&backlight_off
,
256 .is_backlight_on
=&is_backlight_on
,
257 .backlight_set_timeout
=&backlight_set_timeout
,
259 .backdrop_load
=&backdrop_load
,
260 .backdrop_show
=&backdrop_show
,
262 #ifdef HAVE_BUTTONBAR
263 .has_buttonbar
=false,
265 #if defined(HAVE_LCD_BITMAP)
266 .set_framebuffer
= (void*)lcd_set_framebuffer
,
267 #if defined(HAVE_LCD_COLOR)
268 .gradient_fillrect
= lcd_gradient_fillrect
,
274 .screen_type
=SCREEN_REMOTE
,
275 .lcdwidth
=LCD_REMOTE_WIDTH
,
276 .lcdheight
=LCD_REMOTE_HEIGHT
,
277 .depth
=LCD_REMOTE_DEPTH
,
278 .getnblines
=&screen_helper_remote_getnblines
,
279 .is_color
=false,/* No color remotes yet */
280 .pixel_format
=LCD_REMOTE_PIXELFORMAT
,
281 .getcharwidth
=screen_helper_remote_getcharwidth
,
282 .getcharheight
=screen_helper_remote_getcharheight
,
284 .set_viewport
=&lcd_remote_set_viewport
,
285 .getwidth
=&lcd_remote_getwidth
,
286 .getheight
=&lcd_remote_getheight
,
287 .getstringsize
=&lcd_remote_getstringsize
,
288 #if 1 /* all remote LCDs are bitmapped so far */
289 .setfont
=screen_helper_remote_setfont
,
290 .getuifont
=screen_helper_remote_getuifont
,
291 .setuifont
=screen_helper_remote_setuifont
,
292 .mono_bitmap
=&lcd_remote_mono_bitmap
,
293 .mono_bitmap_part
=&lcd_remote_mono_bitmap_part
,
294 .bitmap
=(screen_bitmap_func
*)&lcd_remote_bitmap
,
295 .bitmap_part
=(screen_bitmap_part_func
*)&lcd_remote_bitmap_part
,
296 .set_drawmode
=&lcd_remote_set_drawmode
,
297 #if LCD_REMOTE_DEPTH <= 2
298 /* No transparency yet for grayscale and mono lcd */
299 .transparent_bitmap
=(screen_bitmap_func
*)&lcd_remote_bitmap
,
300 .transparent_bitmap_part
=(screen_bitmap_part_func
*)&lcd_remote_bitmap_part
,
301 /* No colour remotes yet */
303 .bmp
= &lcd_remote_bmp
,
304 .bmp_part
= &lcd_remote_bmp_part
,
305 #if LCD_REMOTE_DEPTH > 1
306 #if defined(HAVE_LCD_COLOR)
307 .color_to_native
=&lcd_remote_color_to_native
,
309 .get_background
=&lcd_remote_get_background
,
310 .get_foreground
=&lcd_remote_get_foreground
,
311 .set_background
=&lcd_remote_set_background
,
312 .set_foreground
=&lcd_remote_set_foreground
,
313 #endif /* LCD_REMOTE_DEPTH > 1 */
314 .update_rect
=&lcd_remote_update_rect
,
315 .update_viewport_rect
=&lcd_remote_update_viewport_rect
,
316 .fillrect
=&lcd_remote_fillrect
,
317 .drawrect
=&lcd_remote_drawrect
,
318 .draw_border_viewport
=&lcd_remote_draw_border_viewport
,
319 .fill_viewport
=&lcd_remote_fill_viewport
,
320 .drawpixel
=&lcd_remote_drawpixel
,
321 .drawline
=&lcd_remote_drawline
,
322 .vline
=&lcd_remote_vline
,
323 .hline
=&lcd_remote_hline
,
324 .scroll_step
=&lcd_remote_scroll_step
,
325 .puts_style_offset
=&lcd_remote_puts_style_offset
,
326 .puts_style_xyoffset
=&lcd_remote_puts_style_xyoffset
,
327 .puts_scroll_style
=&lcd_remote_puts_scroll_style
,
328 .puts_scroll_style_offset
=&lcd_remote_puts_scroll_style_offset
,
329 .puts_scroll_style_xyoffset
=&lcd_remote_puts_scroll_style_xyoffset
,
332 #if 0 /* no charcell remote LCDs so far */
333 .double_height
=&lcd_remote_double_height
,
334 .putc
=&lcd_remote_putc
,
335 .get_locked_pattern
=&lcd_remote_get_locked_pattern
,
336 .define_pattern
=&lcd_remote_define_pattern
,
337 .icon
=&lcd_remote_icon
,
339 .putsxy
=&lcd_remote_putsxy
,
340 .puts
=&lcd_remote_puts
,
341 .putsf
=&lcd_remote_putsf
,
342 .puts_offset
=&lcd_remote_puts_offset
,
343 .puts_scroll
=&lcd_remote_puts_scroll
,
344 .puts_scroll_offset
=&lcd_remote_puts_scroll_offset
,
345 .scroll_speed
=&lcd_remote_scroll_speed
,
346 .scroll_delay
=&lcd_remote_scroll_delay
,
347 .stop_scroll
=&lcd_remote_stop_scroll
,
348 .clear_display
=&lcd_remote_clear_display
,
349 .clear_viewport
=&lcd_remote_clear_viewport
,
350 .scroll_stop
=&lcd_remote_scroll_stop
,
351 .scroll_stop_line
=&lcd_remote_scroll_stop_line
,
352 .update
=&lcd_remote_update
,
353 .update_viewport
=&lcd_remote_update_viewport
,
354 .backlight_on
=&remote_backlight_on
,
355 .backlight_off
=&remote_backlight_off
,
356 .is_backlight_on
=&is_remote_backlight_on
,
357 .backlight_set_timeout
=&remote_backlight_set_timeout
,
360 .backdrop_load
=&remote_backdrop_load
,
361 .backdrop_show
=&remote_backdrop_show
,
363 #ifdef HAVE_BUTTONBAR
364 .has_buttonbar
=false,
366 #if defined(HAVE_LCD_BITMAP)
367 .set_framebuffer
= (void*)lcd_remote_set_framebuffer
,
370 #endif /* NB_SCREENS == 2 */
373 #ifdef HAVE_LCD_BITMAP
374 void screen_clear_area(struct screen
* display
, int xstart
, int ystart
,
375 int width
, int height
)
377 display
->set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
378 display
->fillrect(xstart
, ystart
, width
, height
);
379 display
->set_drawmode(DRMODE_SOLID
);