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 #include <lcd-remote.h>
26 #include <scroll_engine.h>
33 #include "backlight.h"
34 #include "screen_access.h"
37 /* some helper functions to calculate metrics on the fly */
38 static int screen_helper_getcharwidth(void)
40 #ifdef HAVE_LCD_BITMAP
41 return font_get(lcd_getfont())->maxwidth
;
47 static int screen_helper_getcharheight(void)
49 #ifdef HAVE_LCD_BITMAP
50 return font_get(lcd_getfont())->height
;
56 static int screen_helper_getnblines(void)
58 int height
=screens
[0].lcdheight
;
59 #ifdef HAVE_LCD_BITMAP
60 if(global_settings
.statusbar
!= STATUSBAR_OFF
)
61 height
-= STATUSBAR_HEIGHT
;
63 if(global_settings
.buttonbar
&& screens
[0].has_buttonbar
)
64 height
-= BUTTONBAR_HEIGHT
;
67 return height
/ screens
[0].getcharheight();
71 static int screen_helper_remote_getcharwidth(void)
73 #ifdef HAVE_LCD_BITMAP
74 return font_get(lcd_remote_getfont())->maxwidth
;
80 static int screen_helper_remote_getcharheight(void)
82 #ifdef HAVE_LCD_BITMAP
83 return font_get(lcd_remote_getfont())->height
;
89 static int screen_helper_remote_getnblines(void)
91 int height
=screens
[1].lcdheight
;
92 #ifdef HAVE_LCD_BITMAP
93 if(global_settings
.statusbar
!= STATUSBAR_OFF
)
94 height
-= STATUSBAR_HEIGHT
;
96 if(global_settings
.buttonbar
&& screens
[1].has_buttonbar
)
97 height
-= BUTTONBAR_HEIGHT
;
100 return height
/ screens
[1].getcharheight();
104 struct screen screens
[NB_SCREENS
] =
107 .screen_type
=SCREEN_MAIN
,
109 .lcdheight
=LCD_HEIGHT
,
111 .getnblines
=&screen_helper_getnblines
,
112 #if defined(HAVE_LCD_COLOR)
117 #ifdef HAVE_LCD_BITMAP
118 .pixel_format
=LCD_PIXELFORMAT
,
120 .getcharwidth
=screen_helper_getcharwidth
,
121 .getcharheight
=screen_helper_getcharheight
,
122 #if (CONFIG_LED == LED_VIRTUAL)
124 #elif defined(HAVE_REMOTE_LCD)
127 .set_viewport
=&lcd_set_viewport
,
128 .getwidth
=&lcd_getwidth
,
129 .getheight
=&lcd_getheight
,
130 .getstringsize
=&lcd_getstringsize
,
131 #ifdef HAVE_LCD_BITMAP
132 .setfont
=&lcd_setfont
,
133 .getfont
=&lcd_getfont
,
134 .mono_bitmap
=&lcd_mono_bitmap
,
135 .mono_bitmap_part
=&lcd_mono_bitmap_part
,
136 .set_drawmode
=&lcd_set_drawmode
,
137 .bitmap
=(screen_bitmap_func
*)&lcd_bitmap
,
138 .bitmap_part
=(screen_bitmap_part_func
*)&lcd_bitmap_part
,
140 /* No transparency yet for grayscale and mono lcd */
141 .transparent_bitmap
=(screen_bitmap_func
*)&lcd_bitmap
,
142 .transparent_bitmap_part
=(screen_bitmap_part_func
*)&lcd_bitmap_part
,
144 .transparent_bitmap
=(screen_bitmap_func
*)&lcd_bitmap_transparent
,
145 .transparent_bitmap_part
=(screen_bitmap_part_func
*)&lcd_bitmap_transparent_part
,
148 #if defined(HAVE_LCD_COLOR) && defined(LCD_REMOTE_DEPTH) && LCD_REMOTE_DEPTH > 1
149 .color_to_native
=&lcd_color_to_native
,
151 .get_background
=&lcd_get_background
,
152 .get_foreground
=&lcd_get_foreground
,
153 .set_background
=&lcd_set_background
,
154 .set_foreground
=&lcd_set_foreground
,
155 #ifdef HAVE_LCD_COLOR
156 .set_selector_start
=&lcd_set_selector_start
,
157 .set_selector_end
=&lcd_set_selector_end
,
158 .set_selector_text
=&lcd_set_selector_text
,
160 #endif /* LCD_DEPTH > 1 */
161 .update_rect
=&lcd_update_rect
,
162 .update_viewport_rect
=&lcd_update_viewport_rect
,
163 .fillrect
=&lcd_fillrect
,
164 .drawrect
=&lcd_drawrect
,
165 .draw_border_viewport
=&lcd_draw_border_viewport
,
166 .fill_viewport
=&lcd_fill_viewport
,
167 .drawpixel
=&lcd_drawpixel
,
168 .drawline
=&lcd_drawline
,
171 .scroll_step
=&lcd_scroll_step
,
172 .puts_style_offset
=&lcd_puts_style_offset
,
173 .puts_style_xyoffset
=&lcd_puts_style_xyoffset
,
174 .puts_scroll_style
=&lcd_puts_scroll_style
,
175 .puts_scroll_style_offset
=&lcd_puts_scroll_style_offset
,
176 .puts_scroll_style_xyoffset
=&lcd_puts_scroll_style_xyoffset
,
177 #endif /* HAVE_LCD_BITMAP */
179 #ifdef HAVE_LCD_CHARCELLS
180 .double_height
=&lcd_double_height
,
182 .get_locked_pattern
=&lcd_get_locked_pattern
,
183 .define_pattern
=&lcd_define_pattern
,
184 .unlock_pattern
=&lcd_unlock_pattern
,
186 #endif /* HAVE_LCD_CHARCELLS */
191 .puts_offset
=&lcd_puts_offset
,
192 .puts_scroll
=&lcd_puts_scroll
,
193 .puts_scroll_offset
=&lcd_puts_scroll_offset
,
194 .scroll_speed
=&lcd_scroll_speed
,
195 .scroll_delay
=&lcd_scroll_delay
,
196 .stop_scroll
=&lcd_stop_scroll
,
197 .clear_display
=&lcd_clear_display
,
198 .clear_viewport
=&lcd_clear_viewport
,
199 .scroll_stop
=&lcd_scroll_stop
,
200 .scroll_stop_line
=&lcd_scroll_stop_line
,
202 .update_viewport
=&lcd_update_viewport
,
203 .backlight_on
=&backlight_on
,
204 .backlight_off
=&backlight_off
,
205 .is_backlight_on
=&is_backlight_on
,
206 .backlight_set_timeout
=&backlight_set_timeout
,
208 .backdrop_load
=&backdrop_load
,
209 .backdrop_show
=&backdrop_show
,
211 #ifdef HAVE_BUTTONBAR
212 .has_buttonbar
=false,
217 .screen_type
=SCREEN_REMOTE
,
218 .lcdwidth
=LCD_REMOTE_WIDTH
,
219 .lcdheight
=LCD_REMOTE_HEIGHT
,
220 .depth
=LCD_REMOTE_DEPTH
,
221 .getnblines
=&screen_helper_remote_getnblines
,
222 .is_color
=false,/* No color remotes yet */
223 .pixel_format
=LCD_REMOTE_PIXELFORMAT
,
224 .getcharwidth
=screen_helper_remote_getcharwidth
,
225 .getcharheight
=screen_helper_remote_getcharheight
,
227 .set_viewport
=&lcd_remote_set_viewport
,
228 .getwidth
=&lcd_remote_getwidth
,
229 .getheight
=&lcd_remote_getheight
,
230 .getstringsize
=&lcd_remote_getstringsize
,
231 #if 1 /* all remote LCDs are bitmapped so far */
232 .setfont
=&lcd_remote_setfont
,
233 .getfont
=&lcd_remote_getfont
,
234 .mono_bitmap
=&lcd_remote_mono_bitmap
,
235 .mono_bitmap_part
=&lcd_remote_mono_bitmap_part
,
236 .bitmap
=(screen_bitmap_func
*)&lcd_remote_bitmap
,
237 .bitmap_part
=(screen_bitmap_part_func
*)&lcd_remote_bitmap_part
,
238 .set_drawmode
=&lcd_remote_set_drawmode
,
239 #if LCD_REMOTE_DEPTH <= 2
240 /* No transparency yet for grayscale and mono lcd */
241 .transparent_bitmap
=(screen_bitmap_func
*)&lcd_remote_bitmap
,
242 .transparent_bitmap_part
=(screen_bitmap_part_func
*)&lcd_remote_bitmap_part
,
243 /* No colour remotes yet */
245 #if LCD_REMOTE_DEPTH > 1
246 #if defined(HAVE_LCD_COLOR)
247 .color_to_native
=&lcd_remote_color_to_native
,
249 .get_background
=&lcd_remote_get_background
,
250 .get_foreground
=&lcd_remote_get_foreground
,
251 .set_background
=&lcd_remote_set_background
,
252 .set_foreground
=&lcd_remote_set_foreground
,
253 #endif /* LCD_REMOTE_DEPTH > 1 */
254 .update_rect
=&lcd_remote_update_rect
,
255 .update_viewport_rect
=&lcd_remote_update_viewport_rect
,
256 .fillrect
=&lcd_remote_fillrect
,
257 .drawrect
=&lcd_remote_drawrect
,
258 .draw_border_viewport
=&lcd_remote_draw_border_viewport
,
259 .fill_viewport
=&lcd_remote_fill_viewport
,
260 .drawpixel
=&lcd_remote_drawpixel
,
261 .drawline
=&lcd_remote_drawline
,
262 .vline
=&lcd_remote_vline
,
263 .hline
=&lcd_remote_hline
,
264 .scroll_step
=&lcd_remote_scroll_step
,
265 .puts_style_offset
=&lcd_remote_puts_style_offset
,
266 .puts_style_xyoffset
=&lcd_remote_puts_style_xyoffset
,
267 .puts_scroll_style
=&lcd_remote_puts_scroll_style
,
268 .puts_scroll_style_offset
=&lcd_remote_puts_scroll_style_offset
,
269 .puts_scroll_style_xyoffset
=&lcd_remote_puts_scroll_style_xyoffset
,
272 #if 0 /* no charcell remote LCDs so far */
273 .double_height
=&lcd_remote_double_height
,
274 .putc
=&lcd_remote_putc
,
275 .get_locked_pattern
=&lcd_remote_get_locked_pattern
,
276 .define_pattern
=&lcd_remote_define_pattern
,
277 .icon
=&lcd_remote_icon
,
279 .putsxy
=&lcd_remote_putsxy
,
280 .puts
=&lcd_remote_puts
,
281 .putsf
=&lcd_remote_putsf
,
282 .puts_offset
=&lcd_remote_puts_offset
,
283 .puts_scroll
=&lcd_remote_puts_scroll
,
284 .puts_scroll_offset
=&lcd_remote_puts_scroll_offset
,
285 .scroll_speed
=&lcd_remote_scroll_speed
,
286 .scroll_delay
=&lcd_remote_scroll_delay
,
287 .stop_scroll
=&lcd_remote_stop_scroll
,
288 .clear_display
=&lcd_remote_clear_display
,
289 .clear_viewport
=&lcd_remote_clear_viewport
,
290 .scroll_stop
=&lcd_remote_scroll_stop
,
291 .scroll_stop_line
=&lcd_remote_scroll_stop_line
,
292 .update
=&lcd_remote_update
,
293 .update_viewport
=&lcd_remote_update_viewport
,
294 .backlight_on
=&remote_backlight_on
,
295 .backlight_off
=&remote_backlight_off
,
296 .is_backlight_on
=&is_remote_backlight_on
,
297 .backlight_set_timeout
=&remote_backlight_set_timeout
,
300 .backdrop_load
=&remote_backdrop_load
,
301 .backdrop_show
=&remote_backdrop_show
,
303 #ifdef HAVE_BUTTONBAR
304 .has_buttonbar
=false,
307 #endif /* HAVE_REMOTE_LCD */
310 #ifdef HAVE_LCD_BITMAP
311 void screen_clear_area(struct screen
* display
, int xstart
, int ystart
,
312 int width
, int height
)
314 display
->set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
315 display
->fillrect(xstart
, ystart
, width
, height
);
316 display
->set_drawmode(DRMODE_SOLID
);