Mario Simaremare / Mbed 2 deprecated g3_waterplay

Dependencies:   mbed

Thermostat.cpp

Committer:
mariosimaremare
Date:
2016-06-14
Revision:
2:ed17e258da0d
Child:
5:4cbe44452889

File content as of revision 2:ed17e258da0d:

/*
* 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);
}