Fix issue in lastUpdate logic and implement some more debug output

This commit is contained in:
bzi 2019-03-08 20:20:34 +01:00
parent 828877e0fb
commit ac81705a29

View File

@ -114,11 +114,17 @@ long lastMsg = 0;
void publish (Sensor &sensor){ void publish (Sensor &sensor){
bool force = false; bool force = false;
Serial.println("Sample " + sensor.desc + ": " + String(sensor.value).c_str()); Serial.print("Sample " + sensor.desc + " : ");
Serial.print(String(sensor.value).c_str());
Serial.print(" last : ");
Serial.print(String(sensor.lastValue).c_str());
Serial.print(" samples since last update : ");
Serial.println(String(sensor.lastUpdate).c_str());
// check if first sample, set lastValue and return // check if first sample, set lastValue and return
if (sensor.lastUpdate == -1){ if (sensor.lastUpdate == -1){
sensor.lastValue = sensor.value; sensor.lastValue = sensor.value;
sensor.lastUpdate = 0;
return; return;
} }