Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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);
}