Linus Nielsen Feltzing | 530ff7d | 2005-10-28 00:17:15 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
Kevin Ferrare | a3ed62b | 2005-10-30 01:24:35 +0000 | [diff] [blame] | 10 | * Copyright (C) 2005 by Kevin Ferrare |
Linus Nielsen Feltzing | 530ff7d | 2005-10-28 00:17:15 +0000 | [diff] [blame] | 11 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame^] | 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. |
Linus Nielsen Feltzing | 530ff7d | 2005-10-28 00:17:15 +0000 | [diff] [blame] | 16 | * |
| 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 Chapman | 3646c31 | 2008-01-08 01:22:14 +0000 | [diff] [blame] | 24 | #include <scroll_engine.h> |
Kevin Ferrare | 74b6af9 | 2005-11-22 03:38:07 +0000 | [diff] [blame] | 25 | #include "backlight.h" |
Linus Nielsen Feltzing | 530ff7d | 2005-10-28 00:17:15 +0000 | [diff] [blame] | 26 | #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 Feltzing | 530ff7d | 2005-10-28 00:17:15 +0000 | [diff] [blame] | 34 | |
Nils Wallménius | a896f3d | 2007-09-18 19:05:35 +0000 | [diff] [blame] | 35 | struct screen screens[NB_SCREENS] = |
Linus Nielsen Feltzing | 530ff7d | 2005-10-28 00:17:15 +0000 | [diff] [blame] | 36 | { |
Linus Nielsen Feltzing | 530ff7d | 2005-10-28 00:17:15 +0000 | [diff] [blame] | 37 | { |
Nils Wallménius | a896f3d | 2007-09-18 19:05:35 +0000 | [diff] [blame] | 38 | .screen_type=SCREEN_MAIN, |
| 39 | .width=LCD_WIDTH, |
| 40 | .height=LCD_HEIGHT, |
| 41 | .depth=LCD_DEPTH, |
Michael Sevakis | 6aa12c1 | 2006-10-14 01:32:58 +0000 | [diff] [blame] | 42 | #if defined(HAVE_LCD_COLOR) |
Nils Wallménius | a896f3d | 2007-09-18 19:05:35 +0000 | [diff] [blame] | 43 | .is_color=true, |
Kevin Ferrare | f074b46 | 2007-07-18 11:18:52 +0000 | [diff] [blame] | 44 | #else |
Nils Wallménius | a896f3d | 2007-09-18 19:05:35 +0000 | [diff] [blame] | 45 | .is_color=false, |
Kevin Ferrare | f074b46 | 2007-07-18 11:18:52 +0000 | [diff] [blame] | 46 | #endif |
Kevin Ferrare | 93b2f9f | 2007-08-04 03:01:46 +0000 | [diff] [blame] | 47 | #ifdef HAVE_LCD_BITMAP |
Nils Wallménius | a896f3d | 2007-09-18 19:05:35 +0000 | [diff] [blame] | 48 | .pixel_format=LCD_PIXELFORMAT, |
Kevin Ferrare | 93b2f9f | 2007-08-04 03:01:46 +0000 | [diff] [blame] | 49 | #endif |
Jonathan Gordon | bd47d48 | 2007-02-18 05:07:19 +0000 | [diff] [blame] | 50 | #if (CONFIG_LED == LED_VIRTUAL) |
Nils Wallménius | a896f3d | 2007-09-18 19:05:35 +0000 | [diff] [blame] | 51 | .has_disk_led=false, |
Jens Arnold | 548755a | 2005-11-24 00:10:14 +0000 | [diff] [blame] | 52 | #elif defined(HAVE_REMOTE_LCD) |
Nils Wallménius | a896f3d | 2007-09-18 19:05:35 +0000 | [diff] [blame] | 53 | .has_disk_led=true, |
Kevin Ferrare | 1a1abf2 | 2005-11-20 01:02:14 +0000 | [diff] [blame] | 54 | #endif |
Dave Chapman | 3646c31 | 2008-01-08 01:22:14 +0000 | [diff] [blame] | 55 | .set_viewport=&lcd_set_viewport, |
Dave Chapman | 3646c31 | 2008-01-08 01:22:14 +0000 | [diff] [blame] | 56 | .getwidth=&lcd_getwidth, |
| 57 | .getheight=&lcd_getheight, |
Nils Wallménius | a896f3d | 2007-09-18 19:05:35 +0000 | [diff] [blame] | 58 | .getstringsize=&lcd_getstringsize, |
Jens Arnold | ad4e3d6 | 2007-03-26 07:52:13 +0000 | [diff] [blame] | 59 | #ifdef HAVE_LCD_BITMAP |
Nils Wallménius | a896f3d | 2007-09-18 19:05:35 +0000 | [diff] [blame] | 60 | .setfont=&lcd_setfont, |
Dave Chapman | 3646c31 | 2008-01-08 01:22:14 +0000 | [diff] [blame] | 61 | .getfont=&lcd_getfont, |
Nils Wallménius | a896f3d | 2007-09-18 19:05:35 +0000 | [diff] [blame] | 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, |
Jens Arnold | 539c513 | 2007-04-16 23:55:19 +0000 | [diff] [blame] | 67 | #if LCD_DEPTH <= 2 |
Nils Wallménius | a896f3d | 2007-09-18 19:05:35 +0000 | [diff] [blame] | 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, |
Linus Nielsen Feltzing | 281403a | 2006-01-28 23:12:20 +0000 | [diff] [blame] | 71 | #else |
Nils Wallménius | a896f3d | 2007-09-18 19:05:35 +0000 | [diff] [blame] | 72 | .transparent_bitmap=(screen_bitmap_func*)&lcd_bitmap_transparent, |
| 73 | .transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_bitmap_transparent_part, |
Linus Nielsen Feltzing | 281403a | 2006-01-28 23:12:20 +0000 | [diff] [blame] | 74 | #endif |
Jens Arnold | 539c513 | 2007-04-16 23:55:19 +0000 | [diff] [blame] | 75 | #if LCD_DEPTH > 1 |
Daniel Stenberg | 20a5926 | 2007-02-17 21:54:17 +0000 | [diff] [blame] | 76 | #if defined(HAVE_LCD_COLOR) && defined(LCD_REMOTE_DEPTH) && LCD_REMOTE_DEPTH > 1 |
Nils Wallménius | a896f3d | 2007-09-18 19:05:35 +0000 | [diff] [blame] | 77 | .color_to_native=&lcd_color_to_native, |
Michael Sevakis | 6aa12c1 | 2006-10-14 01:32:58 +0000 | [diff] [blame] | 78 | #endif |
Nils Wallménius | a896f3d | 2007-09-18 19:05:35 +0000 | [diff] [blame] | 79 | .get_background=&lcd_get_background, |
| 80 | .get_foreground=&lcd_get_foreground, |
| 81 | .set_background=&lcd_set_background, |
| 82 | .set_foreground=&lcd_set_foreground, |
Nicolas Pennequin | f3b015f | 2007-09-27 15:42:55 +0000 | [diff] [blame] | 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 |
Jens Arnold | ad4e3d6 | 2007-03-26 07:52:13 +0000 | [diff] [blame] | 88 | #endif /* LCD_DEPTH > 1 */ |
Nils Wallménius | a896f3d | 2007-09-18 19:05:35 +0000 | [diff] [blame] | 89 | .update_rect=&lcd_update_rect, |
Dave Chapman | 3646c31 | 2008-01-08 01:22:14 +0000 | [diff] [blame] | 90 | .update_viewport_rect=&lcd_update_viewport_rect, |
Nils Wallménius | a896f3d | 2007-09-18 19:05:35 +0000 | [diff] [blame] | 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, |
Nils Wallménius | a896f3d | 2007-09-18 19:05:35 +0000 | [diff] [blame] | 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, |
Linus Nielsen Feltzing | 530ff7d | 2005-10-28 00:17:15 +0000 | [diff] [blame] | 101 | #endif /* HAVE_LCD_BITMAP */ |
| 102 | |
| 103 | #ifdef HAVE_LCD_CHARCELLS |
Nils Wallménius | a896f3d | 2007-09-18 19:05:35 +0000 | [diff] [blame] | 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, |
Linus Nielsen Feltzing | 530ff7d | 2005-10-28 00:17:15 +0000 | [diff] [blame] | 110 | #endif /* HAVE_LCD_CHARCELLS */ |
Jens Arnold | b85cdbb | 2005-11-19 11:45:08 +0000 | [diff] [blame] | 111 | |
Nils Wallménius | a896f3d | 2007-09-18 19:05:35 +0000 | [diff] [blame] | 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, |
Dave Chapman | 3646c31 | 2008-01-08 01:22:14 +0000 | [diff] [blame] | 121 | .clear_viewport=&lcd_clear_viewport, |
| 122 | .scroll_stop=&lcd_scroll_stop, |
| 123 | .scroll_stop_line=&lcd_scroll_stop_line, |
Nils Wallménius | a896f3d | 2007-09-18 19:05:35 +0000 | [diff] [blame] | 124 | .update=&lcd_update, |
Dave Chapman | 3646c31 | 2008-01-08 01:22:14 +0000 | [diff] [blame] | 125 | .update_viewport=&lcd_update_viewport, |
Nils Wallménius | a896f3d | 2007-09-18 19:05:35 +0000 | [diff] [blame] | 126 | .backlight_on=&backlight_on, |
| 127 | .backlight_off=&backlight_off, |
| 128 | .is_backlight_on=&is_backlight_on, |
Miika Pekkarinen | 47cdc89 | 2007-10-21 11:02:51 +0000 | [diff] [blame] | 129 | .backlight_set_timeout=&backlight_set_timeout, |
Peter D'Hoye | f76122f | 2008-05-29 20:32:39 +0000 | [diff] [blame] | 130 | #ifdef HAVE_BUTTONBAR |
Miika Pekkarinen | 47cdc89 | 2007-10-21 11:02:51 +0000 | [diff] [blame] | 131 | .has_buttonbar=false |
Kevin Ferrare | db8415c | 2005-10-30 22:34:51 +0000 | [diff] [blame] | 132 | #endif |
Miika Pekkarinen | 47cdc89 | 2007-10-21 11:02:51 +0000 | [diff] [blame] | 133 | }, |
| 134 | #if NB_SCREENS == 2 |
| 135 | { |
Nils Wallménius | a896f3d | 2007-09-18 19:05:35 +0000 | [diff] [blame] | 136 | .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 Chapman | 3646c31 | 2008-01-08 01:22:14 +0000 | [diff] [blame] | 143 | .set_viewport=&lcd_remote_set_viewport, |
Dave Chapman | 3646c31 | 2008-01-08 01:22:14 +0000 | [diff] [blame] | 144 | .getwidth=&lcd_remote_getwidth, |
| 145 | .getheight=&lcd_remote_getheight, |
Nils Wallménius | a896f3d | 2007-09-18 19:05:35 +0000 | [diff] [blame] | 146 | .getstringsize=&lcd_remote_getstringsize, |
| 147 | #if 1 /* all remote LCDs are bitmapped so far */ |
Linus Nielsen Feltzing | 397296a | 2008-01-08 11:41:05 +0000 | [diff] [blame] | 148 | .setfont=&lcd_remote_setfont, |
Dave Chapman | 3646c31 | 2008-01-08 01:22:14 +0000 | [diff] [blame] | 149 | .getfont=&lcd_remote_getfont, |
Nils Wallménius | a896f3d | 2007-09-18 19:05:35 +0000 | [diff] [blame] | 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, |
Dave Chapman | 3646c31 | 2008-01-08 01:22:14 +0000 | [diff] [blame] | 171 | .update_viewport_rect=&lcd_remote_update_viewport_rect, |
Nils Wallménius | a896f3d | 2007-09-18 19:05:35 +0000 | [diff] [blame] | 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, |
Nils Wallménius | a896f3d | 2007-09-18 19:05:35 +0000 | [diff] [blame] | 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 */ |
| 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 Chapman | 3646c31 | 2008-01-08 01:22:14 +0000 | [diff] [blame] | 200 | .clear_viewport=&lcd_remote_clear_viewport, |
| 201 | .scroll_stop=&lcd_remote_scroll_stop, |
| 202 | .scroll_stop_line=&lcd_remote_scroll_stop_line, |
Nils Wallménius | a896f3d | 2007-09-18 19:05:35 +0000 | [diff] [blame] | 203 | .update=&lcd_remote_update, |
Dave Chapman | 3646c31 | 2008-01-08 01:22:14 +0000 | [diff] [blame] | 204 | .update_viewport=&lcd_remote_update_viewport, |
Nils Wallménius | a896f3d | 2007-09-18 19:05:35 +0000 | [diff] [blame] | 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 |
| 209 | } |
| 210 | #endif /* HAVE_REMOTE_LCD */ |
| 211 | }; |
Linus Nielsen Feltzing | 530ff7d | 2005-10-28 00:17:15 +0000 | [diff] [blame] | 212 | |
Kevin Ferrare | f7c9752 | 2005-11-09 01:17:57 +0000 | [diff] [blame] | 213 | #ifdef HAVE_LCD_BITMAP |
| 214 | void 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 Ferrare | 8517ed8 | 2005-11-16 02:12:25 +0000 | [diff] [blame] | 222 | |
| 223 | void screen_access_init(void) |
| 224 | { |
| 225 | int i; |
Jonathan Gordon | 0501fb0 | 2008-05-29 11:13:46 +0000 | [diff] [blame] | 226 | struct screen *display; |
Kevin Ferrare | 8517ed8 | 2005-11-16 02:12:25 +0000 | [diff] [blame] | 227 | FOR_NB_SCREENS(i) |
Nils Wallménius | a896f3d | 2007-09-18 19:05:35 +0000 | [diff] [blame] | 228 | { |
Jonathan Gordon | 0501fb0 | 2008-05-29 11:13:46 +0000 | [diff] [blame] | 229 | display = &screens[i]; |
Nils Wallménius | a896f3d | 2007-09-18 19:05:35 +0000 | [diff] [blame] | 230 | #ifdef HAVE_LCD_BITMAP |
| 231 | ((struct screen*)&screens[i])->setfont(FONT_UI); |
| 232 | #endif |
Jonathan Gordon | 0501fb0 | 2008-05-29 11:13:46 +0000 | [diff] [blame] | 233 | |
| 234 | int height=display->height; |
| 235 | #ifdef HAVE_LCD_BITMAP |
| 236 | if(global_settings.statusbar) |
| 237 | height -= STATUSBAR_HEIGHT; |
Peter D'Hoye | f76122f | 2008-05-29 20:32:39 +0000 | [diff] [blame] | 238 | #ifdef HAVE_BUTTONBAR |
Jonathan Gordon | 0501fb0 | 2008-05-29 11:13:46 +0000 | [diff] [blame] | 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; |
Nils Wallménius | a896f3d | 2007-09-18 19:05:35 +0000 | [diff] [blame] | 249 | } |
Kevin Ferrare | 8517ed8 | 2005-11-16 02:12:25 +0000 | [diff] [blame] | 250 | } |