Use user defined characters for the LCD display just like in Arduino projects.

Thu, 25 Feb 2016 20:12:27 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 25 Feb 2016 20:12:27 +0100
changeset 484
7362ebd40f26
parent 483
d676eaec0ee5
child 485
08543a9ca288

Use user defined characters for the LCD display just like in Arduino projects.

thermferm/lcd-buffer.c file | annotate | diff | comparison | revisions
thermferm/slcd.c file | annotate | diff | comparison | revisions
thermferm/slcd.h file | annotate | diff | comparison | revisions
thermferm/thermferm.c file | annotate | diff | comparison | revisions
--- a/thermferm/lcd-buffer.c	Mon Feb 22 19:24:49 2016 +0100
+++ b/thermferm/lcd-buffer.c	Thu Feb 25 20:12:27 2016 +0100
@@ -162,28 +162,6 @@
 	else
 	    tmp = my_lcd_rows;
     }
-
-#ifdef HAVE_WIRINGPI_H
-//    lcdPosition(lcdHandle, 0, r);
-//    lcdPuts(lcdHandle, tmp->row);
-#endif
-//    slcdPosition(slcdHandle, 0, r);
-//    slcdPuts(slcdHandle, tmp->row);
-
-//    r++;
-//    if (r < Config.lcd_rows) {
-//	if (tmp->next != NULL)
-//	    tmp = tmp->next;
-//	else
-//	    tmp = my_lcd_rows;
-#ifdef HAVE_WIRINGPI_H
-//	lcdPosition(lcdHandle, 0, r);
-//	lcdPuts(lcdHandle, tmp->row);
-#endif
-//	slcdPosition(slcdHandle, 0, r);
-//	slcdPuts(slcdHandle, tmp->row);
-//    }
-
 }
 
 
--- a/thermferm/slcd.c	Mon Feb 22 19:24:49 2016 +0100
+++ b/thermferm/slcd.c	Thu Feb 25 20:12:27 2016 +0100
@@ -136,9 +136,14 @@
 
 
 
-//void slcdCharDef(int fd, int index, unsigned char data[8])
-//{
-//}
+void slcdCharDef(int fd, int index, unsigned char data[8])
+{
+    int		i;
+
+    putLCDsocket(fd, SLCD_CGRAM | ((index & 7) << 3));
+    for (i = 0 ; i < 8 ; ++i)
+	putLCDsocket(fd, data[i]);
+}
 
 
 
--- a/thermferm/slcd.h	Mon Feb 22 19:24:49 2016 +0100
+++ b/thermferm/slcd.h	Thu Feb 25 20:12:27 2016 +0100
@@ -6,6 +6,7 @@
 void slcdLEDs(int fd);
 void slcdClear(int fd);
 void slcdPosition(int fd, int x, int y);
+void slcdCharDef(int fd, int index, unsigned char data[8]);
 void slcdPutchar(int fd, unsigned char c);
 void slcdPuts(int fd, const char *string);
 int  slcdInit(int fd, int cols, int rows);
--- a/thermferm/thermferm.c	Mon Feb 22 19:24:49 2016 +0100
+++ b/thermferm/thermferm.c	Thu Feb 25 20:12:27 2016 +0100
@@ -59,6 +59,14 @@
 extern int		sock;
 
 
+unsigned char		degC[8] 	= { 0b01000, 0b10100, 0b01000, 0b00111, 0b01000, 0b01000, 0b01000, 0b00111 };	// [1] degree c sybmol
+unsigned char		SP_Symbol[8]    = { 0b11100, 0b10000, 0b11100, 0b00111, 0b11101, 0b00111, 0b00100, 0b00100 };	// [2] SP Symbol
+unsigned char		CoolONOFF[8]    = { 0b00000, 0b01110, 0b01000, 0b01000, 0b01000, 0b01000, 0b01110, 0b00000 };	// [3] Cool Symbol
+unsigned char		RevCoolONOFF[8] = { 0b11111, 0b10001, 0b10111, 0b10111, 0b10111, 0b10111, 0b10001, 0b11111 };	// [4] Reverse Cool Symbol
+unsigned char		HeatONOFF[8]    = { 0b00000, 0b01010, 0b01010, 0b01110, 0b01110, 0b01010, 0b01010, 0b00000 };	// [5] HEAT symbol
+unsigned char		RevHeatONOFF[8] = { 0b11111, 0b10101, 0b10101, 0b10001, 0b10001, 0b10101, 0b10101, 0b11111 };	// [6] reverse HEAT symbol
+
+
 int  server(void);
 void help(void);
 void die(int);
@@ -857,6 +865,21 @@
 	return 1;
     }
 
+#ifdef HAVE_WIRINGPI_H
+    lcdCharDef(lcdHandle, 1, degC);
+    lcdCharDef(lcdHandle, 2, SP_Symbol);
+    lcdCharDef(lcdHandle, 3, CoolONOFF);
+    lcdCharDef(lcdHandle, 4, RevCoolONOFF);
+    lcdCharDef(lcdHandle, 5, HeatONOFF);
+    lcdCharDef(lcdHandle, 6, RevHeatONOFF);
+#endif
+    slcdCharDef(slcdHandle, 1, degC);
+    slcdCharDef(slcdHandle, 2, SP_Symbol);
+    slcdCharDef(slcdHandle, 3, CoolONOFF);
+    slcdCharDef(slcdHandle, 4, RevCoolONOFF);
+    slcdCharDef(slcdHandle, 5, HeatONOFF);
+    slcdCharDef(slcdHandle, 6, RevHeatONOFF);
+
     if (debug) {
 	/*
 	 * For debugging run in foreground.
@@ -1107,7 +1130,7 @@
 #ifdef HAVE_WIRINGPI_H
 		    piLock(LOCK_LCD);
 #endif
-		    lcd_buf_write(row++, "Room temp %.1f %cC    ", Config.temp_value / 1000.0, 0xdf);
+		    lcd_buf_write(row++, "Room temp %.1f%c    ", Config.temp_value / 1000.0, 0x01);
 #ifdef HAVE_WIRINGPI_H
 		    piUnlock(LOCK_LCD);
 #endif

mercurial