thermferm/thermferm.c

changeset 72
f7cb53c50ee1
parent 71
a09c5cdc4022
child 74
879bd09e2b96
--- a/thermferm/thermferm.c	Mon Jun 23 22:16:29 2014 +0200
+++ b/thermferm/thermferm.c	Mon Jun 23 22:41:09 2014 +0200
@@ -26,8 +26,6 @@
 int			current_unit = -1;
 int			tempA = 80;
 int			tempB = 80;
-int			coolerA = 0;
-int			coolerB = 0;
 
 key_t			key = 5680;		/* key to be passed to shmget()		*/
 int			shmid;
@@ -83,52 +81,11 @@
 
 
 #ifdef HAVE_WIRINGPI_H
-void sendRCswitch(char *address, int state)
-{
-    char    *cmd = NULL;
-    int     rc;
-
-    cmd = xstrcpy(address);
-    if (state)
-	cmd = xstrcat(cmd, (char *)",1");
-    else
-	cmd = xstrcat(cmd, (char *)",0");
-    rc = toggleSwitch(cmd);
-    if (debug)
-	fprintf(stdout, "Switch %s rc=%d\n", cmd, rc);
-    syslog(LOG_NOTICE, "Switch %s rc=%d", cmd, rc);
-    free(cmd);
-}
-#endif
-
-
-#ifdef HAVE_WIRINGPI_H
 void stopLCD(void)
 {
     mb_lcdClear(lcdHandle);
     setBacklight(0);
 }
-
-
-
-void stopRCswitch(void)
-{
-    rc_switch   *tmp, *old;
-    char	*cmd = NULL;
-    int		rc;
-
-    for (tmp = Config.rcswitch; tmp; tmp = old) {
-	old = tmp->next;
-	cmd = xstrcpy(tmp->address);
-	cmd = xstrcat(cmd, (char *)",0");
-	rc = toggleSwitch(cmd);
-	if (debug)
-	    fprintf(stdout, "Switch %s rc=%d\n", cmd, rc);
-	syslog(LOG_NOTICE, "Switch %s rc=%d", cmd, rc);
-	free(cmd);
-	cmd = NULL;
-    }
-}
 #endif
 
 
@@ -197,13 +154,6 @@
     lcdPosition(lcdHandle, 0, 1);
     sprintf(buf, "  Version %s", VERSION);
     mb_lcdPuts(lcdHandle, buf);
-
-    if (Config.tx433 != -1) {
-	if (debug)
-	    fprintf(stdout, "Using 433 MHz transmitter on pin %d\n", Config.tx433);
-	syslog(LOG_NOTICE, "Using 433 MHz transmitter on pin %d", Config.tx433);
-    	enableTransmit(Config.tx433);
-    }
 #endif
 
     if (debug) {
@@ -278,7 +228,6 @@
     time_t		now, last = (time_t)0;
     w1_therm		*tmp1;
 #ifdef HAVE_WIRINGPI_H
-    rc_switch		*tmp2;
     int			rc;
 #endif
     int			run = 1, temp;
@@ -302,7 +251,7 @@
     }
 #endif
 
