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
73c59253
Commit
73c59253
authored
Jun 22, 2022
by
Eric Duminil
Browse files
Define autocalibrate for S8
parent
750b7448
Changes
1
Show whitespace changes
Inline
Side-by-side
ampel-firmware/co2_sensor.cpp
View file @
73c59253
...
...
@@ -96,8 +96,6 @@ namespace sensor {
printIntToHex
(
s8
.
sensor_id
,
4
);
Serial
.
println
();
//TODO: Auto-calibration on/off?
// S8 has its own timer (constant 4s)
Serial
.
println
();
Serial
.
print
(
F
(
"Setting S8 timestep to "
));
...
...
@@ -105,14 +103,16 @@ namespace sensor {
Serial
.
println
(
F
(
" s during acclimatization."
));
check_timestep
=
config
::
measurement_timestep_bootup
;
setAutoCalibration
(
config
::
auto_calibrate_sensor
);
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::defineCommand("calibrate", startCalibrationProcess, F("(Starts calibration process)"));
//
sensor_console::defineIntCommand("calibrate", calibrateSensorToSpecificPPM,
//
F("600 (Starts calibration process, to given ppm)"));
//
sensor_console::defineIntCommand("calibrate!", calibrateSensorRightNow,
//
F("600 (Calibrates right now, to given ppm)"));
//
sensor_console::defineIntCommand("auto_calibrate", setAutoCalibration, F("0/1 (Disables/enables autocalibration)"));
sensor_console
::
defineCommand
(
"calibrate"
,
startCalibrationProcess
,
F
(
"(Starts calibration process)"
));
sensor_console
::
defineIntCommand
(
"calibrate"
,
calibrateSensorToSpecificPPM
,
F
(
"600 (Starts calibration process, to given ppm)"
));
sensor_console
::
defineIntCommand
(
"calibrate!"
,
calibrateSensorRightNow
,
F
(
"600 (Calibrates right now, to given ppm)"
));
sensor_console
::
defineIntCommand
(
"auto_calibrate"
,
setAutoCalibration
,
F
(
"0/1 (Disables/enables autocalibration)"
));
}
bool
hasSensorSettled
()
{
...
...
@@ -144,11 +144,26 @@ namespace sensor {
}
void
startCalibrationProcess
()
{
Serial
.
println
(
F
(
"Implement ME!"
));
/**
* Before applying manual calibration, S8 needs to be operated for 2 minutes with the desired measurement period in continuous mode.
*/
Serial
.
print
(
F
(
"Setting S8 timestep to "
));
Serial
.
print
(
config
::
timestep_during_calibration
);
Serial
.
println
(
F
(
"s, prior to calibration."
));
check_timestep
=
config
::
timestep_during_calibration
;
Serial
.
println
(
F
(
"Waiting until the measurements are stable for at least 2 minutes."
));
Serial
.
println
(
F
(
"It could take a very long time."
));
switchState
(
PREPARE_CALIBRATION_UNSTABLE
);
}
void
calibrate
()
{
Serial
.
println
(
F
(
"Implement ME!"
));
Serial
.
print
(
F
(
"Calibrating S8 now..."
));
//FIXME: Apparently, only to 400ppm, though.
Serial
.
println
(
F
(
"WARNING! FORCING CALIBRATION TO 400ppm, regardless of configuration."
));
sensor_S8
->
manual_calibration
();
Serial
.
println
(
F
(
" Done!"
));
Serial
.
println
(
F
(
"Sensor calibrated."
));
switchState
(
BOOTUP
);
// In order to stop the calibration and select the desired timestep.
}
void
logToSerial
()
{
...
...
@@ -278,7 +293,20 @@ namespace sensor {
}
void
setAutoCalibration
(
int32_t
autoCalibration
)
{
Serial
.
println
(
F
(
"TODO: Implement ME!"
));
int16_t
autoCalibrationHours
=
sensor_S8
->
get_ABC_period
();
bool
isAutoCalibrationOn
=
autoCalibrationHours
>
0
;
Serial
.
print
(
F
(
"Current autocalibration : "
));
Serial
.
print
(
autoCalibrationHours
);
Serial
.
println
(
F
(
" h."
));
if
(
isAutoCalibrationOn
!=
autoCalibration
)
{
Serial
.
print
(
F
(
"Turn autocalibration "
));
Serial
.
print
(
autoCalibration
?
F
(
"on"
)
:
F
(
"off"
));
sensor_S8
->
set_ABC_period
(
autoCalibration
?
180
:
0
);
delay
(
500
);
Serial
.
println
(
F
(
". Done!"
));
}
else
{
}
}
void
setTimer
(
int32_t
timestep
)
{
...
...
@@ -297,6 +325,12 @@ namespace sensor {
}
void
calibrateSensorRightNow
(
int32_t
calibrationLevel
)
{
Serial
.
println
(
F
(
"TODO: Implement ME!"
));
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
();
}
}
}
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