Commits

Alessio Caiazza committed 357f71a

general switch

  • Participants
  • Parent commits 83279fc

Comments (0)

Files changed (1)

File termostato_tx/src/termostato_tx.ino

 		ET.sendData();
 	}
 
-	int temp = getTemp();
-	int trashold = getPot();
-	bool mustSend = false;
-	if(status && temp > trashold) {
-		mydata.cmd = SWITCH_OFF;
-		mydata.args = 0;
+  bool active = digitalRead(GENERAl_SWITCH);
+  bool mustSend = false;
+
+  if(active) {
+  	int temp = getTemp();
+  	int trashold = getPot();
+  	if(status && temp > trashold) {
+  		mydata.cmd = SWITCH_OFF;
+  		mydata.args = 0;
+      status = false;
+  		mustSend = true;
+      Serial.println("SWITCH_OFF");
+  	} else if (!status && temp < trashold) {
+  		mydata.cmd = SWITCH_ON;
+  		mydata.args = 0;
+      status = true;
+  		mustSend = true;
+      Serial.println("SWITCH_ON");
+  	}
+
+  } else {
+    if(status) {
+      Serial.println("GENERAl_SWITCH off");
+
+      mydata.cmd = SWITCH_OFF;
+      mydata.args = 1;
+      mustSend = true;
+    }
     status = false;
-		mustSend = true;
-    Serial.println("SWITCH_OFF");
-	} else if (!status && temp < trashold) {
-		mydata.cmd = SWITCH_ON;
-		mydata.args = 0;
-    status = true;
-		mustSend = true;
-    Serial.println("SWITCH_ON");
-	}
 
-	if(mustSend)
-		ET.sendData();
+  }
+
+  if(mustSend)
+    ET.sendData();
 
 	digitalWrite(STATUS_LED, status);