-    snprintf(buf, 1023, "tempA,coolerA,tempB,coolerB");
+    snprintf(buf, 1023, "tempA,tempB");
     logger((char *)"thermferm.log", (char *)"thermferm", buf);
 
     do {
@@ -312,49 +261,11 @@
 	    run = 0;
 
 	tmp1 = Config.w1therms;
-#ifdef HAVE_WIRINGPI_H
-	tmp2 = Config.rcswitch;
-#endif
-	if (((tmp1->lastval / 100) < (tempA - 5)) && (coolerA == 1)) {
-	    coolerA = 0;
-	    syslog(LOG_NOTICE, "Temperature A is %.1f, switched cooler off", (tmp1->lastval / 1000.0));
-#ifdef HAVE_WIRINGPI_H
-	    sendRCswitch(tmp2->address, 0);
-#endif
-	    lcdupdate = TRUE;
-	}
-	if (((tmp1->lastval / 100) > (tempA + 5)) && (coolerA == 0)) {
-	    coolerA = 1;
-	    syslog(LOG_NOTICE, "Temperature A is %.1f, switched cooler on", (tmp1->lastval / 1000.0));
-#ifdef HAVE_WIRINGPI_H
-	    sendRCswitch(tmp2->address, 1);
-#endif
-	    lcdupdate = TRUE;
-	}
 	if (tmp1->update) {
 	    tmp1->update = FALSE;
 	    lcdupdate = TRUE;
 	}
 	tmp1 = tmp1->next;
-#ifdef HAVE_WIRINGPI_H
-	tmp2 = tmp2->next;
-#endif
-	if (((tmp1->lastval / 100) < (tempB - 5)) && (coolerB == 1)) {
-	    coolerB = 0;
-	    syslog(LOG_NOTICE, "Temperature B is %.1f, switched cooler off", (tmp1->lastval / 1000.0));
-#ifdef HAVE_WIRINGPI_H
-	    sendRCswitch(tmp2->address, 0);
-#endif
-	    lcdupdate = TRUE;
-	}
-	if (((tmp1->lastval / 100) > (tempB + 5)) && (coolerB == 0)) {
-	    coolerB = 1;
-	    syslog(LOG_NOTICE, "Temperature B is %.1f, switched cooler on", (tmp1->lastval / 1000.0));
-#ifdef HAVE_WIRINGPI_H
-	    sendRCswitch(tmp2->address, 1);
-#endif
-	    lcdupdate = TRUE;
-	}
 	if (tmp1->update) {
 	    tmp1->update = FALSE;
 	    lcdupdate = TRUE;
@@ -364,12 +275,12 @@
 	if (run && lcdupdate) {
 	    lcdPosition(lcdHandle, 0, 0);
 	    tmp1 = Config.w1therms;
-	    snprintf(buf, 16, "%5.2f %cC %c %s            ", tmp1->lastval / 1000.0, 0xdf, coolerA ? '-' : ' ', tmp1->alias);
+	    snprintf(buf, 16, "%5.2f %cC %s              ", tmp1->lastval / 1000.0, 0xdf, tmp1->alias);
 	    mb_lcdPuts(lcdHandle, buf);
 	    temp = tmp1->lastval;
 	    tmp1 = tmp1->next;
 	    lcdPosition(lcdHandle, 0, 1);
-	    snprintf(buf, 16, "%5.2f %cC %c %s            ", tmp1->lastval / 1000.0, 0xdf, coolerB ? '-' : ' ', tmp1->alias);
+	    snprintf(buf, 16, "%5.2f %cC %s              ", tmp1->lastval / 1000.0, 0xdf, tmp1->alias);
 	    mb_lcdPuts(lcdHandle, buf);
 	}
 #endif
@@ -381,8 +292,7 @@
 	    temp = tmp1->lastval;
 	    tmp1 = tmp1->next;
 	    if (temp && tmp1->lastval && run) {
-	    	snprintf(buf, 1023, "%.2f,%s,%.2f,%s", temp / 1000.0, coolerA ? (char *)"on" : (char *)"off",
-			    			 tmp1->lastval / 1000.0, coolerB ? (char *)"on" : (char *)"off");
+	    	snprintf(buf, 1023, "%.2f,%.2f", temp / 1000.0, tmp1->lastval / 1000.0);
 	    	logger((char *)"thermferm.log", (char *)"thermferm", buf);
 	    }
 	}
@@ -399,12 +309,7 @@
     usleep(1500000);
 
 #ifdef HAVE_WIRINGPI_H
-    if (Config.tx433 != -1) {
-	stopRCswitch();
-    }
-
     stopLCD();
-    disableTransmit();
 #endif
 
     wrconfig((char *)"thermferm.conf");

mercurial