From 11f84d4f7273d8abf4874bbdb4f18c90f93f3a01 Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Tue, 30 Jul 2019 01:54:32 +0200 Subject: [PATCH] display values from mqtt --- src/main.cpp | 55 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 8 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index e20ecb6..07ddd4e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -232,7 +232,7 @@ void displayValues() { display.print("Humidity"); display.setFont(&FreeSansBold9pt7b); display.setCursor(70,y_offset+40); - display.printf("%.1f %", sensor_readings.humidity); + display.printf("%.1f", sensor_readings.humidity); // Pressure display.drawRect(130,y_offset+10,66,50,GxEPD_BLACK); @@ -241,7 +241,7 @@ void displayValues() { display.print("Pressure"); display.setFont(&FreeSansBold9pt7b); display.setCursor(135,y_offset+40); - display.printf("%.1f\%", sensor_readings.pressure / 100.0F); + display.printf("%.1f", sensor_readings.pressure / 100.0F); // Other display.drawRect(195,y_offset+10,56,122-10,GxEPD_BLACK); @@ -250,23 +250,62 @@ void displayValues() { display.setCursor(200,y_offset+15); display.println("VOC:"); display.setCursor(200,y_offset+25); - display.printf("%.1f %", sensor_readings.voc); + display.printf("%.1f", sensor_readings.voc / 1000.0F); // PM + float pm10, pm25; + if (sds_active) { + pm10 = sensor_readings.pm10; + pm25 = sensor_readings.pm25; + } else if (std::isnormal(sensors_a4cf1211c3e4.pm10) || std::isnormal(sensors_a4cf1211c3e4.pm25)) { + pm10 = sensors_a4cf1211c3e4.pm10; + pm25 = sensors_a4cf1211c3e4.pm25; + } else if (std::isnormal(sensors_246f28d1fa5c.pm10) || std::isnormal(sensors_246f28d1fa5c.pm25)) { + pm10 = sensors_246f28d1fa5c.pm10; + pm25 = sensors_246f28d1fa5c.pm25; + } else if (std::isnormal(sensors_246f28d1a080.pm10) || std::isnormal(sensors_246f28d1a080.pm25)) { + pm10 = sensors_246f28d1a080.pm10; + pm25 = sensors_246f28d1a080.pm25; + } else { + pm10 = 0.0; + pm25 = 0.0; + } display.setCursor(200,y_offset+45); display.println("PM10 / 2.5:"); display.setCursor(200,y_offset+55); - display.printf("%.1f %", sensor_readings.pm10); + display.printf("%.1f", pm10); display.setCursor(200,y_offset+65); - display.printf("%.1f %", sensor_readings.pm25); + display.printf("%.1f", pm25); // UV + float uvi, uva, uvb; + if (uv_active) { + uvi = sensor_readings.uvi; + uva = sensor_readings.uva; + uvb = sensor_readings.uvb; + } else if (std::isnormal(sensors_a4cf1211c3e4.uvi) || std::isnormal(sensors_a4cf1211c3e4.uva) || std::isnormal(sensors_a4cf1211c3e4.uvb)) { + uvi = sensors_a4cf1211c3e4.uvi; + uva = sensors_a4cf1211c3e4.uva; + uvb = sensors_a4cf1211c3e4.uvb; + } else if (std::isnormal(sensors_246f28d1fa5c.uvi) || std::isnormal(sensors_246f28d1fa5c.uva) || std::isnormal(sensors_246f28d1fa5c.uvb)) { + uvi = sensors_246f28d1fa5c.uvi; + uva = sensors_246f28d1fa5c.uva; + uvb = sensors_246f28d1fa5c.uvb; + } else if (std::isnormal(sensors_246f28d1a080.uvi) || std::isnormal(sensors_246f28d1a080.uva) || std::isnormal(sensors_246f28d1a080.uvb)) { + uvi = sensors_246f28d1a080.uvi; + uva = sensors_246f28d1a080.uva; + uvb = sensors_246f28d1a080.uvb; + } else { + uvi = 0.0; + uva = 0.0; + uvb = 0.0; + } display.setCursor(200,y_offset+85); display.println("UV Index/A/B:"); display.setCursor(200,y_offset+95); - display.printf("%.1f %", sensor_readings.uvi); + display.printf("%.1f", uvi); display.setCursor(200,y_offset+105); - display.printf("%.1f %", sensor_readings.uva); + display.printf("%.1f", uva); display.setCursor(200,y_offset+115); - display.printf("%.1f %", sensor_readings.uvb); + display.printf("%.1f", uvb); // other nodes display.setFont(NULL);