picoLCD patch

Martin T Jones <[email protected]> Mon, 11 Feb 2013 15:53:34 +0000
Newsgroups gmane.comp.sysutils.lcdproc
Message-ID <[email protected]>
Hello,

I've attached a patch which add some more icons and fixes some minor bugs.

Martin

_______________________________________________
LCDproc mailing list
[email protected]
http://lists.omnipotent.net/mailman/listinfo/lcdproc
picolcd.c.patch (text/x-patch, 6.2 KB)
--- picolcd-cvs.c	2013-02-11 15:00:31.000000000 +0000
+++ picolcd.c	2013-02-11 15:05:28.000000000 +0000
@@ -16,7 +16,7 @@
  * 		 2007-2008 Mini-Box.com, Nicu Pavel <[email protected]>
  * 		 2008 Jack Cleaver
  * 		 2009 Andries van Schie
- * 		 2010-2011 Martin Jones <[email protected]>
+ * 		 2010-2013 Martin Jones <[email protected]>
  *
  * This file is released under the GNU General Public License. Refer to the
  * COPYING file distributed with this package.
@@ -286,14 +286,13 @@
 		report(RPT_ERR, "%s: libusb_claim_interface error %d", drvthis->name, error);
 		return -1;
 	}
-	/*
-	 * FIXME: Is this the libusb-1.0 equivalent to if
-	 * (usb_set_altinterface(p->lcd, 0) < 0) report(RPT_WARNING, "%s:
-	 * unable to set alternate configuration", drvthis->name); I always
-	 * get error -5 (LIBUSB_ERROR_NOT_FOUND the requested alternate
-	 * setting does not exist) Is this needed? Has it ever worked? lsusb
-	 * reports one configuration with one interface and no alternate
-	 * settings.
+	/*-
+	 * FIXME: Is this the libusb-1.0 equivalent to
+	 *    if (usb_set_altinterface(p->lcd, 0) < 0)
+	 *        report(RPT_WARNING, "%s: unable to set alternate configuration", drvthis->name);
+	 * I always get error -5 (LIBUSB_ERROR_NOT_FOUND the requested alternate
+	 * setting does not exist). Is this needed? Has it ever worked?
+	 * lsusb reports one configuration with one interface and no alternate settings.
 	 */
 	error = libusb_set_interface_alt_setting(p->lcd, 1, 0);
 	if (error) {
@@ -924,9 +923,11 @@
 
 		do_init = 1;
 	}
-
-	/* Lib_adv_bignum does everything needed to show the big numbers. */
-	lib_adv_bignum(drvthis, x, num, 0, do_init);
+	/*
+	 * Lib_adv_bignum does everything needed to show the big numbers.
+	 * Use an offset so that custom character zero is available for the heart-beat
+	 */
+	lib_adv_bignum(drvthis, x, num, 1, do_init);
 }
 
 
@@ -968,6 +969,53 @@
 		b_______
 	};
 
