Commit dc716959 authored by Käppler's avatar Käppler
Browse files

Cast `co2` to uint32_t to avoid overflow

parent 1bc03c7c
Pipeline #3285 passed with stage
in 1 minute and 50 seconds
......@@ -8,7 +8,7 @@ namespace config {
uint16_t co2_calibration_level = ATMOSPHERIC_CO2_CONCENTRATION; // [ppm]
int8_t max_deviation_during_calibration = 30; // [ppm]
int8_t enough_stable_measurements = 60;
const uint8_t max_deviation_during_accl = 20; // [%]
const uint8_t max_deviation_during_bootup = 20; // [%]
#ifdef TEMPERATURE_OFFSET
// Residual heat from CO2 sensor seems to be high enough to change the temperature reading. How much should it be offset?
// NOTE: Sign isn't relevant. The returned temperature will always be shifted down.
......@@ -135,7 +135,7 @@ namespace sensor {
last_co2 = co2;
// We assume the sensor has acclimated to the environment if measurements
// change less than a specified percentage of the current value.
return (co2 > 0 && (100 * delta / config::max_deviation_during_accl) < co2);
return (co2 > 0 && delta < ((uint32_t)co2 * config::max_deviation_during_bootup / 100));
}
bool countStableMeasurements() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment