mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-20 20:22:08 +02:00
Update show PM compensate value on display and documents
This commit is contained in:
@ -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}` |
|
| `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}` |
|
| `tvocLearningOffset` | Set VOC learning gain offset. | Number | 0-720 (default 12) | `{"tvocLearningOffset": 12}` |
|
||||||
| `offlineMode` | Set monitor to run without WiFi. | Boolean | `false`: Disabled (default) <br> `true`: Enabled | `{"offlineMode": true}` |
|
| `offlineMode` | Set monitor to run without WiFi. | Boolean | `false`: Disabled (default) <br> `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) <br> `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) <br> `true`: with compensate | `{"monitorDisplayCompensatedValues": false }` |
|
||||||
|
@ -11,35 +11,29 @@
|
|||||||
* @param hasStatus
|
* @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)) {
|
if (utils::isValidTemperature(value.Temperature)) {
|
||||||
float t = 0.0f;
|
float t = 0.0f;
|
||||||
if(ag->isOpenAir() && config.isMonitorDisplayCompensatedValues()) {
|
|
||||||
if (config.isTemperatureUnitInF()) {
|
if (config.isTemperatureUnitInF()) {
|
||||||
/** Compensate temperature */
|
t = utils::degreeC_To_F(value.Temperature);
|
||||||
t = ag->pms5003t_1.compensateTemp(value.Temperature);
|
|
||||||
/** Convert C to F */
|
|
||||||
t = (t * 9)/5.0f + 32.0f;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
|
t = value.Temperature;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (config.isTemperatureUnitInF()) {
|
if (config.isTemperatureUnitInF()) {
|
||||||
float tempF = (value.Temperature * 9) / 5 + 32;
|
|
||||||
if (hasStatus) {
|
if (hasStatus) {
|
||||||
snprintf(buf, buf_size, "%0.1f", tempF);
|
snprintf(buf, buf_size, "%0.1f", t);
|
||||||
} else {
|
} else {
|
||||||
snprintf(buf, buf_size, "%0.1f°F", tempF);
|
snprintf(buf, buf_size, "%0.1f°F", t);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (hasStatus) {
|
if (hasStatus) {
|
||||||
snprintf(buf, buf_size, "%.1f", value.Temperature);
|
snprintf(buf, buf_size, "%.1f", t);
|
||||||
} else {
|
} else {
|
||||||
snprintf(buf, buf_size, "%.1f°C", value.Temperature);
|
snprintf(buf, buf_size, "%.1f°C", t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else { /** Show invalid value */
|
||||||
if (config.isTemperatureUnitInF()) {
|
if (config.isTemperatureUnitInF()) {
|
||||||
snprintf(buf, buf_size, "-°F");
|
snprintf(buf, buf_size, "-°F");
|
||||||
} else {
|
} else {
|
||||||
@ -48,7 +42,7 @@ void OledDisplay::showTempHum(bool hasStatus, char* buf, int buf_size) {
|
|||||||
}
|
}
|
||||||
DISP()->drawUTF8(1, 10, buf);
|
DISP()->drawUTF8(1, 10, buf);
|
||||||
|
|
||||||
/** Show humidty */
|
/** Show humidity */
|
||||||
if (utils::isValidHumidity(value.Humidity)) {
|
if (utils::isValidHumidity(value.Humidity)) {
|
||||||
snprintf(buf, buf_size, "%d%%", value.Humidity);
|
snprintf(buf, buf_size, "%d%%", value.Humidity);
|
||||||
} else {
|
} else {
|
||||||
@ -318,21 +312,25 @@ void OledDisplay::showDashboard(const char *status) {
|
|||||||
/** Draw PM2.5 value */
|
/** Draw PM2.5 value */
|
||||||
if (utils::isValidPm(value.pm25_1)) {
|
if (utils::isValidPm(value.pm25_1)) {
|
||||||
int pm25 = value.pm25_1;
|
int pm25 = value.pm25_1;
|
||||||
if (config.isPmStandardInUSAQI() &&
|
|
||||||
config.isMonitorDisplayCompensatedValues()) {
|
/** Compensate PM2.5 value. */
|
||||||
if (config.hasSensorSHT) {
|
if (config.hasSensorSHT && config.isMonitorDisplayCompensatedValues()) {
|
||||||
pm25 = ag->pms5003.compensate(pm25, value.Humidity);
|
pm25 = ag->pms5003.compensate(pm25, value.Humidity);
|
||||||
|
logInfo("PM2.5 compensate: " + String(pm25));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.isPmStandardInUSAQI()) {
|
||||||
sprintf(strBuf, "%d", ag->pms5003.convertPm25ToUsAqi(pm25));
|
sprintf(strBuf, "%d", ag->pms5003.convertPm25ToUsAqi(pm25));
|
||||||
} else {
|
} else {
|
||||||
sprintf(strBuf, "%d", pm25);
|
sprintf(strBuf, "%d", pm25);
|
||||||
}
|
}
|
||||||
} else {
|
} else { /** Show invalid value. */
|
||||||
sprintf(strBuf, "%s", "-");
|
sprintf(strBuf, "%s", "-");
|
||||||
}
|
}
|
||||||
DISP()->setFont(u8g2_font_t0_22b_tf);
|
DISP()->setFont(u8g2_font_t0_22b_tf);
|
||||||
DISP()->drawStr(55, 48, strBuf);
|
DISP()->drawStr(55, 48, strBuf);
|
||||||
|
|
||||||
|
/** Draw PM2.5 unit */
|
||||||
DISP()->setFont(u8g2_font_t0_12_tf);
|
DISP()->setFont(u8g2_font_t0_12_tf);
|
||||||
if (config.isPmStandardInUSAQI()) {
|
if (config.isPmStandardInUSAQI()) {
|
||||||
DISP()->drawUTF8(55, 61, "AQI");
|
DISP()->drawUTF8(55, 61, "AQI");
|
||||||
@ -379,6 +377,7 @@ void OledDisplay::showDashboard(const char *status) {
|
|||||||
if (config.hasSensorSHT && config.isMonitorDisplayCompensatedValues()) {
|
if (config.hasSensorSHT && config.isMonitorDisplayCompensatedValues()) {
|
||||||
pm25 = (int)ag->pms5003.compensate(pm25, value.Humidity);
|
pm25 = (int)ag->pms5003.compensate(pm25, value.Humidity);
|
||||||
}
|
}
|
||||||
|
|
||||||
ag->display.setCursor(0, 12);
|
ag->display.setCursor(0, 12);
|
||||||
if (utils::isValidPm(pm25)) {
|
if (utils::isValidPm(pm25)) {
|
||||||
snprintf(strBuf, sizeof(strBuf), "PM2.5:%d", pm25);
|
snprintf(strBuf, sizeof(strBuf), "PM2.5:%d", pm25);
|
||||||
@ -390,8 +389,8 @@ void OledDisplay::showDashboard(const char *status) {
|
|||||||
/** Set temperature and humidity */
|
/** Set temperature and humidity */
|
||||||
if (utils::isValidTemperature(value.Temperature)) {
|
if (utils::isValidTemperature(value.Temperature)) {
|
||||||
if (config.isTemperatureUnitInF()) {
|
if (config.isTemperatureUnitInF()) {
|
||||||
float tempF = (value.Temperature * 9) / 5 + 32;
|
snprintf(strBuf, sizeof(strBuf), "T:%0.1f F",
|
||||||
snprintf(strBuf, sizeof(strBuf), "T:%0.1f F", tempF);
|
utils::degreeC_To_F(value.Temperature));
|
||||||
} else {
|
} else {
|
||||||
snprintf(strBuf, sizeof(strBuf), "T:%0.f1 C", value.Temperature);
|
snprintf(strBuf, sizeof(strBuf), "T:%0.f1 C", value.Temperature);
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,11 @@ void StateMachine::co2handleLeds(void) {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void StateMachine::pm25handleLeds(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) {
|
if (pm25Value < 5) {
|
||||||
/** G; 1 */
|
/** G; 1 */
|
||||||
ag->ledBar.setColor(RGB_COLOR_G, ag->ledBar.getNumberOfLeds() - 1);
|
ag->ledBar.setColor(RGB_COLOR_G, ag->ledBar.getNumberOfLeds() - 1);
|
||||||
|
Reference in New Issue
Block a user