coolers/coolers.c

changeset 33
2357e8636a60
parent 29
ac763b87ee25
child 34
38e3e3a49320
--- a/coolers/coolers.c	Fri May 09 20:39:01 2014 +0200
+++ b/coolers/coolers.c	Fri May 09 22:29:42 2014 +0200
@@ -28,8 +28,8 @@
 #ifdef HAVE_WIRINGPI_H
 
 
-int			tempA = 170;
-int			tempB = 250;
+int			tempA = 80;
+int			tempB = 80;
 int			coolerA = 0;
 int			coolerB = 0;
 
@@ -239,7 +239,7 @@
     char                buf[1024];
     w1_therm		*tmp1, *old1;
     rc_switch		*tmp2, *old2;
-    int			rc, run = 0;
+    int			rc, run = 0, temp;
 
     my_mosquitto_init();
 
@@ -249,6 +249,9 @@
 	syslog(LOG_NOTICE, "my_sensors_loop thread didn't start rc=%d", rc);
     }
 
+    snprintf(buf, 1023, "tempA,coolerA,tempB,coolerB");
+    logger((char *)"coolers.log", (char *)"coolers", buf);
+
     do {
 	lcdupdate = FALSE;
 
@@ -260,11 +263,13 @@
 	    my_mosquitto_switch(tmp2->address, 0);
 	    coolerA = 0;
 	    syslog(LOG_NOTICE, "Temperature A is %.1f, switched cooler off", (tmp1->lastval / 1000.0));
+	    lcdupdate = TRUE;
 	}
 	if (((tmp1->lastval / 100) > (tempA + 5)) && (coolerA == 0)) {
 	    my_mosquitto_switch(tmp2->address, 1);
 	    coolerA = 1;
 	    syslog(LOG_NOTICE, "Temperature A is %.1f, switched cooler on", (tmp1->lastval / 1000.0));
+	    lcdupdate = TRUE;
 	}
 	old1 = tmp1->next;
 	tmp1 = old1;
@@ -274,11 +279,13 @@
 	    my_mosquitto_switch(tmp2->address, 0);
 	    coolerB = 0;
 	    syslog(LOG_NOTICE, "Temperature B is %.1f, switched cooler off", (tmp1->lastval / 1000.0));
+	    lcdupdate = TRUE;
 	}
 	if (((tmp1->lastval / 100) > (tempB + 5)) && (coolerB == 0)) {
 	    my_mosquitto_switch(tmp2->address, 1);
 	    coolerB = 1;
 	    syslog(LOG_NOTICE, "Temperature B is %.1f, switched cooler on", (tmp1->lastval / 1000.0));
+	    lcdupdate = TRUE;
 	}
 
 	if (run && lcdupdate) {
@@ -286,11 +293,15 @@
 	    tmp1 = Config.w1therms;
 	    snprintf(buf, 16, "%4.1f %cC %c %s            ", tmp1->lastval / 1000.0, 0xdf, coolerA ? '+' : ' ', tmp1->alias);
 	    lcdPuts(lcdHandle, buf);
+	    temp = tmp1->lastval;
 	    old1 = tmp1->next;
 	    tmp1 = old1;
 	    lcdPosition(lcdHandle, 0, 1);
 	    snprintf(buf, 16, "%4.1f %cC %c %s            ", tmp1->lastval / 1000.0, 0xdf, coolerB ? '+' : ' ', tmp1->alias);
 	    lcdPuts(lcdHandle, buf);
+	    snprintf(buf, 1023, "%.1f,%s,%.1f,%s", temp / 1000.0, coolerA ? (char *)"on" : (char *)"off",
+			    			 tmp1->lastval / 1000.0, coolerB ? (char *)"on" : (char *)"off");
+	    logger((char *)"coolers.log", (char *)"coolers", buf);
 	}
 	usleep(100000);
 

mercurial