+	static unsigned char bar_right[] =
+	{
+		b____XXX,
+		b____XXX,
+		b____XXX,
+		b____XXX,
+		b____XXX,
+		b____XXX,
+		b____XXX,
+		b_______
+	};
+
+	static unsigned char bar_left[] =
+	{
+		b__XXX__,
+		b__XXX__,
+		b__XXX__,
+		b__XXX__,
+		b__XXX__,
+		b__XXX__,
+		b__XXX__,
+		b_______
+	};
+	static unsigned char triangle_right[] =
+	{
+		b__X____,
+		b__XX___,
+		b__XXX__,
+		b__XXXX_,
+		b__XXX__,
+		b__XX___,
+		b__X____,
+		b_______
+	};
+
+	static unsigned char triangle_left[] =
+	{
+		b______X,
+		b_____XX,
+		b____XXX,
+		b___XXXX,
+		b____XXX,
+		b_____XX,
+		b______X,
+		b_______
+	};
+
 	static unsigned char checkbox_gray[] =
 	{
 		b__X_X_X,
@@ -1020,10 +1068,10 @@
 	/*
 	 * Icons loaded to the display's custom character RAM. Horizontal &
 	 * vertical bars do not use RAM address zero so the heart can be used
-	 * in these modes. Big numbers use all eight locations.
+	 * in these modes. Big numbers use an offset to avoid address zero.
 	 */
-	if ((p->ccmode != custom)
-	    && !((p->ccmode == hbar || p->ccmode == vbar)
+	if ((p->ccmode != icons)
+	    && !((p->ccmode == hbar || p->ccmode == vbar || p->ccmode != bignum)
 		 && (icon == ICON_HEART_FILLED || icon == ICON_HEART_OPEN))) {
 		if (p->ccmode != standard) {
 			/* Combined custom character modes not supported */
@@ -1031,7 +1079,7 @@
 			       drvthis->name);
 			return -1;	/* Let the core do the icon */
 		}
-		p->ccmode = custom;
+		p->ccmode = icons;
 	}
 
 	switch (icon) {
@@ -1055,6 +1103,66 @@
 		picoLCD_set_char(drvthis, 7, checkbox_off);
 		picoLCD_chr(drvthis, x, y, 7);
 		break;
+		case ICON_SELECTOR_AT_LEFT:
+			picoLCD_set_char(drvthis, 2, triangle_right);
+			picoLCD_chr(drvthis, x, y, 2);
+			break;
+		case ICON_SELECTOR_AT_RIGHT:
+			picoLCD_set_char(drvthis, 1, triangle_left);
+			picoLCD_chr(drvthis, x, y, 1);
+			break;
+		/* Icons below are two characters wide */
+		case ICON_STOP:       /* should look like  []  */
+			picoLCD_set_char(drvthis, 4, bar_right);
+			picoLCD_chr(drvthis, x, y, 4);
+			picoLCD_set_char(drvthis, 3, bar_left);
+			picoLCD_chr(drvthis, x+1, y, 3);
+			break;
+		case ICON_PAUSE:      /* should look like  ||  */
+			picoLCD_set_char(drvthis, 3, bar_left);
+			picoLCD_chr(drvthis, x, y, 3);
+			picoLCD_set_char(drvthis, 4, bar_right);
+			picoLCD_chr(drvthis, x+1, y, 4);
+			break;
+		case ICON_PLAY:       /* should look like  >   */
+			picoLCD_set_char(drvthis, 2, triangle_right);
+			picoLCD_chr(drvthis, x, y, 2);
+			picoLCD_chr(drvthis, x+1, y, ' ');
+			break;
+		case ICON_PLAYR:      /* should look like  <   */
+			picoLCD_set_char(drvthis, 1, triangle_left);
+			picoLCD_chr(drvthis, x, y, 1);
+			picoLCD_chr(drvthis, x+1, y, ' ');
+			break;
+		case ICON_FF:         /* should look like  >>  */
+			picoLCD_set_char(drvthis, 2, triangle_right);
+			picoLCD_chr(drvthis, x, y, 2);
+			picoLCD_chr(drvthis, x+1, y, 2);
+			break;
+		case ICON_FR:         /* should look like  <<  */
+			picoLCD_set_char(drvthis, 1, triangle_left);
+			picoLCD_chr(drvthis, x, y, 1);
+			picoLCD_chr(drvthis, x+1, y, 1);
+			break;
+		case ICON_NEXT:       /* should look like  >|  */
+			picoLCD_set_char(drvthis, 2, triangle_right);
+			picoLCD_chr(drvthis, x, y, 2);
+			picoLCD_set_char(drvthis, 3, bar_left);
+			picoLCD_chr(drvthis, x+1, y, 3);
+			break;
+		case ICON_PREV:       /* should look like  |<  */
+			picoLCD_set_char(drvthis, 4, bar_right);
+			picoLCD_chr(drvthis, x, y, 4);
+			picoLCD_set_char(drvthis, 1, triangle_left);
+			picoLCD_chr(drvthis, x+1, y, 1);
+			break;
+		case ICON_REC:        /* should look like  () */
+			/* There aren't enough custom characters to draw a circle so use a diamond. */
+			picoLCD_set_char(drvthis, 1, triangle_left);
+			picoLCD_chr(drvthis, x, y, 1);
+			picoLCD_set_char(drvthis, 2, triangle_right);
+			picoLCD_chr(drvthis, x+1, y, 2);
+			break;
 	    default:
 		return -1;	/* Let the core do other icons */
 	}
@@ -1161,8 +1269,8 @@
 		/* Set the time for repeated key press if enabled */
 		if (p->key_repeat_delay > 0) {
 			gettimeofday(&current_time, NULL);
-			delay_time.tv_sec  = p->key_repeat_interval / 1000;
-			delay_time.tv_usec = (p->key_repeat_interval % 1000) * 1000;
+			delay_time.tv_sec  = p->key_repeat_delay / 1000;
+			delay_time.tv_usec = (p->key_repeat_delay % 1000) * 1000;
 			timeradd(&current_time,&delay_time,p->key_wait_time);
 		}
 	}