diff options
author | Thomas Martitz <kugel@rockbox.org> | 2013-04-04 07:12:10 +0200 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2013-12-14 23:11:30 +0100 |
commit | b094d80dab4f7ac501172d0412e9e53289ede27b (patch) | |
tree | 797ed5c9103e292bf9c9912281d4e124dd6c7421 /firmware/scroll_engine.c | |
parent | 1c5d0b41eebdb4f8c627b1a0e5f7b699f0b08fb8 (diff) | |
download | rockbox-b094d80dab4f7ac501172d0412e9e53289ede27b.tar.gz rockbox-b094d80dab4f7ac501172d0412e9e53289ede27b.zip |
scroll_engine: Split out common main and remote lcd functions.
Uses a similar technique as lcd_*.c files of #including a common .c file, so
that a unified implementation can be reused for both displays.
Change-Id: I21f6de76df757b093e1a1dff0a4caf96a44fe77e
Diffstat (limited to 'firmware/scroll_engine.c')
-rw-r--r-- | firmware/scroll_engine.c | 181 |
1 files changed, 10 insertions, 171 deletions
diff --git a/firmware/scroll_engine.c b/firmware/scroll_engine.c index 82af26afa8..d134f7b2ce 100644 --- a/firmware/scroll_engine.c +++ b/firmware/scroll_engine.c | |||
@@ -9,7 +9,7 @@ | |||
9 | * | 9 | * |
10 | * Copyright (C) 2007 by Michael Sevakis | 10 | * Copyright (C) 2007 by Michael Sevakis |
11 | * | 11 | * |
12 | * LCD scrolling driver and scheduler | 12 | * LCD scrolling thread and scheduler |
13 | * | 13 | * |
14 | * Much collected and combined from the various Rockbox LCD drivers. | 14 | * Much collected and combined from the various Rockbox LCD drivers. |
15 | * | 15 | * |
@@ -22,6 +22,7 @@ | |||
22 | * KIND, either express or implied. | 22 | * KIND, either express or implied. |
23 | * | 23 | * |
24 | ****************************************************************************/ | 24 | ****************************************************************************/ |
25 | |||
25 | #include "config.h" | 26 | #include "config.h" |
26 | #include "gcc_extensions.h" | 27 | #include "gcc_extensions.h" |
27 | #include "cpu.h" | 28 | #include "cpu.h" |
@@ -49,181 +50,19 @@ static void scroll_thread(void); | |||
49 | static char scroll_stack[DEFAULT_STACK_SIZE*3]; | 50 | static char scroll_stack[DEFAULT_STACK_SIZE*3]; |
50 | static const char scroll_name[] = "scroll"; | 51 | static const char scroll_name[] = "scroll"; |
51 | 52 | ||
52 | static struct scrollinfo lcd_scroll[LCD_SCROLLABLE_LINES]; | 53 | #include "drivers/lcd-scroll.c" |
53 | 54 | ||
54 | #ifdef HAVE_REMOTE_LCD | 55 | #ifdef HAVE_REMOTE_LCD |
55 | static struct scrollinfo lcd_remote_scroll[LCD_REMOTE_SCROLLABLE_LINES]; | ||
56 | static struct event_queue scroll_queue SHAREDBSS_ATTR; | 56 | static struct event_queue scroll_queue SHAREDBSS_ATTR; |
57 | #endif | ||
58 | |||
59 | struct scroll_screen_info lcd_scroll_info = | ||
60 | { | ||
61 | .scroll = lcd_scroll, | ||
62 | .lines = 0, | ||
63 | .ticks = 12, | ||
64 | .delay = HZ/2, | ||
65 | .bidir_limit = 50, | ||
66 | #ifdef HAVE_LCD_BITMAP | ||
67 | .step = 6, | ||
68 | #endif | ||
69 | #ifdef HAVE_LCD_CHARCELLS | ||
70 | .jump_scroll_delay = HZ/4, | ||
71 | .jump_scroll = 0, | ||
72 | #endif | ||
73 | }; | ||
74 | |||
75 | #ifdef HAVE_REMOTE_LCD | ||
76 | struct scroll_screen_info lcd_remote_scroll_info = | ||
77 | { | ||
78 | .scroll = lcd_remote_scroll, | ||
79 | .lines = 0, | ||
80 | .ticks = 12, | ||
81 | .delay = HZ/2, | ||
82 | .bidir_limit = 50, | ||
83 | .step = 6, | ||
84 | }; | ||
85 | #endif /* HAVE_REMOTE_LCD */ | ||
86 | |||
87 | void lcd_scroll_stop(void) | ||
88 | { | ||
89 | lcd_scroll_info.lines = 0; | ||
90 | } | ||
91 | |||
92 | /* Stop scrolling line y in the specified viewport, or all lines if y < 0 */ | ||
93 | void lcd_scroll_stop_viewport_line(const struct viewport *current_vp, int line) | ||
94 | { | ||
95 | int i = 0; | ||
96 | |||
97 | while (i < lcd_scroll_info.lines) | ||
98 | { | ||
99 | struct viewport *vp = lcd_scroll_info.scroll[i].vp; | ||
100 | if (((vp == current_vp)) && | ||
101 | ((line < 0) || (lcd_scroll_info.scroll[i].y == line))) | ||
102 | { | ||
103 | /* If i is not the last active line in the array, then move | ||
104 | the last item to position i */ | ||
105 | if ((i + 1) != lcd_scroll_info.lines) | ||
106 | { | ||
107 | lcd_scroll_info.scroll[i] = | ||
108 | lcd_scroll_info.scroll[lcd_scroll_info.lines-1]; | ||
109 | } | ||
110 | lcd_scroll_info.lines--; | ||
111 | 57 | ||
112 | /* A line can only appear once, so we're done, | 58 | /* copied from lcd-remote-1bit.c */ |
113 | * unless we are clearing the whole viewport */ | 59 | /* Compile 1 bit vertical packing LCD driver for remote LCD */ |
114 | if (line >= 0) | 60 | #undef LCDFN |
115 | return ; | 61 | #define LCDFN(fn) lcd_remote_ ## fn |
116 | } | 62 | #undef LCDM |
117 | else | 63 | #define LCDM(ma) LCD_REMOTE_ ## ma |
118 | { | ||
119 | i++; | ||
120 | } | ||
121 | } | ||
122 | } | ||
123 | |||
124 | /* Stop all scrolling lines in the specified viewport */ | ||
125 | void lcd_scroll_stop_viewport(const struct viewport *current_vp) | ||
126 | { | ||
127 | lcd_scroll_stop_viewport_line(current_vp, -1); | ||
128 | } | ||
129 | |||
130 | void lcd_scroll_speed(int speed) | ||
131 | { | ||
132 | lcd_scroll_info.ticks = scroll_tick_table[speed]; | ||
133 | } | ||
134 | |||
135 | #if defined(HAVE_LCD_BITMAP) | ||
136 | void lcd_scroll_step(int step) | ||
137 | { | ||
138 | lcd_scroll_info.step = step; | ||
139 | } | ||
140 | #endif | ||
141 | 64 | ||
142 | void lcd_scroll_delay(int ms) | 65 | #include "drivers/lcd-scroll.c" |
143 | { | ||
144 | lcd_scroll_info.delay = ms / (HZ / 10); | ||
145 | } | ||
146 | |||
147 | void lcd_bidir_scroll(int percent) | ||
148 | { | ||
149 | lcd_scroll_info.bidir_limit = percent; | ||
150 | } | ||
151 | |||
152 | #ifdef HAVE_LCD_CHARCELLS | ||
153 | void lcd_jump_scroll(int mode) /* 0=off, 1=once, ..., JUMP_SCROLL_ALWAYS */ | ||
154 | { | ||
155 | lcd_scroll_info.jump_scroll = mode; | ||
156 | } | ||
157 | |||
158 | void lcd_jump_scroll_delay(int ms) | ||
159 | { | ||
160 | lcd_scroll_info.jump_scroll_delay = ms / (HZ / 10); | ||
161 | } | ||
162 | #endif | ||
163 | |||
164 | #ifdef HAVE_REMOTE_LCD | ||
165 | void lcd_remote_scroll_stop(void) | ||
166 | { | ||
167 | lcd_remote_scroll_info.lines = 0; | ||
168 | } | ||
169 | |||
170 | /* Stop scrolling line y in the specified viewport, or all lines if y < 0 */ | ||
171 | void lcd_remote_scroll_stop_viewport_line(const struct viewport *current_vp, int line) | ||
172 | { | ||
173 | int i = 0; | ||
174 | |||
175 | while (i < lcd_scroll_info.lines) | ||
176 | { | ||
177 | struct viewport *vp = lcd_remote_scroll_info.scroll[i].vp; | ||
178 | if (((vp == current_vp)) && | ||
179 | ((line < 0) || (lcd_remote_scroll_info.scroll[i].y == line))) | ||
180 | { | ||
181 | /* If i is not the last active line in the array, then move | ||
182 | the last item to position i */ | ||
183 | if ((i + 1) != lcd_remote_scroll_info.lines) | ||
184 | { | ||
185 | lcd_remote_scroll_info.scroll[i] = | ||
186 | lcd_remote_scroll_info.scroll[lcd_remote_scroll_info.lines-1]; | ||
187 | } | ||
188 | lcd_remote_scroll_info.lines--; | ||
189 | |||
190 | /* A line can only appear once, so we're done, | ||
191 | * unless we are clearing the whole viewport */ | ||
192 | if (line >= 0) | ||
193 | return ; | ||
194 | } | ||
195 | else | ||
196 | { | ||
197 | i++; | ||
198 | } | ||
199 | } | ||
200 | } | ||
201 | |||
202 | /* Stop all scrolling lines in the specified viewport */ | ||
203 | void lcd_remote_scroll_stop_viewport(const struct viewport *current_vp) | ||
204 | { | ||
205 | lcd_remote_scroll_stop_viewport_line(current_vp, -1); | ||
206 | } | ||
207 | |||
208 | void lcd_remote_scroll_speed(int speed) | ||
209 | { | ||
210 | lcd_remote_scroll_info.ticks = scroll_tick_table[speed]; | ||
211 | } | ||
212 | |||
213 | void lcd_remote_scroll_step(int step) | ||
214 | { | ||
215 | lcd_remote_scroll_info.step = step; | ||
216 | } | ||
217 | |||
218 | void lcd_remote_scroll_delay(int ms) | ||
219 | { | ||
220 | lcd_remote_scroll_info.delay = ms / (HZ / 10); | ||
221 | } | ||
222 | |||
223 | void lcd_remote_bidir_scroll(int percent) | ||
224 | { | ||
225 | lcd_remote_scroll_info.bidir_limit = percent; | ||
226 | } | ||
227 | 66 | ||
228 | static void sync_display_ticks(void) | 67 | static void sync_display_ticks(void) |
229 | { | 68 | { |