D2: Fix inverted USB detection.
[Rockbox.git] / apps / screen_access.c
blobdbd3727a2696d568edf582bb56b7fd8cc82d4603
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2005 by Kevin Ferrare
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 #include <lcd.h>
21 #include <lcd-remote.h>
22 #include <scroll_engine.h>
23 #include "backlight.h"
24 #include <font.h>
25 #include <button.h>
26 #include <sprintf.h>
27 #include <settings.h>
28 #include <kernel.h>
29 #include <icons.h>
31 #include "screen_access.h"
32 #include "textarea.h"
34 struct screen screens[NB_SCREENS] =
37 .screen_type=SCREEN_MAIN,
38 .width=LCD_WIDTH,
39 .height=LCD_HEIGHT,
40 .depth=LCD_DEPTH,
41 #if defined(HAVE_LCD_COLOR)
42 .is_color=true,
43 #else
44 .is_color=false,
45 #endif
46 #ifdef HAVE_LCD_BITMAP
47 .pixel_format=LCD_PIXELFORMAT,
48 #endif
49 #if (CONFIG_LED == LED_VIRTUAL)
50 .has_disk_led=false,
51 #elif defined(HAVE_REMOTE_LCD)
52 .has_disk_led=true,
53 #endif
54 .set_viewport=&lcd_set_viewport,
55 .setmargins=&lcd_setmargins,
56 .getwidth=&lcd_getwidth,
57 .getheight=&lcd_getheight,
58 .getymargin=&lcd_getymargin,
59 .getxmargin=&lcd_getxmargin,
60 .getstringsize=&lcd_getstringsize,
61 #ifdef HAVE_LCD_BITMAP
62 .setfont=&lcd_setfont,
63 .getfont=&lcd_getfont,
64 .mono_bitmap=&lcd_mono_bitmap,
65 .mono_bitmap_part=&lcd_mono_bitmap_part,
66 .set_drawmode=&lcd_set_drawmode,
67 .bitmap=(screen_bitmap_func*)&lcd_bitmap,
68 .bitmap_part=(screen_bitmap_part_func*)&lcd_bitmap_part,
69 #if LCD_DEPTH <= 2
70 /* No transparency yet for grayscale and mono lcd */
71 .transparent_bitmap=(screen_bitmap_func*)&lcd_bitmap,
72 .transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_bitmap_part,
73 #else
74 .transparent_bitmap=(screen_bitmap_func*)&lcd_bitmap_transparent,
75 .transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_bitmap_transparent_part,
76 #endif
77 #if LCD_DEPTH > 1
78 #if defined(HAVE_LCD_COLOR) && defined(LCD_REMOTE_DEPTH) && LCD_REMOTE_DEPTH > 1
79 .color_to_native=&lcd_color_to_native,
80 #endif
81 .get_background=&lcd_get_background,
82 .get_foreground=&lcd_get_foreground,
83 .set_background=&lcd_set_background,
84 .set_foreground=&lcd_set_foreground,
85 #ifdef HAVE_LCD_COLOR
86 .set_selector_start=&lcd_set_selector_start,
87 .set_selector_end=&lcd_set_selector_end,
88 .set_selector_text=&lcd_set_selector_text,
89 #endif
90 #endif /* LCD_DEPTH > 1 */
91 .update_rect=&lcd_update_rect,
92 .update_viewport_rect=&lcd_update_viewport_rect,
93 .fillrect=&lcd_fillrect,
94 .drawrect=&lcd_drawrect,
95 .drawpixel=&lcd_drawpixel,
96 .drawline=&lcd_drawline,
97 .vline=&lcd_vline,
98 .hline=&lcd_hline,
99 .scroll_step=&lcd_scroll_step,
100 .puts_style_offset=&lcd_puts_style_offset,
101 .puts_scroll_style=&lcd_puts_scroll_style,
102 .puts_scroll_style_offset=&lcd_puts_scroll_style_offset,
103 #endif /* HAVE_LCD_BITMAP */
105 #ifdef HAVE_LCD_CHARCELLS
106 .double_height=&lcd_double_height,
107 .putc=&lcd_putc,
108 .get_locked_pattern=&lcd_get_locked_pattern,
109 .define_pattern=&lcd_define_pattern,
110 .unlock_pattern=&lcd_unlock_pattern,
111 .icon=&lcd_icon,
112 #endif /* HAVE_LCD_CHARCELLS */
114 .putsxy=&lcd_putsxy,
115 .puts=&lcd_puts,
116 .puts_offset=&lcd_puts_offset,
117 .puts_scroll=&lcd_puts_scroll,
118 .puts_scroll_offset=&lcd_puts_scroll_offset,
119 .scroll_speed=&lcd_scroll_speed,
120 .scroll_delay=&lcd_scroll_delay,
121 .stop_scroll=&lcd_stop_scroll,
122 .clear_display=&lcd_clear_display,
123 .clear_viewport=&lcd_clear_viewport,
124 .scroll_stop=&lcd_scroll_stop,
125 .scroll_stop_line=&lcd_scroll_stop_line,
126 .update=&lcd_update,
127 .update_viewport=&lcd_update_viewport,
128 .backlight_on=&backlight_on,
129 .backlight_off=&backlight_off,
130 .is_backlight_on=&is_backlight_on,
131 .backlight_set_timeout=&backlight_set_timeout,
132 #ifdef HAS_BUTTONBAR
133 .has_buttonbar=false
134 #endif
136 #if NB_SCREENS == 2
138 .screen_type=SCREEN_REMOTE,
139 .width=LCD_REMOTE_WIDTH,
140 .height=LCD_REMOTE_HEIGHT,
141 .depth=LCD_REMOTE_DEPTH,
142 .is_color=false,/* No color remotes yet */
143 .pixel_format=LCD_REMOTE_PIXELFORMAT,
144 .has_disk_led=false,
145 .set_viewport=&lcd_remote_set_viewport,
146 .setmargins=&lcd_remote_setmargins,
147 .getwidth=&lcd_remote_getwidth,
148 .getheight=&lcd_remote_getheight,
149 .getymargin=&lcd_remote_getymargin,
150 .getxmargin=&lcd_remote_getxmargin,
151 .getstringsize=&lcd_remote_getstringsize,
152 #if 1 /* all remote LCDs are bitmapped so far */
153 .setfont=&lcd_remote_setfont,
154 .getfont=&lcd_remote_getfont,
155 .mono_bitmap=&lcd_remote_mono_bitmap,
156 .mono_bitmap_part=&lcd_remote_mono_bitmap_part,
157 .bitmap=(screen_bitmap_func*)&lcd_remote_bitmap,
158 .bitmap_part=(screen_bitmap_part_func*)&lcd_remote_bitmap_part,
159 .set_drawmode=&lcd_remote_set_drawmode,
160 #if LCD_REMOTE_DEPTH <= 2
161 /* No transparency yet for grayscale and mono lcd */
162 .transparent_bitmap=(screen_bitmap_func*)&lcd_remote_bitmap,
163 .transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_remote_bitmap_part,
164 /* No colour remotes yet */
165 #endif
166 #if LCD_REMOTE_DEPTH > 1
167 #if defined(HAVE_LCD_COLOR)
168 .color_to_native=&lcd_remote_color_to_native,
169 #endif
170 .get_background=&lcd_remote_get_background,
171 .get_foreground=&lcd_remote_get_foreground,
172 .set_background=&lcd_remote_set_background,
173 .set_foreground=&lcd_remote_set_foreground,
174 #endif /* LCD_REMOTE_DEPTH > 1 */
175 .update_rect=&lcd_remote_update_rect,
176 .update_viewport_rect=&lcd_remote_update_viewport_rect,
177 .fillrect=&lcd_remote_fillrect,
178 .drawrect=&lcd_remote_drawrect,
179 .drawpixel=&lcd_remote_drawpixel,
180 .drawline=&lcd_remote_drawline,
181 .vline=&lcd_remote_vline,
182 .hline=&lcd_remote_hline,
183 .scroll_step=&lcd_remote_scroll_step,
184 .puts_style_offset=&lcd_remote_puts_style_offset,
185 .puts_scroll_style=&lcd_remote_puts_scroll_style,
186 .puts_scroll_style_offset=&lcd_remote_puts_scroll_style_offset,
187 #endif /* 1 */
189 #if 0 /* no charcell remote LCDs so far */
190 .double_height=&lcd_remote_double_height,
191 .putc=&lcd_remote_putc,
192 .get_locked_pattern=&lcd_remote_get_locked_pattern,
193 .define_pattern=&lcd_remote_define_pattern,
194 .icon=&lcd_remote_icon,
195 #endif /* 0 */
196 .putsxy=&lcd_remote_putsxy,
197 .puts=&lcd_remote_puts,
198 .puts_offset=&lcd_remote_puts_offset,
199 .puts_scroll=&lcd_remote_puts_scroll,
200 .puts_scroll_offset=&lcd_remote_puts_scroll_offset,
201 .scroll_speed=&lcd_remote_scroll_speed,
202 .scroll_delay=&lcd_remote_scroll_delay,
203 .stop_scroll=&lcd_remote_stop_scroll,
204 .clear_display=&lcd_remote_clear_display,
205 .clear_viewport=&lcd_remote_clear_viewport,
206 .scroll_stop=&lcd_remote_scroll_stop,
207 .scroll_stop_line=&lcd_remote_scroll_stop_line,
208 .update=&lcd_remote_update,
209 .update_viewport=&lcd_remote_update_viewport,
210 .backlight_on=&remote_backlight_on,
211 .backlight_off=&remote_backlight_off,
212 .is_backlight_on=&is_remote_backlight_on,
213 .backlight_set_timeout=&remote_backlight_set_timeout
215 #endif /* HAVE_REMOTE_LCD */
218 #ifdef HAVE_LCD_BITMAP
219 void screen_clear_area(struct screen * display, int xstart, int ystart,
220 int width, int height)
222 display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
223 display->fillrect(xstart, ystart, width, height);
224 display->set_drawmode(DRMODE_SOLID);
226 #endif
228 void screen_access_init(void)
230 int i;
231 FOR_NB_SCREENS(i)
233 #ifdef HAVE_LCD_BITMAP
234 ((struct screen*)&screens[i])->setfont(FONT_UI);
235 #endif
236 gui_textarea_update_nblines(&screens[i]);