From af08f16efc8b31f2ae66672ac0df8dedbabdc163 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 17 Oct 2021 20:24:41 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20Tweak=20MKS=20UI=20G-code=20cons?= =?UTF-8?q?ole?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/gcode/queue.h | 2 +- Marlin/src/lcd/extui/mks_ui/draw_gcode.cpp | 2 -- Marlin/src/lcd/extui/mks_ui/draw_keyboard.cpp | 10 +++++----- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Marlin/src/gcode/queue.h b/Marlin/src/gcode/queue.h index 2e3e26d179..82e2a7a0e4 100644 --- a/Marlin/src/gcode/queue.h +++ b/Marlin/src/gcode/queue.h @@ -133,7 +133,7 @@ public: * Enqueue command(s) to run from SRAM. Drained by process_injected_command(). * Aborts the current SRAM queue so only use for one or two commands. */ - static inline void inject(char * const gcode) { + static inline void inject(const char * const gcode) { strncpy(injected_commands, gcode, sizeof(injected_commands) - 1); } diff --git a/Marlin/src/lcd/extui/mks_ui/draw_gcode.cpp b/Marlin/src/lcd/extui/mks_ui/draw_gcode.cpp index effd49bff8..8a3366e01d 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_gcode.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_gcode.cpp @@ -82,8 +82,6 @@ void lv_serial_capt_hook(void * userPointer, uint8_t c) { void lv_eom_hook(void *) { // Message is done, let's remove the hook now MYSERIAL1.setHook(); - // We are back from the keyboard, so let's redraw ourselves - draw_return_ui(); } void lv_draw_gcode(bool clear) { diff --git a/Marlin/src/lcd/extui/mks_ui/draw_keyboard.cpp b/Marlin/src/lcd/extui/mks_ui/draw_keyboard.cpp index df5ebc8f22..6d7bdc2aa7 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_keyboard.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_keyboard.cpp @@ -164,13 +164,13 @@ static void lv_kb_event_cb(lv_obj_t *kb, lv_event_t event) { draw_return_ui(); break; case GCodeCommand: - if (!queue.ring_buffer.full(3)) { - // Hook anything that goes to the serial port + if (ret_ta_txt[0] && !queue.ring_buffer.full(3)) { + // Hook for the next bytes to arrive from the serial port MYSERIAL1.setHook(lv_serial_capt_hook, lv_eom_hook, 0); - queue.enqueue_one_now(ret_ta_txt); + // Run the command as soon as possible + queue.inject(ret_ta_txt); } - lv_clear_keyboard(); - // draw_return_ui is called in the end of message hook + goto_previous_ui(); break; default: break; }