Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
co2ampel
ampel-firmware
Commits
f5afb399
Commit
f5afb399
authored
Jun 06, 2021
by
Eric Duminil
Browse files
co2_sensor: slight refactor
parent
842a541f
Changes
1
Hide whitespace changes
Inline
Side-by-side
ampel-firmware/co2_sensor.cpp
View file @
f5afb399
...
...
@@ -126,8 +126,7 @@ namespace sensor {
return
(
co2
>
0
&&
delta
<
((
uint32_t
)
co2
*
config
::
max_deviation_during_bootup
/
100
));
}
bool
countStableMeasurements
()
{
// Returns true, if a sufficient number of stable measurements has been observed.
bool
enoughStableMeasurements
()
{
static
int16_t
previous_co2
=
0
;
if
(
co2
>
(
previous_co2
-
config
::
max_deviation_during_calibration
)
&&
co2
<
(
previous_co2
+
config
::
max_deviation_during_calibration
))
{
...
...
@@ -207,11 +206,11 @@ namespace sensor {
}
scd30
.
setMeasurementInterval
(
config
::
measurement_timestep
);
// [s]
}
// Check for pre-calibration states first, because we do not want to
// leave them before calibration is done.
if
((
current_state
==
PREPARE_CALIBRATION_UNSTABLE
)
||
(
current_state
==
PREPARE_CALIBRATION_STABLE
))
{
// Check for pre-calibration states first, because we do not want to
// leave them before calibration is done.
bool
ready_for_calibration
=
countStableMeasurements
();
if
(
ready_for_calibration
)
{
if
(
enoughStableMeasurements
())
{
calibrate
();
}
}
else
if
(
co2
<
250
)
{
...
...
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