From 97e0ed73937fe2922d4685a6bdb7681d439dee44 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Wed, 31 May 2023 23:32:39 -0400 Subject: [PATCH] fix touch ui for stm32 --- Marlin/Configuration_adv.h | 2 +- .../src/lcd/extui/ia_dwin/Creality_DWIN.cpp | 43 +++++++++++-------- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 387d4a9389..09fd7c0c26 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1974,7 +1974,7 @@ #define DGUS_RX_BUFFER_SIZE 128 #define DGUS_TX_BUFFER_SIZE 48 - #if ENABLED(FORCE10SPRODISPLAY) + #if ENABLED(FORCE10SPRODISPLAY) && DISABLED(Creality422, Creality427) #define SERIAL_STATS_RX_BUFFER_OVERRUNS // Fix Rx overrun situation (Currently only for AVR) #endif #define DGUS_UPDATE_INTERVAL_MS 500 // (ms) Interval between automatic screen updates diff --git a/Marlin/src/lcd/extui/ia_dwin/Creality_DWIN.cpp b/Marlin/src/lcd/extui/ia_dwin/Creality_DWIN.cpp index b55ac6ad47..152f79e594 100644 --- a/Marlin/src/lcd/extui/ia_dwin/Creality_DWIN.cpp +++ b/Marlin/src/lcd/extui/ia_dwin/Creality_DWIN.cpp @@ -599,7 +599,7 @@ RTSSHOW::RTSSHOW() int RTSSHOW::RTS_RecData() { uint8_t receivedbyte; - + #if ENABLED(SERIAL_STATS_RX_BUFFER_OVERRUNS) if (!DWIN_SERIAL.available() && DWIN_SERIAL.buffer_overruns()) { // Overrun, but reset the flag only when the buffer is empty // We want to extract as many as valid datagrams possible... @@ -608,6 +608,7 @@ int RTSSHOW::RTS_RecData() //DWIN_SERIAL.reset_rx_overun(); DWIN_SERIAL.flush(); } + #endif while (DWIN_SERIAL.available()) { @@ -777,16 +778,18 @@ void RTSSHOW::RTS_SndData(const char *str, unsigned long addr, unsigned char cmd uint8_t expected_tx = 6 + len; // 6 bytes header + payload. const millis_t try_until = ExtUI::safe_millis() + 1000; - while (expected_tx > DWIN_SERIAL.get_tx_buffer_free()) { - if (ELAPSED(ExtUI::safe_millis(), try_until)) return; // Stop trying after 1 second + #if ENABLED(SERIAL_STATS_RX_BUFFER_OVERRUNS) + while (expected_tx > DWIN_SERIAL.get_tx_buffer_free()) { + if (ELAPSED(ExtUI::safe_millis(), try_until)) return; // Stop trying after 1 second - #ifdef ARDUINO_ARCH_STM32 - DWIN_SERIAL.flush(); - #else - DWIN_SERIAL.flushTX(); - #endif - delay(50); - } + #ifdef ARDUINO_ARCH_STM32 + DWIN_SERIAL.flush(); + #else + DWIN_SERIAL.flushTX(); + #endif + delay(50); + } + #endif int dataRec2; do { dataRec2 = rtscheck.RTS_RecData(); } while (dataRec2 > 0); // Since OS4 returns an ack on an 82 command, receive and purge it now @@ -907,16 +910,18 @@ void RTSSHOW::WriteVariable(uint16_t adr, const void* values, uint8_t valueslen, uint8_t expected_tx = 6 + valueslen; // 6 bytes header + payload. const millis_t try_until = ExtUI::safe_millis() + 1000; - while (expected_tx > DWIN_SERIAL.get_tx_buffer_free()) { - if (ELAPSED(ExtUI::safe_millis(), try_until)) return; // Stop trying after 1 second + #if ENABLED(SERIAL_STATS_RX_BUFFER_OVERRUNS) + while (expected_tx > DWIN_SERIAL.get_tx_buffer_free()) { + if (ELAPSED(ExtUI::safe_millis(), try_until)) return; // Stop trying after 1 second - #ifdef ARDUINO_ARCH_STM32 - DWIN_SERIAL.flush(); - #else - DWIN_SERIAL.flushTX(); - #endif - delay(50); - } + #ifdef ARDUINO_ARCH_STM32 + DWIN_SERIAL.flush(); + #else + DWIN_SERIAL.flushTX(); + #endif + delay(50); + } + #endif int dataRec2; do { dataRec2 = rtscheck.RTS_RecData(); } while (dataRec2 > 0); // Since OS4 returns an ack on an 82 command, receive and purge it now