HDD6330: Configure touchpad (maximum touch sensivity, reduce transmission
[maemo-rb.git] / apps / screen_access.c
blobb83e842de8229fbc5a5e3c6ed90441b0d4da4ca4
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
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 ****************************************************************************/
22 #include <stdio.h>
23 #include "config.h"
24 #include <lcd.h>
25 #include <lcd-remote.h>
26 #include <scroll_engine.h>
27 #include <font.h>
28 #include <button.h>
29 #include <settings.h>
30 #include <kernel.h>
31 #include <icons.h>
33 #include "backlight.h"
34 #include "screen_access.h"
35 #include "backdrop.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;
42 #else
43 return 1;
44 #endif
47 static int screen_helper_getcharheight(void)
49 #ifdef HAVE_LCD_BITMAP
50 return font_get(lcd_getfont())->height;
51 #else
52 return 1;
53 #endif
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;
62 #ifdef HAVE_BUTTONBAR
63 if(global_settings.buttonbar && screens[0].has_buttonbar)
64 height -= BUTTONBAR_HEIGHT;
65 #endif
66 #endif
67 return height / screens[0].getcharheight();
70 #if NB_SCREENS == 2
71 static int screen_helper_remote_getcharwidth(void)
73 #ifdef HAVE_LCD_BITMAP
74 return font_get(lcd_remote_getfont())->maxwidth;
75 #else
76 return 1;
77 #endif
80 static int screen_helper_remote_getcharheight(void)
82 #ifdef HAVE_LCD_BITMAP
83 return font_get(lcd_remote_getfont())->height;
84 #else
85 return 1;
86 #endif
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;
95 #ifdef HAVE_BUTTONBAR
96 if(global_settings.buttonbar && screens[1].has_buttonbar)
97 height -= BUTTONBAR_HEIGHT;
98 #endif
99 #endif
100 return height / screens[1].getcharheight();
102 #endif
104 struct screen screens[NB_SCREENS] =
107 .screen_type=SCREEN_MAIN,
108 .lcdwidth=LCD_WIDTH,
109 .lcdheight=LCD_HEIGHT,
110 .depth=LCD_DEPTH,
111 .getnblines=&screen_helper_getnblines,
112 #if defined(HAVE_LCD_COLOR)
113 .is_color=true,
114 #else
115 .is_color=false,
116 #endif
117 #ifdef HAVE_LCD_BITMAP
118 .pixel_format=LCD_PIXELFORMAT,
119 #endif
120 .getcharwidth=screen_helper_getcharwidth,
121 .getcharheight=screen_helper_getcharheight,
122 #if (CONFIG_LED == LED_VIRTUAL)
123 .has_disk_led=false,
124 #elif defined(HAVE_REMOTE_LCD)
125 .has_disk_led=true,
126 #endif
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,
139 #if LCD_DEPTH <= 2
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,
143 #else
144 .transparent_bitmap=(screen_bitmap_func*)&lcd_bitmap_transparent,
145 .transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_bitmap_transparent_part,
146 #endif
147 #if LCD_DEPTH > 1
148 #if defined(HAVE_LCD_COLOR) && defined(LCD_REMOTE_DEPTH) && LCD_REMOTE_DEPTH > 1
149 .color_to_native=&lcd_color_to_native,
150 #endif
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,
159 #endif
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,
169 .vline=&lcd_vline,
170 .hline=&lcd_hline,
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,
181 .putchar=&lcd_putc,
182 .get_locked_pattern=&lcd_get_locked_pattern,
183 .define_pattern=&lcd_define_pattern,
184 .unlock_pattern=&lcd_unlock_pattern,
185 .icon=&lcd_icon,
186 #endif /* HAVE_LCD_CHARCELLS */
188 .putsxy=&lcd_putsxy,
189 .puts=&lcd_puts,
190 .putsf=&lcd_putsf,
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,
201 .update=&lcd_update,
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,
207 #if LCD_DEPTH > 1
208 .backdrop_load=&backdrop_load,
209 .backdrop_show=&backdrop_show,
210 #endif
211 #ifdef HAVE_BUTTONBAR
212 .has_buttonbar=false,
213 #endif
215 #if NB_SCREENS == 2
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,
226 .has_disk_led=false,
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 */
244 #endif
245 #if LCD_REMOTE_DEPTH > 1
246 #if defined(HAVE_LCD_COLOR)
247 .color_to_native=&lcd_remote_color_to_native,
248 #endif
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,
270 #endif /* 1 */
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,
278 #endif /* 0 */
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,
299 #if LCD_DEPTH > 1
300 .backdrop_load=&remote_backdrop_load,
301 .backdrop_show=&remote_backdrop_show,
302 #endif
303 #ifdef HAVE_BUTTONBAR
304 .has_buttonbar=false,
305 #endif
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);
318 #endif