Display also humidity and pressure

Display update triggered by value change, not interval
This commit is contained in:
cryptogopher
2026-02-12 00:10:45 +01:00
parent 0c9a7a51d9
commit c2af98d588
5 changed files with 116 additions and 33 deletions

View File

@@ -1,23 +1,50 @@
#include "Seeed_BME280.h"
enum {
LOWER = 0,
HIGHER
};
BME280 sensor;
float highTemp = 0.0, lowTemp = 0.0;
const float blindZone = 0.03;
float bounds[2][SENSORS] = {};
const float hysteresisWidth[SENSORS] = {0.03, 0.5, 0.5};
void initBME280() {
sensor.init();
}
void readTemperature() {
float newTemperature = sensor.getTemperature();
void readSensors() {
float newValue;
if (newTemperature > highTemp) {
temperature = newTemperature;
highTemp = newTemperature;
lowTemp = highTemp - blindZone;
} else if (newTemperature < lowTemp) {
temperature = newTemperature;
lowTemp = newTemperature;
highTemp = lowTemp + blindZone;
for (uint i = 0; i < SENSORS; i++) {
switch (i) {
case TEMPERATURE:
newValue = sensor.getTemperature();
break;
case HUMIDITY:
newValue = sensor.getHumidity();
break;
case PRESSURE:
newValue = sensor.getPressure();
break;
}
if (newValue > bounds[HIGHER][i]) {
sensorValue[i] = newValue;
bounds[HIGHER][i] = newValue;
bounds[LOWER][i] = bounds[HIGHER][i] - hysteresisWidth[i];
if ((countdown <= 0) && (displaySensor == i)) {
displayNeedsUpdate = true;
}
} else if (newValue < bounds[LOWER][i]) {
sensorValue[i] = newValue;
bounds[LOWER][i] = newValue;
bounds[HIGHER][i] = bounds[LOWER][i] + hysteresisWidth[i];
if ((countdown <= 0) && (displaySensor == i)) {
displayNeedsUpdate = true;
}
};
};
}