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/drivers | |
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/drivers')
-rw-r--r-- | firmware/drivers/lcd-scroll.c | 127 |
1 files changed, 127 insertions, 0 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 | |||
33 | static struct scrollinfo LCDFN(scroll)[LCD_SCROLLABLE_LINES]; | ||
34 | |||
35 | struct 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 | |||
52 | void 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 */ | ||
58 | void 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 */ | ||
90 | void LCDFN(scroll_stop_viewport)(const struct viewport *current_vp) | ||
91 | { | ||
92 | LCDFN(scroll_stop_viewport_line)(current_vp, -1); | ||
93 | } | ||
94 | |||
95 | void LCDFN(scroll_speed)(int speed) | ||
96 | { | ||
97 | LCDFN(scroll_info).ticks = scroll_tick_table[speed]; | ||
98 | } | ||
99 | |||
100 | #if defined(HAVE_LCD_BITMAP) | ||
101 | void LCDFN(scroll_step)(int step) | ||
102 | { | ||
103 | LCDFN(scroll_info).step = step; | ||
104 | } | ||
105 | #endif | ||
106 | |||
107 | void LCDFN(scroll_delay)(int ms) | ||
108 | { | ||
109 | LCDFN(scroll_info).delay = ms / (HZ / 10); | ||
110 | } | ||
111 | |||
112 | void LCDFN(bidir_scroll)(int percent) | ||
113 | { | ||
114 | LCDFN(scroll_info).bidir_limit = percent; | ||
115 | } | ||
116 | |||
117 | #ifdef HAVE_LCD_CHARCELLS | ||
118 | void LCDFN(jump_scroll)(int mode) /* 0=off, 1=once, ..., JUMP_SCROLL_ALWAYS */ | ||
119 | { | ||
120 | LCDFN(scroll_info).jump_scroll = mode; | ||
121 | } | ||
122 | |||
123 | void LCDFN(jump_scroll_delay)(int ms) | ||
124 | { | ||
125 | LCDFN(scroll_info).jump_scroll_delay = ms / (HZ / 10); | ||
126 | } | ||
127 | #endif | ||