Mario Simaremare / Mbed 2 deprecated g3_waterplay

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Thermostat.cpp Source File

Thermostat.cpp

00001 /*
00002 * G3: WATERPLAY
00003 */
00004 
00005 #include "Thermostat.h"
00006 #include "mbed.h"
00007 
00008 Thermostat::Thermostat(
00009     Printer &printer,
00010     PinName pin,
00011     PinName led_pin
00012 ):
00013     _printer(printer),
00014     _analog_out(pin),
00015     _led(led_pin),
00016     _status(STATUS_OFF),
00017     _strStatus("Thermostat: OFF\n\r")
00018 {
00019 }
00020 
00021 int Thermostat::update()
00022 {
00023     this->_analog_out = this->_status;
00024     this->_led = this->_status;
00025 
00026     return(this->_status);
00027 }
00028 
00029 int Thermostat::on()
00030 {
00031     this->_status = STATUS_ON;
00032     this->_strStatus = "Thermostat: ON\n\r";
00033     return(this->_status);
00034 }
00035 
00036 int Thermostat::off()
00037 {
00038     this->_status = STATUS_OFF;
00039     this->_strStatus = "Thermostat: OFF\n\r";
00040     return(this->_status);
00041 }
00042 
00043 int Thermostat::react(double temperature)
00044 {
00045     int retVal = 0;
00046 
00047     if(temperature < 0.0) {
00048         retVal = this->on();
00049     } else {
00050         retVal = this->off();
00051     }
00052     this->update();
00053 
00054     return(retVal);
00055 }
00056 
00057 char* Thermostat::getStrStatus()
00058 {
00059     return(this->_strStatus);
00060 }