Michael Sevakis | 58fc279 | 2007-07-28 08:12:05 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
| 10 | * Copyright (C) 2007 Michael Sevakis |
| 11 | * |
| 12 | * LCD scrolling driver and scheduler |
| 13 | * |
| 14 | * Much collected and combined from the various Rockbox LCD drivers. |
| 15 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame^] | 16 | * This program is free software; you can redistribute it and/or |
| 17 | * modify it under the terms of the GNU General Public License |
| 18 | * as published by the Free Software Foundation; either version 2 |
| 19 | * of the License, or (at your option) any later version. |
Michael Sevakis | 58fc279 | 2007-07-28 08:12:05 +0000 | [diff] [blame] | 20 | * |
| 21 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 22 | * KIND, either express or implied. |
| 23 | * |
| 24 | ****************************************************************************/ |
| 25 | #ifndef __SCROLL_ENGINE_H__ |
| 26 | #define __SCROLL_ENGINE_H__ |
| 27 | |
Dave Chapman | 945c8a2 | 2008-01-07 20:34:11 +0000 | [diff] [blame] | 28 | #include <lcd.h> |
| 29 | |
Michael Sevakis | 58fc279 | 2007-07-28 08:12:05 +0000 | [diff] [blame] | 30 | void scroll_init(void); |
Dave Chapman | 945c8a2 | 2008-01-07 20:34:11 +0000 | [diff] [blame] | 31 | void lcd_scroll_stop(struct viewport* vp); |
| 32 | void lcd_scroll_stop_line(struct viewport* vp, int y); |
Michael Sevakis | 58fc279 | 2007-07-28 08:12:05 +0000 | [diff] [blame] | 33 | void lcd_scroll_fn(void); |
Dave Chapman | 945c8a2 | 2008-01-07 20:34:11 +0000 | [diff] [blame] | 34 | #ifdef HAVE_REMOTE_LCD |
Michael Sevakis | 58fc279 | 2007-07-28 08:12:05 +0000 | [diff] [blame] | 35 | void lcd_remote_scroll_fn(void); |
Dave Chapman | 945c8a2 | 2008-01-07 20:34:11 +0000 | [diff] [blame] | 36 | void lcd_remote_scroll_stop(struct viewport* vp); |
| 37 | void lcd_remote_scroll_stop_line(struct viewport* vp, int y); |
| 38 | #endif |
Michael Sevakis | 58fc279 | 2007-07-28 08:12:05 +0000 | [diff] [blame] | 39 | |
| 40 | /* internal usage, but in multiple drivers */ |
| 41 | #define SCROLL_SPACING 3 |
| 42 | #ifdef HAVE_LCD_BITMAP |
| 43 | #define SCROLL_LINE_SIZE (MAX_PATH + SCROLL_SPACING + 3*LCD_WIDTH/2 + 2) |
| 44 | #else |
| 45 | #define SCROLL_LINE_SIZE (MAX_PATH + SCROLL_SPACING + 3*LCD_WIDTH + 2) |
| 46 | #endif |
| 47 | |
| 48 | struct scrollinfo |
| 49 | { |
Dave Chapman | 945c8a2 | 2008-01-07 20:34:11 +0000 | [diff] [blame] | 50 | struct viewport* vp; |
Michael Sevakis | 58fc279 | 2007-07-28 08:12:05 +0000 | [diff] [blame] | 51 | char line[SCROLL_LINE_SIZE]; |
| 52 | int len; /* length of line in chars */ |
Dave Chapman | 945c8a2 | 2008-01-07 20:34:11 +0000 | [diff] [blame] | 53 | int y; /* Position of the line on the screen (char co-ordinates) */ |
Michael Sevakis | 58fc279 | 2007-07-28 08:12:05 +0000 | [diff] [blame] | 54 | int offset; |
| 55 | int startx; |
| 56 | #ifdef HAVE_LCD_BITMAP |
| 57 | int width; /* length of line in pixels */ |
Antoine Cellerier | 7b7b931 | 2007-09-30 21:12:33 +0000 | [diff] [blame] | 58 | int style; /* line style */ |
Nicolas Pennequin | f3b015f | 2007-09-27 15:42:55 +0000 | [diff] [blame] | 59 | #endif/* HAVE_LCD_BITMAP */ |
Michael Sevakis | 58fc279 | 2007-07-28 08:12:05 +0000 | [diff] [blame] | 60 | bool backward; /* scroll presently forward or backward? */ |
| 61 | bool bidir; |
| 62 | long start_tick; |
Michael Sevakis | 58fc279 | 2007-07-28 08:12:05 +0000 | [diff] [blame] | 63 | }; |
| 64 | |
| 65 | struct scroll_screen_info |
| 66 | { |
| 67 | struct scrollinfo * const scroll; |
| 68 | const int num_scroll; /* number of scrollable lines (also number of scroll structs) */ |
Dave Chapman | 945c8a2 | 2008-01-07 20:34:11 +0000 | [diff] [blame] | 69 | int lines; /* Number of currently scrolling lines */ |
Michael Sevakis | 58fc279 | 2007-07-28 08:12:05 +0000 | [diff] [blame] | 70 | long ticks; /* # of ticks between updates*/ |
| 71 | long delay; /* ticks delay before start */ |
| 72 | int bidir_limit; /* percent */ |
| 73 | #ifdef HAVE_LCD_CHARCELLS |
| 74 | long jump_scroll_delay; /* delay between jump scroll jumps */ |
| 75 | int jump_scroll; /* 0=off, 1=once, ..., JUMP_SCROLL_ALWAYS */ |
| 76 | #endif |
| 77 | #if defined(HAVE_LCD_BITMAP) || defined(HAVE_REMOTE_LCD) |
| 78 | int step; /* pixels per scroll step */ |
| 79 | #endif |
| 80 | #if defined(HAVE_REMOTE_LCD) |
| 81 | long last_scroll; |
| 82 | #endif |
| 83 | }; |
| 84 | |
| 85 | /** main lcd **/ |
| 86 | #ifdef HAVE_LCD_BITMAP |
| 87 | #define LCD_SCROLLABLE_LINES ((LCD_HEIGHT+4)/5 < 32 ? (LCD_HEIGHT+4)/5 : 32) |
| 88 | #else |
Dave Chapman | 945c8a2 | 2008-01-07 20:34:11 +0000 | [diff] [blame] | 89 | #define LCD_SCROLLABLE_LINES LCD_HEIGHT * 2 |
Michael Sevakis | 58fc279 | 2007-07-28 08:12:05 +0000 | [diff] [blame] | 90 | #endif |
| 91 | |
| 92 | extern struct scroll_screen_info lcd_scroll_info; |
| 93 | |
| 94 | /** remote lcd **/ |
| 95 | #ifdef HAVE_REMOTE_LCD |
| 96 | #define LCD_REMOTE_SCROLLABLE_LINES \ |
| 97 | (((LCD_REMOTE_HEIGHT+4)/5 < 32) ? (LCD_REMOTE_HEIGHT+4)/5 : 32) |
| 98 | extern struct scroll_screen_info lcd_remote_scroll_info; |
| 99 | #endif |
| 100 | |
| 101 | #endif /* __SCROLL_ENGINE_H__ */ |