Changed device outputs and status leds.

Thu, 10 Dec 2015 17:31:45 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 10 Dec 2015 17:31:45 +0100
changeset 452
edc86e2d2eaa
parent 451
2247970de278
child 453
76418c89b480

Changed device outputs and status leds.

brewco/brewco.c file | annotate | diff | comparison | revisions
brewco/devices.c file | annotate | diff | comparison | revisions
--- a/brewco/brewco.c	Thu Dec 10 15:58:01 2015 +0100
+++ b/brewco/brewco.c	Thu Dec 10 17:31:45 2015 +0100
@@ -104,6 +104,31 @@
 
 
 
+void tempstatus(float hlttemp, float mlttemp)
+{
+    char	text[81];
+
+    snprintf(text, 7, "%5.1f\001", hlttemp);
+#ifdef HAVE_WIRINGPI_H
+    piLock(LOCK_LCD);
+    lcdPosition(lcdHandle, 2, 1);
+    lcdPuts(lcdHandle, text);
+#endif
+    slcdPosition(slcdHandle, 2, 1);
+    slcdPuts(slcdHandle, text);
+
+    snprintf(text, 7, "%5.1f\001", mlttemp);
+#ifdef HAVE_WIRINGPI_H
+    piLock(LOCK_LCD);
+    lcdPosition(lcdHandle, 11, 1);
+    lcdPuts(lcdHandle, text);
+#endif
+    slcdPosition(slcdHandle, 11, 1);
+    slcdPuts(slcdHandle, text);
+}
+
+
+
 int server(void);
 int server(void)
 {
@@ -273,8 +298,14 @@
 					    manual = MANUAL_SELMLT;
 					if (key == KEY_RETURN)
 					    manual = MANUAL_NONE;
-					if (key == KEY_ENTER)
+					if (key == KEY_ENTER) {
+						// TODO: prompt for water
 					    manual = MANUAL_HLT;
+					    prompt(0, NULL);
+					    device_out(unit->hlt_heater.uuid, man_hlt_heat);
+					    device_out(unit->mlt_heater.uuid, man_mlt_heat);
+					    device_out(unit->mlt_pump.uuid, man_mlt_pump);
+					}
 					break;
 		case MANUAL_SELMLT:	prompt(0, NULL);
 					prompt(104, NULL);
@@ -285,11 +316,16 @@
 					    manual = MANUAL_SELHLT;
 					if (key == KEY_RETURN)
 					    manual = MANUAL_NONE;
-					if (key == KEY_ENTER)
+					if (key == KEY_ENTER) {
+						// TODO: prompt for water
 					    manual = MANUAL_MLT;
+					    prompt(0, NULL);
+					    device_out(unit->hlt_heater.uuid, man_hlt_heat);
+					    device_out(unit->mlt_heater.uuid, man_mlt_heat);
+					    device_out(unit->mlt_pump.uuid, man_mlt_pump);
+					}
 					break;
-		case MANUAL_HLT:	prompt(0, NULL);
-					prompt(104, NULL);
+		case MANUAL_HLT:	prompt(104, NULL);
 					prompt(413, NULL);
 
 					key = keywait();
@@ -307,8 +343,7 @@
 					if (debug)
 					    fprintf(stdout, "device_out(%s, %d) HLT heater\n", unit->hlt_heater.uuid, man_hlt_heat);
 					break;
-		case MANUAL_MLT:	prompt(0, NULL);
-					prompt(104, NULL);
+		case MANUAL_MLT:	prompt(104, NULL);
 					prompt(406, NULL);
 					key = keywait();
 					if (key == KEY_RETURN) {
@@ -338,6 +373,7 @@
 	    prompt(0, NULL);
 	    prompt(101, NULL);
 	    prompt(401, NULL);
+	    tempstatus(120.3, 165.34);
 	    key = keywait();
 	    if (key == KEY_ENTER)
 		setup();
--- a/brewco/devices.c	Thu Dec 10 15:58:01 2015 +0100
+++ b/brewco/devices.c	Thu Dec 10 17:31:45 2015 +0100
@@ -135,6 +135,90 @@
 
 
 
+void hlt_heater(int value)
+{
+#ifdef HAVE_WIRINGPI_H
+    piLock(LOCK_LCD);
+    lcdPosition(lcdHandle, 0, 1);
+#endif
+    slcdPosition(slcdHandle, 0, 1);
+    if (value) {
+	leds |= SLED_HLTH;
+#ifdef HAVE_WIRINGPI_H
+	lcdPutchar(lcdHandle, 5);
+#endif
+	slcdPutchar(slcdHandle, 5);
+    } else {
+	leds &= ~SLED_HLTH;
+#ifdef HAVE_WIRINGPI_H
+	lcdPutchar(lcdHandle, 6);
+#endif
+	slcdPutchar(slcdHandle, 6);
+    }
+#ifdef HAVE_WIRINGPI_H
+    piUnlock(LOCK_LCD);
+#endif
+    slcdLEDs(slcdHandle);
+}
+
+
+
+void mlt_heater(int value)
+{
+#ifdef HAVE_WIRINGPI_H
+    piLock(LOCK_LCD);
+    lcdPosition(lcdHandle, 18, 1);
+#endif
+    slcdPosition(slcdHandle, 18, 1);
+    if (value) {
+        leds |= SLED_MLTH;
+#ifdef HAVE_WIRINGPI_H
+        lcdPutchar(lcdHandle, 5);
+#endif
+        slcdPutchar(slcdHandle, 5);
+    } else {
+        leds &= ~SLED_MLTH;
+#ifdef HAVE_WIRINGPI_H
+        lcdPutchar(lcdHandle, 6);
+#endif
+        slcdPutchar(slcdHandle, 6);
+    }
+#ifdef HAVE_WIRINGPI_H
+    piUnlock(LOCK_LCD);
+#endif
+    slcdLEDs(slcdHandle);
+}
+
+
+
+void mlt_pump(int value)
+{
+#ifdef HAVE_WIRINGPI_H
+    piLock(LOCK_LCD);
+    lcdPosition(lcdHandle, 19, 1);
+#endif
+    slcdPosition(slcdHandle, 19, 1);
+    if (value) {
+        leds |= SLED_MLTP;
+#ifdef HAVE_WIRINGPI_H
+        lcdPutchar(lcdHandle, 3);
+#endif
+        slcdPutchar(slcdHandle, 3);
+    } else {
+        leds &= ~SLED_MLTP;
+#ifdef HAVE_WIRINGPI_H
+        lcdPutchar(lcdHandle, 4);
+#endif
+        slcdPutchar(slcdHandle, 4);
+    }
+#ifdef HAVE_WIRINGPI_H
+    piUnlock(LOCK_LCD);
+#endif
+    slcdLEDs(slcdHandle);
+}
+
+
+
 int device_out(char *uuid, int value)
 {
     devices_list	*device;
@@ -221,26 +305,14 @@
 			device->value = value;
 			if (strcmp((char *)"SimHLTheater", device->address) == 0) {
 			    SIM_hlt_value = value;
-			    if (value)
-				leds |= SLED_HLTH;
-			    else
-				leds &= ~SLED_HLTH;
-			    slcdLEDs(slcdHandle);
+			    hlt_heater(value);
 			}
 			if (strcmp((char *)"SimMLTheater", device->address) == 0) {
 			    SIM_mlt_value = value;
-			    if (value)
-				leds |= SLED_MLTH;
-			    else
-				leds &= ~SLED_MLTH;
-			    slcdLEDs(slcdHandle);
+			    mlt_heater(value);
 			}
 			if (strcmp((char *)"SimMLTpump", device->address) == 0) {
-			    if (value)
-				leds |= SLED_MLTP;
-			    else
-				leds &= ~SLED_MLTP;
-			    slcdLEDs(slcdHandle);
+			    mlt_pump(value);
 			}
 		    }
 		}

mercurial