diff --git a/docs/local-server.md b/docs/local-server.md index 25cab52..68582b9 100644 --- a/docs/local-server.md +++ b/docs/local-server.md @@ -130,4 +130,4 @@ If the monitor is set up on the AirGradient dashboard, it will also receive conf | `noxLearningOffset` | Set NOx learning gain offset. | Number | 0-720 (default 12) | `{"noxLearningOffset": 12}` | | `tvocLearningOffset` | Set VOC learning gain offset. | Number | 0-720 (default 12) | `{"tvocLearningOffset": 12}` | | `offlineMode` | Set monitor to run without WiFi. | Boolean | `false`: Disabled (default)
`true`: Enabled | `{"offlineMode": true}` | -| `monitorDisplayCompensatedValues` | Set the display show the PM value with/without compensate value (From [3.1.8]()) | Boolean | `false`: Without compensate (default)
`true`: with compensate | `{"monitorDisplayCompensatedValues": false }` | +| `monitorDisplayCompensatedValues` | Set the display show the PM value with/without compensate value (From [3.1.9]()) | Boolean | `false`: Without compensate (default)
`true`: with compensate | `{"monitorDisplayCompensatedValues": false }` | diff --git a/src/AgOledDisplay.cpp b/src/AgOledDisplay.cpp index 2a18d59..451da32 100644 --- a/src/AgOledDisplay.cpp +++ b/src/AgOledDisplay.cpp @@ -10,36 +10,30 @@ * * @param hasStatus */ -void OledDisplay::showTempHum(bool hasStatus, char* buf, int buf_size) { +void OledDisplay::showTempHum(bool hasStatus, char *buf, int buf_size) { + /** Temperature */ if (utils::isValidTemperature(value.Temperature)) { float t = 0.0f; - if(ag->isOpenAir() && config.isMonitorDisplayCompensatedValues()) { - if(config.isTemperatureUnitInF()) { - /** Compensate temperature */ - t = ag->pms5003t_1.compensateTemp(value.Temperature); - /** Convert C to F */ - t = (t * 9)/5.0f + 32.0f; - } + if (config.isTemperatureUnitInF()) { + t = utils::degreeC_To_F(value.Temperature); } else { - + t = value.Temperature; } - if (config.isTemperatureUnitInF()) { - float tempF = (value.Temperature * 9) / 5 + 32; if (hasStatus) { - snprintf(buf, buf_size, "%0.1f", tempF); + snprintf(buf, buf_size, "%0.1f", t); } else { - snprintf(buf, buf_size, "%0.1f°F", tempF); + snprintf(buf, buf_size, "%0.1f°F", t); } } else { if (hasStatus) { - snprintf(buf, buf_size, "%.1f", value.Temperature); + snprintf(buf, buf_size, "%.1f", t); } else { - snprintf(buf, buf_size, "%.1f°C", value.Temperature); + snprintf(buf, buf_size, "%.1f°C", t); } } - } else { + } else { /** Show invalid value */ if (config.isTemperatureUnitInF()) { snprintf(buf, buf_size, "-°F"); } else { @@ -48,7 +42,7 @@ void OledDisplay::showTempHum(bool hasStatus, char* buf, int buf_size) { } DISP()->drawUTF8(1, 10, buf); - /** Show humidty */ + /** Show humidity */ if (utils::isValidHumidity(value.Humidity)) { snprintf(buf, buf_size, "%d%%", value.Humidity); } else { @@ -318,21 +312,25 @@ void OledDisplay::showDashboard(const char *status) { /** Draw PM2.5 value */ if (utils::isValidPm(value.pm25_1)) { int pm25 = value.pm25_1; - if (config.isPmStandardInUSAQI() && - config.isMonitorDisplayCompensatedValues()) { - if (config.hasSensorSHT) { - pm25 = ag->pms5003.compensate(pm25, value.Humidity); - } + + /** Compensate PM2.5 value. */ + if (config.hasSensorSHT && config.isMonitorDisplayCompensatedValues()) { + pm25 = ag->pms5003.compensate(pm25, value.Humidity); + logInfo("PM2.5 compensate: " + String(pm25)); + } + + if (config.isPmStandardInUSAQI()) { sprintf(strBuf, "%d", ag->pms5003.convertPm25ToUsAqi(pm25)); } else { sprintf(strBuf, "%d", pm25); } - } else { + } else { /** Show invalid value. */ sprintf(strBuf, "%s", "-"); } DISP()->setFont(u8g2_font_t0_22b_tf); DISP()->drawStr(55, 48, strBuf); + /** Draw PM2.5 unit */ DISP()->setFont(u8g2_font_t0_12_tf); if (config.isPmStandardInUSAQI()) { DISP()->drawUTF8(55, 61, "AQI"); @@ -379,6 +377,7 @@ void OledDisplay::showDashboard(const char *status) { if (config.hasSensorSHT && config.isMonitorDisplayCompensatedValues()) { pm25 = (int)ag->pms5003.compensate(pm25, value.Humidity); } + ag->display.setCursor(0, 12); if (utils::isValidPm(pm25)) { snprintf(strBuf, sizeof(strBuf), "PM2.5:%d", pm25); @@ -390,8 +389,8 @@ void OledDisplay::showDashboard(const char *status) { /** Set temperature and humidity */ if (utils::isValidTemperature(value.Temperature)) { if (config.isTemperatureUnitInF()) { - float tempF = (value.Temperature * 9) / 5 + 32; - snprintf(strBuf, sizeof(strBuf), "T:%0.1f F", tempF); + snprintf(strBuf, sizeof(strBuf), "T:%0.1f F", + utils::degreeC_To_F(value.Temperature)); } else { snprintf(strBuf, sizeof(strBuf), "T:%0.f1 C", value.Temperature); } diff --git a/src/AgStateMachine.cpp b/src/AgStateMachine.cpp index f2e6105..8cc0372 100644 --- a/src/AgStateMachine.cpp +++ b/src/AgStateMachine.cpp @@ -141,7 +141,11 @@ void StateMachine::co2handleLeds(void) { * */ void StateMachine::pm25handleLeds(void) { - int pm25Value = ag->pms5003.compensate(value.pm25_1, value.Humidity); + int pm25Value = value.pm25_1; + if (config.isMonitorDisplayCompensatedValues() && config.hasSensorSHT) { + pm25Value = ag->pms5003.compensate(value.pm25_1, value.Humidity); + } + if (pm25Value < 5) { /** G; 1 */ ag->ledBar.setColor(RGB_COLOR_G, ag->ledBar.getNumberOfLeds() - 1);