diff options
author | Daniel Stenberg <daniel@haxx.se> | 2002-04-11 12:39:50 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2002-04-11 12:39:50 +0000 |
commit | eb2072507dd51c634ab7abef2c25bc61161e08fd (patch) | |
tree | 4b10b6ad411c78fad5091d63cd4968c8ddf12218 /uisimulator/lcd.c | |
parent | 2101b9bd4185835d4a70d92233c1762bf3722cde (diff) | |
download | rockbox-eb2072507dd51c634ab7abef2c25bc61161e08fd.tar.gz rockbox-eb2072507dd51c634ab7abef2c25bc61161e08fd.zip |
use live, actual firmware code instead
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@79 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'uisimulator/lcd.c')
-rw-r--r-- | uisimulator/lcd.c | 269 |
1 files changed, 0 insertions, 269 deletions
diff --git a/uisimulator/lcd.c b/uisimulator/lcd.c deleted file mode 100644 index 294302c9ac..0000000000 --- a/uisimulator/lcd.c +++ /dev/null | |||
@@ -1,269 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Daniel Stenberg <daniel@haxx.se> | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | /* | ||
21 | * This file is meant for generic LCD defines and global variables etc. | ||
22 | */ | ||
23 | |||
24 | #include "lcd.h" | ||
25 | #ifdef LCD_DEBUG | ||
26 | #include <stdio.h> | ||
27 | |||
28 | #define PRINT(x) printf x | ||
29 | #else | ||
30 | #define PRINT(x) | ||
31 | #endif | ||
32 | |||
33 | |||
34 | #define DISP_X LCD_WIDTH /* Display width in pixels */ | ||
35 | #define DISP_Y LCD_HEIGHT /* Display height in pixels */ | ||
36 | |||
37 | #define CHAR_X 6 /* Character width in pixels */ | ||
38 | #define CHAR_Y 8 /* Character height in pixels */ | ||
39 | #define COL_MASK 0xff /* Character column pixels changed */ | ||
40 | |||
41 | /* | ||
42 | * ASCII character generation table | ||
43 | * | ||
44 | * This contains only the printable characters (0x20-0x7f). | ||
45 | * Each row in this table is a 5x8 pixel character pattern. | ||
46 | * Each byte is a column of pixels, with the top pixel in the LSB. | ||
47 | */ | ||
48 | #define ASCII_MIN 0x20 /* First char in table */ | ||
49 | #define ASCII_MAX 0x7f /* Last char in table */ | ||
50 | |||
51 | static const unsigned char lcd_font_data[ASCII_MAX-ASCII_MIN+1][CHAR_X-1] = | ||
52 | { | ||
53 | 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x2f */ | ||
54 | 0x00, 0x00, 0x4f, 0x00, 0x00, | ||
55 | 0x00, 0x07, 0x00, 0x07, 0x00, | ||
56 | 0x14, 0x7f, 0x14, 0x7f, 0x14, | ||
57 | 0x24, 0x2a, 0x7f, 0x2a, 0x12, | ||
58 | 0x23, 0x13, 0x08, 0x64, 0x62, | ||
59 | 0x36, 0x49, 0x55, 0x22, 0x50, | ||
60 | 0x00, 0x05, 0x03, 0x00, 0x00, | ||
61 | 0x00, 0x1c, 0x22, 0x41, 0x00, | ||
62 | 0x00, 0x41, 0x22, 0x1c, 0x00, | ||
63 | 0x14, 0x08, 0x3e, 0x08, 0x14, | ||
64 | 0x08, 0x08, 0x3e, 0x08, 0x08, | ||
65 | 0x00, 0xa0, 0x60, 0x00, 0x00, | ||
66 | 0x08, 0x08, 0x08, 0x08, 0x08, | ||
67 | 0x00, 0x60, 0x60, 0x00, 0x00, | ||
68 | 0x20, 0x10, 0x08, 0x04, 0x02, | ||
69 | |||
70 | 0x3e, 0x51, 0x49, 0x45, 0x3e, /* 0x30-0x3f */ | ||
71 | 0x00, 0x42, 0x7f, 0x40, 0x00, | ||
72 | 0x42, 0x61, 0x51, 0x49, 0x46, | ||
73 | 0x21, 0x41, 0x45, 0x4b, 0x31, | ||
74 | 0x18, 0x14, 0x12, 0x7f, 0x10, | ||
75 | 0x27, 0x45, 0x45, 0x45, 0x39, | ||
76 | 0x3c, 0x4a, 0x49, 0x49, 0x30, | ||
77 | 0x01, 0x71, 0x09, 0x05, 0x03, | ||
78 | 0x36, 0x49, 0x49, 0x49, 0x36, | ||
79 | 0x06, 0x49, 0x49, 0x29, 0x1e, | ||
80 | 0x00, 0x6c, 0x6c, 0x00, 0x00, | ||
81 | 0x00, 0xac, 0x6c, 0x00, 0x00, | ||
82 | 0x08, 0x14, 0x22, 0x41, 0x00, | ||
83 | 0x14, 0x14, 0x14, 0x14, 0x14, | ||
84 | 0x00, 0x41, 0x22, 0x14, 0x08, | ||
85 | 0x02, 0x01, 0x51, 0x09, 0x06, | ||
86 | |||
87 | 0x32, 0x49, 0x79, 0x41, 0x3e, /* 0x40-0x4f */ | ||
88 | 0x7e, 0x11, 0x11, 0x11, 0x7e, | ||
89 | 0x7f, 0x49, 0x49, 0x49, 0x36, | ||
90 | 0x3e, 0x41, 0x41, 0x41, 0x22, | ||
91 | 0x7f, 0x41, 0x41, 0x22, 0x1c, | ||
92 | 0x7f, 0x49, 0x49, 0x49, 0x41, | ||
93 | 0x7f, 0x09, 0x09, 0x09, 0x01, | ||
94 | 0x3e, 0x41, 0x49, 0x49, 0x7a, | ||
95 | 0x7f, 0x08, 0x08, 0x08, 0x7f, | ||
96 | 0x00, 0x41, 0x7f, 0x41, 0x00, | ||
97 | 0x20, 0x40, 0x41, 0x3f, 0x01, | ||
98 | 0x7f, 0x08, 0x14, 0x22, 0x41, | ||
99 | 0x7f, 0x40, 0x40, 0x40, 0x40, | ||
100 | 0x7f, 0x02, 0x0c, 0x02, 0x7f, | ||
101 | 0x7f, 0x04, 0x08, 0x10, 0x7f, | ||
102 | 0x3e, 0x41, 0x41, 0x41, 0x3e, | ||
103 | |||
104 | 0x7f, 0x09, 0x09, 0x09, 0x06, /* 0x50-0x5f */ | ||
105 | 0x3e, 0x41, 0x51, 0x21, 0x5e, | ||
106 | 0x7f, 0x09, 0x19, 0x29, 0x46, | ||
107 | 0x46, 0x49, 0x49, 0x49, 0x31, | ||
108 | 0x01, 0x01, 0x7f, 0x01, 0x01, | ||
109 | 0x3f, 0x40, 0x40, 0x40, 0x3f, | ||
110 | 0x1f, 0x20, 0x40, 0x20, 0x1f, | ||
111 | 0x3f, 0x40, 0x38, 0x40, 0x3f, | ||
112 | 0x63, 0x14, 0x08, 0x14, 0x63, | ||
113 | 0x07, 0x08, 0x70, 0x08, 0x07, | ||
114 | 0x71, 0x51, 0x49, 0x45, 0x43, | ||
115 | 0x00, 0x7f, 0x41, 0x41, 0x00, | ||
116 | 0x02, 0x04, 0x08, 0x10, 0x20, | ||
117 | 0x00, 0x41, 0x41, 0x7f, 0x00, | ||
118 | 0x04, 0x02, 0x01, 0x02, 0x04, | ||
119 | 0x40, 0x40, 0x40, 0x40, 0x40, | ||
120 | |||
121 | 0x00, 0x01, 0x02, 0x04, 0x00, /* 0x60-0x6f */ | ||
122 | 0x20, 0x54, 0x54, 0x54, 0x78, | ||
123 | 0x7f, 0x48, 0x44, 0x44, 0x38, | ||
124 | 0x38, 0x44, 0x44, 0x44, 0x20, | ||
125 | 0x38, 0x44, 0x44, 0x48, 0x7f, | ||
126 | 0x38, 0x54, 0x54, 0x54, 0x18, | ||
127 | 0x08, 0x7e, 0x09, 0x01, 0x02, | ||
128 | 0x18, 0xa4, 0xa4, 0xa4, 0x7c, | ||
129 | 0x7f, 0x08, 0x04, 0x04, 0x78, | ||
130 | 0x00, 0x44, 0x7d, 0x40, 0x00, | ||
131 | 0x40, 0x80, 0x84, 0x7d, 0x00, | ||
132 | 0x7f, 0x10, 0x28, 0x44, 0x00, | ||
133 | 0x00, 0x41, 0x7f, 0x40, 0x00, | ||
134 | 0x7c, 0x04, 0x18, 0x04, 0x78, | ||
135 | 0x7c, 0x08, 0x04, 0x04, 0x78, | ||
136 | 0x38, 0x44, 0x44, 0x44, 0x38, | ||
137 | |||
138 | 0xfc, 0x24, 0x24, 0x24, 0x18, /* 0x70-0x7f */ | ||
139 | 0x18, 0x24, 0x24, 0x24, 0xfc, | ||
140 | 0x7c, 0x08, 0x04, 0x04, 0x08, | ||
141 | 0x48, 0x54, 0x54, 0x54, 0x20, | ||
142 | 0x04, 0x3f, 0x44, 0x40, 0x20, | ||
143 | 0x3c, 0x40, 0x40, 0x20, 0x7c, | ||
144 | 0x1c, 0x20, 0x40, 0x20, 0x1c, | ||
145 | 0x3c, 0x40, 0x30, 0x40, 0x3c, | ||
146 | 0x44, 0x28, 0x10, 0x28, 0x44, | ||
147 | 0x1c, 0xa0, 0xa0, 0xa0, 0x7c, | ||
148 | 0x44, 0x64, 0x54, 0x4c, 0x44, | ||
149 | 0x00, 0x08, 0x36, 0x41, 0x00, | ||
150 | 0x00, 0x00, 0x7f, 0x00, 0x00, | ||
151 | 0x00, 0x41, 0x36, 0x08, 0x00, | ||
152 | 0x04, 0x02, 0x04, 0x08, 0x04, | ||
153 | 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, | ||
154 | }; | ||
155 | |||
156 | /* | ||
157 | * Memory copy of display bitmap | ||
158 | * | ||
159 | * This has the same format as the Recorder hardware: | ||
160 | * Bits within a byte are arranged veritcally, LSB at top. | ||
161 | * Byte 0 is top left, byte 1 is 2nd left, byte DISP_X starts 2nd row. | ||
162 | */ | ||
163 | unsigned char display[LCD_HEIGHT/8][LCD_WIDTH]; | ||
164 | |||
165 | static int lcd_y; /* Current pixel row */ | ||
166 | static int lcd_x; /* Current pixel column */ | ||
167 | |||
168 | /* | ||
169 | * Set current x,y position | ||
170 | */ | ||
171 | void lcd_position(int x, int y) | ||
172 | { | ||
173 | if (x >= 0 && x < DISP_X && y >= 0 && y < DISP_Y) { | ||
174 | lcd_x = x; | ||
175 | lcd_y = y; | ||
176 | PRINT(("lcd_position: set to %d, %d\n", x, y)); | ||
177 | } | ||
178 | else | ||
179 | PRINT(("lcd_position: not set\n")); | ||
180 | |||
181 | |||
182 | } | ||
183 | |||
184 | /* | ||
185 | * Clear the display | ||
186 | */ | ||
187 | void lcd_clear(void) | ||
188 | { | ||
189 | lcd_x = 0; | ||
190 | lcd_y = 0; | ||
191 | memset (display, 0, sizeof display); | ||
192 | } | ||
193 | |||
194 | /* | ||
195 | * Display a character at current position. | ||
196 | * This writes a 5x8 character within a 6x8 cell. | ||
197 | * The cell does not have to be aligned to a display byte. | ||
198 | * The top left of the cell is displayed at the current position. | ||
199 | * invert is TRUE to display in reverse video. | ||
200 | */ | ||
201 | void lcd_char (int ch, char invert) | ||
202 | { | ||
203 | unsigned char yrow = lcd_y/8; | ||
204 | unsigned char (*dp)[LCD_WIDTH] = &display[yrow][lcd_x]; | ||
205 | unsigned char shift, mask, col; | ||
206 | |||
207 | PRINT(("lcd_char: output %c (%02x) at %d, %d (yrow %d)\n", | ||
208 | ch, ch, lcd_x, lcd_y, yrow)); | ||
209 | |||
210 | /* Limit to char generation table */ | ||
211 | if (ch < ASCII_MIN || ch > ASCII_MAX) | ||
212 | ch = ASCII_MAX; | ||
213 | |||
214 | /* Calculate shift and masks for cell bit position */ | ||
215 | shift = (lcd_y & 0x7); | ||
216 | mask = ~(COL_MASK << shift); | ||
217 | if (invert) | ||
218 | invert = ~mask; | ||
219 | |||
220 | /* Write each char column */ | ||
221 | for (col = 0; col < CHAR_X-1; col++) { | ||
222 | unsigned long data = (lcd_font_data[ch-ASCII_MIN][col] << shift) ^ invert; | ||
223 | |||
224 | PRINT(("OR[0]: %02x on x %d y %d \n", data&0xff, col+lcd_x, yrow)); | ||
225 | |||
226 | dp[0][col] = (dp[0][col] & mask) | data; | ||
227 | if (lcd_y < DISP_Y-8) { | ||
228 | PRINT(("OR[1]: %02x on x %d y %d\n", (data>>8), col+lcd_x, yrow+1)); | ||
229 | dp[1][col] = (dp[1][col] & (mask >> 8)) | (data >> 8); | ||
230 | } | ||
231 | } | ||
232 | |||
233 | /* Column after char */ | ||
234 | dp[0][CHAR_X-1] = (dp[0][CHAR_X-1] & mask) | invert; | ||
235 | if (lcd_y < DISP_Y-8) | ||
236 | dp[1][CHAR_X-1] = (dp[1][CHAR_X-1] & (mask >> 8)) | (invert >> 8); | ||
237 | } | ||
238 | |||
239 | /* | ||
240 | * Output a string at current position | ||
241 | */ | ||
242 | void lcd_string(const char *text, char invert) | ||
243 | { | ||
244 | int ch; | ||
245 | |||
246 | PRINT(("lcd_string: output %s at %d, %d\n", text, lcd_x, lcd_y)); | ||
247 | |||
248 | while ((ch = *text++) != '\0') { | ||
249 | if (lcd_y > DISP_Y-CHAR_Y) { | ||
250 | /* Scroll (8 pixels) */ | ||
251 | memcpy (display[0], display[1], DISP_X*(DISP_Y/8-1)); | ||
252 | lcd_y -= 8; | ||
253 | } | ||
254 | |||
255 | if (ch == '\n') | ||
256 | lcd_x = DISP_X; | ||
257 | else { | ||
258 | lcd_char (ch, invert); | ||
259 | lcd_x += CHAR_X; | ||
260 | |||
261 | if (lcd_x > DISP_X-CHAR_X) { | ||
262 | /* Wrap to next line */ | ||
263 | lcd_x = 0; | ||
264 | lcd_y += CHAR_Y; | ||
265 | } | ||
266 | } | ||
267 | } | ||
268 | PRINT(("lcd_string: position after write: %d, %d\n", lcd_x, lcd_y)); | ||
269 | } | ||