Skip to content

Commit 79b38e0

Browse files
authored
🚸 Update Ender3 V2/S1 Pro UI (MarlinFirmware#23878)
1 parent bd3ecc3 commit 79b38e0

40 files changed

+1574
-1208
lines changed

Marlin/src/MarlinCore.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ void idle(bool no_stepper_sleep/*=false*/) {
822822
TERN_(USE_BEEPER, buzzer.tick());
823823

824824
// Handle UI input / draw events
825-
TERN(HAS_DWIN_E3V2_BASIC, DWIN_Update(), ui.update());
825+
TERN(DWIN_CREALITY_LCD, DWIN_Update(), ui.update());
826826

827827
// Run i2c Position Encoders
828828
#if ENABLED(I2C_POSITION_ENCODERS)
@@ -1571,11 +1571,7 @@ void setup() {
15711571
#endif
15721572

15731573
#if HAS_DWIN_E3V2_BASIC
1574-
SETUP_LOG("E3V2 Init");
1575-
Encoder_Configuration();
1576-
HMI_Init();
1577-
HMI_SetLanguageCache();
1578-
HMI_StartFrame(true);
1574+
SETUP_RUN(DWIN_InitScreen());
15791575
#endif
15801576

15811577
#if HAS_SERVICE_INTERVALS && !HAS_DWIN_E3V2_BASIC

Marlin/src/feature/pause.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const bool
407407
#endif
408408

409409
TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_open(PROMPT_INFO, F("Pause"), FPSTR(DISMISS_STR)));
410+
TERN_(DWIN_LCD_PROUI, DWIN_Print_Pause());
410411

411412
// Indicate that the printer is paused
412413
++did_pause_print;
@@ -709,7 +710,7 @@ void resume_print(const_float_t slow_load_length/*=0*/, const_float_t fast_load_
709710

710711
TERN_(HAS_FILAMENT_SENSOR, runout.reset());
711712

712-
TERN_(HAS_STATUS_MESSAGE, ui.reset_status());
713+
TERN(DWIN_LCD_PROUI, DWIN_Print_Resume(), ui.reset_status());
713714
TERN_(HAS_MARLINUI_MENU, ui.return_to_status());
714715
TERN_(DWIN_LCD_PROUI, HMI_ReturnScreen());
715716
}

Marlin/src/gcode/bedlevel/mbl/G29.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ void GcodeSuite::G29() {
105105
if (!ui.wait_for_move) {
106106
queue.inject(parser.seen_test('N') ? F("G28" TERN(CAN_SET_LEVELING_AFTER_G28, "L0", "") "\nG29S2") : F("G29S2"));
107107
TERN_(EXTENSIBLE_UI, ExtUI::onMeshLevelingStart());
108+
TERN_(DWIN_LCD_PROUI, DWIN_MeshLevelingStart());
108109
return;
109110
}
110111
state = MeshNext;
@@ -127,6 +128,7 @@ void GcodeSuite::G29() {
127128
// Save Z for the previous mesh position
128129
mbl.set_zigzag_z(mbl_probe_index - 1, current_position.z);
129130
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ix, iy, current_position.z));
131+
TERN_(DWIN_LCD_PROUI, DWIN_MeshUpdate(_MIN(mbl_probe_index, GRID_MAX_POINTS), int(GRID_MAX_POINTS), current_position.z));
130132
SET_SOFT_ENDSTOP_LOOSE(false);
131133
}
132134
// If there's another point to sample, move there with optional lift.

Marlin/src/gcode/config/M302.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
#include "../gcode.h"
2828
#include "../../module/temperature.h"
2929

30+
#if ENABLED(DWIN_LCD_PROUI)
31+
#include "../../lcd/e3v2/proui/dwin_defines.h"
32+
#endif
33+
3034
/**
3135
* M302: Allow cold extrudes, or set the minimum extrude temperature
3236
*
@@ -47,6 +51,7 @@ void GcodeSuite::M302() {
4751
if (seen_S) {
4852
thermalManager.extrude_min_temp = parser.value_celsius();
4953
thermalManager.allow_cold_extrude = (thermalManager.extrude_min_temp == 0);
54+
TERN_(DWIN_LCD_PROUI, HMI_data.ExtMinT = thermalManager.extrude_min_temp);
5055
}
5156

5257
if (parser.seen('P'))

Marlin/src/gcode/sd/M524.cpp

+16-4
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,27 @@
2727
#include "../gcode.h"
2828
#include "../../sd/cardreader.h"
2929

30+
#if ENABLED(DWIN_LCD_PROUI)
31+
#include "../../lcd/e3v2/proui/dwin.h"
32+
#endif
33+
3034
/**
3135
* M524: Abort the current SD print job (started with M24)
3236
*/
3337
void GcodeSuite::M524() {
3438

35-
if (IS_SD_PRINTING())
36-
card.abortFilePrintSoon();
37-
else if (card.isMounted())
38-
card.closefile();
39+
#if ENABLED(DWIN_LCD_PROUI)
40+
41+
HMI_flag.abort_flag = true; // The LCD will handle it
42+
43+
#else
44+
45+
if (IS_SD_PRINTING())
46+
card.abortFilePrintSoon();
47+
else if (card.isMounted())
48+
card.closefile();
49+
50+
#endif
3951

4052
}
4153

Marlin/src/gcode/stats/M75-M78.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
void GcodeSuite::M75() {
4040
startOrResumeJob();
4141
#if ENABLED(DWIN_LCD_PROUI)
42-
DWIN_Print_Header(parser.string_arg && parser.string_arg[0] ? parser.string_arg : GET_TEXT(MSG_HOST_START_PRINT));
4342
DWIN_Print_Started(false);
43+
if (!IS_SD_PRINTING()) DWIN_Print_Header(parser.string_arg && parser.string_arg[0] ? parser.string_arg : GET_TEXT(MSG_HOST_START_PRINT));
4444
#endif
4545
}
4646

@@ -50,6 +50,7 @@ void GcodeSuite::M75() {
5050
void GcodeSuite::M76() {
5151
print_job_timer.pause();
5252
TERN_(HOST_PAUSE_M76, hostui.pause());
53+
TERN_(DWIN_LCD_PROUI, DWIN_Print_Pause());
5354
}
5455

5556
/**

Marlin/src/inc/Conditionals_LCD.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,9 @@
479479
#if EITHER(HAS_DWIN_E3V2_BASIC, DWIN_CREALITY_LCD_JYERSUI)
480480
#define HAS_DWIN_E3V2 1
481481
#endif
482+
#if ENABLED(DWIN_LCD_PROUI)
483+
#define DO_LIST_BIN_FILES 1
484+
#endif
482485

483486
// E3V2 extras
484487
#if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI
@@ -513,7 +516,7 @@
513516
#endif
514517
#endif
515518

516-
#if ANY(HAS_WIRED_LCD, EXTENSIBLE_UI, DWIN_CREALITY_LCD_JYERSUI)
519+
#if ANY(HAS_WIRED_LCD, EXTENSIBLE_UI, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI)
517520
#define HAS_DISPLAY 1
518521
#endif
519522

Marlin/src/lcd/e3v2/common/encoder.h

+20
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,32 @@ typedef enum {
4545
ENCODER_DIFF_ENTER = 3 // click
4646
} EncoderState;
4747

48+
#define ENCODER_WAIT_MS 20
49+
4850
// Encoder initialization
4951
void Encoder_Configuration();
5052

5153
// Analyze encoder value and return state
5254
EncoderState Encoder_ReceiveAnalyze();
5355

56+
inline EncoderState get_encoder_state() {
57+
static millis_t Encoder_ms = 0;
58+
const millis_t ms = millis();
59+
if (PENDING(ms, Encoder_ms)) return ENCODER_DIFF_NO;
60+
const EncoderState state = Encoder_ReceiveAnalyze();
61+
if (state != ENCODER_DIFF_NO) Encoder_ms = ms + ENCODER_WAIT_MS;
62+
return state;
63+
}
64+
65+
template<typename T>
66+
inline bool Apply_Encoder(const EncoderState &encoder_diffState, T &valref) {
67+
if (encoder_diffState == ENCODER_DIFF_CW)
68+
valref += EncoderRate.encoderMoveValue;
69+
else if (encoder_diffState == ENCODER_DIFF_CCW)
70+
valref -= EncoderRate.encoderMoveValue;
71+
return encoder_diffState == ENCODER_DIFF_ENTER;
72+
}
73+
5474
/*********************** Encoder LED ***********************/
5575

5676
#if PIN_EXISTS(LCD_LED)

Marlin/src/lcd/e3v2/creality/dwin.cpp

+7-18
Original file line numberDiff line numberDiff line change
@@ -471,15 +471,6 @@ void Draw_Back_First(const bool is_sel=true) {
471471
if (is_sel) Draw_Menu_Cursor(0);
472472
}
473473

474-
template <typename T>
475-
inline bool Apply_Encoder(const EncoderState &encoder_diffState, T &valref) {
476-
if (encoder_diffState == ENCODER_DIFF_CW)
477-
valref += EncoderRate.encoderMoveValue;
478-
else if (encoder_diffState == ENCODER_DIFF_CCW)
479-
valref -= EncoderRate.encoderMoveValue;
480-
return encoder_diffState == ENCODER_DIFF_ENTER;
481-
}
482-
483474
//
484475
// Draw Menus
485476
//
@@ -1296,15 +1287,6 @@ void Goto_MainMenu() {
12961287
TERN(HAS_ONESTEP_LEVELING, ICON_Leveling, ICON_StartInfo)();
12971288
}
12981289

1299-
inline EncoderState get_encoder_state() {
1300-
static millis_t Encoder_ms = 0;
1301-
const millis_t ms = millis();
1302-
if (PENDING(ms, Encoder_ms)) return ENCODER_DIFF_NO;
1303-
const EncoderState state = Encoder_ReceiveAnalyze();
1304-
if (state != ENCODER_DIFF_NO) Encoder_ms = ms + ENCODER_WAIT_MS;
1305-
return state;
1306-
}
1307-
13081290
void HMI_Plan_Move(const feedRate_t fr_mm_s) {
13091291
if (!planner.is_full()) {
13101292
planner.synchronize();
@@ -4086,6 +4068,13 @@ void HMI_Init() {
40864068
HMI_SetLanguage();
40874069
}
40884070

4071+
void DWIN_InitScreen() {
4072+
Encoder_Configuration();
4073+
HMI_Init();
4074+
HMI_SetLanguageCache();
4075+
HMI_StartFrame(true);
4076+
}
4077+
40894078
void DWIN_Update() {
40904079
EachMomentUpdate(); // Status update
40914080
HMI_SDCardUpdate(); // SD card update

Marlin/src/lcd/e3v2/creality/dwin.h

+1
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ void HMI_MaxJerk(); // Maximum jerk speed submenu
236236
void HMI_Step(); // Transmission ratio
237237

238238
void HMI_Init();
239+
void DWIN_InitScreen();
239240
void DWIN_Update();
240241
void EachMomentUpdate();
241242
void DWIN_HandleScreen();

0 commit comments

Comments
 (0)