Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Käppler
ampel-firmware
Commits
dc716959
Commit
dc716959
authored
Apr 29, 2021
by
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
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
ampel-firmware/co2_sensor.cpp
View file @
dc716959
...
@@ -8,7 +8,7 @@ namespace config {
...
@@ -8,7 +8,7 @@ namespace config {
uint16_t
co2_calibration_level
=
ATMOSPHERIC_CO2_CONCENTRATION
;
// [ppm]
uint16_t
co2_calibration_level
=
ATMOSPHERIC_CO2_CONCENTRATION
;
// [ppm]
int8_t
max_deviation_during_calibration
=
30
;
// [ppm]
int8_t
max_deviation_during_calibration
=
30
;
// [ppm]
int8_t
enough_stable_measurements
=
60
;
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
#ifdef TEMPERATURE_OFFSET
// Residual heat from CO2 sensor seems to be high enough to change the temperature reading. How much should it be 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.
// NOTE: Sign isn't relevant. The returned temperature will always be shifted down.
...
@@ -135,7 +135,7 @@ namespace sensor {
...
@@ -135,7 +135,7 @@ namespace sensor {
last_co2
=
co2
;
last_co2
=
co2
;
// We assume the sensor has acclimated to the environment if measurements
// We assume the sensor has acclimated to the environment if measurements
// change less than a specified percentage of the current value.
// 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
()
{
bool
countStableMeasurements
()
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment