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
0dad2457
Commit
0dad2457
authored
Apr 16, 2021
by
Eric Duminil
Browse files
Timer
parent
32f8968b
Changes
4
Hide whitespace changes
Inline
Side-by-side
ampel-firmware/co2_sensor.cpp
View file @
0dad2457
...
...
@@ -31,6 +31,17 @@ namespace sensor {
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
initialize
()
{
#if defined(ESP8266)
Wire
.
begin
(
12
,
14
);
// ESP8266 - D6, D5;
...
...
@@ -76,6 +87,7 @@ namespace sensor {
Serial
.
println
(
config
::
auto_calibrate_sensor
?
"ON."
:
"OFF."
);
sensor_commands
::
defineCallback
(
"co2"
,
setCO2forDebugging
);
sensor_commands
::
defineCallback
(
"timer"
,
setTimer
);
}
//NOTE: should timer deviation be used to adjust measurement_timestep?
...
...
ampel-firmware/mqtt.cpp
View file @
0dad2457
...
...
@@ -55,20 +55,6 @@ namespace mqtt {
}
}
//TODO: Move all those setters to a separate class, which could be used by Serial/MQTT/WebServer
void
setTimer
(
String
messageString
)
{
messageString
.
replace
(
"timer "
,
""
);
int
timestep
=
messageString
.
toInt
();
if
(
timestep
>=
2
&&
timestep
<=
1800
)
{
Serial
.
print
(
F
(
"Setting Measurement Interval to : "
));
Serial
.
print
(
timestep
);
Serial
.
println
(
"s."
);
sensor
::
scd30
.
setMeasurementInterval
(
messageString
.
toInt
());
config
::
measurement_timestep
=
messageString
.
toInt
();
led_effects
::
showKITTWheel
(
color
::
green
,
1
);
}
}
void
setMQTTinterval
(
String
messageString
)
{
messageString
.
replace
(
"mqtt "
,
""
);
config
::
sending_interval
=
messageString
.
toInt
();
...
...
@@ -101,13 +87,6 @@ namespace mqtt {
}
}
void
setCO2forDebugging
(
String
messageString
)
{
Serial
.
print
(
F
(
"DEBUG. Setting CO2 to "
));
messageString
.
replace
(
"co2 "
,
""
);
sensor
::
co2
=
messageString
.
toInt
();
Serial
.
println
(
sensor
::
co2
);
}
void
sendInfoAboutLocalNetwork
()
{
char
info_topic
[
60
];
// Should be enough for "CO2sensors/ESPd03cc5/info"
snprintf
(
info_topic
,
sizeof
(
info_topic
),
"%s/info"
,
publish_topic
.
c_str
());
...
...
@@ -146,11 +125,7 @@ namespace mqtt {
//TODO: Move this logic to a separate class, which could be used by Serial/MQTT/WebServer
if
(
messageString
.
startsWith
(
"co2 "
))
{
setCO2forDebugging
(
messageString
);
}
else
if
(
messageString
.
startsWith
(
"timer "
))
{
setTimer
(
messageString
);
}
else
if
(
messageString
==
"calibrate"
)
{
if
(
messageString
==
"calibrate"
)
{
sensor
::
startCalibrationProcess
();
}
else
if
(
messageString
.
startsWith
(
"calibrate "
))
{
calibrateSensorToSpecificPPM
(
messageString
);
...
...
ampel-firmware/sensor_commands.cpp
View file @
0dad2457
...
...
@@ -5,8 +5,6 @@ namespace sensor_commands {
const
uint8_t
MAX_COMMAND_SIZE
=
30
;
uint8_t
callbacks_count
=
0
;
// A callback contains both a function and a pointer to arbitrary data
// that will be passed as argument to the function.
struct
Callback
{
Callback
(
const
char
*
s
=
0
,
void
(
*
f
)(
int32_t
)
=
0
)
:
name
(
s
),
function
(
f
)
{
...
...
ampel-firmware/sensor_commands.h
View file @
0dad2457
...
...
@@ -7,5 +7,6 @@
namespace
sensor_commands
{
void
run
(
const
char
*
command
);
//TODO: Add defineIntCallback?
void
defineCallback
(
const
char
*
command
,
void
(
*
f
)(
int32_t
));
}
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