Mario Simaremare / Mbed 2 deprecated g3_waterplay

Dependencies:   mbed

Revision:
5:4cbe44452889
Parent:
2:ed17e258da0d
Child:
13:142a142a7ac5
--- a/Thermostat.cpp	Fri Jun 17 09:24:01 2016 +0000
+++ b/Thermostat.cpp	Fri Jun 17 11:03:37 2016 +0000
@@ -6,44 +6,51 @@
 #include "mbed.h"
 
 Thermostat::Thermostat(
-    mbed::Serial &serial,
+    Printer &printer,
     PinName pin,
     PinName led_pin
 ):
-    _serial(serial),
+    _printer(printer),
     _analog_out(pin),
-    _led(led_pin)
+    _led(led_pin),
+    _status(STATUS_OFF)
 {
-    off();
+}
+
+int Thermostat::update(){
+    this->_analog_out = this->_status;
+    this->_led = this->_status;
+    
+    return(this->_status);
 }
 
 int Thermostat::on()
 {
-    this->_analog_out = 1;
-    this->_led = 1;
-    _serial.printf("thermostat: ON\n\r");
-    
-    return(this->_analog_out);
+    this->_status = STATUS_ON;
+    this->_strStatus = "Thermostat: ON\n\r";
+    return(this->_status);
 }
 
 int Thermostat::off()
 {
-    this->_analog_out = 0;
-    this->_led = 0;
-    _serial.printf("thermostat: OFF\n\r");
-    
-    return(this->_analog_out);
+    this->_status = STATUS_OFF;
+    this->_strStatus = "Thermostat: OFF\n\r";
+    return(this->_status);
 }
 
 int Thermostat::react(double temperature)
 {
     int retVal = 0;
-    
-    if(temperature < 0.0){
+
+    if(temperature < 0.0) {
         retVal = this->on();
-    }else{
+    } else {
         retVal = this->off();
     }
-    
+
     return(retVal);
+}
+
+char* Thermostat::getStrStatus(){
+    return(this->_strStatus);
 }
\ No newline at end of file