mirror of
https://github.com/esphome/esphome.git
synced 2025-11-19 08:15:49 +00:00
Updated AQI calculation for HM3301 to the new standard (#9442)
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
committed by
GitHub
parent
c77bb3b269
commit
f55c872180
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include <climits>
|
||||||
#include "abstract_aqi_calculator.h"
|
#include "abstract_aqi_calculator.h"
|
||||||
// https://www.airnow.gov/sites/default/files/2020-05/aqi-technical-assistance-document-sept2018.pdf
|
// https://document.airnow.gov/technical-assistance-document-for-the-reporting-of-daily-air-quailty.pdf
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace hm3301 {
|
namespace hm3301 {
|
||||||
@@ -16,16 +16,15 @@ class AQICalculator : public AbstractAQICalculator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static const int AMOUNT_OF_LEVELS = 7;
|
static const int AMOUNT_OF_LEVELS = 6;
|
||||||
|
|
||||||
int index_grid_[AMOUNT_OF_LEVELS][2] = {{0, 50}, {51, 100}, {101, 150}, {151, 200},
|
int index_grid_[AMOUNT_OF_LEVELS][2] = {{0, 50}, {51, 100}, {101, 150}, {151, 200}, {201, 300}, {301, 500}};
|
||||||
{201, 300}, {301, 400}, {401, 500}};
|
|
||||||
|
|
||||||
int pm2_5_calculation_grid_[AMOUNT_OF_LEVELS][2] = {{0, 12}, {13, 35}, {36, 55}, {56, 150},
|
int pm2_5_calculation_grid_[AMOUNT_OF_LEVELS][2] = {{0, 9}, {10, 35}, {36, 55},
|
||||||
{151, 250}, {251, 350}, {351, 500}};
|
{56, 125}, {126, 225}, {226, INT_MAX}};
|
||||||
|
|
||||||
int pm10_0_calculation_grid_[AMOUNT_OF_LEVELS][2] = {{0, 54}, {55, 154}, {155, 254}, {255, 354},
|
int pm10_0_calculation_grid_[AMOUNT_OF_LEVELS][2] = {{0, 54}, {55, 154}, {155, 254},
|
||||||
{355, 424}, {425, 504}, {505, 604}};
|
{255, 354}, {355, 424}, {425, INT_MAX}};
|
||||||
|
|
||||||
int calculate_index_(uint16_t value, int array[AMOUNT_OF_LEVELS][2]) {
|
int calculate_index_(uint16_t value, int array[AMOUNT_OF_LEVELS][2]) {
|
||||||
int grid_index = get_grid_index_(value, array);
|
int grid_index = get_grid_index_(value, array);
|
||||||
|
|||||||
Reference in New Issue
Block a user