Multi-platform DWIN_CREALITY_LCD support (#20738)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
parent
a26f2fb00b
commit
7f3dcb3e8a
@ -109,8 +109,9 @@
|
||||
#else
|
||||
#error "LCD_SERIAL_PORT must be -1 or from 1 to 3. Please update your configuration."
|
||||
#endif
|
||||
|
||||
#define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
|
||||
#if HAS_DGUS_LCD
|
||||
#define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Set interrupt grouping for this MCU
|
||||
|
@ -995,8 +995,9 @@ void setup() {
|
||||
#endif
|
||||
|
||||
MYSERIAL0.begin(BAUDRATE);
|
||||
uint32_t serial_connect_timeout = millis() + 1000UL;
|
||||
millis_t serial_connect_timeout = millis() + 1000UL;
|
||||
while (!MYSERIAL0 && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
|
||||
|
||||
#if HAS_MULTI_SERIAL && !HAS_ETHERNET
|
||||
MYSERIAL1.begin(BAUDRATE);
|
||||
serial_connect_timeout = millis() + 1000UL;
|
||||
|
@ -651,6 +651,9 @@
|
||||
|
||||
#if ENABLED(DWIN_CREALITY_LCD)
|
||||
#define SERIAL_CATCHALL 0
|
||||
#ifndef LCD_SERIAL_PORT
|
||||
#define LCD_SERIAL_PORT 3 // Creality 4.x board
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -82,20 +82,27 @@ inline void DWIN_String(size_t &i, const __FlashStringHelper * string) {
|
||||
// Send the data in the buffer and the packet end
|
||||
inline void DWIN_Send(size_t &i) {
|
||||
++i;
|
||||
LOOP_L_N(n, i) { MYSERIAL1.write(DWIN_SendBuf[n]); delayMicroseconds(1); }
|
||||
LOOP_L_N(n, 4) { MYSERIAL1.write(DWIN_BufTail[n]); delayMicroseconds(1); }
|
||||
LOOP_L_N(n, i) { LCD_SERIAL.write(DWIN_SendBuf[n]); delayMicroseconds(1); }
|
||||
LOOP_L_N(n, 4) { LCD_SERIAL.write(DWIN_BufTail[n]); delayMicroseconds(1); }
|
||||
}
|
||||
|
||||
/*-------------------------------------- System variable function --------------------------------------*/
|
||||
|
||||
// Handshake (1: Success, 0: Fail)
|
||||
bool DWIN_Handshake(void) {
|
||||
#ifndef LCD_BAUDRATE
|
||||
#define LCD_BAUDRATE 115200
|
||||
#endif
|
||||
LCD_SERIAL.begin(LCD_BAUDRATE);
|
||||
const millis_t serial_connect_timeout = millis() + 1000UL;
|
||||
while (!LCD_SERIAL && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
|
||||
|
||||
size_t i = 0;
|
||||
DWIN_Byte(i, 0x00);
|
||||
DWIN_Send(i);
|
||||
|
||||
while (MYSERIAL1.available() > 0 && recnum < (signed)sizeof(databuf)) {
|
||||
databuf[recnum] = MYSERIAL1.read();
|
||||
while (LCD_SERIAL.available() > 0 && recnum < (signed)sizeof(databuf)) {
|
||||
databuf[recnum] = LCD_SERIAL.read();
|
||||
// ignore the invalid data
|
||||
if (databuf[0] != FHONE) { // prevent the program from running.
|
||||
if (recnum > 0) {
|
||||
|
@ -497,14 +497,21 @@ inline void Draw_Back_First(const bool is_sel=true) {
|
||||
if (is_sel) Draw_Menu_Cursor(0);
|
||||
}
|
||||
|
||||
inline bool Apply_Encoder(const ENCODER_DiffState &encoder_diffState, auto &valref) {
|
||||
if (encoder_diffState == ENCODER_DIFF_CW)
|
||||
valref += EncoderRate.encoderMoveValue;
|
||||
else if (encoder_diffState == ENCODER_DIFF_CCW)
|
||||
valref -= EncoderRate.encoderMoveValue;
|
||||
else if (encoder_diffState == ENCODER_DIFF_ENTER)
|
||||
return true;
|
||||
#define APPLY_ENCODER_F \
|
||||
if (encoder_diffState == ENCODER_DIFF_CW) \
|
||||
valref += EncoderRate.encoderMoveValue; \
|
||||
else if (encoder_diffState == ENCODER_DIFF_CCW) \
|
||||
valref -= EncoderRate.encoderMoveValue; \
|
||||
else if (encoder_diffState == ENCODER_DIFF_ENTER) \
|
||||
return true; \
|
||||
return false;
|
||||
|
||||
inline bool Apply_Encoder(const ENCODER_DiffState &encoder_diffState, int16_t &valref) {
|
||||
APPLY_ENCODER_F
|
||||
}
|
||||
|
||||
inline bool Apply_Encoder(const ENCODER_DiffState &encoder_diffState, float &valref) {
|
||||
APPLY_ENCODER_F
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -249,7 +249,8 @@ typedef struct {
|
||||
float Move_E_scale = 0;
|
||||
#endif
|
||||
float offset_value = 0;
|
||||
char show_mode = 0; // -1: Temperature control 0: Printing temperature
|
||||
TERN_(__STM32F1__, signed)
|
||||
char show_mode = 0; // -1: Temperature control 0: Printing temperature
|
||||
} HMI_value_t;
|
||||
|
||||
#define DWIN_CHINESE 123
|
||||
|
@ -592,15 +592,12 @@ void AnycubicTFTClass::GetCommandFromTFT() {
|
||||
} break;
|
||||
|
||||
case 5: { // A5 GET CURRENT COORDINATE
|
||||
float xPostition = ExtUI::getAxisPosition_mm(ExtUI::X);
|
||||
float yPostition = ExtUI::getAxisPosition_mm(ExtUI::Y);
|
||||
float zPostition = ExtUI::getAxisPosition_mm(ExtUI::Z);
|
||||
SEND_PGM("A5V X: ");
|
||||
LCD_SERIAL.print(xPostition);
|
||||
SEND_PGM(" Y: ");
|
||||
LCD_SERIAL.print(yPostition);
|
||||
SEND_PGM(" Z: ");
|
||||
LCD_SERIAL.print(zPostition);
|
||||
const float xPosition = ExtUI::getAxisPosition_mm(ExtUI::X),
|
||||
yPosition = ExtUI::getAxisPosition_mm(ExtUI::Y),
|
||||
zPosition = ExtUI::getAxisPosition_mm(ExtUI::Z);
|
||||
SEND_PGM("A5V X: "); LCD_SERIAL.print(xPosition);
|
||||
SEND_PGM( " Y: "); LCD_SERIAL.print(yPosition);
|
||||
SEND_PGM( " Z: "); LCD_SERIAL.print(zPosition);
|
||||
SENDLINE_PGM("");
|
||||
} break;
|
||||
|
||||
|
@ -282,27 +282,24 @@ void esp_port_begin(uint8_t interrupt) {
|
||||
dma_init();
|
||||
}
|
||||
#endif
|
||||
if (interrupt) {
|
||||
#if ENABLED(MKS_WIFI_MODULE)
|
||||
WIFISERIAL.end();
|
||||
for (uint16_t i = 0; i < 65535; i++);
|
||||
WIFISERIAL.begin(WIFI_BAUDRATE);
|
||||
uint32_t serial_connect_timeout = millis() + 1000UL;
|
||||
while (/*!WIFISERIAL && */PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
|
||||
//for (uint8_t i=0;i<100;i++)WIFISERIAL.write(0x33);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
#if ENABLED(MKS_WIFI_MODULE)
|
||||
WIFISERIAL.end();
|
||||
for (uint16_t i = 0; i < 65535; i++);
|
||||
WIFISERIAL.begin(WIFI_UPLOAD_BAUDRATE);
|
||||
uint32_t serial_connect_timeout = millis() + 1000UL;
|
||||
while (/*!WIFISERIAL && */PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
|
||||
//for (uint16_t i=0;i<65535;i++);//WIFISERIAL.write(0x33);
|
||||
#endif
|
||||
dma_init();
|
||||
}
|
||||
|
||||
#if ENABLED(MKS_WIFI_MODULE)
|
||||
WIFISERIAL.end();
|
||||
for (uint16_t i = 0; i < 65535; i++) { /*nada*/ }
|
||||
WIFISERIAL.begin(interrupt ? WIFI_BAUDRATE : WIFI_UPLOAD_BAUDRATE);
|
||||
|
||||
const millis_t serial_connect_timeout = millis() + 1000UL;
|
||||
while (/*!WIFISERIAL && */PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
|
||||
|
||||
if (interrupt) {
|
||||
//for (uint8_t i=0;i<100;i++) WIFISERIAL.write(0x33);
|
||||
}
|
||||
else {
|
||||
//for (uint16_t i=0;i<65535;i++); //WIFISERIAL.write(0x33);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!interrupt) dma_init();
|
||||
}
|
||||
|
||||
#if ENABLED(MKS_WIFI_MODULE)
|
||||
|
@ -50,10 +50,6 @@
|
||||
#include "stepper.h"
|
||||
#include "temperature.h"
|
||||
|
||||
#if ENABLED(DWIN_CREALITY_LCD)
|
||||
#include "../lcd/dwin/e3v2/dwin.h"
|
||||
#endif
|
||||
|
||||
#include "../lcd/marlinui.h"
|
||||
#include "../libs/vector_3.h" // for matrix_3x3
|
||||
#include "../gcode/gcode.h"
|
||||
|
@ -258,7 +258,20 @@
|
||||
* EXP2 EXP1
|
||||
*/
|
||||
|
||||
#if HAS_WIRED_LCD && !HAS_BTT_EXP_MOT
|
||||
#if ENABLED(DWIN_CREALITY_LCD)
|
||||
|
||||
// RET6 DWIN ENCODER LCD
|
||||
#define BTN_ENC P1_20
|
||||
#define BTN_EN1 P1_23
|
||||
#define BTN_EN2 P1_22
|
||||
|
||||
#ifndef BEEPER_PIN
|
||||
#define BEEPER_PIN P1_21
|
||||
#undef SPEAKER
|
||||
#endif
|
||||
|
||||
#elif HAS_WIRED_LCD && !HAS_BTT_EXP_MOT
|
||||
|
||||
#if ENABLED(ANET_FULL_GRAPHICS_LCD_ALT_WIRING)
|
||||
#error "CAUTION! ANET_FULL_GRAPHICS_LCD_ALT_WIRING requires wiring modifications. See 'pins_BTT_SKR_V1_4.h' for details. Comment out this line to continue."
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user