Mario Simaremare / Mbed 2 deprecated g3_waterplay

Dependencies:   mbed

Revision:
2:ed17e258da0d
Child:
5:4cbe44452889
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Thermostat.cpp	Tue Jun 14 09:14:24 2016 +0000
@@ -0,0 +1,49 @@
+/*
+* G3: WATERPLAY
+*/
+
+#include "Thermostat.h"
+#include "mbed.h"
+
+Thermostat::Thermostat(
+    mbed::Serial &serial,
+    PinName pin,
+    PinName led_pin
+):
+    _serial(serial),
+    _analog_out(pin),
+    _led(led_pin)
+{
+    off();
+}
+
+int Thermostat::on()
+{
+    this->_analog_out = 1;
+    this->_led = 1;
+    _serial.printf("thermostat: ON\n\r");
+    
+    return(this->_analog_out);
+}
+
+int Thermostat::off()
+{
+    this->_analog_out = 0;
+    this->_led = 0;
+    _serial.printf("thermostat: OFF\n\r");
+    
+    return(this->_analog_out);
+}
+
+int Thermostat::react(double temperature)
+{
+    int retVal = 0;
+    
+    if(temperature < 0.0){
+        retVal = this->on();
+    }else{
+        retVal = this->off();
+    }
+    
+    return(retVal);
+}
\ No newline at end of file