mirror of
https://github.com/esphome/esphome.git
synced 2024-12-18 15:57:58 +01:00
Fix HM3301 AQI index calculator (#2739)
This commit is contained in:
parent
dbcfa7b599
commit
0469e19f54
@ -33,7 +33,7 @@ class AQICalculator : public AbstractAQICalculator {
|
|||||||
int conc_lo = array[grid_index][0];
|
int conc_lo = array[grid_index][0];
|
||||||
int conc_hi = array[grid_index][1];
|
int conc_hi = array[grid_index][1];
|
||||||
|
|
||||||
return ((aqi_hi - aqi_lo) / (conc_hi - conc_lo)) * (value - conc_lo) + aqi_lo;
|
return (value - conc_lo) * (aqi_hi - aqi_lo) / (conc_hi - conc_lo) + aqi_lo;
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_grid_index_(uint16_t value, int array[AMOUNT_OF_LEVELS][2]) {
|
int get_grid_index_(uint16_t value, int array[AMOUNT_OF_LEVELS][2]) {
|
||||||
|
@ -37,9 +37,7 @@ class CAQICalculator : public AbstractAQICalculator {
|
|||||||
int conc_lo = array[grid_index][0];
|
int conc_lo = array[grid_index][0];
|
||||||
int conc_hi = array[grid_index][1];
|
int conc_hi = array[grid_index][1];
|
||||||
|
|
||||||
int aqi = ((aqi_hi - aqi_lo) / (conc_hi - conc_lo)) * (value - conc_lo) + aqi_lo;
|
return (value - conc_lo) * (aqi_hi - aqi_lo) / (conc_hi - conc_lo) + aqi_lo;
|
||||||
|
|
||||||
return aqi;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_grid_index_(uint16_t value, int array[AMOUNT_OF_LEVELS][2]) {
|
int get_grid_index_(uint16_t value, int array[AMOUNT_OF_LEVELS][2]) {
|
||||||
|
Loading…
Reference in New Issue
Block a user