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.
Diff: Thermostat.cpp
- Revision:
- 2:ed17e258da0d
- Child:
- 5:4cbe44452889
diff -r f448c12d2c5b -r ed17e258da0d Thermostat.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Thermostat.cpp Tue Jun 14 09:14:24 2016 +0000
@@ -0,0 +1,49 @@
+/*
+* 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);
+}
\ No newline at end of file