[hm3301] Updated the AQI based on the airnow document (#6004)

This commit is contained in:
optimusprimespace 2024-04-28 21:22:14 +02:00 committed by GitHub
parent 76c55992ae
commit 0ef7781bb3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,6 +1,7 @@
#pragma once #pragma once
#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
namespace esphome { namespace esphome {
namespace hm3301 { namespace hm3301 {
@ -15,14 +16,16 @@ class AQICalculator : public AbstractAQICalculator {
} }
protected: protected:
static const int AMOUNT_OF_LEVELS = 6; static const int AMOUNT_OF_LEVELS = 7;
int index_grid_[AMOUNT_OF_LEVELS][2] = {{0, 51}, {51, 100}, {101, 150}, {151, 200}, {201, 300}, {301, 500}}; int index_grid_[AMOUNT_OF_LEVELS][2] = {{0, 50}, {51, 100}, {101, 150}, {151, 200},
{201, 300}, {301, 400}, {401, 500}};
int pm2_5_calculation_grid_[AMOUNT_OF_LEVELS][2] = {{0, 12}, {13, 35}, {36, 55}, {56, 150}, {151, 250}, {251, 500}}; int pm2_5_calculation_grid_[AMOUNT_OF_LEVELS][2] = {{0, 12}, {13, 35}, {36, 55}, {56, 150},
{151, 250}, {251, 350}, {351, 500}};
int pm10_0_calculation_grid_[AMOUNT_OF_LEVELS][2] = {{0, 54}, {55, 154}, {155, 254}, int pm10_0_calculation_grid_[AMOUNT_OF_LEVELS][2] = {{0, 54}, {55, 154}, {155, 254}, {255, 354},
{255, 354}, {355, 424}, {425, 604}}; {355, 424}, {425, 504}, {505, 604}};
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);