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
,
202 .backdrop_load
=&backdrop_load
,
203 .backdrop_unload
=&backdrop_unload
,
204 .backdrop_show
=&backdrop_show
,
205 #ifdef HAVE_BUTTONBAR
206 .has_buttonbar
=false,
211 .screen_type
=SCREEN_REMOTE
,
212 .lcdwidth
=LCD_REMOTE_WIDTH
,
213 .lcdheight
=LCD_REMOTE_HEIGHT
,
214 .depth
=LCD_REMOTE_DEPTH
,
215 .getnblines
=&screen_helper_remote_getnblines
,
216 .is_color
=false,/* No color remotes yet */
217 .pixel_format
=LCD_REMOTE_PIXELFORMAT
,
218 .getcharwidth
=screen_helper_remote_getcharwidth
,
219 .getcharheight
=screen_helper_remote_getcharheight
,
221 .set_viewport
=&lcd_remote_set_viewport
,
222 .getwidth
=&lcd_remote_getwidth
,
223 .getheight
=&lcd_remote_getheight
,
224 .getstringsize
=&lcd_remote_getstringsize
,
225 #if 1 /* all remote LCDs are bitmapped so far */
226 .setfont
=&lcd_remote_setfont
,
227 .getfont
=&lcd_remote_getfont
,
228 .mono_bitmap
=&lcd_remote_mono_bitmap
,
229 .mono_bitmap_part
=&lcd_remote_mono_bitmap_part
,
230 .bitmap
=(screen_bitmap_func
*)&lcd_remote_bitmap
,
231 .bitmap_part
=(screen_bitmap_part_func
*)&lcd_remote_bitmap_part
,
232 .set_drawmode
=&lcd_remote_set_drawmode
,
233 #if LCD_REMOTE_DEPTH <= 2
234 /* No transparency yet for grayscale and mono lcd */
235 .transparent_bitmap
=(screen_bitmap_func
*)&lcd_remote_bitmap
,
236 .transparent_bitmap_part
=(screen_bitmap_part_func
*)&lcd_remote_bitmap_part
,
237 /* No colour remotes yet */
239 #if LCD_REMOTE_DEPTH > 1
240 #if defined(HAVE_LCD_COLOR)
241 .color_to_native
=&lcd_remote_color_to_native
,
243 .get_background
=&lcd_remote_get_background
,
244 .get_foreground
=&lcd_remote_get_foreground
,
245 .set_background
=&lcd_remote_set_background
,
246 .set_foreground
=&lcd_remote_set_foreground
,
247 #endif /* LCD_REMOTE_DEPTH > 1 */
248 .update_rect
=&lcd_remote_update_rect
,
249 .update_viewport_rect
=&lcd_remote_update_viewport_rect
,
250 .fillrect
=&lcd_remote_fillrect
,
251 .drawrect
=&lcd_remote_drawrect
,
252 .drawpixel
=&lcd_remote_drawpixel
,
253 .drawline
=&lcd_remote_drawline
,
254 .vline
=&lcd_remote_vline
,
255 .hline
=&lcd_remote_hline
,
256 .scroll_step
=&lcd_remote_scroll_step
,
257 .puts_style_offset
=&lcd_remote_puts_style_offset
,
258 .puts_scroll_style
=&lcd_remote_puts_scroll_style
,
259 .puts_scroll_style_offset
=&lcd_remote_puts_scroll_style_offset
,
262 #if 0 /* no charcell remote LCDs so far */
263 .double_height
=&lcd_remote_double_height
,
264 .putc
=&lcd_remote_putc
,
265 .get_locked_pattern
=&lcd_remote_get_locked_pattern
,
266 .define_pattern
=&lcd_remote_define_pattern
,
267 .icon
=&lcd_remote_icon
,
269 .putsxy
=&lcd_remote_putsxy
,
270 .puts
=&lcd_remote_puts
,
271 .putsf
=&lcd_remote_putsf
,
272 .puts_offset
=&lcd_remote_puts_offset
,
273 .puts_scroll
=&lcd_remote_puts_scroll
,
274 .puts_scroll_offset
=&lcd_remote_puts_scroll_offset
,
275 .scroll_speed
=&lcd_remote_scroll_speed
,
276 .scroll_delay
=&lcd_remote_scroll_delay
,
277 .stop_scroll
=&lcd_remote_stop_scroll
,
278 .clear_display
=&lcd_remote_clear_display
,
279 .clear_viewport
=&lcd_remote_clear_viewport
,
280 .scroll_stop
=&lcd_remote_scroll_stop
,
281 .scroll_stop_line
=&lcd_remote_scroll_stop_line
,
282 .update
=&lcd_remote_update
,
283 .update_viewport
=&lcd_remote_update_viewport
,
284 .backlight_on
=&remote_backlight_on
,
285 .backlight_off
=&remote_backlight_off
,
286 .is_backlight_on
=&is_remote_backlight_on
,
287 .backlight_set_timeout
=&remote_backlight_set_timeout
,
288 .backdrop_load
=&remote_backdrop_load
,
289 .backdrop_unload
=&remote_backdrop_unload
,
290 .backdrop_show
=&remote_backdrop_show
,
291 #ifdef HAVE_BUTTONBAR
292 .has_buttonbar
=false,
295 #endif /* HAVE_REMOTE_LCD */
298 #ifdef HAVE_LCD_BITMAP
299 void screen_clear_area(struct screen
* display
, int xstart
, int ystart
,
300 int width
, int height
)
302 display
->set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
303 display
->fillrect(xstart
, ystart
, width
, height
);
304 display
->set_drawmode(DRMODE_SOLID
);