ok

Dependencies:   mbed

Fork of g3_waterplay by Mario Simaremare

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 {
00018 }
00019 
00020 int Thermostat::update(){
00021     this->_analog_out = this->_status;
00022     this->_led = this->_status;
00023     
00024     return(this->_status);
00025 }
00026 
00027 int Thermostat::on()
00028 {
00029     this->_status = STATUS_ON;
00030     this->_strStatus = "Thermostat: ON\n\r";
00031     return(this->_status);
00032 }
00033 
00034 int Thermostat::off()
00035 {
00036     this->_status = STATUS_OFF;
00037     this->_strStatus = "Thermostat: OFF\n\r";
00038     return(this->_status);
00039 }
00040 
00041 int Thermostat::react(double temperature)
00042 {
00043     int retVal = 0;
00044 
00045     if(temperature < 0.0) {
00046         retVal = this->on();
00047     } else {
00048         retVal = this->off();
00049     }
00050 
00051     return(retVal);
00052 }
00053 
00054 char* Thermostat::getStrStatus(){
00055     return(this->_strStatus);
00056 }