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
2af2eeab
Commit
2af2eeab
authored
Dec 20, 2020
by
Eric Duminil
Browse files
Small refactor
parent
b28542b7
Changes
3
Hide whitespace changes
Inline
Side-by-side
ampel-firmware.ino
View file @
2af2eeab
...
...
@@ -121,16 +121,7 @@ void loop() {
/**
* GET DATA
*/
bool
freshData
=
sensor
::
scd30
.
dataAvailable
();
// Alternative : close to time-step AND dataAvailable, to avoid asking the sensor too often.
if
(
freshData
)
{
//TODO: Move to co2_sensor.cpp
//TODO: Save count of stable measurements
//TODO: Compare time to previous measurements, check that it's not too far away from config::measurement_interval
sensor
::
co2
=
sensor
::
scd30
.
getCO2
();
sensor
::
temperature
=
sensor
::
scd30
.
getTemperature
();
sensor
::
humidity
=
sensor
::
scd30
.
getHumidity
();
}
bool
freshData
=
sensor
::
updateDataIfAvailable
();
//NOTE: Data is available, but it's sometimes erroneous: the sensor outputs zero ppm but non-zero temperature and non-zero humidity.
if
(
sensor
::
co2
<=
0
)
{
...
...
co2_sensor.cpp
View file @
2af2eeab
...
...
@@ -66,6 +66,18 @@ namespace sensor {
Serial
.
println
(
config
::
auto_calibrate_sensor
?
"ON."
:
"OFF."
);
}
bool
updateDataIfAvailable
()
{
//TODO: Save count of stable measurements
//TODO: Compare time to previous measurements, check that it's not too far away from config::measurement_interval
if
(
scd30
.
dataAvailable
())
{
co2
=
scd30
.
getCO2
();
temperature
=
scd30
.
getTemperature
();
humidity
=
scd30
.
getHumidity
();
return
true
;
}
return
false
;
}
void
waitUntilMeasurementsAreStable
()
{
//TODO: Refactor completely, in order to avoid very long loop?
/** From the sensor documentation:
...
...
co2_sensor.h
View file @
2af2eeab
...
...
@@ -24,6 +24,7 @@ namespace sensor {
extern
String
timestamp
;
void
initialize
();
bool
updateDataIfAvailable
();
void
startCalibrationProcess
();
}
#endif
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