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