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-24
- Revision:
- 14:6c24cab82ff0
- Parent:
- 13:142a142a7ac5
File content as of revision 14:6c24cab82ff0:
/*
* G3: WATERPLAY
*/
#include "Thermostat.h"
#include "mbed.h"
Thermostat::Thermostat(
Printer &printer,
PinName pin,
PinName led_pin
):
_printer(printer),
_analog_out(pin),
_led(led_pin),
_status(STATUS_OFF),
_strStatus("Thermostat: OFF\n\r")
{
}
int Thermostat::update()
{
this->_analog_out = this->_status;
this->_led = this->_status;
return(this->_status);
}
int Thermostat::on()
{
this->_status = STATUS_ON;
this->_strStatus = "Thermostat: ON\n\r";
return(this->_status);
}
int Thermostat::off()
{
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) {
retVal = this->on();
} else {
retVal = this->off();
}
this->update();
return(retVal);
}
char* Thermostat::getStrStatus()
{
return(this->_strStatus);
}