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
3546cc81
Commit
3546cc81
authored
Apr 17, 2021
by
Eric Duminil
Browse files
Adding documentation to commands
parent
0722bbb7
Changes
5
Hide whitespace changes
Inline
Side-by-side
ampel-firmware/co2_sensor.cpp
View file @
3546cc81
...
...
@@ -103,17 +103,18 @@ namespace sensor {
Serial
.
print
(
F
(
"Auto-calibration is "
));
Serial
.
println
(
config
::
auto_calibrate_sensor
?
"ON."
:
"OFF."
);
sensor_commands
::
defineCallback
(
"co2"
,
setCO2forDebugging
);
sensor_commands
::
defineCallback
(
"timer"
,
setTimer
);
sensor_commands
::
defineCallback
(
"calibrate"
,
calibrateSensorToSpecificPPM
);
sensor_commands
::
defineCallback
(
"calibrate!"
,
calibrateSensorRightNow
);
sensor_commands
::
defineCallback
(
"co2"
,
setCO2forDebugging
,
" 1500 (Sets co2 level, for debugging purposes)"
);
sensor_commands
::
defineCallback
(
"timer"
,
setTimer
,
" 30 (Sets measurement interval)"
);
sensor_commands
::
defineCallback
(
"calibrate"
,
calibrateSensorToSpecificPPM
,
" 600 (Starts calibration process, to given ppm)"
);
sensor_commands
::
defineCallback
(
"calibrate!"
,
calibrateSensorRightNow
,
" 600 (Calibrates right now, to given ppm)"
);
}
//NOTE: should timer deviation be used to adjust measurement_timestep?
void
checkTimerDeviation
()
{
static
int32_t
previous_measurement_at
=
0
;
int32_t
now
=
millis
();
Serial
.
print
(
"Measurement time offset : "
);
Serial
.
print
(
F
(
"Measurement time offset : "
)
)
;
Serial
.
print
(
now
-
previous_measurement_at
-
config
::
measurement_timestep
*
1000
);
Serial
.
println
(
" ms."
);
previous_measurement_at
=
now
;
...
...
ampel-firmware/csv_writer.cpp
View file @
3546cc81
...
...
@@ -125,7 +125,7 @@ namespace csv_writer {
showFilesystemContent
();
Serial
.
println
();
sensor_commands
::
defineCallback
(
"csv"
,
setCSVinterval
);
sensor_commands
::
defineCallback
(
"csv"
,
setCSVinterval
,
" 60 (Sets CSV writing interval)"
);
// sensor_commands::defineCallback("format_filesystem", FS_LIB.format);
}
...
...
ampel-firmware/mqtt.cpp
View file @
3546cc81
...
...
@@ -44,7 +44,7 @@ namespace mqtt {
// mqttClient.setSocketTimeout(config::mqtt_timeout); //NOTE: somehow doesn't seem to have any effect on connect()
mqttClient
.
setServer
(
config
::
mqtt_server
,
config
::
mqtt_port
);
sensor_commands
::
defineCallback
(
"mqtt"
,
setMQTTinterval
);
sensor_commands
::
defineCallback
(
"mqtt"
,
setMQTTinterval
,
" 60 (Sets MQTT sending interval)"
);
}
void
publish
(
const
String
&
timestamp
,
int16_t
co2
,
float
temperature
,
float
humidity
)
{
...
...
ampel-firmware/sensor_commands.cpp
View file @
3546cc81
...
...
@@ -5,20 +5,20 @@ namespace sensor_commands {
const
uint8_t
MAX_COMMAND_SIZE
=
30
;
uint8_t
callbacks_count
=
0
;
//TODO: Add example? Add description?
struct
Callback
{
Callback
(
const
char
*
s
=
0
,
void
(
*
f
)(
int32_t
)
=
0
)
:
name
(
s
),
function
(
f
)
{
Callback
(
const
char
*
s
=
0
,
void
(
*
f
)(
int32_t
)
=
0
,
const
char
*
d
=
0
)
:
name
(
s
),
function
(
f
)
,
doc
(
d
)
{
}
const
char
*
name
;
void
(
*
function
)(
int32_t
);
const
char
*
doc
;
};
Callback
callbacks
[
MAX_CALLBACKS
];
void
defineCallback
(
const
char
*
n
,
void
(
*
f
)(
int32_t
))
{
void
defineCallback
(
const
char
*
n
ame
,
void
(
*
f
unction
)(
int32_t
)
,
const
char
*
doc
)
{
if
(
callbacks_count
<
MAX_CALLBACKS
)
{
callbacks
[
callbacks_count
]
=
Callback
(
n
,
f
);
callbacks
[
callbacks_count
]
=
Callback
(
n
ame
,
function
,
doc
);
callbacks_count
++
;
}
else
{
Serial
.
println
(
F
(
"Too many callbacks have been defined."
));
...
...
@@ -58,11 +58,12 @@ namespace sensor_commands {
}
void
listAvailableCallbacks
()
{
Serial
.
println
(
F
(
"Message not supported.
Doing nothing.
Available commands :"
));
Serial
.
println
(
F
(
"Message not supported. Available commands :"
));
for
(
uint8_t
i
=
0
;
i
<
callbacks_count
;
i
++
)
{
Serial
.
print
(
" "
);
Serial
.
print
(
callbacks
[
i
].
name
);
Serial
.
println
(
" 1234"
);
Serial
.
print
(
callbacks
[
i
].
doc
);
Serial
.
println
(
"."
);
}
led_effects
::
showKITTWheel
(
color
::
red
,
1
);
}
...
...
ampel-firmware/sensor_commands.h
View file @
3546cc81
...
...
@@ -9,5 +9,5 @@
namespace
sensor_commands
{
void
run
(
const
char
*
command
);
//TODO: Add defineIntCallback?
void
defineCallback
(
const
char
*
command
,
void
(
*
f
)(
int32_t
));
void
defineCallback
(
const
char
*
command
,
void
(
*
f
unction
)(
int32_t
)
,
const
char
*
doc
);
}
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