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
3 years ago
by
Eric Duminil
Browse files
Options
Download
Email Patches
Plain Diff
co2_sensor: slight refactor
parent
842a541f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
ampel-firmware/co2_sensor.cpp
+5
-6
ampel-firmware/co2_sensor.cpp
with
5 additions
and
6 deletions
+5
-6
ampel-firmware/co2_sensor.cpp
+
5
-
6
View file @
f5afb399
...
@@ -126,8 +126,7 @@ namespace sensor {
...
@@ -126,8 +126,7 @@ namespace sensor {
return
(
co2
>
0
&&
delta
<
((
uint32_t
)
co2
*
config
::
max_deviation_during_bootup
/
100
));
return
(
co2
>
0
&&
delta
<
((
uint32_t
)
co2
*
config
::
max_deviation_during_bootup
/
100
));
}
}
bool
countStableMeasurements
()
{
bool
enoughStableMeasurements
()
{
// Returns true, if a sufficient number of stable measurements has been observed.
static
int16_t
previous_co2
=
0
;
static
int16_t
previous_co2
=
0
;
if
(
co2
>
(
previous_co2
-
config
::
max_deviation_during_calibration
)
if
(
co2
>
(
previous_co2
-
config
::
max_deviation_during_calibration
)
&&
co2
<
(
previous_co2
+
config
::
max_deviation_during_calibration
))
{
&&
co2
<
(
previous_co2
+
config
::
max_deviation_during_calibration
))
{
...
@@ -207,11 +206,11 @@ namespace sensor {
...
@@ -207,11 +206,11 @@ namespace sensor {
}
}
scd30
.
setMeasurementInterval
(
config
::
measurement_timestep
);
// [s]
scd30
.
setMeasurementInterval
(
config
::
measurement_timestep
);
// [s]
}
}
if
((
current_state
==
PREPARE_CALIBRATION_UNSTABLE
)
||
(
current_state
==
PREPARE_CALIBRATION_STABLE
))
{
// Check for pre-calibration states first, because we do not want to
// Check for pre-calibration states first, because we do not want to
// leave them before calibration is done.
// leave them before calibration is done.
bool
ready_for_calibration
=
countStableMeasurements
();
if
((
current_state
==
PREPARE_CALIBRATION_UNSTABLE
)
||
(
current_state
==
PREPARE_CALIBRATION_STABLE
))
{
if
(
ready_for_calibration
)
{
if
(
enoughStableMeasurements
()
)
{
calibrate
();
calibrate
();
}
}
}
else
if
(
co2
<
250
)
{
}
else
if
(
co2
<
250
)
{
...
...
This diff is collapsed.
Click to expand it.
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