1
0
mirror of https://github.com/revspace/operame synced 2024-10-31 21:47:30 +00:00

Add check on CO2 levels (<330, <400, >400)

This commit is contained in:
Pieter De Mil 2022-04-20 17:47:43 +02:00
parent 49d05af75e
commit 5bd075e078

View File

@ -147,6 +147,13 @@ void display_logo() {
sprite.pushSprite(0, 0); sprite.pushSprite(0, 0);
} }
void display_cal() {
int fg, bg;
fg = TFT_WHITE;
bg = TFT_BLACK;
display_big(String("E 01"), fg, bg);
}
void display_ppm(int ppm) { void display_ppm(int ppm) {
int fg, bg; int fg, bg;
if (ppm >= co2_critical) { if (ppm >= co2_critical) {
@ -595,13 +602,36 @@ void loop() {
if (isnan(h) || isnan(t)) { if (isnan(h) || isnan(t)) {
// Only display CO2 value (the old way) // Only display CO2 value (the old way)
// some MH-Z19's go to 10000 but the display has space for 4 digits // some MH-Z19's go to 10000 but the display has space for 4 digits
if(co2 < 330 )
{
display_cal();
}
else if(co2 < 400)
{
display_ppm(co2 < 399 ? 399 : co2);
}
else if(co2 >= 400)
{
display_ppm(co2 > 9999 ? 9999 : co2); display_ppm(co2 > 9999 ? 9999 : co2);
}
} else { } else {
if(co2 < 330)
{
display_cal();
}
else if(co2 < 400)
{
display_ppm_t_h(co2 < 399 ? 399 : co2, t, h);
}
// Display also humidity and temperature // Display also humidity and temperature
else if(co2 >= 400)
{
display_ppm_t_h(co2 > 9999 ? 9999 : co2, t, h); display_ppm_t_h(co2 > 9999 ? 9999 : co2, t, h);
} }
} }
} }
}
if (mqtt_enabled) { if (mqtt_enabled) {
mqtt.loop(); mqtt.loop();