lcd-common.h hasn't contained code in nearly 6 years.
[kugel-rb.git] / apps / screen_access.c
blobacb376e92aeb4b4619291f69848c5e87d2d12afa
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"
33 struct screen screens[NB_SCREENS] =
36 .screen_type=SCREEN_MAIN,
37 .width=LCD_WIDTH,
38 .height=LCD_HEIGHT,
39 .depth=LCD_DEPTH,
40 #if defined(HAVE_LCD_COLOR)
41 .is_color=true,
42 #else
43 .is_color=false,
44 #endif
45 #ifdef HAVE_LCD_BITMAP
46 .pixel_format=LCD_PIXELFORMAT,
47 #endif
48 #if (CONFIG_LED == LED_VIRTUAL)
49 .has_disk_led=false,
50 #elif defined(HAVE_REMOTE_LCD)
51 .has_disk_led=true,
52 #endif
53 .set_viewport=&lcd_set_viewport,
54 .setmargins=&lcd_setmargins,
55 .getwidth=&lcd_getwidth,
56 .getheight=&lcd_getheight,
57 .getymargin=&lcd_getymargin,
58 .getxmargin=&lcd_getxmargin,
59 .getstringsize=&lcd_getstringsize,
60 #ifdef HAVE_LCD_BITMAP
61 .setfont=&lcd_setfont,
62 .getfont=&lcd_getfont,
63 .mono_bitmap=&lcd_mono_bitmap,
64 .mono_bitmap_part=&lcd_mono_bitmap_part,
65 .set_drawmode=&lcd_set_drawmode,
66 .bitmap=(screen_bitmap_func*)&lcd_bitmap,
67 .bitmap_part=(screen_bitmap_part_func*)&lcd_bitmap_part,
68 #if LCD_DEPTH <= 2
69 /* No transparency yet for grayscale and mono lcd */
70 .transparent_bitmap=(screen_bitmap_func*)&lcd_bitmap,
71 .transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_bitmap_part,
72 #else
73 .transparent_bitmap=(screen_bitmap_func*)&lcd_bitmap_transparent,
74 .transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_bitmap_transparent_part,
75 #endif
76 #if LCD_DEPTH > 1
77 #if defined(HAVE_LCD_COLOR) && defined(LCD_REMOTE_DEPTH) && LCD_REMOTE_DEPTH > 1
78 .color_to_native=&lcd_color_to_native,
79 #endif
80 .get_background=&lcd_get_background,
81 .get_foreground=&lcd_get_foreground,
82 .set_background=&lcd_set_background,
83 .set_foreground=&lcd_set_foreground,
84 #ifdef HAVE_LCD_COLOR
85 .set_selector_start=&lcd_set_selector_start,
86 .set_selector_end=&lcd_set_selector_end,
87 .set_selector_text=&lcd_set_selector_text,
88 #endif
89 #endif /* LCD_DEPTH > 1 */
90 .update_rect=&lcd_update_rect,
91 .update_viewport_rect=&lcd_update_viewport_rect,
92 .fillrect=&lcd_fillrect,
93 .drawrect=&lcd_drawrect,
94 .drawpixel=&lcd_drawpixel,
95 .drawline=&lcd_drawline,
96 .vline=&lcd_vline,
97 .hline=&lcd_hline,
98 .scroll_step=&lcd_scroll_step,
99 .puts_style_offset=&lcd_puts_style_offset,
100 .puts_scroll_style=&lcd_puts_scroll_style,
101 .puts_scroll_style_offset=&lcd_puts_scroll_style_offset,
102 #endif /* HAVE_LCD_BITMAP */
104 #ifdef HAVE_LCD_CHARCELLS
105 .double_height=&lcd_double_height,
106 .putc=&lcd_putc,
107 .get_locked_pattern=&lcd_get_locked_pattern,
108 .define_pattern=&lcd_define_pattern,
109 .unlock_pattern=&lcd_unlock_pattern,
110 .icon=&lcd_icon,
111 #endif /* HAVE_LCD_CHARCELLS */
113 .putsxy=&lcd_putsxy,
114 .puts=&lcd_puts,
115 .puts_offset=&lcd_puts_offset,
116 .puts_scroll=&lcd_puts_scroll,
117 .puts_scroll_offset=&lcd_puts_scroll_offset,
118 .scroll_speed=&lcd_scroll_speed,
119 .scroll_delay=&lcd_scroll_delay,
120 .stop_scroll=&lcd_stop_scroll,
121 .clear_display=&lcd_clear_display,
122 .clear_viewport=&lcd_clear_viewport,
123 .scroll_stop=&lcd_scroll_stop,
124 .scroll_stop_line=&lcd_scroll_stop_line,
125 .update=&lcd_update,
126 .update_viewport=&lcd_update_viewport,
127 .backlight_on=&backlight_on,
128 .backlight_off=&backlight_off,
129 .is_backlight_on=&is_backlight_on,
130 .backlight_set_timeout=&backlight_set_timeout,
131 #ifdef HAVE_BUTTONBAR
132 .has_buttonbar=false
133 #endif
135 #if NB_SCREENS == 2
137 .screen_type=SCREEN_REMOTE,
138 .width=LCD_REMOTE_WIDTH,
139 .height=LCD_REMOTE_HEIGHT,
140 .depth=LCD_REMOTE_DEPTH,
141 .is_color=false,/* No color remotes yet */
142 .pixel_format=LCD_REMOTE_PIXELFORMAT,
143 .has_disk_led=false,
144 .set_viewport=&lcd_remote_set_viewport,
145 .setmargins=&lcd_remote_setmargins,
146 .getwidth=&lcd_remote_getwidth,
147 .getheight=&lcd_remote_getheight,
148 .getymargin=&lcd_remote_getymargin,
149 .getxmargin=&lcd_remote_getxmargin,
150 .getstringsize=&lcd_remote_getstringsize,
151 #if 1 /* all remote LCDs are bitmapped so far */
152 .setfont=&lcd_remote_setfont,
153 .getfont=&lcd_remote_getfont,
154 .mono_bitmap=&lcd_remote_mono_bitmap,
155 .mono_bitmap_part=&lcd_remote_mono_bitmap_part,
156 .bitmap=(screen_bitmap_func*)&lcd_remote_bitmap,
157 .bitmap_part=(screen_bitmap_part_func*)&lcd_remote_bitmap_part,
158 .set_drawmode=&lcd_remote_set_drawmode,
159 #if LCD_REMOTE_DEPTH <= 2
160 /* No transparency yet for grayscale and mono lcd */
161 .transparent_bitmap=(screen_bitmap_func*)&lcd_remote_bitmap,
162 .transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_remote_bitmap_part,
163 /* No colour remotes yet */
164 #endif
165 #if LCD_REMOTE_DEPTH > 1
166 #if defined(HAVE_LCD_COLOR)
167 .color_to_native=&lcd_remote_color_to_native,
168 #endif
169 .get_background=&lcd_remote_get_background,
170 .get_foreground=&lcd_remote_get_foreground,
171 .set_background=&lcd_remote_set_background,
172 .set_foreground=&lcd_remote_set_foreground,
173 #endif /* LCD_REMOTE_DEPTH > 1 */
174 .update_rect=&lcd_remote_update_rect,
175 .update_viewport_rect=&lcd_remote_update_viewport_rect,
176 .fillrect=&lcd_remote_fillrect,
177 .drawrect=&lcd_remote_drawrect,
178 .drawpixel=&lcd_remote_drawpixel,
179 .drawline=&lcd_remote_drawline,
180 .vline=&lcd_remote_vline,
181 .hline=&lcd_remote_hline,
182 .scroll_step=&lcd_remote_scroll_step,
183 .puts_style_offset=&lcd_remote_puts_style_offset,
184 .puts_scroll_style=&lcd_remote_puts_scroll_style,
185 .puts_scroll_style_offset=&lcd_remote_puts_scroll_style_offset,
186 #endif /* 1 */
188 #if 0 /* no charcell remote LCDs so far */
189 .double_height=&lcd_remote_double_height,
190 .putc=&lcd_remote_putc,
191 .get_locked_pattern=&lcd_remote_get_locked_pattern,
192 .define_pattern=&lcd_remote_define_pattern,
193 .icon=&lcd_remote_icon,
194 #endif /* 0 */
195 .putsxy=&lcd_remote_putsxy,
196 .puts=&lcd_remote_puts,
197 .puts_offset=&lcd_remote_puts_offset,
198 .puts_scroll=&lcd_remote_puts_scroll,
199 .puts_scroll_offset=&lcd_remote_puts_scroll_offset,
200 .scroll_speed=&lcd_remote_scroll_speed,
201 .scroll_delay=&lcd_remote_scroll_delay,
202 .stop_scroll=&lcd_remote_stop_scroll,
203 .clear_display=&lcd_remote_clear_display,
204 .clear_viewport=&lcd_remote_clear_viewport,
205 .scroll_stop=&lcd_remote_scroll_stop,
206 .scroll_stop_line=&lcd_remote_scroll_stop_line,
207 .update=&lcd_remote_update,
208 .update_viewport=&lcd_remote_update_viewport,
209 .backlight_on=&remote_backlight_on,
210 .backlight_off=&remote_backlight_off,
211 .is_backlight_on=&is_remote_backlight_on,
212 .backlight_set_timeout=&remote_backlight_set_timeout
214 #endif /* HAVE_REMOTE_LCD */
217 #ifdef HAVE_LCD_BITMAP
218 void screen_clear_area(struct screen * display, int xstart, int ystart,
219 int width, int height)
221 display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
222 display->fillrect(xstart, ystart, width, height);
223 display->set_drawmode(DRMODE_SOLID);
225 #endif
227 void screen_access_init(void)
229 int i;
230 struct screen *display;
231 FOR_NB_SCREENS(i)
233 display = &screens[i];
234 #ifdef HAVE_LCD_BITMAP
235 ((struct screen*)&screens[i])->setfont(FONT_UI);
236 #endif
238 int height=display->height;
239 #ifdef HAVE_LCD_BITMAP
240 if(global_settings.statusbar)
241 height -= STATUSBAR_HEIGHT;
242 #ifdef HAVE_BUTTONBAR
243 if(global_settings.buttonbar && display->has_buttonbar)
244 height -= BUTTONBAR_HEIGHT;
245 #endif
246 display->getstringsize((unsigned char *)"A", &display->char_width,
247 &display->char_height);
248 #else
249 display->char_width = 1;
250 display->char_height = 1;
251 #endif
252 display->nb_lines = height / display->char_height;