changeset 78:2c266d4339ff

pirexplore: lcdfill implemented
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Thu, 01 Aug 2013 02:27:09 +0000
parents fcbe1332b197
children 947b1f473960
files target-utils/pirexplore/cmdtab.c target-utils/pirexplore/lcd.c
diffstat 2 files changed, 68 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/target-utils/pirexplore/cmdtab.c	Thu Aug 01 00:57:49 2013 +0000
+++ b/target-utils/pirexplore/cmdtab.c	Thu Aug 01 02:27:09 2013 +0000
@@ -3,6 +3,7 @@
 extern void cmd_baud_switch();
 extern void cmd_dieid();
 extern void cmd_jump();
+extern void cmd_lcdfill();
 extern void cmd_lcdinit();
 extern void cmd_r8();
 extern void cmd_r16();
@@ -19,6 +20,7 @@
 	{"baud", cmd_baud_switch},
 	{"dieid", cmd_dieid},
 	{"jump", cmd_jump},
+	{"lcdfill", cmd_lcdfill},
 	{"lcdinit", cmd_lcdinit},
 	{"r8", cmd_r8},
 	{"r16", cmd_r16},
--- a/target-utils/pirexplore/lcd.c	Thu Aug 01 00:57:49 2013 +0000
+++ b/target-utils/pirexplore/lcd.c	Thu Aug 01 02:27:09 2013 +0000
@@ -1,3 +1,7 @@
+/*
+ * Almost all of this Pirelli LCD black magic has been lifted from OsmocomBB.
+ */
+
 #include <sys/types.h>
 #include "types.h"
 
@@ -121,3 +125,65 @@
 	GPIO_OUT_REG |= 0x0080;
 	fb_s6b33b1x_send_cmdlist(s6b33b1x_initdata);
 }
+
+set_lcd_addr_region(xstart, xend, ystart, yend)
+{
+	GPIO_OUT_REG |= 0x0080;
+	nCS4_ADDR0 = 0x42;
+	nCS4_ADDR0 = xstart;
+	nCS4_ADDR0 = xend;
+	nCS4_ADDR0 = 0x43;
+	nCS4_ADDR0 = ystart;
+	nCS4_ADDR0 = yend;
+}
+
+void
+cmd_lcdfill(argbulk)
+	char *argbulk;
+{
+	int argc;
+	char *argv[6];
+	u_long pixval;
+	int xstart, xend, ystart, yend;
+	int npix;
+
+	if (parse_args(argbulk, 1, 5, argv, &argc) < 0)
+		return;
+	if (parse_hexarg(argv[0], 4, &pixval) < 0) {
+		printf("ERROR: arg1 must be a valid 16-bit hex value\n");
+		return;
+	}
+	switch (argc) {
+	case 1:
+		xstart = ystart = 0;
+		xend = yend = 131;
+		break;
+	case 5:
+		xstart = atoi(argv[1]);
+		if (xstart < 0 || xstart > 131) {
+range_err:		printf("ERROR: coordinate arg out of range\n");
+			return;
+		}
+		xend = atoi(argv[2]);
+		if (xend < 0 || xend > 131)
+			goto range_err;
+		ystart = atoi(argv[3]);
+		if (ystart < 0 || ystart > 131)
+			goto range_err;
+		yend = atoi(argv[4]);
+		if (yend < 0 || yend > 131)
+			goto range_err;
+		if (xend < xstart || yend < ystart) {
+			printf("ERROR: negative range\n");
+			return;
+		}
+		break;
+	default:
+		printf("ERROR: wrong number of arguments\n");
+		return;
+	}
+	set_lcd_addr_region(xstart, xend, ystart, yend);
+	npix = (xend + 1 - xstart) * (yend + 1 - ystart);
+	while (npix--)
+		nCS4_ADDR2 = pixval;
+}