From ca5a8ea827e99a681fa1dfc7e8d4949ef0c45d9a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 8 Jun 2020 17:28:25 -0500 Subject: [PATCH] Add G-code "backspace" support --- Marlin/src/gcode/queue.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index 24d1d2cf67..d87166d979 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -387,9 +387,15 @@ inline void process_stream_char(const char c, uint8_t &sis, char (&buff)[MAX_CMD } #endif - buff[ind++] = c; - if (ind >= MAX_CMD_SIZE - 1) - sis = PS_EOL; // Skip the rest on overflow + // Backspace erases previous characters + if (c == 0x08) { + if (ind) buff[--ind] = '\0'; + } + else { + buff[ind++] = c; + if (ind >= MAX_CMD_SIZE - 1) + sis = PS_EOL; // Skip the rest on overflow + } } /**