blob: a1cabf67e39c47ca6624617f8822a2f3b780e86d [file] [log] [blame]
Linus Nielsen Feltzing530ff7d2005-10-28 00:17:15 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
Kevin Ferrarea3ed62b2005-10-30 01:24:35 +000010 * Copyright (C) 2005 by Kevin Ferrare
Linus Nielsen Feltzing530ff7d2005-10-28 00:17:15 +000011 *
Daniel Stenberg2acc0ac2008-06-28 18:10:04 +000012 * 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.
Linus Nielsen Feltzing530ff7d2005-10-28 00:17:15 +000016 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include <lcd.h>
23#include <lcd-remote.h>
Dave Chapman3646c312008-01-08 01:22:14 +000024#include <scroll_engine.h>
Kevin Ferrare74b6af92005-11-22 03:38:07 +000025#include "backlight.h"
Linus Nielsen Feltzing530ff7d2005-10-28 00:17:15 +000026#include <font.h>
27#include <button.h>
28#include <sprintf.h>
29#include <settings.h>
30#include <kernel.h>
31#include <icons.h>
32
33#include "screen_access.h"
Linus Nielsen Feltzing530ff7d2005-10-28 00:17:15 +000034
Nils Wallméniusa896f3d2007-09-18 19:05:35 +000035struct screen screens[NB_SCREENS] =
Linus Nielsen Feltzing530ff7d2005-10-28 00:17:15 +000036{
Linus Nielsen Feltzing530ff7d2005-10-28 00:17:15 +000037 {
Nils Wallméniusa896f3d2007-09-18 19:05:35 +000038 .screen_type=SCREEN_MAIN,
39 .width=LCD_WIDTH,
40 .height=LCD_HEIGHT,
41 .depth=LCD_DEPTH,
Michael Sevakis6aa12c12006-10-14 01:32:58 +000042#if defined(HAVE_LCD_COLOR)
Nils Wallméniusa896f3d2007-09-18 19:05:35 +000043 .is_color=true,
Kevin Ferraref074b462007-07-18 11:18:52 +000044#else
Nils Wallméniusa896f3d2007-09-18 19:05:35 +000045 .is_color=false,
Kevin Ferraref074b462007-07-18 11:18:52 +000046#endif
Kevin Ferrare93b2f9f2007-08-04 03:01:46 +000047#ifdef HAVE_LCD_BITMAP
Nils Wallméniusa896f3d2007-09-18 19:05:35 +000048 .pixel_format=LCD_PIXELFORMAT,
Kevin Ferrare93b2f9f2007-08-04 03:01:46 +000049#endif
Jonathan Gordonbd47d482007-02-18 05:07:19 +000050#if (CONFIG_LED == LED_VIRTUAL)
Nils Wallméniusa896f3d2007-09-18 19:05:35 +000051 .has_disk_led=false,
Jens Arnold548755a2005-11-24 00:10:14 +000052#elif defined(HAVE_REMOTE_LCD)
Nils Wallméniusa896f3d2007-09-18 19:05:35 +000053 .has_disk_led=true,
Kevin Ferrare1a1abf22005-11-20 01:02:14 +000054#endif
Dave Chapman3646c312008-01-08 01:22:14 +000055 .set_viewport=&lcd_set_viewport,
Dave Chapman3646c312008-01-08 01:22:14 +000056 .getwidth=&lcd_getwidth,
57 .getheight=&lcd_getheight,
Nils Wallméniusa896f3d2007-09-18 19:05:35 +000058 .getstringsize=&lcd_getstringsize,
Jens Arnoldad4e3d62007-03-26 07:52:13 +000059#ifdef HAVE_LCD_BITMAP
Nils Wallméniusa896f3d2007-09-18 19:05:35 +000060 .setfont=&lcd_setfont,
Dave Chapman3646c312008-01-08 01:22:14 +000061 .getfont=&lcd_getfont,
Nils Wallméniusa896f3d2007-09-18 19:05:35 +000062 .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,
Jens Arnold539c5132007-04-16 23:55:19 +000067#if LCD_DEPTH <= 2
Nils Wallméniusa896f3d2007-09-18 19:05:35 +000068 /* 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,
Linus Nielsen Feltzing281403a2006-01-28 23:12:20 +000071#else
Nils Wallméniusa896f3d2007-09-18 19:05:35 +000072 .transparent_bitmap=(screen_bitmap_func*)&lcd_bitmap_transparent,
73 .transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_bitmap_transparent_part,
Linus Nielsen Feltzing281403a2006-01-28 23:12:20 +000074#endif
Jens Arnold539c5132007-04-16 23:55:19 +000075#if LCD_DEPTH > 1
Daniel Stenberg20a59262007-02-17 21:54:17 +000076#if defined(HAVE_LCD_COLOR) && defined(LCD_REMOTE_DEPTH) && LCD_REMOTE_DEPTH > 1
Nils Wallméniusa896f3d2007-09-18 19:05:35 +000077 .color_to_native=&lcd_color_to_native,
Michael Sevakis6aa12c12006-10-14 01:32:58 +000078#endif
Nils Wallméniusa896f3d2007-09-18 19:05:35 +000079 .get_background=&lcd_get_background,
80 .get_foreground=&lcd_get_foreground,
81 .set_background=&lcd_set_background,
82 .set_foreground=&lcd_set_foreground,
Nicolas Pennequinf3b015f2007-09-27 15:42:55 +000083#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
Jens Arnoldad4e3d62007-03-26 07:52:13 +000088#endif /* LCD_DEPTH > 1 */
Nils Wallméniusa896f3d2007-09-18 19:05:35 +000089 .update_rect=&lcd_update_rect,
Dave Chapman3646c312008-01-08 01:22:14 +000090 .update_viewport_rect=&lcd_update_viewport_rect,
Nils Wallméniusa896f3d2007-09-18 19:05:35 +000091 .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,
Nils Wallméniusa896f3d2007-09-18 19:05:35 +000098 .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,
Linus Nielsen Feltzing530ff7d2005-10-28 00:17:15 +0000101#endif /* HAVE_LCD_BITMAP */
102
103#ifdef HAVE_LCD_CHARCELLS
Nils Wallméniusa896f3d2007-09-18 19:05:35 +0000104 .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,
Linus Nielsen Feltzing530ff7d2005-10-28 00:17:15 +0000110#endif /* HAVE_LCD_CHARCELLS */
Jens Arnoldb85cdbb2005-11-19 11:45:08 +0000111
Nils Wallméniusa896f3d2007-09-18 19:05:35 +0000112 .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,
Dave Chapman3646c312008-01-08 01:22:14 +0000121 .clear_viewport=&lcd_clear_viewport,
122 .scroll_stop=&lcd_scroll_stop,
123 .scroll_stop_line=&lcd_scroll_stop_line,
Nils Wallméniusa896f3d2007-09-18 19:05:35 +0000124 .update=&lcd_update,
Dave Chapman3646c312008-01-08 01:22:14 +0000125 .update_viewport=&lcd_update_viewport,
Nils Wallméniusa896f3d2007-09-18 19:05:35 +0000126 .backlight_on=&backlight_on,
127 .backlight_off=&backlight_off,
128 .is_backlight_on=&is_backlight_on,
Miika Pekkarinen47cdc892007-10-21 11:02:51 +0000129 .backlight_set_timeout=&backlight_set_timeout,
Peter D'Hoyef76122f2008-05-29 20:32:39 +0000130#ifdef HAVE_BUTTONBAR
Miika Pekkarinen47cdc892007-10-21 11:02:51 +0000131 .has_buttonbar=false
Kevin Ferraredb8415c2005-10-30 22:34:51 +0000132#endif
Miika Pekkarinen47cdc892007-10-21 11:02:51 +0000133 },
134#if NB_SCREENS == 2
135 {
Nils Wallméniusa896f3d2007-09-18 19:05:35 +0000136 .screen_type=SCREEN_REMOTE,
137 .width=LCD_REMOTE_WIDTH,
138 .height=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,
Dave Chapman3646c312008-01-08 01:22:14 +0000143 .set_viewport=&lcd_remote_set_viewport,
Dave Chapman3646c312008-01-08 01:22:14 +0000144 .getwidth=&lcd_remote_getwidth,
145 .getheight=&lcd_remote_getheight,
Nils Wallméniusa896f3d2007-09-18 19:05:35 +0000146 .getstringsize=&lcd_remote_getstringsize,
147#if 1 /* all remote LCDs are bitmapped so far */
Linus Nielsen Feltzing397296a2008-01-08 11:41:05 +0000148 .setfont=&lcd_remote_setfont,
Dave Chapman3646c312008-01-08 01:22:14 +0000149 .getfont=&lcd_remote_getfont,
Nils Wallméniusa896f3d2007-09-18 19:05:35 +0000150 .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,
Dave Chapman3646c312008-01-08 01:22:14 +0000171 .update_viewport_rect=&lcd_remote_update_viewport_rect,
Nils Wallméniusa896f3d2007-09-18 19:05:35 +0000172 .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,
Nils Wallméniusa896f3d2007-09-18 19:05:35 +0000179 .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 */
183
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,
Dave Chapman3646c312008-01-08 01:22:14 +0000200 .clear_viewport=&lcd_remote_clear_viewport,
201 .scroll_stop=&lcd_remote_scroll_stop,
202 .scroll_stop_line=&lcd_remote_scroll_stop_line,
Nils Wallméniusa896f3d2007-09-18 19:05:35 +0000203 .update=&lcd_remote_update,
Dave Chapman3646c312008-01-08 01:22:14 +0000204 .update_viewport=&lcd_remote_update_viewport,
Nils Wallméniusa896f3d2007-09-18 19:05:35 +0000205 .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
209 }
210#endif /* HAVE_REMOTE_LCD */
211};
Linus Nielsen Feltzing530ff7d2005-10-28 00:17:15 +0000212
Kevin Ferraref7c97522005-11-09 01:17:57 +0000213#ifdef HAVE_LCD_BITMAP
214void screen_clear_area(struct screen * display, int xstart, int ystart,
215 int width, int height)
216{
217 display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
218 display->fillrect(xstart, ystart, width, height);
219 display->set_drawmode(DRMODE_SOLID);
220}
221#endif
Kevin Ferrare8517ed82005-11-16 02:12:25 +0000222
223void screen_access_init(void)
224{
225 int i;
Jonathan Gordon0501fb02008-05-29 11:13:46 +0000226 struct screen *display;
Kevin Ferrare8517ed82005-11-16 02:12:25 +0000227 FOR_NB_SCREENS(i)
Nils Wallméniusa896f3d2007-09-18 19:05:35 +0000228 {
Jonathan Gordon0501fb02008-05-29 11:13:46 +0000229 display = &screens[i];
Nils Wallméniusa896f3d2007-09-18 19:05:35 +0000230#ifdef HAVE_LCD_BITMAP
231 ((struct screen*)&screens[i])->setfont(FONT_UI);
232#endif
Jonathan Gordon0501fb02008-05-29 11:13:46 +0000233
234 int height=display->height;
235#ifdef HAVE_LCD_BITMAP
236 if(global_settings.statusbar)
237 height -= STATUSBAR_HEIGHT;
Peter D'Hoyef76122f2008-05-29 20:32:39 +0000238#ifdef HAVE_BUTTONBAR
Jonathan Gordon0501fb02008-05-29 11:13:46 +0000239 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;
Nils Wallméniusa896f3d2007-09-18 19:05:35 +0000249 }
Kevin Ferrare8517ed82005-11-16 02:12:25 +0000250}