FreeCalypso > hg > freecalypso-sw
diff 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 |
line wrap: on
line diff
--- a/target-utils/pirexplore/lcd.c Mon Sep 02 01:28:11 2013 +0000 +++ b/target-utils/pirexplore/lcd.c Mon Sep 02 03:07:07 2013 +0000 @@ -130,11 +130,11 @@ { GPIO_OUT_REG |= 0x0080; nCS4_ADDR0 = 0x42; + nCS4_ADDR0 = ystart + 4; + nCS4_ADDR0 = yend + 4; + nCS4_ADDR0 = 0x43; nCS4_ADDR0 = xstart; nCS4_ADDR0 = xend; - nCS4_ADDR0 = 0x43; - nCS4_ADDR0 = ystart; - nCS4_ADDR0 = yend; } void @@ -156,22 +156,22 @@ switch (argc) { case 1: xstart = ystart = 0; - xend = yend = 131; + xend = yend = 127; break; case 5: xstart = atoi(argv[1]); - if (xstart < 0 || xstart > 131) { + if (xstart < 0 || xstart > 127) { range_err: printf("ERROR: coordinate arg out of range\n"); return; } xend = atoi(argv[2]); - if (xend < 0 || xend > 131) + if (xend < 0 || xend > 127) goto range_err; ystart = atoi(argv[3]); - if (ystart < 0 || ystart > 131) + if (ystart < 0 || ystart > 127) goto range_err; yend = atoi(argv[4]); - if (yend < 0 || yend > 131) + if (yend < 0 || yend > 127) goto range_err; if (xend < xstart || yend < ystart) { printf("ERROR: negative range\n"); @@ -187,3 +187,86 @@ while (npix--) nCS4_ADDR2 = pixval; } + +void +cmd_lcdramp() +{ + int i, j, k, p; + + set_lcd_addr_region(10, 89, 10, 89); + for (i = 0; i < 80; i++) { + for (j = 0; j < 8; j++) { + p = 0; + if (j & 4) + p |= 0xF800; + if (j & 2) + p |= 0x07E0; + if (j & 1) + p |= 0x001F; + for (k = 0; k < 10; k++) + nCS4_ADDR2 = p; + } + } +} + +void +cmd_blit(argbulk) + char *argbulk; +{ + int argc; + char *argv[6]; + u16 imgbuf[16384]; + size_t img_file_size; + int xstart, ystart, width, height; + int npix, i; + + if (parse_args(argbulk, 1, 5, argv, &argc) < 0) + return; + if (mpffs_read_into_ram(argv[0], imgbuf, 32768, &img_file_size) < 0) + return; + switch (argc) { + case 1: + xstart = ystart = 0; + width = height = 128; + break; + case 3: + xstart = ystart = 0; + goto widthheight; + case 5: + xstart = atoi(argv[3]); + if (xstart < 0 || xstart > 127) { +range_err: printf("ERROR: coordinate arg out of range\n"); + return; + } + ystart = atoi(argv[4]); + if (ystart < 0 || ystart > 127) + goto range_err; + /* FALL THRU */ + widthheight: + width = atoi(argv[1]); + if (width < 1 || width > 128) + goto range_err; + height = atoi(argv[2]); + if (height < 1 || height > 128) + goto range_err; + if (xstart + width > 128) + goto range_err; + if (ystart + height > 128) + goto range_err; + break; + default: + printf("ERROR: wrong number of arguments\n"); + return; + } + npix = width * height; + if (img_file_size != npix * 2) { + printf("ERROR: image file size (%u bytes) does not match WxH\n", + img_file_size); + return; + } + set_lcd_addr_region(xstart, xstart + width - 1, + ystart, ystart + height - 1); + /* the artwork images in Pirelli's FFS appear to be inverted */ + for (i = 0; i < npix; i++) + nCS4_ADDR2 = ~imgbuf[i]; +}