heating logic

This commit is contained in:
Martin Brodbeck 2022-05-31 13:01:10 +02:00
parent 7ca6b69f9d
commit 8b58b3a443

View file

@ -5,6 +5,7 @@
#include "hardware/i2c.h" #include "hardware/i2c.h"
#include "pico/stdlib.h" #include "pico/stdlib.h"
#include "config.h"
#include "ds18b20.h" #include "ds18b20.h"
#include "lcd.h" #include "lcd.h"
@ -28,21 +29,38 @@ int main() {
float temp_act{0}; float temp_act{0};
float temp_tgt{28.0}; float temp_tgt{28.0};
float temp_diff{0.5};
std::stringstream lcdText{}; std::stringstream lcdText{};
bool isHeating = false; bool isHeating = false;
bool isSystemOn = false;
string heatInfo{" "}; string heatInfo{" "};
string systemInfo{"OFF"}; string systemInfo{"OFF"};
lcdText << " G" << CUSTOM_CHAR_AE << "rbox Manager\n (Ver. "
<< PROJECT_VERSION << ")";
myLCD.sendString(lcdText.str());
sleep_ms(3000);
while (true) { while (true) {
// ds.convert(); // ds.convert();
sleep_ms(750); sleep_ms(750);
// temp_act = ds.getTemperature(); // temp_act = ds.getTemperature();
temp_act = 23.5; temp_act = 23.5;
if (isSystemOn && temp_act < temp_tgt - temp_diff) {
isHeating = true;
} else if (isSystemOn && temp_act > temp_tgt + temp_diff) {
isHeating = false;
} else if (!isSystemOn) {
isHeating = false;
}
isHeating ? heatInfo = ">H<" : heatInfo = " ";
lcdText.str(""); lcdText.str("");
lcdText.clear(); lcdText.clear();
lcdText.precision(4); lcdText.precision(4);
lcdText << "ACT: " << temp_act << CUSTOM_CHAR_DEG << "C " << heatInfo << "\n" lcdText << "ACT: " << temp_act << CUSTOM_CHAR_DEG << "C " << heatInfo
<< "\n"
<< "TGT: " << temp_tgt << CUSTOM_CHAR_DEG << "C " << systemInfo; << "TGT: " << temp_tgt << CUSTOM_CHAR_DEG << "C " << systemInfo;
myLCD.setCursor(0, 0); myLCD.setCursor(0, 0);