Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] MarlinUI for Creality DWIN #19371

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -2320,6 +2320,12 @@
//
//#define DWIN_CREALITY_LCD

//
// MarlinUI for Creality's DWIN display (and others)
//
//#define DWIN_MARLINUI_PORTRAIT
//#define DWIN_MARLINUI_LANDSCAPE

//
// ADS7843/XPT2046 ADC Touchscreen such as ILI9341 2.8
//
Expand Down
7 changes: 1 addition & 6 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@

#if ENABLED(DWIN_CREALITY_LCD)
#include "lcd/dwin/e3v2/dwin.h"
#include "lcd/dwin/dwin_lcd.h"
#include "lcd/dwin/e3v2/rotary_encoder.h"
#endif

Expand Down Expand Up @@ -1077,11 +1076,7 @@ void setup() {
// (because EEPROM code calls the UI).

#if ENABLED(DWIN_CREALITY_LCD)
delay(800); // Required delay (since boot?)
SERIAL_ECHOPGM("\nDWIN handshake ");
if (DWIN_Handshake()) SERIAL_ECHOLNPGM("ok."); else SERIAL_ECHOLNPGM("error.");
DWIN_Frame_SetDir(1); // Orientation 90°
DWIN_UpdateLCD(); // Show bootscreen (first image)
SETUP_RUN(DWIN_Startup());
#else
SETUP_RUN(ui.init());
#if HAS_WIRED_LCD && ENABLED(SHOW_BOOTSCREEN)
Expand Down
7 changes: 4 additions & 3 deletions Marlin/src/core/boards.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,10 @@
#define BOARD_CHITU3D_V6 4034 // Chitu3D TronXY X5SA V5 Board
#define BOARD_CREALITY_V4 4035 // Creality v4.x (STM32F103RE)
#define BOARD_CREALITY_V427 4036 // Creality v4.2.7 (STM32F103RE)
#define BOARD_TRIGORILLA_PRO 4037 // Trigorilla Pro (STM32F103ZET6)
#define BOARD_FLY_MINI 4038 // FLY MINI (STM32F103RCT6)
#define BOARD_FLSUN_HISPEED 4039 // FLSUN HiSpeedV1 (STM32F103VET6)
#define BOARD_CREALITY_CR_6_SE 4037 // Creality v4.5.2 (STM32F103??)
#define BOARD_TRIGORILLA_PRO 4038 // Trigorilla Pro (STM32F103ZET6)
#define BOARD_FLY_MINI 4039 // FLY MINI (STM32F103RCT6)
#define BOARD_FLSUN_HISPEED 4040 // FLSUN HiSpeedV1 (STM32F103VET6)

//
// ARM Cortex-M4F
Expand Down
3 changes: 3 additions & 0 deletions Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,9 @@
#define HAS_MARLINUI_U8GLIB 1
#elif IS_TFTGLCD_PANEL
// Neither DOGM nor HD44780. Fully customized interface.
#elif IS_DWIN_MARLINUI
// Since HAS_MARLINUI_U8GLIB refers to U8G displays
// the DWIN display can define its own flags
#elif DISABLED(HAS_GRAPHICAL_TFT)
#define HAS_MARLINUI_HD44780 1
#endif
Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -2661,13 +2661,17 @@
#ifndef LCD_WIDTH
#if HAS_MARLINUI_U8GLIB
#define LCD_WIDTH 21
#elif IS_DWIN_MARLINUI
// Defined by header
#else
#define LCD_WIDTH TERN(IS_ULTIPANEL, 20, 16)
#endif
#endif
#ifndef LCD_HEIGHT
#if HAS_MARLINUI_U8GLIB
#define LCD_HEIGHT 5
#elif IS_DWIN_MARLINUI
// Defined by header
#else
#define LCD_HEIGHT TERN(IS_ULTIPANEL, 4, 2)
#endif
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -2222,6 +2222,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
+ COUNT_ENABLED(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON, ANYCUBIC_TFT35) \
+ COUNT_ENABLED(DGUS_LCD_UI_ORIGIN, DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_HIPRECY) \
+ COUNT_ENABLED(ENDER2_STOCKDISPLAY, CR10_STOCKDISPLAY, DWIN_CREALITY_LCD) \
+ COUNT_ENABLED(ULTRALCD_DWIN_PORTRAIT, ULTRALCD_DWIN_LANDSCAPE) \
+ COUNT_ENABLED(FYSETC_MINI_12864_X_X, FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1, FYSETC_GENERIC_12864_1_1) \
+ COUNT_ENABLED(LCD_SAINSMART_I2C_1602, LCD_SAINSMART_I2C_2004) \
+ COUNT_ENABLED(MKS_12864OLED, MKS_12864OLED_SSD1306) \
Expand Down
14 changes: 12 additions & 2 deletions Marlin/src/lcd/dwin/dwin_lcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

#include "../../inc/MarlinConfigPre.h"

#if ENABLED(DWIN_CREALITY_LCD)
#if ANY(DWIN_CREALITY_LCD, DWIN_MARLINUI_PORTRAIT, DWIN_MARLINUI_LANDSCAPE)

#include "../../inc/MarlinConfig.h"

Expand Down Expand Up @@ -115,6 +115,16 @@ bool DWIN_Handshake(void) {
&& databuf[3] == 'K' );
}

