Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
co2ampel
ampel-firmware
Commits
39fe4d11
Commit
39fe4d11
authored
4 years ago
by
Eric Duminil
Browse files
Options
Download
Email Patches
Plain Diff
Don't read serial before enter is pressed
parent
9db226d7
master
develop
experimental/example_for_iotwebconf
senseair_s8
v0.3.0
v0.2.3
v0.2.2
v0.2.1
v0.2.0
v0.1.0
archive/refactor/src_structure
archive/experimental/wifimanager
archive/experimental/simple
archive/experimental/save_lora_session
archive/experimental/save_config
archive/experimental/ota
archive/experimental/binary_clock
archive/experimental/autoconnect
archive/dev/debugcalib
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
ampel-firmware/ampel-firmware.ino
+3
-4
ampel-firmware/ampel-firmware.ino
ampel-firmware/sensor_commands.cpp
+21
-1
ampel-firmware/sensor_commands.cpp
ampel-firmware/sensor_commands.h
+1
-0
ampel-firmware/sensor_commands.h
with
25 additions
and
5 deletions
+25
-5
ampel-firmware/ampel-firmware.ino
+
3
-
4
View file @
39fe4d11
...
...
@@ -147,9 +147,8 @@ void loop() {
// Short press for night mode, Long press for calibration.
checkFlashButton
();
if
(
Serial
.
available
()
>
0
)
{
commandString
=
Serial
.
readStringUntil
(
'\n'
);
sensor_commands
::
run
(
commandString
.
c_str
());
while
(
Serial
.
available
()
>
0
)
{
sensor_commands
::
processIncomingByte
(
Serial
.
read
());
}
if
(
sensor
::
processData
())
{
...
...
@@ -171,7 +170,7 @@ void loop() {
max_loop_duration
=
duration
;
Serial
.
print
(
F
(
"Debug - Max loop duration : "
));
Serial
.
print
(
max_loop_duration
);
Serial
.
println
(
" ms."
);
Serial
.
println
(
F
(
" ms."
)
)
;
}
}
...
...
This diff is collapsed.
Click to expand it.
ampel-firmware/sensor_commands.cpp
+
21
-
1
View file @
39fe4d11
...
...
@@ -77,6 +77,26 @@ namespace sensor_commands {
return
code
;
}
// http://www.gammon.com.au/serial
void
processIncomingByte
(
const
byte
input_byte
)
{
static
char
input_line
[
MAX_COMMAND_SIZE
];
static
unsigned
int
input_pos
=
0
;
switch
(
input_byte
)
{
case
'\n'
:
// end of text
input_line
[
input_pos
]
=
0
;
run
(
input_line
);
input_pos
=
0
;
break
;
case
'\r'
:
// discard carriage return
break
;
default:
// keep adding if not full ... allow for terminating null byte
if
(
input_pos
<
(
MAX_COMMAND_SIZE
-
1
))
input_line
[
input_pos
++
]
=
input_byte
;
break
;
}
}
void
listAvailableCallbacks
()
{
for
(
uint8_t
i
=
0
;
i
<
callbacks_count
;
i
++
)
{
Serial
.
print
(
" "
);
...
...
@@ -106,7 +126,7 @@ namespace sensor_commands {
Serial
.
println
(
")"
);
callbacks
[
i
].
intFunction
(
argument
);
}
else
{
Serial
.
println
();
Serial
.
println
(
"()"
);
callbacks
[
i
].
voidFunction
();
}
return
;
...
...
This diff is collapsed.
Click to expand it.
ampel-firmware/sensor_commands.h
+
1
-
0
View file @
39fe4d11
...
...
@@ -7,6 +7,7 @@
*/
namespace
sensor_commands
{
void
processIncomingByte
(
const
byte
in_byte
);
void
run
(
const
char
*
command
);
void
defineIntCallback
(
const
char
*
command
,
void
(
*
function
)(
int32_t
),
const
char
*
doc
);
void
defineCallback
(
const
char
*
command
,
void
(
*
function
)(
void
),
const
char
*
doc
);
...
...
This diff is collapsed.
Click to expand it.
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
Menu
Explore
Projects
Groups
Snippets