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"
35 /* some helper functions to calculate metrics on the fly */
36 static int screen_helper_getcharwidth(void)
38 #ifdef HAVE_LCD_BITMAP
39 return font_get(lcd_getfont())->maxwidth
;
45 static int screen_helper_getcharheight(void)
47 #ifdef HAVE_LCD_BITMAP
48 return font_get(lcd_getfont())->height
;
54 static int screen_helper_getnblines(void)
56 int height
=screens
[0].lcdheight
;
57 #ifdef HAVE_LCD_BITMAP
58 if(global_settings
.statusbar
)
59 height
-= STATUSBAR_HEIGHT
;
61 if(global_settings
.buttonbar
&& screens
[0].has_buttonbar
)
62 height
-= BUTTONBAR_HEIGHT
;
65 return height
/ screens
[0].getcharheight();
69 static int screen_helper_remote_getcharwidth(void)
71 #ifdef HAVE_LCD_BITMAP
72 return font_get(lcd_remote_getfont())->maxwidth
;
78 static int screen_helper_remote_getcharheight(void)
80 #ifdef HAVE_LCD_BITMAP
81 return font_get(lcd_remote_getfont())->height
;
87 static int screen_helper_remote_getnblines(void)
89 int height
=screens
[1].lcdheight
;
90 #ifdef HAVE_LCD_BITMAP
91 if(global_settings
.statusbar
)
92 height
-= STATUSBAR_HEIGHT
;
94 if(global_settings
.buttonbar
&& screens
[0].has_buttonbar
)
95 height
-= BUTTONBAR_HEIGHT
;
98 return height
/ screens
[1].getcharheight();
102 struct screen screens
[NB_SCREENS
] =
105 .screen_type
=SCREEN_MAIN
,
107 .lcdheight
=LCD_HEIGHT
,
109 .getnblines
=&screen_helper_getnblines
,
110 #if defined(HAVE_LCD_COLOR)
115 #ifdef HAVE_LCD_BITMAP
116 .pixel_format
=LCD_PIXELFORMAT
,
118 .getcharwidth
=screen_helper_getcharwidth
,
119 .getcharheight
=screen_helper_getcharheight
,
120 #if (CONFIG_LED == LED_VIRTUAL)
122 #elif defined(HAVE_REMOTE_LCD)
125 .set_viewport
=&lcd_set_viewport
,
126 .getwidth
=&lcd_getwidth
,
127 .getheight
=&lcd_getheight
,
128 .getstringsize
=&lcd_getstringsize
,
129 #ifdef HAVE_LCD_BITMAP
130 .setfont
=&lcd_setfont
,
131 .getfont
=&lcd_getfont
,
132 .mono_bitmap
=&lcd_mono_bitmap
,
133 .mono_bitmap_part
=&lcd_mono_bitmap_part
,
134 .set_drawmode
=&lcd_set_drawmode
,
135 .bitmap
=(screen_bitmap_func
*)&lcd_bitmap
,
136 .bitmap_part
=(screen_bitmap_part_func
*)&lcd_bitmap_part
,
138 /* No transparency yet for grayscale and mono lcd */
139 .transparent_bitmap
=(screen_bitmap_func
*)&lcd_bitmap
,
140 .transparent_bitmap_part
=(screen_bitmap_part_func
*)&lcd_bitmap_part
,
142 .transparent_bitmap
=(screen_bitmap_func
*)&lcd_bitmap_transparent
,
143 .transparent_bitmap_part
=(screen_bitmap_part_func
*)&lcd_bitmap_transparent_part
,
146 #if defined(HAVE_LCD_COLOR) && defined(LCD_REMOTE_DEPTH) && LCD_REMOTE_DEPTH > 1
147 .color_to_native
=&lcd_color_to_native
,
149 .get_background
=&lcd_get_background
,
150 .get_foreground
=&lcd_get_foreground
,
151 .set_background
=&lcd_set_background
,
152 .set_foreground
=&lcd_set_foreground
,
153 #ifdef HAVE_LCD_COLOR
154 .set_selector_start
=&lcd_set_selector_start
,
155 .set_selector_end
=&lcd_set_selector_end
,
156 .set_selector_text
=&lcd_set_selector_text
,
158 #endif /* LCD_DEPTH > 1 */
159 .update_rect
=&lcd_update_rect
,
160 .update_viewport_rect
=&lcd_update_viewport_rect
,
161 .fillrect
=&lcd_fillrect
,
162 .drawrect
=&lcd_drawrect
,
163 .drawpixel
=&lcd_drawpixel
,
164 .drawline
=&lcd_drawline
,
167 .scroll_step
=&lcd_scroll_step
,
168 .puts_style_offset
=&lcd_puts_style_offset
,
169 .puts_scroll_style
=&lcd_puts_scroll_style
,
170 .puts_scroll_style_offset
=&lcd_puts_scroll_style_offset
,
171 #endif /* HAVE_LCD_BITMAP */
173 #ifdef HAVE_LCD_CHARCELLS
174 .double_height
=&lcd_double_height
,
176 .get_locked_pattern
=&lcd_get_locked_pattern
,
177 .define_pattern
=&lcd_define_pattern
,
178 .unlock_pattern
=&lcd_unlock_pattern
,
180 #endif /* HAVE_LCD_CHARCELLS */
184 .puts_offset
=&lcd_puts_offset
,
185 .puts_scroll
=&lcd_puts_scroll
,
186 .puts_scroll_offset
=&lcd_puts_scroll_offset
,
187 .scroll_speed
=&lcd_scroll_speed
,
188 .scroll_delay
=&lcd_scroll_delay
,
189 .stop_scroll
=&lcd_stop_scroll
,
190 .clear_display
=&lcd_clear_display
,
191 .clear_viewport
=&lcd_clear_viewport
,
192 .scroll_stop
=&lcd_scroll_stop
,
193 .scroll_stop_line
=&lcd_scroll_stop_line
,
195 .update_viewport
=&lcd_update_viewport
,
196 .backlight_on
=&backlight_on
,
197 .backlight_off
=&backlight_off
,
198 .is_backlight_on
=&is_backlight_on
,
199 .backlight_set_timeout
=&backlight_set_timeout
,
200 #ifdef HAVE_BUTTONBAR
206 .screen_type
=SCREEN_REMOTE
,
207 .lcdwidth
=LCD_REMOTE_WIDTH
,
208 .lcdheight
=LCD_REMOTE_HEIGHT
,
209 .depth
=LCD_REMOTE_DEPTH
,
210 .getnblines
=&screen_helper_remote_getnblines
,
211 .is_color
=false,/* No color remotes yet */
212 .pixel_format
=LCD_REMOTE_PIXELFORMAT
,
213 .getcharwidth
=screen_helper_remote_getcharwidth
,
214 .getcharheight
=screen_helper_remote_getcharheight
,
216 .set_viewport
=&lcd_remote_set_viewport
,
217 .getwidth
=&lcd_remote_getwidth
,
218 .getheight
=&lcd_remote_getheight
,
219 .getstringsize
=&lcd_remote_getstringsize
,
220 #if 1 /* all remote LCDs are bitmapped so far */
221 .setfont
=&lcd_remote_setfont
,
222 .getfont
=&lcd_remote_getfont
,
223 .mono_bitmap
=&lcd_remote_mono_bitmap
,
224 .mono_bitmap_part
=&lcd_remote_mono_bitmap_part
,
225 .bitmap
=(screen_bitmap_func
*)&lcd_remote_bitmap
,
226 .bitmap_part
=(screen_bitmap_part_func
*)&lcd_remote_bitmap_part
,
227 .set_drawmode
=&lcd_remote_set_drawmode
,
228 #if LCD_REMOTE_DEPTH <= 2
229 /* No transparency yet for grayscale and mono lcd */
230 .transparent_bitmap
=(screen_bitmap_func
*)&lcd_remote_bitmap
,
231 .transparent_bitmap_part
=(screen_bitmap_part_func
*)&lcd_remote_bitmap_part
,
232 /* No colour remotes yet */
234 #if LCD_REMOTE_DEPTH > 1
235 #if defined(HAVE_LCD_COLOR)
236 .color_to_native
=&lcd_remote_color_to_native
,
238 .get_background
=&lcd_remote_get_background
,
239 .get_foreground
=&lcd_remote_get_foreground
,
240 .set_background
=&lcd_remote_set_background
,
241 .set_foreground
=&lcd_remote_set_foreground
,
242 #endif /* LCD_REMOTE_DEPTH > 1 */
243 .update_rect
=&lcd_remote_update_rect
,
244 .update_viewport_rect
=&lcd_remote_update_viewport_rect
,
245 .fillrect
=&lcd_remote_fillrect
,
246 .drawrect
=&lcd_remote_drawrect
,
247 .drawpixel
=&lcd_remote_drawpixel
,
248 .drawline
=&lcd_remote_drawline
,
249 .vline
=&lcd_remote_vline
,
250 .hline
=&lcd_remote_hline
,
251 .scroll_step
=&lcd_remote_scroll_step
,
252 .puts_style_offset
=&lcd_remote_puts_style_offset
,
253 .puts_scroll_style
=&lcd_remote_puts_scroll_style
,
254 .puts_scroll_style_offset
=&lcd_remote_puts_scroll_style_offset
,
257 #if 0 /* no charcell remote LCDs so far */
258 .double_height
=&lcd_remote_double_height
,
259 .putc
=&lcd_remote_putc
,
260 .get_locked_pattern
=&lcd_remote_get_locked_pattern
,
261 .define_pattern
=&lcd_remote_define_pattern
,
262 .icon
=&lcd_remote_icon
,
264 .putsxy
=&lcd_remote_putsxy
,
265 .puts
=&lcd_remote_puts
,
266 .puts_offset
=&lcd_remote_puts_offset
,
267 .puts_scroll
=&lcd_remote_puts_scroll
,
268 .puts_scroll_offset
=&lcd_remote_puts_scroll_offset
,
269 .scroll_speed
=&lcd_remote_scroll_speed
,
270 .scroll_delay
=&lcd_remote_scroll_delay
,
271 .stop_scroll
=&lcd_remote_stop_scroll
,
272 .clear_display
=&lcd_remote_clear_display
,
273 .clear_viewport
=&lcd_remote_clear_viewport
,
274 .scroll_stop
=&lcd_remote_scroll_stop
,
275 .scroll_stop_line
=&lcd_remote_scroll_stop_line
,
276 .update
=&lcd_remote_update
,
277 .update_viewport
=&lcd_remote_update_viewport
,
278 .backlight_on
=&remote_backlight_on
,
279 .backlight_off
=&remote_backlight_off
,
280 .is_backlight_on
=&is_remote_backlight_on
,
281 .backlight_set_timeout
=&remote_backlight_set_timeout
283 #endif /* HAVE_REMOTE_LCD */
286 #ifdef HAVE_LCD_BITMAP
287 void screen_clear_area(struct screen
* display
, int xstart
, int ystart
,
288 int width
, int height
)
290 display
->set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
291 display
->fillrect(xstart
, ystart
, width
, height
);
292 display
->set_drawmode(DRMODE_SOLID
);