# HG changeset patch # User Michael Spacefalcon # Date 1378091227 0 # Node ID f65df1d640aae32eccd2dd2449abbdaac4882ab3 # Parent ac310ee737886a23a4c8a18c04438e63840f64ff pirexplore: approaching sanity with the LCD diff -r ac310ee73788 -r f65df1d640aa target-utils/pirexplore/cmdtab.c --- a/target-utils/pirexplore/cmdtab.c Mon Sep 02 01:28:11 2013 +0000 +++ b/target-utils/pirexplore/cmdtab.c Mon Sep 02 03:07:07 2013 +0000 @@ -1,11 +1,13 @@ #include "cmdtab.h" extern void cmd_baud_switch(); +extern void cmd_blit(); extern void cmd_dieid(); extern void cmd_find(); extern void cmd_jump(); extern void cmd_lcdfill(); extern void cmd_lcdinit(); +extern void cmd_lcdramp(); extern void cmd_r8(); extern void cmd_r16(); extern void cmd_r32(); @@ -21,12 +23,14 @@ const struct cmdtab cmdtab[] = { {"baud", cmd_baud_switch}, + {"blit", cmd_blit}, {"dieid", cmd_dieid}, {"ffsinit", mpffs_init}, {"find", cmd_find}, {"jump", cmd_jump}, {"lcdfill", cmd_lcdfill}, {"lcdinit", cmd_lcdinit}, + {"lcdramp", cmd_lcdramp}, {"r8", cmd_r8}, {"r16", cmd_r16}, {"r32", cmd_r32}, diff -r ac310ee73788 -r f65df1d640aa target-utils/pirexplore/lcd.c --- 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]; +}