diff options
author | Björn Stenberg <bjorn@haxx.se> | 2002-04-25 15:09:03 +0000 |
---|---|---|
committer | Björn Stenberg <bjorn@haxx.se> | 2002-04-25 15:09:03 +0000 |
commit | 29db1a9e720f8ca8ae497bee3c8022e91e86b235 (patch) | |
tree | 2f34a4210a2dc01421fd80ced9a17c2379ccdcfc /firmware/drivers/lcd.c | |
parent | 4fbea7cf8bc0326fa939568c866ba33c49ec5b80 (diff) | |
download | rockbox-29db1a9e720f8ca8ae497bee3c8022e91e86b235.tar.gz rockbox-29db1a9e720f8ca8ae497bee3c8022e91e86b235.zip |
Cleaned up lcd API
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@236 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/lcd.c')
-rw-r--r-- | firmware/drivers/lcd.c | 474 |
1 files changed, 210 insertions, 264 deletions
diff --git a/firmware/drivers/lcd.c b/firmware/drivers/lcd.c index 868883ef0a..ab862e9dfb 100644 --- a/firmware/drivers/lcd.c +++ b/firmware/drivers/lcd.c | |||
@@ -20,6 +20,8 @@ | |||
20 | #include "config.h" | 20 | #include "config.h" |
21 | #include "lcd.h" | 21 | #include "lcd.h" |
22 | 22 | ||
23 | /*** definitions ***/ | ||
24 | |||
23 | #define LCDR (PBDR+1) | 25 | #define LCDR (PBDR+1) |
24 | 26 | ||
25 | /* PA14 : /LCD-BL --- backlight */ | 27 | /* PA14 : /LCD-BL --- backlight */ |
@@ -31,7 +33,7 @@ | |||
31 | #define LCD_CS 2 // PB1 = 1 --- 0010 --- /LCD-CS | 33 | #define LCD_CS 2 // PB1 = 1 --- 0010 --- /LCD-CS |
32 | #define LCD_SD 4 // PB2 = 1 --- 0100 --- LCD-SD | 34 | #define LCD_SD 4 // PB2 = 1 --- 0100 --- LCD-SD |
33 | #define LCD_SC 8 // PB3 = 1 --- 1000 --- LCD-SC | 35 | #define LCD_SC 8 // PB3 = 1 --- 1000 --- LCD-SC |
34 | #ifndef JBP_OLD | 36 | #ifdef HAVE_NEW_CHARCELL_LCD |
35 | # define LCD_CONTRAST_SET ((char)0x50) | 37 | # define LCD_CONTRAST_SET ((char)0x50) |
36 | # define LCD_CRAM ((char)0x80) /* Characters */ | 38 | # define LCD_CRAM ((char)0x80) /* Characters */ |
37 | # define LCD_PRAM ((char)0xC0) /* Patterns */ | 39 | # define LCD_PRAM ((char)0xC0) /* Patterns */ |
@@ -46,6 +48,56 @@ | |||
46 | #define LCD_CURSOR(x,y) ((char)(LCD_CRAM+((y)*16+(x)))) | 48 | #define LCD_CURSOR(x,y) ((char)(LCD_CRAM+((y)*16+(x)))) |
47 | #define LCD_ICON(i) ((char)(LCD_IRAM+i)) | 49 | #define LCD_ICON(i) ((char)(LCD_IRAM+i)) |
48 | 50 | ||
51 | #elif HAVE_LCD_BITMAP | ||
52 | |||
53 | #define LCD_SD 1 // PB0 = 1 --- 0001 | ||
54 | #define LCD_SC 2 // PB1 = 1 --- 0010 | ||
55 | #define LCD_RS 4 // PB2 = 1 --- 0100 | ||
56 | #define LCD_CS 8 // PB3 = 1 --- 1000 | ||
57 | #define LCD_DS LCD_RS | ||
58 | |||
59 | #define LCD_SET_LOWER_COLUMN_ADDRESS ((char)0x00) | ||
60 | #define LCD_SET_HIGHER_COLUMN_ADDRESS ((char)0x10) | ||
61 | #define LCD_SET_INTERNAL_REGULATOR_RESISTOR_RATIO ((char)0x20) | ||
62 | #define LCD_SET_POWER_CONTROL_REGISTER ((char)0x28) | ||
63 | #define LCD_SET_DISPLAY_START_LINE ((char)0x40) | ||
64 | #define LCD_SET_CONTRAST_CONTROL_REGISTER ((char)0x81) | ||
65 | #define LCD_SET_SEGMENT_REMAP ((char)0xA0) | ||
66 | #define LCD_SET_LCD_BIAS ((char)0xA2) | ||
67 | #define LCD_SET_ENTIRE_DISPLAY_OFF ((char)0xA4) | ||
68 | #define LCD_SET_ENTIRE_DISPLAY_ON ((char)0xA5) | ||
69 | #define LCD_SET_NORMAL_DISPLAY ((char)0xA6) | ||
70 | #define LCD_SET_REVERSE_DISPLAY ((char)0xA7) | ||
71 | #define LCD_SET_INDICATOR_OFF ((char)0xAC) | ||
72 | #define LCD_SET_INDICATOR_ON ((char)0xAD) | ||
73 | #define LCD_SET_DISPLAY_OFF ((char)0xAE) | ||
74 | #define LCD_SET_DISPLAY_ON ((char)0xAF) | ||
75 | #define LCD_SET_PAGE_ADDRESS ((char)0xB0) | ||
76 | #define LCD_SET_COM_OUTPUT_SCAN_DIRECTION ((char)0xC0) | ||
77 | #define LCD_SET_DISPLAY_OFFSET ((char)0xD3) | ||
78 | #define LCD_SET_READ_MODIFY_WRITE_MODE ((char)0xE0) | ||
79 | #define LCD_SOFTWARE_RESET ((char)0xE2) | ||
80 | #define LCD_NOP ((char)0xE3) | ||
81 | #define LCD_SET_END_OF_READ_MODIFY_WRITE_MODE ((char)0xEE) | ||
82 | |||
83 | /* LCD command codes */ | ||
84 | #define LCD_CNTL_RESET 0xe2 // Software reset | ||
85 | #define LCD_CNTL_POWER 0x2f // Power control | ||
86 | #define LCD_CNTL_CONTRAST 0x81 // Contrast | ||
87 | #define LCD_CNTL_OUTSCAN 0xc8 // Output scan direction | ||
88 | #define LCD_CNTL_SEGREMAP 0xa1 // Segment remap | ||
89 | #define LCD_CNTL_DISPON 0xaf // Display on | ||
90 | |||
91 | #define LCD_CNTL_PAGE 0xb0 // Page address | ||
92 | #define LCD_CNTL_HIGHCOL 0x10 // Upper column address | ||
93 | #define LCD_CNTL_LOWCOL 0x00 // Lower column address | ||
94 | |||
95 | |||
96 | #endif /* CHARCELL or BITMAP */ | ||
97 | |||
98 | |||
99 | /*** generic code ***/ | ||
100 | |||
49 | #ifndef SIMULATOR | 101 | #ifndef SIMULATOR |
50 | /* | 102 | /* |
51 | * About /CS,DS,SC,SD | 103 | * About /CS,DS,SC,SD |
@@ -94,58 +146,20 @@ | |||
94 | * | 146 | * |
95 | */ | 147 | */ |
96 | 148 | ||
97 | /* | 149 | |
98 | * Enter a LCD session : | 150 | |
99 | * | 151 | static void lcd_write(bool command, int byte) |
100 | * LCDR &= ~(LCD_CS|LCD_DS|LCD_SD|LCD_SC); | 152 | |
101 | */ | 153 | #ifdef ASM_IMPLEMENTATION |
102 | static void lcd_start (void) | ||
103 | { | 154 | { |
155 | lcd_start(); | ||
156 | |||
104 | asm("and.b %0, @(r0,gbr)" | 157 | asm("and.b %0, @(r0,gbr)" |
105 | : | 158 | : |
106 | : /* %0 */ "I"(~(LCD_CS|LCD_DS|LCD_SD|LCD_SC)), | 159 | : /* %0 */ "I"(~(LCD_CS|LCD_DS|LCD_SD|LCD_SC)), |
107 | /* %1 */ "z"(LCDR)); | 160 | /* %1 */ "z"(LCDR)); |
108 | } | ||
109 | 161 | ||
110 | /* | 162 | if (command) |
111 | * Leave a LCD session : | ||
112 | * | ||
113 | * LCDR |= LCD_CS|LCD_RS|LCD_SD|LCD_SC; | ||
114 | */ | ||
115 | static void lcd_stop (void) | ||
116 | { | ||
117 | asm | ||
118 | ("or.b\t%0,@(r0,gbr)" | ||
119 | : | ||
120 | : /* %0 */ "I"(LCD_CS|LCD_DS|LCD_SD|LCD_SC), | ||
121 | /* %1 */ "z"(LCDR)); | ||
122 | } | ||
123 | |||
124 | static void lcd_byte (int byte,bool data) | ||
125 | |||
126 | /* | ||
127 | * char j = 0x80; | ||
128 | * if (rs) | ||
129 | * do | ||
130 | * { | ||
131 | * LCDR &= ~(LCD_SC|LCD_SD); | ||
132 | * if (j & byte) | ||
133 | * LCDR |= LCD_SD; | ||
134 | * LCDR |= LCD_SC|LCD_DS; | ||
135 | * } | ||
136 | * while ((unsigned char)j >>= 1); | ||
137 | * else | ||
138 | * do | ||
139 | * { | ||
140 | * LCDR &= ~(LCD_SC|LCD_SD|LCD_DS); | ||
141 | * if (j & byte) | ||
142 | * LCDR |= LCD_SD; | ||
143 | * LCDR |= LCD_SC; | ||
144 | * } | ||
145 | * while ((unsigned char)j >>= 1); | ||
146 | */ | ||
147 | { | ||
148 | if (data) | ||
149 | asm ("shll8 %0\n" | 163 | asm ("shll8 %0\n" |
150 | "0: \n\t" | 164 | "0: \n\t" |
151 | "and.b %2,@(r0,gbr)\n\t" | 165 | "and.b %2,@(r0,gbr)\n\t" |
@@ -165,18 +179,17 @@ static void lcd_byte (int byte,bool data) | |||
165 | /* %4 */ "I"(LCD_SC|LCD_DS), | 179 | /* %4 */ "I"(LCD_SC|LCD_DS), |
166 | /* %5 */ "z"(LCDR)); | 180 | /* %5 */ "z"(LCDR)); |
167 | else | 181 | else |
168 | asm | 182 | asm ("shll8 %0\n" |
169 | ("shll8\t%0\n" | 183 | "0: \n\t" |
170 | "0:\n\t" | 184 | "and.b %2, @(r0,gbr)\n\t" |
171 | "and.b\t%2,@(r0,gbr)\n\t" | 185 | "shll %0\n\t" |
172 | "shll\t%0\n\t" | 186 | "bf 1f\n\t" |
173 | "bf\t1f\n\t" | 187 | "or.b %3, @(r0,gbr)\n" |
174 | "or.b\t%3,@(r0,gbr)\n" | 188 | "1: \n\t" |
175 | "1:\n\t" | 189 | "or.b %4, @(r0,gbr)\n" |
176 | "or.b\t%4,@(r0,gbr)\n" | 190 | "add #-1, %1\n\t" |
177 | "add\t#-1,%1\n\t" | 191 | "cmp/pl %1\n\t" |
178 | "cmp/pl\t%1\n\t" | 192 | "bt 0b" |
179 | "bt\t0b" | ||
180 | : | 193 | : |
181 | : /* %0 */ "r"(((unsigned)byte)<<16), | 194 | : /* %0 */ "r"(((unsigned)byte)<<16), |
182 | /* %1 */ "r"(8), | 195 | /* %1 */ "r"(8), |
@@ -184,186 +197,159 @@ static void lcd_byte (int byte,bool data) | |||
184 | /* %3 */ "I"(LCD_SD), | 197 | /* %3 */ "I"(LCD_SD), |
185 | /* %4 */ "I"(LCD_SC), | 198 | /* %4 */ "I"(LCD_SC), |
186 | /* %5 */ "z"(LCDR)); | 199 | /* %5 */ "z"(LCDR)); |
187 | } | ||
188 | 200 | ||
189 | static void lcd_data (int data) | 201 | asm("or.b %0, @(r0,gbr)" |
190 | { | 202 | : |
191 | lcd_byte (data,1); | 203 | : /* %0 */ "I"(LCD_CS|LCD_DS|LCD_SD|LCD_SC), |
204 | /* %1 */ "z"(LCDR)); | ||
192 | } | 205 | } |
193 | 206 | #else | |
194 | void lcd_instruction (int instruction) | ||
195 | { | 207 | { |
196 | lcd_byte (instruction,0); | 208 | int i; |
197 | } | 209 | char on,off; |
198 | 210 | ||
199 | void lcd_zero (int length) | 211 | PBDR &= ~LCD_CS; /* enable lcd chip select */ |
200 | { | ||
201 | length *= 8; | ||
202 | while (--length >= 0) | ||
203 | lcd_data (0); | ||
204 | } | ||
205 | 212 | ||
206 | void lcd_fill (int data,int length) | 213 | if ( command ) { |
207 | { | 214 | on=~(LCD_SD|LCD_SC|LCD_DS); |
208 | length *= 8; | 215 | off=LCD_SC; |
209 | while (--length >= 0) | 216 | } |
210 | lcd_data (data); | 217 | else { |
211 | } | 218 | on=~(LCD_SD|LCD_SC); |
219 | off=LCD_SC|LCD_DS; | ||
220 | } | ||
212 | 221 | ||
213 | void lcd_copy (void *data,int count) | 222 | /* clock out each bit, MSB first */ |
214 | { | 223 | for (i=0x80;i;i>>=1) |
215 | while (--count >= 0) | 224 | { |
216 | lcd_data (*((char *)data)++); | 225 | PBDR &= on; |
217 | } | 226 | if (i & byte) |
227 | PBDR |= LCD_SD; | ||
228 | PBDR |= off; | ||
229 | } | ||
218 | 230 | ||
219 | static void lcd_goto (int x,int y) | 231 | PBDR |= LCD_CS; /* disable lcd chip select */ |
220 | { | ||
221 | lcd_instruction (LCD_CURSOR(x,y)); | ||
222 | } | 232 | } |
233 | #endif /* ASM_IMPLEMENTATION */ | ||
223 | 234 | ||
224 | /*** BACKLIGHT ***/ | 235 | /*** BACKLIGHT ***/ |
225 | 236 | ||
226 | static void lcd_toggle_backlight (void) | 237 | void lcd_backlight(bool on) |
227 | { | 238 | { |
228 | PAIOR ^= LCD_BL; | 239 | if ( on ) |
240 | PAIOR |= LCD_BL; | ||
241 | else | ||
242 | PAIOR &= ~LCD_BL; | ||
229 | } | 243 | } |
230 | 244 | ||
231 | static void lcd_turn_on_backlight (void) | 245 | #endif /* SIMULATOR */ |
232 | { | ||
233 | PAIOR |= LCD_BL; | ||
234 | } | ||
235 | 246 | ||
236 | static void lcd_turn_off_backlight (void) | ||
237 | { | ||
238 | PAIOR &= ~LCD_BL; | ||
239 | } | ||
240 | 247 | ||
241 | /*** ICONS ***/ | 248 | |
242 | #endif /* SIMULATOR */ | 249 | /*** model specific code */ |
250 | |||
251 | #ifdef HAVE_LCD_CHARCELLS | ||
243 | 252 | ||
244 | #ifdef HAVE_NEW_CHARCELL_LCD | 253 | #ifdef HAVE_NEW_CHARCELL_LCD |
245 | 254 | ||
246 | static char lcd_ascii[] = | 255 | static const unsigned char lcd_ascii[] = { |
247 | { | 256 | 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, |
248 | /*****************************************************************************/ | 257 | 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f, |
249 | /* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF */ | 258 | 0x10,0x11,0x05,0x13,0x14,0x15,0x16,0x17, |
250 | /* ************************************************************************/ | 259 | 0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f, |
251 | /* 0x */ 0x00,0x01,0x02,0x03,0x00,0x00,0x00,0x00,0x04,0x05,0x00,0x00,0x00,0x00,0x00,0x00, | 260 | 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27, |
252 | /* 1x */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | 261 | 0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f, |
253 | /* 2x */ 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F, | 262 | 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37, |
254 | /* 3x */ 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F, | 263 | 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, |
255 | /* 4x */ 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F, | 264 | 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47, |
256 | /* 5x */ 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F, | 265 | 0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f, |
257 | /* 6x */ 0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F, | 266 | 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57, |
258 | /* 7x */ 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x20,0x20,0x20,0x20,0x20, | 267 | 0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f, |
259 | /* 8x */ 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, | 268 | 0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67, |
260 | /* 9x */ 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, | 269 | 0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f, |
261 | /* Ax */ 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, | 270 | 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77, |
262 | /* Bx */ 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, | 271 | 0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f, |
263 | /* Cx */ 0x41,0x41,0x41,0x41,0x41,0x41,0x20,0x43,0x45,0x45,0x45,0x45,0x49,0x49,0x49,0x49, | 272 | 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, |
264 | /* Dx */ 0x44,0x4E,0x4F,0x4F,0x4F,0x4F,0x4F,0x20,0x20,0x55,0x55,0x55,0x55,0x59,0x20,0x20, | 273 | 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, |
265 | /* Ex */ 0x61,0x61,0x61,0x61,0x61,0x61,0x20,0x63,0x65,0x65,0x65,0x65,0x69,0x69,0x69,0x69, | 274 | 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, |
266 | /* Fx */ 0x64,0x6E,0x6F,0x6F,0x6F,0x6F,0x6F,0x20,0x20,0x75,0x75,0x75,0x75,0x79,0x79,0x79 | 275 | 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, |
276 | 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, | ||
277 | 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, | ||
278 | 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, | ||
279 | 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, | ||
280 | 0x41,0x41,0x41,0x41,0x41,0x41,0x20,0x43, | ||
281 | 0x45,0x45,0x45,0x45,0x49,0x49,0x49,0x49, | ||
282 | 0x44,0x4e,0x4f,0x4f,0x4f,0x4f,0x4f,0x20, | ||
283 | 0x20,0x55,0x55,0x55,0x55,0x59,0x20,0x20, | ||
284 | 0x61,0x61,0x61,0x61,0x61,0x61,0x20,0x63, | ||
285 | 0x65,0x65,0x65,0x65,0x69,0x69,0x69,0x69, | ||
286 | 0x6f,0x6e,0x6f,0x6f,0x6f,0x6f,0x6f,0x20, | ||
287 | 0x20,0x75,0x75,0x75,0x75,0x79,0x20,0x79 | ||
267 | }; | 288 | }; |
268 | 289 | ||
269 | #else | 290 | #else |
270 | 291 | ||
271 | static char lcd_ascii[] = | 292 | static const unsigned char lcd_ascii[] = { |
272 | { | 293 | 0x00,0x01,0x02,0x03,0x00,0x84,0x85,0x89, |
273 | /*****************************************************************************/ | 294 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
274 | /* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF */ | 295 | 0xec,0xe3,0xe2,0xe1,0xe0,0xdf,0x15,0x00, |
275 | /* ************************************************************************/ | 296 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
276 | /* 0x */ 0x00,0x01,0x02,0x03,0x00,0x00,0x00,0x00,0x85,0x89,0x00,0x00,0x00,0x00,0x00,0x00, | 297 | 0x24,0x25,0x26,0x37,0x06,0x29,0x2a,0x2b, |
277 | /* 1x */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | 298 | 0x2c,0x2d,0x2e,0x2f,0x30,0x31,0x32,0x33, |
278 | /* 2x */ 0x24,0x25,0x26,0x37,0x06,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,0x30,0x31,0x32,0x33, | 299 | 0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b, |
279 | /* 3x */ 0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,0x40,0x41,0x42,0x43, | 300 | 0x3c,0x3d,0x3e,0x3f,0x40,0x41,0x42,0x43, |
280 | /* 4x */ 0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,0x50,0x51,0x52,0x53, | 301 | 0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b, |
281 | /* 5x */ 0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0xA9,0x33,0xCE,0x00,0x15, | 302 | 0x4c,0x4d,0x4e,0x4f,0x50,0x51,0x52,0x53, |
282 | /* 6x */ 0x00,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,0x70,0x71,0x72,0x73, | 303 | 0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b, |
283 | /* 7x */ 0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x24,0x24,0x24,0x24,0x24, | 304 | 0x5c,0x5d,0x5e,0xa9,0x33,0xce,0x00,0x15, |
284 | /* 8x */ 0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24, | 305 | 0x00,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b, |
285 | /* 9x */ 0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24, | 306 | 0x6c,0x6d,0x6e,0x6f,0x70,0x71,0x72,0x73, |
286 | /* Ax */ 0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24, | 307 | 0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b, |
287 | /* Bx */ 0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24, | 308 | 0x7c,0x7d,0x7e,0x24,0x24,0x24,0x24,0x24, |
288 | /* Cx */ 0x45,0x45,0x45,0x45,0x45,0x45,0x24,0x47,0x49,0x49,0x49,0x49,0x4D,0x4D,0x4D,0x4D, | 309 | 0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24, |
289 | /* Dx */ 0x48,0x52,0x53,0x53,0x53,0x53,0x53,0x24,0x24,0x59,0x59,0x59,0x59,0x5D,0x24,0x24, | 310 | 0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24, |
290 | /* Ex */ 0x65,0x65,0x65,0x65,0x65,0x65,0x24,0x67,0x69,0x69,0x69,0x69,0x6D,0x6D,0x6D,0x6D, | 311 | 0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24, |
291 | /* Fx */ 0x73,0x72,0x73,0x73,0x73,0x73,0x73,0x24,0x24,0x79,0x79,0x79,0x79,0x7D,0x24,0x7D | 312 | 0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24, |
313 | 0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24, | ||
314 | 0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24, | ||
315 | 0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24, | ||
316 | 0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24, | ||
317 | 0x45,0x45,0x45,0x45,0x45,0x45,0x24,0x47, | ||
318 | 0x49,0x49,0x49,0x49,0x4d,0x4d,0x4d,0x4d, | ||
319 | 0x48,0x52,0x53,0x53,0x53,0x53,0x53,0x24, | ||
320 | 0x24,0x59,0x59,0x59,0x59,0x5d,0x24,0x24, | ||
321 | 0x65,0x65,0x65,0x65,0x65,0x65,0x24,0x67, | ||
322 | 0x69,0x69,0x69,0x69,0x6d,0x6d,0x6d,0x6d, | ||
323 | 0x73,0x72,0x73,0x73,0x73,0x73,0x73,0x24, | ||
324 | 0x24,0x79,0x79,0x79,0x79,0x7d,0x24,0x7d | ||
292 | }; | 325 | }; |
326 | #endif /* HAVE_NEW_CHARCELL_LCD */ | ||
293 | 327 | ||
294 | #endif | 328 | void lcd_clear_display(void) |
295 | |||
296 | void lcd_puts(int x, int y, char *string) | ||
297 | { | 329 | { |
298 | while (*string) | 330 | int i; |
299 | lcd_data (LCD_ASCII(*string++)); | 331 | lcd_write(TRUE,LCD_CURSOR(0,0)); |
300 | } | 332 | for (i=0;i<24;i++) |
301 | 333 | lcd_write(FALSE,0); | |
302 | void lcd_putns (char *string,int n) | ||
303 | { | ||
304 | while (n--) | ||
305 | lcd_data (LCD_ASCII(*string++)); | ||
306 | } | ||
307 | |||
308 | void lcd_putc (int character) | ||
309 | { | ||
310 | lcd_data (LCD_ASCII(character)); | ||
311 | } | 334 | } |
312 | 335 | ||
313 | void lcd_pattern (int which,char *pattern,int count) | 336 | void lcd_puts(int x, int y, char *string) |
314 | { | 337 | { |
315 | lcd_instruction (LCD_PRAM|which); | 338 | lcd_write(TRUE,LCD_CURSOR(x,y)); |
316 | lcd_copy ((void *)pattern,count); | 339 | while (*string) |
340 | lcd_write(FALSE,LCD_ASCII(*string++)); | ||
317 | } | 341 | } |
318 | 342 | ||
319 | void lcd_puthex (unsigned int value,int digits) | 343 | void lcd_define_pattern (int which,char *pattern,int length) |
320 | { | 344 | { |
321 | switch (digits) { | 345 | int i; |
322 | case 8: | 346 | lcd_write(TRUE,LCD_PRAM|which); |
323 | lcd_puthex (value >> 16,4); | 347 | for (i=0;i<length;i++) |
324 | case 4: | 348 | lcd_write(FALSE,pattern[i]); |
325 | lcd_puthex (value >> 8,2); | ||
326 | case 2: | ||
327 | lcd_puthex (value >> 4,1); | ||
328 | case 1: | ||
329 | value &= 15; | ||
330 | lcd_putc (value+((value < 10) ? '0' : ('A'-10))); | ||
331 | } | ||
332 | } | 349 | } |
333 | 350 | ||
334 | |||
335 | #elif HAVE_LCD_BITMAP /* not CHARCELLS */ | 351 | #elif HAVE_LCD_BITMAP /* not CHARCELLS */ |
336 | 352 | ||
337 | #define LCD_SD 1 // PB0 = 1 --- 0001 | ||
338 | #define LCD_SC 2 // PB1 = 1 --- 0010 | ||
339 | #define LCD_RS 4 // PB2 = 1 --- 0100 | ||
340 | #define LCD_CS 8 // PB3 = 1 --- 1000 | ||
341 | #define LCD_DS LCD_RS | ||
342 | |||
343 | #define LCD_SET_LOWER_COLUMN_ADDRESS ((char)0x00) | ||
344 | #define LCD_SET_HIGHER_COLUMN_ADDRESS ((char)0x10) | ||
345 | #define LCD_SET_INTERNAL_REGULATOR_RESISTOR_RATIO ((char)0x20) | ||
346 | #define LCD_SET_POWER_CONTROL_REGISTER ((char)0x28) | ||
347 | #define LCD_SET_DISPLAY_START_LINE ((char)0x40) | ||
348 | #define LCD_SET_CONTRAST_CONTROL_REGISTER ((char)0x81) | ||
349 | #define LCD_SET_SEGMENT_REMAP ((char)0xA0) | ||
350 | #define LCD_SET_LCD_BIAS ((char)0xA2) | ||
351 | #define LCD_SET_ENTIRE_DISPLAY_OFF ((char)0xA4) | ||
352 | #define LCD_SET_ENTIRE_DISPLAY_ON ((char)0xA5) | ||
353 | #define LCD_SET_NORMAL_DISPLAY ((char)0xA6) | ||
354 | #define LCD_SET_REVERSE_DISPLAY ((char)0xA7) | ||
355 | #define LCD_SET_INDICATOR_OFF ((char)0xAC) | ||
356 | #define LCD_SET_INDICATOR_ON ((char)0xAD) | ||
357 | #define LCD_SET_DISPLAY_OFF ((char)0xAE) | ||
358 | #define LCD_SET_DISPLAY_ON ((char)0xAF) | ||
359 | #define LCD_SET_PAGE_ADDRESS ((char)0xB0) | ||
360 | #define LCD_SET_COM_OUTPUT_SCAN_DIRECTION ((char)0xC0) | ||
361 | #define LCD_SET_DISPLAY_OFFSET ((char)0xD3) | ||
362 | #define LCD_SET_READ_MODIFY_WRITE_MODE ((char)0xE0) | ||
363 | #define LCD_SOFTWARE_RESET ((char)0xE2) | ||
364 | #define LCD_NOP ((char)0xE3) | ||
365 | #define LCD_SET_END_OF_READ_MODIFY_WRITE_MODE ((char)0xEE) | ||
366 | |||
367 | /* | 353 | /* |
368 | * All bitmaps have this format: | 354 | * All bitmaps have this format: |
369 | * Bits within a byte are arranged veritcally, LSB at top. | 355 | * Bits within a byte are arranged veritcally, LSB at top. |
@@ -375,7 +361,7 @@ void lcd_puthex (unsigned int value,int digits) | |||
375 | * | 361 | * |
376 | * Memory copy of display bitmap | 362 | * Memory copy of display bitmap |
377 | */ | 363 | */ |
378 | unsigned char display[DISP_X][DISP_Y/8]; | 364 | unsigned char display[LCD_WIDTH][LCD_HEIGHT/8]; |
379 | 365 | ||
380 | /* | 366 | /* |
381 | * ASCII character generation tables | 367 | * ASCII character generation tables |
@@ -386,20 +372,16 @@ unsigned char display[DISP_X][DISP_Y/8]; | |||
386 | #define ASCII_MIN 0x20 /* First char in table */ | 372 | #define ASCII_MIN 0x20 /* First char in table */ |
387 | #define ASCII_MAX 0x7f /* Last char in table */ | 373 | #define ASCII_MAX 0x7f /* Last char in table */ |
388 | 374 | ||
389 | extern const unsigned char char_gen_6x8[][5][1]; | 375 | extern unsigned char char_gen_6x8[][5][1]; |
390 | extern const unsigned char char_gen_8x12[][7][2]; | 376 | extern unsigned char char_gen_8x12[][7][2]; |
391 | extern const unsigned char char_gen_12x16[][11][2]; | 377 | extern unsigned char char_gen_12x16[][11][2]; |
392 | |||
393 | 378 | ||
394 | /* All zeros and ones bitmaps for area filling */ | 379 | /* All zeros and ones bitmaps for area filling */ |
395 | static const unsigned char zeros[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 380 | static unsigned char zeros[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
396 | 0x00, 0x00 }; | 381 | 0x00, 0x00 }; |
397 | static const unsigned char ones[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 382 | static unsigned char ones[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, |
398 | 0xff, 0xff }; | 383 | 0xff, 0xff }; |
399 | 384 | static char fonts[] = { 6,8,12 }; | |
400 | static int lcd_y; /* Current pixel row */ | ||
401 | static int lcd_x; /* Current pixel column */ | ||
402 | static int lcd_size; /* Current font width */ | ||
403 | 385 | ||
404 | #ifndef SIMULATOR | 386 | #ifndef SIMULATOR |
405 | 387 | ||
@@ -434,39 +416,17 @@ void lcd_update (void) | |||
434 | int x, y; | 416 | int x, y; |
435 | 417 | ||
436 | /* Copy display bitmap to hardware */ | 418 | /* Copy display bitmap to hardware */ |
437 | for (y = 0; y < DISP_Y/8; y++) | 419 | for (y = 0; y < LCD_HEIGHT/8; y++) |
438 | { | 420 | { |
439 | lcd_write (TRUE, LCD_CNTL_PAGE | (y & 0xf)); | 421 | lcd_write (TRUE, LCD_CNTL_PAGE | (y & 0xf)); |
440 | lcd_write (TRUE, LCD_CNTL_HIGHCOL); | 422 | lcd_write (TRUE, LCD_CNTL_HIGHCOL); |
441 | lcd_write (TRUE, LCD_CNTL_LOWCOL); | 423 | lcd_write (TRUE, LCD_CNTL_LOWCOL); |
442 | 424 | ||
443 | for (x = 0; x < DISP_X; x++) | 425 | for (x = 0; x < LCD_WIDTH; x++) |
444 | lcd_write (FALSE, display[x][y]); | 426 | lcd_write (FALSE, display[x][y]); |
445 | } | 427 | } |
446 | } | 428 | } |
447 | 429 | ||
448 | static void lcd_write (bool command, int value) | ||
449 | { | ||
450 | int bit; | ||
451 | |||
452 | /* Enable chip select, set DC if data */ | ||
453 | PBDR &= ~(PBDR_LCD_CS1|PBDR_LCD_DC); | ||
454 | if (!command) | ||
455 | PBDR |= PBDR_LCD_DC; | ||
456 | |||
457 | /* Send each bit, starting with MSB */ | ||
458 | for (bit = 0x80; bit > 0; bit >>= 1) | ||
459 | { | ||
460 | PBDR &= ~(PBDR_LCD_SDA|PBDR_LCD_SCK); | ||
461 | if (value & bit) | ||
462 | PBDR |= PBDR_LCD_SDA; | ||
463 | PBDR |= PBDR_LCD_SCK; | ||
464 | } | ||
465 | |||
466 | /* Disable chip select */ | ||
467 | PBDR |= PBDR_LCD_CS1; | ||
468 | } | ||
469 | |||
470 | #endif /* SIMULATOR */ | 430 | #endif /* SIMULATOR */ |
471 | 431 | ||
472 | /* | 432 | /* |
@@ -474,33 +434,19 @@ static void lcd_write (bool command, int value) | |||
474 | */ | 434 | */ |
475 | void lcd_clear_display (void) | 435 | void lcd_clear_display (void) |
476 | { | 436 | { |
477 | lcd_position (0, 0, 8); | ||
478 | memset (display, 0, sizeof display); | 437 | memset (display, 0, sizeof display); |
479 | } | 438 | } |
480 | 439 | ||
481 | /* | 440 | /* |
482 | * Set current x,y position and font size | 441 | * Put a string at specified position and font |
483 | */ | ||
484 | void lcd_position (int x, int y, int size) | ||
485 | { | ||
486 | if (x >= 0 && x < DISP_X && y >= 0 && y < DISP_Y) | ||
487 | { | ||
488 | lcd_x = x; | ||
489 | lcd_y = y; | ||
490 | } | ||
491 | |||
492 | lcd_size = size; | ||
493 | } | ||
494 | |||
495 | /* | ||
496 | * Display a string at current position and size | ||
497 | */ | 442 | */ |
498 | void lcd_string (const char *str) | 443 | void lcd_puts(int x, int y, char *str, int font) |
499 | { | 444 | { |
500 | int x = lcd_x; | 445 | int nx = fonts[font]; |
501 | int nx = lcd_size; | ||
502 | int ny, ch; | 446 | int ny, ch; |
503 | const unsigned char *src; | 447 | unsigned char *src; |
448 | int lcd_x = x; | ||
449 | int lcd_y = y; | ||
504 | 450 | ||
505 | if (nx == 12) | 451 | if (nx == 12) |
506 | ny = 16; | 452 | ny = 16; |
@@ -514,14 +460,14 @@ void lcd_string (const char *str) | |||
514 | 460 | ||
515 | while ((ch = *str++) != '\0') | 461 | while ((ch = *str++) != '\0') |
516 | { | 462 | { |
517 | if (ch == '\n' || lcd_x + nx > DISP_X) | 463 | if (ch == '\n' || lcd_x + nx > LCD_WIDTH) |
518 | { | 464 | { |
519 | /* Wrap to next line */ | 465 | /* Wrap to next line */ |
520 | lcd_x = x; | 466 | lcd_x = x; |
521 | lcd_y += ny; | 467 | lcd_y += ny; |
522 | } | 468 | } |
523 | 469 | ||
524 | if (lcd_y + ny > DISP_Y) | 470 | if (lcd_y + ny > LCD_HEIGHT) |
525 | return; | 471 | return; |
526 | 472 | ||
527 | /* Limit to char generation table */ | 473 | /* Limit to char generation table */ |
@@ -546,7 +492,7 @@ void lcd_string (const char *str) | |||
546 | * Display a bitmap at (x, y), size (nx, ny) | 492 | * Display a bitmap at (x, y), size (nx, ny) |
547 | * clear is TRUE to clear destination area first | 493 | * clear is TRUE to clear destination area first |
548 | */ | 494 | */ |
549 | void lcd_bitmap (const unsigned char *src, int x, int y, int nx, int ny, | 495 | void lcd_bitmap (unsigned char *src, int x, int y, int nx, int ny, |
550 | bool clear) | 496 | bool clear) |
551 | { | 497 | { |
552 | unsigned char *dst; | 498 | unsigned char *dst; |
@@ -573,7 +519,7 @@ void lcd_bitmap (const unsigned char *src, int x, int y, int nx, int ny, | |||
573 | for (x = 0; x < nx; x++) | 519 | for (x = 0; x < nx; x++) |
574 | { | 520 | { |
575 | dst = dst2; | 521 | dst = dst2; |
576 | dst2 += DISP_Y/8; | 522 | dst2 += LCD_HEIGHT/8; |
577 | data = 0; | 523 | data = 0; |
578 | y = 0; | 524 | y = 0; |
579 | 525 | ||