Skip to content

Commit

Permalink
✨ Ender-3 V2 CrealityUI Enhanced (#21942, #22728, #22733)
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
  • Loading branch information
mriscoc and thinkyhead committed Oct 3, 2021
1 parent 54416f7 commit 6cf2cf7
Show file tree
Hide file tree
Showing 45 changed files with 6,545 additions and 86 deletions.
5 changes: 5 additions & 0 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -2756,6 +2756,11 @@
//
//#define DWIN_CREALITY_LCD

//
// Ender-3 v2 OEM display, enhanced.
//
//#define DWIN_CREALITY_LCD_ENHANCED

//
// Ender-3 v2 OEM display with enhancements by Jacob Myers
//
Expand Down
13 changes: 8 additions & 5 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@
#if ENABLED(DWIN_CREALITY_LCD)
#include "lcd/e3v2/creality/dwin.h"
#include "lcd/e3v2/creality/rotary_encoder.h"
#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
#include "lcd/e3v2/enhanced/dwin.h"
#include "lcd/e3v2/enhanced/rotary_encoder.h"
#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
#include "lcd/e3v2/jyersui/dwin.h"
#include "lcd/e3v2/jyersui/rotary_encoder.h"
Expand Down Expand Up @@ -849,7 +852,7 @@ void idle(bool no_stepper_sleep/*=false*/) {
TERN_(USE_BEEPER, buzzer.tick());

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

// Run i2c Position Encoders
#if ENABLED(I2C_POSITION_ENCODERS)
Expand Down Expand Up @@ -904,7 +907,7 @@ void kill(PGM_P const lcd_error/*=nullptr*/, PGM_P const lcd_component/*=nullptr
// Echo the LCD message to serial for extra context
if (lcd_error) { SERIAL_ECHO_START(); SERIAL_ECHOLNPGM_P(lcd_error); }

#if HAS_DISPLAY
#if EITHER(HAS_DISPLAY, DWIN_CREALITY_LCD_ENHANCED)
ui.kill_screen(lcd_error ?: GET_TEXT(MSG_KILLED), lcd_component ?: NUL_STR);
#else
UNUSED(lcd_error); UNUSED(lcd_component);
Expand Down Expand Up @@ -1315,7 +1318,7 @@ void setup() {
// UI must be initialized before EEPROM
// (because EEPROM code calls the UI).

#if ENABLED(DWIN_CREALITY_LCD)
#if HAS_DWIN_E3V2_BASIC
SETUP_RUN(DWIN_Startup());
#else
SETUP_RUN(ui.init());
Expand Down Expand Up @@ -1590,15 +1593,15 @@ void setup() {
SERIAL_ECHO_TERNARY(err, "BL24CXX Check ", "failed", "succeeded", "!\n");
#endif

#if ENABLED(DWIN_CREALITY_LCD)
#if HAS_DWIN_E3V2_BASIC
Encoder_Configuration();
HMI_Init();
HMI_SetLanguageCache();
HMI_StartFrame(true);
DWIN_StatusChanged_P(GET_TEXT(WELCOME_MSG));
#endif

#if HAS_SERVICE_INTERVALS && DISABLED(DWIN_CREALITY_LCD)
#if HAS_SERVICE_INTERVALS && !HAS_DWIN_E3V2_BASIC
ui.reset_status(true); // Show service messages or keep current status
#endif

Expand Down
13 changes: 12 additions & 1 deletion Marlin/src/feature/pause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@

#if ENABLED(EXTENSIBLE_UI)
#include "../lcd/extui/ui_api.h"
#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
#include "../lcd/e3v2/enhanced/dwin.h"
#endif

#include "../lcd/marlinui.h"
Expand Down Expand Up @@ -242,6 +244,7 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load

TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_FILAMENT_CHANGE_PURGE)));
TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT(MSG_FILAMENT_CHANGE_PURGE), CONTINUE_STR));
TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_Popup_Confirm(ICON_BLTouch, GET_TEXT(MSG_FILAMENT_CHANGE_PURGE), CONTINUE_STR));
wait_for_user = true; // A click or M108 breaks the purge_length loop
for (float purge_count = purge_length; purge_count > 0 && wait_for_user; --purge_count)
unscaled_e_move(1, ADVANCED_PAUSE_PURGE_FEEDRATE);
Expand All @@ -265,7 +268,7 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load
// Show "Purge More" / "Resume" menu and wait for reply
KEEPALIVE_STATE(PAUSED_FOR_USER);
wait_for_user = false;
#if HAS_LCD_MENU
#if EITHER(HAS_LCD_MENU, DWIN_CREALITY_LCD_ENHANCED)
ui.pause_show_message(PAUSE_MESSAGE_OPTION); // Also sets PAUSE_RESPONSE_WAIT_FOR
#else
pause_menu_response = PAUSE_RESPONSE_WAIT_FOR;
Expand Down Expand Up @@ -525,6 +528,8 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep

TERN_(EXTENSIBLE_UI, ExtUI::onStatusChanged_P(GET_TEXT(MSG_REHEATING)));

TERN_(DWIN_CREALITY_LCD_ENHANCED, ui.set_status_P(GET_TEXT(MSG_REHEATING)));

// Re-enable the heaters if they timed out
HOTEND_LOOP() thermalManager.reset_hotend_idle_timer(e);

Expand All @@ -538,8 +543,13 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
const millis_t nozzle_timeout = SEC_TO_MS(PAUSE_PARK_NOZZLE_TIMEOUT);

HOTEND_LOOP() thermalManager.heater_idle[e].start(nozzle_timeout);

TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT(MSG_REHEATDONE), CONTINUE_STR));

TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_REHEATDONE)));

TERN_(DWIN_CREALITY_LCD_ENHANCED, ui.set_status_P(GET_TEXT(MSG_REHEATDONE)));

wait_for_user = true;
nozzle_timed_out = false;

Expand Down Expand Up @@ -675,6 +685,7 @@ void resume_print(const_float_t slow_load_length/*=0*/, const_float_t fast_load_

TERN_(HAS_STATUS_MESSAGE, ui.reset_status());
TERN_(HAS_LCD_MENU, ui.return_to_status());
TERN_(DWIN_CREALITY_LCD_ENHANCED, HMI_ReturnScreen());
}

#endif // ADVANCED_PAUSE_FEATURE
2 changes: 1 addition & 1 deletion Marlin/src/feature/powerloss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ uint8_t PrintJobRecovery::queue_index_r;
uint32_t PrintJobRecovery::cmd_sdpos, // = 0
PrintJobRecovery::sdpos[BUFSIZE];

#if ENABLED(DWIN_CREALITY_LCD)
#if HAS_DWIN_E3V2_BASIC
bool PrintJobRecovery::dwin_flag; // = false
#endif

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/feature/powerloss.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class PrintJobRecovery {
static uint32_t cmd_sdpos, //!< SD position of the next command
sdpos[BUFSIZE]; //!< SD positions of queued commands

#if ENABLED(DWIN_CREALITY_LCD)
#if HAS_DWIN_E3V2_BASIC
static bool dwin_flag;
#endif

Expand Down
3 changes: 3 additions & 0 deletions Marlin/src/feature/runout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ bool FilamentMonitorBase::enabled = true,

#if ENABLED(EXTENSIBLE_UI)
#include "../lcd/extui/ui_api.h"
#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
#include "../lcd/e3v2/enhanced/dwin.h"
#endif

void event_filament_runout(const uint8_t extruder) {
Expand All @@ -86,6 +88,7 @@ void event_filament_runout(const uint8_t extruder) {
#endif

TERN_(EXTENSIBLE_UI, ExtUI::onFilamentRunout(ExtUI::getTool(extruder)));
TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_FilamentRunout(extruder));

#if ANY(HOST_PROMPT_SUPPORT, HOST_ACTION_COMMANDS, MULTI_FILAMENT_SENSOR)
const char tool = '0' + TERN0(MULTI_FILAMENT_SENSOR, extruder);
Expand Down
17 changes: 7 additions & 10 deletions Marlin/src/gcode/bedlevel/abl/G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@

#if ENABLED(EXTENSIBLE_UI)
#include "../../../lcd/extui/ui_api.h"
#endif

#if ENABLED(DWIN_CREALITY_LCD)
#elif ENABLED(DWIN_CREALITY_LCD)
#include "../../../lcd/e3v2/creality/dwin.h"
#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
#include "../../../lcd/e3v2/enhanced/dwin.h"
#endif

#if HAS_MULTI_HOTEND
Expand Down Expand Up @@ -403,10 +403,9 @@ G29_TYPE GcodeSuite::G29() {
#if ENABLED(AUTO_BED_LEVELING_3POINT)
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> 3-point Leveling");
points[0].z = points[1].z = points[2].z = 0; // Probe at 3 arbitrary points
#endif

#if BOTH(AUTO_BED_LEVELING_BILINEAR, EXTENSIBLE_UI)
ExtUI::onMeshLevelingStart();
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
TERN_(EXTENSIBLE_UI, ExtUI::onMeshLevelingStart());
TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_MeshLevelingStart());
#endif

if (!faux) {
Expand Down Expand Up @@ -886,9 +885,7 @@ G29_TYPE GcodeSuite::G29() {
process_subcommands_now_P(PSTR(Z_PROBE_END_SCRIPT));
#endif

#if ENABLED(DWIN_CREALITY_LCD)
DWIN_CompletedLeveling();
#endif
TERN_(HAS_DWIN_E3V2_BASIC, DWIN_CompletedLeveling());

report_current_position();

Expand Down
3 changes: 3 additions & 0 deletions Marlin/src/gcode/bedlevel/mbl/G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@

#if ENABLED(EXTENSIBLE_UI)
#include "../../../lcd/extui/ui_api.h"
#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
#include "../../../lcd/e3v2/enhanced/dwin.h"
#endif

#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
Expand Down Expand Up @@ -191,6 +193,7 @@ void GcodeSuite::G29() {
if (parser.seenval('Z')) {
mbl.z_values[ix][iy] = parser.value_linear_units();
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ix, iy, mbl.z_values[ix][iy]));
TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_MeshUpdate(ix, iy, mbl.z_values[ix][iy]));
}
else
return echo_not_entered('Z');
Expand Down
3 changes: 3 additions & 0 deletions Marlin/src/gcode/bedlevel/ubl/M421.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

#if ENABLED(EXTENSIBLE_UI)
#include "../../../lcd/extui/ui_api.h"
#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
#include "../../../lcd/e3v2/enhanced/dwin.h"
#endif

/**
Expand Down Expand Up @@ -67,6 +69,7 @@ void GcodeSuite::M421() {
float &zval = ubl.z_values[ij.x][ij.y]; // Altering this Mesh Point
zval = hasN ? NAN : parser.value_linear_units() + (hasQ ? zval : 0); // N=NAN, Z=NEWVAL, or Q=ADDVAL
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ij.x, ij.y, zval)); // Ping ExtUI in case it's showing the mesh
TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_MeshUpdate(ij.x, ij.y, zval));
}
}

Expand Down
11 changes: 6 additions & 5 deletions Marlin/src/gcode/calibrate/G28.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@
#endif

#include "../../lcd/marlinui.h"
#if ENABLED(DWIN_CREALITY_LCD)
#include "../../lcd/e3v2/creality/dwin.h"
#endif

#if ENABLED(EXTENSIBLE_UI)
#include "../../lcd/extui/ui_api.h"
#elif ENABLED(DWIN_CREALITY_LCD)
#include "../../lcd/e3v2/creality/dwin.h"
#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
#include "../../lcd/e3v2/enhanced/dwin.h"
#endif

#if HAS_L64XX // set L6470 absolute position registers to counts
Expand Down Expand Up @@ -238,7 +239,7 @@ void GcodeSuite::G28() {
return;
}

TERN_(DWIN_CREALITY_LCD, DWIN_StartHoming());
TERN_(HAS_DWIN_E3V2_BASIC, DWIN_StartHoming());
TERN_(EXTENSIBLE_UI, ExtUI::onHomingStart());

planner.synchronize(); // Wait for planner moves to finish!
Expand Down Expand Up @@ -522,7 +523,7 @@ void GcodeSuite::G28() {

ui.refresh();

TERN_(DWIN_CREALITY_LCD, DWIN_CompletedHoming());
TERN_(HAS_DWIN_E3V2_BASIC, DWIN_CompletedHoming());
TERN_(EXTENSIBLE_UI, ExtUI::onHomingComplete());

report_current_position();
Expand Down
6 changes: 6 additions & 0 deletions Marlin/src/gcode/control/M997.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,17 @@

#if ENABLED(PLATFORM_M997_SUPPORT)

#if ENABLED(DWIN_CREALITY_LCD_ENHANCED)
#include "../../lcd/e3v2/enhanced/dwin.h"
#endif

/**
* M997: Perform in-application firmware update
*/
void GcodeSuite::M997() {

TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_RebootScreen());

flashFirmware(parser.intval('S'));

}
Expand Down
7 changes: 6 additions & 1 deletion Marlin/src/gcode/feature/powerloss/M1000.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,14 @@
#include "../../gcode.h"
#include "../../../feature/powerloss.h"
#include "../../../module/motion.h"

#include "../../../lcd/marlinui.h"
#if ENABLED(EXTENSIBLE_UI)
#include "../../../lcd/extui/ui_api.h"
#elif ENABLED(DWIN_CREALITY_LCD)
#include "../../../lcd/e3v2/creality/dwin.h"
#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
#include "../../../lcd/e3v2/enhanced/dwin.h"
#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
#include "../../../lcd/e3v2/jyersui/dwin.h" // Temporary fix until it can be better implemented
#endif
Expand Down Expand Up @@ -64,7 +69,7 @@ void GcodeSuite::M1000() {
if (parser.seen_test('S')) {
#if HAS_LCD_MENU
ui.goto_screen(menu_job_recovery);
#elif ENABLED(DWIN_CREALITY_LCD)
#elif HAS_DWIN_E3V2_BASIC
recovery.dwin_flag = true;
#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) // Temporary fix until it can be better implemented
CrealityDWIN.Popup_Handler(Resume);
Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/gcode/lcd/M0_M1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#include "../../lcd/marlinui.h"
#elif ENABLED(EXTENSIBLE_UI)
#include "../../lcd/extui/ui_api.h"
#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
#include "../../lcd/e3v2/enhanced/dwin.h"
#endif

#if ENABLED(HOST_PROMPT_SUPPORT)
Expand Down Expand Up @@ -68,6 +70,8 @@ void GcodeSuite::M0_M1() {
ExtUI::onUserConfirmRequired(parser.string_arg); // Can this take an SRAM string??
else
ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_USERWAIT));
#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
DWIN_Popup_Confirm(ICON_BLTouch, parser.string_arg ?: GET_TEXT(MSG_STOPPED), GET_TEXT(MSG_USERWAIT));
#else

if (parser.string_arg) {
Expand Down
28 changes: 21 additions & 7 deletions Marlin/src/gcode/lcd/M73.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,34 @@
#include "../../lcd/marlinui.h"
#include "../../sd/cardreader.h"

#if ENABLED(DWIN_CREALITY_LCD_ENHANCED)
#include "../../lcd/e3v2/enhanced/dwin.h"
#endif

/**
* M73: Set percentage complete (for display on LCD)
*
* Example:
* M73 P25 ; Set progress to 25%
*/
void GcodeSuite::M73() {
if (parser.seenval('P'))
ui.set_progress((PROGRESS_SCALE) > 1
? parser.value_float() * (PROGRESS_SCALE)
: parser.value_byte()
);
#if ENABLED(USE_M73_REMAINING_TIME)
if (parser.seenval('R')) ui.set_remaining_time(60 * parser.value_ulong());

#if ENABLED(DWIN_CREALITY_LCD_ENHANCED)

DWIN_Progress_Update();

#else

if (parser.seenval('P'))
ui.set_progress((PROGRESS_SCALE) > 1
? parser.value_float() * (PROGRESS_SCALE)
: parser.value_byte()
);

#if ENABLED(USE_M73_REMAINING_TIME)
if (parser.seenval('R')) ui.set_remaining_time(60 * parser.value_ulong());
#endif

#endif
}

Expand Down
3 changes: 3 additions & 0 deletions Marlin/src/gcode/sd/M1001.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@

#if ENABLED(EXTENSIBLE_UI)
#include "../../lcd/extui/ui_api.h"
#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
#include "../../lcd/e3v2/enhanced/dwin.h"
#endif

#if ENABLED(HOST_ACTION_COMMANDS)
Expand Down Expand Up @@ -106,6 +108,7 @@ void GcodeSuite::M1001() {
#endif

TERN_(EXTENSIBLE_UI, ExtUI::onPrintFinished());
TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_Print_Finished());

// Re-select the last printed file in the UI
TERN_(SD_REPRINT_LAST_SELECTED_FILE, ui.reselect_last_file());
Expand Down
Loading

0 comments on commit 6cf2cf7

Please sign in to comment.