Handle backspace in the serial interface

This commit is contained in:
Paul van Tilburg 2019-03-12 17:28:03 +01:00
parent 84325d9434
commit 27fe066219
1 changed files with 9 additions and 2 deletions

View File

@ -113,7 +113,8 @@ const APP: () = {
block!(resources.serial_tx.write(byte)).unwrap();
//hprintln!("serial: {}", byte).unwrap();
// Handle the command in the buffer for newline, otherwise append to the buffer.
// Handle the command in the buffer for newline or backspace, otherwise append to the
// buffer.
if byte == b'\r' {
block!(resources.serial_tx.write(b'\n')).unwrap();
match &buffer[..] {
@ -141,12 +142,18 @@ const APP: () = {
}
buffer.clear();
} else if byte == 0x7F {
buffer.pop();
block!(resources.serial_tx.write(b'\r')).unwrap();
for byte in buffer {
block!(resources.serial_tx.write(*byte)).unwrap();
}
} else {
if buffer.push(byte).is_err() {
hprintln!("Serial read buffer full!").unwrap();
}
//hprintln!("buffer: {:?}", buffer).unwrap();
}
//hprintln!("buffer: {:?}", buffer).unwrap();
}
extern "C" {