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,9 +109,10 @@
|
||||||
#else
|
#else
|
||||||
#error "LCD_SERIAL_PORT must be -1 or from 1 to 3. Please update your configuration."
|
#error "LCD_SERIAL_PORT must be -1 or from 1 to 3. Please update your configuration."
|
||||||
#endif
|
#endif
|
||||||
|
#if HAS_DGUS_LCD
|
||||||
#define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
|
#define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
// Set interrupt grouping for this MCU
|
// Set interrupt grouping for this MCU
|
||||||
void HAL_init();
|
void HAL_init();
|
||||||
|
|
|
@ -995,8 +995,9 @@ void setup() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
MYSERIAL0.begin(BAUDRATE);
|
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*/ }
|
while (!MYSERIAL0 && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
|
||||||
|
|
||||||
#if HAS_MULTI_SERIAL && !HAS_ETHERNET
|
#if HAS_MULTI_SERIAL && !HAS_ETHERNET
|
||||||
MYSERIAL1.begin(BAUDRATE);
|
MYSERIAL1.begin(BAUDRATE);
|
||||||
serial_connect_timeout = millis() + 1000UL;
|
serial_connect_timeout = millis() + 1000UL;
|
||||||
|
|
|
@ -651,6 +651,9 @@
|
||||||
|
|
||||||
#if ENABLED(DWIN_CREALITY_LCD)
|
#if ENABLED(DWIN_CREALITY_LCD)
|
||||||
#define SERIAL_CATCHALL 0
|
#define SERIAL_CATCHALL 0
|
||||||
|
#ifndef LCD_SERIAL_PORT
|
||||||
|
#define LCD_SERIAL_PORT 3 // Creality 4.x board
|
||||||
|
#endif
|
||||||
#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
|
// Send the data in the buffer and the packet end
|
||||||
inline void DWIN_Send(size_t &i) {
|
inline void DWIN_Send(size_t &i) {
|
||||||
++i;
|
++i;
|
||||||
LOOP_L_N(n, i) { MYSERIAL1.write(DWIN_SendBuf[n]); delayMicroseconds(1); }
|
LOOP_L_N(n, i) { LCD_SERIAL.write(DWIN_SendBuf[n]); delayMicroseconds(1); }
|
||||||
LOOP_L_N(n, 4) { MYSERIAL1.write(DWIN_BufTail[n]); delayMicroseconds(1); }
|
LOOP_L_N(n, 4) { LCD_SERIAL.write(DWIN_BufTail[n]); delayMicroseconds(1); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------------------- System variable function --------------------------------------*/
|
/*-------------------------------------- System variable function --------------------------------------*/
|
||||||
|
|
||||||
// Handshake (1: Success, 0: Fail)
|
// Handshake (1: Success, 0: Fail)
|
||||||
bool DWIN_Handshake(void) {
|
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;
|
size_t i = 0;
|
||||||
DWIN_Byte(i, 0x00);
|
DWIN_Byte(i, 0x00);
|
||||||
DWIN_Send(i);
|
DWIN_Send(i);
|
||||||
|
|
||||||
while (MYSERIAL1.available() > 0 && recnum < (signed)sizeof(databuf)) {
|
while (LCD_SERIAL.available() > 0 && recnum < (signed)sizeof(databuf)) {
|
||||||
databuf[recnum] = MYSERIAL1.read();
|
databuf[recnum] = LCD_SERIAL.read();
|
||||||
// ignore the invalid data
|
// ignore the invalid data
|
||||||
if (databuf[0] != FHONE) { // prevent the program from running.
|
if (databuf[0] != FHONE) { // prevent the program from running.
|
||||||
if (recnum > 0) {
|
if (recnum > 0) {
|
||||||
|
|
|
@ -497,14 +497,21 @@ inline void Draw_Back_First(const bool is_sel=true) {
|
||||||
if (is_sel) Draw_Menu_Cursor(0);
|
if (is_sel) Draw_Menu_Cursor(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool Apply_Encoder(const ENCODER_DiffState &encoder_diffState, auto &valref) {
|
#define APPLY_ENCODER_F \
|
||||||
if (encoder_diffState == ENCODER_DIFF_CW)
|
if (encoder_diffState == ENCODER_DIFF_CW) \
|
||||||
valref += EncoderRate.encoderMoveValue;
|
valref += EncoderRate.encoderMoveValue; \
|
||||||
else if (encoder_diffState == ENCODER_DIFF_CCW)
|
else if (encoder_diffState == ENCODER_DIFF_CCW) \
|
||||||
valref -= EncoderRate.encoderMoveValue;
|
valref -= EncoderRate.encoderMoveValue; \
|
||||||
else if (encoder_diffState == ENCODER_DIFF_ENTER)
|
else if (encoder_diffState == ENCODER_DIFF_ENTER) \
|
||||||
return true;
|
return true; \
|
||||||
return false;
|
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,6 +249,7 @@ typedef struct {
|
||||||
float Move_E_scale = 0;
|
float Move_E_scale = 0;
|
||||||
#endif
|
#endif
|
||||||
float offset_value = 0;
|
float offset_value = 0;
|
||||||
|
TERN_(__STM32F1__, signed)
|
||||||
char show_mode = 0; // -1: Temperature control 0: Printing temperature
|
char show_mode = 0; // -1: Temperature control 0: Printing temperature
|
||||||
} HMI_value_t;
|
} HMI_value_t;
|
||||||
|
|
||||||
|
|
|
@ -592,15 +592,12 @@ void AnycubicTFTClass::GetCommandFromTFT() {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case 5: { // A5 GET CURRENT COORDINATE
|
case 5: { // A5 GET CURRENT COORDINATE
|
||||||
float xPostition = ExtUI::getAxisPosition_mm(ExtUI::X);
|
const float xPosition = ExtUI::getAxisPosition_mm(ExtUI::X),
|
||||||
float yPostition = ExtUI::getAxisPosition_mm(ExtUI::Y);
|
yPosition = ExtUI::getAxisPosition_mm(ExtUI::Y),
|
||||||
float zPostition = ExtUI::getAxisPosition_mm(ExtUI::Z);
|
zPosition = ExtUI::getAxisPosition_mm(ExtUI::Z);
|
||||||
SEND_PGM("A5V X: ");
|
SEND_PGM("A5V X: "); LCD_SERIAL.print(xPosition);
|
||||||
LCD_SERIAL.print(xPostition);
|
SEND_PGM( " Y: "); LCD_SERIAL.print(yPosition);
|
||||||
SEND_PGM(" Y: ");
|
SEND_PGM( " Z: "); LCD_SERIAL.print(zPosition);
|
||||||
LCD_SERIAL.print(yPostition);
|
|
||||||
SEND_PGM(" Z: ");
|
|
||||||
LCD_SERIAL.print(zPostition);
|
|
||||||
SENDLINE_PGM("");
|
SENDLINE_PGM("");
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
|
|
@ -282,27 +282,24 @@ void esp_port_begin(uint8_t interrupt) {
|
||||||
dma_init();
|
dma_init();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (interrupt) {
|
|
||||||
#if ENABLED(MKS_WIFI_MODULE)
|
#if ENABLED(MKS_WIFI_MODULE)
|
||||||
WIFISERIAL.end();
|
WIFISERIAL.end();
|
||||||
for (uint16_t i = 0; i < 65535; i++);
|
for (uint16_t i = 0; i < 65535; i++) { /*nada*/ }
|
||||||
WIFISERIAL.begin(WIFI_BAUDRATE);
|
WIFISERIAL.begin(interrupt ? WIFI_BAUDRATE : WIFI_UPLOAD_BAUDRATE);
|
||||||
uint32_t serial_connect_timeout = millis() + 1000UL;
|
|
||||||
|
const millis_t serial_connect_timeout = millis() + 1000UL;
|
||||||
while (/*!WIFISERIAL && */PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
|
while (/*!WIFISERIAL && */PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
|
||||||
|
|
||||||
|
if (interrupt) {
|
||||||
//for (uint8_t i=0;i<100;i++) WIFISERIAL.write(0x33);
|
//for (uint8_t i=0;i<100;i++) WIFISERIAL.write(0x33);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else {
|
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);
|
//for (uint16_t i=0;i<65535;i++); //WIFISERIAL.write(0x33);
|
||||||
#endif
|
|
||||||
dma_init();
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (!interrupt) dma_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLED(MKS_WIFI_MODULE)
|
#if ENABLED(MKS_WIFI_MODULE)
|
||||||
|
|
|
@ -50,10 +50,6 @@
|
||||||
#include "stepper.h"
|
#include "stepper.h"
|
||||||
#include "temperature.h"
|
#include "temperature.h"
|
||||||
|
|
||||||
#if ENABLED(DWIN_CREALITY_LCD)
|
|
||||||
#include "../lcd/dwin/e3v2/dwin.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "../lcd/marlinui.h"
|
#include "../lcd/marlinui.h"
|
||||||
#include "../libs/vector_3.h" // for matrix_3x3
|
#include "../libs/vector_3.h" // for matrix_3x3
|
||||||
#include "../gcode/gcode.h"
|
#include "../gcode/gcode.h"
|
||||||
|
|
|
@ -258,7 +258,20 @@
|
||||||
* EXP2 EXP1
|
* 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)
|
#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."
|
#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 a new issue