two modes if no humidity sensor available
This commit is contained in:
parent
92e7089aef
commit
4a7a929dbc
@ -5,12 +5,44 @@
|
|||||||
#include "Heating.h"
|
#include "Heating.h"
|
||||||
#include "Pins.h"
|
#include "Pins.h"
|
||||||
|
|
||||||
void Heating::init(Temperature *tempsensor) {
|
void Heating::init(Temperature *tempsensor, unsigned mode) {
|
||||||
|
switch (mode) {
|
||||||
|
case TIME: {
|
||||||
|
const unsigned percentOn = 20;
|
||||||
|
const unsigned refreshperiod = 60;
|
||||||
|
|
||||||
|
const auto func = [this]() {
|
||||||
|
mLuefterTicker.detach();
|
||||||
|
|
||||||
|
// every minute turn on the heating
|
||||||
|
digitalWrite(LuefterPin, HIGH);
|
||||||
|
digitalWrite(HeizungPin, HIGH);
|
||||||
|
|
||||||
|
Serial.println("Turning on heating");
|
||||||
|
|
||||||
|
mTurnOffTicker.once(refreshperiod * percentOn / 100, []() {
|
||||||
|
digitalWrite(HeizungPin, LOW);
|
||||||
|
|
||||||
|
Serial.println("Turned off heating!");
|
||||||
|
});
|
||||||
|
|
||||||
|
mLuefterTicker.once((refreshperiod * percentOn / 100) + 30, []() {
|
||||||
|
digitalWrite(LuefterPin, LOW);
|
||||||
|
|
||||||
|
Serial.println("Turned off fan!");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
func();
|
||||||
|
mHeizungTicker.attach(60, func);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case HUMIDITY:
|
||||||
mFanWaiting = false;
|
mFanWaiting = false;
|
||||||
|
|
||||||
mHeizungTicker.attach(10, [&tempsensor, this]() {
|
mHeizungTicker.attach(10, [&tempsensor, this]() {
|
||||||
// shedule this function because tempread is blocking
|
// shedule this function because tempread is blocking
|
||||||
schedule_function([this, &tempsensor](){
|
schedule_function([this, &tempsensor]() {
|
||||||
// check temperature
|
// check temperature
|
||||||
Serial.println("checking humidity");
|
Serial.println("checking humidity");
|
||||||
const float hum = tempsensor->getHum();
|
const float hum = tempsensor->getHum();
|
||||||
@ -47,4 +79,8 @@ void Heating::init(Temperature *tempsensor) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,10 +9,13 @@
|
|||||||
|
|
||||||
class Heating {
|
class Heating {
|
||||||
public:
|
public:
|
||||||
void init(Temperature* tempsensor);
|
void init(Temperature* tempsensor, unsigned mode);
|
||||||
|
|
||||||
|
enum MODES {TIME, HUMIDITY};
|
||||||
private:
|
private:
|
||||||
Ticker mHeizungTicker;
|
Ticker mHeizungTicker;
|
||||||
Ticker mLuefterTicker;
|
Ticker mLuefterTicker;
|
||||||
|
Ticker mTurnOffTicker;
|
||||||
|
|
||||||
bool mFanWaiting;
|
bool mFanWaiting;
|
||||||
};
|
};
|
||||||
|
@ -189,7 +189,7 @@ void setup() {
|
|||||||
mang.init(&temp);
|
mang.init(&temp);
|
||||||
|
|
||||||
Serial.println("initializing heating service");
|
Serial.println("initializing heating service");
|
||||||
mHeat.init(&temp);
|
mHeat.init(&temp, Heating::TIME);
|
||||||
|
|
||||||
Serial.println("startup sequence complete!\n");
|
Serial.println("startup sequence complete!\n");
|
||||||
digitalWrite(LED_BUILTIN, HIGH);
|
digitalWrite(LED_BUILTIN, HIGH);
|
||||||
|
Loading…
Reference in New Issue
Block a user