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