summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2013-04-04 07:12:10 +0200
committerThomas Martitz <kugel@rockbox.org>2013-12-14 23:11:30 +0100
commitb094d80dab4f7ac501172d0412e9e53289ede27b (patch)
tree797ed5c9103e292bf9c9912281d4e124dd6c7421
parent1c5d0b41eebdb4f8c627b1a0e5f7b699f0b08fb8 (diff)
downloadrockbox-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
-rw-r--r--firmware/drivers/lcd-scroll.c127
-rw-r--r--firmware/scroll_engine.c181
2 files changed, 137 insertions, 171 deletions
diff --git a/firmware/drivers/lcd-scroll.c b/firmware/drivers/lcd-scroll.c
new file mode 100644
index 0000000000..ffd4663c79
--- /dev/null
+++ b/firmware/drivers/lcd-scroll.c
@@ -0,0 +1,127 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Michael Sevakis
11 *
12 * LCD scroll control functions (API to apps).
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
18 *
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
21 *
22 ****************************************************************************/
23
24/* This file is meant to be #included by scroll_engine.c (twice if a remote
25 * is present) */
26
27#ifndef LCDFN /* Not compiling for remote - define macros for main LCD. */
28#define LCDFN(fn) lcd_ ## fn
29#define LCDM(ma) LCD_ ## ma
30#define MAIN_LCD
31#endif
32
33static struct scrollinfo LCDFN(scroll)[LCD_SCROLLABLE_LINES];
34
35struct scroll_screen_info LCDFN(scroll_info) =
36{
37 .scroll = LCDFN(scroll),
38 .lines = 0,
39 .ticks = 12,
40 .delay = HZ/2,
41 .bidir_limit = 50,
42#ifdef HAVE_LCD_BITMAP
43 .step = 6,
44#endif
45#ifdef HAVE_LCD_CHARCELLS
46 .jump_scroll_delay = HZ/4,
47 .jump_scroll = 0,
48#endif
49};
50
51
52void LCDFN(scroll_stop)(void)
53{
54 LCDFN(scroll_info).lines = 0;
55}
56
57/* Stop scrolling line y in the specified viewport, or all lines if y < 0 */
58void LCDFN(scroll_stop_viewport_line)(const struct viewport *current_vp, int line)
59{
60 int i = 0;
61
62 while (i < LCDFN(scroll_info).lines)
63 {
64 struct viewport *vp = LCDFN(scroll_info).scroll[i].vp;
65 if (((vp == current_vp)) &&
66 ((line < 0) || (LCDFN(scroll_info).scroll[i].y == line)))
67 {
68 /* If i is not the last active line in the array, then move
69 the last item to position i */
70 if ((i + 1) != LCDFN(scroll_info).lines)
71 {
72 LCDFN(scroll_info).scroll[i] =
73 LCDFN(scroll_info).scroll[LCDFN(scroll_info).lines-1];
74 }
75 LCDFN(scroll_info).lines--;
76
77 /* A line can only appear once, so we're done,
78 * unless we are clearing the whole viewport */
79 if (line >= 0)
80 return ;
81 }
82 else
83 {
84 i++;
85 }
86 }
87}
88
89/* Stop all scrolling lines in the specified viewport */
90void LCDFN(scroll_stop_viewport)(const struct viewport *current_vp)
91{
92 LCDFN(scroll_stop_viewport_line)(current_vp, -1);
93}
94
95void LCDFN(scroll_speed)(int speed)
96{
97 LCDFN(scroll_info).ticks = scroll_tick_table[speed];
98}
99
100#if defined(HAVE_LCD_BITMAP)
101void LCDFN(scroll_step)(int step)
102{
103 LCDFN(scroll_info).step = step;
104}
105#endif
106
107void LCDFN(scroll_delay)(int ms)
108{
109 LCDFN(scroll_info).delay = ms / (HZ / 10);
110}
111
112void LCDFN(bidir_scroll)(int percent)
113{
114 LCDFN(scroll_info).bidir_limit = percent;
115}
116
117#ifdef HAVE_LCD_CHARCELLS
118void LCDFN(jump_scroll)(int mode) /* 0=off, 1=once, ..., JUMP_SCROLL_ALWAYS */
119{
120 LCDFN(scroll_info).jump_scroll = mode;
121}
122
123void LCDFN(jump_scroll_delay)(int ms)
124{
125 LCDFN(scroll_info).jump_scroll_delay = ms / (HZ / 10);
126}
127#endif
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);
49static char scroll_stack[DEFAULT_STACK_SIZE*3]; 50static char scroll_stack[DEFAULT_STACK_SIZE*3];
50static const char scroll_name[] = "scroll"; 51static const char scroll_name[] = "scroll";
51 52
52static 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
55static struct scrollinfo lcd_remote_scroll[LCD_REMOTE_SCROLLABLE_LINES];
56static struct event_queue scroll_queue SHAREDBSS_ATTR; 56static struct event_queue scroll_queue SHAREDBSS_ATTR;
57#endif
58
59struct 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
76struct 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
87void 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 */
93void 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 */
125void lcd_scroll_stop_viewport(const struct viewport *current_vp)
126{
127 lcd_scroll_stop_viewport_line(current_vp, -1);
128}
129
130void lcd_scroll_speed(int speed)
131{
132 lcd_scroll_info.ticks = scroll_tick_table[speed];
133}
134
135#if defined(HAVE_LCD_BITMAP)
136void lcd_scroll_step(int step)
137{
138 lcd_scroll_info.step = step;
139}
140#endif
141 64
142void lcd_scroll_delay(int ms) 65#include "drivers/lcd-scroll.c"
143{
144 lcd_scroll_info.delay = ms / (HZ / 10);
145}
146
147void lcd_bidir_scroll(int percent)
148{
149 lcd_scroll_info.bidir_limit = percent;
150}
151
152#ifdef HAVE_LCD_CHARCELLS
153void lcd_jump_scroll(int mode) /* 0=off, 1=once, ..., JUMP_SCROLL_ALWAYS */
154{
155 lcd_scroll_info.jump_scroll = mode;
156}
157
158void 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
165void 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 */
171void 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 */
203void lcd_remote_scroll_stop_viewport(const struct viewport *current_vp)
204{
205 lcd_remote_scroll_stop_viewport_line(current_vp, -1);
206}
207
208void lcd_remote_scroll_speed(int speed)
209{
210 lcd_remote_scroll_info.ticks = scroll_tick_table[speed];
211}
212
213void lcd_remote_scroll_step(int step)
214{
215 lcd_remote_scroll_info.step = step;
216}
217
218void lcd_remote_scroll_delay(int ms)
219{
220 lcd_remote_scroll_info.delay = ms / (HZ / 10);
221}
222
223void lcd_remote_bidir_scroll(int percent)
224{
225 lcd_remote_scroll_info.bidir_limit = percent;
226}
227 66
228static void sync_display_ticks(void) 67static void sync_display_ticks(void)
229{ 68{