void DWIN_Startup(void) {
DEBUG_ECHOPGM("\r\nDWIN handshake ");
delay(750); // Delay here or init later in the boot process
const bool success = DWIN_Handshake();
if (success) DEBUG_ECHOLNPGM("ok."); else DEBUG_ECHOLNPGM("error.");
DWIN_Frame_SetDir(DISABLED(DWIN_MARLINUI_LANDSCAPE) ? 1 : 0);
TERN(SHOW_BOOTSCREEN,,DWIN_Frame_Clear(Color_Bg_Black));
DWIN_UpdateLCD();
}

// Set the backlight luminance
// luminance: (0x00-0xFF)
void DWIN_Backlight_SetLuminance(const uint8_t luminance) {
Expand Down Expand Up @@ -452,4 +462,4 @@ void DWIN_ICON_AnimationControl(uint16_t state) {
//
// Flash writing returns 0xA5 0x4F 0x4B

#endif // DWIN_CREALITY_LCD
#endif // DWIN_CREALITY_LCD || DWIN_MARLINUI_PORTRAIT || DWIN_MARLINUI_LANDSCAPE
152 changes: 150 additions & 2 deletions Marlin/src/lcd/dwin/dwin_lcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,156 @@
#define DWIN_SCROLL_UP 2
#define DWIN_SCROLL_DOWN 3

#define DWIN_WIDTH 272
#define DWIN_HEIGHT 480
#if DISABLED(DWIN_MARLINUI_LANDSCAPE)
#define DWIN_WIDTH 272
#define DWIN_HEIGHT 480
#else
#define DWIN_WIDTH 480
#define DWIN_HEIGHT 272
#endif

// Character matrix width x height
//#define LCD_WIDTH ((DWIN_WIDTH) / 8)
//#define LCD_HEIGHT ((DWIN_HEIGHT) / 12)

// Picture ID
#define DWIN_Boot_Screen 0
#define Language_English 1
#define Language_Chinese 2

// ICON ID
#define ICON 0x09
#define ICON_LOGO 0
#define ICON_Print_0 1
#define ICON_Print_1 2
#define ICON_Prepare_0 3
#define ICON_Prepare_1 4
#define ICON_Control_0 5
#define ICON_Control_1 6
#define ICON_Leveling_0 7
#define ICON_Leveling_1 8
#define ICON_HotendTemp 9
#define ICON_BedTemp 10
#define ICON_Speed 11
#define ICON_Zoffset 12
#define ICON_Back 13
#define ICON_File 14
#define ICON_PrintTime 15
#define ICON_RemainTime 16
#define ICON_Setup_0 17
#define ICON_Setup_1 18
#define ICON_Pause_0 19
#define ICON_Pause_1 20
#define ICON_Continue_0 21
#define ICON_Continue_1 22
#define ICON_Stop_0 23
#define ICON_Stop_1 24
#define ICON_Bar 25
#define ICON_More 26

#define ICON_Axis 27
#define ICON_CloseMotor 28
#define ICON_Homing 29
#define ICON_SetHome 30
#define ICON_PLAPreheat 31
#define ICON_ABSPreheat 32
#define ICON_Cool 33
#define ICON_Language 34

#define ICON_MoveX 35
#define ICON_MoveY 36
#define ICON_MoveZ 37
#define ICON_Extruder 38

#define ICON_Temperature 40
#define ICON_Motion 41
#define ICON_WriteEEPROM 42
#define ICON_ReadEEPROM 43
#define ICON_ResumeEEPROM 44
#define ICON_Info 45

#define ICON_SetEndTemp 46
#define ICON_SetBedTemp 47
#define ICON_FanSpeed 48
#define ICON_SetPLAPreheat 49
#define ICON_SetABSPreheat 50

#define ICON_MaxSpeed 51
#define ICON_MaxAccelerated 52
#define ICON_MaxJerk 53
#define ICON_Step 54
#define ICON_PrintSize 55
#define ICON_Version 56
#define ICON_Contact 57
#define ICON_StockConfiguraton 58
#define ICON_MaxSpeedX 59
#define ICON_MaxSpeedY 60
#define ICON_MaxSpeedZ 61
#define ICON_MaxSpeedE 62
#define ICON_MaxAccX 63
#define ICON_MaxAccY 64
#define ICON_MaxAccZ 65
#define ICON_MaxAccE 66
#define ICON_MaxSpeedJerkX 67
#define ICON_MaxSpeedJerkY 68
#define ICON_MaxSpeedJerkZ 69
#define ICON_MaxSpeedJerkE 70
#define ICON_StepX 71
#define ICON_StepY 72
#define ICON_StepZ 73
#define ICON_StepE 74
#define ICON_Setspeed 75
#define ICON_SetZOffset 76
#define ICON_Rectangle 77
#define ICON_BLTouch 78
#define ICON_TempTooLow 79
#define ICON_AutoLeveling 80
#define ICON_TempTooHigh 81
#define ICON_NoTips_C 82
#define ICON_NoTips_E 83
#define ICON_Continue_C 84
#define ICON_Continue_E 85
#define ICON_Cancel_C 86
#define ICON_Cancel_E 87
#define ICON_Confirm_C 88
#define ICON_Confirm_E 89
#define ICON_Info_0 90
#define ICON_Info_1 91

/**
* 3-.0:The font size, 0x00-0x09, corresponds to the font size below:
* 0x00=6*12 0x01=8*16 0x02=10*20 0x03=12*24 0x04=14*28
* 0x05=16*32 0x06=20*40 0x07=24*48 0x08=28*56 0x09=32*64
*/
#define font6x12 0x00
#define font8x16 0x01
#define font10x20 0x02
#define font12x24 0x03
#define font14x28 0x04
#define font16x32 0x05
#define font20x40 0x06
#define font24x48 0x07
#define font28x56 0x08
#define font32x64 0x09

#define DWIN_FONT_MENU font8x16
#define DWIN_FONT_STAT font10x20
#define DWIN_FONT_HEAD font10x20
#define DWIN_FONT_ALERT font10x20

// Color
#define Color_White 0xFFFF
#define Color_Yellow 0xFF0F
#define Color_Bg_Red 0xF00F // Red background color
#define Color_Bg_Window 0x31E8 // Popup background color
#define Color_Bg_Blue 0x1125 // Dark blue background color
#define Color_Bg_Black 0x0841 // Black background color
#define Popup_Text_Color 0xD6BA // Popup font background color
#define Line_Color 0x3A6A // Split line color
#define Rectangle_Color 0xEE2F // Blue square cursor color
#define Percent_Color 0xFE29 // Percentage color
#define BarFill_Color 0x10E4 // Fill color of progress bar
#define Select_Color 0x33BB // Selected color

/*-------------------------------------- System variable function --------------------------------------*/

Expand Down
Loading