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
880463c0
Commit
880463c0
authored
Mar 22, 2022
by
Eric Duminil
Browse files
Cleaning up
parent
fa480706
Pipeline
#6023
failed with stage
in 1 minute and 24 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
ampel-firmware/co2_sensor.cpp
View file @
880463c0
...
...
@@ -66,6 +66,7 @@ namespace sensor {
void
setAutoCalibration
(
int32_t
autoCalibration
);
void
initialize
()
{
Serial
.
println
(
F
(
"Sensor : Senseair S8"
));
S8_serial
.
begin
(
S8_BAUDRATE
);
sensor_S8
=
new
S8_UART
(
S8_serial
);
#endif
...
...
@@ -81,18 +82,14 @@ namespace sensor {
}
// Show basic S8 sensor info
Serial
.
print
ln
(
">>> SenseAir S8 NDIR CO2 sensor <<<"
);
printf
(
"Firmware version: %s
\n
"
,
s8
.
firm_version
);
Serial
.
print
(
F
(
"S8 - Firmware : "
)
);
Serial
.
println
(
s8
.
firm_version
);
s8
.
sensor_id
=
sensor_S8
->
get_sensor_ID
();
Serial
.
print
(
"S
ensor
ID: 0x"
);
Serial
.
print
(
"S
8 -
ID
: 0x"
);
printIntToHex
(
s8
.
sensor_id
,
4
);
Serial
.
println
(
""
);
Serial
.
println
(
"Setup done!"
);
Serial
.
flush
();
Serial
.
print
(
F
(
"Auto-calibration is "
));
Serial
.
println
(
config
::
auto_calibrate_sensor
?
"ON."
:
"OFF."
);
//TODO: Auto-calibration on/off?
// S8 has its own timer (constant 4s)
Serial
.
println
();
...
...
@@ -102,7 +99,7 @@ namespace sensor {
check_timestep
=
config
::
measurement_timestep_bootup
;
sensor_console
::
defineIntCommand
(
"co2"
,
setCO2forDebugging
,
F
(
"1500 (Sets co2 level, for debugging)"
));
//
sensor_console::defineIntCommand("timer", setTimer, F("30 (Sets measurement interval, in s)"));
sensor_console
::
defineIntCommand
(
"timer"
,
setTimer
,
F
(
"30 (Sets measurement interval, in s)"
));
// sensor_console::defineCommand("calibrate", startCalibrationProcess, F("(Starts calibration process)"));
// sensor_console::defineIntCommand("calibrate", calibrateSensorToSpecificPPM,
// F("600 (Starts calibration process, to given ppm)"));
...
...
@@ -152,10 +149,7 @@ namespace sensor {
Serial
.
print
(
timestamp
);
Serial
.
print
(
F
(
" - co2(ppm): "
));
Serial
.
print
(
co2
);
Serial
.
print
(
F
(
" temp(C): "
));
Serial
.
print
(
temperature
,
1
);
Serial
.
print
(
F
(
" humidity(%): "
));
Serial
.
println
(
humidity
,
1
);
Serial
.
println
(
F
(
" temp(C): ? humidity(%): ?"
));
}
void
switchState
(
state
new_state
)
{
...
...
@@ -246,6 +240,7 @@ namespace sensor {
last_measurement
=
now
;
ntp
::
getLocalTime
(
timestamp
);
co2
=
sensor_S8
->
get_co2
();
//TODO: Check if there's really no temperature info available.
temperature
=
0.0
;
humidity
=
0.0
;
...
...
@@ -277,34 +272,29 @@ namespace sensor {
}
void
setAutoCalibration
(
int32_t
autoCalibration
)
{
Serial
.
println
(
F
(
"Implement ME!"
));
Serial
.
println
(
F
(
"
TODO:
Implement ME!"
));
}
void
setTimer
(
int32_t
timestep
)
{
Serial
.
println
(
F
(
"Implement ME!"
));
if
(
timestep
>=
4
)
{
Serial
.
print
(
F
(
"Setting Measurement Interval to : "
));
Serial
.
print
(
timestep
);
Serial
.
println
(
F
(
"s."
));
check_timestep
=
timestep
;
config
::
measurement_timestep
=
timestep
;
led_effects
::
showKITTWheel
(
color
::
green
,
1
);
}
}
void
calibrateSensorToSpecificPPM
(
int32_t
calibrationLevel
)
{
if
(
calibrationLevel
>=
400
&&
calibrationLevel
<=
2000
)
{
Serial
.
print
(
F
(
"Force calibration, at "
));
config
::
co2_calibration_level
=
calibrationLevel
;
Serial
.
print
(
config
::
co2_calibration_level
);
Serial
.
println
(
F
(
" ppm."
));
startCalibrationProcess
();
}
Serial
.
println
(
F
(
"TODO: Implement ME!"
));
}
void
calibrateSensorRightNow
(
int32_t
calibrationLevel
)
{
if
(
calibrationLevel
>=
400
&&
calibrationLevel
<=
2000
)
{
Serial
.
print
(
F
(
"Force calibration, right now, at "
));
config
::
co2_calibration_level
=
calibrationLevel
;
Serial
.
print
(
config
::
co2_calibration_level
);
Serial
.
println
(
F
(
" ppm."
));
calibrate
();
}
Serial
.
println
(
F
(
"TODO: Implement ME!"
));
}
void
resetSCD
()
{
Serial
.
println
(
F
(
"Implement ME!"
));
Serial
.
println
(
F
(
"
TODO:
Implement ME!
(or delete me)
"
));
}
}
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