FreeCalypso > hg > freecalypso-sw
comparison target-utils/pirexplore/lcd.c @ 104:f65df1d640aa
pirexplore: approaching sanity with the LCD
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Mon, 02 Sep 2013 03:07:07 +0000 |
parents | 2c266d4339ff |
children | b26b7459bd44 |
comparison
equal
deleted
inserted
replaced
103:ac310ee73788 | 104:f65df1d640aa |
---|---|
128 | 128 |
129 set_lcd_addr_region(xstart, xend, ystart, yend) | 129 set_lcd_addr_region(xstart, xend, ystart, yend) |
130 { | 130 { |
131 GPIO_OUT_REG |= 0x0080; | 131 GPIO_OUT_REG |= 0x0080; |
132 nCS4_ADDR0 = 0x42; | 132 nCS4_ADDR0 = 0x42; |
133 nCS4_ADDR0 = ystart + 4; | |
134 nCS4_ADDR0 = yend + 4; | |
135 nCS4_ADDR0 = 0x43; | |
133 nCS4_ADDR0 = xstart; | 136 nCS4_ADDR0 = xstart; |
134 nCS4_ADDR0 = xend; | 137 nCS4_ADDR0 = xend; |
135 nCS4_ADDR0 = 0x43; | |
136 nCS4_ADDR0 = ystart; | |
137 nCS4_ADDR0 = yend; | |
138 } | 138 } |
139 | 139 |
140 void | 140 void |
141 cmd_lcdfill(argbulk) | 141 cmd_lcdfill(argbulk) |
142 char *argbulk; | 142 char *argbulk; |
154 return; | 154 return; |
155 } | 155 } |
156 switch (argc) { | 156 switch (argc) { |
157 case 1: | 157 case 1: |
158 xstart = ystart = 0; | 158 xstart = ystart = 0; |
159 xend = yend = 131; | 159 xend = yend = 127; |
160 break; | 160 break; |
161 case 5: | 161 case 5: |
162 xstart = atoi(argv[1]); | 162 xstart = atoi(argv[1]); |
163 if (xstart < 0 || xstart > 131) { | 163 if (xstart < 0 || xstart > 127) { |
164 range_err: printf("ERROR: coordinate arg out of range\n"); | 164 range_err: printf("ERROR: coordinate arg out of range\n"); |
165 return; | 165 return; |
166 } | 166 } |
167 xend = atoi(argv[2]); | 167 xend = atoi(argv[2]); |
168 if (xend < 0 || xend > 131) | 168 if (xend < 0 || xend > 127) |
169 goto range_err; | 169 goto range_err; |
170 ystart = atoi(argv[3]); | 170 ystart = atoi(argv[3]); |
171 if (ystart < 0 || ystart > 131) | 171 if (ystart < 0 || ystart > 127) |
172 goto range_err; | 172 goto range_err; |
173 yend = atoi(argv[4]); | 173 yend = atoi(argv[4]); |
174 if (yend < 0 || yend > 131) | 174 if (yend < 0 || yend > 127) |
175 goto range_err; | 175 goto range_err; |
176 if (xend < xstart || yend < ystart) { | 176 if (xend < xstart || yend < ystart) { |
177 printf("ERROR: negative range\n"); | 177 printf("ERROR: negative range\n"); |
178 return; | 178 return; |
179 } | 179 } |
185 set_lcd_addr_region(xstart, xend, ystart, yend); | 185 set_lcd_addr_region(xstart, xend, ystart, yend); |
186 npix = (xend + 1 - xstart) * (yend + 1 - ystart); | 186 npix = (xend + 1 - xstart) * (yend + 1 - ystart); |
187 while (npix--) | 187 while (npix--) |
188 nCS4_ADDR2 = pixval; | 188 nCS4_ADDR2 = pixval; |
189 } | 189 } |
190 | |
191 void | |
192 cmd_lcdramp() | |
193 { | |
194 int i, j, k, p; | |
195 | |
196 set_lcd_addr_region(10, 89, 10, 89); | |
197 for (i = 0; i < 80; i++) { | |
198 for (j = 0; j < 8; j++) { | |
199 p = 0; | |
200 if (j & 4) | |
201 p |= 0xF800; | |
202 if (j & 2) | |
203 p |= 0x07E0; | |
204 if (j & 1) | |
205 p |= 0x001F; | |
206 for (k = 0; k < 10; k++) | |
207 nCS4_ADDR2 = p; | |
208 } | |
209 } | |
210 } | |
211 | |
212 void | |
213 cmd_blit(argbulk) | |
214 char *argbulk; | |
215 { | |
216 int argc; | |
217 char *argv[6]; | |
218 u16 imgbuf[16384]; | |
219 size_t img_file_size; | |
220 int xstart, ystart, width, height; | |
221 int npix, i; | |
222 | |
223 if (parse_args(argbulk, 1, 5, argv, &argc) < 0) | |
224 return; | |
225 if (mpffs_read_into_ram(argv[0], imgbuf, 32768, &img_file_size) < 0) | |
226 return; | |
227 switch (argc) { | |
228 case 1: | |
229 xstart = ystart = 0; | |
230 width = height = 128; | |
231 break; | |
232 case 3: | |
233 xstart = ystart = 0; | |
234 goto widthheight; | |
235 case 5: | |
236 xstart = atoi(argv[3]); | |
237 if (xstart < 0 || xstart > 127) { | |
238 range_err: printf("ERROR: coordinate arg out of range\n"); | |
239 return; | |
240 } | |
241 ystart = atoi(argv[4]); | |
242 if (ystart < 0 || ystart > 127) | |
243 goto range_err; | |
244 /* FALL THRU */ | |
245 widthheight: | |
246 width = atoi(argv[1]); | |
247 if (width < 1 || width > 128) | |
248 goto range_err; | |
249 height = atoi(argv[2]); | |
250 if (height < 1 || height > 128) | |
251 goto range_err; | |
252 if (xstart + width > 128) | |
253 goto range_err; | |
254 if (ystart + height > 128) | |
255 goto range_err; | |
256 break; | |
257 default: | |
258 printf("ERROR: wrong number of arguments\n"); | |
259 return; | |
260 } | |
261 npix = width * height; | |
262 if (img_file_size != npix * 2) { | |
263 printf("ERROR: image file size (%u bytes) does not match WxH\n", | |
264 img_file_size); | |
265 return; | |
266 } | |
267 set_lcd_addr_region(xstart, xstart + width - 1, | |
268 ystart, ystart + height - 1); | |
269 /* the artwork images in Pirelli's FFS appear to be inverted */ | |
270 for (i = 0; i < npix; i++) | |
271 nCS4_ADDR2 = ~imgbuf[i]; | |
272 } |