Skip to content

Commit

Permalink
🚸 Update Ender3 V2/S1 Pro UI (MarlinFirmware#23878)
Browse files Browse the repository at this point in the history
  • Loading branch information
mriscoc authored and mh-dm committed May 15, 2022
1 parent 6e25e09 commit 12087fd
Show file tree
Hide file tree
Showing 40 changed files with 1,574 additions and 1,208 deletions.
8 changes: 2 additions & 6 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ void idle(bool no_stepper_sleep/*=false*/) {
TERN_(USE_BEEPER, buzzer.tick());

// Handle UI input / draw events
TERN(HAS_DWIN_E3V2_BASIC, DWIN_Update(), ui.update());
TERN(DWIN_CREALITY_LCD, DWIN_Update(), ui.update());

// Run i2c Position Encoders
#if ENABLED(I2C_POSITION_ENCODERS)
Expand Down Expand Up @@ -1571,11 +1571,7 @@ void setup() {
#endif

#if HAS_DWIN_E3V2_BASIC
SETUP_LOG("E3V2 Init");
Encoder_Configuration();
HMI_Init();
HMI_SetLanguageCache();
HMI_StartFrame(true);
SETUP_RUN(DWIN_InitScreen());
#endif

#if HAS_SERVICE_INTERVALS && !HAS_DWIN_E3V2_BASIC
Expand Down
3 changes: 2 additions & 1 deletion Marlin/src/feature/pause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const bool
#endif

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

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

TERN_(HAS_FILAMENT_SENSOR, runout.reset());

TERN_(HAS_STATUS_MESSAGE, ui.reset_status());
TERN(DWIN_LCD_PROUI, DWIN_Print_Resume(), ui.reset_status());
TERN_(HAS_MARLINUI_MENU, ui.return_to_status());
TERN_(DWIN_LCD_PROUI, HMI_ReturnScreen());
}
Expand Down
2 changes: 2 additions & 0 deletions Marlin/src/gcode/bedlevel/mbl/G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ void GcodeSuite::G29() {
if (!ui.wait_for_move) {
queue.inject(parser.seen_test('N') ? F("G28" TERN(CAN_SET_LEVELING_AFTER_G28, "L0", "") "\nG29S2") : F("G29S2"));
TERN_(EXTENSIBLE_UI, ExtUI::onMeshLevelingStart());
TERN_(DWIN_LCD_PROUI, DWIN_MeshLevelingStart());
return;
}
state = MeshNext;
Expand All @@ -127,6 +128,7 @@ void GcodeSuite::G29() {
// Save Z for the previous mesh position
mbl.set_zigzag_z(mbl_probe_index - 1, current_position.z);
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ix, iy, current_position.z));
TERN_(DWIN_LCD_PROUI, DWIN_MeshUpdate(_MIN(mbl_probe_index, GRID_MAX_POINTS), int(GRID_MAX_POINTS), current_position.z));
SET_SOFT_ENDSTOP_LOOSE(false);
}
// If there's another point to sample, move there with optional lift.
Expand Down
5 changes: 5 additions & 0 deletions Marlin/src/gcode/config/M302.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
#include "../gcode.h"
#include "../../module/temperature.h"

#if ENABLED(DWIN_LCD_PROUI)
#include "../../lcd/e3v2/proui/dwin_defines.h"
#endif

/**
* M302: Allow cold extrudes, or set the minimum extrude temperature
*
Expand All @@ -47,6 +51,7 @@ void GcodeSuite::M302() {
if (seen_S) {
thermalManager.extrude_min_temp = parser.value_celsius();
thermalManager.allow_cold_extrude = (thermalManager.extrude_min_temp == 0);
TERN_(DWIN_LCD_PROUI, HMI_data.ExtMinT = thermalManager.extrude_min_temp);
}

if (parser.seen('P'))
Expand Down
20 changes: 16 additions & 4 deletions Marlin/src/gcode/sd/M524.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,27 @@
#include "../gcode.h"
#include "../../sd/cardreader.h"

#if ENABLED(DWIN_LCD_PROUI)
#include "../../lcd/e3v2/proui/dwin.h"
#endif

/**
* M524: Abort the current SD print job (started with M24)
*/
void GcodeSuite::M524() {

if (IS_SD_PRINTING())
card.abortFilePrintSoon();
else if (card.isMounted())
card.closefile();
#if ENABLED(DWIN_LCD_PROUI)

HMI_flag.abort_flag = true; // The LCD will handle it

#else

if (IS_SD_PRINTING())
card.abortFilePrintSoon();
else if (card.isMounted())
card.closefile();

#endif

}

Expand Down
3 changes: 2 additions & 1 deletion Marlin/src/gcode/stats/M75-M78.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
void GcodeSuite::M75() {
startOrResumeJob();
#if ENABLED(DWIN_LCD_PROUI)
DWIN_Print_Header(parser.string_arg && parser.string_arg[0] ? parser.string_arg : GET_TEXT(MSG_HOST_START_PRINT));
DWIN_Print_Started(false);
if (!IS_SD_PRINTING()) DWIN_Print_Header(parser.string_arg && parser.string_arg[0] ? parser.string_arg : GET_TEXT(MSG_HOST_START_PRINT));
#endif
}

Expand All @@ -50,6 +50,7 @@ void GcodeSuite::M75() {
void GcodeSuite::M76() {
print_job_timer.pause();
TERN_(HOST_PAUSE_M76, hostui.pause());
TERN_(DWIN_LCD_PROUI, DWIN_Print_Pause());
}

/**
Expand Down
5 changes: 4 additions & 1 deletion Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,9 @@
#if EITHER(HAS_DWIN_E3V2_BASIC, DWIN_CREALITY_LCD_JYERSUI)
#define HAS_DWIN_E3V2 1
#endif
#if ENABLED(DWIN_LCD_PROUI)
#define DO_LIST_BIN_FILES 1
#endif

// E3V2 extras
#if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI
Expand Down Expand Up @@ -513,7 +516,7 @@
#endif
#endif

#if ANY(HAS_WIRED_LCD, EXTENSIBLE_UI, DWIN_CREALITY_LCD_JYERSUI)
#if ANY(HAS_WIRED_LCD, EXTENSIBLE_UI, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI)
#define HAS_DISPLAY 1
#endif

Expand Down
20 changes: 20 additions & 0 deletions Marlin/src/lcd/e3v2/common/encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,32 @@ typedef enum {
ENCODER_DIFF_ENTER = 3 // click
} EncoderState;

#define ENCODER_WAIT_MS 20

// Encoder initialization
void Encoder_Configuration();

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

inline EncoderState get_encoder_state() {
static millis_t Encoder_ms = 0;
const millis_t ms = millis();
if (PENDING(ms, Encoder_ms)) return ENCODER_DIFF_NO;
const EncoderState state = Encoder_ReceiveAnalyze();
if (state != ENCODER_DIFF_NO) Encoder_ms = ms + ENCODER_WAIT_MS;
return state;
}

template<typename T>
inline bool Apply_Encoder(const EncoderState &encoder_diffState, T &valref) {
if (encoder_diffState == ENCODER_DIFF_CW)
valref += EncoderRate.encoderMoveValue;
else if (encoder_diffState == ENCODER_DIFF_CCW)
valref -= EncoderRate.encoderMoveValue;
return encoder_diffState == ENCODER_DIFF_ENTER;
}

/*********************** Encoder LED ***********************/

#if PIN_EXISTS(LCD_LED)
Expand Down
25 changes: 7 additions & 18 deletions Marlin/src/lcd/e3v2/creality/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,15 +471,6 @@ void Draw_Back_First(const bool is_sel=true) {
if (is_sel) Draw_Menu_Cursor(0);
}

template <typename T>
inline bool Apply_Encoder(const EncoderState &encoder_diffState, T &valref) {
if (encoder_diffState == ENCODER_DIFF_CW)
valref += EncoderRate.encoderMoveValue;
else if (encoder_diffState == ENCODER_DIFF_CCW)
valref -= EncoderRate.encoderMoveValue;
return encoder_diffState == ENCODER_DIFF_ENTER;
}

//
// Draw Menus
//
Expand Down Expand Up @@ -1296,15 +1287,6 @@ void Goto_MainMenu() {
TERN(HAS_ONESTEP_LEVELING, ICON_Leveling, ICON_StartInfo)();
}

inline EncoderState get_encoder_state() {
static millis_t Encoder_ms = 0;
const millis_t ms = millis();
if (PENDING(ms, Encoder_ms)) return ENCODER_DIFF_NO;
const EncoderState state = Encoder_ReceiveAnalyze();
if (state != ENCODER_DIFF_NO) Encoder_ms = ms + ENCODER_WAIT_MS;
return state;
}

void HMI_Plan_Move(const feedRate_t fr_mm_s) {
if (!planner.is_full()) {
planner.synchronize();
Expand Down Expand Up @@ -4086,6 +4068,13 @@ void HMI_Init() {
HMI_SetLanguage();
}

void DWIN_InitScreen() {
Encoder_Configuration();
HMI_Init();
HMI_SetLanguageCache();
HMI_StartFrame(true);
}

void DWIN_Update() {
EachMomentUpdate(); // Status update
HMI_SDCardUpdate(); // SD card update
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/lcd/e3v2/creality/dwin.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ void HMI_MaxJerk(); // Maximum jerk speed submenu
void HMI_Step(); // Transmission ratio

void HMI_Init();
void DWIN_InitScreen();
void DWIN_Update();
void EachMomentUpdate();
void DWIN_HandleScreen();
Expand Down
Loading

0 comments on commit 12087fd

Please sign in to comment.