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 ****************************************************************************/
23 #include <lcd-remote.h>
24 #include <scroll_engine.h>
25 #include "backlight.h"
33 #include "screen_access.h"
36 /* some helper functions to calculate metrics on the fly */
37 static int screen_helper_getcharwidth(void)
39 #ifdef HAVE_LCD_BITMAP
40 return font_get(lcd_getfont())->maxwidth
;
46 static int screen_helper_getcharheight(void)
48 #ifdef HAVE_LCD_BITMAP
49 return font_get(lcd_getfont())->height
;
55 static int screen_helper_getnblines(void)
57 int height
=screens
[0].lcdheight
;
58 #ifdef HAVE_LCD_BITMAP
59 if(global_settings
.statusbar
!= STATUSBAR_OFF
)
60 height
-= STATUSBAR_HEIGHT
;
62 if(global_settings
.buttonbar
&& screens
[0].has_buttonbar
)
63 height
-= BUTTONBAR_HEIGHT
;
66 return height
/ screens
[0].getcharheight();
70 static int screen_helper_remote_getcharwidth(void)
72 #ifdef HAVE_LCD_BITMAP
73 return font_get(lcd_remote_getfont())->maxwidth
;
79 static int screen_helper_remote_getcharheight(void)
81 #ifdef HAVE_LCD_BITMAP
82 return font_get(lcd_remote_getfont())->height
;
88 static int screen_helper_remote_getnblines(void)
90 int height
=screens
[1].lcdheight
;
91 #ifdef HAVE_LCD_BITMAP
92 if(global_settings
.statusbar
!= STATUSBAR_OFF
)
93 height
-= STATUSBAR_HEIGHT
;
95 if(global_settings
.buttonbar
&& screens
[1].has_buttonbar
)
96 height
-= BUTTONBAR_HEIGHT
;
99 return height
/ screens
[1].getcharheight();
103 struct screen screens
[NB_SCREENS
] =
106 .screen_type
=SCREEN_MAIN
,
108 .lcdheight
=LCD_HEIGHT
,
110 .getnblines
=&screen_helper_getnblines
,
111 #if defined(HAVE_LCD_COLOR)
116 #ifdef HAVE_LCD_BITMAP
117 .pixel_format
=LCD_PIXELFORMAT
,
119 .getcharwidth
=screen_helper_getcharwidth
,
120 .getcharheight
=screen_helper_getcharheight
,
121 #if (CONFIG_LED == LED_VIRTUAL)
123 #elif defined(HAVE_REMOTE_LCD)
126 .set_viewport
=&lcd_set_viewport
,
127 .getwidth
=&lcd_getwidth
,
128 .getheight
=&lcd_getheight
,
129 .getstringsize
=&lcd_getstringsize
,
130 #ifdef HAVE_LCD_BITMAP
131 .setfont
=&lcd_setfont
,
132 .getfont
=&lcd_getfont
,
133 .mono_bitmap
=&lcd_mono_bitmap
,
134 .mono_bitmap_part
=&lcd_mono_bitmap_part
,
135 .set_drawmode
=&lcd_set_drawmode
,
136 .bitmap
=(screen_bitmap_func
*)&lcd_bitmap
,
137 .bitmap_part
=(screen_bitmap_part_func
*)&lcd_bitmap_part
,
139 /* No transparency yet for grayscale and mono lcd */
140 .transparent_bitmap
=(screen_bitmap_func
*)&lcd_bitmap
,
141 .transparent_bitmap_part
=(screen_bitmap_part_func
*)&lcd_bitmap_part
,
143 .transparent_bitmap
=(screen_bitmap_func
*)&lcd_bitmap_transparent
,
144 .transparent_bitmap_part
=(screen_bitmap_part_func
*)&lcd_bitmap_transparent_part
,
147 #if defined(HAVE_LCD_COLOR) && defined(LCD_REMOTE_DEPTH) && LCD_REMOTE_DEPTH > 1
148 .color_to_native
=&lcd_color_to_native
,
150 .get_background
=&lcd_get_background
,
151 .get_foreground
=&lcd_get_foreground
,
152 .set_background
=&lcd_set_background
,
153 .set_foreground
=&lcd_set_foreground
,
154 #ifdef HAVE_LCD_COLOR
155 .set_selector_start
=&lcd_set_selector_start
,
156 .set_selector_end
=&lcd_set_selector_end
,
157 .set_selector_text
=&lcd_set_selector_text
,
159 #endif /* LCD_DEPTH > 1 */
160 .update_rect
=&lcd_update_rect
,
161 .update_viewport_rect
=&lcd_update_viewport_rect
,
162 .fillrect
=&lcd_fillrect
,
163 .drawrect
=&lcd_drawrect
,
164 .drawpixel
=&lcd_drawpixel
,
165 .drawline
=&lcd_drawline
,
168 .scroll_step
=&lcd_scroll_step
,
169 .puts_style_offset
=&lcd_puts_style_offset
,
170 .puts_scroll_style
=&lcd_puts_scroll_style
,
171 .puts_scroll_style_offset
=&lcd_puts_scroll_style_offset
,
172 #endif /* HAVE_LCD_BITMAP */
174 #ifdef HAVE_LCD_CHARCELLS
175 .double_height
=&lcd_double_height
,
177 .get_locked_pattern
=&lcd_get_locked_pattern
,
178 .define_pattern
=&lcd_define_pattern
,
179 .unlock_pattern
=&lcd_unlock_pattern
,
181 #endif /* HAVE_LCD_CHARCELLS */
186 .puts_offset
=&lcd_puts_offset
,
187 .puts_scroll
=&lcd_puts_scroll
,
188 .puts_scroll_offset
=&lcd_puts_scroll_offset
,
189 .scroll_speed
=&lcd_scroll_speed
,
190 .scroll_delay
=&lcd_scroll_delay
,
191 .stop_scroll
=&lcd_stop_scroll
,
192 .clear_display
=&lcd_clear_display
,
193 .clear_viewport
=&lcd_clear_viewport
,
194 .scroll_stop
=&lcd_scroll_stop
,
195 .scroll_stop_line
=&lcd_scroll_stop_line
,
197 .update_viewport
=&lcd_update_viewport
,
198 .backlight_on
=&backlight_on
,
199 .backlight_off
=&backlight_off
,
200 .is_backlight_on
=&is_backlight_on
,
201 .backlight_set_timeout
=&backlight_set_timeout
,
203 .backdrop_load
=&backdrop_load
,
204 .backdrop_unload
=&backdrop_unload
,
205 .backdrop_show
=&backdrop_show
,
206 .backdrop_hide
=&backdrop_hide
,
208 #ifdef HAVE_BUTTONBAR
209 .has_buttonbar
=false,
214 .screen_type
=SCREEN_REMOTE
,
215 .lcdwidth
=LCD_REMOTE_WIDTH
,
216 .lcdheight
=LCD_REMOTE_HEIGHT
,
217 .depth
=LCD_REMOTE_DEPTH
,
218 .getnblines
=&screen_helper_remote_getnblines
,
219 .is_color
=false,/* No color remotes yet */
220 .pixel_format
=LCD_REMOTE_PIXELFORMAT
,
221 .getcharwidth
=screen_helper_remote_getcharwidth
,
222 .getcharheight
=screen_helper_remote_getcharheight
,
224 .set_viewport
=&lcd_remote_set_viewport
,
225 .getwidth
=&lcd_remote_getwidth
,
226 .getheight
=&lcd_remote_getheight
,
227 .getstringsize
=&lcd_remote_getstringsize
,
228 #if 1 /* all remote LCDs are bitmapped so far */
229 .setfont
=&lcd_remote_setfont
,
230 .getfont
=&lcd_remote_getfont
,
231 .mono_bitmap
=&lcd_remote_mono_bitmap
,
232 .mono_bitmap_part
=&lcd_remote_mono_bitmap_part
,
233 .bitmap
=(screen_bitmap_func
*)&lcd_remote_bitmap
,
234 .bitmap_part
=(screen_bitmap_part_func
*)&lcd_remote_bitmap_part
,
235 .set_drawmode
=&lcd_remote_set_drawmode
,
236 #if LCD_REMOTE_DEPTH <= 2
237 /* No transparency yet for grayscale and mono lcd */
238 .transparent_bitmap
=(screen_bitmap_func
*)&lcd_remote_bitmap
,
239 .transparent_bitmap_part
=(screen_bitmap_part_func
*)&lcd_remote_bitmap_part
,
240 /* No colour remotes yet */
242 #if LCD_REMOTE_DEPTH > 1
243 #if defined(HAVE_LCD_COLOR)
244 .color_to_native
=&lcd_remote_color_to_native
,
246 .get_background
=&lcd_remote_get_background
,
247 .get_foreground
=&lcd_remote_get_foreground
,
248 .set_background
=&lcd_remote_set_background
,
249 .set_foreground
=&lcd_remote_set_foreground
,
250 #endif /* LCD_REMOTE_DEPTH > 1 */
251 .update_rect
=&lcd_remote_update_rect
,
252 .update_viewport_rect
=&lcd_remote_update_viewport_rect
,
253 .fillrect
=&lcd_remote_fillrect
,
254 .drawrect
=&lcd_remote_drawrect
,
255 .drawpixel
=&lcd_remote_drawpixel
,
256 .drawline
=&lcd_remote_drawline
,
257 .vline
=&lcd_remote_vline
,
258 .hline
=&lcd_remote_hline
,
259 .scroll_step
=&lcd_remote_scroll_step
,
260 .puts_style_offset
=&lcd_remote_puts_style_offset
,
261 .puts_scroll_style
=&lcd_remote_puts_scroll_style
,
262 .puts_scroll_style_offset
=&lcd_remote_puts_scroll_style_offset
,
265 #if 0 /* no charcell remote LCDs so far */
266 .double_height
=&lcd_remote_double_height
,
267 .putc
=&lcd_remote_putc
,
268 .get_locked_pattern
=&lcd_remote_get_locked_pattern
,
269 .define_pattern
=&lcd_remote_define_pattern
,
270 .icon
=&lcd_remote_icon
,
272 .putsxy
=&lcd_remote_putsxy
,
273 .puts
=&lcd_remote_puts
,
274 .putsf
=&lcd_remote_putsf
,
275 .puts_offset
=&lcd_remote_puts_offset
,
276 .puts_scroll
=&lcd_remote_puts_scroll
,
277 .puts_scroll_offset
=&lcd_remote_puts_scroll_offset
,
278 .scroll_speed
=&lcd_remote_scroll_speed
,
279 .scroll_delay
=&lcd_remote_scroll_delay
,
280 .stop_scroll
=&lcd_remote_stop_scroll
,
281 .clear_display
=&lcd_remote_clear_display
,
282 .clear_viewport
=&lcd_remote_clear_viewport
,
283 .scroll_stop
=&lcd_remote_scroll_stop
,
284 .scroll_stop_line
=&lcd_remote_scroll_stop_line
,
285 .update
=&lcd_remote_update
,
286 .update_viewport
=&lcd_remote_update_viewport
,
287 .backlight_on
=&remote_backlight_on
,
288 .backlight_off
=&remote_backlight_off
,
289 .is_backlight_on
=&is_remote_backlight_on
,
290 .backlight_set_timeout
=&remote_backlight_set_timeout
,
293 .backdrop_load
=&remote_backdrop_load
,
294 .backdrop_unload
=&remote_backdrop_unload
,
295 .backdrop_show
=&remote_backdrop_show
,
296 .backdrop_hide
=&remote_backdrop_hide
,
298 #ifdef HAVE_BUTTONBAR
299 .has_buttonbar
=false,
302 #endif /* HAVE_REMOTE_LCD */
305 #ifdef HAVE_LCD_BITMAP
306 void screen_clear_area(struct screen
* display
, int xstart
, int ystart
,
307 int width
, int height
)
309 display
->set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
310 display
->fillrect(xstart
, ystart
, width
, height
);
311 display
->set_drawmode(DRMODE_SOLID
);