Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Käppler
ampel-firmware
Commits
72c2ef74
Commit
72c2ef74
authored
Apr 17, 2021
by
Eric Duminil
Browse files
Moving command callbacks to the end of the scripts
parent
6d71a41e
Changes
6
Hide whitespace changes
Inline
Side-by-side
ampel-firmware/co2_sensor.cpp
View file @
72c2ef74
...
...
@@ -27,38 +27,6 @@ namespace sensor {
uint32_t
waiting_color
=
color
::
blue
;
bool
should_calibrate
=
false
;
void
setCO2forDebugging
(
int32_t
fakeCo2
)
{
Serial
.
print
(
F
(
"DEBUG. Setting CO2 to "
));
co2
=
fakeCo2
;
Serial
.
println
(
co2
);
}
void
setTimer
(
int32_t
timestep
)
{
if
(
timestep
>=
2
&&
timestep
<=
1800
)
{
Serial
.
print
(
F
(
"Setting Measurement Interval to : "
));
Serial
.
print
(
timestep
);
Serial
.
println
(
"s."
);
sensor
::
scd30
.
setMeasurementInterval
(
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
(
" ppm."
);
sensor
::
startCalibrationProcess
();
}
}
void
calibrateSensorRightNow
(
int32_t
calibrationLevel
)
{
stable_measurements
=
config
::
enough_stable_measurements
;
calibrateSensorToSpecificPPM
(
calibrationLevel
);
}
void
initialize
()
{
#if defined(ESP8266)
Wire
.
begin
(
12
,
14
);
// ESP8266 - D6, D5;
...
...
@@ -228,4 +196,39 @@ namespace sensor {
displayCO2OnLedRing
();
return
freshData
;
}
/*****************************************************************
* Callbacks for sensor commands *
*****************************************************************/
void
setCO2forDebugging
(
int32_t
fakeCo2
)
{
Serial
.
print
(
F
(
"DEBUG. Setting CO2 to "
));
co2
=
fakeCo2
;
Serial
.
println
(
co2
);
}
void
setTimer
(
int32_t
timestep
)
{
if
(
timestep
>=
2
&&
timestep
<=
1800
)
{
Serial
.
print
(
F
(
"Setting Measurement Interval to : "
));
Serial
.
print
(
timestep
);
Serial
.
println
(
"s."
);
sensor
::
scd30
.
setMeasurementInterval
(
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
(
" ppm."
);
sensor
::
startCalibrationProcess
();
}
}
void
calibrateSensorRightNow
(
int32_t
calibrationLevel
)
{
stable_measurements
=
config
::
enough_stable_measurements
;
calibrateSensorToSpecificPPM
(
calibrationLevel
);
}
}
ampel-firmware/co2_sensor.h
View file @
72c2ef74
...
...
@@ -27,5 +27,10 @@ namespace sensor {
void
initialize
();
bool
processData
();
void
startCalibrationProcess
();
void
setCO2forDebugging
(
int32_t
fakeCo2
);
void
setTimer
(
int32_t
timestep
);
void
calibrateSensorToSpecificPPM
(
int32_t
calibrationLevel
);
void
calibrateSensorRightNow
(
int32_t
calibrationLevel
);
}
#endif
ampel-firmware/csv_writer.cpp
View file @
72c2ef74
...
...
@@ -86,14 +86,6 @@ namespace csv_writer {
return
getTotalSpace
()
-
getUsedSpace
();
}
void
setCSVinterval
(
int32_t
csv_interval
)
{
config
::
csv_interval
=
csv_interval
;
Serial
.
print
(
F
(
"Setting CSV Interval to : "
));
Serial
.
print
(
config
::
csv_interval
);
Serial
.
println
(
"s."
);
led_effects
::
showKITTWheel
(
color
::
green
,
1
);
}
void
initialize
()
{
Serial
.
print
(
F
(
"Initializing FS..."
));
if
(
mountFS
())
{
...
...
@@ -172,4 +164,15 @@ namespace csv_writer {
log
(
timeStamp
,
co2
,
temperature
,
humidity
);
}
}
/*****************************************************************
* Callbacks for sensor commands *
*****************************************************************/
void
setCSVinterval
(
int32_t
csv_interval
)
{
config
::
csv_interval
=
csv_interval
;
Serial
.
print
(
F
(
"Setting CSV Interval to : "
));
Serial
.
print
(
config
::
csv_interval
);
Serial
.
println
(
"s."
);
led_effects
::
showKITTWheel
(
color
::
green
,
1
);
}
}
ampel-firmware/csv_writer.h
View file @
72c2ef74
...
...
@@ -25,6 +25,8 @@ namespace csv_writer {
void
logIfTimeHasCome
(
const
String
&
timeStamp
,
const
int16_t
&
co2
,
const
float
&
temperature
,
const
float
&
humidity
);
int
getAvailableSpace
();
extern
const
String
filename
;
void
setCSVinterval
(
int32_t
csv_interval
);
}
#endif
ampel-firmware/mqtt.cpp
View file @
72c2ef74
...
...
@@ -27,14 +27,6 @@ namespace mqtt {
const
char
*
json_sensor_format
;
String
last_successful_publish
=
""
;
void
setMQTTinterval
(
int32_t
sending_interval
)
{
config
::
sending_interval
=
sending_interval
;
Serial
.
print
(
F
(
"Setting Sending Interval to : "
));
Serial
.
print
(
config
::
sending_interval
);
Serial
.
println
(
"s."
);
led_effects
::
showKITTWheel
(
color
::
green
,
1
);
}
void
initialize
(
String
&
topic
)
{
json_sensor_format
=
PSTR
(
"{
\"
time
\"
:
\"
%s
\"
,
\"
co2
\"
:%d,
\"
temp
\"
:%.1f,
\"
rh
\"
:%.1f}"
);
publish_topic
=
topic
;
...
...
@@ -177,4 +169,14 @@ namespace mqtt {
mqttClient
.
loop
();
}
/*****************************************************************
* Callbacks for sensor commands *
*****************************************************************/
void
setMQTTinterval
(
int32_t
sending_interval
)
{
config
::
sending_interval
=
sending_interval
;
Serial
.
print
(
F
(
"Setting Sending Interval to : "
));
Serial
.
print
(
config
::
sending_interval
);
Serial
.
println
(
"s."
);
led_effects
::
showKITTWheel
(
color
::
green
,
1
);
}
}
ampel-firmware/mqtt.h
View file @
72c2ef74
...
...
@@ -20,5 +20,7 @@ namespace mqtt {
void
initialize
(
String
&
topic
);
void
keepConnection
();
void
publishIfTimeHasCome
(
const
String
&
timeStamp
,
const
int16_t
&
co2
,
const
float
&
temp
,
const
float
&
hum
);
void
setMQTTinterval
(
int32_t
sending_interval
);
}
#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