From ed643e634fbd98d21e22fdcdf615532cc9cf0def Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 14 Jul 2022 21:03:11 -0500 Subject: [PATCH 01/32] =?UTF-8?q?=F0=9F=94=A8=20Fix=20Warnings/settings=20?= =?UTF-8?q?force-recompile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PlatformIO/scripts/preflight-checks.py | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/buildroot/share/PlatformIO/scripts/preflight-checks.py b/buildroot/share/PlatformIO/scripts/preflight-checks.py index dbd0510b5dff..d0f1c138c94a 100644 --- a/buildroot/share/PlatformIO/scripts/preflight-checks.py +++ b/buildroot/share/PlatformIO/scripts/preflight-checks.py @@ -78,21 +78,27 @@ def sanity_check_target(): err = "ERROR: Config files found in directory %s. Please move them into the Marlin subfolder." % p raise SystemExit(err) + # + # Find the name.cpp.o or name.o and remove it + # + def rm_ofile(subdir, name): + build_dir = os.path.join(env['PROJECT_BUILD_DIR'], build_env); + for outdir in [ build_dir, os.path.join(build_dir, "debug") ]: + for ext in [ ".cpp.o", ".o" ]: + fpath = os.path.join(outdir, "src", "src", subdir, name + ext) + if os.path.exists(fpath): + os.remove(fpath) + # # Give warnings on every build # - srcpath = os.path.join(env['PROJECT_BUILD_DIR'], build_env, "src", "src") - warnfile = os.path.join(srcpath, "inc", "Warnings.cpp.o") - if os.path.exists(warnfile): - os.remove(warnfile) + rm_ofile("inc", "Warnings") # # Rebuild 'settings.cpp' for EEPROM_INIT_NOW # if 'EEPROM_INIT_NOW' in env['MARLIN_FEATURES']: - setfile = os.path.join(srcpath, "module", "settings.cpp.o") - if os.path.exists(setfile): - os.remove(setfile) + rm_ofile("module", "settings") # # Check for old files indicating an entangled Marlin (mixing old and new code) From 923d34550a828f483d73481242782715080ebc7e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 14 Jul 2022 21:56:13 -0500 Subject: [PATCH 02/32] =?UTF-8?q?=F0=9F=94=A8=20PlatformIO=20"--target=20u?= =?UTF-8?q?pload"=20=3D=3D=20"--target=20exec"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildroot/share/PlatformIO/scripts/simulator.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/buildroot/share/PlatformIO/scripts/simulator.py b/buildroot/share/PlatformIO/scripts/simulator.py index c6a5277b92ad..2961d2826d41 100644 --- a/buildroot/share/PlatformIO/scripts/simulator.py +++ b/buildroot/share/PlatformIO/scripts/simulator.py @@ -50,5 +50,3 @@ # Break out of the PIO build immediately sys.exit(1) - - env.AddCustomTarget("upload", "$BUILD_DIR/${PROGNAME}", "$BUILD_DIR/${PROGNAME}") From 678955949f980f2bfa942a1a8dc4542a20423bd1 Mon Sep 17 00:00:00 2001 From: Victor Oliveira Date: Sat, 2 Jul 2022 21:31:27 -0300 Subject: [PATCH 03/32] =?UTF-8?q?=F0=9F=94=A8=20Disable=20stack=20protecto?= =?UTF-8?q?r=20on=20macOS=20simulator=20(#24443)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ini/native.ini | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ini/native.ini b/ini/native.ini index e860a55958f2..693a985d4e92 100644 --- a/ini/native.ini +++ b/ini/native.ini @@ -78,7 +78,7 @@ build_flags = ${simulator_linux.build_flags} ${simulator_linux.release_flags} # If Xcode is installed be sure to run `xcode-select --install` first. # [simulator_macos] -build_unflags = -lGL +build_unflags = -lGL -fstack-protector-strong build_flags = -I/opt/local/include -I/opt/local/include/freetype2 @@ -87,6 +87,7 @@ build_flags = -Wl,-framework,OpenGl -Wl,-framework,CoreFoundation -lSDL2 + -fno-stack-protector [env:simulator_macos_debug] extends = env:simulator_linux_debug From e4f85e8fbc57e4688b966fa29823c51ba5bb2588 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 3 Jul 2022 10:32:47 -0500 Subject: [PATCH 04/32] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Encapsulate=20PID=20?= =?UTF-8?q?in=20class=20(#24389)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/MarlinCore.cpp | 2 +- Marlin/src/core/language.h | 4 - Marlin/src/core/utility.cpp | 4 +- Marlin/src/gcode/motion/G2_G3.cpp | 2 +- Marlin/src/gcode/queue.cpp | 2 +- Marlin/src/lcd/e3v2/jyersui/dwin.cpp | 12 +- Marlin/src/lcd/extui/ui_api.cpp | 2 +- Marlin/src/libs/buzzer.cpp | 2 +- Marlin/src/module/motion.cpp | 2 +- Marlin/src/module/planner_bezier.cpp | 2 +- Marlin/src/module/temperature.cpp | 462 +++++++----------- Marlin/src/module/temperature.h | 16 +- .../sd/usb_flashdrive/Sd2Card_FlashDrive.cpp | 2 +- 13 files changed, 216 insertions(+), 298 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 2724006dd193..c1bd973b4a1d 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -789,7 +789,7 @@ void idle(bool no_stepper_sleep/*=false*/) { manage_inactivity(no_stepper_sleep); // Manage Heaters (and Watchdog) - thermalManager.manage_heater(); + thermalManager.task(); // Max7219 heartbeat, animation, etc TERN_(MAX7219_DEBUG, max7219.idle_tasks()); diff --git a/Marlin/src/core/language.h b/Marlin/src/core/language.h index 16d7b1bf663e..157bd6918515 100644 --- a/Marlin/src/core/language.h +++ b/Marlin/src/core/language.h @@ -227,10 +227,6 @@ #define STR_PID_DEBUG " PID_DEBUG " #define STR_PID_DEBUG_INPUT ": Input " #define STR_PID_DEBUG_OUTPUT " Output " -#define STR_PID_DEBUG_PTERM " pTerm " -#define STR_PID_DEBUG_ITERM " iTerm " -#define STR_PID_DEBUG_DTERM " dTerm " -#define STR_PID_DEBUG_CTERM " cTerm " #define STR_INVALID_EXTRUDER_NUM " - Invalid extruder number !" #define STR_MPC_AUTOTUNE "MPC Autotune" #define STR_MPC_AUTOTUNE_START " start for " STR_E diff --git a/Marlin/src/core/utility.cpp b/Marlin/src/core/utility.cpp index 84e4c1f69696..9cdf8dec7bcf 100644 --- a/Marlin/src/core/utility.cpp +++ b/Marlin/src/core/utility.cpp @@ -29,10 +29,10 @@ void safe_delay(millis_t ms) { while (ms > 50) { ms -= 50; delay(50); - thermalManager.manage_heater(); + thermalManager.task(); } delay(ms); - thermalManager.manage_heater(); // This keeps us safe if too many small safe_delay() calls are made + thermalManager.task(); // This keeps us safe if too many small safe_delay() calls are made } // A delay to provide brittle hosts time to receive bytes diff --git a/Marlin/src/gcode/motion/G2_G3.cpp b/Marlin/src/gcode/motion/G2_G3.cpp index d9458f61eb39..14ef9ac2a6f4 100644 --- a/Marlin/src/gcode/motion/G2_G3.cpp +++ b/Marlin/src/gcode/motion/G2_G3.cpp @@ -290,7 +290,7 @@ void plan_arc( for (uint16_t i = 1; i < segments; i++) { // Iterate (segments-1) times - thermalManager.manage_heater(); + thermalManager.task(); const millis_t ms = millis(); if (ELAPSED(ms, next_idle_ms)) { next_idle_ms = ms + 200UL; diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index 454a009b8598..a390a46d8e31 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -384,7 +384,7 @@ inline bool process_line_done(uint8_t &sis, char (&buff)[MAX_CMD_SIZE], int &ind buff[ind] = '\0'; // Of course, I'm a Terminator. const bool is_empty = (ind == 0); // An empty line? if (is_empty) - thermalManager.manage_heater(); // Keep sensors satisfied + thermalManager.task(); // Keep sensors satisfied else ind = 0; // Start a new line return is_empty; // Inform the caller diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp index 5f1507feb332..285013d7504e 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp @@ -1202,7 +1202,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) Popup_Handler(ETemp); else { - if (thermalManager.temp_hotend[0].celsius < thermalManager.temp_hotend[0].target - 2) { + if (thermalManager.temp_hotend[0].is_below_target(-2)) { Popup_Handler(Heating); thermalManager.wait_for_hotend(0); } @@ -1345,7 +1345,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ Popup_Handler(ETemp); } else { - if (thermalManager.temp_hotend[0].celsius < thermalManager.temp_hotend[0].target - 2) { + if (thermalManager.temp_hotend[0].is_below_target(-2)) { Popup_Handler(Heating); thermalManager.wait_for_hotend(0); Redraw_Menu(); @@ -1732,7 +1732,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) Popup_Handler(ETemp); else { - if (thermalManager.temp_hotend[0].celsius < thermalManager.temp_hotend[0].target - 2) { + if (thermalManager.temp_hotend[0].is_below_target(-2)) { Popup_Handler(Heating); thermalManager.wait_for_hotend(0); } @@ -1751,7 +1751,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ Popup_Handler(ETemp); } else { - if (thermalManager.temp_hotend[0].celsius < thermalManager.temp_hotend[0].target - 2) { + if (thermalManager.temp_hotend[0].is_below_target(-2)) { Popup_Handler(Heating); thermalManager.wait_for_hotend(0); } @@ -1769,7 +1769,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) Popup_Handler(ETemp); else { - if (thermalManager.temp_hotend[0].celsius < thermalManager.temp_hotend[0].target - 2) { + if (thermalManager.temp_hotend[0].is_below_target(-2)) { Popup_Handler(Heating); thermalManager.wait_for_hotend(0); } @@ -4404,7 +4404,7 @@ void CrealityDWINClass::Popup_Control() { if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) Popup_Handler(ETemp); else { - if (thermalManager.temp_hotend[0].celsius < thermalManager.temp_hotend[0].target - 2) { + if (thermalManager.temp_hotend[0].is_below_target(-2)) { Popup_Handler(Heating); thermalManager.wait_for_hotend(0); } diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index 68b0a81fe514..57822279c530 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -169,7 +169,7 @@ namespace ExtUI { } void yield() { - if (!flags.printer_killed) thermalManager.manage_heater(); + if (!flags.printer_killed) thermalManager.task(); } void enableHeater(const extruder_t extruder) { diff --git a/Marlin/src/libs/buzzer.cpp b/Marlin/src/libs/buzzer.cpp index a3c838ebc0a3..1e2f23c5fdef 100644 --- a/Marlin/src/libs/buzzer.cpp +++ b/Marlin/src/libs/buzzer.cpp @@ -48,7 +48,7 @@ void Buzzer::tone(const uint16_t duration, const uint16_t frequency/*=0*/) { if (!ui.sound_on) return; while (buffer.isFull()) { tick(); - thermalManager.manage_heater(); + thermalManager.task(); } tone_t tone = { duration, frequency }; buffer.enqueue(tone); diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 36afdb2e485f..b3b607e677a8 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -966,7 +966,7 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { next_idle_ms = ms + 200UL; return idle(); } - thermalManager.manage_heater(); // Returns immediately on most calls + thermalManager.task(); // Returns immediately on most calls } #if IS_KINEMATIC diff --git a/Marlin/src/module/planner_bezier.cpp b/Marlin/src/module/planner_bezier.cpp index fa7e16a387e6..93b118f33054 100644 --- a/Marlin/src/module/planner_bezier.cpp +++ b/Marlin/src/module/planner_bezier.cpp @@ -123,7 +123,7 @@ void cubic_b_spline( for (float t = 0; t < 1;) { - thermalManager.manage_heater(); + thermalManager.task(); millis_t now = millis(); if (ELAPSED(now, next_idle_ms)) { next_idle_ms = now + 200UL; diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 8e12b2c4003b..9bdc6eced71c 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -1318,104 +1318,101 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { } #if ANY(PID_DEBUG, PID_BED_DEBUG, PID_CHAMBER_DEBUG) - bool Temperature::pid_debug_flag; // = 0 + #define HAS_PID_DEBUG 1 + bool Temperature::pid_debug_flag; // = false #endif -#if HAS_HOTEND +#if HAS_PID_HEATING - float Temperature::get_pid_output_hotend(const uint8_t E_NAME) { - const uint8_t ee = HOTEND_INDEX; - #if ENABLED(PIDTEMP) - #if DISABLED(PID_OPENLOOP) - static hotend_pid_t work_pid[HOTENDS]; - static float temp_iState[HOTENDS] = { 0 }, - temp_dState[HOTENDS] = { 0 }; - static Flags pid_reset; - const float pid_error = temp_hotend[ee].target - temp_hotend[ee].celsius; - - float pid_output; - - if (temp_hotend[ee].target == 0 - || pid_error < -(PID_FUNCTIONAL_RANGE) - || TERN0(HEATER_IDLE_HANDLER, heater_idle[ee].timed_out) - ) { - pid_output = 0; - pid_reset.set(ee); + template + class PIDRunner { + public: + TT &tempinfo; + __typeof__(TT::pid) work_pid{0}; + float temp_iState = 0, temp_dState = 0; + bool pid_reset = true; + + PIDRunner(TT &t) : tempinfo(t) { } + + float get_pid_output() { + + #if ENABLED(PID_OPENLOOP) + + return constrain(tempinfo.target, 0, MAX_POW); + + #else // !PID_OPENLOOP + + const float pid_error = tempinfo.target - tempinfo.celsius; + if (!tempinfo.target || pid_error < -(PID_FUNCTIONAL_RANGE)) { + pid_reset = true; + return 0; } else if (pid_error > PID_FUNCTIONAL_RANGE) { - pid_output = PID_MAX; - pid_reset.set(ee); + pid_reset = true; + return MAX_POW; } - else { - if (pid_reset[ee]) { - temp_iState[ee] = 0.0; - work_pid[ee].Kd = 0.0; - pid_reset.clear(ee); - } - work_pid[ee].Kd = work_pid[ee].Kd + PID_K2 * (PID_PARAM(Kd, ee) * (temp_dState[ee] - temp_hotend[ee].celsius) - work_pid[ee].Kd); - const float max_power_over_i_gain = float(PID_MAX) / PID_PARAM(Ki, ee) - float(MIN_POWER); - temp_iState[ee] = constrain(temp_iState[ee] + pid_error, 0, max_power_over_i_gain); - work_pid[ee].Kp = PID_PARAM(Kp, ee) * pid_error; - work_pid[ee].Ki = PID_PARAM(Ki, ee) * temp_iState[ee]; + if (pid_reset) { + pid_reset = false; + temp_iState = 0.0; + work_pid.Kd = 0.0; + } - pid_output = work_pid[ee].Kp + work_pid[ee].Ki + work_pid[ee].Kd + float(MIN_POWER); + const float max_power_over_i_gain = float(MAX_POW) / tempinfo.pid.Ki - float(MIN_POW); + temp_iState = constrain(temp_iState + pid_error, 0, max_power_over_i_gain); - #if ENABLED(PID_EXTRUSION_SCALING) - #if HOTENDS == 1 - constexpr bool this_hotend = true; - #else - const bool this_hotend = (ee == active_extruder); - #endif - work_pid[ee].Kc = 0; - if (this_hotend) { - const long e_position = stepper.position(E_AXIS); - if (e_position > pes_e_position) { - lpq[lpq_ptr] = e_position - pes_e_position; - pes_e_position = e_position; - } - else - lpq[lpq_ptr] = 0; + work_pid.Kp = tempinfo.pid.Kp * pid_error; + work_pid.Ki = tempinfo.pid.Ki * temp_iState; + work_pid.Kd = work_pid.Kd + PID_K2 * (tempinfo.pid.Kd * (temp_dState - tempinfo.celsius) - work_pid.Kd); - if (++lpq_ptr >= lpq_len) lpq_ptr = 0; - work_pid[ee].Kc = (lpq[lpq_ptr] * planner.mm_per_step[E_AXIS]) * PID_PARAM(Kc, ee); - pid_output += work_pid[ee].Kc; - } - #endif // PID_EXTRUSION_SCALING - #if ENABLED(PID_FAN_SCALING) - if (fan_speed[active_extruder] > PID_FAN_SCALING_MIN_SPEED) { - work_pid[ee].Kf = PID_PARAM(Kf, ee) + (PID_FAN_SCALING_LIN_FACTOR) * fan_speed[active_extruder]; - pid_output += work_pid[ee].Kf; - } - //pid_output -= work_pid[ee].Ki; - //pid_output += work_pid[ee].Ki * work_pid[ee].Kf - #endif // PID_FAN_SCALING - LIMIT(pid_output, 0, PID_MAX); - } - temp_dState[ee] = temp_hotend[ee].celsius; + temp_dState = tempinfo.celsius; - #else // PID_OPENLOOP + return constrain(work_pid.Kp + work_pid.Ki + work_pid.Kd + float(MIN_POW), 0, MAX_POW); - const float pid_output = constrain(temp_hotend[ee].target, 0, PID_MAX); + #endif // !PID_OPENLOOP + } - #endif // PID_OPENLOOP + FORCE_INLINE void debug(const_celsius_float_t c, const_float_t pid_out, FSTR_P const name=nullptr, const int8_t index=-1) { + if (TERN0(HAS_PID_DEBUG, thermalManager.pid_debug_flag)) { + SERIAL_ECHO_START(); + if (name) SERIAL_ECHOLNF(name); + if (index >= 0) SERIAL_ECHO(index); + SERIAL_ECHOLNPGM( + STR_PID_DEBUG_INPUT, c, + STR_PID_DEBUG_OUTPUT, pid_out + #if DISABLED(PID_OPENLOOP) + , "pTerm", work_pid.Kp, "iTerm", work_pid.Ki, "dTerm", work_pid.Kd + #endif + ); + } + } + }; + +#endif // HAS_PID_HEATING + +#if HAS_HOTEND + + float Temperature::get_pid_output_hotend(const uint8_t E_NAME) { + const uint8_t ee = HOTEND_INDEX; + + #if ENABLED(PIDTEMP) + + typedef PIDRunner PIDRunnerHotend; + + static PIDRunnerHotend hotend_pid[HOTENDS] = { + #define _HOTENDPID(E) temp_hotend[E], + REPEAT(HOTENDS, _HOTENDPID) + }; + + const float pid_output = hotend_pid[ee].get_pid_output(); #if ENABLED(PID_DEBUG) - if (ee == active_extruder && pid_debug_flag) { - SERIAL_ECHO_MSG(STR_PID_DEBUG, ee, STR_PID_DEBUG_INPUT, temp_hotend[ee].celsius, STR_PID_DEBUG_OUTPUT, pid_output - #if DISABLED(PID_OPENLOOP) - , STR_PID_DEBUG_PTERM, work_pid[ee].Kp - , STR_PID_DEBUG_ITERM, work_pid[ee].Ki - , STR_PID_DEBUG_DTERM, work_pid[ee].Kd - #if ENABLED(PID_EXTRUSION_SCALING) - , STR_PID_DEBUG_CTERM, work_pid[ee].Kc - #endif - #endif - ); - } + if (ee == active_extruder) + hotend_pid[ee].debug(temp_hotend[ee].celsius, pid_output, F("E"), ee); #endif #elif ENABLED(MPCTEMP) + MPCHeaterInfo &hotend = temp_hotend[ee]; MPC_t &constants = hotend.constants; @@ -1497,7 +1494,7 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { #else // No PID or MPC enabled const bool is_idling = TERN0(HEATER_IDLE_HANDLER, heater_idle[ee].timed_out); - const float pid_output = (!is_idling && temp_hotend[ee].celsius < temp_hotend[ee].target) ? BANG_MAX : 0; + const float pid_output = (!is_idling && temp_hotend[ee].is_below_target()) ? BANG_MAX : 0; #endif @@ -1509,61 +1506,9 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { #if ENABLED(PIDTEMPBED) float Temperature::get_pid_output_bed() { - - #if DISABLED(PID_OPENLOOP) - - static PID_t work_pid{0}; - static float temp_iState = 0, temp_dState = 0; - static bool pid_reset = true; - float pid_output = 0; - const float max_power_over_i_gain = float(MAX_BED_POWER) / temp_bed.pid.Ki - float(MIN_BED_POWER), - pid_error = temp_bed.target - temp_bed.celsius; - - if (!temp_bed.target || pid_error < -(PID_FUNCTIONAL_RANGE)) { - pid_output = 0; - pid_reset = true; - } - else if (pid_error > PID_FUNCTIONAL_RANGE) { - pid_output = MAX_BED_POWER; - pid_reset = true; - } - else { - if (pid_reset) { - temp_iState = 0.0; - work_pid.Kd = 0.0; - pid_reset = false; - } - - temp_iState = constrain(temp_iState + pid_error, 0, max_power_over_i_gain); - - work_pid.Kp = temp_bed.pid.Kp * pid_error; - work_pid.Ki = temp_bed.pid.Ki * temp_iState; - work_pid.Kd = work_pid.Kd + PID_K2 * (temp_bed.pid.Kd * (temp_dState - temp_bed.celsius) - work_pid.Kd); - - temp_dState = temp_bed.celsius; - - pid_output = constrain(work_pid.Kp + work_pid.Ki + work_pid.Kd + float(MIN_BED_POWER), 0, MAX_BED_POWER); - } - - #else // PID_OPENLOOP - - const float pid_output = constrain(temp_bed.target, 0, MAX_BED_POWER); - - #endif // PID_OPENLOOP - - #if ENABLED(PID_BED_DEBUG) - if (pid_debug_flag) { - SERIAL_ECHO_MSG( - " PID_BED_DEBUG : Input ", temp_bed.celsius, " Output ", pid_output - #if DISABLED(PID_OPENLOOP) - , STR_PID_DEBUG_PTERM, work_pid.Kp - , STR_PID_DEBUG_ITERM, work_pid.Ki - , STR_PID_DEBUG_DTERM, work_pid.Kd - #endif - ); - } - #endif - + static PIDRunner bed_pid(temp_bed); + const float pid_output = bed_pid.get_pid_output(); + TERN_(PID_BED_DEBUG, bed_pid.debug(temp_bed.celsius, pid_output, F("(Bed)"))); return pid_output; } @@ -1572,114 +1517,17 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { #if ENABLED(PIDTEMPCHAMBER) float Temperature::get_pid_output_chamber() { - - #if DISABLED(PID_OPENLOOP) - - static PID_t work_pid{0}; - static float temp_iState = 0, temp_dState = 0; - static bool pid_reset = true; - float pid_output = 0; - const float max_power_over_i_gain = float(MAX_CHAMBER_POWER) / temp_chamber.pid.Ki - float(MIN_CHAMBER_POWER), - pid_error = temp_chamber.target - temp_chamber.celsius; - - if (!temp_chamber.target || pid_error < -(PID_FUNCTIONAL_RANGE)) { - pid_output = 0; - pid_reset = true; - } - else if (pid_error > PID_FUNCTIONAL_RANGE) { - pid_output = MAX_CHAMBER_POWER; - pid_reset = true; - } - else { - if (pid_reset) { - temp_iState = 0.0; - work_pid.Kd = 0.0; - pid_reset = false; - } - - temp_iState = constrain(temp_iState + pid_error, 0, max_power_over_i_gain); - - work_pid.Kp = temp_chamber.pid.Kp * pid_error; - work_pid.Ki = temp_chamber.pid.Ki * temp_iState; - work_pid.Kd = work_pid.Kd + PID_K2 * (temp_chamber.pid.Kd * (temp_dState - temp_chamber.celsius) - work_pid.Kd); - - temp_dState = temp_chamber.celsius; - - pid_output = constrain(work_pid.Kp + work_pid.Ki + work_pid.Kd + float(MIN_CHAMBER_POWER), 0, MAX_CHAMBER_POWER); - } - - #else // PID_OPENLOOP - - const float pid_output = constrain(temp_chamber.target, 0, MAX_CHAMBER_POWER); - - #endif // PID_OPENLOOP - - #if ENABLED(PID_CHAMBER_DEBUG) - { - SERIAL_ECHO_MSG( - " PID_CHAMBER_DEBUG : Input ", temp_chamber.celsius, " Output ", pid_output - #if DISABLED(PID_OPENLOOP) - , STR_PID_DEBUG_PTERM, work_pid.Kp - , STR_PID_DEBUG_ITERM, work_pid.Ki - , STR_PID_DEBUG_DTERM, work_pid.Kd - #endif - ); - } - #endif - + static PIDRunner chamber_pid(temp_chamber); + const float pid_output = chamber_pid.get_pid_output(); + TERN_(PID_CHAMBER_DEBUG, chamber_pid.debug(temp_chamber.celsius, pid_output, F("(Chamber)"))); return pid_output; } #endif // PIDTEMPCHAMBER -/** - * Manage heating activities for extruder hot-ends and a heated bed - * - Acquire updated temperature readings - * - Also resets the watchdog timer - * - Invoke thermal runaway protection - * - Manage extruder auto-fan - * - Apply filament width to the extrusion rate (may move) - * - Update the heated bed PID output value - */ -void Temperature::manage_heater() { - if (marlin_state == MF_INITIALIZING) return hal.watchdog_refresh(); // If Marlin isn't started, at least reset the watchdog! - - static bool no_reentry = false; // Prevent recursion - if (no_reentry) return; - REMEMBER(mh, no_reentry, true); - - #if ENABLED(EMERGENCY_PARSER) - if (emergency_parser.killed_by_M112) kill(FPSTR(M112_KILL_STR), nullptr, true); - - if (emergency_parser.quickstop_by_M410) { - emergency_parser.quickstop_by_M410 = false; // quickstop_stepper may call idle so clear this now! - quickstop_stepper(); - } - #endif - - if (!updateTemperaturesIfReady()) return; // Will also reset the watchdog if temperatures are ready - - #if DISABLED(IGNORE_THERMOCOUPLE_ERRORS) - #if TEMP_SENSOR_0_IS_MAX_TC - if (degHotend(0) > _MIN(HEATER_0_MAXTEMP, TEMP_SENSOR_0_MAX_TC_TMAX - 1.0)) max_temp_error(H_E0); - if (degHotend(0) < _MAX(HEATER_0_MINTEMP, TEMP_SENSOR_0_MAX_TC_TMIN + .01)) min_temp_error(H_E0); - #endif - #if TEMP_SENSOR_1_IS_MAX_TC - if (degHotend(1) > _MIN(HEATER_1_MAXTEMP, TEMP_SENSOR_1_MAX_TC_TMAX - 1.0)) max_temp_error(H_E1); - if (degHotend(1) < _MAX(HEATER_1_MINTEMP, TEMP_SENSOR_1_MAX_TC_TMIN + .01)) min_temp_error(H_E1); - #endif - #if TEMP_SENSOR_REDUNDANT_IS_MAX_TC - if (degRedundant() > TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX - 1.0) max_temp_error(H_REDUNDANT); - if (degRedundant() < TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN + .01) min_temp_error(H_REDUNDANT); - #endif - #else - #warning "Safety Alert! Disable IGNORE_THERMOCOUPLE_ERRORS for the final build!" - #endif - - millis_t ms = millis(); - - #if HAS_HOTEND +#if HAS_HOTEND + void Temperature::manage_hotends(const millis_t &ms) { HOTEND_LOOP() { #if ENABLED(THERMAL_PROTECTION_HOTENDS) if (degHotend(e) > temp_range[e].maxtemp) max_temp_error((heater_id_t)e); @@ -1707,25 +1555,13 @@ void Temperature::manage_heater() { #endif } // HOTEND_LOOP + } - #endif // HAS_HOTEND - - #if HAS_TEMP_REDUNDANT - // Make sure measured temperatures are close together - if (ABS(degRedundantTarget() - degRedundant()) > TEMP_SENSOR_REDUNDANT_MAX_DIFF) - _temp_error((heater_id_t)HEATER_ID(TEMP_SENSOR_REDUNDANT_TARGET), F(STR_REDUNDANCY), GET_TEXT_F(MSG_ERR_REDUNDANT_TEMP)); - #endif - - // Manage extruder auto fans and/or read fan tachometers - TERN_(HAS_FAN_LOGIC, manage_extruder_fans(ms)); +#endif // HAS_HOTEND - /** - * Dynamically set the volumetric multiplier based - * on the delayed Filament Width measurement. - */ - TERN_(FILAMENT_WIDTH_SENSOR, filwidth.update_volumetric()); +#if HAS_HEATED_BED - #if HAS_HEATED_BED + void Temperature::manage_heated_bed(const millis_t &ms) { #if ENABLED(THERMAL_PROTECTION_BED) if (degBed() > BED_MAXTEMP) max_temp_error(H_BED); @@ -1770,9 +1606,7 @@ void Temperature::manage_heater() { #if HEATER_IDLE_HANDLER if (heater_idle[IDLE_INDEX_BED].timed_out) { temp_bed.soft_pwm_amount = 0; - #if DISABLED(PIDTEMPBED) - WRITE_HEATER_BED(LOW); - #endif + if (DISABLED(PIDTEMPBED)) WRITE_HEATER_BED(LOW); } else #endif @@ -1785,10 +1619,10 @@ void Temperature::manage_heater() { #if ENABLED(BED_LIMIT_SWITCHING) if (temp_bed.celsius >= temp_bed.target + BED_HYSTERESIS) temp_bed.soft_pwm_amount = 0; - else if (temp_bed.celsius <= temp_bed.target - (BED_HYSTERESIS)) + else if (temp_bed.is_below_target(-(BED_HYSTERESIS) + 1)) temp_bed.soft_pwm_amount = MAX_BED_POWER >> 1; #else // !PIDTEMPBED && !BED_LIMIT_SWITCHING - temp_bed.soft_pwm_amount = temp_bed.celsius < temp_bed.target ? MAX_BED_POWER >> 1 : 0; + temp_bed.soft_pwm_amount = temp_bed.is_below_target() ? MAX_BED_POWER >> 1 : 0; #endif } else { @@ -1799,10 +1633,13 @@ void Temperature::manage_heater() { } } while (false); + } - #endif // HAS_HEATED_BED +#endif // HAS_HEATED_BED - #if HAS_HEATED_CHAMBER +#if HAS_HEATED_CHAMBER + + void Temperature::manage_heated_chamber(const millis_t &ms) { #ifndef CHAMBER_CHECK_INTERVAL #define CHAMBER_CHECK_INTERVAL 1000UL @@ -1897,17 +1734,17 @@ void Temperature::manage_heater() { if (flag_chamber_excess_heat) { temp_chamber.soft_pwm_amount = 0; #if ENABLED(CHAMBER_VENT) - if (!flag_chamber_off) servo[CHAMBER_VENT_SERVO_NR].move(temp_chamber.celsius <= temp_chamber.target ? 0 : 90); + if (!flag_chamber_off) servo[CHAMBER_VENT_SERVO_NR].move(temp_chamber.is_below_target() ? 0 : 90); #endif } else { #if ENABLED(CHAMBER_LIMIT_SWITCHING) if (temp_chamber.celsius >= temp_chamber.target + TEMP_CHAMBER_HYSTERESIS) temp_chamber.soft_pwm_amount = 0; - else if (temp_chamber.celsius <= temp_chamber.target - (TEMP_CHAMBER_HYSTERESIS)) + else if (temp_chamber.is_below_target(-(TEMP_CHAMBER_HYSTERESIS) + 1)) temp_chamber.soft_pwm_amount = (MAX_CHAMBER_POWER) >> 1; #else - temp_chamber.soft_pwm_amount = temp_chamber.celsius < temp_chamber.target ? (MAX_CHAMBER_POWER) >> 1 : 0; + temp_chamber.soft_pwm_amount = temp_chamber.is_below_target() ? (MAX_CHAMBER_POWER) >> 1 : 0; #endif #if ENABLED(CHAMBER_VENT) if (!flag_chamber_off) servo[CHAMBER_VENT_SERVO_NR].move(0); @@ -1923,10 +1760,13 @@ void Temperature::manage_heater() { tr_state_machine[RUNAWAY_IND_CHAMBER].run(temp_chamber.celsius, temp_chamber.target, H_CHAMBER, THERMAL_PROTECTION_CHAMBER_PERIOD, THERMAL_PROTECTION_CHAMBER_HYSTERESIS); #endif #endif + } - #endif // HAS_HEATED_CHAMBER +#endif // HAS_HEATED_CHAMBER - #if HAS_COOLER +#if HAS_COOLER + + void Temperature::manage_cooler(const millis_t &ms) { #ifndef COOLER_CHECK_INTERVAL #define COOLER_CHECK_INTERVAL 2000UL @@ -1984,8 +1824,82 @@ void Temperature::manage_heater() { #if ENABLED(THERMAL_PROTECTION_COOLER) tr_state_machine[RUNAWAY_IND_COOLER].run(temp_cooler.celsius, temp_cooler.target, H_COOLER, THERMAL_PROTECTION_COOLER_PERIOD, THERMAL_PROTECTION_COOLER_HYSTERESIS); #endif + } - #endif // HAS_COOLER +#endif // HAS_COOLER + +/** + * Manage heating activities for extruder hot-ends and a heated bed + * - Acquire updated temperature readings + * - Also resets the watchdog timer + * - Invoke thermal runaway protection + * - Manage extruder auto-fan + * - Apply filament width to the extrusion rate (may move) + * - Update the heated bed PID output value + */ +void Temperature::task() { + if (marlin_state == MF_INITIALIZING) return hal.watchdog_refresh(); // If Marlin isn't started, at least reset the watchdog! + + static bool no_reentry = false; // Prevent recursion + if (no_reentry) return; + REMEMBER(mh, no_reentry, true); + + #if ENABLED(EMERGENCY_PARSER) + if (emergency_parser.killed_by_M112) kill(FPSTR(M112_KILL_STR), nullptr, true); + + if (emergency_parser.quickstop_by_M410) { + emergency_parser.quickstop_by_M410 = false; // quickstop_stepper may call idle so clear this now! + quickstop_stepper(); + } + #endif + + if (!updateTemperaturesIfReady()) return; // Will also reset the watchdog if temperatures are ready + + #if DISABLED(IGNORE_THERMOCOUPLE_ERRORS) + #if TEMP_SENSOR_0_IS_MAX_TC + if (degHotend(0) > _MIN(HEATER_0_MAXTEMP, TEMP_SENSOR_0_MAX_TC_TMAX - 1.0)) max_temp_error(H_E0); + if (degHotend(0) < _MAX(HEATER_0_MINTEMP, TEMP_SENSOR_0_MAX_TC_TMIN + .01)) min_temp_error(H_E0); + #endif + #if TEMP_SENSOR_1_IS_MAX_TC + if (degHotend(1) > _MIN(HEATER_1_MAXTEMP, TEMP_SENSOR_1_MAX_TC_TMAX - 1.0)) max_temp_error(H_E1); + if (degHotend(1) < _MAX(HEATER_1_MINTEMP, TEMP_SENSOR_1_MAX_TC_TMIN + .01)) min_temp_error(H_E1); + #endif + #if TEMP_SENSOR_REDUNDANT_IS_MAX_TC + if (degRedundant() > TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX - 1.0) max_temp_error(H_REDUNDANT); + if (degRedundant() < TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN + .01) min_temp_error(H_REDUNDANT); + #endif + #else + #warning "Safety Alert! Disable IGNORE_THERMOCOUPLE_ERRORS for the final build!" + #endif + + const millis_t ms = millis(); + + // Handle Hotend Temp Errors, Heating Watch, etc. + TERN_(HAS_HOTEND, manage_hotends(ms)); + + #if HAS_TEMP_REDUNDANT + // Make sure measured temperatures are close together + if (ABS(degRedundantTarget() - degRedundant()) > TEMP_SENSOR_REDUNDANT_MAX_DIFF) + _temp_error((heater_id_t)HEATER_ID(TEMP_SENSOR_REDUNDANT_TARGET), F(STR_REDUNDANCY), GET_TEXT_F(MSG_ERR_REDUNDANT_TEMP)); + #endif + + // Manage extruder auto fans and/or read fan tachometers + TERN_(HAS_FAN_LOGIC, manage_extruder_fans(ms)); + + /** + * Dynamically set the volumetric multiplier based + * on the delayed Filament Width measurement. + */ + TERN_(FILAMENT_WIDTH_SENSOR, filwidth.update_volumetric()); + + // Handle Bed Temp Errors, Heating Watch, etc. + TERN_(HAS_HEATED_BED, manage_heated_bed(ms)); + + // Handle Heated Chamber Temp Errors, Heating Watch, etc. + TERN_(HAS_HEATED_CHAMBER, manage_heated_chamber(ms)); + + // Handle Cooler Temp Errors, Cooling Watch, etc. + TERN_(HAS_COOLER, manage_cooler(ms)); #if ENABLED(LASER_COOLANT_FLOW_METER) cooler.flowmeter_task(ms); @@ -2479,7 +2393,7 @@ void Temperature::updateTemperaturesFromRawValues() { /** * Initialize the temperature manager * - * The manager is implemented by periodic calls to manage_heater() + * The manager is implemented by periodic calls to task() * * - Init (and disable) SPI thermocouples like MAX6675 and MAX31865 * - Disable RUMBA JTAG to accommodate a thermocouple extension @@ -3111,7 +3025,7 @@ void Temperature::disable_all_heaters() { static millis_t next_max_tc_ms[MAX_TC_COUNT] = { 0 }; // Return last-read value between readings - millis_t ms = millis(); + const millis_t ms = millis(); if (PENDING(ms, next_max_tc_ms[hindex])) return THERMO_TEMP(hindex); @@ -3419,16 +3333,18 @@ void Temperature::isr() { _PWM_MOD(COOLER, soft_pwm_cooler, temp_cooler); #endif - #if BOTH(USE_CONTROLLER_FAN, FAN_SOFT_PWM) - WRITE(CONTROLLER_FAN_PIN, soft_pwm_controller.add(pwm_mask, soft_pwm_controller_speed)); - #endif - #if ENABLED(FAN_SOFT_PWM) + + #if ENABLED(USE_CONTROLLER_FAN) + WRITE(CONTROLLER_FAN_PIN, soft_pwm_controller.add(pwm_mask, soft_pwm_controller_speed)); + #endif + #define _FAN_PWM(N) do{ \ uint8_t &spcf = soft_pwm_count_fan[N]; \ spcf = (spcf & pwm_mask) + (soft_pwm_amount_fan[N] >> 1); \ WRITE_FAN(N, spcf > pwm_mask ? HIGH : LOW); \ }while(0) + #if HAS_FAN0 _FAN_PWM(0); #endif diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index c11c9d76defb..80d15ce39e4a 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -232,6 +232,7 @@ typedef struct TempInfo { typedef struct HeaterInfo : public TempInfo { celsius_t target; uint8_t soft_pwm_amount; + bool is_below_target(const celsius_t offs=0) const { return (celsius < (target + offs)); } } heater_info_t; // A heater with PID stabilization @@ -715,9 +716,9 @@ class Temperature { static void readings_ready(); /** - * Call periodically to manage heaters + * Call periodically to manage heaters and keep the watchdog fed */ - static void manage_heater() __O2; // __O2 added to work around a compiler error + static void task(); /** * Preheating hotends @@ -807,6 +808,8 @@ class Temperature { #endif } + static void manage_hotends(const millis_t &ms); + #endif // HAS_HOTEND #if HAS_HEATED_BED @@ -819,6 +822,9 @@ class Temperature { static celsius_t degTargetBed() { return temp_bed.target; } static bool isHeatingBed() { return temp_bed.target > temp_bed.celsius; } static bool isCoolingBed() { return temp_bed.target < temp_bed.celsius; } + static bool degBedNear(const celsius_t temp) { + return ABS(wholeDegBed() - temp) < (TEMP_BED_HYSTERESIS); + } // Start watching the Bed to make sure it's really heating up static void start_watching_bed() { TERN_(WATCH_BED, watch_bed.restart(degBed(), degTargetBed())); } @@ -835,9 +841,7 @@ class Temperature { static void wait_for_bed_heating(); - static bool degBedNear(const celsius_t temp) { - return ABS(wholeDegBed() - temp) < (TEMP_BED_HYSTERESIS); - } + static void manage_heated_bed(const millis_t &ms); #endif // HAS_HEATED_BED @@ -863,6 +867,7 @@ class Temperature { static bool isHeatingChamber() { return temp_chamber.target > temp_chamber.celsius; } static bool isCoolingChamber() { return temp_chamber.target < temp_chamber.celsius; } static bool wait_for_chamber(const bool no_wait_for_cooling=true); + static void manage_heated_chamber(const millis_t &ms); #endif #endif @@ -886,6 +891,7 @@ class Temperature { static bool isLaserHeating() { return temp_cooler.target > temp_cooler.celsius; } static bool isLaserCooling() { return temp_cooler.target < temp_cooler.celsius; } static bool wait_for_cooler(const bool no_wait_for_cooling=true); + static void manage_cooler(const millis_t &ms); #endif #endif diff --git a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp index a681af4efa63..7d698247e565 100644 --- a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp +++ b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp @@ -62,7 +62,7 @@ #define USB_HOST_MANUAL_POLL // Optimization to shut off IRQ automatically // Workarounds to keep Marlin's watchdog timer from barking... - void marlin_yield() { thermalManager.manage_heater(); } + void marlin_yield() { thermalManager.task(); } #define SYSTEM_OR_SPECIAL_YIELD(...) marlin_yield(); #define delay(x) safe_delay(x) From 8f40a2f257511370f587f15613b2308cabdb2ee0 Mon Sep 17 00:00:00 2001 From: EvilGremlin <22657714+EvilGremlin@users.noreply.github.com> Date: Mon, 4 Jul 2022 04:49:23 +0300 Subject: [PATCH 05/32] =?UTF-8?q?=F0=9F=94=A8=20Fix=20OpenBLT=20encode;=20?= =?UTF-8?q?no-bootloader=20envs=20(#24446)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/pins/pins.h | 6 +-- buildroot/share/PlatformIO/scripts/openblt.py | 6 +-- ini/stm32f4.ini | 46 ++++++++++++++----- 3 files changed, 40 insertions(+), 18 deletions(-) diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index f94de8363b93..bdebb25969e6 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -678,15 +678,15 @@ #elif MB(MKS_ROBIN_NANO_V3_1) #include "stm32f4/pins_MKS_ROBIN_NANO_V3.h" // STM32F4 env:mks_robin_nano_v3_1 env:mks_robin_nano_v3_1_usb_flash_drive env:mks_robin_nano_v3_1_usb_flash_drive_msc #elif MB(ANET_ET4) - #include "stm32f4/pins_ANET_ET4.h" // STM32F4 env:Anet_ET4_OpenBLT + #include "stm32f4/pins_ANET_ET4.h" // STM32F4 env:Anet_ET4_no_bootloader env:Anet_ET4_OpenBLT #elif MB(ANET_ET4P) - #include "stm32f4/pins_ANET_ET4P.h" // STM32F4 env:Anet_ET4_OpenBLT + #include "stm32f4/pins_ANET_ET4P.h" // STM32F4 env:Anet_ET4_no_bootloader env:Anet_ET4_OpenBLT #elif MB(FYSETC_CHEETAH_V20) #include "stm32f4/pins_FYSETC_CHEETAH_V20.h" // STM32F4 env:FYSETC_CHEETAH_V20 #elif MB(MKS_MONSTER8) #include "stm32f4/pins_MKS_MONSTER8.h" // STM32F4 env:mks_monster8 env:mks_monster8_usb_flash_drive env:mks_monster8_usb_flash_drive_msc #elif MB(TH3D_EZBOARD_V2) - #include "stm32f4/pins_TH3D_EZBOARD_V2.h" // STM32F4 env:TH3D_EZBoard_V2 + #include "stm32f4/pins_TH3D_EZBOARD_V2.h" // STM32F4 env:TH3D_EZBoard_V2_no_bootloader env:TH3D_EZBoard_V2_OpenBLT #elif MB(OPULO_LUMEN_REV3) #include "stm32f4/pins_OPULO_LUMEN_REV3.h" // STM32F4 env:Opulo_Lumen_REV3 #elif MB(MKS_ROBIN_NANO_V1_3_F4) diff --git a/buildroot/share/PlatformIO/scripts/openblt.py b/buildroot/share/PlatformIO/scripts/openblt.py index 61b38a5e87f7..33e82898f7b4 100644 --- a/buildroot/share/PlatformIO/scripts/openblt.py +++ b/buildroot/share/PlatformIO/scripts/openblt.py @@ -10,11 +10,11 @@ board = env.BoardConfig() board_keys = board.get("build").keys() - if 'encrypt' in board_keys: + if 'encode' in board_keys: env.AddPostAction( join("$BUILD_DIR", "${PROGNAME}.bin"), env.VerboseAction(" ".join([ "$OBJCOPY", "-O", "srec", - "\"$BUILD_DIR/${PROGNAME}.elf\"", "\"" + join("$BUILD_DIR", board.get("build.encrypt")) + "\"" - ]), "Building $TARGET") + "\"$BUILD_DIR/${PROGNAME}.elf\"", "\"" + join("$BUILD_DIR", board.get("build.encode")) + "\"" + ]), "Building " + board.get("build.encode")) ) diff --git a/ini/stm32f4.ini b/ini/stm32f4.ini index 8da73f0f4088..ddb944e80f61 100644 --- a/ini/stm32f4.ini +++ b/ini/stm32f4.ini @@ -106,24 +106,34 @@ extra_scripts = ${stm32_variant.extra_scripts} # # Anet ET4-MB_V1.x/ET4P-MB_V1.x (STM32F407VGT6 ARM Cortex-M4) -# For use with with davidtgbe's OpenBLT bootloader https://github.com/davidtgbe/openblt/releases -# Comment out board_build.offset = 0x10000 if you don't plan to use OpenBLT/flashing directly to 0x08000000. # -[env:Anet_ET4_OpenBLT] +[Anet_ET4] extends = stm32_variant board = marlin_STM32F407VGT6_CCM board_build.variant = MARLIN_F4x7Vx -board_build.encrypt_mks = firmware.srec -board_build.offset = 0x10000 -board_upload.offset_address = 0x08010000 build_flags = ${stm32_variant.build_flags} -DHAL_SD_MODULE_ENABLED -DHAL_SRAM_MODULE_ENABLED build_unflags = ${stm32_variant.build_unflags} -DUSBCON -DUSBD_USE_CDC -DUSBD_VID=0x0483 + +# +# Anet ET4 directly flashed via ST-Link +# +[env:Anet_ET4_no_bootloader] +extends = Anet_ET4 +debug_tool = stlink +upload_protocol = stlink + +# +# Anet ET4 with OpenBLT from https://github.com/davidtgbe/openblt/releases +# +[env:Anet_ET4_OpenBLT] +extends = Anet_ET4 +board_build.encode = firmware.srec +board_build.offset = 0x10000 +board_upload.offset_address = 0x08010000 extra_scripts = ${stm32_variant.extra_scripts} buildroot/share/PlatformIO/scripts/openblt.py -debug_tool = jlink -upload_protocol = jlink # # BigTreeTech SKR Pro (STM32F407ZGT6 ARM Cortex-M4) @@ -546,16 +556,28 @@ build_unflags = -DUSBD_USE_CDC # # TH3D EZBoard v2.0 (STM32F405RGT6 ARM Cortex-M4) # -[env:TH3D_EZBoard_V2] +[TH3D_EZBoard_V2] extends = stm32_variant board = genericSTM32F405RG board_build.variant = MARLIN_TH3D_EZBOARD_V2 -board_build.encrypt_mks = firmware.bin -board_build.offset = 0xC000 -board_upload.offset_address = 0x0800C000 build_flags = ${stm32_variant.build_flags} -DHSE_VALUE=12000000U -O0 + +# +# TH3D EZBoard v2.0 directly flashed via ST-Link +# +[env:TH3D_EZBoard_V2_no_bootloader] +extends = TH3D_EZBoard_V2 debug_tool = stlink upload_protocol = stlink + +# +# TH3D EZBoard v2.0 with OpenBLT from https://github.com/rhapsodyv/OpenBLT-STM32 +# +[env:TH3D_EZBoard_V2_OpenBLT] +extends = TH3D_EZBoard_V2 +board_build.encode = firmware.bin +board_build.offset = 0xC000 +board_upload.offset_address = 0x0800C000 extra_scripts = ${stm32_variant.extra_scripts} buildroot/share/PlatformIO/scripts/openblt.py From 5b6c46db2910b3ec651793d8cb0c1d1b08a39384 Mon Sep 17 00:00:00 2001 From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Date: Sun, 3 Jul 2022 22:31:06 -0700 Subject: [PATCH 06/32] =?UTF-8?q?=E2=9C=A8=20BigTreeTech=20SKR=20SE=20BX?= =?UTF-8?q?=20V3.0=20(#24449)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SKR SE BX V3.0 removes the Reverse Driver Protection feature. --- Marlin/src/core/boards.h | 7 +++-- Marlin/src/pins/pins.h | 10 +++++-- .../src/pins/stm32h7/pins_BTT_SKR_SE_BX_V2.h | 28 +++++++++++++++++++ .../src/pins/stm32h7/pins_BTT_SKR_SE_BX_V3.h | 26 +++++++++++++++++ ...KR_SE_BX.h => pins_BTT_SKR_SE_BX_common.h} | 4 +-- ini/stm32h7.ini | 2 +- 6 files changed, 68 insertions(+), 9 deletions(-) create mode 100644 Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX_V2.h create mode 100644 Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX_V3.h rename Marlin/src/pins/stm32h7/{pins_BTT_SKR_SE_BX.h => pins_BTT_SKR_SE_BX_common.h} (98%) diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index f6b30c6cffa5..72c7e22541f5 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -428,9 +428,10 @@ #define BOARD_TEENSY41 5001 // Teensy 4.1 #define BOARD_T41U5XBB 5002 // T41U5XBB Teensy 4.1 breakout board #define BOARD_NUCLEO_F767ZI 5003 // ST NUCLEO-F767ZI Dev Board -#define BOARD_BTT_SKR_SE_BX 5004 // BigTreeTech SKR SE BX (STM32H743II) -#define BOARD_BTT_SKR_V3_0 5005 // BigTreeTech SKR V3.0 (STM32H743VG) -#define BOARD_BTT_SKR_V3_0_EZ 5006 // BigTreeTech SKR V3.0 EZ (STM32H743VG) +#define BOARD_BTT_SKR_SE_BX_V2 5004 // BigTreeTech SKR SE BX V2.0 (STM32H743II) +#define BOARD_BTT_SKR_SE_BX_V3 5005 // BigTreeTech SKR SE BX V3.0 (STM32H743II) +#define BOARD_BTT_SKR_V3_0 5006 // BigTreeTech SKR V3.0 (STM32H743VG) +#define BOARD_BTT_SKR_V3_0_EZ 5007 // BigTreeTech SKR V3.0 EZ (STM32H743VG) // // Espressif ESP32 WiFi diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index bdebb25969e6..2a29c66d8acc 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -706,8 +706,10 @@ #include "stm32f7/pins_REMRAM_V1.h" // STM32F7 env:REMRAM_V1 #elif MB(NUCLEO_F767ZI) #include "stm32f7/pins_NUCLEO_F767ZI.h" // STM32F7 env:NUCLEO_F767ZI -#elif MB(BTT_SKR_SE_BX) - #include "stm32h7/pins_BTT_SKR_SE_BX.h" // STM32H7 env:BTT_SKR_SE_BX +#elif MB(BTT_SKR_SE_BX_V2) + #include "stm32h7/pins_BTT_SKR_SE_BX_V2.h" // STM32H7 env:BTT_SKR_SE_BX +#elif MB(BTT_SKR_SE_BX_V3) + #include "stm32h7/pins_BTT_SKR_SE_BX_V3.h" // STM32H7 env:BTT_SKR_SE_BX #elif MB(BTT_SKR_V3_0) #include "stm32h7/pins_BTT_SKR_V3_0.h" // STM32H7 env:STM32H743Vx_btt #elif MB(BTT_SKR_V3_0_EZ) @@ -797,6 +799,7 @@ #define BOARD_RAMPS_LONGER3D_LK4PRO 99921 #define BOARD_BTT_SKR_V2_0 99922 #define BOARD_TH3D_EZBOARD_LITE_V2 99923 + #define BOARD_BTT_SKR_SE_BX 99924 #if MB(MKS_13) #error "BOARD_MKS_13 has been renamed BOARD_MKS_GEN_13. Please update your configuration." @@ -848,6 +851,8 @@ #error "BOARD_BTT_SKR_V2_0 is now BOARD_BTT_SKR_V2_0_REV_A or BOARD_BTT_SKR_V2_0_REV_B. See https://bit.ly/3t5d9JQ for more information. Please update your configuration." #elif MB(TH3D_EZBOARD_LITE_V2) #error "BOARD_TH3D_EZBOARD_LITE_V2 is now BOARD_TH3D_EZBOARD_V2. Please update your configuration." + #elif MB(BTT_SKR_SE_BX) + #error "BOARD_BTT_SKR_SE_BX is now BOARD_BTT_SKR_SE_BX_V2 or BOARD_BTT_SKR_SE_BX_V3. Please update your configuration." #elif defined(MOTHERBOARD) #error "Unknown MOTHERBOARD value set in Configuration.h." #else @@ -878,6 +883,7 @@ #undef BOARD_RAMPS_LONGER3D_LK4PRO #undef BOARD_BTT_SKR_V2_0 #undef BOARD_TH3D_EZBOARD_LITE_V2 + #undef BOARD_BTT_SKR_SE_BX #endif diff --git a/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX_V2.h b/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX_V2.h new file mode 100644 index 000000000000..8be6dadee43b --- /dev/null +++ b/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX_V2.h @@ -0,0 +1,28 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#define BOARD_INFO_NAME "BTT SKR SE BX V2.0" + +#define SAFE_POWER_PIN PI11 + +#include "pins_BTT_SKR_SE_BX_common.h" diff --git a/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX_V3.h b/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX_V3.h new file mode 100644 index 000000000000..8d8143ee622b --- /dev/null +++ b/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX_V3.h @@ -0,0 +1,26 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#define BOARD_INFO_NAME "BTT SKR SE BX V3.0" + +#include "pins_BTT_SKR_SE_BX_common.h" diff --git a/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX.h b/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX_common.h similarity index 98% rename from Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX.h rename to Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX_common.h index ddc0a202ea30..1ee7846c9315 100644 --- a/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX.h +++ b/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX_common.h @@ -25,8 +25,7 @@ #error "Oops! Select an STM32H7 board in 'Tools > Board.'" #endif -#define BOARD_INFO_NAME "BTT SKR SE BX" -#define DEFAULT_MACHINE_NAME "BIQU-BX" +#define DEFAULT_MACHINE_NAME "Biqu BX" // Onboard I2C EEPROM #define I2C_EEPROM @@ -56,7 +55,6 @@ #define POWER_MONITOR_PIN PB0 #define RPI_POWER_PIN PE5 -#define SAFE_POWER_PIN PI11 #define SERVO0_PIN PA2 // diff --git a/ini/stm32h7.ini b/ini/stm32h7.ini index c5d7d6299a1e..fb898d1b72b1 100644 --- a/ini/stm32h7.ini +++ b/ini/stm32h7.ini @@ -20,7 +20,7 @@ ################################# # -# BigTreeTech SKR SE BX (STM32H743IIT6 ARM Cortex-M7) +# BigTreeTech SKR SE BX V2.0 / V3.0 (STM32H743IIT6 ARM Cortex-M7) # [env:BTT_SKR_SE_BX] extends = stm32_variant From d965303a7a1592e348853c1620cf54576652ace8 Mon Sep 17 00:00:00 2001 From: Mike La Spina Date: Wed, 6 Jul 2022 07:46:39 -0500 Subject: [PATCH 07/32] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Fix=20and=20improve?= =?UTF-8?q?=20Inline=20Laser=20Power=20(#22690)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration_adv.h | 104 ++----- Marlin/src/feature/spindle_laser.cpp | 88 +++--- Marlin/src/feature/spindle_laser.h | 333 ++++++++++----------- Marlin/src/feature/spindle_laser_types.h | 6 +- Marlin/src/gcode/calibrate/G28.cpp | 9 +- Marlin/src/gcode/control/M3-M5.cpp | 134 +++++---- Marlin/src/gcode/gcode.cpp | 37 ++- Marlin/src/inc/SanityCheck.h | 45 +-- Marlin/src/lcd/dogm/status_screen_DOGM.cpp | 2 +- Marlin/src/lcd/menu/menu_item.h | 5 + Marlin/src/lcd/menu/menu_spindle_laser.cpp | 18 +- Marlin/src/module/planner.cpp | 286 ++++++++++-------- Marlin/src/module/planner.h | 92 +++--- Marlin/src/module/stepper.cpp | 236 +++++++-------- Marlin/src/module/stepper.h | 19 -- Marlin/src/module/temperature.cpp | 5 +- buildroot/tests/mega2560 | 4 +- docs/Cutter.md | 137 +++++++++ 18 files changed, 848 insertions(+), 712 deletions(-) create mode 100644 docs/Cutter.md diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index b085ec7ec4a9..db664477f44c 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3668,8 +3668,11 @@ #endif // Define the minimum and maximum test pulse time values for a laser test fire function - #define LASER_TEST_PULSE_MIN 1 // Used with Laser Control Menu - #define LASER_TEST_PULSE_MAX 999 // Caution: Menu may not show more than 3 characters + #define LASER_TEST_PULSE_MIN 1 // (ms) Used with Laser Control Menu + #define LASER_TEST_PULSE_MAX 999 // (ms) Caution: Menu may not show more than 3 characters + + #define SPINDLE_LASER_POWERUP_DELAY 50 // (ms) Delay to allow the spindle/laser to come up to speed/power + #define SPINDLE_LASER_POWERDOWN_DELAY 50 // (ms) Delay to allow the spindle to stop /** * Laser Safety Timeout @@ -3682,79 +3685,38 @@ #define LASER_SAFETY_TIMEOUT_MS 1000 // (ms) /** - * Enable inline laser power to be handled in the planner / stepper routines. - * Inline power is specified by the I (inline) flag in an M3 command (e.g., M3 S20 I) - * or by the 'S' parameter in G0/G1/G2/G3 moves (see LASER_MOVE_POWER). + * Any M3 or G1/2/3/5 command with the 'I' parameter enables continuous inline power mode. + * + * e.g., 'M3 I' enables continuous inline power which is processed by the planner. + * Power is stored in move blocks and applied when blocks are processed by the Stepper ISR. + * + * 'M4 I' sets dynamic mode which uses the current feedrate to calculate a laser power OCR value. * - * This allows the laser to keep in perfect sync with the planner and removes - * the powerup/down delay since lasers require negligible time. + * Any move in dynamic mode will use the current feedrate to calculate the laser power. + * Feed rates are set by the F parameter of a move command e.g. G1 X0 Y10 F6000 + * Laser power would be calculated by bit shifting off 8 LSB's. In binary this is div 256. + * The calculation gives us ocr values from 0 to 255, values over F65535 will be set as 255 . + * More refined power control such as compesation for accell/decell will be addressed in future releases. + * + * M5 I clears inline mode and set power to 0, M5 sets the power output to 0 but leaves inline mode on. */ - //#define LASER_POWER_INLINE - - #if ENABLED(LASER_POWER_INLINE) - /** - * Scale the laser's power in proportion to the movement rate. - * - * - Sets the entry power proportional to the entry speed over the nominal speed. - * - Ramps the power up every N steps to approximate the speed trapezoid. - * - Due to the limited power resolution this is only approximate. - */ - #define LASER_POWER_INLINE_TRAPEZOID - - /** - * Continuously calculate the current power (nominal_power * current_rate / nominal_rate). - * Required for accurate power with non-trapezoidal acceleration (e.g., S_CURVE_ACCELERATION). - * This is a costly calculation so this option is discouraged on 8-bit AVR boards. - * - * LASER_POWER_INLINE_TRAPEZOID_CONT_PER defines how many step cycles there are between power updates. If your - * board isn't able to generate steps fast enough (and you are using LASER_POWER_INLINE_TRAPEZOID_CONT), increase this. - * Note that when this is zero it means it occurs every cycle; 1 means a delay wait one cycle then run, etc. - */ - //#define LASER_POWER_INLINE_TRAPEZOID_CONT - - /** - * Stepper iterations between power updates. Increase this value if the board - * can't keep up with the processing demands of LASER_POWER_INLINE_TRAPEZOID_CONT. - * Disable (or set to 0) to recalculate power on every stepper iteration. - */ - //#define LASER_POWER_INLINE_TRAPEZOID_CONT_PER 10 - - /** - * Include laser power in G0/G1/G2/G3/G5 commands with the 'S' parameter - */ - //#define LASER_MOVE_POWER - - #if ENABLED(LASER_MOVE_POWER) - // Turn off the laser on G0 moves with no power parameter. - // If a power parameter is provided, use that instead. - //#define LASER_MOVE_G0_OFF - // Turn off the laser on G28 homing. - //#define LASER_MOVE_G28_OFF - #endif - - /** - * Inline flag inverted - * - * WARNING: M5 will NOT turn off the laser unless another move - * is done (so G-code files must end with 'M5 I'). - */ - //#define LASER_POWER_INLINE_INVERT - - /** - * Continuously apply inline power. ('M3 S3' == 'G1 S3' == 'M3 S3 I') - * - * The laser might do some weird things, so only enable this - * feature if you understand the implications. - */ - //#define LASER_POWER_INLINE_CONTINUOUS - - #else - - #define SPINDLE_LASER_POWERUP_DELAY 50 // (ms) Delay to allow the spindle/laser to come up to speed/power - #define SPINDLE_LASER_POWERDOWN_DELAY 50 // (ms) Delay to allow the spindle to stop + /** + * Enable M3 commands for laser mode inline power planner syncing. + * This feature enables any M3 S-value to be injected into the block buffers while in + * CUTTER_MODE_CONTINUOUS. The option allows M3 laser power to be commited without waiting + * for a planner syncronization + */ + //#define LASER_POWER_SYNC - #endif + /** + * Scale the laser's power in proportion to the movement rate. + * + * - Sets the entry power proportional to the entry speed over the nominal speed. + * - Ramps the power up every N steps to approximate the speed trapezoid. + * - Due to the limited power resolution this is only approximate. + */ + //#define LASER_POWER_TRAP // // Laser I2C Ammeter (High precision INA226 low/high side module) diff --git a/Marlin/src/feature/spindle_laser.cpp b/Marlin/src/feature/spindle_laser.cpp index 4f8f4d49dc2f..da38646a3674 100644 --- a/Marlin/src/feature/spindle_laser.cpp +++ b/Marlin/src/feature/spindle_laser.cpp @@ -39,18 +39,26 @@ #endif SpindleLaser cutter; -uint8_t SpindleLaser::power, +bool SpindleLaser::enable_state; // Virtual enable state, controls enable pin if present and or apply power if > 0 +uint8_t SpindleLaser::power, // Actual power output 0-255 ocr or "0 = off" > 0 = "on" SpindleLaser::last_power_applied; // = 0 // Basic power state tracking + #if ENABLED(LASER_FEATURE) - cutter_test_pulse_t SpindleLaser::testPulse = 50; // Test fire Pulse time ms value. + cutter_test_pulse_t SpindleLaser::testPulse = 50; // (ms) Test fire pulse default duration + uint8_t SpindleLaser::last_block_power; // = 0 // Track power changes for dynamic inline power + feedRate_t SpindleLaser::feedrate_mm_m = 1500, + SpindleLaser::last_feedrate_mm_m; // = 0 // (mm/min) Track feedrate changes for dynamic power #endif -bool SpindleLaser::isReady; // Ready to apply power setting from the UI to OCR -cutter_power_t SpindleLaser::menuPower, // Power set via LCD menu in PWM, PERCENT, or RPM - SpindleLaser::unitPower; // LCD status power in PWM, PERCENT, or RPM -#if ENABLED(MARLIN_DEV_MODE) - cutter_frequency_t SpindleLaser::frequency; // PWM frequency setting; range: 2K - 50K -#endif +bool SpindleLaser::isReadyForUI = false; // Ready to apply power setting from the UI to OCR +CutterMode SpindleLaser::cutter_mode = CUTTER_MODE_STANDARD; // Default is standard mode + +constexpr cutter_cpower_t SpindleLaser::power_floor; +cutter_power_t SpindleLaser::menuPower = 0, // Power value via LCD menu in PWM, PERCENT, or RPM based on configured format set by CUTTER_POWER_UNIT. + SpindleLaser::unitPower = 0; // Unit power is in PWM, PERCENT, or RPM based on CUTTER_POWER_UNIT. + +cutter_frequency_t SpindleLaser::frequency; // PWM frequency setting; range: 2K - 50K + #define SPINDLE_LASER_PWM_OFF TERN(SPINDLE_LASER_PWM_INVERT, 255, 0) /** @@ -65,14 +73,14 @@ void SpindleLaser::init() { #if ENABLED(SPINDLE_CHANGE_DIR) OUT_WRITE(SPINDLE_DIR_PIN, SPINDLE_INVERT_DIR); // Init rotation to clockwise (M3) #endif + #if ENABLED(HAL_CAN_SET_PWM_FREQ) && SPINDLE_LASER_FREQUENCY + frequency = SPINDLE_LASER_FREQUENCY; + hal.set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_FREQUENCY); + #endif #if ENABLED(SPINDLE_LASER_USE_PWM) SET_PWM(SPINDLE_LASER_PWM_PIN); hal.set_pwm_duty(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_PWM_OFF); // Set to lowest speed #endif - #if ENABLED(HAL_CAN_SET_PWM_FREQ) && SPINDLE_LASER_FREQUENCY - hal.set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_FREQUENCY); - TERN_(MARLIN_DEV_MODE, frequency = SPINDLE_LASER_FREQUENCY); - #endif #if ENABLED(AIR_EVACUATION) OUT_WRITE(AIR_EVACUATION_PIN, !AIR_EVACUATION_ACTIVE); // Init Vacuum/Blower OFF #endif @@ -90,7 +98,7 @@ void SpindleLaser::init() { */ void SpindleLaser::_set_ocr(const uint8_t ocr) { #if ENABLED(HAL_CAN_SET_PWM_FREQ) && SPINDLE_LASER_FREQUENCY - hal.set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), TERN(MARLIN_DEV_MODE, frequency, SPINDLE_LASER_FREQUENCY)); + hal.set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), frequency); #endif hal.set_pwm_duty(pin_t(SPINDLE_LASER_PWM_PIN), ocr ^ SPINDLE_LASER_PWM_OFF); } @@ -107,35 +115,41 @@ void SpindleLaser::init() { #endif // SPINDLE_LASER_USE_PWM /** - * Apply power for laser/spindle + * Apply power for Laser or Spindle * * Apply cutter power value for PWM, Servo, and on/off pin. * - * @param opwr Power value. Range 0 to MAX. When 0 disable spindle/laser. + * @param opwr Power value. Range 0 to MAX. */ void SpindleLaser::apply_power(const uint8_t opwr) { - if (opwr == last_power_applied) return; - last_power_applied = opwr; - power = opwr; - #if ENABLED(SPINDLE_LASER_USE_PWM) - if (cutter.unitPower == 0 && CUTTER_UNIT_IS(RPM)) { - ocr_off(); - isReady = false; - } - else if (ENABLED(CUTTER_POWER_RELATIVE) || enabled()) { - set_ocr(power); - isReady = true; - } - else { - ocr_off(); - isReady = false; - } - #elif ENABLED(SPINDLE_SERVO) - servo[SPINDLE_SERVO_NR].move(power); - #else - WRITE(SPINDLE_LASER_ENA_PIN, enabled() ? SPINDLE_LASER_ACTIVE_STATE : !SPINDLE_LASER_ACTIVE_STATE); - isReady = true; - #endif + if (enabled() || opwr == 0) { // 0 check allows us to disable where no ENA pin exists + // Test and set the last power used to improve performance + if (opwr == last_power_applied) return; + last_power_applied = opwr; + // Handle PWM driven or just simple on/off + #if ENABLED(SPINDLE_LASER_USE_PWM) + if (CUTTER_UNIT_IS(RPM) && unitPower == 0) + ocr_off(); + else if (ENABLED(CUTTER_POWER_RELATIVE) || enabled() || opwr == 0) { + set_ocr(opwr); + isReadyForUI = true; + } + else + ocr_off(); + #elif ENABLED(SPINDLE_SERVO) + MOVE_SERVO(SPINDLE_SERVO_NR, power); + #else + WRITE(SPINDLE_LASER_ENA_PIN, enabled() ? SPINDLE_LASER_ACTIVE_STATE : !SPINDLE_LASER_ACTIVE_STATE); + isReadyForUI = true; + #endif + } + else { + #if PIN_EXISTS(SPINDLE_LASER_ENA) + WRITE(SPINDLE_LASER_ENA_PIN, !SPINDLE_LASER_ACTIVE_STATE); + #endif + isReadyForUI = false; // Only used for UI display updates. + TERN_(SPINDLE_LASER_USE_PWM, ocr_off()); + } } #if ENABLED(SPINDLE_CHANGE_DIR) diff --git a/Marlin/src/feature/spindle_laser.h b/Marlin/src/feature/spindle_laser.h index 808fa634e162..b945032d8ea2 100644 --- a/Marlin/src/feature/spindle_laser.h +++ b/Marlin/src/feature/spindle_laser.h @@ -34,85 +34,98 @@ #include "../libs/buzzer.h" #endif -#if ENABLED(LASER_POWER_INLINE) - #include "../module/planner.h" -#endif +// Inline laser power +#include "../module/planner.h" #define PCT_TO_PWM(X) ((X) * 255 / 100) #define PCT_TO_SERVO(X) ((X) * 180 / 100) + +// Laser/Cutter operation mode +enum CutterMode : int8_t { + CUTTER_MODE_ERROR = -1, + CUTTER_MODE_STANDARD, // M3 power is applied directly and waits for planner moves to sync. + CUTTER_MODE_CONTINUOUS, // M3 or G1/2/3 move power is controlled within planner blocks, set with 'M3 I', cleared with 'M5 I'. + CUTTER_MODE_DYNAMIC // M4 laser power is proportional to the feed rate, set with 'M4 I', cleared with 'M5 I'. +}; + class SpindleLaser { public: - static const inline uint8_t pct_to_ocr(const_float_t pct) { return uint8_t(PCT_TO_PWM(pct)); } + static CutterMode cutter_mode; - // cpower = configured values (e.g., SPEED_POWER_MAX) + static constexpr uint8_t pct_to_ocr(const_float_t pct) { return uint8_t(PCT_TO_PWM(pct)); } + // cpower = configured values (e.g., SPEED_POWER_MAX) // Convert configured power range to a percentage - static const inline uint8_t cpwr_to_pct(const cutter_cpower_t cpwr) { - constexpr cutter_cpower_t power_floor = TERN(CUTTER_POWER_RELATIVE, SPEED_POWER_MIN, 0), - power_range = SPEED_POWER_MAX - power_floor; - return cpwr ? round(100.0f * (cpwr - power_floor) / power_range) : 0; + static constexpr cutter_cpower_t power_floor = TERN(CUTTER_POWER_RELATIVE, SPEED_POWER_MIN, 0); + static constexpr uint8_t cpwr_to_pct(const cutter_cpower_t cpwr) { + return cpwr ? round(100.0f * (cpwr - power_floor) / (SPEED_POWER_MAX - power_floor)) : 0; } - // Convert a cpower (e.g., SPEED_POWER_STARTUP) to unit power (upwr, upower), - // which can be PWM, Percent, Servo angle, or RPM (rel/abs). - static const inline cutter_power_t cpwr_to_upwr(const cutter_cpower_t cpwr) { // STARTUP power to Unit power - const cutter_power_t upwr = ( + // Convert config defines from RPM to %, angle or PWM when in Spindle mode + // and convert from PERCENT to PWM when in Laser mode + static constexpr cutter_power_t cpwr_to_upwr(const cutter_cpower_t cpwr) { // STARTUP power to Unit power + return ( #if ENABLED(SPINDLE_FEATURE) - // Spindle configured values are in RPM + // Spindle configured define values are in RPM #if CUTTER_UNIT_IS(RPM) - cpwr // to RPM - #elif CUTTER_UNIT_IS(PERCENT) // to PCT - cpwr_to_pct(cpwr) - #elif CUTTER_UNIT_IS(SERVO) // to SERVO angle - PCT_TO_SERVO(cpwr_to_pct(cpwr)) - #else // to PWM - PCT_TO_PWM(cpwr_to_pct(cpwr)) + cpwr // to same + #elif CUTTER_UNIT_IS(PERCENT) + cpwr_to_pct(cpwr) // to Percent + #elif CUTTER_UNIT_IS(SERVO) + PCT_TO_SERVO(cpwr_to_pct(cpwr)) // to SERVO angle + #else + PCT_TO_PWM(cpwr_to_pct(cpwr)) // to PWM #endif #else - // Laser configured values are in PCT + // Laser configured define values are in Percent #if CUTTER_UNIT_IS(PWM255) - PCT_TO_PWM(cpwr) + PCT_TO_PWM(cpwr) // to PWM #else - cpwr // to RPM/PCT + cpwr // to same #endif #endif ); - return upwr; } - static const cutter_power_t mpower_min() { return cpwr_to_upwr(SPEED_POWER_MIN); } - static const cutter_power_t mpower_max() { return cpwr_to_upwr(SPEED_POWER_MAX); } + static constexpr cutter_power_t mpower_min() { return cpwr_to_upwr(SPEED_POWER_MIN); } + static constexpr cutter_power_t mpower_max() { return cpwr_to_upwr(SPEED_POWER_MAX); } #if ENABLED(LASER_FEATURE) - static cutter_test_pulse_t testPulse; // Test fire Pulse ms value + static cutter_test_pulse_t testPulse; // (ms) Test fire pulse duration + static uint8_t last_block_power; // Track power changes for dynamic power + + static feedRate_t feedrate_mm_m, last_feedrate_mm_m; // (mm/min) Track feedrate changes for dynamic power + static bool laser_feedrate_changed() { + const bool changed = last_feedrate_mm_m != feedrate_mm_m; + if (changed) last_feedrate_mm_m = feedrate_mm_m; + return changed; + } #endif - static bool isReady; // Ready to apply power setting from the UI to OCR + static bool isReadyForUI; // Ready to apply power setting from the UI to OCR + static bool enable_state; static uint8_t power, last_power_applied; // Basic power state tracking - #if ENABLED(MARLIN_DEV_MODE) - static cutter_frequency_t frequency; // Set PWM frequency; range: 2K-50K - #endif + static cutter_frequency_t frequency; // Set PWM frequency; range: 2K-50K static cutter_power_t menuPower, // Power as set via LCD menu in PWM, Percentage or RPM unitPower; // Power as displayed status in PWM, Percentage or RPM static void init(); - #if ENABLED(MARLIN_DEV_MODE) + #if ENABLED(HAL_CAN_SET_PWM_FREQ) && SPINDLE_LASER_FREQUENCY static void refresh_frequency() { hal.set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), frequency); } #endif // Modifying this function should update everywhere static bool enabled(const cutter_power_t opwr) { return opwr > 0; } - static bool enabled() { return enabled(power); } + static bool enabled() { return enable_state; } static void apply_power(const uint8_t inpow); FORCE_INLINE static void refresh() { apply_power(power); } - FORCE_INLINE static void set_power(const uint8_t upwr) { power = upwr; refresh(); } #if ENABLED(SPINDLE_LASER_USE_PWM) @@ -123,7 +136,6 @@ class SpindleLaser { public: static void set_ocr(const uint8_t ocr); - static void ocr_set_power(const uint8_t ocr) { power = ocr; set_ocr(ocr); } static void ocr_off(); /** @@ -141,78 +153,76 @@ class SpindleLaser { ); } - /** - * Correct power to configured range - */ - static cutter_power_t power_to_range(const cutter_power_t pwr) { - return power_to_range(pwr, _CUTTER_POWER(CUTTER_POWER_UNIT)); - } - - static cutter_power_t power_to_range(const cutter_power_t pwr, const uint8_t pwrUnit) { - static constexpr float - min_pct = TERN(CUTTER_POWER_RELATIVE, 0, TERN(SPINDLE_FEATURE, round(100.0f * (SPEED_POWER_MIN) / (SPEED_POWER_MAX)), SPEED_POWER_MIN)), - max_pct = TERN(SPINDLE_FEATURE, 100, SPEED_POWER_MAX); - if (pwr <= 0) return 0; - cutter_power_t upwr; - switch (pwrUnit) { - case _CUTTER_POWER_PWM255: - upwr = cutter_power_t( - (pwr < pct_to_ocr(min_pct)) ? pct_to_ocr(min_pct) // Use minimum if set below - : (pwr > pct_to_ocr(max_pct)) ? pct_to_ocr(max_pct) // Use maximum if set above - : pwr - ); - break; - case _CUTTER_POWER_PERCENT: - upwr = cutter_power_t( - (pwr < min_pct) ? min_pct // Use minimum if set below - : (pwr > max_pct) ? max_pct // Use maximum if set above - : pwr // PCT - ); - break; - case _CUTTER_POWER_RPM: - upwr = cutter_power_t( - (pwr < SPEED_POWER_MIN) ? SPEED_POWER_MIN // Use minimum if set below - : (pwr > SPEED_POWER_MAX) ? SPEED_POWER_MAX // Use maximum if set above - : pwr // Calculate OCR value - ); - break; - default: break; - } - return upwr; - } - #endif // SPINDLE_LASER_USE_PWM /** - * Enable/Disable spindle/laser - * @param enable true = enable; false = disable + * Correct power to configured range */ - static void set_enabled(const bool enable) { - uint8_t value = 0; - if (enable) { - #if ENABLED(SPINDLE_LASER_USE_PWM) - if (power) - value = power; - else if (unitPower) - value = upower_to_ocr(cpwr_to_upwr(SPEED_POWER_STARTUP)); - #else - value = 255; - #endif + static cutter_power_t power_to_range(const cutter_power_t pwr, const uint8_t pwrUnit=_CUTTER_POWER(CUTTER_POWER_UNIT)) { + static constexpr float + min_pct = TERN(CUTTER_POWER_RELATIVE, 0, TERN(SPINDLE_FEATURE, round(100.0f * (SPEED_POWER_MIN) / (SPEED_POWER_MAX)), SPEED_POWER_MIN)), + max_pct = TERN(SPINDLE_FEATURE, 100, SPEED_POWER_MAX); + if (pwr <= 0) return 0; + cutter_power_t upwr; + switch (pwrUnit) { + case _CUTTER_POWER_PWM255: { // PWM + const uint8_t pmin = pct_to_ocr(min_pct), pmax = pct_to_ocr(max_pct); + upwr = cutter_power_t(constrain(pwr, pmin, pmax)); + } break; + case _CUTTER_POWER_PERCENT: // Percent + upwr = cutter_power_t(constrain(pwr, min_pct, max_pct)); + break; + case _CUTTER_POWER_RPM: // Calculate OCR value + upwr = cutter_power_t(constrain(pwr, SPEED_POWER_MIN, SPEED_POWER_MAX)); + break; + default: break; } - set_power(value); + return upwr; } - static void disable() { isReady = false; set_enabled(false); } - /** - * Wait for spindle to spin up or spin down + * Enable Laser or Spindle output. + * It's important to prevent changing the power output value during inline cutter operation. + * Inline power is adjusted in the planner to support LASER_TRAP_POWER and CUTTER_MODE_DYNAMIC mode. + * + * This method accepts one of the following control states: + * + * - For CUTTER_MODE_STANDARD the cutter power is either full on/off or ocr-based and it will apply + * SPEED_POWER_STARTUP if no value is assigned. * - * @param on true = state to on; false = state to off. + * - For CUTTER_MODE_CONTINUOUS inline and power remains where last set and the cutter output enable flag is set. + * + * - CUTTER_MODE_DYNAMIC is also inline-based and it just sets the enable output flag. + * + * - For CUTTER_MODE_ERROR set the output enable_state flag directly and set power to 0 for any mode. + * This mode allows a global power shutdown action to occur. */ - static void power_delay(const bool on) { - #if DISABLED(LASER_POWER_INLINE) - safe_delay(on ? SPINDLE_LASER_POWERUP_DELAY : SPINDLE_LASER_POWERDOWN_DELAY); + static void set_enabled(const bool enable) { + switch (cutter_mode) { + case CUTTER_MODE_STANDARD: + apply_power(enable ? TERN(SPINDLE_LASER_USE_PWM, (power ?: (unitPower ? upower_to_ocr(cpwr_to_upwr(SPEED_POWER_STARTUP)) : 0)), 255) : 0); + break; + case CUTTER_MODE_CONTINUOUS: + TERN_(LASER_FEATURE, set_inline_enabled(enable)); + break; + case CUTTER_MODE_DYNAMIC: + TERN_(LASER_FEATURE, set_inline_enabled(enable)); + break; + case CUTTER_MODE_ERROR: // Error mode, no enable and kill power. + enable_state = false; + apply_power(0); + } + #if SPINDLE_LASER_ENA_PIN + WRITE(SPINDLE_LASER_ENA_PIN, enable ? SPINDLE_LASER_ACTIVE_STATE : !SPINDLE_LASER_ACTIVE_STATE); #endif + enable_state = enable; + } + + static void disable() { isReadyForUI = false; set_enabled(false); } + + // Wait for spindle/laser to startup or shutdown + static void power_delay(const bool on) { + safe_delay(on ? SPINDLE_LASER_POWERUP_DELAY : SPINDLE_LASER_POWERDOWN_DELAY); } #if ENABLED(SPINDLE_CHANGE_DIR) @@ -224,47 +234,60 @@ class SpindleLaser { #endif #if ENABLED(AIR_EVACUATION) - static void air_evac_enable(); // Turn On Cutter Vacuum or Laser Blower motor - static void air_evac_disable(); // Turn Off Cutter Vacuum or Laser Blower motor - static void air_evac_toggle(); // Toggle Cutter Vacuum or Laser Blower motor - static bool air_evac_state() { // Get current state + static void air_evac_enable(); // Turn On Cutter Vacuum or Laser Blower motor + static void air_evac_disable(); // Turn Off Cutter Vacuum or Laser Blower motor + static void air_evac_toggle(); // Toggle Cutter Vacuum or Laser Blower motor + static bool air_evac_state() { // Get current state return (READ(AIR_EVACUATION_PIN) == AIR_EVACUATION_ACTIVE); } #endif #if ENABLED(AIR_ASSIST) - static void air_assist_enable(); // Turn on air assist - static void air_assist_disable(); // Turn off air assist - static void air_assist_toggle(); // Toggle air assist - static bool air_assist_state() { // Get current state + static void air_assist_enable(); // Turn on air assist + static void air_assist_disable(); // Turn off air assist + static void air_assist_toggle(); // Toggle air assist + static bool air_assist_state() { // Get current state return (READ(AIR_ASSIST_PIN) == AIR_ASSIST_ACTIVE); } #endif #if HAS_MARLINUI_MENU - static void enable_with_dir(const bool reverse) { - isReady = true; - const uint8_t ocr = TERN(SPINDLE_LASER_USE_PWM, upower_to_ocr(menuPower), 255); - if (menuPower) - power = ocr; - else - menuPower = cpwr_to_upwr(SPEED_POWER_STARTUP); - unitPower = menuPower; - set_reverse(reverse); - set_enabled(true); - } - FORCE_INLINE static void enable_forward() { enable_with_dir(false); } - FORCE_INLINE static void enable_reverse() { enable_with_dir(true); } - FORCE_INLINE static void enable_same_dir() { enable_with_dir(is_reverse()); } + + #if ENABLED(SPINDLE_FEATURE) + static void enable_with_dir(const bool reverse) { + isReadyForUI = true; + const uint8_t ocr = TERN(SPINDLE_LASER_USE_PWM, upower_to_ocr(menuPower), 255); + if (menuPower) + power = ocr; + else + menuPower = cpwr_to_upwr(SPEED_POWER_STARTUP); + unitPower = menuPower; + set_reverse(reverse); + set_enabled(true); + } + FORCE_INLINE static void enable_forward() { enable_with_dir(false); } + FORCE_INLINE static void enable_reverse() { enable_with_dir(true); } + FORCE_INLINE static void enable_same_dir() { enable_with_dir(is_reverse()); } + #endif // SPINDLE_FEATURE #if ENABLED(SPINDLE_LASER_USE_PWM) static void update_from_mpower() { - if (isReady) power = upower_to_ocr(menuPower); + if (isReadyForUI) power = upower_to_ocr(menuPower); unitPower = menuPower; } #endif #if ENABLED(LASER_FEATURE) + // Toggle the laser on/off with menuPower. Apply SPEED_POWER_STARTUP if it was 0 on entry. + static void laser_menu_toggle(const bool state) { + set_enabled(state); + if (state) { + if (!menuPower) menuPower = cpwr_to_upwr(SPEED_POWER_STARTUP); + power = upower_to_ocr(menuPower); + apply_power(power); + } + } + /** * Test fire the laser using the testPulse ms duration * Also fires with any PWM power that was previous set @@ -272,74 +295,36 @@ class SpindleLaser { */ static void test_fire_pulse() { TERN_(HAS_BEEPER, buzzer.tone(30, 3000)); - enable_forward(); // Turn Laser on (Spindle speak but same funct) + cutter_mode = CUTTER_MODE_STANDARD;// Menu needs standard mode. + laser_menu_toggle(true); // Laser On delay(testPulse); // Delay for time set by user in pulse ms menu screen. - disable(); // Turn laser off + laser_menu_toggle(false); // Laser Off } - #endif + #endif // LASER_FEATURE #endif // HAS_MARLINUI_MENU - #if ENABLED(LASER_POWER_INLINE) - /** - * Inline power adds extra fields to the planner block - * to handle laser power and scale to movement speed. - */ + #if ENABLED(LASER_FEATURE) - // Force disengage planner power control - static void inline_disable() { - isReady = false; - unitPower = 0; - planner.laser_inline.status.isPlanned = false; - planner.laser_inline.status.isEnabled = false; - planner.laser_inline.power = 0; + // Dynamic mode rate calculation + static uint8_t calc_dynamic_power() { + if (feedrate_mm_m > 65535) return 255; // Too fast, go always on + uint16_t rate = uint16_t(feedrate_mm_m); // 16 bits from the G-code parser float input + rate >>= 8; // Take the G-code input e.g. F40000 and shift off the lower bits to get an OCR value from 1-255 + return uint8_t(rate); } // Inline modes of all other functions; all enable planner inline power control - static void set_inline_enabled(const bool enable) { - if (enable) - inline_power(255); - else { - isReady = false; - unitPower = menuPower = 0; - planner.laser_inline.status.isPlanned = false; - TERN(SPINDLE_LASER_USE_PWM, inline_ocr_power, inline_power)(0); - } - } + static void set_inline_enabled(const bool enable) { planner.laser_inline.status.isEnabled = enable;} // Set the power for subsequent movement blocks - static void inline_power(const cutter_power_t upwr) { - unitPower = menuPower = upwr; - #if ENABLED(SPINDLE_LASER_USE_PWM) - #if ENABLED(SPEED_POWER_RELATIVE) && !CUTTER_UNIT_IS(RPM) // relative mode does not turn laser off at 0, except for RPM - planner.laser_inline.status.isEnabled = true; - planner.laser_inline.power = upower_to_ocr(upwr); - isReady = true; - #else - inline_ocr_power(upower_to_ocr(upwr)); - #endif - #else - planner.laser_inline.status.isEnabled = enabled(upwr); - planner.laser_inline.power = upwr; - isReady = enabled(upwr); - #endif + static void inline_power(const cutter_power_t cpwr) { + TERN(SPINDLE_LASER_USE_PWM, power = planner.laser_inline.power = cpwr, planner.laser_inline.power = cpwr > 0 ? 255 : 0); } - static void inline_direction(const bool) { /* never */ } - - #if ENABLED(SPINDLE_LASER_USE_PWM) - static void inline_ocr_power(const uint8_t ocrpwr) { - isReady = ocrpwr > 0; - planner.laser_inline.status.isEnabled = ocrpwr > 0; - planner.laser_inline.power = ocrpwr; - } - #endif - #endif // LASER_POWER_INLINE + #endif // LASER_FEATURE - static void kill() { - TERN_(LASER_POWER_INLINE, inline_disable()); - disable(); - } + static void kill() { disable(); } }; extern SpindleLaser cutter; diff --git a/Marlin/src/feature/spindle_laser_types.h b/Marlin/src/feature/spindle_laser_types.h index d249a20e7531..2f36a68a1a32 100644 --- a/Marlin/src/feature/spindle_laser_types.h +++ b/Marlin/src/feature/spindle_laser_types.h @@ -74,12 +74,10 @@ typedef IF<(SPEED_POWER_MAX > 255), uint16_t, uint8_t>::type cutter_cpower_t; #endif #endif +typedef uint16_t cutter_frequency_t; + #if ENABLED(LASER_FEATURE) typedef uint16_t cutter_test_pulse_t; #define CUTTER_MENU_PULSE_TYPE uint16_3 -#endif - -#if ENABLED(MARLIN_DEV_MODE) - typedef uint16_t cutter_frequency_t; #define CUTTER_MENU_FREQUENCY_TYPE uint16_5 #endif diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index 01c2b13dda53..384fc7210c42 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -59,7 +59,7 @@ #include "../../libs/L64XX/L64XX_Marlin.h" #endif -#if ENABLED(LASER_MOVE_G28_OFF) +#if ENABLED(LASER_FEATURE) #include "../../feature/spindle_laser.h" #endif @@ -205,7 +205,12 @@ void GcodeSuite::G28() { DEBUG_SECTION(log_G28, "G28", DEBUGGING(LEVELING)); if (DEBUGGING(LEVELING)) log_machine_info(); - TERN_(LASER_MOVE_G28_OFF, cutter.set_inline_enabled(false)); // turn off laser + /* + * Set the laser power to false to stop the planner from processing the current power setting. + */ + #if ENABLED(LASER_FEATURE) + planner.laser_inline.status.isPowered = false; + #endif #if ENABLED(DUAL_X_CARRIAGE) bool IDEX_saved_duplication_state = extruder_duplication_enabled; diff --git a/Marlin/src/gcode/control/M3-M5.cpp b/Marlin/src/gcode/control/M3-M5.cpp index 817ed4fcb4d9..3c51de6f6f94 100644 --- a/Marlin/src/gcode/control/M3-M5.cpp +++ b/Marlin/src/gcode/control/M3-M5.cpp @@ -31,17 +31,27 @@ /** * Laser: * M3 - Laser ON/Power (Ramped power) - * M4 - Laser ON/Power (Continuous power) + * M4 - Laser ON/Power (Ramped power) + * M5 - Set power output to 0 (leaving inline mode unchanged). + * + * M3I - Enable continuous inline power to be processed by the planner, with power + * calculated and set in the planner blocks, processed inline during stepping. + * Within inline mode M3 S-Values will set the power for the next moves e.g. G1 X10 Y10 powers on with the last S-Value. + * M3I must be set before using planner-synced M3 inline S-Values (LASER_POWER_SYNC). + * + * M4I - Set dynamic mode which calculates laser power OCR based on the current feedrate. + * + * M5I - Clear inline mode and set power to 0. * * Spindle: * M3 - Spindle ON (Clockwise) * M4 - Spindle ON (Counter-clockwise) + * M5 - Spindle OFF * * Parameters: - * S - Set power. S0 will turn the spindle/laser off, except in relative mode. - * O - Set power and OCR (oscillator count register) + * S - Set power. S0 will turn the spindle/laser off. * - * If no PWM pin is defined then M3/M4 just turns it on. + * If no PWM pin is defined then M3/M4 just turns it on or off. * * At least 12.8kHz (50Hz * 256) is needed for Spindle PWM. * Hardware PWM is required on AVR. ISRs are too slow. @@ -70,77 +80,77 @@ void GcodeSuite::M3_M4(const bool is_M4) { reset_stepper_timeout(); // Reset timeout to allow subsequent G-code to power the laser (imm.) #endif - #if EITHER(SPINDLE_LASER_USE_PWM, SPINDLE_SERVO) - auto get_s_power = [] { - if (parser.seenval('S')) { - const float spwr = parser.value_float(); - #if ENABLED(SPINDLE_SERVO) - cutter.unitPower = spwr; - #else - cutter.unitPower = TERN(SPINDLE_LASER_USE_PWM, - cutter.power_to_range(cutter_power_t(round(spwr))), - spwr > 0 ? 255 : 0); - #endif - } - else - cutter.unitPower = cutter.cpwr_to_upwr(SPEED_POWER_STARTUP); - return cutter.unitPower; - }; - #endif + if (cutter.cutter_mode == CUTTER_MODE_STANDARD) + planner.synchronize(); // Wait for previous movement commands (G0/G1/G2/G3) to complete before changing power - #if ENABLED(LASER_POWER_INLINE) - if (parser.seen('I') == DISABLED(LASER_POWER_INLINE_INVERT)) { - // Laser power in inline mode - cutter.inline_direction(is_M4); // Should always be unused - #if ENABLED(SPINDLE_LASER_USE_PWM) - if (parser.seenval('O')) { - cutter.unitPower = cutter.power_to_range(parser.value_byte(), 0); - cutter.inline_ocr_power(cutter.unitPower); // The OCR is a value from 0 to 255 (uint8_t) - } - else - cutter.inline_power(cutter.upower_to_ocr(get_s_power())); - #else - cutter.set_inline_enabled(true); - #endif - return; + #if ENABLED(LASER_FEATURE) + if (parser.seen_test('I')) { + cutter.cutter_mode = is_M4 ? CUTTER_MODE_DYNAMIC : CUTTER_MODE_CONTINUOUS; + cutter.inline_power(0); + cutter.set_enabled(true); } - // Non-inline, standard case - cutter.inline_disable(); // Prevent future blocks re-setting the power #endif - planner.synchronize(); // Wait for previous movement commands (G0/G0/G2/G3) to complete before changing power - cutter.set_reverse(is_M4); - - #if ENABLED(SPINDLE_LASER_USE_PWM) - if (parser.seenval('O')) { - cutter.unitPower = cutter.power_to_range(parser.value_byte(), 0); - cutter.ocr_set_power(cutter.unitPower); // The OCR is a value from 0 to 255 (uint8_t) + auto get_s_power = [] { + float u; + if (parser.seenval('S')) { + const float v = parser.value_float(); + u = TERN(LASER_POWER_TRAP, v, cutter.power_to_range(v)); } - else - cutter.set_power(cutter.upower_to_ocr(get_s_power())); - #elif ENABLED(SPINDLE_SERVO) - cutter.set_power(get_s_power()); - #else + else if (cutter.cutter_mode == CUTTER_MODE_STANDARD) + u = cutter.cpwr_to_upwr(SPEED_POWER_STARTUP); + + cutter.menuPower = cutter.unitPower = u; + + // PWM not implied, power converted to OCR from unit definition and on/off if not PWM. + cutter.power = TERN(SPINDLE_LASER_USE_PWM, cutter.upower_to_ocr(u), u > 0 ? 255 : 0); + return u; + }; + + if (cutter.cutter_mode == CUTTER_MODE_CONTINUOUS || cutter.cutter_mode == CUTTER_MODE_DYNAMIC) { // Laser power in inline mode + #if ENABLED(LASER_FEATURE) + planner.laser_inline.status.isPowered = true; // M3 or M4 is powered either way + get_s_power(); // Update cutter.power if seen + #if ENABLED(LASER_POWER_SYNC) + // With power sync we only set power so it does not effect queued inline power sets + planner.buffer_sync_block(BLOCK_BIT_LASER_PWR); // Send the flag, queueing inline power + #else + planner.synchronize(); + cutter.inline_power(cutter.power); + #endif + #endif + } + else { cutter.set_enabled(true); - #endif - cutter.menuPower = cutter.unitPower; + get_s_power(); + cutter.apply_power( + #if ENABLED(SPINDLE_SERVO) + cutter.unitPower + #elif ENABLED(SPINDLE_LASER_USE_PWM) + cutter.upower_to_ocr(cutter.unitPower) + #else + cutter.unitPower > 0 ? 255 : 0 + #endif + ); + TERN_(SPINDLE_CHANGE_DIR, cutter.set_reverse(is_M4)); + } } /** * M5 - Cutter OFF (when moves are complete) */ void GcodeSuite::M5() { - #if ENABLED(LASER_POWER_INLINE) - if (parser.seen('I') == DISABLED(LASER_POWER_INLINE_INVERT)) { - cutter.set_inline_enabled(false); // Laser power in inline mode - return; - } - // Non-inline, standard case - cutter.inline_disable(); // Prevent future blocks re-setting the power - #endif planner.synchronize(); - cutter.set_enabled(false); - cutter.menuPower = cutter.unitPower; + cutter.power = 0; + cutter.apply_power(0); // M5 just kills power, leaving inline mode unchanged + if (cutter.cutter_mode != CUTTER_MODE_STANDARD) { + if (parser.seen_test('I')) { + TERN_(LASER_FEATURE, cutter.inline_power(cutter.power)); + cutter.set_enabled(false); // Needs to happen while we are in inline mode to clear inline power. + cutter.cutter_mode = CUTTER_MODE_STANDARD; // Switch from inline to standard mode. + } + } + cutter.set_enabled(false); // Disable enable output setting } #endif // HAS_CUTTER diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index f4dac89b0e07..a13940afc326 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -53,7 +53,7 @@ GcodeSuite gcode; #include "../feature/cancel_object.h" #endif -#if ENABLED(LASER_MOVE_POWER) +#if ENABLED(LASER_FEATURE) #include "../feature/spindle_laser.h" #endif @@ -210,8 +210,11 @@ void GcodeSuite::get_destination_from_command() { recovery.save(); #endif - if (parser.floatval('F') > 0) + if (parser.floatval('F') > 0) { feedrate_mm_s = parser.value_feedrate(); + // Update the cutter feed rate for use by M4 I set inline moves. + TERN_(LASER_FEATURE, cutter.feedrate_mm_m = MMS_TO_MMM(feedrate_mm_s)); + } #if BOTH(PRINTCOUNTER, HAS_EXTRUDERS) if (!DEBUGGING(DRYRUN) && !skip_move) @@ -223,15 +226,29 @@ void GcodeSuite::get_destination_from_command() { M165(); #endif - #if ENABLED(LASER_MOVE_POWER) - // Set the laser power in the planner to configure this move - if (parser.seen('S')) { - const float spwr = parser.value_float(); - cutter.inline_power(TERN(SPINDLE_LASER_USE_PWM, cutter.power_to_range(cutter_power_t(round(spwr))), spwr > 0 ? 255 : 0)); + #if ENABLED(LASER_FEATURE) + if (cutter.cutter_mode == CUTTER_MODE_CONTINUOUS || cutter.cutter_mode == CUTTER_MODE_DYNAMIC) { + // Set the cutter power in the planner to configure this move + cutter.last_feedrate_mm_m = 0; + if (WITHIN(parser.codenum, 1, TERN(ARC_SUPPORT, 3, 1)) || TERN0(BEZIER_CURVE_SUPPORT, parser.codenum == 5)) { + planner.laser_inline.status.isPowered = true; + if (parser.seen('I')) cutter.set_enabled(true); // This is set for backward LightBurn compatibility. + if (parser.seen('S')) { + const float v = parser.value_float(), + u = TERN(LASER_POWER_TRAP, v, cutter.power_to_range(v)); + cutter.menuPower = cutter.unitPower = u; + cutter.inline_power(TERN(SPINDLE_LASER_USE_PWM, cutter.upower_to_ocr(u), u > 0 ? 255 : 0)); + } + } + else if (parser.codenum == 0) { + // For dynamic mode we need to flag isPowered off, dynamic power is calculated in the stepper based on feedrate. + if (cutter.cutter_mode == CUTTER_MODE_DYNAMIC) planner.laser_inline.status.isPowered = false; + cutter.inline_power(0); // This is planner-based so only set power and do not disable inline control flags. + } } - else if (ENABLED(LASER_MOVE_G0_OFF) && parser.codenum == 0) // G0 - cutter.set_inline_enabled(false); - #endif + else if (parser.codenum == 0) + cutter.apply_power(0); + #endif // LASER_FEATURE } /** diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 1340ba89ef1b..a967f0109457 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -447,6 +447,16 @@ #error "SPINDLE_LASER_ACTIVE_HIGH is now SPINDLE_LASER_ACTIVE_STATE." #elif defined(SPINDLE_LASER_ENABLE_INVERT) #error "SPINDLE_LASER_ENABLE_INVERT is now SPINDLE_LASER_ACTIVE_STATE." +#elif defined(LASER_POWER_INLINE) + #error "LASER_POWER_INLINE is not required, inline mode is enabled with 'M3 I' and disabled with 'M5 I'." +#elif defined(LASER_POWER_INLINE_TRAPEZOID) + #error "LASER_POWER_INLINE_TRAPEZOID is now LASER_POWER_TRAP." +#elif defined(LASER_POWER_INLINE_TRAPEZOID_CONT) + #error "LASER_POWER_INLINE_TRAPEZOID_CONT is replaced with LASER_POWER_TRAP." +#elif defined(LASER_POWER_INLINE_TRAPEZOID_PER) + #error "LASER_POWER_INLINE_TRAPEZOID_CONT_PER replaced with LASER_POWER_TRAP." +#elif defined(LASER_POWER_INLINE_CONTINUOUS) + #error "LASER_POWER_INLINE_CONTINUOUS is not required, inline mode is enabled with 'M3 I' and disabled with 'M5 I'." #elif defined(CUTTER_POWER_DISPLAY) #error "CUTTER_POWER_DISPLAY is now CUTTER_POWER_UNIT." #elif defined(CHAMBER_HEATER_PIN) @@ -595,6 +605,8 @@ #error "ARC_SUPPORT no longer uses ARC_SEGMENTS_PER_R." #elif ENABLED(ARC_SUPPORT) && (!defined(MIN_ARC_SEGMENT_MM) || !defined(MAX_ARC_SEGMENT_MM)) #error "ARC_SUPPORT now requires MIN_ARC_SEGMENT_MM and MAX_ARC_SEGMENT_MM." +#elif defined(LASER_POWER_INLINE) + #error "LASER_POWER_INLINE is obsolete." #elif defined(SPINDLE_LASER_PWM) #error "SPINDLE_LASER_PWM (true) is now set with SPINDLE_LASER_USE_PWM (enabled)." #elif ANY(IS_RAMPS_EEB, IS_RAMPS_EEF, IS_RAMPS_EFB, IS_RAMPS_EFF, IS_RAMPS_SF) @@ -3841,37 +3853,26 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #error "CUTTER_POWER_UNIT must be PWM255, PERCENT, RPM, or SERVO." #endif - #if ENABLED(LASER_POWER_INLINE) + #if ENABLED(LASER_FEATURE) #if ENABLED(SPINDLE_CHANGE_DIR) - #error "SPINDLE_CHANGE_DIR and LASER_POWER_INLINE are incompatible." - #elif ENABLED(LASER_MOVE_G0_OFF) && DISABLED(LASER_MOVE_POWER) - #error "LASER_MOVE_G0_OFF requires LASER_MOVE_POWER." + #error "SPINDLE_CHANGE_DIR and LASER_FEATURE are incompatible." + #elif ENABLED(LASER_MOVE_G0_OFF) + #error "LASER_MOVE_G0_OFF is no longer required, G0 and G28 cannot apply power." + #elif ENABLED(LASER_MOVE_G28_OFF) + #error "LASER_MOVE_G0_OFF is no longer required, G0 and G28 cannot apply power." + #elif ENABLED(LASER_MOVE_POWER) + #error "LASER_MOVE_POWER is no longer applicable." #endif - #if ENABLED(LASER_POWER_INLINE_TRAPEZOID) + #if ENABLED(LASER_POWER_TRAP) #if DISABLED(SPINDLE_LASER_USE_PWM) - #error "LASER_POWER_INLINE_TRAPEZOID requires SPINDLE_LASER_USE_PWM to function." - #elif ENABLED(S_CURVE_ACCELERATION) - //#ifndef LASER_POWER_INLINE_S_CURVE_ACCELERATION_WARN - // #define LASER_POWER_INLINE_S_CURVE_ACCELERATION_WARN - // #warning "Combining LASER_POWER_INLINE_TRAPEZOID with S_CURVE_ACCELERATION may result in unintended behavior." - //#endif + #error "LASER_POWER_TRAP requires SPINDLE_LASER_USE_PWM to function." #endif #endif - #if ENABLED(LASER_POWER_INLINE_INVERT) - //#ifndef LASER_POWER_INLINE_INVERT_WARN - // #define LASER_POWER_INLINE_INVERT_WARN - // #warning "Enabling LASER_POWER_INLINE_INVERT means that `M5` won't kill the laser immediately; use `M5 I` instead." - //#endif - #endif #else #if SPINDLE_LASER_POWERUP_DELAY < 1 #error "SPINDLE_LASER_POWERUP_DELAY must be greater than 0." #elif SPINDLE_LASER_POWERDOWN_DELAY < 1 #error "SPINDLE_LASER_POWERDOWN_DELAY must be greater than 0." - #elif ENABLED(LASER_MOVE_POWER) - #error "LASER_MOVE_POWER requires LASER_POWER_INLINE." - #elif ANY(LASER_POWER_INLINE_TRAPEZOID, LASER_POWER_INLINE_INVERT, LASER_MOVE_G0_OFF, LASER_MOVE_POWER) - #error "Enabled an inline laser feature without inline laser power being enabled." #endif #endif @@ -3889,7 +3890,7 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #error "SPINDLE_LASER_PWM_PIN not assigned to a PWM pin." #elif !defined(SPINDLE_LASER_PWM_INVERT) #error "SPINDLE_LASER_PWM_INVERT is required for (SPINDLE|LASER)_FEATURE." - #elif !(defined(SPEED_POWER_INTERCEPT) && defined(SPEED_POWER_MIN) && defined(SPEED_POWER_MAX) && defined(SPEED_POWER_STARTUP)) + #elif !(defined(SPEED_POWER_MIN) && defined(SPEED_POWER_MAX) && defined(SPEED_POWER_STARTUP)) #error "SPINDLE_LASER_USE_PWM equation constant(s) missing." #elif _PIN_CONFLICT(X_MIN) #error "SPINDLE_LASER_USE_PWM pin conflicts with X_MIN_PIN." diff --git a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp index 858c6ea781fb..67039d52de7b 100644 --- a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp +++ b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp @@ -670,7 +670,7 @@ void MarlinUI::draw_status_screen() { // Laser / Spindle #if DO_DRAW_CUTTER - if (cutter.isReady && PAGE_CONTAINS(STATUS_CUTTER_TEXT_Y - INFO_FONT_ASCENT, STATUS_CUTTER_TEXT_Y - 1)) { + if (cutter.isReadyForUI && PAGE_CONTAINS(STATUS_CUTTER_TEXT_Y - INFO_FONT_ASCENT, STATUS_CUTTER_TEXT_Y - 1)) { #if CUTTER_UNIT_IS(PERCENT) lcd_put_u8str(STATUS_CUTTER_TEXT_X, STATUS_CUTTER_TEXT_Y, cutter_power2str(cutter.unitPower)); #elif CUTTER_UNIT_IS(RPM) diff --git a/Marlin/src/lcd/menu/menu_item.h b/Marlin/src/lcd/menu/menu_item.h index 77e6bcab7b1b..3e1733ee1c90 100644 --- a/Marlin/src/lcd/menu/menu_item.h +++ b/Marlin/src/lcd/menu/menu_item.h @@ -27,6 +27,10 @@ #include "../../inc/MarlinConfigPre.h" +#if ENABLED(LASER_SYNCHRONOUS_M106_M107) + #include "../../module/planner.h" +#endif + void lcd_move_z(); //////////////////////////////////////////// @@ -538,6 +542,7 @@ class MenuItem_bool : public MenuEditItemBase { inline void on_fan_update() { thermalManager.set_fan_speed(MenuItemBase::itemIndex, editable.uint8); + TERN_(LASER_SYNCHRONOUS_M106_M107, planner.buffer_sync_block(BLOCK_FLAG_SYNC_FANS)); } #if ENABLED(EXTRA_FAN_SPEED) diff --git a/Marlin/src/lcd/menu/menu_spindle_laser.cpp b/Marlin/src/lcd/menu/menu_spindle_laser.cpp index 9efd68ca005d..bef86a6db8a9 100644 --- a/Marlin/src/lcd/menu/menu_spindle_laser.cpp +++ b/Marlin/src/lcd/menu/menu_spindle_laser.cpp @@ -33,7 +33,7 @@ #include "../../feature/spindle_laser.h" void menu_spindle_laser() { - bool is_enabled = cutter.enabled() && cutter.isReady; + bool is_enabled = cutter.enabled(); #if ENABLED(SPINDLE_CHANGE_DIR) bool is_rev = cutter.is_reverse(); #endif @@ -49,7 +49,13 @@ #endif editable.state = is_enabled; - EDIT_ITEM(bool, MSG_CUTTER(TOGGLE), &is_enabled, []{ if (editable.state) cutter.disable(); else cutter.enable_same_dir(); }); + EDIT_ITEM(bool, MSG_CUTTER(TOGGLE), &is_enabled, []{ + #if ENABLED(SPINDLE_FEATURE) + if (editable.state) cutter.disable(); else cutter.enable_same_dir(); + #else + cutter.laser_menu_toggle(!editable.state); + #endif + }); #if ENABLED(AIR_EVACUATION) bool evac_state = cutter.air_evac_state(); @@ -72,12 +78,10 @@ // Setup and fire a test pulse using the current PWM power level for for a duration of test_pulse_min to test_pulse_max ms. EDIT_ITEM_FAST(CUTTER_MENU_PULSE_TYPE, MSG_LASER_PULSE_MS, &cutter.testPulse, LASER_TEST_PULSE_MIN, LASER_TEST_PULSE_MAX); ACTION_ITEM(MSG_LASER_FIRE_PULSE, cutter.test_fire_pulse); + #if ENABLED(HAL_CAN_SET_PWM_FREQ) && SPINDLE_LASER_FREQUENCY + EDIT_ITEM_FAST(CUTTER_MENU_FREQUENCY_TYPE, MSG_CUTTER_FREQUENCY, &cutter.frequency, 2000, 80000, cutter.refresh_frequency); + #endif #endif - - #if BOTH(MARLIN_DEV_MODE, HAL_CAN_SET_PWM_FREQ) && SPINDLE_LASER_FREQUENCY - EDIT_ITEM_FAST(CUTTER_MENU_FREQUENCY_TYPE, MSG_CUTTER_FREQUENCY, &cutter.frequency, 2000, 80000, cutter.refresh_frequency); - #endif - END_MENU(); } diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index b80be01dea29..bc5bfd3dfcc4 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -128,8 +128,13 @@ uint8_t Planner::delay_before_delivering; // This counter delays delivery planner_settings_t Planner::settings; // Initialized by settings.load() -#if ENABLED(LASER_POWER_INLINE) +/** + * Set up inline block variables + * Set laser_power_floor based on SPEED_POWER_MIN to pevent a zero power output state with LASER_POWER_TRAP + */ +#if ENABLED(LASER_FEATURE) laser_state_t Planner::laser_inline; // Current state for blocks + const uint8_t laser_power_floor = cutter.pct_to_ocr(SPEED_POWER_MIN); #endif uint32_t Planner::max_acceleration_steps_per_s2[DISTINCT_AXES]; // (steps/s^2) Derived from mm_per_s2 @@ -799,6 +804,7 @@ void Planner::calculate_trapezoid_for_block(block_t * const block, const_float_t if (plateau_steps < 0) { const float accelerate_steps_float = CEIL(intersection_distance(initial_rate, final_rate, accel, block->step_event_count)); accelerate_steps = _MIN(uint32_t(_MAX(accelerate_steps_float, 0)), block->step_event_count); + decelerate_steps = block->step_event_count - accelerate_steps; plateau_steps = 0; #if ENABLED(S_CURVE_ACCELERATION) @@ -822,7 +828,7 @@ void Planner::calculate_trapezoid_for_block(block_t * const block, const_float_t // Store new block parameters block->accelerate_until = accelerate_steps; - block->decelerate_after = accelerate_steps + plateau_steps; + block->decelerate_after = block->step_event_count - decelerate_steps; block->initial_rate = initial_rate; #if ENABLED(S_CURVE_ACCELERATION) block->acceleration_time = acceleration_time; @@ -833,46 +839,52 @@ void Planner::calculate_trapezoid_for_block(block_t * const block, const_float_t #endif block->final_rate = final_rate; - /** - * Laser trapezoid calculations - * - * Approximate the trapezoid with the laser, incrementing the power every `entry_per` while accelerating - * and decrementing it every `exit_power_per` while decelerating, thus ensuring power is related to feedrate. - * - * LASER_POWER_INLINE_TRAPEZOID_CONT doesn't need this as it continuously approximates - * - * Note this may behave unreliably when running with S_CURVE_ACCELERATION - */ - #if ENABLED(LASER_POWER_INLINE_TRAPEZOID) - if (block->laser.power > 0) { // No need to care if power == 0 - const uint8_t entry_power = block->laser.power * entry_factor; // Power on block entry - #if DISABLED(LASER_POWER_INLINE_TRAPEZOID_CONT) - // Speedup power - const uint8_t entry_power_diff = block->laser.power - entry_power; - if (entry_power_diff) { - block->laser.entry_per = accelerate_steps / entry_power_diff; - block->laser.power_entry = entry_power; - } - else { - block->laser.entry_per = 0; - block->laser.power_entry = block->laser.power; - } - // Slowdown power - const uint8_t exit_power = block->laser.power * exit_factor, // Power on block entry - exit_power_diff = block->laser.power - exit_power; - if (exit_power_diff) { - block->laser.exit_per = (block->step_event_count - block->decelerate_after) / exit_power_diff; - block->laser.power_exit = exit_power; + #if ENABLED(LASER_POWER_TRAP) + /** + * Laser Trapezoid Calculations + * + * Approximate the trapezoid with the laser, incrementing the power every `trap_ramp_entry_incr` steps while accelerating, + * and decrementing the power every `trap_ramp_exit_decr` while decelerating, to keep power proportional to feedrate. + * Laser power trap will reduce the initial power to no less than the laser_power_floor value. Based on the number + * of calculated accel/decel steps the power is distributed over the trapezoid entry- and exit-ramp steps. + * + * trap_ramp_active_pwr - The active power is initially set at a reduced level factor of initial power / accel steps and + * will be additively incremented using a trap_ramp_entry_incr value for each accel step processed later in the stepper code. + * The trap_ramp_exit_decr value is calculated as power / decel steps and is also adjusted to no less than the power floor. + * + * If the power == 0 the inline mode variables need to be set to zero to prevent stepper processing. The method allows + * for simpler non-powered moves like G0 or G28. + * + * Laser Trap Power works for all Jerk and Curve modes; however Arc-based moves will have issues since the segments are + * usually too small. + */ + if (cutter.cutter_mode == CUTTER_MODE_CONTINUOUS) { + if (planner.laser_inline.status.isPowered && planner.laser_inline.status.isEnabled) { + if (block->laser.power > 0) { + NOLESS(block->laser.power, laser_power_floor); + block->laser.trap_ramp_active_pwr = (block->laser.power - laser_power_floor) * (initial_rate / float(block->nominal_rate)) + laser_power_floor; + block->laser.trap_ramp_entry_incr = (block->laser.power - block->laser.trap_ramp_active_pwr) / accelerate_steps; + float laser_pwr = block->laser.power * (final_rate / float(block->nominal_rate)); + NOLESS(laser_pwr, laser_power_floor); + block->laser.trap_ramp_exit_decr = (block->laser.power - laser_pwr) / decelerate_steps; + #if ENABLED(DEBUG_LASER_TRAP) + SERIAL_ECHO_MSG("lp:",block->laser.power); + SERIAL_ECHO_MSG("as:",accelerate_steps); + SERIAL_ECHO_MSG("ds:",decelerate_steps); + SERIAL_ECHO_MSG("p.trap:",block->laser.trap_ramp_active_pwr); + SERIAL_ECHO_MSG("p.incr:",block->laser.trap_ramp_entry_incr); + SERIAL_ECHO_MSG("p.decr:",block->laser.trap_ramp_exit_decr); + #endif } else { - block->laser.exit_per = 0; - block->laser.power_exit = block->laser.power; + block->laser.trap_ramp_active_pwr = 0; + block->laser.trap_ramp_entry_incr = 0; + block->laser.trap_ramp_exit_decr = 0; } - #else - block->laser.power_entry = entry_power; - #endif + + } } - #endif + #endif // LASER_POWER_TRAP } /* PLANNER SPEED DEFINITION @@ -1130,10 +1142,9 @@ void Planner::recalculate_trapezoids() { // The tail may be changed by the ISR so get a local copy. uint8_t block_index = block_buffer_tail, head_block_index = block_buffer_head; - - // Since there could be non-move blocks in the head of the queue, and the + // Since there could be a sync block in the head of the queue, and the // next loop must not recalculate the head block (as it needs to be - // specially handled), scan backwards to the first move block. + // specially handled), scan backwards to the first non-SYNC block. while (head_block_index != block_index) { // Go back (head always point to the first free block) @@ -1203,7 +1214,7 @@ void Planner::recalculate_trapezoids() { // Last/newest block in buffer. Exit speed is set with MINIMUM_PLANNER_SPEED. Always recalculated. if (next) { - // Mark the last block as RECALCULATE, to prevent the Stepper ISR running it. + // Mark the next(last) block as RECALCULATE, to prevent the Stepper ISR running it. // As the last block is always recalculated here, there is a chance the block isn't // marked as RECALCULATE yet. That's the reason for the following line. block->flag.recalculate = true; @@ -1295,7 +1306,7 @@ void Planner::recalculate() { #endif // HAS_FAN /** - * Maintain fans, paste extruder pressure, + * Maintain fans, paste extruder pressure, spindle/laser power */ void Planner::check_axes_activity() { @@ -1359,7 +1370,7 @@ void Planner::check_axes_activity() { } else { - TERN_(HAS_CUTTER, cutter.refresh()); + TERN_(HAS_CUTTER, if (cutter.cutter_mode == CUTTER_MODE_STANDARD) cutter.refresh()); #if HAS_TAIL_FAN_SPEED FANS_LOOP(i) { @@ -1459,7 +1470,7 @@ void Planner::check_axes_activity() { for (uint8_t b = block_buffer_tail; b != block_buffer_head; b = next_block_index(b)) { const block_t * const block = &block_buffer[b]; if (NUM_AXIS_GANG(block->steps.x, || block->steps.y, || block->steps.z, || block->steps.i, || block->steps.j, || block->steps.k, || block->steps.u, || block->steps.v, || block->steps.w)) { - const float se = (float)block->steps.e / block->step_event_count * SQRT(block->nominal_speed_sqr); // mm/sec + const float se = (float)block->steps.e / block->step_event_count * SQRT(block->nominal_speed_sqr); // mm/sec; NOLESS(high, se); } } @@ -1781,7 +1792,7 @@ void Planner::synchronize() { while (busy()) idle(); } bool Planner::_buffer_steps(const xyze_long_t &target OPTARG(HAS_POSITION_FLOAT, const xyze_pos_t &target_float) OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm) - , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters/*=0.0*/ + , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters ) { // Wait for the next available block @@ -1863,8 +1874,36 @@ bool Planner::_populate_block( ); /* <-- add a slash to enable - #define _ALINE(A) " " STR_##A ":", target[_AXIS(A)], " (", int32_t(target[_AXIS(A)] - position[_AXIS(A)]), " steps)" - SERIAL_ECHOLNPGM(" _populate_block FR:", fr_mm_s, LOGICAL_AXIS_MAP(_ALINE)); + SERIAL_ECHOLNPGM( + " _populate_block FR:", fr_mm_s, + " A:", target.a, " (", da, " steps)" + #if HAS_Y_AXIS + " B:", target.b, " (", db, " steps)" + #endif + #if HAS_Z_AXIS + " C:", target.c, " (", dc, " steps)" + #endif + #if HAS_I_AXIS + " " STR_I ":", target.i, " (", di, " steps)" + #endif + #if HAS_J_AXIS + " " STR_J ":", target.j, " (", dj, " steps)" + #endif + #if HAS_K_AXIS + " " STR_K ":", target.k, " (", dk, " steps)" + #endif + #if HAS_U_AXIS + " " STR_U ":", target.u, " (", du, " steps)" + #endif + #if HAS_V_AXIS + " " STR_V ":", target.v, " (", dv, " steps)" + #endif + #if HAS_W_AXIS + " " STR_W ":", target.w, " (", dw, " steps)" + #if HAS_EXTRUDERS + " E:", target.e, " (", de, " steps)" + #endif + ); //*/ #if EITHER(PREVENT_COLD_EXTRUSION, PREVENT_LENGTHY_EXTRUDE) @@ -1962,11 +2001,34 @@ bool Planner::_populate_block( // Set direction bits block->direction_bits = dm; - // Update block laser power - #if ENABLED(LASER_POWER_INLINE) - laser_inline.status.isPlanned = true; - block->laser.status = laser_inline.status; - block->laser.power = laser_inline.power; + /** + * Update block laser power + * For standard mode get the cutter.power value for processing, since it's + * only set by apply_power(). + */ + #if HAS_CUTTER + switch (cutter.cutter_mode) { + default: break; + + case CUTTER_MODE_STANDARD: block->cutter_power = cutter.power; break; + + #if ENABLED(LASER_FEATURE) + /** + * For inline mode get the laser_inline variables, including power and status. + * Dynamic mode only needs to update if the feedrate has changed, since it's + * calculated from the current feedrate and power level. + */ + case CUTTER_MODE_CONTINUOUS: + block->laser.power = laser_inline.power; + block->laser.status = laser_inline.status; + break; + + case CUTTER_MODE_DYNAMIC: + if (cutter.laser_feedrate_changed()) // Only process changes in rate + block->laser.power = laser_inline.power = cutter.calc_dynamic_power(); + break; + #endif + } #endif // Number of steps for each axis @@ -2028,9 +2090,9 @@ bool Planner::_populate_block( #endif #elif ENABLED(MARKFORGED_XY) steps_dist_mm.a = (da - db) * mm_per_step[A_AXIS]; - steps_dist_mm.b = db * mm_per_step[B_AXIS]; + steps_dist_mm.b = db * mm_per_step[B_AXIS]; #elif ENABLED(MARKFORGED_YX) - steps_dist_mm.a = da * mm_per_step[A_AXIS]; + steps_dist_mm.a = da * mm_per_step[A_AXIS]; steps_dist_mm.b = (db - da) * mm_per_step[B_AXIS]; #else XYZ_CODE( @@ -2076,21 +2138,12 @@ bool Planner::_populate_block( block->millimeters = millimeters; else { /** - * Distance for interpretation of feedrate in accordance with LinuxCNC (the successor of - * NIST RS274NGC interpreter - version 3) and its default CANON_XYZ feed reference mode. - * - * Assume: - * - X, Y, Z are the primary linear axes; - * - U, V, W are secondary linear axes; - * - A, B, C are rotational axes. - * - * Then: - * - dX, dY, dZ are the displacements of the primary linear axes; - * - dU, dV, dW are the displacements of linear axes; - * - dA, dB, dC are the displacements of rotational axes. - * - * The time it takes to execute move command with feedrate F is t = D/F, - * where D is the total distance, calculated as follows: + * Distance for interpretation of feedrate in accordance with LinuxCNC (the successor of NIST + * RS274NGC interpreter - version 3) and its default CANON_XYZ feed reference mode. + * Assume that X, Y, Z are the primary linear axes and U, V, W are secondary linear axes and A, B, C are + * rotational axes. Then dX, dY, dZ are the displacements of the primary linear axes and dU, dV, dW are the displacements of linear axes and + * dA, dB, dC are the displacements of rotational axes. + * The time it takes to execute move command with feedrate F is t = D/F, where D is the total distance, calculated as follows: * D^2 = dX^2 + dY^2 + dZ^2 * if D^2 == 0 (none of XYZ move but any secondary linear axes move, whether other axes are moved or not): * D^2 = dU^2 + dV^2 + dW^2 @@ -2099,9 +2152,8 @@ bool Planner::_populate_block( */ float distance_sqr = ( #if ENABLED(ARTICULATED_ROBOT_ARM) - // For articulated robots, interpreting feedrate like LinuxCNC would require inverse kinematics. As a workaround, - // assume that motors sit on a mutually-orthogonal axes and we can think of distance as magnitude of an n-vector - // in an n-dimensional Euclidian space. + // For articulated robots, interpreting feedrate like LinuxCNC would require inverse kinematics. As a workaround, pretend that motors sit on n mutually orthogonal + // axes and assume that we could think of distance as magnitude of an n-vector in an n-dimensional Euclidian space. NUM_AXIS_GANG( sq(steps_dist_mm.x), + sq(steps_dist_mm.y), + sq(steps_dist_mm.z), + sq(steps_dist_mm.i), + sq(steps_dist_mm.j), + sq(steps_dist_mm.k), @@ -2121,7 +2173,7 @@ bool Planner::_populate_block( #elif CORE_IS_YZ XYZ_GANG(sq(steps_dist_mm.x), + sq(steps_dist_mm.head.y), + sq(steps_dist_mm.head.z)) #else - XYZ_GANG(sq(steps_dist_mm.x), + sq(steps_dist_mm.y), + sq(steps_dist_mm.z)) + XYZ_GANG(sq(steps_dist_mm.x), + sq(steps_dist_mm.y), + sq(steps_dist_mm.z)) #endif ); @@ -2154,9 +2206,9 @@ bool Planner::_populate_block( /** * At this point at least one of the axes has more steps than - * MIN_STEPS_PER_SEGMENT, ensuring the segment won't get dropped - * as zero-length. It's important to not apply corrections to blocks - * that would get dropped! + * MIN_STEPS_PER_SEGMENT, ensuring the segment won't get dropped as + * zero-length. It's important to not apply corrections + * to blocks that would get dropped! * * A correction function is permitted to add steps to an axis, it * should *never* remove steps! @@ -2177,7 +2229,6 @@ bool Planner::_populate_block( TERN_(MIXING_EXTRUDER, mixer.populate_block(block->b_color)); - TERN_(HAS_CUTTER, block->cutter_power = cutter.power); #if HAS_FAN FANS_LOOP(i) block->fan_speed[i] = thermalManager.fan_speed[i]; @@ -2192,9 +2243,15 @@ bool Planner::_populate_block( #if ENABLED(AUTO_POWER_CONTROL) if (NUM_AXIS_GANG( - block->steps.x, || block->steps.y, || block->steps.z, - || block->steps.i, || block->steps.j, || block->steps.k, - || block->steps.u, || block->steps.v, || block->steps.w + block->steps.x, + || block->steps.y, + || block->steps.z, + || block->steps.i, + || block->steps.j, + || block->steps.k, + || block->steps.u, + || block->steps.v, + || block->steps.w )) powerManager.power_on(); #endif @@ -2428,7 +2485,7 @@ bool Planner::_populate_block( if (speed_factor < 1.0f) { current_speed *= speed_factor; block->nominal_rate *= speed_factor; - block->nominal_speed_sqr *= sq(speed_factor); + block->nominal_speed_sqr = block->nominal_speed_sqr * sq(speed_factor); } // Compute and limit the acceleration rate for the trapezoid generator. @@ -2630,15 +2687,14 @@ bool Planner::_populate_block( vmax_junction_sqr = sq(float(MINIMUM_PLANNER_SPEED)); } else { + NOLESS(junction_cos_theta, -0.999999f); // Check for numerical round-off to avoid divide by zero. + // Convert delta vector to unit vector xyze_float_t junction_unit_vec = unit_vec - prev_unit_vec; normalize_junction_vector(junction_unit_vec); - const float junction_acceleration = limit_value_by_axis_maximum(block->acceleration, junction_unit_vec); - - NOLESS(junction_cos_theta, -0.999999f); // Check for numerical round-off to avoid divide by zero. - - const float sin_theta_d2 = SQRT(0.5f * (1.0f - junction_cos_theta)); // Trig half angle identity. Always positive. + const float junction_acceleration = limit_value_by_axis_maximum(block->acceleration, junction_unit_vec), + sin_theta_d2 = SQRT(0.5f * (1.0f - junction_cos_theta)); // Trig half angle identity. Always positive. vmax_junction_sqr = junction_acceleration * junction_deviation_mm * sin_theta_d2 / (1.0f - sin_theta_d2); @@ -2889,21 +2945,19 @@ bool Planner::_populate_block( /** * Planner::buffer_sync_block - * Add a block to the buffer that just updates the position, - * or in case of LASER_SYNCHRONOUS_M106_M107 the fan PWM + * Add a block to the buffer that just updates the position + * @param sync_flag BLOCK_FLAG_SYNC_FANS & BLOCK_FLAG_LASER_PWR + * Supports LASER_SYNCHRONOUS_M106_M107 and LASER_POWER_SYNC power sync block buffer queueing. */ -void Planner::buffer_sync_block(TERN_(LASER_SYNCHRONOUS_M106_M107, const BlockFlagBit sync_flag/*=BLOCK_BIT_SYNC_POSITION*/)) { - #if DISABLED(LASER_SYNCHRONOUS_M106_M107) - constexpr BlockFlagBit sync_flag = BLOCK_BIT_SYNC_POSITION; - #endif + +void Planner::buffer_sync_block(const BlockFlagBit sync_flag/*=BLOCK_BIT_SYNC_POSITION*/) { // Wait for the next available block uint8_t next_buffer_head; block_t * const block = get_next_free_block(next_buffer_head); // Clear block - block->reset(); - + memset(block, 0, sizeof(block_t)); block->flag.apply(sync_flag); block->position = position; @@ -2915,6 +2969,12 @@ void Planner::buffer_sync_block(TERN_(LASER_SYNCHRONOUS_M106_M107, const BlockFl FANS_LOOP(i) block->fan_speed[i] = thermalManager.fan_speed[i]; #endif + /** + * M3-based power setting can be processed inline with a laser power sync block. + * During active moves cutter.power is processed immediately, otherwise on the next move. + */ + TERN_(LASER_POWER_SYNC, block->laser.power = cutter.power); + // If this is the first added movement, reload the delay, otherwise, cancel it. if (block_buffer_head == block_buffer_tail) { // If it was the first queued block, restart the 1st block delivery delay, to @@ -3052,8 +3112,8 @@ bool Planner::buffer_segment(const abce_pos_t &abce if (!_buffer_steps(target OPTARG(HAS_POSITION_FLOAT, target_float) OPTARG(HAS_DIST_MM_ARG, cart_dist_mm) - , fr_mm_s, extruder, millimeters - )) return false; + , fr_mm_s, extruder, millimeters) + ) return false; stepper.wake_up(); return true; @@ -3099,7 +3159,7 @@ bool Planner::buffer_line(const xyze_pos_t &cart, const_feedRate_t fr_mm_s, cons inverse_kinematics(machine); #if ENABLED(SCARA_FEEDRATE_SCALING) - // For SCARA scale the feed rate from mm/s to degrees/s + // For SCARA scale the feedrate from mm/s to degrees/s // i.e., Complete the angular vector in the given time. const float duration_recip = inv_duration ?: fr_mm_s / mm; const xyz_pos_t diff = delta - position_float; @@ -3120,14 +3180,6 @@ bool Planner::buffer_line(const xyze_pos_t &cart, const_feedRate_t fr_mm_s, cons #if ENABLED(DIRECT_STEPPING) - /** - * @brief Add a direct stepping page block to the buffer - * and wake up the Stepper ISR to process it. - * - * @param page_idx Page index provided by G6 I - * @param extruder The extruder to use in the move - * @param num_steps Number of steps to process in the ISR - */ void Planner::buffer_page(const page_idx_t page_idx, const uint8_t extruder, const uint16_t num_steps) { if (!last_page_step_rate) { kill(GET_TEXT_F(MSG_BAD_PAGE_SPEED)); @@ -3212,7 +3264,7 @@ void Planner::set_machine_position_mm(const abce_pos_t &abce) { if (has_blocks_queued()) { //previous_nominal_speed_sqr = 0.0; // Reset planner junction speeds. Assume start from rest. //previous_speed.reset(); - buffer_sync_block(); + buffer_sync_block(BLOCK_BIT_SYNC_POSITION); } else { #if ENABLED(BACKLASH_COMPENSATION) @@ -3225,12 +3277,6 @@ void Planner::set_machine_position_mm(const abce_pos_t &abce) { } } -/** - * @brief Set the Planner position in mm - * @details Set the Planner position from a native machine position in mm - * - * @param xyze A native (Cartesian) machine position - */ void Planner::set_position_mm(const xyze_pos_t &xyze) { xyze_pos_t machine = xyze; TERN_(HAS_POSITION_MODIFIERS, apply_modifiers(machine, true)); @@ -3259,20 +3305,14 @@ void Planner::set_position_mm(const xyze_pos_t &xyze) { TERN_(IS_KINEMATIC, TERN_(HAS_EXTRUDERS, position_cart.e = e)); if (has_blocks_queued()) - buffer_sync_block(); + buffer_sync_block(BLOCK_BIT_SYNC_POSITION); else stepper.set_axis_position(E_AXIS, position.e); } #endif -/** - * @brief Recalculate the steps/s^2 acceleration rates, based on the mm/s^2 - * @details Update planner movement factors after a change to certain settings: - * - max_acceleration_steps_per_s2 from settings max_acceleration_mm_per_s2 * axis_steps_per_mm (M201, M92) - * - acceleration_long_cutoff based on the largest max_acceleration_steps_per_s2 (M201) - * - max_e_jerk for all extruders based on junction_deviation_mm (M205 J) - */ +// Recalculate the steps/s^2 acceleration rates, based on the mm/s^2 void Planner::refresh_acceleration_rates() { uint32_t highest_rate = 1; LOOP_DISTINCT_AXES(i) { @@ -3285,8 +3325,8 @@ void Planner::refresh_acceleration_rates() { } /** - * @brief Recalculate 'position' and 'mm_per_step'. - * @details Required whenever settings.axis_steps_per_mm changes! + * Recalculate 'position' and 'mm_per_step'. + * Must be called whenever settings.axis_steps_per_mm changes! */ void Planner::refresh_positioning() { LOOP_DISTINCT_AXES(i) mm_per_step[i] = 1.0f / settings.axis_steps_per_mm[i]; diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index a6f5bd5774d7..e0aa89ab7228 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -89,30 +89,6 @@ #define HAS_DIST_MM_ARG 1 #endif -#if ENABLED(LASER_POWER_INLINE) - - typedef struct { - bool isPlanned:1; - bool isEnabled:1; - bool dir:1; - bool Reserved:6; - } power_status_t; - - typedef struct { - power_status_t status; // See planner settings for meaning - uint8_t power; // Ditto; When in trapezoid mode this is nominal power - #if ENABLED(LASER_POWER_INLINE_TRAPEZOID) - uint8_t power_entry; // Entry power for the laser - #if DISABLED(LASER_POWER_INLINE_TRAPEZOID_CONT) - uint8_t power_exit; // Exit power for the laser - uint32_t entry_per, // Steps per power increment (to avoid floats in stepper calcs) - exit_per; // Steps per power decrement - #endif - #endif - } block_laser_t; - -#endif - /** * Planner block flags as boolean bit fields */ @@ -132,14 +108,14 @@ enum BlockFlagBit { BLOCK_BIT_SYNC_POSITION // Direct stepping page - #if ENABLED(DIRECT_STEPPING) - , BLOCK_BIT_PAGE - #endif + OPTARG(DIRECT_STEPPING, BLOCK_BIT_PAGE) + // Sync the fan speeds from the block - #if ENABLED(LASER_SYNCHRONOUS_M106_M107) - , BLOCK_BIT_SYNC_FANS - #endif + OPTARG(LASER_SYNCHRONOUS_M106_M107, BLOCK_BIT_SYNC_FANS) + + // Sync laser power from a queued block + OPTARG(LASER_POWER_SYNC, BLOCK_BIT_LASER_PWR) }; /** @@ -165,6 +141,10 @@ typedef struct { #if ENABLED(LASER_SYNCHRONOUS_M106_M107) bool sync_fans:1; #endif + + #if ENABLED(LASER_POWER_SYNC) + bool sync_laser_pwr:1; + #endif }; }; @@ -176,9 +156,34 @@ typedef struct { } block_flags_t; +#if ENABLED(LASER_FEATURE) + + typedef struct { + bool isEnabled:1; // Set to engage the inline laser power output. + bool dir:1; + bool isPowered:1; // Set on any parsed G1, G2, G3, or G5 powered move, cleared on G0 and G28. + bool isSyncPower:1; // Set on a M3 sync based set laser power, used to determine active trap power + bool Reserved:4; + } power_status_t; + + typedef struct { + power_status_t status; // See planner settings for meaning + uint8_t power; // Ditto; When in trapezoid mode this is nominal power + + #if ENABLED(LASER_POWER_TRAP) + float trap_ramp_active_pwr; // Laser power level during active trapezoid smoothing + float trap_ramp_entry_incr; // Acceleration per step laser power increment (trap entry) + float trap_ramp_exit_decr; // Deceleration per step laser power decrement (trap exit) + #endif + } block_laser_t; + +#endif + /** - * A single entry in the planner buffer, used to set up and - * track a coordinated linear motion for one or more axes. + * struct block_t + * + * A single entry in the planner buffer. + * Tracks linear movement over multiple axes. * * The "nominal" values are as-specified by G-code, and * may never actually be reached due to acceleration limits. @@ -188,7 +193,8 @@ typedef struct block_t { volatile block_flags_t flag; // Block flags volatile bool is_fan_sync() { return TERN0(LASER_SYNCHRONOUS_M106_M107, flag.sync_fans); } - volatile bool is_sync() { return flag.sync_position || is_fan_sync(); } + volatile bool is_pwr_sync() { return TERN0(LASER_POWER_SYNC, flag.sync_laser_pwr); } + volatile bool is_sync() { return flag.sync_position || is_fan_sync() || is_pwr_sync(); } volatile bool is_page() { return TERN0(DIRECT_STEPPING, flag.page); } volatile bool is_move() { return !(is_sync() || is_page()); } @@ -270,12 +276,10 @@ typedef struct block_t { xyze_pos_t start_position; #endif - #if ENABLED(LASER_POWER_INLINE) + #if ENABLED(LASER_FEATURE) block_laser_t laser; #endif - void reset() { memset((char*)this, 0, sizeof(*this)); } - } block_t; #if ANY(LIN_ADVANCE, SCARA_FEEDRATE_SCALING, GRADIENT_MIX, LCD_SHOW_E_TOTAL, POWER_LOSS_RECOVERY) @@ -284,7 +288,7 @@ typedef struct block_t { #define BLOCK_MOD(n) ((n)&(BLOCK_BUFFER_SIZE-1)) -#if ENABLED(LASER_POWER_INLINE) +#if ENABLED(LASER_FEATURE) typedef struct { /** * Laser status flags @@ -293,11 +297,10 @@ typedef struct block_t { /** * Laser power: 0 or 255 in case of PWM-less laser, * or the OCR (oscillator count register) value; - * * Using OCR instead of raw power, because it avoids * floating point operations during the move loop. */ - uint8_t power; + volatile uint8_t power; } laser_state_t; #endif @@ -399,7 +402,7 @@ class Planner { static planner_settings_t settings; - #if ENABLED(LASER_POWER_INLINE) + #if ENABLED(LASER_FEATURE) static laser_state_t laser_inline; #endif @@ -784,12 +787,11 @@ class Planner { /** * Planner::buffer_sync_block - * Add a block to the buffer that just updates the position or in - * case of LASER_SYNCHRONOUS_M106_M107 the fan pwm + * Add a block to the buffer that just updates the position + * @param sync_flag sets a condition bit to process additional items + * such as sync fan pwm or sync M3/M4 laser power into a queued block */ - static void buffer_sync_block( - TERN_(LASER_SYNCHRONOUS_M106_M107, const BlockFlagBit flag=BLOCK_BIT_SYNC_POSITION) - ); + static void buffer_sync_block(const BlockFlagBit flag=BLOCK_BIT_SYNC_POSITION); #if IS_KINEMATIC private: diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 5dd1bd24b3fe..4832220abd75 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -253,20 +253,6 @@ xyz_long_t Stepper::endstops_trigsteps; xyze_long_t Stepper::count_position{0}; xyze_int8_t Stepper::count_direction{0}; -#if ENABLED(LASER_POWER_INLINE_TRAPEZOID) - Stepper::stepper_laser_t Stepper::laser_trap = { - .enabled = false, - .cur_power = 0, - .cruise_set = false, - #if DISABLED(LASER_POWER_INLINE_TRAPEZOID_CONT) - .last_step_count = 0, - .acc_step_count = 0 - #else - .till_update = 0 - #endif - }; -#endif - #define MINDIR(A) (count_direction[_AXIS(A)] < 0) #define MAXDIR(A) (count_direction[_AXIS(A)] > 0) @@ -1964,7 +1950,6 @@ uint32_t Stepper::block_phase_isr() { // If there is a current block if (current_block) { - // If current block is finished, reset pointer and finalize state if (step_events_completed >= step_event_count) { #if ENABLED(DIRECT_STEPPING) @@ -2017,32 +2002,28 @@ uint32_t Stepper::block_phase_isr() { else if (LA_steps) nextAdvanceISR = 0; #endif - // Update laser - Accelerating - #if ENABLED(LASER_POWER_INLINE_TRAPEZOID) - if (laser_trap.enabled) { - #if DISABLED(LASER_POWER_INLINE_TRAPEZOID_CONT) - if (current_block->laser.entry_per) { - laser_trap.acc_step_count -= step_events_completed - laser_trap.last_step_count; - laser_trap.last_step_count = step_events_completed; - - // Should be faster than a divide, since this should trip just once - if (laser_trap.acc_step_count < 0) { - while (laser_trap.acc_step_count < 0) { - laser_trap.acc_step_count += current_block->laser.entry_per; - if (laser_trap.cur_power < current_block->laser.power) laser_trap.cur_power++; - } - cutter.ocr_set_power(laser_trap.cur_power); - } - } - #else - if (laser_trap.till_update) - laser_trap.till_update--; - else { - laser_trap.till_update = LASER_POWER_INLINE_TRAPEZOID_CONT_PER; - laser_trap.cur_power = (current_block->laser.power * acc_step_rate) / current_block->nominal_rate; - cutter.ocr_set_power(laser_trap.cur_power); // Cycle efficiency is irrelevant it the last line was many cycles + /* + * Adjust Laser Power - Accelerating + * isPowered - True when a move is powered. + * isEnabled - laser power is active. + * Laser power variables are calulated and stored in this block by the planner code. + * + * trap_ramp_active_pwr - the active power in this block across accel or decel trap steps. + * trap_ramp_entry_incr - holds the precalculated value to increase the current power per accel step. + * + * Apply the starting active power and then increase power per step by the trap_ramp_entry_incr value if positive. + */ + + #if ENABLED(LASER_POWER_TRAP) + if (cutter.cutter_mode == CUTTER_MODE_CONTINUOUS) { + if (planner.laser_inline.status.isPowered && planner.laser_inline.status.isEnabled) { + if (current_block->laser.trap_ramp_entry_incr > 0) { + cutter.apply_power(current_block->laser.trap_ramp_active_pwr); + current_block->laser.trap_ramp_active_pwr += current_block->laser.trap_ramp_entry_incr; } - #endif + } + // Not a powered move. + else cutter.apply_power(0); } #endif } @@ -2066,7 +2047,6 @@ uint32_t Stepper::block_phase_isr() { : current_block->final_rate; } #else - // Using the old trapezoidal control step_rate = STEP_MULTIPLY(deceleration_time, current_block->acceleration_rate); if (step_rate < acc_step_rate) { // Still decelerating? @@ -2094,37 +2074,25 @@ uint32_t Stepper::block_phase_isr() { else if (LA_steps) nextAdvanceISR = 0; #endif // LIN_ADVANCE - // Update laser - Decelerating - #if ENABLED(LASER_POWER_INLINE_TRAPEZOID) - if (laser_trap.enabled) { - #if DISABLED(LASER_POWER_INLINE_TRAPEZOID_CONT) - if (current_block->laser.exit_per) { - laser_trap.acc_step_count -= step_events_completed - laser_trap.last_step_count; - laser_trap.last_step_count = step_events_completed; - - // Should be faster than a divide, since this should trip just once - if (laser_trap.acc_step_count < 0) { - while (laser_trap.acc_step_count < 0) { - laser_trap.acc_step_count += current_block->laser.exit_per; - if (laser_trap.cur_power > current_block->laser.power_exit) laser_trap.cur_power--; - } - cutter.ocr_set_power(laser_trap.cur_power); - } - } - #else - if (laser_trap.till_update) - laser_trap.till_update--; - else { - laser_trap.till_update = LASER_POWER_INLINE_TRAPEZOID_CONT_PER; - laser_trap.cur_power = (current_block->laser.power * step_rate) / current_block->nominal_rate; - cutter.ocr_set_power(laser_trap.cur_power); // Cycle efficiency isn't relevant when the last line was many cycles + /* + * Adjust Laser Power - Decelerating + * trap_ramp_entry_decr - holds the precalculated value to decrease the current power per decel step. + */ + #if ENABLED(LASER_POWER_TRAP) + if (cutter.cutter_mode == CUTTER_MODE_CONTINUOUS) { + if (planner.laser_inline.status.isPowered && planner.laser_inline.status.isEnabled) { + if (current_block->laser.trap_ramp_exit_decr > 0) { + current_block->laser.trap_ramp_active_pwr -= current_block->laser.trap_ramp_exit_decr; + cutter.apply_power(current_block->laser.trap_ramp_active_pwr); } - #endif + // Not a powered move. + else cutter.apply_power(0); + } } #endif + } - // Must be in cruise phase otherwise - else { + else { // Must be in cruise phase otherwise #if ENABLED(LIN_ADVANCE) // If there are any esteps, fire the next advance_isr "now" @@ -2139,24 +2107,50 @@ uint32_t Stepper::block_phase_isr() { // The timer interval is just the nominal value for the nominal speed interval = ticks_nominal; + } - // Update laser - Cruising - #if ENABLED(LASER_POWER_INLINE_TRAPEZOID) - if (laser_trap.enabled) { - if (!laser_trap.cruise_set) { - laser_trap.cur_power = current_block->laser.power; - cutter.ocr_set_power(laser_trap.cur_power); - laser_trap.cruise_set = true; + /* Adjust Laser Power - Cruise + * power - direct or floor adjusted active laser power. + */ + + #if ENABLED(LASER_POWER_TRAP) + if (cutter.cutter_mode == CUTTER_MODE_CONTINUOUS) { + if (step_events_completed + 1 == accelerate_until) { + if (planner.laser_inline.status.isPowered && planner.laser_inline.status.isEnabled) { + if (current_block->laser.trap_ramp_entry_incr > 0) { + current_block->laser.trap_ramp_active_pwr = current_block->laser.power; + cutter.apply_power(current_block->laser.power); + } } - #if ENABLED(LASER_POWER_INLINE_TRAPEZOID_CONT) - laser_trap.till_update = LASER_POWER_INLINE_TRAPEZOID_CONT_PER; - #else - laser_trap.last_step_count = step_events_completed; - #endif + // Not a powered move. + else cutter.apply_power(0); } - #endif - } + } + #endif } + + #if ENABLED(LASER_FEATURE) + /* + * CUTTER_MODE_DYNAMIC is experimental and developing. + * Super-fast method to dynamically adjust the laser power OCR value based on the input feedrate in mm-per-minute. + * TODO: Set up Min/Max OCR offsets to allow tuning and scaling of various lasers. + * TODO: Integrate accel/decel +-rate into the dynamic laser power calc. + */ + if (cutter.cutter_mode == CUTTER_MODE_DYNAMIC + && planner.laser_inline.status.isPowered // isPowered flag set on any parsed G1, G2, G3, or G5 move; cleared on any others. + && cutter.last_block_power != current_block->laser.power // Prevent constant update without change + ) { + cutter.apply_power(current_block->laser.power); + cutter.last_block_power = current_block->laser.power; + } + #endif + } + else { // !current_block + #if ENABLED(LASER_FEATURE) + if (cutter.cutter_mode == CUTTER_MODE_DYNAMIC) { + cutter.apply_power(0); // No movement in dynamic mode so turn Laser off + } + #endif } // If there is no current block at this point, attempt to pop one from the buffer @@ -2169,11 +2163,18 @@ uint32_t Stepper::block_phase_isr() { // Sync block? Sync the stepper counts or fan speeds and return while (current_block->is_sync()) { - if (current_block->is_fan_sync()) { - TERN_(LASER_SYNCHRONOUS_M106_M107, planner.sync_fan_speeds(current_block->fan_speed)); - } - else - _set_position(current_block->position); + #if ENABLED(LASER_POWER_SYNC) + if (cutter.cutter_mode == CUTTER_MODE_CONTINUOUS) { + if (current_block->is_pwr_sync()) { + planner.laser_inline.status.isSyncPower = true; + cutter.apply_power(current_block->laser.power); + } + } + #endif + + TERN_(LASER_SYNCHRONOUS_M106_M107, if (current_block->is_fan_sync()) planner.sync_fan_speeds(current_block->fan_speed)); + + if (!(current_block->is_fan_sync() || current_block->is_pwr_sync())) _set_position(current_block->position); discard_current_block(); @@ -2183,8 +2184,10 @@ uint32_t Stepper::block_phase_isr() { } // For non-inline cutter, grossly apply power - #if ENABLED(LASER_FEATURE) && DISABLED(LASER_POWER_INLINE) - cutter.apply_power(current_block->cutter_power); + #if HAS_CUTTER + if (cutter.cutter_mode == CUTTER_MODE_STANDARD) { + cutter.apply_power(current_block->cutter_power); + } #endif #if ENABLED(POWER_LOSS_RECOVERY) @@ -2357,36 +2360,22 @@ uint32_t Stepper::block_phase_isr() { set_directions(current_block->direction_bits); } - #if ENABLED(LASER_POWER_INLINE) - const power_status_t stat = current_block->laser.status; - #if ENABLED(LASER_POWER_INLINE_TRAPEZOID) - laser_trap.enabled = stat.isPlanned && stat.isEnabled; - laser_trap.cur_power = current_block->laser.power_entry; // RESET STATE - laser_trap.cruise_set = false; - #if DISABLED(LASER_POWER_INLINE_TRAPEZOID_CONT) - laser_trap.last_step_count = 0; - laser_trap.acc_step_count = current_block->laser.entry_per / 2; - #else - laser_trap.till_update = 0; - #endif - // Always have PWM in this case - if (stat.isPlanned) { // Planner controls the laser - cutter.ocr_set_power( - stat.isEnabled ? laser_trap.cur_power : 0 // ON with power or OFF - ); - } - #else - if (stat.isPlanned) { // Planner controls the laser - #if ENABLED(SPINDLE_LASER_USE_PWM) - cutter.ocr_set_power( - stat.isEnabled ? current_block->laser.power : 0 // ON with power or OFF - ); + #if ENABLED(LASER_FEATURE) + if (cutter.cutter_mode == CUTTER_MODE_CONTINUOUS) { // Planner controls the laser + if (planner.laser_inline.status.isSyncPower) + // If the previous block was a M3 sync power then skip the trap power init otherwise it will 0 the sync power. + planner.laser_inline.status.isSyncPower = false; // Clear the flag to process subsequent trap calc's. + else if (current_block->laser.status.isEnabled) { + #if ENABLED(LASER_POWER_TRAP) + TERN_(DEBUG_LASER_TRAP, SERIAL_ECHO_MSG("InitTrapPwr:",current_block->laser.trap_ramp_active_pwr)); + cutter.apply_power(current_block->laser.status.isPowered ? current_block->laser.trap_ramp_active_pwr : 0); #else - cutter.set_enabled(stat.isEnabled); + TERN_(DEBUG_CUTTER_POWER, SERIAL_ECHO_MSG("InlinePwr:",current_block->laser.power)); + cutter.apply_power(current_block->laser.status.isPowered ? current_block->laser.power : 0); #endif } - #endif - #endif // LASER_POWER_INLINE + } + #endif // LASER_FEATURE // If the endstop is already pressed, endstop interrupts won't invoke // endstop_triggered and the move will grind. So check here for a @@ -2416,21 +2405,6 @@ uint32_t Stepper::block_phase_isr() { // Calculate the initial timer interval interval = calc_timer_interval(current_block->initial_rate, &steps_per_isr); } - #if ENABLED(LASER_POWER_INLINE_CONTINUOUS) - else { // No new block found; so apply inline laser parameters - // This should mean ending file with 'M5 I' will stop the laser; thus the inline flag isn't needed - const power_status_t stat = planner.laser_inline.status; - if (stat.isPlanned) { // Planner controls the laser - #if ENABLED(SPINDLE_LASER_USE_PWM) - cutter.ocr_set_power( - stat.isEnabled ? planner.laser_inline.power : 0 // ON with power or OFF - ); - #else - cutter.set_enabled(stat.isEnabled); - #endif - } - } - #endif } // Return the interval to wait diff --git a/Marlin/src/module/stepper.h b/Marlin/src/module/stepper.h index c9a83caa7edb..787599ce3115 100644 --- a/Marlin/src/module/stepper.h +++ b/Marlin/src/module/stepper.h @@ -444,25 +444,6 @@ class Stepper { // Current stepper motor directions (+1 or -1) static xyze_int8_t count_direction; - #if ENABLED(LASER_POWER_INLINE_TRAPEZOID) - - typedef struct { - bool enabled; // Trapezoid needed flag (i.e., laser on, planner in control) - uint8_t cur_power; // Current laser power - bool cruise_set; // Power set up for cruising? - - #if ENABLED(LASER_POWER_INLINE_TRAPEZOID_CONT) - uint16_t till_update; // Countdown to the next update - #else - uint32_t last_step_count, // Step count from the last update - acc_step_count; // Bresenham counter for laser accel/decel - #endif - } stepper_laser_t; - - static stepper_laser_t laser_trap; - - #endif - public: // Initialize stepper hardware static void init(); diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 9bdc6eced71c..65b79d8bc464 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -1904,9 +1904,10 @@ void Temperature::task() { #if ENABLED(LASER_COOLANT_FLOW_METER) cooler.flowmeter_task(ms); #if ENABLED(FLOWMETER_SAFETY) - if (cutter.enabled() && cooler.check_flow_too_low()) { + if (cooler.check_flow_too_low()) { + TERN_(HAS_DISPLAY, if (cutter.enabled()) ui.flow_fault()); cutter.disable(); - TERN_(HAS_DISPLAY, ui.flow_fault()); + cutter.cutter_mode = CUTTER_MODE_ERROR; // Immediately kill stepper inline power output } #endif #endif diff --git a/buildroot/tests/mega2560 b/buildroot/tests/mega2560 index 6871ce4a0cef..969b3b14ccbc 100755 --- a/buildroot/tests/mega2560 +++ b/buildroot/tests/mega2560 @@ -189,7 +189,7 @@ opt_set MOTHERBOARD BOARD_RAMPS_14_EFB EXTRUDERS 0 LCD_LANGUAGE en TEMP_SENSOR_C AXIS_RELATIVE_MODES '{ false, false, false }' opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER SDSUPPORT EEPROM_SETTINGS EEPROM_BOOT_SILENT EEPROM_AUTO_INIT MEATPACK_ON_SERIAL_PORT_1 \ LASER_FEATURE LASER_SAFETY_TIMEOUT_MS LASER_COOLANT_FLOW_METER AIR_EVACUATION AIR_EVACUATION_PIN AIR_ASSIST AIR_ASSIST_PIN -exec_test $1 $2 "MEGA2560 RAMPS | Laser Feature | Air Evacuation | Air Assist | Cooler | Flowmeter | 12864 LCD | meatpack | SERIAL_PORT_2 " "$3" +exec_test $1 $2 "MEGA2560 RAMPS | Laser Feature | Air Evacuation | Air Assist | Cooler | Flowmeter | 12864 LCD | meatpack | Laser Safety Timeout | M3 Power Sync | Trap Power Smoothing | SERIAL_PORT_2 " "$3" # # Test Laser features with 44780 LCD @@ -203,7 +203,7 @@ opt_set MOTHERBOARD BOARD_RAMPS_14_EFB EXTRUDERS 0 LCD_LANGUAGE en TEMP_SENSOR_C AXIS_RELATIVE_MODES '{ false, false, false }' opt_enable REPRAP_DISCOUNT_SMART_CONTROLLER SDSUPPORT EEPROM_SETTINGS EEPROM_BOOT_SILENT EEPROM_AUTO_INIT PRINTCOUNTER I2C_AMMETER \ LASER_FEATURE LASER_SAFETY_TIMEOUT_MS LASER_COOLANT_FLOW_METER AIR_EVACUATION AIR_EVACUATION_PIN AIR_ASSIST AIR_ASSIST_PIN -exec_test $1 $2 "MEGA2560 RAMPS | Laser Feature | Air Evacuation | Air Assist | Cooler | Flowmeter | 44780 LCD " "$3" +exec_test $1 $2 "MEGA2560 RAMPS | Laser Feature | Air Evacuation | Air Assist | Cooler | Laser Safety Timeout | Flowmeter | 44780 LCD " "$3" # # Test redundant temperature sensors + MAX TC diff --git a/docs/Cutter.md b/docs/Cutter.md new file mode 100644 index 000000000000..c78b0551a0ac --- /dev/null +++ b/docs/Cutter.md @@ -0,0 +1,137 @@ +### Introduction + +With Marlin version 2.0.9.x or higher, Laser improvements were introduced that enhance inline functionality. Previously the inline feature option was not operational without enabling and recompiling the source. Also with inline enabled the base features are not functional. With v2.0.9.x new functionality is added which allows the standard and inline modes to be G-Code selectable and also compatible with each other. Additionally an experimental dynamic mode is also available. Spindle operational features are available with defines and recompiling. + +### Architecture + +Laser selectable feature capability is defined through 4 global mode flags within gcode ,laser/spindle, planner and stepper routines. The default mode maintains the standard laser function. G-Codes are received, processed and parsed to determine what mode to set through M3, M4 and M5 commands. When the inline mode parameter set is detected, laser power processing will be driven through the planner and stepper routines. Handling of the initial power values and settings are performed by G-Code parsing and the laser/spindle routines. + +Inline power feeds from the block->inline_power variable into the planner's laser.power when in continuous power mode. Further power adjustment will be applied if the laser power trap feature is active otherwise laser.power is used as set in the stepper for the entire block. When laser power trap is active the power levels are step incremented during acceleration and step decremented during deceleration. + +Two additional power sets are fed in the planner by features laser power sync and laser fan power sync. Both of these power sets are done with planner sync block bit flags. With laser power sync, when the bit flag is matched the global block laser.power value is updated from laser/spindle standard M3 S-Value power sets. For laser fan sync, power values are updated into the planner block->fan_speed[i] variable from fan G-Code S-Value sets. + +With dynamic inline power mode, F-Value feedrate sets are processed with cutter.calc_dynamic_power() and fed into the planner laser.power value. + +Irrespective of what laser power value source is used, the final laser output pin is always updated using the laser/spindle code. Specifically the apply_power(value) call is used to set the laser or spindle output. This call permits safe power control in the event that a sensor fault occurs. + +Note: Spindle operation is not selectable with G-Codes at this time. + +The following flow charts depict the flow control logic for spindle and laser operations in the code base. + +#### Spindle Mode Logic: + + ┌──────────┐ ┌───────────┐ ┌───────────┐ + │M3 S-Value│ │Dir !same ?│ │Stepper │ + │Spindle │ │stop & wait│ │processes │ + ┌──┤Clockwise ├──┤ & start ├──┤moves │ + ┌─────┐ │ │ │ │spindle │ │ │ + │GCode│ │ └──────────┘ └───────────┘ └───────────┘ + │Send ├──┤ ┌──────────┐ ┌───────────┐ ┌───────────┐ + └─────┘ │ │M4 S-Value│ │Dir !same ?│ │Stepper │ + ├──┤Spindle ├──┤stop & wait├──┤processes │ + │ │Counter │ │& start │ │moves │ + │ │Clockwise │ │spindle │ │ │ + │ └──────────┘ └───────────┘ └───────────┘ + │ ┌──────────┐ ┌────────┐ + │ │M5 │ │Wait for│ + │ │Spindle ├──┤move & │ + └──┤Stop │ │disable │ + └──────────┘ └────────┘ + ┌──────────┐ ┌──────────┐ + Sensors─────┤Fault ├──┤Disable │ + └──────────┘ │power │ + └──────────┘ + +#### Laser Mode Logic: + + ┌──────────┐ ┌─────────────┐ ┌───────────┐ + │M3,M4,M5 I│ │Set power │ │Stepper │ + ┌──┤Standard ├──┤Immediately &├──┤processes │ + │ │Default │ │wait for move│ │moves │ + │ │ │ │completion │ │ │ + │ └──────────┘ └─────────────┘ └───────────┘ + │ ┌──────────┐ ┌───────────┐ ┌───────────┐ ┌────────────┐ ┌────────────┐ ┌────────────┐ ┌───────────┐ + ┌─────┐ │ │M3 I │ │G0,G1,G2,G4│ │Planner │ │Planner │ │Planner fan │ │Planner │ │Stepper │ + │GCode│ │ │Continuous│ │M3 receive │ │sets block │ │sync power ?│ │sync power ?│ │trap power ?│ │uses block │ + │Send ├──┼──┤Inline ├──┤power from ├──┤power using├──┤process M3 ├──┤process fan ├──┤adjusts for ├──┤values to │ + └─────┘ │ │ │ │S-Value │ │Gx S-Value │ │power inline│ │power inline│ │accel/decel │ │apply power│ + │ └──────────┘ └───────────┘ └───────────┘ └────────────┘ └────────────┘ └────────────┘ └───────────┘ + │ ┌──────────┐ ┌───────────┐ ┌────────────────┐ ┌───────────┐ + │ │M4 I │ │Gx F-Value │ │Planner │ │Stepper │ + │ │Dynamic │ │set power │ │Calc & set block│ │uses block │ + └──┤Inline ├──┤or use ├──┤block power ├──┤values to │ + │ │ │default │ │using F-Value │ │apply power│ + └──────────┘ └───────────┘ └────────────────┘ └───────────┘ + ┌──────────┐ ┌──────────┐ + Sensors─────┤Fault ├──┤Disable │ + └──────────┘ │Power │ + └──────────┘ + + + +### Continuous Inline Trap Power Calculations + +When LASER_FEATURE and LASER_POWER_TRAP are defined, planner calculations are performed and applied to the incoming laser power S-Value. The power will be factored and distributed across trapezoid acceleration and deceleration movements. + +When the laser.power > 0 + +We set a minimum power if defined in SPEED_POWER_MIN it's fed into the planner block as laser_power_floor. + +A reduced entry laser power factor is based on the entry step rate to cruise step rate ratio for acceleration. + + block entry laser power = laser power * ( entry step rate / cruise step rate ) + +The initial power will be set to no less than the laser_power_floor or the inital power calculation. + +The reduced final power factor is based on the final step rate to cruise step rate ratio for deceleration. + + block exit laser power = laser power * ( exit step rate / cruise step rate ) + +Once the entry and exit power values are determined, the values are divided into step increments to be applied in the stepper. + + trap step power incr_decr = ( cruize power - entry_exit ) / accel_decel_steps + +The trap steps are incremented or decremented during each accel or decel step until the block is complete. +Step power is either cumulatively added or subtracted during trapeziod ramp progressions. + +#### Planner Code: + + ``` + if (block->laser.power > 0) { + NOLESS(block->laser.power, laser_power_floor); + block->laser.trap_ramp_active_pwr = (block->laser.power - laser_power_floor) * (initial_rate / float(block->nominal_rate)) + laser_power_floor; + block->laser.trap_ramp_entry_incr = (block->laser.power - block->laser.trap_ramp_active_pwr) / accelerate_steps; + float laser_pwr = block->laser.power * (final_rate / float(block->nominal_rate)); + NOLESS(laser_pwr, laser_power_floor); + block->laser.trap_ramp_exit_decr = (block->laser.power - laser_pwr) / decelerate_steps; + ``` + +#### Stepper Code: + + ``` + if (current_block->laser.trap_ramp_entry_incr > 0) { + cutter.apply_power(current_block->laser.trap_ramp_active_pwr); + current_block->laser.trap_ramp_active_pwr += current_block->laser.trap_ramp_entry_incr; + ``` + + ``` + if (current_block->laser.trap_ramp_exit_decr > 0) { + current_block->laser.trap_ramp_active_pwr -= current_block->laser.trap_ramp_exit_decr; + cutter.apply_power(current_block->laser.trap_ramp_active_pwr); + ``` + +### Dynamic Inline Calculations + +Dynamic mode will calculate laser power based on the F-Value feedrate. The method uses bit shifting to set a power level from 0 to 255. It's simple and fast and we can use a scaler to shift the laser power output to center on a given power level. + +#### Spindle/Laser Code: + +``` + // Dynamic mode rate calculation + static inline uint8_t calc_dynamic_power() { + if (feedrate_mm_m > 65535) return 255; // Too fast, go always on + uint16_t rate = uint16_t(feedrate_mm_m); // 16 bits from the G-code parser float input + rate >>= 8; // Take the G-code input e.g. F40000 and shift off the lower bits to get an OCR value from 1-255 + return uint8_t(rate); + } +``` From 893707711e2a507aa48e41c3c59a267f9aea238f Mon Sep 17 00:00:00 2001 From: Eduard Sukharev Date: Wed, 6 Jul 2022 16:30:47 +0300 Subject: [PATCH 08/32] =?UTF-8?q?=F0=9F=90=9B=20Fix=20MKS=20TinyBee=20comp?= =?UTF-8?q?ile=20(#24454)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/ESP32/HAL.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/HAL/ESP32/HAL.h b/Marlin/src/HAL/ESP32/HAL.h index 600ca8f5ee37..ddfedf92eed9 100644 --- a/Marlin/src/HAL/ESP32/HAL.h +++ b/Marlin/src/HAL/ESP32/HAL.h @@ -60,8 +60,8 @@ #endif #endif -#define CRITICAL_SECTION_START() portENTER_CRITICAL(&spinlock) -#define CRITICAL_SECTION_END() portEXIT_CRITICAL(&spinlock) +#define CRITICAL_SECTION_START() portENTER_CRITICAL(&hal.spinlock) +#define CRITICAL_SECTION_END() portEXIT_CRITICAL(&hal.spinlock) #define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment #define PWM_FREQUENCY 1000u // Default PWM frequency when set_pwm_duty() is called without set_pwm_frequency() From d3aed23e18bd9b165282ad83ef86422510af55c0 Mon Sep 17 00:00:00 2001 From: Bob Kuhn Date: Wed, 6 Jul 2022 08:35:08 -0500 Subject: [PATCH 09/32] =?UTF-8?q?=F0=9F=90=9B=20Fix=20Sensorless=20Probing?= =?UTF-8?q?=20compile=20(#24455)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/module/delta.cpp | 4 -- Marlin/src/module/delta.h | 4 -- Marlin/src/module/probe.cpp | 83 +++++++++++-------------------------- Marlin/src/module/probe.h | 12 +++--- 4 files changed, 30 insertions(+), 73 deletions(-) diff --git a/Marlin/src/module/delta.cpp b/Marlin/src/module/delta.cpp index 8207dacaf700..ce2a6f4adad0 100644 --- a/Marlin/src/module/delta.cpp +++ b/Marlin/src/module/delta.cpp @@ -60,10 +60,6 @@ xy_float_t delta_tower[ABC]; abc_float_t delta_diagonal_rod_2_tower; float delta_clip_start_height = Z_MAX_POS; abc_float_t delta_diagonal_rod_trim; -#if HAS_DELTA_SENSORLESS_PROBING - abc_float_t offset_sensorless_adj{0}; - float largest_sensorless_adj = 0; -#endif float delta_safe_distance_from_top(); diff --git a/Marlin/src/module/delta.h b/Marlin/src/module/delta.h index f7067ef9c713..0a0c6124eecf 100644 --- a/Marlin/src/module/delta.h +++ b/Marlin/src/module/delta.h @@ -38,10 +38,6 @@ extern xy_float_t delta_tower[ABC]; extern abc_float_t delta_diagonal_rod_2_tower; extern float delta_clip_start_height; extern abc_float_t delta_diagonal_rod_trim; -#if HAS_DELTA_SENSORLESS_PROBING - extern abc_float_t offset_sensorless_adj; - extern float largest_sensorless_adj; -#endif /** * Recalculate factors used for delta kinematics whenever diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 2649aa41b634..ed8d4a1429a7 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -48,6 +48,11 @@ #include "delta.h" #endif +#if ENABLED(SENSORLESS_PROBING) + abc_float_t offset_sensorless_adj{0}; + float largest_sensorless_adj = 0; +#endif + #if ANY(HAS_QUIET_PROBING, USE_SENSORLESS) #include "stepper/indirection.h" #if BOTH(HAS_QUIET_PROBING, PROBING_ESTEPPERS_OFF) @@ -867,76 +872,38 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai #endif // HAS_Z_SERVO_PROBE -#if USE_SENSORLESS - - sensorless_t stealth_states { false }; - - /** - * Disable stealthChop if used. Enable diag1 pin on driver. - */ - void Probe::enable_stallguard_diag1() { - #if ENABLED(SENSORLESS_PROBING) - #if HAS_DELTA_SENSORLESS_PROBING - stealth_states.x = tmc_enable_stallguard(stepperX); - stealth_states.y = tmc_enable_stallguard(stepperY); - #endif - stealth_states.z = tmc_enable_stallguard(stepperZ); - endstops.enable(true); - #endif - } - - /** - * Re-enable stealthChop if used. Disable diag1 pin on driver. - */ - void Probe::disable_stallguard_diag1() { - #if ENABLED(SENSORLESS_PROBING) - endstops.not_homing(); - #if HAS_DELTA_SENSORLESS_PROBING - tmc_disable_stallguard(stepperX, stealth_states.x); - tmc_disable_stallguard(stepperY, stealth_states.y); - #endif - tmc_disable_stallguard(stepperZ, stealth_states.z); - #endif - } +#if HAS_DELTA_SENSORLESS_PROBING /** * Set the sensorless Z offset */ void Probe::set_offset_sensorless_adj(const_float_t sz) { - #if ENABLED(SENSORLESS_PROBING) - DEBUG_SECTION(pso, "Probe::set_offset_sensorless_adj", true); - #if HAS_DELTA_SENSORLESS_PROBING - if (test_sensitivity.x) offset_sensorless_adj.a = sz; - if (test_sensitivity.y) offset_sensorless_adj.b = sz; - #endif - if (test_sensitivity.z) offset_sensorless_adj.c = sz; - #endif + DEBUG_SECTION(pso, "Probe::set_offset_sensorless_adj", true); + if (test_sensitivity.x) offset_sensorless_adj.a = sz; + if (test_sensitivity.y) offset_sensorless_adj.b = sz; + if (test_sensitivity.z) offset_sensorless_adj.c = sz; } /** * Refresh largest_sensorless_adj based on triggered endstops */ void Probe::refresh_largest_sensorless_adj() { - #if ENABLED(SENSORLESS_PROBING) - DEBUG_SECTION(rso, "Probe::refresh_largest_sensorless_adj", true); - largest_sensorless_adj = -3; // A reference away from any real probe height - #if HAS_DELTA_SENSORLESS_PROBING - if (TEST(endstops.state(), X_MAX)) { - NOLESS(largest_sensorless_adj, offset_sensorless_adj.a); - DEBUG_ECHOLNPGM("Endstop_X: ", largest_sensorless_adj, " TowerX"); - } - if (TEST(endstops.state(), Y_MAX)) { - NOLESS(largest_sensorless_adj, offset_sensorless_adj.b); - DEBUG_ECHOLNPGM("Endstop_Y: ", largest_sensorless_adj, " TowerY"); - } - #endif - if (TEST(endstops.state(), Z_MAX)) { - NOLESS(largest_sensorless_adj, offset_sensorless_adj.c); - DEBUG_ECHOLNPGM("Endstop_Z: ", largest_sensorless_adj, " TowerZ"); - } - #endif + DEBUG_SECTION(rso, "Probe::refresh_largest_sensorless_adj", true); + largest_sensorless_adj = -3; // A reference away from any real probe height + if (TEST(endstops.state(), X_MAX)) { + NOLESS(largest_sensorless_adj, offset_sensorless_adj.a); + DEBUG_ECHOLNPGM("Endstop_X: ", largest_sensorless_adj, " TowerX"); + } + if (TEST(endstops.state(), Y_MAX)) { + NOLESS(largest_sensorless_adj, offset_sensorless_adj.b); + DEBUG_ECHOLNPGM("Endstop_Y: ", largest_sensorless_adj, " TowerY"); + } + if (TEST(endstops.state(), Z_MAX)) { + NOLESS(largest_sensorless_adj, offset_sensorless_adj.c); + DEBUG_ECHOLNPGM("Endstop_Z: ", largest_sensorless_adj, " TowerZ"); + } } -#endif // SENSORLESS_PROBING || SENSORLESS_HOMING +#endif #endif // HAS_BED_PROBE diff --git a/Marlin/src/module/probe.h b/Marlin/src/module/probe.h index ca596e896977..1bcbc6564241 100644 --- a/Marlin/src/module/probe.h +++ b/Marlin/src/module/probe.h @@ -62,16 +62,16 @@ #endif #endif +#if ENABLED(SENSORLESS_PROBING) + extern abc_float_t offset_sensorless_adj; +#endif + class Probe { public: #if ENABLED(SENSORLESS_PROBING) typedef struct { - #if HAS_DELTA_SENSORLESS_PROBING bool x:1, y:1, z:1; - #else - bool z; - #endif } sense_bool_t; static sense_bool_t test_sensitivity; #endif @@ -302,9 +302,7 @@ class Probe { #endif // Basic functions for Sensorless Homing and Probing - #if USE_SENSORLESS - static void enable_stallguard_diag1(); - static void disable_stallguard_diag1(); + #if HAS_DELTA_SENSORLESS_PROBING static void set_offset_sensorless_adj(const_float_t sz); static void refresh_largest_sensorless_adj(); #endif From 03760fd79ea7f020f8739647f7a420bf4ec286b7 Mon Sep 17 00:00:00 2001 From: Christophe Huriaux Date: Wed, 6 Jul 2022 22:43:38 +0200 Subject: [PATCH 10/32] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20ST7565=20LCD=20contr?= =?UTF-8?q?ast=20init=20(#24457)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration.h | 6 ++++++ Marlin/src/inc/Conditionals_LCD.h | 5 ++++- Marlin/src/lcd/dogm/u8g_dev_st7565_64128n_HAL.cpp | 8 +++++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 15106a20a324..ce2b8fcd6f56 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -2631,6 +2631,12 @@ // //#define SILVER_GATE_GLCD_CONTROLLER +// +// eMotion Tech LCD with SD +// https://www.reprap-france.com/produit/1234568748-ecran-graphique-128-x-64-points-2-1 +// +//#define EMOTION_TECH_LCD + //============================================================================= //============================== OLED Displays ============================== //============================================================================= diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index e41bc0d48977..8d29b177dd56 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -99,7 +99,7 @@ #define IS_ULTIPANEL 1 #define STD_ENCODER_PULSES_PER_STEP 2 -#elif ANY(miniVIKI, VIKI2, WYH_L12864, ELB_FULL_GRAPHIC_CONTROLLER, AZSMZ_12864) +#elif ANY(miniVIKI, VIKI2, WYH_L12864, ELB_FULL_GRAPHIC_CONTROLLER, AZSMZ_12864, EMOTION_TECH_LCD) #define DOGLCD #define IS_DOGM_12864 1 @@ -116,6 +116,9 @@ #define IS_U8GLIB_LM6059_AF 1 #elif ENABLED(AZSMZ_12864) #define IS_U8GLIB_ST7565_64128N 1 + #elif ENABLED(EMOTION_TECH_LCD) + #define IS_U8GLIB_ST7565_64128N 1 + #define ST7565_VOLTAGE_DIVIDER_VALUE 0x07 #endif #elif ENABLED(OLED_PANEL_TINYBOY2) diff --git a/Marlin/src/lcd/dogm/u8g_dev_st7565_64128n_HAL.cpp b/Marlin/src/lcd/dogm/u8g_dev_st7565_64128n_HAL.cpp index bfd44d08dfbb..63e7b2e2b8b5 100644 --- a/Marlin/src/lcd/dogm/u8g_dev_st7565_64128n_HAL.cpp +++ b/Marlin/src/lcd/dogm/u8g_dev_st7565_64128n_HAL.cpp @@ -74,7 +74,6 @@ #define ST7565_ON(N) ((N) ? 0xAF : 0xAE) #define ST7565_OUT_MODE(N) ((N) ? 0xC8 : 0xC0) #define ST7565_POWER_CONTROL(N) (0x28 | (N)) -#define ST7565_V0_RATIO(N) (0x10 | ((N) & 0x7)) #define ST7565_V5_RATIO(N) (0x20 | ((N) & 0x7)) #define ST7565_CONTRAST(N) (0x81), (N) @@ -106,11 +105,14 @@ static const uint8_t u8g_dev_st7565_64128n_HAL_init_seq[] PROGMEM = { ST7565_POWER_CONTROL(0x7), // power control: turn on voltage follower U8G_ESC_DLY(50), // delay 50 ms - ST7565_V0_RATIO(0), // Set V0 voltage resistor ratio. Setting for controlling brightness of Displaytech 64128N + #ifdef ST7565_VOLTAGE_DIVIDER_VALUE + // Set V5 voltage resistor ratio. Affects brightness of Displaytech 64128N + ST7565_V5_RATIO(ST7565_VOLTAGE_DIVIDER_VALUE), + #endif ST7565_INVERTED(0), // display normal, bit val 0: LCD pixel off. - ST7565_CONTRAST(0x1E), // Contrast value. Setting for controlling brightness of Displaytech 64128N + ST7565_CONTRAST(0x1E), // Contrast value for Displaytech 64128N ST7565_ON(1), // display on From e93a1dd2fae37457894bf04b30e1c8ad5801b35c Mon Sep 17 00:00:00 2001 From: Meilleur Gars <98503100+LCh-77@users.noreply.github.com> Date: Wed, 6 Jul 2022 13:46:11 -0700 Subject: [PATCH 11/32] =?UTF-8?q?=F0=9F=9A=B8=20JyersUI=20updates=20(#2445?= =?UTF-8?q?1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/gcode/bedlevel/abl/G29.cpp | 2 + Marlin/src/gcode/config/M575.cpp | 9 +- Marlin/src/gcode/control/M997.cpp | 3 + Marlin/src/gcode/lcd/M0_M1.cpp | 4 + Marlin/src/gcode/probe/G30.cpp | 10 +- Marlin/src/gcode/stats/M75-M78.cpp | 16 +- Marlin/src/gcode/temp/M303.cpp | 3 + Marlin/src/inc/Conditionals_LCD.h | 9 +- Marlin/src/inc/Conditionals_post.h | 2 +- Marlin/src/inc/SanityCheck.h | 2 +- Marlin/src/lcd/e3v2/common/dwin_api.cpp | 10 +- Marlin/src/lcd/e3v2/jyersui/base64.hpp | 208 ++ Marlin/src/lcd/e3v2/jyersui/dwin.cpp | 3090 ++++++++++++----- Marlin/src/lcd/e3v2/jyersui/dwin.h | 230 +- Marlin/src/lcd/e3v2/jyersui/dwin_defines.h | 131 + Marlin/src/lcd/e3v2/jyersui/dwin_lcd.cpp | 33 +- Marlin/src/lcd/e3v2/jyersui/dwin_lcd.h | 8 + Marlin/src/lcd/e3v2/jyersui/dwinui.cpp | 340 ++ Marlin/src/lcd/e3v2/jyersui/dwinui.h | 527 +++ Marlin/src/lcd/e3v2/jyersui/endstop_diag.cpp | 111 + Marlin/src/lcd/e3v2/jyersui/endstop_diag.h | 39 + Marlin/src/lcd/e3v2/jyersui/gcode_preview.cpp | 244 ++ Marlin/src/lcd/e3v2/jyersui/gcode_preview.h | 34 + Marlin/src/lcd/e3v2/jyersui/lockscreen.cpp | 83 + Marlin/src/lcd/e3v2/jyersui/lockscreen.h | 49 + Marlin/src/lcd/e3v2/jyersui/plot.cpp | 86 + Marlin/src/lcd/e3v2/jyersui/plot.h | 41 + Marlin/src/lcd/e3v2/proui/base64.hpp | 6 +- Marlin/src/lcd/e3v2/proui/gcode_preview.cpp | 6 +- Marlin/src/lcd/e3v2/proui/gcode_preview.h | 2 +- Marlin/src/module/settings.cpp | 6 +- Marlin/src/module/temperature.cpp | 8 + 32 files changed, 4352 insertions(+), 1000 deletions(-) create mode 100644 Marlin/src/lcd/e3v2/jyersui/base64.hpp create mode 100644 Marlin/src/lcd/e3v2/jyersui/dwin_defines.h create mode 100644 Marlin/src/lcd/e3v2/jyersui/dwinui.cpp create mode 100644 Marlin/src/lcd/e3v2/jyersui/dwinui.h create mode 100644 Marlin/src/lcd/e3v2/jyersui/endstop_diag.cpp create mode 100644 Marlin/src/lcd/e3v2/jyersui/endstop_diag.h create mode 100644 Marlin/src/lcd/e3v2/jyersui/gcode_preview.cpp create mode 100644 Marlin/src/lcd/e3v2/jyersui/gcode_preview.h create mode 100644 Marlin/src/lcd/e3v2/jyersui/lockscreen.cpp create mode 100644 Marlin/src/lcd/e3v2/jyersui/lockscreen.h create mode 100644 Marlin/src/lcd/e3v2/jyersui/plot.cpp create mode 100644 Marlin/src/lcd/e3v2/jyersui/plot.h diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index a2c53b5ab253..e8c9c4a1857c 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -51,6 +51,8 @@ #include "../../../lcd/e3v2/creality/dwin.h" #elif ENABLED(DWIN_LCD_PROUI) #include "../../../lcd/e3v2/proui/dwin.h" +#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) + #include "../../../lcd/e3v2/jyersui/dwin.h" #endif #if HAS_MULTI_HOTEND diff --git a/Marlin/src/gcode/config/M575.cpp b/Marlin/src/gcode/config/M575.cpp index 2c12428d982a..f96bca8a3ee3 100644 --- a/Marlin/src/gcode/config/M575.cpp +++ b/Marlin/src/gcode/config/M575.cpp @@ -26,6 +26,10 @@ #include "../gcode.h" +#if ENABLED(DWIN_CREALITY_LCD_JYERSUI) + #include "../../lcd/e3v2/jyersui/dwin.h" +#endif + /** * M575 - Change serial baud rate * @@ -65,7 +69,10 @@ void GcodeSuite::M575() { SERIAL_FLUSH(); - if (set1) { MYSERIAL1.end(); MYSERIAL1.begin(baud); } + if (set1) { + MYSERIAL1.end(); MYSERIAL1.begin(baud); + TERN_(DWIN_CREALITY_LCD_JYERSUI, eeprom_settings.Baud115k = (baud == 115200)); + } #if HAS_MULTI_SERIAL if (set2) { MYSERIAL2.end(); MYSERIAL2.begin(baud); } #ifdef SERIAL_PORT_3 diff --git a/Marlin/src/gcode/control/M997.cpp b/Marlin/src/gcode/control/M997.cpp index 74ed8b0d073e..66a0256c44ef 100644 --- a/Marlin/src/gcode/control/M997.cpp +++ b/Marlin/src/gcode/control/M997.cpp @@ -26,6 +26,8 @@ #if ENABLED(DWIN_LCD_PROUI) #include "../../lcd/e3v2/proui/dwin.h" +#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) + #include "../../lcd/e3v2/jyersui/dwin.h" #endif /** @@ -34,6 +36,7 @@ void GcodeSuite::M997() { TERN_(DWIN_LCD_PROUI, DWIN_RebootScreen()); + TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWIN.DWIN_RebootScreen()); flashFirmware(parser.intval('S')); diff --git a/Marlin/src/gcode/lcd/M0_M1.cpp b/Marlin/src/gcode/lcd/M0_M1.cpp index af03fcb0b1a1..b6d2131555c6 100644 --- a/Marlin/src/gcode/lcd/M0_M1.cpp +++ b/Marlin/src/gcode/lcd/M0_M1.cpp @@ -38,6 +38,8 @@ #elif ENABLED(DWIN_LCD_PROUI) #include "../../lcd/e3v2/proui/dwin_popup.h" #include "../../lcd/e3v2/proui/dwin.h" +#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) + #include "../../lcd/e3v2/jyersui/dwin.h" #endif #if ENABLED(HOST_PROMPT_SUPPORT) @@ -76,6 +78,8 @@ void GcodeSuite::M0_M1() { DWIN_Popup_Confirm(ICON_BLTouch, parser.string_arg, GET_TEXT_F(MSG_USERWAIT)); else DWIN_Popup_Confirm(ICON_BLTouch, GET_TEXT_F(MSG_STOPPED), GET_TEXT_F(MSG_USERWAIT)); + #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) + CrealityDWIN.Confirm_Handler(UserInput, parser.string_arg == nullptr); #else if (parser.string_arg) { diff --git a/Marlin/src/gcode/probe/G30.cpp b/Marlin/src/gcode/probe/G30.cpp index a16853bdf894..b22ec6eb7f7f 100644 --- a/Marlin/src/gcode/probe/G30.cpp +++ b/Marlin/src/gcode/probe/G30.cpp @@ -33,7 +33,7 @@ #include "../../feature/probe_temp_comp.h" #endif -#if ENABLED(DWIN_LCD_PROUI) +#if EITHER(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) #include "../../lcd/marlinui.h" #endif @@ -53,7 +53,7 @@ void GcodeSuite::G30() { parser.linearval('Y', current_position.y + probe.offset_xy.y) }; if (!probe.can_reach(pos)) { - #if ENABLED(DWIN_LCD_PROUI) + #if EITHER(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) SERIAL_ECHOLNF(GET_EN_TEXT_F(MSG_ZPROBE_OUT)); LCD_MESSAGE(MSG_ZPROBE_OUT); #endif @@ -65,7 +65,9 @@ void GcodeSuite::G30() { remember_feedrate_scaling_off(); - TERN_(DWIN_LCD_PROUI, process_subcommands_now(F("G28O"))); + #if EITHER(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) + process_subcommands_now(F("G28O")); + #endif const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE; @@ -74,7 +76,7 @@ void GcodeSuite::G30() { TERN_(HAS_PTC, ptc.set_enabled(true)); if (!isnan(measured_z)) { SERIAL_ECHOLNPGM("Bed X: ", pos.x, " Y: ", pos.y, " Z: ", measured_z); - #if ENABLED(DWIN_LCD_PROUI) + #if EITHER(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) char msg[31], str_1[6], str_2[6], str_3[6]; sprintf_P(msg, PSTR("X:%s, Y:%s, Z:%s"), dtostrf(pos.x, 1, 1, str_1), diff --git a/Marlin/src/gcode/stats/M75-M78.cpp b/Marlin/src/gcode/stats/M75-M78.cpp index 0ed1e6693013..13a593bc30f1 100644 --- a/Marlin/src/gcode/stats/M75-M78.cpp +++ b/Marlin/src/gcode/stats/M75-M78.cpp @@ -33,15 +33,23 @@ #include "../../lcd/e3v2/proui/dwin.h" #endif +#if ENABLED(DWIN_CREALITY_LCD_JYERSUI) + #include "../../lcd/e3v2/jyersui/dwin.h" +#endif + /** * M75: Start print timer */ void GcodeSuite::M75() { startOrResumeJob(); - #if ENABLED(DWIN_LCD_PROUI) - 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 + TERN_(DWIN_LCD_PROUI, DWIN_Print_Started(false)); + if (!IS_SD_PRINTING()) { + #if ENABLED(DWIN_LCD_PROUI) + DWIN_Print_Header(parser.string_arg && parser.string_arg[0] ? parser.string_arg : GET_TEXT(MSG_HOST_START_PRINT)); + #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) + CrealityDWIN.Update_Print_Filename(parser.string_arg && parser.string_arg[0] ? parser.string_arg : GET_TEXT(MSG_HOST_START_PRINT)); + #endif + } } /** diff --git a/Marlin/src/gcode/temp/M303.cpp b/Marlin/src/gcode/temp/M303.cpp index ce362984a6ca..2bd05f75373c 100644 --- a/Marlin/src/gcode/temp/M303.cpp +++ b/Marlin/src/gcode/temp/M303.cpp @@ -32,6 +32,8 @@ #include "../../lcd/extui/ui_api.h" #elif ENABLED(DWIN_LCD_PROUI) #include "../../lcd/e3v2/proui/dwin.h" +#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) + #include "../../lcd/e3v2/jyersui/dwin.h" #endif /** @@ -75,6 +77,7 @@ void GcodeSuite::M303() { SERIAL_ECHOLNPGM(STR_PID_BAD_HEATER_ID); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_BAD_EXTRUDER_NUM)); TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_BAD_EXTRUDER_NUM)); + TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWINClass::DWIN_PidTuning(PID_BAD_EXTRUDER_NUM)); return; } diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 8d29b177dd56..bf8d5e122a5e 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -1256,6 +1256,8 @@ #endif #if ANY(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_3POINT) #define HAS_ABL_NOT_UBL 1 +#else + #undef PROBE_MANUALLY #endif #if ANY(AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_UBL, MESH_BED_LEVELING) #define HAS_MESH 1 @@ -1274,14 +1276,11 @@ #if DISABLED(AUTO_BED_LEVELING_UBL) #define PLANNER_LEVELING 1 #endif -#endif -#if !HAS_LEVELING +#else #undef RESTORE_LEVELING_AFTER_G28 #undef ENABLE_LEVELING_AFTER_G28 #undef G29_RETRY_AND_RECOVER -#endif -#if !HAS_LEVELING || EITHER(MESH_BED_LEVELING, AUTO_BED_LEVELING_UBL) - #undef PROBE_MANUALLY + #undef PREHEAT_BEFORE_LEVELING #endif #if ANY(HAS_BED_PROBE, PROBE_MANUALLY, MESH_BED_LEVELING) #define PROBE_SELECTED 1 diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 9edcd6f1aa9a..0f4cf1381a7f 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -3541,7 +3541,7 @@ #ifndef MESH_MAX_Y #define MESH_MAX_Y _MESH_MAX_Y #endif -#else +#elif DISABLED(DWIN_CREALITY_LCD_JYERSUI) #undef MESH_MIN_X #undef MESH_MIN_Y #undef MESH_MAX_X diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index a967f0109457..8ef8a3d2d64a 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -3671,7 +3671,7 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #error "A very large BLOCK_BUFFER_SIZE is not needed and takes longer to drain the buffer on pause / cancel." #endif -#if ENABLED(LED_CONTROL_MENU) && NONE(HAS_MARLINUI_MENU, DWIN_LCD_PROUI) +#if ENABLED(LED_CONTROL_MENU) && NONE(HAS_MARLINUI_MENU, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) #error "LED_CONTROL_MENU requires an LCD controller that implements the menu." #endif diff --git a/Marlin/src/lcd/e3v2/common/dwin_api.cpp b/Marlin/src/lcd/e3v2/common/dwin_api.cpp index 3f699465a9c8..79998219a95e 100644 --- a/Marlin/src/lcd/e3v2/common/dwin_api.cpp +++ b/Marlin/src/lcd/e3v2/common/dwin_api.cpp @@ -234,7 +234,7 @@ void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis, // *string: The string // rlimit: To limit the drawn string length void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const char * const string, uint16_t rlimit/*=0xFFFF*/) { - #if DISABLED(DWIN_LCD_PROUI) + #if NONE(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) DWIN_Draw_Rectangle(1, bColor, x, y, x + (fontWidth(size) * strlen_P(string)), y + fontHeight(size)); #endif constexpr uint8_t widthAdjust = 0; @@ -266,7 +266,9 @@ void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, uint32_t value) { size_t i = 0; - DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * iNum + 1, y + fontHeight(size)); + #if DISABLED(DWIN_CREALITY_LCD_JYERSUI) + DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * iNum + 1, y + fontHeight(size)); + #endif DWIN_Byte(i, 0x14); // Bit 7: bshow // Bit 6: 1 = signed; 0 = unsigned number; @@ -314,7 +316,9 @@ void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_ uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, int32_t value) { //uint8_t *fvalue = (uint8_t*)&value; size_t i = 0; - DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * (iNum+fNum+1), y + fontHeight(size)); + #if DISABLED(DWIN_CREALITY_LCD_JYERSUI) + DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * (iNum+fNum+1), y + fontHeight(size)); + #endif DWIN_Byte(i, 0x14); DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size); DWIN_Word(i, color); diff --git a/Marlin/src/lcd/e3v2/jyersui/base64.hpp b/Marlin/src/lcd/e3v2/jyersui/base64.hpp new file mode 100644 index 000000000000..7a933df321b8 --- /dev/null +++ b/Marlin/src/lcd/e3v2/jyersui/base64.hpp @@ -0,0 +1,208 @@ +/** + * Base64 encoder/decoder for arduino repo + * Uses common web conventions - '+' for 62, '/' for 63, '=' for padding. + * Note that invalid base64 characters are interpreted as padding. + * Author: Densaugeo + * Maintainer: Densaugeo + * Version: 1.2.1.1 + * Changed unsigned int to uint16_t for use in the professional Ender 3V2/S1 firmware + * Url: https://www.arduino.cc/reference/en/libraries/base64/ + */ + +#ifndef BASE64_H_INCLUDED +#define BASE64_H_INCLUDED + +/* binary_to_base64: + * Description: + * Converts a single byte from a binary value to the corresponding base64 character + * Parameters: + * v - Byte to convert + * Returns: + * ascii code of base64 character. If byte is >= 64, then there is not corresponding base64 character + * and 255 is returned + */ +unsigned char binary_to_base64(unsigned char v); + +/* base64_to_binary: + * Description: + * Converts a single byte from a base64 character to the corresponding binary value + * Parameters: + * c - Base64 character (as ascii code) + * Returns: + * 6-bit binary value + */ +unsigned char base64_to_binary(unsigned char c); + +/* encode_base64_length: + * Description: + * Calculates length of base64 string needed for a given number of binary bytes + * Parameters: + * input_length - Amount of binary data in bytes + * Returns: + * Number of base64 characters needed to encode input_length bytes of binary data + */ +uint16_t encode_base64_length(uint16_t input_length); + +/* decode_base64_length: + * Description: + * Calculates number of bytes of binary data in a base64 string + * Variant that does not use input_length no longer used within library, retained for API compatibility + * Parameters: + * input - Base64-encoded null-terminated string + * input_length (optional) - Number of bytes to read from input pointer + * Returns: + * Number of bytes of binary data in input + */ +uint16_t decode_base64_length(unsigned char input[]); +uint16_t decode_base64_length(unsigned char input[], uint16_t input_length); + +/* encode_base64: + * Description: + * Converts an array of bytes to a base64 null-terminated string + * Parameters: + * input - Pointer to input data + * input_length - Number of bytes to read from input pointer + * output - Pointer to output string. Null terminator will be added automatically + * Returns: + * Length of encoded string in bytes (not including null terminator) + */ +uint16_t encode_base64(unsigned char input[], uint16_t input_length, unsigned char output[]); + +/* decode_base64: + * Description: + * Converts a base64 null-terminated string to an array of bytes + * Parameters: + * input - Pointer to input string + * input_length (optional) - Number of bytes to read from input pointer + * output - Pointer to output array + * Returns: + * Number of bytes in the decoded binary + */ +uint16_t decode_base64(unsigned char input[], unsigned char output[]); +uint16_t decode_base64(unsigned char input[], uint16_t input_length, unsigned char output[]); + +unsigned char binary_to_base64(unsigned char v) { + // Capital letters - 'A' is ascii 65 and base64 0 + if (v < 26) return v + 'A'; + + // Lowercase letters - 'a' is ascii 97 and base64 26 + if (v < 52) return v + 71; + + // Digits - '0' is ascii 48 and base64 52 + if (v < 62) return v - 4; + + // '+' is ascii 43 and base64 62 + if (v == 62) return '+'; + + // '/' is ascii 47 and base64 63 + if (v == 63) return '/'; + + return 64; +} + +unsigned char base64_to_binary(unsigned char c) { + // Capital letters - 'A' is ascii 65 and base64 0 + if ('A' <= c && c <= 'Z') return c - 'A'; + + // Lowercase letters - 'a' is ascii 97 and base64 26 + if ('a' <= c && c <= 'z') return c - 71; + + // Digits - '0' is ascii 48 and base64 52 + if ('0' <= c && c <= '9') return c + 4; + + // '+' is ascii 43 and base64 62 + if (c == '+') return 62; + + // '/' is ascii 47 and base64 63 + if (c == '/') return 63; + + return 255; +} + +uint16_t encode_base64_length(uint16_t input_length) { + return (input_length + 2)/3*4; +} + +uint16_t decode_base64_length(unsigned char input[]) { + return decode_base64_length(input, -1); +} + +uint16_t decode_base64_length(unsigned char input[], uint16_t input_length) { + unsigned char *start = input; + + while (base64_to_binary(input[0]) < 64 && (unsigned char)(input - start) < input_length) { + ++input; + } + + input_length = input - start; + return input_length/4*3 + (input_length % 4 ? input_length % 4 - 1 : 0); +} + +uint16_t encode_base64(unsigned char input[], uint16_t input_length, unsigned char output[]) { + uint16_t full_sets = input_length/3; + + // While there are still full sets of 24 bits... + for (uint16_t i = 0; i < full_sets; ++i) { + output[0] = binary_to_base64( input[0] >> 2); + output[1] = binary_to_base64((input[0] & 0x03) << 4 | input[1] >> 4); + output[2] = binary_to_base64((input[1] & 0x0F) << 2 | input[2] >> 6); + output[3] = binary_to_base64( input[2] & 0x3F); + + input += 3; + output += 4; + } + + switch (input_length % 3) { + case 0: + output[0] = '\0'; + break; + case 1: + output[0] = binary_to_base64( input[0] >> 2); + output[1] = binary_to_base64((input[0] & 0x03) << 4); + output[2] = '='; + output[3] = '='; + output[4] = '\0'; + break; + case 2: + output[0] = binary_to_base64( input[0] >> 2); + output[1] = binary_to_base64((input[0] & 0x03) << 4 | input[1] >> 4); + output[2] = binary_to_base64((input[1] & 0x0F) << 2); + output[3] = '='; + output[4] = '\0'; + break; + } + + return encode_base64_length(input_length); +} + +uint16_t decode_base64(unsigned char input[], unsigned char output[]) { + return decode_base64(input, -1, output); +} + +uint16_t decode_base64(unsigned char input[], uint16_t input_length, unsigned char output[]) { + uint16_t output_length = decode_base64_length(input, input_length); + + // While there are still full sets of 24 bits... + for (uint16_t i = 2; i < output_length; i += 3) { + output[0] = base64_to_binary(input[0]) << 2 | base64_to_binary(input[1]) >> 4; + output[1] = base64_to_binary(input[1]) << 4 | base64_to_binary(input[2]) >> 2; + output[2] = base64_to_binary(input[2]) << 6 | base64_to_binary(input[3]); + + input += 4; + output += 3; + } + + switch (output_length % 3) { + case 1: + output[0] = base64_to_binary(input[0]) << 2 | base64_to_binary(input[1]) >> 4; + break; + case 2: + output[0] = base64_to_binary(input[0]) << 2 | base64_to_binary(input[1]) >> 4; + output[1] = base64_to_binary(input[1]) << 4 | base64_to_binary(input[2]) >> 2; + break; + } + + return output_length; +} + +#endif // BASE64_H_INCLUDED diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp index 285013d7504e..e62bb04a43a2 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp @@ -22,23 +22,30 @@ /** * lcd/e3v2/jyersui/dwin.cpp + * JYERSUI Author: Jacob Myers + * + * JYERSUI Enhanced by LCH-77 + * Version: 1.9 + * Date: Jun 16, 2022 */ #include "../../../inc/MarlinConfigPre.h" #if ENABLED(DWIN_CREALITY_LCD_JYERSUI) +#include "dwin_defines.h" #include "dwin.h" +#include "dwinui.h" #include "../../marlinui.h" #include "../../../MarlinCore.h" - #include "../../../gcode/gcode.h" #include "../../../module/temperature.h" #include "../../../module/planner.h" #include "../../../module/settings.h" #include "../../../libs/buzzer.h" #include "../../../inc/Conditionals_post.h" +#include "../common/encoder.h" //#define DEBUG_OUT 1 #include "../../../core/debug_out.h" @@ -67,6 +74,10 @@ #include "../../../feature/bedlevel/bedlevel.h" #endif +#ifdef BLTOUCH_HS_MODE + #include "../../../feature/bltouch.h" +#endif + #if ENABLED(AUTO_BED_LEVELING_UBL) #include "../../../libs/least_squares_fit.h" #include "../../../libs/vector_3.h" @@ -80,21 +91,40 @@ #include "../../../feature/powerloss.h" #endif -#define MACHINE_SIZE STRINGIFY(X_BED_SIZE) "x" STRINGIFY(Y_BED_SIZE) "x" STRINGIFY(Z_MAX_POS) +#if HAS_ESDIAG + #include "endstop_diag.h" +#endif + +#if HAS_LOCKSCREEN + #include "lockscreen.h" +#endif -#define DWIN_FONT_MENU font8x16 -#define DWIN_FONT_STAT font10x20 -#define DWIN_FONT_HEAD font10x20 +#if ENABLED(CASE_LIGHT_MENU) + #include "../../../feature/caselight.h" +#endif + +#if ENABLED(LED_CONTROL_MENU) + #include "../../../feature/leds/leds.h" +#endif + +#if HAS_PIDPLOT + #include "plot.h" +#endif +#if HAS_GCODE_PREVIEW + #include "gcode_preview.h" +#endif + +#define MACHINE_SIZE STRINGIFY(X_BED_SIZE) "x" STRINGIFY(Y_BED_SIZE) "x" STRINGIFY(Z_MAX_POS) -#define MENU_CHAR_LIMIT 24 -#define STATUS_Y 352 +#define MENU_CHAR_LIMIT 24 +#define STATUS_CHAR_LIMIT 30 -#define MAX_PRINT_SPEED 500 -#define MIN_PRINT_SPEED 10 +#define MAX_PRINT_SPEED 500 +#define MIN_PRINT_SPEED 10 #if HAS_FAN - #define MAX_FAN_SPEED 255 - #define MIN_FAN_SPEED 0 + #define MAX_FAN_SPEED 255 + #define MIN_FAN_SPEED 0 #endif #define MAX_XY_OFFSET 100 @@ -109,16 +139,21 @@ #endif #if HAS_HOTEND - #define MAX_FLOW_RATE 200 - #define MIN_FLOW_RATE 10 + #define MAX_FLOW_RATE 200 + #define MIN_FLOW_RATE 10 - #define MAX_E_TEMP (HEATER_0_MAXTEMP - HOTEND_OVERSHOOT) - #define MIN_E_TEMP 0 + #define MAX_E_TEMP (HEATER_0_MAXTEMP - HOTEND_OVERSHOOT) + #define MIN_E_TEMP 0 #endif #if HAS_HEATED_BED - #define MAX_BED_TEMP BED_MAXTEMP - #define MIN_BED_TEMP 0 + #define MAX_BED_TEMP BED_MAXTEMP + #define MIN_BED_TEMP 0 +#endif + +#if HAS_JUNCTION_DEVIATION + #define MIN_JD_MM 0.01 + #define MAX_JD_MM 0.3 #endif /** @@ -141,19 +176,11 @@ #endif #endif -constexpr uint16_t TROWS = 6, MROWS = TROWS - 1, - TITLE_HEIGHT = 30, - MLINE = 53, - LBLX = 60, - MENU_CHR_W = 8, MENU_CHR_H = 16, STAT_CHR_W = 10; - -#define MBASE(L) (49 + MLINE * (L)) - -constexpr float default_max_feedrate[] = DEFAULT_MAX_FEEDRATE; -constexpr float default_max_acceleration[] = DEFAULT_MAX_ACCELERATION; -constexpr float default_steps[] = DEFAULT_AXIS_STEPS_PER_UNIT; +constexpr float default_max_feedrate[] = DEFAULT_MAX_FEEDRATE; +constexpr float default_max_acceleration[] = DEFAULT_MAX_ACCELERATION; +constexpr float default_steps[] = DEFAULT_AXIS_STEPS_PER_UNIT; #if HAS_CLASSIC_JERK - constexpr float default_max_jerk[] = { DEFAULT_XJERK, DEFAULT_YJERK, DEFAULT_ZJERK, DEFAULT_EJERK }; + constexpr float default_max_jerk[] = { DEFAULT_XJERK, DEFAULT_YJERK, DEFAULT_ZJERK, DEFAULT_EJERK }; #endif enum SelectItem : uint8_t { @@ -169,8 +196,10 @@ enum SelectItem : uint8_t { PRINT_COUNT }; +eeprom_settings_t eeprom_settings = {0}; +temp_val_t temp_val = {0}; uint8_t active_menu = MainMenu, last_menu = MainMenu; -uint8_t selection = 0, last_selection = 0; +uint8_t selection = 0, last_selection = 0, last_pos_selection = 0; uint8_t scrollpos = 0; uint8_t process = Main, last_process = Main; PopupID popup, last_popup; @@ -183,24 +212,22 @@ float valuemax; uint8_t valueunit; uint8_t valuetype; -char cmd[MAX_CMD_SIZE+16], str_1[16], str_2[16], str_3[16]; +char cmd[MAX_CMD_SIZE + 16], str_1[16], str_2[16], str_3[16]; char statusmsg[64]; char filename[LONG_FILENAME_LENGTH]; -bool printing = false; -bool paused = false; -bool sdprint = false; -int16_t pausetemp, pausebed, pausefan; - -bool livemove = false; -bool liveadjust = false; -uint8_t preheatmode = 0; -float zoffsetvalue = 0; -uint8_t gridpoint; -float corner_avg; -float corner_pos; - -bool probe_deployed = false; +#if HAS_HOSTACTION_MENUS + #define KEY_WIDTH 26 + #define KEY_HEIGHT 30 + #define KEY_INSET 5 + #define KEY_PADDING 3 + #define KEY_Y_START DWIN_HEIGHT - (4 * (KEY_HEIGHT) + 2 * (KEY_INSET + 1)) + + bool keyboard_restrict, reset_keyboard, numeric_keyboard = false; + uint8_t maxstringlen; + char *stringpointer = nullptr; + char action1[9], action2[9], action3[9]; +#endif CrealityDWINClass CrealityDWIN; @@ -215,6 +242,7 @@ CrealityDWINClass CrealityDWIN; uint8_t mesh_y = 0; #if ENABLED(AUTO_BED_LEVELING_UBL) + uint8_t tilt_grid = 1; void manual_value_update(bool undefined=false) { @@ -330,13 +358,13 @@ CrealityDWINClass CrealityDWIN; const float v_max = abs(get_max_value()), v_min = abs(get_min_value()), range = _MAX(v_min, v_max); // Clear background from previous selection and select new square - DWIN_Draw_Rectangle(1, Color_Bg_Black, _MAX(0, padding_x - gridline_width), _MAX(0, padding_y_top - gridline_width), padding_x + total_width_px, padding_y_top + total_width_px); + DWIN_Draw_Rectangle(1, Def_Background_Color, _MAX(0, padding_x - gridline_width), _MAX(0, padding_y_top - gridline_width), padding_x + total_width_px, padding_y_top + total_width_px); if (selected >= 0) { const auto selected_y = selected / (GRID_MAX_POINTS_X); const auto selected_x = selected - (GRID_MAX_POINTS_X) * selected_y; const auto start_y_px = padding_y_top + selected_y * cell_height_px; const auto start_x_px = padding_x + selected_x * cell_width_px; - DWIN_Draw_Rectangle(1, Color_White, _MAX(0, start_x_px - gridline_width), _MAX(0, start_y_px - gridline_width), start_x_px + cell_width_px, start_y_px + cell_height_px); + DWIN_Draw_Rectangle(1, Def_Highlight_Color, _MAX(0, start_x_px - gridline_width), _MAX(0, start_y_px - gridline_width), start_x_px + cell_width_px, start_y_px + cell_height_px); } // Draw value square grid @@ -362,7 +390,7 @@ CrealityDWINClass CrealityDWIN; if (viewer_print_value) { int8_t offset_x, offset_y = cell_height_px / 2 - 6; if (isnan(bedlevel.z_values[x][y])) { // undefined - DWIN_Draw_String(false, font6x12, Color_White, Color_Bg_Blue, start_x_px + cell_width_px / 2 - 5, start_y_px + offset_y, F("X")); + DWINUI::Draw_String(font6x12, Def_Text_Color, Color_Bg_Blue, start_x_px + cell_width_px / 2 - 5, start_y_px + offset_y, F("X")); } else { // has value if (GRID_MAX_POINTS_X < 10) @@ -371,8 +399,8 @@ CrealityDWINClass CrealityDWIN; sprintf_P(buf, PSTR("%02i"), (uint16_t)(abs(bedlevel.z_values[x][y] - (int16_t)bedlevel.z_values[x][y]) * 100)); offset_x = cell_width_px / 2 - 3 * (strlen(buf)) - 2; if (!(GRID_MAX_POINTS_X < 10)) - DWIN_Draw_String(false, font6x12, Color_White, Color_Bg_Blue, start_x_px - 2 + offset_x, start_y_px + offset_y /*+ square / 2 - 6*/, F(".")); - DWIN_Draw_String(false, font6x12, Color_White, Color_Bg_Blue, start_x_px + 1 + offset_x, start_y_px + offset_y /*+ square / 2 - 6*/, buf); + DWINUI::Draw_String(font6x12, Def_Text_Color, Color_Bg_Blue, start_x_px - 2 + offset_x, start_y_px + offset_y /*+ square / 2 - 6*/, F(".")); + DWINUI::Draw_String(font6x12, Def_Text_Color, Color_Bg_Blue, start_x_px + 1 + offset_x, start_y_px + offset_y /*+ square / 2 - 6*/, buf); } safe_delay(10); LCD_SERIAL.flushTX(); @@ -405,10 +433,12 @@ CrealityDWINClass CrealityDWIN; #endif // HAS_MESH /* General Display Functions */ - -struct CrealityDWINClass::EEPROM_Settings CrealityDWINClass::eeprom_settings{0}; constexpr const char * const CrealityDWINClass::color_names[11]; constexpr const char * const CrealityDWINClass::preheat_modes[3]; +constexpr const char * const CrealityDWINClass::zoffset_modes[3]; +#if ENABLED(PREHEAT_BEFORE_LEVELING) + constexpr const char * const CrealityDWINClass::preheat_levmodes[4]; +#endif // Clear a part of the screen // 4=Entire screen @@ -416,98 +446,119 @@ constexpr const char * const CrealityDWINClass::preheat_modes[3]; // 2=Menu area // 1=Title bar void CrealityDWINClass::Clear_Screen(uint8_t e/*=3*/) { - if (e == 1 || e == 3 || e == 4) DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.menu_top_bg, Color_Bg_Blue, false), 0, 0, DWIN_WIDTH, TITLE_HEIGHT); // Clear Title Bar - if (e == 2 || e == 3) DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, 31, DWIN_WIDTH, STATUS_Y); // Clear Menu Area - if (e == 4) DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, 31, DWIN_WIDTH, DWIN_HEIGHT); // Clear Popup Area + if (e == 1 || e == 3 || e == 4) DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.menu_top_bg, Def_TitleBg_color, false), 0, 0, DWIN_WIDTH, TITLE_HEIGHT); // Clear Title Bar + if (e == 2 || e == 3) DWIN_Draw_Rectangle(1, Def_Background_Color, 0, 31, DWIN_WIDTH, STATUS_Y); // Clear Menu Area + if (e == 4) DWIN_Draw_Rectangle(1, Def_Background_Color, 0, 31, DWIN_WIDTH, DWIN_HEIGHT); // Clear Popup Area } void CrealityDWINClass::Draw_Float(float value, uint8_t row, bool selected/*=false*/, uint8_t minunit/*=10*/) { const uint8_t digits = (uint8_t)floor(log10(abs(value))) + log10(minunit) + (minunit > 1); - const uint16_t bColor = (selected) ? Select_Color : Color_Bg_Black; + const uint16_t bColor = (selected) ? Def_Selected_Color : Def_Background_Color; const uint16_t xpos = 240 - (digits * 8); - DWIN_Draw_Rectangle(1, Color_Bg_Black, 194, MBASE(row), 234 - (digits * 8), MBASE(row) + 16); + DWIN_Draw_Rectangle(1, Def_Background_Color, 194, MBASE(row), 234 - (digits * 8), MBASE(row) + 16); if (isnan(value)) - DWIN_Draw_String(true, DWIN_FONT_MENU, Color_White, bColor, xpos - 8, MBASE(row), F(" NaN")); + DWINUI::Draw_String(Def_Text_Color, bColor, xpos - 8, MBASE(row), F(" NaN")); else { - DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, Color_White, bColor, digits - log10(minunit) + 1, log10(minunit), xpos, MBASE(row), (value < 0 ? -value : value)); - DWIN_Draw_String(true, DWIN_FONT_MENU, Color_White, bColor, xpos - 8, MBASE(row), value < 0 ? F("-") : F(" ")); + DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, Def_Text_Color, bColor, digits - log10(minunit) + 1, log10(minunit), xpos, MBASE(row), (value < 0 ? -value : value)); + DWINUI::Draw_String(Def_Text_Color, bColor, xpos - 8, MBASE(row), value < 0 ? F("-") : F(" ")); } } void CrealityDWINClass::Draw_Option(uint8_t value, const char * const * options, uint8_t row, bool selected/*=false*/, bool color/*=false*/) { - uint16_t bColor = (selected) ? Select_Color : Color_Bg_Black, - tColor = (color) ? GetColor(value, Color_White, false) : Color_White; + uint16_t bColor = (selected) ? Def_Selected_Color : Def_Background_Color, + tColor = (color) ? GetColor(value, Def_Text_Color, false) : Def_Text_Color; DWIN_Draw_Rectangle(1, bColor, 202, MBASE(row) + 14, 258, MBASE(row) - 2); - DWIN_Draw_String(false, DWIN_FONT_MENU, tColor, bColor, 202, MBASE(row) - 1, options[value]); + DWINUI::Draw_String(tColor, bColor, 202, MBASE(row) - 1, options[value]); } +#if HAS_HOSTACTION_MENUS + + void CrealityDWINClass::Draw_String(char * string, uint8_t row, bool selected/*=false*/, bool below/*=false*/) { + if (!string) string[0] = '\0'; + const uint8_t offset_x = DWIN_WIDTH - strlen(string) * 8 - 20; + const uint8_t offset_y = (below) ? MENU_CHR_H * 3 / 5 : 0; + DWIN_Draw_Rectangle(1, Def_Background_Color, offset_x - 10, MBASE(row) + offset_y - 1, offset_x, MBASE(row) + 16 + offset_y); + DWINUI::Draw_String(Def_Text_Color, (selected) ? Def_Selected_Color : Def_Background_Color, offset_x, MBASE(row) - 1 + offset_y, string); + } + + const uint64_t CrealityDWINClass::Encode_String(const char * string) { + const char table[65] = "-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz"; + uint64_t output = 0; + LOOP_L_N(i, strlen(string)) { + uint8_t upper_bound = 63, lower_bound = 0; + uint8_t midpoint; + LOOP_L_N(x, 6) { + midpoint = (uint8_t)(0.5 * (upper_bound + lower_bound)); + if (string[i] == table[midpoint]) break; + if (string[i] > table[midpoint]) + lower_bound = midpoint; + else + upper_bound = midpoint; + } + output += midpoint * pow(64, i); + } + return output; + } + + void CrealityDWINClass::Decode_String(uint64_t num, char * string) { + const char table[65] = "-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz"; + LOOP_L_N(i, 30) { + string[i] = table[num % 64]; + num /= 64; + if (num == 0) { + string[i + 1] = '\0'; + break; + } + } + } + +#endif // HAS_HOSTACTION_MENUS + uint16_t CrealityDWINClass::GetColor(uint8_t color, uint16_t original, bool light/*=false*/) { switch (color) { - case Default: - return original; - break; - case White: - return (light) ? Color_Light_White : Color_White; - break; - case Green: - return (light) ? Color_Light_Green : Color_Green; - break; - case Cyan: - return (light) ? Color_Light_Cyan : Color_Cyan; - break; - case Blue: - return (light) ? Color_Light_Blue : Color_Blue; - break; - case Magenta: - return (light) ? Color_Light_Magenta : Color_Magenta; - break; - case Red: - return (light) ? Color_Light_Red : Color_Red; - break; - case Orange: - return (light) ? Color_Light_Orange : Color_Orange; - break; - case Yellow: - return (light) ? Color_Light_Yellow : Color_Yellow; - break; - case Brown: - return (light) ? Color_Light_Brown : Color_Brown; - break; - case Black: - return Color_Black; - break; + case Default: return original; + case White: return (light) ? Color_Light_White : Color_White; + case Green: return (light) ? Color_Light_Green : Color_Green; + case Cyan: return (light) ? Color_Light_Cyan : Color_Cyan; + case Blue: return (light) ? Color_Light_Blue : Color_Blue; + case Magenta: return (light) ? Color_Light_Magenta : Color_Magenta; + case Red: return (light) ? Color_Light_Red : Color_Red; + case Orange: return (light) ? Color_Light_Orange : Color_Orange; + case Yellow: return (light) ? Color_Light_Yellow : Color_Yellow; + case Brown: return (light) ? Color_Light_Brown : Color_Brown; + case Black: return Color_Black; } return Color_White; } void CrealityDWINClass::Draw_Title(const char * ctitle) { - DWIN_Draw_String(false, DWIN_FONT_HEAD, GetColor(eeprom_settings.menu_top_txt, Color_White, false), Color_Bg_Blue, (DWIN_WIDTH - strlen(ctitle) * STAT_CHR_W) / 2, 5, ctitle); + DWINUI::Draw_CenteredString((uint8_t)DWIN_FONT_HEAD, GetColor(eeprom_settings.menu_top_txt, Def_TitleTxt_color, false), 5, ctitle); } void CrealityDWINClass::Draw_Title(FSTR_P const ftitle) { - DWIN_Draw_String(false, DWIN_FONT_HEAD, GetColor(eeprom_settings.menu_top_txt, Color_White, false), Color_Bg_Blue, (DWIN_WIDTH - strlen_P(FTOP(ftitle)) * STAT_CHR_W) / 2, 5, ftitle); + DWINUI::Draw_CenteredString((uint8_t)DWIN_FONT_HEAD, GetColor(eeprom_settings.menu_top_txt, Def_TitleTxt_color, false), 5, ftitle); } void _Decorate_Menu_Item(uint8_t row, uint8_t icon, bool more) { if (icon) DWIN_ICON_Show(ICON, icon, 26, MBASE(row) - 3); //Draw Menu Icon if (more) DWIN_ICON_Show(ICON, ICON_More, 226, MBASE(row) - 3); // Draw More Arrow - DWIN_Draw_Line(CrealityDWIN.GetColor(CrealityDWIN.eeprom_settings.menu_split_line, Line_Color, true), 16, MBASE(row) + 33, 256, MBASE(row) + 33); // Draw Menu Line + DWIN_Draw_HLine(CrealityDWIN.GetColor(eeprom_settings.menu_split_line, Def_SplitLine_Color, true), 16, MBASE(row) + 33, 240); // Draw Menu Line } void CrealityDWINClass::Draw_Menu_Item(uint8_t row, uint8_t icon/*=0*/, const char * label1, const char * label2, bool more/*=false*/, bool centered/*=false*/) { - const uint8_t label_offset_y = (label1 || label2) ? MENU_CHR_H * 3 / 5 : 0, - label1_offset_x = !centered ? LBLX : LBLX * 4/5 + _MAX(LBLX * 1U/5, (DWIN_WIDTH - LBLX - (label1 ? strlen(label1) : 0) * MENU_CHR_W) / 2), - label2_offset_x = !centered ? LBLX : LBLX * 4/5 + _MAX(LBLX * 1U/5, (DWIN_WIDTH - LBLX - (label2 ? strlen(label2) : 0) * MENU_CHR_W) / 2); - if (label1) DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, label1_offset_x, MBASE(row) - 1 - label_offset_y, label1); // Draw Label - if (label2) DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, label2_offset_x, MBASE(row) - 1 + label_offset_y, label2); // Draw Label + const uint8_t label_offset_y = (label1 && label2) ? MENU_CHR_H * 3 / 5 : 0, + label1_offset_x = !centered ? LBLX : LBLX * 4/5 + _MAX(LBLX * 1/5U, (DWIN_WIDTH - LBLX - (label1 ? strlen(label1) : 0) * MENU_CHR_W) / 2), + label2_offset_x = !centered ? LBLX : LBLX * 4/5 + _MAX(LBLX * 1/5U, (DWIN_WIDTH - LBLX - (label2 ? strlen(label2) : 0) * MENU_CHR_W) / 2); + if (label1) DWINUI::Draw_String(label1_offset_x, MBASE(row) - 1 - label_offset_y, label1); // Draw Label + if (label2) DWINUI::Draw_String(label2_offset_x, MBASE(row) - 1 + label_offset_y, label2); // Draw Label _Decorate_Menu_Item(row, icon, more); } void CrealityDWINClass::Draw_Menu_Item(uint8_t row, uint8_t icon/*=0*/, FSTR_P const flabel1, FSTR_P const flabel2, bool more/*=false*/, bool centered/*=false*/) { - const uint8_t label_offset_y = (flabel1 || flabel2) ? MENU_CHR_H * 3 / 5 : 0, - label1_offset_x = !centered ? LBLX : LBLX * 4/5 + _MAX(LBLX * 1U/5, (DWIN_WIDTH - LBLX - (flabel1 ? strlen_P(FTOP(flabel1)) : 0) * MENU_CHR_W) / 2), - label2_offset_x = !centered ? LBLX : LBLX * 4/5 + _MAX(LBLX * 1U/5, (DWIN_WIDTH - LBLX - (flabel2 ? strlen_P(FTOP(flabel2)) : 0) * MENU_CHR_W) / 2); - if (flabel1) DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, label1_offset_x, MBASE(row) - 1 - label_offset_y, flabel1); // Draw Label - if (flabel2) DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, label2_offset_x, MBASE(row) - 1 + label_offset_y, flabel2); // Draw Label + const uint8_t label_offset_y = (flabel1 && flabel2) ? MENU_CHR_H * 3 / 5 : 0, + label1_offset_x = !centered ? LBLX : LBLX * 4/5 + _MAX(LBLX * 1/5U, (DWIN_WIDTH - LBLX - (flabel1 ? strlen_P(FTOP(flabel1)) : 0) * MENU_CHR_W) / 2), + label2_offset_x = !centered ? LBLX : LBLX * 4/5 + _MAX(LBLX * 1/5U, (DWIN_WIDTH - LBLX - (flabel2 ? strlen_P(FTOP(flabel2)) : 0) * MENU_CHR_W) / 2); + if (flabel1) DWINUI::Draw_String(label1_offset_x, MBASE(row) - 1 - label_offset_y, flabel1); // Draw Label + if (flabel2) DWINUI::Draw_String(label2_offset_x, MBASE(row) - 1 + label_offset_y, flabel2); // Draw Label _Decorate_Menu_Item(row, icon, more); } @@ -515,8 +566,8 @@ void CrealityDWINClass::Draw_Checkbox(uint8_t row, bool value) { #if ENABLED(DWIN_CREALITY_LCD_CUSTOM_ICONS) // Draw appropriate checkbox icon DWIN_ICON_Show(ICON, (value ? ICON_Checkbox_T : ICON_Checkbox_F), 226, MBASE(row) - 3); #else // Draw a basic checkbox using rectangles and lines - DWIN_Draw_Rectangle(1, Color_Bg_Black, 226, MBASE(row) - 3, 226 + 20, MBASE(row) - 3 + 20); - DWIN_Draw_Rectangle(0, Color_White, 226, MBASE(row) - 3, 226 + 20, MBASE(row) - 3 + 20); + DWIN_Draw_Rectangle(1, Def_Background_Color, 226, MBASE(row) - 3, 226 + 20, MBASE(row) - 3 + 20); + DWIN_Draw_Rectangle(0, Def_Text_Color, 226, MBASE(row) - 3, 226 + 20, MBASE(row) - 3 + 20); if (value) { DWIN_Draw_Line(Check_Color, 227, MBASE(row) - 3 + 11, 226 + 8, MBASE(row) - 3 + 17); DWIN_Draw_Line(Check_Color, 227 + 8, MBASE(row) - 3 + 17, 226 + 19, MBASE(row) - 3 + 1); @@ -542,7 +593,7 @@ void CrealityDWINClass::Draw_Menu(uint8_t menu, uint8_t select/*=0*/, uint8_t sc Clear_Screen(); Draw_Title(Get_Menu_Title(menu)); LOOP_L_N(i, TROWS) Menu_Item_Handler(menu, i + scrollpos); - DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Rectangle_Color), 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); + DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Def_Cursor_color), 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); } void CrealityDWINClass::Redraw_Menu(bool lastprocess/*=true*/, bool lastselection/*=false*/, bool lastmenu/*=false*/) { @@ -558,7 +609,8 @@ void CrealityDWINClass::Redraw_Menu(bool lastprocess/*=true*/, bool lastselectio } void CrealityDWINClass::Redraw_Screen() { - Redraw_Menu(false); + if (printingIsActive()) Draw_Print_Screen(); + else Redraw_Menu(false); Draw_Status_Area(true); Update_Status_Bar(true); } @@ -566,53 +618,56 @@ void CrealityDWINClass::Redraw_Screen() { /* Primary Menus and Screen Elements */ void CrealityDWINClass::Main_Menu_Icons() { + if (selection == 0) { - DWIN_ICON_Show(ICON, ICON_Print_1, 17, 130); - DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 17, 130, 126, 229); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 52, 200, F("Print")); - } - else { - DWIN_ICON_Show(ICON, ICON_Print_0, 17, 130); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 52, 200, F("Print")); + DWINUI::DRAW_IconWB(ICON, ICON_Print_1, 17, 110); + DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Def_Highlight_Color), 17, 110, 126, 209); } + else + DWINUI::DRAW_IconWB(ICON, ICON_Print_0, 17, 110); + + DWINUI::Draw_String(52, 180, GET_TEXT_F(MSG_BUTTON_PRINT)); + if (selection == 1) { - DWIN_ICON_Show(ICON, ICON_Prepare_1, 145, 130); - DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 145, 130, 254, 229); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 170, 200, F("Prepare")); - } - else { - DWIN_ICON_Show(ICON, ICON_Prepare_0, 145, 130); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 170, 200, F("Prepare")); + DWINUI::DRAW_IconWB(ICON, ICON_Prepare_1, 145, 110); + DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Def_Highlight_Color), 145, 110, 254, 209); } + else + DWINUI::DRAW_IconWB(ICON, ICON_Prepare_0, 145, 110); + + DWINUI::Draw_String(170, 180, GET_TEXT_F(MSG_PREPARE)); + if (selection == 2) { - DWIN_ICON_Show(ICON, ICON_Control_1, 17, 246); - DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 17, 246, 126, 345); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 43, 317, F("Control")); - } - else { - DWIN_ICON_Show(ICON, ICON_Control_0, 17, 246); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 43, 317, F("Control")); + DWINUI::DRAW_IconWB(ICON, ICON_Control_1, 17, 226); + DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Def_Highlight_Color), 17, 226, 126, 325); } + else + DWINUI::DRAW_IconWB(ICON, ICON_Control_0, 17, 226); + + DWINUI::Draw_String(43, 297, GET_TEXT_F(MSG_CONTROL)); + #if HAS_ABL_OR_UBL + if (selection == 3) { - DWIN_ICON_Show(ICON, ICON_Leveling_1, 145, 246); - DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 145, 246, 254, 345); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 179, 317, F("Level")); - } - else { - DWIN_ICON_Show(ICON, ICON_Leveling_0, 145, 246); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 179, 317, F("Level")); + DWINUI::DRAW_IconWB(ICON, ICON_Leveling_1, 145, 226); + DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Def_Highlight_Color), 145, 226, 254, 325); } + else + DWINUI::DRAW_IconWB(ICON, ICON_Leveling_0, 145, 226); + + DWINUI::Draw_String(179, 297, GET_TEXT_F(MSG_BUTTON_LEVEL)); + #else + if (selection == 3) { - DWIN_ICON_Show(ICON, ICON_Info_1, 145, 246); - DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 145, 246, 254, 345); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 181, 317, F("Info")); - } - else { - DWIN_ICON_Show(ICON, ICON_Info_0, 145, 246); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 181, 317, F("Info")); + DWINUI::DRAW_IconWB(ICON, ICON_Info_1, 145, 226); + DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Def_Highlight_Color), 145, 226, 254, 325); } + else + DWINUI::DRAW_IconWB(ICON, ICON_Info_0, 145, 226); + + DWINUI::Draw_String(181, 297, GET_TEXT_F(MSG_BUTTON_INFO)); + #endif } @@ -623,50 +678,48 @@ void CrealityDWINClass::Draw_Main_Menu(uint8_t select/*=0*/) { Clear_Screen(); Draw_Title(Get_Menu_Title(MainMenu)); SERIAL_ECHOPGM("\nDWIN handshake "); - DWIN_ICON_Show(ICON, ICON_LOGO, 71, 72); + DWIN_ICON_Show(ICON, ICON_LOGO, 71, 62); Main_Menu_Icons(); } void CrealityDWINClass::Print_Screen_Icons() { if (selection == 0) { - DWIN_ICON_Show(ICON, ICON_Setup_1, 8, 252); - DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 8, 252, 87, 351); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 30, 322, F("Tune")); - } - else { - DWIN_ICON_Show(ICON, ICON_Setup_0, 8, 252); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 30, 322, F("Tune")); + DWINUI::DRAW_IconWB(ICON, ICON_Setup_1, 8, 252); + DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Def_Highlight_Color), 8, 252, 87, 351); } + else + DWINUI::DRAW_IconWB(ICON, ICON_Setup_0, 8, 252); + + DWINUI::Draw_String(30, 322, GET_TEXT_F(MSG_TUNE)); + if (selection == 2) { - DWIN_ICON_Show(ICON, ICON_Stop_1, 184, 252); - DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 184, 252, 263, 351); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 205, 322, F("Stop")); + DWINUI::DRAW_IconWB(ICON, ICON_Stop_1, 184, 252); + DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Def_Highlight_Color), 184, 252, 263, 351); } - else { - DWIN_ICON_Show(ICON, ICON_Stop_0, 184, 252); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 205, 322, F("Stop")); - } - if (paused) { + else + DWINUI::DRAW_IconWB(ICON, ICON_Stop_0, 184, 252); + + DWINUI::Draw_String(205, 322, GET_TEXT_F(MSG_BUTTON_STOP)); + + if (temp_val.paused) { if (selection == 1) { - DWIN_ICON_Show(ICON, ICON_Continue_1, 96, 252); - DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 96, 252, 175, 351); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 114, 322, F("Print")); - } - else { - DWIN_ICON_Show(ICON, ICON_Continue_0, 96, 252); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 114, 322, F("Print")); + DWINUI::DRAW_IconWB(ICON, ICON_Continue_1, 96, 252); + DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Def_Highlight_Color), 96, 252, 175, 351); } + else + DWINUI::DRAW_IconWB(ICON, ICON_Continue_0, 96, 252); + + DWINUI::Draw_String(114, 322, GET_TEXT_F(MSG_BUTTON_RESUME)); } else { if (selection == 1) { - DWIN_ICON_Show(ICON, ICON_Pause_1, 96, 252); - DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 96, 252, 175, 351); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 114, 322, F("Pause")); - } - else { - DWIN_ICON_Show(ICON, ICON_Pause_0, 96, 252); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 114, 322, F("Pause")); + DWINUI::DRAW_IconWB(ICON, ICON_Pause_1, 96, 252); + DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Def_Highlight_Color), 96, 252, 175, 351); } + else + DWINUI::DRAW_IconWB(ICON, ICON_Pause_0, 96, 252); + + DWINUI::Draw_String(114, 322, GET_TEXT_F(MSG_BUTTON_PAUSE)); } } @@ -674,13 +727,13 @@ void CrealityDWINClass::Draw_Print_Screen() { process = Print; selection = 0; Clear_Screen(); - DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 352, DWIN_WIDTH - 8, 376); - Draw_Title("Printing..."); + DWIN_Draw_Rectangle(1, Def_Background_Color, 8, 352, DWIN_WIDTH - 8, 376); + Draw_Title(GET_TEXT(MSG_PRINTING)); Print_Screen_Icons(); DWIN_ICON_Show(ICON, ICON_PrintTime, 14, 171); DWIN_ICON_Show(ICON, ICON_RemainTime, 147, 169); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, 41, 163, F("Elapsed")); - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, 176, 163, F("Remaining")); + DWINUI::Draw_String(Def_PercentTxt_Color, 41, 163, GET_TEXT_F(MSG_INFO_PRINT_TIME)); + DWINUI::Draw_String(Def_PercentTxt_Color, 176, 163, GET_TEXT_F(MSG_REMAINING_TIME)); Update_Status_Bar(true); Draw_Print_ProgressBar(); Draw_Print_ProgressElapsed(); @@ -692,83 +745,91 @@ void CrealityDWINClass::Draw_Print_Filename(const bool reset/*=false*/) { static uint8_t namescrl = 0; if (reset) namescrl = 0; if (process == Print) { - constexpr int8_t maxlen = 30; - char *outstr = filename; - size_t slen = strlen(filename); - int8_t outlen = slen; - if (slen > maxlen) { - char dispname[maxlen + 1]; - int8_t pos = slen - namescrl, len = maxlen; + size_t len = strlen(filename); + int8_t pos = len; + if (pos > STATUS_CHAR_LIMIT) { + pos -= namescrl; + len = _MIN((size_t)pos, (size_t)STATUS_CHAR_LIMIT); + char dispname[len + 1]; if (pos >= 0) { - NOMORE(len, pos); LOOP_L_N(i, len) dispname[i] = filename[i + namescrl]; } else { - const int8_t mp = maxlen + pos; - LOOP_L_N(i, mp) dispname[i] = ' '; - LOOP_S_L_N(i, mp, maxlen) dispname[i] = filename[i - mp]; - if (mp <= 0) namescrl = 0; + LOOP_L_N(i, STATUS_CHAR_LIMIT + pos) dispname[i] = ' '; + LOOP_S_L_N(i, STATUS_CHAR_LIMIT + pos, STATUS_CHAR_LIMIT) dispname[i] = filename[i - (STATUS_CHAR_LIMIT + pos)]; } dispname[len] = '\0'; - outstr = dispname; - outlen = maxlen; + DWIN_Draw_Rectangle(1, Def_Background_Color, 8, 50, DWIN_WIDTH - 8, 80); + const int8_t npos = (DWIN_WIDTH - STATUS_CHAR_LIMIT * MENU_CHR_W) / 2; + DWINUI::Draw_String(npos, 60, dispname); + if (-pos >= STATUS_CHAR_LIMIT) namescrl = 0; namescrl++; } - DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 50, DWIN_WIDTH - 8, 80); - const int8_t npos = (DWIN_WIDTH - outlen * MENU_CHR_W) / 2; - DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, npos, 60, outstr); + else { + DWIN_Draw_Rectangle(1, Def_Background_Color, 8, 50, DWIN_WIDTH - 8, 80); + const int8_t npos = (DWIN_WIDTH - strlen(filename) * MENU_CHR_W) / 2; + DWINUI::Draw_String(npos, 60, filename); + } } } void CrealityDWINClass::Draw_Print_ProgressBar() { - uint8_t printpercent = sdprint ? card.percentDone() : (ui._get_progress() / 100); - DWIN_ICON_Show(ICON, ICON_Bar, 15, 93); - DWIN_Draw_Rectangle(1, BarFill_Color, 16 + printpercent * 240 / 100, 93, 256, 113); - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_percent, Percent_Color), Color_Bg_Black, 3, 109, 133, printpercent); - DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_percent, Percent_Color), Color_Bg_Black, 133, 133, F("%")); + uint8_t printpercent = temp_val.sdprint ? card.percentDone() : (ui._get_progress() / 100); + DWINUI::DRAW_IconWB(ICON, ICON_Bar, 15, 93); + DWIN_Draw_Rectangle(1, Def_Barfill_Color, 16 + printpercent * 240 / 100, 93, 256, 113); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_percent, Def_PercentTxt_Color), Def_Background_Color, 3, 109, 133, printpercent); + DWINUI::Draw_String(GetColor(eeprom_settings.progress_percent, Def_PercentTxt_Color), Def_Background_Color, 134, 133, F("%")); } #if ENABLED(USE_M73_REMAINING_TIME) void CrealityDWINClass::Draw_Print_ProgressRemain() { uint16_t remainingtime = ui.get_remaining_time(); - DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 2, 176, 187, remainingtime / 3600); - DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 2, 200, 187, (remainingtime % 3600) / 60); + DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Def_PercentTxt_Color), Def_Background_Color, 2, 176, 187, remainingtime / 3600); + DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Def_PercentTxt_Color), Def_Background_Color, 2, 201, 187, (remainingtime % 3600) / 60); if (eeprom_settings.time_format_textual) { - DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 192, 187, F("h")); - DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 216, 187, F("m")); + DWINUI::Draw_String(GetColor(eeprom_settings.progress_time, Def_PercentTxt_Color), Def_Background_Color, 193, 187, F("h")); + DWINUI::Draw_String(GetColor(eeprom_settings.progress_time, Def_PercentTxt_Color), Def_Background_Color, 217, 187, F("m")); } else - DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 192, 187, F(":")); + DWINUI::Draw_String(GetColor(eeprom_settings.progress_time, Def_PercentTxt_Color), Def_Background_Color, 193, 187, F(":")); } #endif void CrealityDWINClass::Draw_Print_ProgressElapsed() { duration_t elapsed = print_job_timer.duration(); - DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 2, 42, 187, elapsed.value / 3600); - DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 2, 66, 187, (elapsed.value % 3600) / 60); + DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Def_PercentTxt_Color), Def_Background_Color, 2, 42, 187, elapsed.value / 3600); + DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Def_PercentTxt_Color), Def_Background_Color, 2, 67, 187, (elapsed.value % 3600) / 60); if (eeprom_settings.time_format_textual) { - DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 58, 187, F("h")); - DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 82, 187, F("m")); + DWINUI::Draw_String(GetColor(eeprom_settings.progress_time, Def_PercentTxt_Color), Def_Background_Color, 59, 187, F("h")); + DWINUI::Draw_String(GetColor(eeprom_settings.progress_time, Def_PercentTxt_Color), Def_Background_Color, 83, 187, F("m")); } else - DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 58, 187, F(":")); + DWINUI::Draw_String(GetColor(eeprom_settings.progress_time, Def_PercentTxt_Color), Def_Background_Color, 59, 187, F(":")); } -void CrealityDWINClass::Draw_Print_confirm() { - Draw_Print_Screen(); +void CrealityDWINClass::Draw_PrintDone_confirm() { process = Confirm; popup = Complete; - DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 252, 263, 351); - DWIN_ICON_Show(ICON, ICON_Confirm_E, 87, 283); - DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 86, 282, 187, 321); - DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 85, 281, 188, 322); + if (TERN0(HAS_GCODE_PREVIEW, Preview_Valid())) { + Clear_Screen(); + Draw_Title(GET_TEXT(MSG_PRINT_DONE)); + DWIN_ICON_Show(0, 0, 1, 21, 100, 0x00); + DWINUI::Draw_Button(BTN_Continue, 87, 300); + } + else { + Draw_Print_Screen(); + DWIN_Draw_Rectangle(1, Def_Background_Color, 8, 252, 263, 351); + DWINUI::Draw_Button(BTN_Continue, 87, 283); + DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Def_Highlight_Color), 86, 282, 187, 321); + DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Def_Highlight_Color), 85, 281, 188, 322); + } } void CrealityDWINClass::Draw_SD_Item(uint8_t item, uint8_t row) { if (item == 0) - Draw_Menu_Item(0, ICON_Back, card.flag.workDirIsRoot ? F("Back") : F("..")); + Draw_Menu_Item(0, ICON_Back, card.flag.workDirIsRoot ? GET_TEXT_F(MSG_BACK) : F("..")); else { card.getfilename_sorted(SD_ORDER(item - 1, card.get_num_Files())); char * const filename = card.longest_filename(); @@ -777,11 +838,10 @@ void CrealityDWINClass::Draw_SD_Item(uint8_t item, uint8_t row) { if (!card.flag.filenameIsDir) while (pos && filename[pos] != '.') pos--; len = pos; - if (len > max) len = max; + NOMORE(len, max); char name[len + 1]; - LOOP_L_N(i, len) name[i] = filename[i]; - if (pos > max) - LOOP_S_L_N(i, len - 3, len) name[i] = '.'; + memcpy(name, filename, len); + if (pos > max) LOOP_S_L_N(i, len - 3, len) name[i] = '.'; name[len] = '\0'; Draw_Menu_Item(row, card.flag.filenameIsDir ? ICON_More : ICON_File, name); } @@ -798,16 +858,16 @@ void CrealityDWINClass::Draw_SD_List(bool removed/*=false*/) { Draw_SD_Item(i, i); } else { - Draw_Menu_Item(0, ICON_Back, F("Back")); - DWIN_Draw_Rectangle(1, Color_Bg_Red, 10, MBASE(3) - 10, DWIN_WIDTH - 10, MBASE(4)); - DWIN_Draw_String(false, font16x32, Color_Yellow, Color_Bg_Red, ((DWIN_WIDTH) - 8 * 16) / 2, MBASE(3), F("No Media")); + Draw_Menu_Item(0, ICON_Back, GET_TEXT_F(MSG_BACK)); + DWIN_Draw_Rectangle(1, Def_AlertBg_Color, 10, MBASE(3) - 10, DWIN_WIDTH - 10, MBASE(4)); + DWINUI::Draw_String(font16x32, Def_AlertTxt_Color, Def_AlertBg_Color, ((DWIN_WIDTH) - 8 * 16) / 2, MBASE(3), GET_TEXT_F(MSG_NO_MEDIA)); } - DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Rectangle_Color), 0, MBASE(0) - 18, 14, MBASE(0) + 33); + DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Def_Cursor_color), 0, MBASE(0) - 18, 14, MBASE(0) + 33); } void CrealityDWINClass::Draw_Status_Area(bool icons/*=false*/) { - if (icons) DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, STATUS_Y, DWIN_WIDTH, DWIN_HEIGHT - 1); + if (icons) DWIN_Draw_Rectangle(1, Def_Background_Color, 0, STATUS_Y, DWIN_WIDTH, DWIN_HEIGHT - 1); #if HAS_HOTEND static float hotend = -1; @@ -816,26 +876,26 @@ void CrealityDWINClass::Draw_Status_Area(bool icons/*=false*/) { hotend = -1; hotendtarget = -1; DWIN_ICON_Show(ICON, ICON_HotendTemp, 10, 383); - DWIN_Draw_String(false, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 25 + 3 * STAT_CHR_W + 5, 384, F("/")); + DWINUI::Draw_String(DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), Def_Background_Color, 25 + 3 * STAT_CHR_W + 5, 384, F("/")); } if (thermalManager.temp_hotend[0].celsius != hotend) { hotend = thermalManager.temp_hotend[0].celsius; - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 3, 28, 384, thermalManager.temp_hotend[0].celsius); - DWIN_Draw_DegreeSymbol(GetColor(eeprom_settings.status_area_text, Color_White), 25 + 3 * STAT_CHR_W + 5, 386); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), Def_Background_Color, 3, 28, 384, thermalManager.temp_hotend[0].celsius); + DWIN_Draw_DegreeSymbol(GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), 25 + 3 * STAT_CHR_W + 5, 386); } if (thermalManager.temp_hotend[0].target != hotendtarget) { hotendtarget = thermalManager.temp_hotend[0].target; - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 384, thermalManager.temp_hotend[0].target); - DWIN_Draw_DegreeSymbol(GetColor(eeprom_settings.status_area_text, Color_White), 25 + 4 * STAT_CHR_W + 39, 386); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), Def_Background_Color, 3, 25 + 4 * STAT_CHR_W + 6, 384, thermalManager.temp_hotend[0].target); + DWIN_Draw_DegreeSymbol(GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), 25 + 4 * STAT_CHR_W + 39, 386); } if (icons) { flow = -1; DWIN_ICON_Show(ICON, ICON_StepE, 112, 417); - DWIN_Draw_String(false, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 116 + 5 * STAT_CHR_W + 2, 417, F("%")); + DWINUI::Draw_String(DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), Def_Background_Color, 116 + 5 * STAT_CHR_W + 2, 417, F("%")); } if (planner.flow_percentage[0] != flow) { flow = planner.flow_percentage[0]; - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 3, 116 + 2 * STAT_CHR_W, 417, planner.flow_percentage[0]); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), Def_Background_Color, 3, 116 + 2 * STAT_CHR_W, 417, planner.flow_percentage[0]); } #endif @@ -846,17 +906,17 @@ void CrealityDWINClass::Draw_Status_Area(bool icons/*=false*/) { bed = -1; bedtarget = -1; DWIN_ICON_Show(ICON, ICON_BedTemp, 10, 416); - DWIN_Draw_String(false, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 25 + 3 * STAT_CHR_W + 5, 417, F("/")); + DWINUI::Draw_String(DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), Def_Background_Color, 25 + 3 * STAT_CHR_W + 5, 417, F("/")); } if (thermalManager.temp_bed.celsius != bed) { bed = thermalManager.temp_bed.celsius; - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 3, 28, 417, thermalManager.temp_bed.celsius); - DWIN_Draw_DegreeSymbol(GetColor(eeprom_settings.status_area_text, Color_White), 25 + 3 * STAT_CHR_W + 5, 419); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), Def_Background_Color, 3, 28, 417, thermalManager.temp_bed.celsius); + DWIN_Draw_DegreeSymbol(GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), 25 + 3 * STAT_CHR_W + 5, 419); } if (thermalManager.temp_bed.target != bedtarget) { bedtarget = thermalManager.temp_bed.target; - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 417, thermalManager.temp_bed.target); - DWIN_Draw_DegreeSymbol(GetColor(eeprom_settings.status_area_text, Color_White), 25 + 4 * STAT_CHR_W + 39, 419); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), Def_Background_Color, 3, 25 + 4 * STAT_CHR_W + 6, 417, thermalManager.temp_bed.target); + DWIN_Draw_DegreeSymbol(GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), 25 + 4 * STAT_CHR_W + 39, 419); } #endif @@ -868,21 +928,37 @@ void CrealityDWINClass::Draw_Status_Area(bool icons/*=false*/) { } if (thermalManager.fan_speed[0] != fan) { fan = thermalManager.fan_speed[0]; - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 3, 195 + 2 * STAT_CHR_W, 384, thermalManager.fan_speed[0]); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), Def_Background_Color, 3, 195 + 2 * STAT_CHR_W, 384, thermalManager.fan_speed[0]); } #endif #if HAS_ZOFFSET_ITEM static float offset = -1; - if (icons) { - offset = -1; + #if HAS_MESH + static bool _leveling_active = false, + _printing_leveling_active = false; + if (printingIsActive()) { + _printing_leveling_active = ((planner.leveling_active && planner.leveling_active_at_z(current_position.z)) || _printing_leveling_active ); + if ((_printing_leveling_active = (planner.leveling_active && planner.leveling_active_at_z(current_position.z)) && ui.get_blink())) + DWIN_Draw_Rectangle(1, Def_SplitLine_Color, 186, 415, 205, 436); + else + DWIN_Draw_Rectangle(1, Def_Background_Color, 186, 415, 205, 436); + } + else { + _leveling_active = (planner.leveling_active || _leveling_active); + if ((_leveling_active = planner.leveling_active && ui.get_blink())) + DWIN_Draw_Rectangle(1, Def_SplitLine_Color, 186, 415, 205, 436); + else + DWIN_Draw_Rectangle(1, Def_Background_Color, 186, 415, 205, 436); + } DWIN_ICON_Show(ICON, ICON_Zoffset, 187, 416); - } - if (zoffsetvalue != offset) { - offset = zoffsetvalue; - DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 2, 2, 207, 417, (zoffsetvalue < 0 ? -zoffsetvalue : zoffsetvalue)); - DWIN_Draw_String(true, DWIN_FONT_MENU, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 205, 419, zoffsetvalue < 0 ? F("-") : F(" ")); + #else + if (icons) DWIN_ICON_Show(ICON, ICON_Zoffset, 187, 416); + #endif + if (temp_val.zoffsetvalue != offset || icons) { + offset = temp_val.zoffsetvalue; + DWINUI::Draw_Signed_Float(DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Def_Indicator_Color),Def_Background_Color, 1, 2, 202, 417, temp_val.zoffsetvalue); } #endif @@ -890,11 +966,11 @@ void CrealityDWINClass::Draw_Status_Area(bool icons/*=false*/) { if (icons) { feedrate = -1; DWIN_ICON_Show(ICON, ICON_Speed, 113, 383); - DWIN_Draw_String(false, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 116 + 5 * STAT_CHR_W + 2, 384, F("%")); + DWINUI::Draw_String(DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), Def_Background_Color, 116 + 5 * STAT_CHR_W + 2, 384, F("%")); } if (feedrate_percentage != feedrate) { feedrate = feedrate_percentage; - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 3, 116 + 2 * STAT_CHR_W, 384, feedrate_percentage); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), Def_Background_Color, 3, 116 + 2 * STAT_CHR_W, 384, feedrate_percentage); } static float x = -1, y = -1, z = -1; @@ -904,7 +980,7 @@ void CrealityDWINClass::Draw_Status_Area(bool icons/*=false*/) { update_z = (current_position.z != z || axis_should_home(Z_AXIS) || update_z); if (icons) { x = y = z = -1; - DWIN_Draw_Line(GetColor(eeprom_settings.coordinates_split_line, Line_Color, true), 16, 450, 256, 450); + DWIN_Draw_Line(GetColor(eeprom_settings.coordinates_split_line, Def_SplitLine_Color, true), 16, 450, 256, 450); DWIN_ICON_Show(ICON, ICON_MaxSpeedX, 10, 456); DWIN_ICON_Show(ICON, ICON_MaxSpeedY, 95, 456); DWIN_ICON_Show(ICON, ICON_MaxSpeedZ, 180, 456); @@ -912,60 +988,59 @@ void CrealityDWINClass::Draw_Status_Area(bool icons/*=false*/) { if (update_x) { x = current_position.x; if ((update_x = axis_should_home(X_AXIS) && ui.get_blink())) - DWIN_Draw_String(true, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 35, 459, F(" -?- ")); + DWINUI::Draw_String(GetColor(eeprom_settings.coordinates_text, Def_Coordinate_Color), Def_Background_Color, 39, 459, F(" -?- ")); else - DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 3, 1, 35, 459, current_position.x); + DWINUI::Draw_Signed_Float(DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Def_Coordinate_Color), Def_Background_Color, 3, 1, 31, 459, current_position.x); } if (update_y) { y = current_position.y; if ((update_y = axis_should_home(Y_AXIS) && ui.get_blink())) - DWIN_Draw_String(true, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 120, 459, F(" -?- ")); + DWINUI::Draw_String(GetColor(eeprom_settings.coordinates_text, Def_Coordinate_Color), Def_Background_Color, 124, 459, F(" -?- ")); else - DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 3, 1, 120, 459, current_position.y); + DWINUI::Draw_Signed_Float(DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Def_Coordinate_Color), Def_Background_Color, 3, 1, 116, 459, current_position.y); } if (update_z) { z = current_position.z; if ((update_z = axis_should_home(Z_AXIS) && ui.get_blink())) - DWIN_Draw_String(true, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 205, 459, F(" -?- ")); + DWINUI::Draw_String(GetColor(eeprom_settings.coordinates_text, Def_Coordinate_Color), Def_Background_Color, 205, 459, F(" -?- ")); else - DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 3, 2, 205, 459, (current_position.z>=0) ? current_position.z : 0); + DWINUI::Draw_Signed_Float(DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Def_Coordinate_Color), Def_Background_Color, 3, 2, 197, 459, current_position.z); } DWIN_UpdateLCD(); } void CrealityDWINClass::Draw_Popup(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, uint8_t mode, uint8_t icon/*=0*/) { - if (process != Confirm && process != Popup && process != Wait) last_process = process; + if (process != Confirm && process != Popup && process != Wait && process != Cancel) last_process = process; if ((process == Menu || process == Wait) && mode == Popup) last_selection = selection; process = mode; - Clear_Screen(); - DWIN_Draw_Rectangle(0, Color_White, 13, 59, 259, 351); - DWIN_Draw_Rectangle(1, Color_Bg_Window, 14, 60, 258, 350); - const uint8_t ypos = (mode == Popup || mode == Confirm) ? 150 : 230; + if (popup != PrintConfirm) { + Clear_Screen(); + DWIN_Draw_Rectangle(0, Def_Highlight_Color, 13, 59, 259, 346); + DWIN_Draw_Rectangle(1, Def_PopupBg_color, 14, 60, 258, 345); + } + else DWIN_Draw_Rectangle(1, Def_Background_Color, 0, 0, DWIN_WIDTH, STATUS_Y - 1); + const uint8_t ypos = (mode == Popup || mode == Confirm) ? 150 : (mode == Cancel) ? 200 : 230; if (icon > 0) DWIN_ICON_Show(ICON, icon, 101, 105); - DWIN_Draw_String(true, DWIN_FONT_MENU, Popup_Text_Color, Color_Bg_Window, (272 - 8 * strlen_P(FTOP(line1))) / 2, ypos, line1); - DWIN_Draw_String(true, DWIN_FONT_MENU, Popup_Text_Color, Color_Bg_Window, (272 - 8 * strlen_P(FTOP(line2))) / 2, ypos + 30, line2); - DWIN_Draw_String(true, DWIN_FONT_MENU, Popup_Text_Color, Color_Bg_Window, (272 - 8 * strlen_P(FTOP(line3))) / 2, ypos + 60, line3); + if (line1) DWINUI::Draw_String(Def_PopupTxt_Color, (272 - 8 * strlen_P(FTOP(line1))) / 2, ypos, line1); + if (line2) DWINUI::Draw_String(Def_PopupTxt_Color, (272 - 8 * strlen_P(FTOP(line2))) / 2, ypos + 30, line2); + if (line3) DWINUI::Draw_String(Def_PopupTxt_Color, (272 - 8 * strlen_P(FTOP(line3))) / 2, ypos + 60, line3); if (mode == Popup) { selection = 0; - DWIN_Draw_Rectangle(1, Confirm_Color, 26, 280, 125, 317); - DWIN_Draw_Rectangle(1, Cancel_Color, 146, 280, 245, 317); - DWIN_Draw_String(false, DWIN_FONT_STAT, Color_White, Color_Bg_Window, 39, 290, F("Confirm")); - DWIN_Draw_String(false, DWIN_FONT_STAT, Color_White, Color_Bg_Window, 165, 290, F("Cancel")); + DWINUI::Draw_Button(BTN_Confirm, 26, 280); + DWINUI::Draw_Button(BTN_Cancel, 146, 280); Popup_Select(); } - else if (mode == Confirm) { - DWIN_Draw_Rectangle(1, Confirm_Color, 87, 280, 186, 317); - DWIN_Draw_String(false, DWIN_FONT_STAT, Color_White, Color_Bg_Window, 96, 290, F("Continue")); - } + else if (mode == Confirm) DWINUI::Draw_Button(BTN_Continue, 87, 280); + else if (mode == Cancel) DWINUI::Draw_Button(BTN_Cancel, 87, 280); } void MarlinUI::kill_screen(FSTR_P const error, FSTR_P const) { - CrealityDWIN.Draw_Popup(F("Printer Kill Reason:"), error, F("Restart Required"), Wait, ICON_BLTouch); + CrealityDWIN.Draw_Popup(GET_TEXT_F(MSG_KILLED), error, GET_TEXT_F(MSG_SWITCH_PS_OFF), Wait, ICON_BLTouch); } void CrealityDWINClass::Popup_Select() { - const uint16_t c1 = (selection == 0) ? GetColor(eeprom_settings.highlight_box, Color_White) : Color_Bg_Window, - c2 = (selection == 0) ? Color_Bg_Window : GetColor(eeprom_settings.highlight_box, Color_White); + const uint16_t c1 = (selection == 0) ? GetColor(eeprom_settings.highlight_box, Def_Highlight_Color) : Def_Background_Color, + c2 = (selection == 0) ? Def_Background_Color : GetColor(eeprom_settings.highlight_box, Def_Highlight_Color); DWIN_Draw_Rectangle(0, c1, 25, 279, 126, 318); DWIN_Draw_Rectangle(0, c1, 24, 278, 127, 319); DWIN_Draw_Rectangle(0, c2, 145, 279, 246, 318); @@ -975,7 +1050,7 @@ void CrealityDWINClass::Popup_Select() { void CrealityDWINClass::Update_Status_Bar(bool refresh/*=false*/) { static bool new_msg; static uint8_t msgscrl = 0; - static char lastmsg[64]; + static char lastmsg[128]; if (strcmp(lastmsg, statusmsg) != 0 || refresh) { strcpy(lastmsg, statusmsg); msgscrl = 0; @@ -983,50 +1058,162 @@ void CrealityDWINClass::Update_Status_Bar(bool refresh/*=false*/) { } size_t len = strlen(statusmsg); int8_t pos = len; - if (pos > 30) { + if (pos > STATUS_CHAR_LIMIT) { pos -= msgscrl; - len = pos; - if (len > 30) - len = 30; + len = _MIN((size_t)pos, (size_t)STATUS_CHAR_LIMIT); char dispmsg[len + 1]; if (pos >= 0) { LOOP_L_N(i, len) dispmsg[i] = statusmsg[i + msgscrl]; } else { - LOOP_L_N(i, 30 + pos) dispmsg[i] = ' '; - LOOP_S_L_N(i, 30 + pos, 30) dispmsg[i] = statusmsg[i - (30 + pos)]; + LOOP_L_N(i, STATUS_CHAR_LIMIT + pos) dispmsg[i] = ' '; + LOOP_S_L_N(i, STATUS_CHAR_LIMIT + pos, STATUS_CHAR_LIMIT) dispmsg[i] = statusmsg[i - (STATUS_CHAR_LIMIT + pos)]; } dispmsg[len] = '\0'; if (process == Print) { - DWIN_Draw_Rectangle(1, Color_Grey, 8, 214, DWIN_WIDTH - 8, 238); - const int8_t npos = (DWIN_WIDTH - 30 * MENU_CHR_W) / 2; - DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.status_bar_text, Color_White), Color_Bg_Black, npos, 219, dispmsg); + DWIN_Draw_Rectangle(1, Def_StatusBg_Color, 8, 214, DWIN_WIDTH - 8, 238); + const int8_t npos = (DWIN_WIDTH - STATUS_CHAR_LIMIT * MENU_CHR_W) / 2; + DWINUI::Draw_String(GetColor(eeprom_settings.status_bar_text, Def_StatusTxt_Color), Def_StatusBg_Color, npos, 219, dispmsg); } else { - DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 352, DWIN_WIDTH - 8, 376); - const int8_t npos = (DWIN_WIDTH - 30 * MENU_CHR_W) / 2; - DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.status_bar_text, Color_White), Color_Bg_Black, npos, 357, dispmsg); + DWIN_Draw_Rectangle(1, Def_StatusBg_Color, 8, 352, DWIN_WIDTH - 8, 376); + const int8_t npos = (DWIN_WIDTH - STATUS_CHAR_LIMIT * MENU_CHR_W) / 2; + DWINUI::Draw_String(GetColor(eeprom_settings.status_bar_text, Def_StatusTxt_Color), Def_StatusBg_Color, npos, 357, dispmsg); } - if (-pos >= 30) msgscrl = 0; + if (-pos >= STATUS_CHAR_LIMIT) msgscrl = 0; msgscrl++; } else { if (new_msg) { new_msg = false; if (process == Print) { - DWIN_Draw_Rectangle(1, Color_Grey, 8, 214, DWIN_WIDTH - 8, 238); + DWIN_Draw_Rectangle(1, Def_StatusBg_Color, 8, 214, DWIN_WIDTH - 8, 238); const int8_t npos = (DWIN_WIDTH - strlen(statusmsg) * MENU_CHR_W) / 2; - DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.status_bar_text, Color_White), Color_Bg_Black, npos, 219, statusmsg); + DWINUI::Draw_String(GetColor(eeprom_settings.status_bar_text, Def_StatusTxt_Color), Def_StatusBg_Color, npos, 219, statusmsg); } else { - DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 352, DWIN_WIDTH - 8, 376); + DWIN_Draw_Rectangle(1, Def_StatusBg_Color, 8, 352, DWIN_WIDTH - 8, 376); const int8_t npos = (DWIN_WIDTH - strlen(statusmsg) * MENU_CHR_W) / 2; - DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.status_bar_text, Color_White), Color_Bg_Black, npos, 357, statusmsg); + DWINUI::Draw_String(GetColor(eeprom_settings.status_bar_text, Def_StatusTxt_Color), Def_StatusBg_Color, npos, 357, statusmsg); } } } } +#if HAS_HOSTACTION_MENUS + + void CrealityDWINClass::Draw_Keyboard(bool restrict, bool numeric, uint8_t selected, bool uppercase/*=false*/, bool lock/*=false*/) { + process = Keyboard; + keyboard_restrict = restrict; + numeric_keyboard = numeric; + DWIN_Draw_Rectangle(0, Def_SplitLine_Color, 0, KEY_Y_START, DWIN_WIDTH-2, DWIN_HEIGHT-2); + DWIN_Draw_Rectangle(1, Def_Background_Color, 1, KEY_Y_START+1, DWIN_WIDTH-3, DWIN_HEIGHT-3); + LOOP_L_N(i, 36) Draw_Keys(i, (i == selected), uppercase, lock); + } + + void CrealityDWINClass::Draw_Keys(uint8_t index, bool selected, bool uppercase/*=false*/, bool lock/*=false*/) { + const char *keys; + if (numeric_keyboard) keys = "1234567890&<>() {}[]*\"\':;!?"; + else keys = (uppercase) ? "QWERTYUIOPASDFGHJKLZXCVBNM" : "qwertyuiopasdfghjklzxcvbnm"; + #define KEY_X1(x) x*KEY_WIDTH+KEY_INSET+KEY_PADDING + #define KEY_X2(x) (x+1) * KEY_WIDTH+KEY_INSET-KEY_PADDING + #define KEY_Y1(y) KEY_Y_START+KEY_INSET+KEY_PADDING+y*KEY_HEIGHT + #define KEY_Y2(y) KEY_Y_START+KEY_INSET-KEY_PADDING+(y+1) * KEY_HEIGHT + + const uint8_t rowCount[3] = { 10, 9, 7 }; + const float xOffset[3] = { 0, 0.5f * KEY_WIDTH, 1.5f * KEY_WIDTH }; + + if (index < 28) { + if (index == 19) { + DWIN_Draw_Rectangle(0, Color_Light_Blue, KEY_X1(0), KEY_Y1(2), KEY_X2(0) + xOffset[1], KEY_Y2(2)); + DWIN_Draw_Rectangle(0, (selected) ? Def_Selected_Color : Def_Background_Color, KEY_X1(0) + 1, KEY_Y1(2) + 1, KEY_X2(0) + xOffset[1] - 1, KEY_Y2(2) - 1); + if (!numeric_keyboard) { + if (lock) { + DWIN_Draw_Line(Def_Selected_Color, KEY_X1(0) + 17, KEY_Y1(2) + 16, KEY_X1(0) + 25, KEY_Y1(2) + 8); + DWIN_Draw_Line(Def_Selected_Color, KEY_X1(0) + 17, KEY_Y1(2) + 16, KEY_X1(0) + 9, KEY_Y1(2) + 8); + } + else { + DWIN_Draw_Line((uppercase) ? Def_Selected_Color : Def_Text_Color, KEY_X1(0) + 17, KEY_Y1(2) + 8, KEY_X1(0) + 25, KEY_Y1(2) + 16); + DWIN_Draw_Line((uppercase) ? Def_Selected_Color : Def_Text_Color, KEY_X1(0) + 17, KEY_Y1(2) + 8, KEY_X1(0) + 9, KEY_Y1(2) + 16); + } + } + } + else if (index == 27) { + DWIN_Draw_Rectangle(0, Color_Light_Blue, KEY_X1(7) + xOffset[2], KEY_Y1(2), KEY_X2(9), KEY_Y2(2)); + DWIN_Draw_Rectangle(0, (selected) ? Def_Selected_Color : Def_Background_Color, KEY_X1(7) + xOffset[2] + 1, KEY_Y1(2) + 1, KEY_X2(9) - 1, KEY_Y2(2) - 1); + DWINUI::Draw_String(Color_Red, KEY_X1(7) + xOffset[2] + 3, KEY_Y1(2) + 5, F("<--")); + } + else { + if (index > 19) index--; + if (index > 27) index--; + uint8_t y, x; + if (index < rowCount[0]) y = 0, x = index; + else if (index < (rowCount[0] + rowCount[1])) y = 1, x = index-rowCount[0]; + else y = 2, x = index-(rowCount[0] + rowCount[1]); + const char keyStr[2] = {keys[(y > 0) * rowCount[0] + (y > 1) * rowCount[1] + x], '\0'}; + DWIN_Draw_Rectangle(0, Color_Light_Blue, KEY_X1(x) + xOffset[y], KEY_Y1(y), KEY_X2(x) + xOffset[y], KEY_Y2(y)); + DWIN_Draw_Rectangle(0, (selected) ? Def_Selected_Color : Def_Background_Color, KEY_X1(x) + xOffset[y] + 1, KEY_Y1(y) + 1, KEY_X2(x) + xOffset[y] - 1, KEY_Y2(y) - 1); + DWINUI::Draw_String(KEY_X1(x) + xOffset[y] + 5, KEY_Y1(y) + 5, keyStr); + if (keyboard_restrict && numeric_keyboard && index > 9) { + DWIN_Draw_Line(Color_Light_Red, KEY_X1(x) + xOffset[y] + 1, KEY_Y1(y) + 1, KEY_X2(x) + xOffset[y] - 1, KEY_Y2(y) - 1); + DWIN_Draw_Line(Color_Light_Red, KEY_X1(x) + xOffset[y] + 1, KEY_Y2(y) - 1, KEY_X2(x) + xOffset[y] - 1, KEY_Y1(y) + 1); + } + } + } + else { + switch (index) { + case 28: + DWIN_Draw_Rectangle(0, Color_Light_Blue, KEY_X1(0), KEY_Y1(3), KEY_X2(0) + xOffset[1], KEY_Y2(3)); + DWIN_Draw_Rectangle(0, (selected) ? Def_Selected_Color : Def_Background_Color, KEY_X1(0) + 1, KEY_Y1(3) + 1, KEY_X2(0) + xOffset[1] - 1, KEY_Y2(3) - 1); + DWINUI::Draw_String(KEY_X1(0) - 1, KEY_Y1(3) + 5, F("?123")); + break; + case 29: + DWIN_Draw_Rectangle(0, Color_Light_Blue, KEY_X1(1) + xOffset[1], KEY_Y1(3), KEY_X2(1) + xOffset[1], KEY_Y2(3)); + DWIN_Draw_Rectangle(0, (selected) ? Def_Selected_Color : Def_Background_Color, KEY_X1(1) + xOffset[1] + 1, KEY_Y1(3) + 1, KEY_X2(1) + xOffset[1] - 1, KEY_Y2(3) - 1); + DWINUI::Draw_String(KEY_X1(1) + xOffset[1] + 5, KEY_Y1(3) + 5, F("-")); + break; + case 30: + DWIN_Draw_Rectangle(0, Color_Light_Blue, KEY_X1(2) + xOffset[1], KEY_Y1(3), KEY_X2(2) + xOffset[1], KEY_Y2(3)); + DWIN_Draw_Rectangle(0, (selected) ? Def_Selected_Color : Def_Background_Color, KEY_X1(2) + xOffset[1] + 1, KEY_Y1(3) + 1, KEY_X2(2) + xOffset[1] - 1, KEY_Y2(3) - 1); + DWINUI::Draw_String(KEY_X1(2) + xOffset[1] + 5, KEY_Y1(3) + 5, F("_")); + break; + case 31: + DWIN_Draw_Rectangle(0, Color_Light_Blue, KEY_X1(3) + xOffset[1], KEY_Y1(3), KEY_X2(5) + xOffset[1], KEY_Y2(3)); + DWIN_Draw_Rectangle(0, (selected) ? Def_Selected_Color : Def_Background_Color, KEY_X1(3) + xOffset[1] + 1, KEY_Y1(3) + 1, KEY_X2(5) + xOffset[1] - 1, KEY_Y2(3) - 1); + DWINUI::Draw_String(KEY_X1(3) + xOffset[1] + 14, KEY_Y1(3) + 5, F("Space")); + if (keyboard_restrict) { + DWIN_Draw_Line(Color_Light_Red, KEY_X1(3) + xOffset[1] + 1, KEY_Y1(3) + 1, KEY_X2(5) + xOffset[1] - 1, KEY_Y2(3) - 1); + DWIN_Draw_Line(Color_Light_Red, KEY_X1(3) + xOffset[1] + 1, KEY_Y2(3) - 1, KEY_X2(5) + xOffset[1] - 1, KEY_Y1(3) + 1); + } + break; + case 32: + DWIN_Draw_Rectangle(0, Color_Light_Blue, KEY_X1(6) + xOffset[1], KEY_Y1(3), KEY_X2(6) + xOffset[1], KEY_Y2(3)); + DWIN_Draw_Rectangle(0, (selected) ? Def_Selected_Color : Def_Background_Color, KEY_X1(6) + xOffset[1] + 1, KEY_Y1(3) + 1, KEY_X2(6) + xOffset[1] - 1, KEY_Y2(3) - 1); + DWINUI::Draw_String(KEY_X1(6) + xOffset[1] + 7, KEY_Y1(3) + 5, F(".")); + if (keyboard_restrict) { + DWIN_Draw_Line(Color_Light_Red, KEY_X1(6) + xOffset[1] + 1, KEY_Y1(3) + 1, KEY_X2(6) + xOffset[1] - 1, KEY_Y2(3) - 1); + DWIN_Draw_Line(Color_Light_Red, KEY_X1(6) + xOffset[1] + 1, KEY_Y2(3) - 1, KEY_X2(6) + xOffset[1] - 1, KEY_Y1(3) + 1); + } + break; + case 33: + DWIN_Draw_Rectangle(0, Color_Light_Blue, KEY_X1(7) + xOffset[1], KEY_Y1(3), KEY_X2(7) + xOffset[1], KEY_Y2(3)); + DWIN_Draw_Rectangle(0, (selected) ? Def_Selected_Color : Def_Background_Color, KEY_X1(7) + xOffset[1] + 1, KEY_Y1(3) + 1, KEY_X2(7) + xOffset[1] - 1, KEY_Y2(3) - 1); + DWINUI::Draw_String(KEY_X1(7) + xOffset[1] + 4, KEY_Y1(3) + 5, F("/")); + if (keyboard_restrict) { + DWIN_Draw_Line(Color_Light_Red, KEY_X1(7) + xOffset[1] + 1, KEY_Y1(3) + 1, KEY_X2(7) + xOffset[1] - 1, KEY_Y2(3) - 1); + DWIN_Draw_Line(Color_Light_Red, KEY_X1(7) + xOffset[1] + 1, KEY_Y2(3) - 1, KEY_X2(7) + xOffset[1] - 1, KEY_Y1(3) + 1); + } + break; + case 34: + DWIN_Draw_Rectangle(0, Color_Light_Blue, KEY_X1(7) + xOffset[2], KEY_Y1(3), KEY_X2(9), KEY_Y2(3)); + DWIN_Draw_Rectangle(0, (selected) ? Def_Selected_Color : Def_Background_Color, KEY_X1(7) + xOffset[2] + 1, KEY_Y1(3) + 1, KEY_X2(9) - 1, KEY_Y2(3) - 1); + DWINUI::Draw_String(Color_Cyan, KEY_X1(7) + xOffset[2] + 3, KEY_Y1(3) + 5, F("-->")); + break; + } + } + } +#endif // HAS_HOSTACTION_MENUS + /* Menu Item Config */ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/*=true*/) { @@ -1047,7 +1234,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case PREHEAT_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(TempMenu, sel); break; @@ -1074,7 +1261,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if HAS_FAN case PREHEAT_SUBMENU_FAN: if (draw) { - Draw_Menu_Item(row, ICON_FanSpeed, F("Fan")); + Draw_Menu_Item(row, ICON_FanSpeed, GET_TEXT_F(MSG_FAN_SPEED)); Draw_Float(ui.material_preset[index].fan_speed, row, false, 1); } else @@ -1098,37 +1285,38 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #define PREPARE_PREHEAT (PREPARE_ZOFFSET + ENABLED(HAS_PREHEAT)) #define PREPARE_COOLDOWN (PREPARE_PREHEAT + EITHER(HAS_HOTEND, HAS_HEATED_BED)) #define PREPARE_CHANGEFIL (PREPARE_COOLDOWN + ENABLED(ADVANCED_PAUSE_FEATURE)) - #define PREPARE_CUSTOM_MENU (PREPARE_CHANGEFIL + ENABLED(HAS_CUSTOM_MENU)) - #define PREPARE_TOTAL PREPARE_CUSTOM_MENU + #define PREPARE_ACTIONCOMMANDS (PREPARE_CHANGEFIL + ENABLED(HAS_HOSTACTION_MENUS)) + #define PREPARE_CUSTOM_MENU (PREPARE_ACTIONCOMMANDS + ENABLED(HAS_CUSTOM_MENU)) + #define PREPARE_TOTAL PREPARE_ACTIONCOMMANDS switch (item) { case PREPARE_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Main_Menu(1); break; case PREPARE_MOVE: if (draw) - Draw_Menu_Item(row, ICON_Axis, F("Move"), nullptr, true); + Draw_Menu_Item(row, ICON_Axis, GET_TEXT_F(MSG_MOVE_AXIS), nullptr, true); else Draw_Menu(Move); break; case PREPARE_DISABLE: if (draw) - Draw_Menu_Item(row, ICON_CloseMotor, F("Disable Stepper")); + Draw_Menu_Item(row, ICON_CloseMotor, GET_TEXT_F(MSG_DISABLE_STEPPERS)); else queue.inject(F("M84")); break; case PREPARE_HOME: if (draw) - Draw_Menu_Item(row, ICON_SetHome, F("Homing"), nullptr, true); + Draw_Menu_Item(row, ICON_SetHome, GET_TEXT_F(MSG_HOMING), nullptr, true); else Draw_Menu(HomeMenu); break; case PREPARE_MANUALLEVEL: if (draw) - Draw_Menu_Item(row, ICON_PrintSize, F("Manual Leveling"), nullptr, true); + Draw_Menu_Item(row, ICON_PrintSize, GET_TEXT_F(MSG_BED_TRAMMING_MANUAL), nullptr, true); else { if (axes_should_home()) { Popup_Handler(Home); @@ -1168,12 +1356,23 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if HAS_HOTEND || HAS_HEATED_BED case PREPARE_COOLDOWN: if (draw) - Draw_Menu_Item(row, ICON_Cool, F("Cooldown")); - else + Draw_Menu_Item(row, ICON_Cool, GET_TEXT_F(MSG_COOLDOWN)); + else { thermalManager.cooldown(); + Update_Status(GET_TEXT(MSG_COOLDOWN)); + } break; #endif + #if HAS_HOSTACTION_MENUS + case PREPARE_ACTIONCOMMANDS: + if (draw) + Draw_Menu_Item(row, ICON_SetHome, F("Host Actions"), nullptr, true); + else + Draw_Menu(HostActions); + break; + #endif + #if HAS_CUSTOM_MENU case PREPARE_CUSTOM_MENU: #ifndef CUSTOM_MENU_CONFIG_TITLE @@ -1189,7 +1388,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if ENABLED(ADVANCED_PAUSE_FEATURE) case PREPARE_CHANGEFIL: if (draw) { - Draw_Menu_Item(row, ICON_ResumeEEPROM, F("Change Filament") + Draw_Menu_Item(row, ICON_ResumeEEPROM, GET_TEXT_F(MSG_FILAMENTCHANGE) #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) , nullptr, true #endif @@ -1230,13 +1429,13 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case HOME_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(Prepare, PREPARE_HOME); break; case HOME_ALL: if (draw) - Draw_Menu_Item(row, ICON_Homing, F("Home All")); + Draw_Menu_Item(row, ICON_Homing, GET_TEXT_F(MSG_AUTO_HOME)); else { Popup_Handler(Home); gcode.home_all_axes(true); @@ -1245,7 +1444,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case HOME_X: if (draw) - Draw_Menu_Item(row, ICON_MoveX, F("Home X")); + Draw_Menu_Item(row, ICON_MoveX, GET_TEXT_F(MSG_AUTO_HOME_X)); else { Popup_Handler(Home); gcode.process_subcommands_now(F("G28 X")); @@ -1255,7 +1454,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case HOME_Y: if (draw) - Draw_Menu_Item(row, ICON_MoveY, F("Home Y")); + Draw_Menu_Item(row, ICON_MoveY, GET_TEXT_F(MSG_AUTO_HOME_Y)); else { Popup_Handler(Home); gcode.process_subcommands_now(F("G28 Y")); @@ -1265,7 +1464,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case HOME_Z: if (draw) - Draw_Menu_Item(row, ICON_MoveZ, F("Home Z")); + Draw_Menu_Item(row, ICON_MoveZ, GET_TEXT_F(MSG_AUTO_HOME_Z)); else { Popup_Handler(Home); gcode.process_subcommands_now(F("G28 Z")); @@ -1275,7 +1474,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case HOME_SET: if (draw) - Draw_Menu_Item(row, ICON_SetHome, F("Set Home Position")); + Draw_Menu_Item(row, ICON_SetHome, GET_TEXT_F(MSG_SET_HOME_OFFSETS)); else { gcode.process_subcommands_now(F("G92X0Y0Z0")); AudioFeedback(); @@ -1298,18 +1497,18 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case MOVE_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else { #if HAS_BED_PROBE - probe_deployed = false; - probe.set_deployed(probe_deployed); + temp_val.probe_deployed = false; + probe.set_deployed(temp_val.probe_deployed); #endif Draw_Menu(Prepare, PREPARE_MOVE); } break; case MOVE_X: if (draw) { - Draw_Menu_Item(row, ICON_MoveX, F("Move X")); + Draw_Menu_Item(row, ICON_MoveX, GET_TEXT_F(MSG_MOVE_X)); Draw_Float(current_position.x, row, false); } else @@ -1317,7 +1516,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case MOVE_Y: if (draw) { - Draw_Menu_Item(row, ICON_MoveY, F("Move Y")); + Draw_Menu_Item(row, ICON_MoveY, GET_TEXT_F(MSG_MOVE_Y)); Draw_Float(current_position.y, row); } else @@ -1325,7 +1524,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case MOVE_Z: if (draw) { - Draw_Menu_Item(row, ICON_MoveZ, F("Move Z")); + Draw_Menu_Item(row, ICON_MoveZ, GET_TEXT_F(MSG_MOVE_Z)); Draw_Float(current_position.z, row); } else @@ -1335,15 +1534,14 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if HAS_HOTEND case MOVE_E: if (draw) { - Draw_Menu_Item(row, ICON_Extruder, F("Extruder")); + Draw_Menu_Item(row, ICON_Extruder, GET_TEXT_F(MSG_MOVE_E)); current_position.e = 0; sync_plan_position(); Draw_Float(current_position.e, row); } else { - if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) { + if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) Popup_Handler(ETemp); - } else { if (thermalManager.temp_hotend[0].is_below_target(-2)) { Popup_Handler(Heating); @@ -1361,13 +1559,13 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if HAS_BED_PROBE case MOVE_P: if (draw) { - Draw_Menu_Item(row, ICON_StockConfiguration, F("Probe")); - Draw_Checkbox(row, probe_deployed); + Draw_Menu_Item(row, ICON_ProbeDeploy, GET_TEXT_F(MSG_MANUAL_DEPLOY)); + Draw_Checkbox(row, temp_val.probe_deployed); } else { - probe_deployed = !probe_deployed; - probe.set_deployed(probe_deployed); - Draw_Checkbox(row, probe_deployed); + temp_val.probe_deployed = !temp_val.probe_deployed; + probe.set_deployed(temp_val.probe_deployed); + Draw_Checkbox(row, temp_val.probe_deployed); } break; #endif @@ -1375,11 +1573,11 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case MOVE_LIVE: if (draw) { Draw_Menu_Item(row, ICON_Axis, F("Live Movement")); - Draw_Checkbox(row, livemove); + Draw_Checkbox(row, temp_val.livemove); } else { - livemove = !livemove; - Draw_Checkbox(row, livemove); + temp_val.livemove = !temp_val.livemove; + Draw_Checkbox(row, temp_val.livemove); } break; } @@ -1388,11 +1586,11 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #define MLEVEL_BACK 0 #define MLEVEL_PROBE (MLEVEL_BACK + ENABLED(HAS_BED_PROBE)) - #define MLEVEL_BL (MLEVEL_PROBE + 1) - #define MLEVEL_TL (MLEVEL_BL + 1) - #define MLEVEL_TR (MLEVEL_TL + 1) - #define MLEVEL_BR (MLEVEL_TR + 1) - #define MLEVEL_C (MLEVEL_BR + 1) + #define MLEVEL_FL (MLEVEL_PROBE + 1) + #define MLEVEL_BL (MLEVEL_FL + 1) + #define MLEVEL_BR (MLEVEL_BL + 1) + #define MLEVEL_FR (MLEVEL_BR + 1) + #define MLEVEL_C (MLEVEL_FR + 1) #define MLEVEL_ZPOS (MLEVEL_C + 1) #define MLEVEL_TOTAL MLEVEL_ZPOS @@ -1402,7 +1600,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case MLEVEL_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else { TERN_(HAS_LEVELING, set_bed_leveling_enabled(level_state)); Draw_Menu(Prepare, PREPARE_MANUALLEVEL); @@ -1419,24 +1617,46 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ Draw_Checkbox(row, use_probe); if (use_probe) { Popup_Handler(Level); - corner_avg = 0; - #define PROBE_X_MIN _MAX(0 + corner_pos, X_MIN_POS + probe.offset.x, X_MIN_POS + PROBING_MARGIN) - probe.offset.x - #define PROBE_X_MAX _MIN((X_BED_SIZE + X_MIN_POS) - corner_pos, X_MAX_POS + probe.offset.x, X_MAX_POS - PROBING_MARGIN) - probe.offset.x - #define PROBE_Y_MIN _MAX(0 + corner_pos, Y_MIN_POS + probe.offset.y, Y_MIN_POS + PROBING_MARGIN) - probe.offset.y - #define PROBE_Y_MAX _MIN((Y_BED_SIZE + Y_MIN_POS) - corner_pos, Y_MAX_POS + probe.offset.y, Y_MAX_POS - PROBING_MARGIN) - probe.offset.y - corner_avg += probe.probe_at_point(PROBE_X_MIN, PROBE_Y_MIN, PROBE_PT_RAISE, 0, false); - corner_avg += probe.probe_at_point(PROBE_X_MIN, PROBE_Y_MAX, PROBE_PT_RAISE, 0, false); - corner_avg += probe.probe_at_point(PROBE_X_MAX, PROBE_Y_MAX, PROBE_PT_RAISE, 0, false); - corner_avg += probe.probe_at_point(PROBE_X_MAX, PROBE_Y_MIN, PROBE_PT_STOW, 0, false); - corner_avg /= 4; + do_z_clearance(Z_HOMING_HEIGHT); + temp_val.corner_avg = 0; + #define PROBE_X_MIN _MAX(temp_val.corner_pos, PROBING_MARGIN, MESH_MIN_X) - probe.offset.x + #define PROBE_X_MAX _MIN(X_BED_SIZE - temp_val.corner_pos, X_BED_SIZE - PROBING_MARGIN, MESH_MAX_X) - probe.offset.x + #define PROBE_Y_MIN _MAX(temp_val.corner_pos, PROBING_MARGIN, MESH_MIN_Y) - probe.offset.y + #define PROBE_Y_MAX _MIN(Y_BED_SIZE - temp_val.corner_pos, Y_BED_SIZE - PROBING_MARGIN, MESH_MAX_Y) - probe.offset.y + temp_val.zval = probe.probe_at_point(PROBE_X_MIN, PROBE_Y_MIN, PROBE_PT_RAISE, 0, false); + const char * MSG_UNREACHABLE = "Position unreachable. Check Probe Offsets and Bed Screw Inset."; + if (isnan(temp_val.zval)) { + Update_Status(MSG_UNREACHABLE); + Redraw_Menu(); + } + temp_val.corner_avg += temp_val.zval; + temp_val.zval = probe.probe_at_point(PROBE_X_MIN, PROBE_Y_MAX, PROBE_PT_RAISE, 0, false); + if (isnan(temp_val.zval)) { + Update_Status(MSG_UNREACHABLE); + Redraw_Menu(); + } + temp_val.corner_avg += temp_val.zval; + temp_val.zval = probe.probe_at_point(PROBE_X_MAX, PROBE_Y_MAX, PROBE_PT_RAISE, 0, false); + if (isnan(temp_val.zval)) { + Update_Status(MSG_UNREACHABLE); + Redraw_Menu(); + } + temp_val.corner_avg += temp_val.zval; + temp_val.zval = probe.probe_at_point(PROBE_X_MAX, PROBE_Y_MIN, PROBE_PT_STOW, 0, false); + if (isnan(temp_val.zval)) { + Update_Status(MSG_UNREACHABLE); + Redraw_Menu(); + } + temp_val.corner_avg += temp_val.zval; + temp_val.corner_avg /= 4; Redraw_Menu(); } } break; #endif - case MLEVEL_BL: + case MLEVEL_FL: if (draw) - Draw_Menu_Item(row, ICON_AxisBL, F("Bottom Left")); + Draw_Menu_Item(row, ICON_AxisBL, GET_TEXT_F(MSG_LEVBED_FL)); else { Popup_Handler(MoveWait); if (use_probe) { @@ -1448,16 +1668,16 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #endif } else { - sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s\nG0 F300 Z%s"), dtostrf(corner_pos, 1, 3, str_1), dtostrf(corner_pos, 1, 3, str_2), dtostrf(mlev_z_pos, 1, 3, str_3)); + sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s\nG0 F300 Z%s"), dtostrf(temp_val.corner_pos, 1, 3, str_1), dtostrf(temp_val.corner_pos, 1, 3, str_2), dtostrf(mlev_z_pos, 1, 3, str_3)); gcode.process_subcommands_now(cmd); planner.synchronize(); Redraw_Menu(); } } break; - case MLEVEL_TL: + case MLEVEL_BL: if (draw) - Draw_Menu_Item(row, ICON_AxisTL, F("Top Left")); + Draw_Menu_Item(row, ICON_AxisTL, GET_TEXT_F(MSG_LEVBED_BL)); else { Popup_Handler(MoveWait); if (use_probe) { @@ -1469,16 +1689,16 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #endif } else { - sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s\nG0 F300 Z%s"), dtostrf(corner_pos, 1, 3, str_1), dtostrf((Y_BED_SIZE + Y_MIN_POS) - corner_pos, 1, 3, str_2), dtostrf(mlev_z_pos, 1, 3, str_3)); + sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s\nG0 F300 Z%s"), dtostrf(temp_val.corner_pos, 1, 3, str_1), dtostrf(Y_BED_SIZE - temp_val.corner_pos, 1, 3, str_2), dtostrf(mlev_z_pos, 1, 3, str_3)); gcode.process_subcommands_now(cmd); planner.synchronize(); Redraw_Menu(); } } break; - case MLEVEL_TR: + case MLEVEL_BR: if (draw) - Draw_Menu_Item(row, ICON_AxisTR, F("Top Right")); + Draw_Menu_Item(row, ICON_AxisTR, GET_TEXT_F(MSG_LEVBED_BR)); else { Popup_Handler(MoveWait); if (use_probe) { @@ -1490,16 +1710,16 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #endif } else { - sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s\nG0 F300 Z%s"), dtostrf((X_BED_SIZE + X_MIN_POS) - corner_pos, 1, 3, str_1), dtostrf((Y_BED_SIZE + Y_MIN_POS) - corner_pos, 1, 3, str_2), dtostrf(mlev_z_pos, 1, 3, str_3)); + sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s\nG0 F300 Z%s"), dtostrf(X_BED_SIZE - temp_val.corner_pos, 1, 3, str_1), dtostrf(Y_BED_SIZE - temp_val.corner_pos, 1, 3, str_2), dtostrf(mlev_z_pos, 1, 3, str_3)); gcode.process_subcommands_now(cmd); planner.synchronize(); Redraw_Menu(); } } break; - case MLEVEL_BR: + case MLEVEL_FR: if (draw) - Draw_Menu_Item(row, ICON_AxisBR, F("Bottom Right")); + Draw_Menu_Item(row, ICON_AxisBR, GET_TEXT_F(MSG_LEVBED_FR)); else { Popup_Handler(MoveWait); if (use_probe) { @@ -1511,7 +1731,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #endif } else { - sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s\nG0 F300 Z%s"), dtostrf((X_BED_SIZE + X_MIN_POS) - corner_pos, 1, 3, str_1), dtostrf(corner_pos, 1, 3, str_2), dtostrf(mlev_z_pos, 1, 3, str_3)); + sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s\nG0 F300 Z%s"), dtostrf(X_BED_SIZE - temp_val.corner_pos, 1, 3, str_1), dtostrf(temp_val.corner_pos, 1, 3, str_2), dtostrf(mlev_z_pos, 1, 3, str_3)); gcode.process_subcommands_now(cmd); planner.synchronize(); Redraw_Menu(); @@ -1520,19 +1740,19 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case MLEVEL_C: if (draw) - Draw_Menu_Item(row, ICON_AxisC, F("Center")); + Draw_Menu_Item(row, ICON_AxisC, GET_TEXT_F(MSG_LEVBED_C)); else { Popup_Handler(MoveWait); if (use_probe) { #if HAS_BED_PROBE - sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s"), dtostrf(X_MAX_POS / 2.0f - probe.offset.x, 1, 3, str_1), dtostrf(Y_MAX_POS / 2.0f - probe.offset.y, 1, 3, str_2)); + sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s"), dtostrf((PROBE_X_MIN + PROBE_X_MAX) / 2.0f, 1, 3, str_1), dtostrf((PROBE_Y_MIN + PROBE_Y_MAX) / 2.0f, 1, 3, str_2)); gcode.process_subcommands_now(cmd); planner.synchronize(); Popup_Handler(ManualProbing); #endif } else { - sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s\nG0 F300 Z%s"), dtostrf((X_BED_SIZE + X_MIN_POS) / 2.0f, 1, 3, str_1), dtostrf((Y_BED_SIZE + Y_MIN_POS) / 2.0f, 1, 3, str_2), dtostrf(mlev_z_pos, 1, 3, str_3)); + sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s\nG0 F300 Z%s"), dtostrf(X_BED_SIZE / 2.0f, 1, 3, str_1), dtostrf(Y_BED_SIZE / 2.0f, 1, 3, str_2), dtostrf(mlev_z_pos, 1, 3, str_3)); gcode.process_subcommands_now(cmd); planner.synchronize(); Redraw_Menu(); @@ -1541,7 +1761,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case MLEVEL_ZPOS: if (draw) { - Draw_Menu_Item(row, ICON_SetZOffset, F("Z Position")); + Draw_Menu_Item(row, ICON_SetZOffset, GET_TEXT_F(MSG_MOVE_Z)); Draw_Float(mlev_z_pos, row, false, 100); } else @@ -1564,16 +1784,19 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case ZOFFSET_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else { - liveadjust = false; + temp_val.zoffsetmode = 0; + #if !HAS_BED_PROBE + gcode.process_subcommands_now(F("M211 S1")); // Soft end-stops + #endif TERN_(HAS_LEVELING, set_bed_leveling_enabled(level_state)); Draw_Menu(Prepare, PREPARE_ZOFFSET); } break; case ZOFFSET_HOME: if (draw) - Draw_Menu_Item(row, ICON_Homing, F("Home Z Axis")); + Draw_Menu_Item(row, ICON_Homing, GET_TEXT_F(MSG_AUTO_HOME_Z)); else { Popup_Handler(Home); gcode.process_subcommands_now(F("G28 Z")); @@ -1583,7 +1806,8 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ sprintf_P(cmd, PSTR("G0 F4000 X%s Y%s"), dtostrf(Z_SAFE_HOMING_X_POINT, 1, 3, str_1), dtostrf(Z_SAFE_HOMING_Y_POINT, 1, 3, str_2)); gcode.process_subcommands_now(cmd); #else - gcode.process_subcommands_now(F("G0 F4000 X117.5 Y117.5")); + sprintf_P(cmd, PSTR("G0 F4000 X%s Y%s"), dtostrf((X_BED_SIZE + X_MIN_POS) / 2.0f, 1, 3, str_1), dtostrf((Y_BED_SIZE + Y_MIN_POS) / 2.0f, 1, 3, str_2)); + gcode.process_subcommands_now(cmd); #endif gcode.process_subcommands_now(F("G0 F300 Z0")); planner.synchronize(); @@ -1593,49 +1817,30 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case ZOFFSET_MODE: if (draw) { Draw_Menu_Item(row, ICON_Zoffset, F("Live Adjustment")); - Draw_Checkbox(row, liveadjust); - } - else { - if (!liveadjust) { - if (axes_should_home()) { - Popup_Handler(Home); - gcode.home_all_axes(true); - } - Popup_Handler(MoveWait); - #if ENABLED(Z_SAFE_HOMING) - planner.synchronize(); - sprintf_P(cmd, PSTR("G0 F4000 X%s Y%s"), dtostrf(Z_SAFE_HOMING_X_POINT, 1, 3, str_1), dtostrf(Z_SAFE_HOMING_Y_POINT, 1, 3, str_2)); - gcode.process_subcommands_now(cmd); - #else - gcode.process_subcommands_now(F("G0 F4000 X117.5 Y117.5")); - #endif - gcode.process_subcommands_now(F("G0 F300 Z0")); - planner.synchronize(); - Redraw_Menu(); - } - liveadjust = !liveadjust; - Draw_Checkbox(row, liveadjust); + Draw_Option(temp_val.zoffsetmode, zoffset_modes, row); } + else + Modify_Option(temp_val.zoffsetmode, zoffset_modes, 2); break; case ZOFFSET_OFFSET: if (draw) { Draw_Menu_Item(row, ICON_SetZOffset, F("Z Offset")); - Draw_Float(zoffsetvalue, row, false, 100); + Draw_Float(temp_val.zoffsetvalue, row, false, 100); } else - Modify_Value(zoffsetvalue, MIN_Z_OFFSET, MAX_Z_OFFSET, 100); + Modify_Value(temp_val.zoffsetvalue, MIN_Z_OFFSET, MAX_Z_OFFSET, 100); break; case ZOFFSET_UP: if (draw) Draw_Menu_Item(row, ICON_Axis, F("Microstep Up")); else { - if (zoffsetvalue < MAX_Z_OFFSET) { - if (liveadjust) { + if (temp_val.zoffsetvalue < MAX_Z_OFFSET) { + if (temp_val.zoffsetmode != 0) { gcode.process_subcommands_now(F("M290 Z0.01")); planner.synchronize(); } - zoffsetvalue += 0.01; - Draw_Float(zoffsetvalue, row - 1, false, 100); + temp_val.zoffsetvalue += 0.01; + Draw_Float(temp_val.zoffsetvalue, row - 1, false, 100); } } break; @@ -1643,20 +1848,20 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ if (draw) Draw_Menu_Item(row, ICON_AxisD, F("Microstep Down")); else { - if (zoffsetvalue > MIN_Z_OFFSET) { - if (liveadjust) { + if (temp_val.zoffsetvalue > MIN_Z_OFFSET) { + if (temp_val.zoffsetmode != 0) { gcode.process_subcommands_now(F("M290 Z-0.01")); planner.synchronize(); } - zoffsetvalue -= 0.01; - Draw_Float(zoffsetvalue, row - 2, false, 100); + temp_val.zoffsetvalue -= 0.01; + Draw_Float(temp_val.zoffsetvalue, row - 2, false, 100); } } break; #if ENABLED(EEPROM_SETTINGS) case ZOFFSET_SAVE: if (draw) - Draw_Menu_Item(row, ICON_WriteEEPROM, F("Save")); + Draw_Menu_Item(row, ICON_WriteEEPROM, GET_TEXT_F(MSG_BUTTON_SAVE)); else AudioFeedback(settings.save()); break; @@ -1677,25 +1882,25 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ auto do_preheat = [](const uint8_t m) { thermalManager.cooldown(); - if (preheatmode == 0 || preheatmode == 1) { ui.preheat_hotend_and_fan(m); } - if (preheatmode == 0 || preheatmode == 2) ui.preheat_bed(m); + if (temp_val.preheatmode == 0 || temp_val.preheatmode == 1) { ui.preheat_hotend_and_fan(m); } + if (temp_val.preheatmode == 0 || temp_val.preheatmode == 2) ui.preheat_bed(m); }; switch (item) { case PREHEAT_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(Prepare, PREPARE_PREHEAT); break; case PREHEAT_MODE: if (draw) { - Draw_Menu_Item(row, ICON_Homing, F("Preheat Mode")); - Draw_Option(preheatmode, preheat_modes, row); + Draw_Menu_Item(row, ICON_Homing, GET_TEXT_F(MSG_CONFIGURATION)); + Draw_Option(temp_val.preheatmode, preheat_modes, row); } else - Modify_Option(preheatmode, preheat_modes, 2); + Modify_Option(temp_val.preheatmode, preheat_modes, 2); break; #define _PREHEAT_CASE(N) \ @@ -1713,7 +1918,8 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case ChangeFilament: #define CHANGEFIL_BACK 0 - #define CHANGEFIL_LOAD (CHANGEFIL_BACK + 1) + #define CHANGEFIL_PARKHEAD (CHANGEFIL_BACK + 1) + #define CHANGEFIL_LOAD (CHANGEFIL_PARKHEAD + 1) #define CHANGEFIL_UNLOAD (CHANGEFIL_LOAD + 1) #define CHANGEFIL_CHANGE (CHANGEFIL_UNLOAD + 1) #define CHANGEFIL_TOTAL CHANGEFIL_CHANGE @@ -1721,13 +1927,25 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case CHANGEFIL_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(Prepare, PREPARE_CHANGEFIL); break; + case CHANGEFIL_PARKHEAD: + if (draw) + Draw_Menu_Item(row, ICON_Park, GET_TEXT_F(MSG_FILAMENT_PARK_ENABLED)); + else { + #if ENABLED(NOZZLE_PARK_FEATURE) + queue.inject(F("G28O\nG27 P2")); + #else + sprintf_P(cmd, PSTR("G28O\nG0 F4000 X%i Y%i\nG0 F3000 Z%i"), 0 , 0, 20); + queue.inject(cmd); + #endif + } + break; case CHANGEFIL_LOAD: if (draw) - Draw_Menu_Item(row, ICON_WriteEEPROM, F("Load Filament")); + Draw_Menu_Item(row, ICON_WriteEEPROM, GET_TEXT_F(MSG_FILAMENTLOAD)); else { if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) Popup_Handler(ETemp); @@ -1745,7 +1963,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case CHANGEFIL_UNLOAD: if (draw) - Draw_Menu_Item(row, ICON_ReadEEPROM, F("Unload Filament")); + Draw_Menu_Item(row, ICON_ReadEEPROM, GET_TEXT_F(MSG_FILAMENTUNLOAD)); else { if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) { Popup_Handler(ETemp); @@ -1764,7 +1982,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case CHANGEFIL_CHANGE: if (draw) - Draw_Menu_Item(row, ICON_ResumeEEPROM, F("Change Filament")); + Draw_Menu_Item(row, ICON_ResumeEEPROM, GET_TEXT_F(MSG_FILAMENTCHANGE)); else { if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) Popup_Handler(ETemp); @@ -1783,6 +2001,44 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; #endif // FILAMENT_LOAD_UNLOAD_GCODES + #if HAS_HOSTACTION_MENUS + case HostActions: + + #define HOSTACTIONS_BACK 0 + #define HOSTACTIONS_1 (HOSTACTIONS_BACK + 1) + #define HOSTACTIONS_2 (HOSTACTIONS_1 + 1) + #define HOSTACTIONS_3 (HOSTACTIONS_2 + 1) + #define HOSTACTIONS_TOTAL HOSTACTIONS_3 + + switch (item) { + case HOSTACTIONS_BACK: + if (draw) + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); + else { + if (temp_val.flag_tune) { + temp_val.flag_tune = false; + Redraw_Menu(false, true, true); + } + else + Draw_Menu(Prepare, PREPARE_ACTIONCOMMANDS); + } + break; + case HOSTACTIONS_1: + if (draw) Draw_Menu_Item(row, ICON_File, action1); + else if (!strcmp(action1, "-") == 0) hostui.action(F(action1)); + break; + case HOSTACTIONS_2: + if (draw) Draw_Menu_Item(row, ICON_File, action2); + else if (!strcmp(action2, "-") == 0) hostui.action(F(action2)); + break; + case HOSTACTIONS_3: + if (draw) Draw_Menu_Item(row, ICON_File, action3); + else if (!strcmp(action3, "-") == 0) hostui.action(F(action3)); + break; + } + break; + #endif + #if HAS_CUSTOM_MENU case MenuCustom: @@ -1908,70 +2164,104 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #define CONTROL_BACK 0 #define CONTROL_TEMP (CONTROL_BACK + 1) #define CONTROL_MOTION (CONTROL_TEMP + 1) - #define CONTROL_VISUAL (CONTROL_MOTION + 1) - #define CONTROL_ADVANCED (CONTROL_VISUAL + 1) + #define CONTROL_FWRETRACT (CONTROL_MOTION + ENABLED(FWRETRACT)) + #define CONTROL_LEDS (CONTROL_FWRETRACT + ANY(CASE_LIGHT_MENU, LED_CONTROL_MENU)) + #define CONTROL_VISUAL (CONTROL_LEDS + 1) + #define CONTROL_HOSTSETTINGS (CONTROL_VISUAL + ENABLED(HAS_HOSTACTION_MENUS)) + #define CONTROL_ADVANCED (CONTROL_HOSTSETTINGS + 1) #define CONTROL_SAVE (CONTROL_ADVANCED + ENABLED(EEPROM_SETTINGS)) #define CONTROL_RESTORE (CONTROL_SAVE + ENABLED(EEPROM_SETTINGS)) #define CONTROL_RESET (CONTROL_RESTORE + ENABLED(EEPROM_SETTINGS)) - #define CONTROL_INFO (CONTROL_RESET + 1) + #define CONTROL_REBOOT (CONTROL_RESET + 1) + #define CONTROL_INFO (CONTROL_REBOOT + 1) #define CONTROL_TOTAL CONTROL_INFO switch (item) { case CONTROL_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Main_Menu(2); break; case CONTROL_TEMP: if (draw) - Draw_Menu_Item(row, ICON_Temperature, F("Temperature"), nullptr, true); + Draw_Menu_Item(row, ICON_Temperature, GET_TEXT_F(MSG_TEMPERATURE), nullptr, true); else Draw_Menu(TempMenu); break; case CONTROL_MOTION: if (draw) - Draw_Menu_Item(row, ICON_Motion, F("Motion"), nullptr, true); + Draw_Menu_Item(row, ICON_Motion, GET_TEXT_F(MSG_MOTION), nullptr, true); else Draw_Menu(Motion); break; + #if ENABLED(FWRETRACT) + case CONTROL_FWRETRACT: + if (draw) + Draw_Menu_Item(row, ICON_StepE, GET_TEXT_F(MSG_AUTORETRACT), nullptr, true); + else + Draw_Menu(FwRetraction); + break; + #endif + #if ANY(CASE_LIGHT_MENU, LED_CONTROL_MENU) + case CONTROL_LEDS: + if (draw) + Draw_Menu_Item(row, ICON_LedControl, GET_TEXT_F(MSG_LEDS), nullptr, true); + else + Draw_Menu(Ledsmenu); + break; + #endif case CONTROL_VISUAL: if (draw) Draw_Menu_Item(row, ICON_PrintSize, F("Visual"), nullptr, true); else Draw_Menu(Visual); break; + #if HAS_HOSTACTION_MENUS + case CONTROL_HOSTSETTINGS: + if (draw) + Draw_Menu_Item(row, ICON_Contact, F("Host Settings"), nullptr, true); + else + Draw_Menu(HostSettings); + break; + #endif case CONTROL_ADVANCED: if (draw) - Draw_Menu_Item(row, ICON_Version, F("Advanced"), nullptr, true); + Draw_Menu_Item(row, ICON_Version, GET_TEXT_F(MSG_ADVANCED_SETTINGS), nullptr, true); else Draw_Menu(Advanced); break; #if ENABLED(EEPROM_SETTINGS) case CONTROL_SAVE: if (draw) - Draw_Menu_Item(row, ICON_WriteEEPROM, F("Store Settings")); + Draw_Menu_Item(row, ICON_WriteEEPROM, GET_TEXT_F(MSG_STORE_EEPROM)); else AudioFeedback(settings.save()); break; case CONTROL_RESTORE: if (draw) - Draw_Menu_Item(row, ICON_ReadEEPROM, F("Restore Settings")); + Draw_Menu_Item(row, ICON_ReadEEPROM, GET_TEXT_F(MSG_LOAD_EEPROM)); else AudioFeedback(settings.load()); break; case CONTROL_RESET: if (draw) - Draw_Menu_Item(row, ICON_Temperature, F("Reset to Defaults")); + Draw_Menu_Item(row, ICON_Temperature, GET_TEXT_F(MSG_RESTORE_DEFAULTS)); else { settings.reset(); AudioFeedback(); } break; #endif + case CONTROL_REBOOT: + if (draw) + Draw_Menu_Item(row, ICON_Reboot, GET_TEXT_F(MSG_RESET_PRINTER)); + else + RebootPrinter(); + break; case CONTROL_INFO: if (draw) - Draw_Menu_Item(row, ICON_Info, F("Info")); + Draw_Menu_Item(row, ICON_Info, GET_TEXT_F(MSG_INFO_SCREEN)); else Draw_Menu(Info); break; @@ -1995,7 +2285,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case TEMP_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(Control, CONTROL_TEMP); break; @@ -2022,7 +2312,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if HAS_FAN case TEMP_FAN: if (draw) { - Draw_Menu_Item(row, ICON_FanSpeed, F("Fan")); + Draw_Menu_Item(row, ICON_FanSpeed, GET_TEXT_F(MSG_FAN_SPEED)); Draw_Float(thermalManager.fan_speed[0], row, false, 1); } else @@ -2062,14 +2352,14 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case PID_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(TempMenu, TEMP_PID); break; #if HAS_HOTEND case PID_HOTEND: if (draw) - Draw_Menu_Item(row, ICON_HotendTemp, F("Hotend"), nullptr, true); + Draw_Menu_Item(row, ICON_HotendTemp, F(STR_HOTEND_PID), nullptr, true); else Draw_Menu(HotendPID); break; @@ -2077,14 +2367,14 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if HAS_HEATED_BED case PID_BED: if (draw) - Draw_Menu_Item(row, ICON_BedTemp, F("Bed"), nullptr, true); + Draw_Menu_Item(row, ICON_BedTemp, F(STR_BED_PID), nullptr, true); else Draw_Menu(BedPID); break; #endif case PID_CYCLES: if (draw) { - Draw_Menu_Item(row, ICON_FanSpeed, F("Cycles")); + Draw_Menu_Item(row, ICON_FanSpeed, GET_TEXT_F(MSG_PID_CYCLE)); Draw_Float(PID_cycles, row, false, 1); } else @@ -2105,21 +2395,19 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #define HOTENDPID_KD (HOTENDPID_KI + 1) #define HOTENDPID_TOTAL HOTENDPID_KD - static uint16_t PID_e_temp = 180; - switch (item) { case HOTENDPID_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(PID, PID_HOTEND); break; case HOTENDPID_TUNE: if (draw) - Draw_Menu_Item(row, ICON_HotendTemp, F("Autotune")); + Draw_Menu_Item(row, ICON_HotendTemp, GET_TEXT_F(MSG_PID_AUTOTUNE)); else { Popup_Handler(PIDWait); - sprintf_P(cmd, PSTR("M303 E0 C%i S%i U1"), PID_cycles, PID_e_temp); + sprintf_P(cmd, PSTR("M303 E0 C%i S%i U1"), PID_cycles, temp_val.PID_e_temp); gcode.process_subcommands_now(cmd); planner.synchronize(); Redraw_Menu(); @@ -2127,11 +2415,11 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case HOTENDPID_TEMP: if (draw) { - Draw_Menu_Item(row, ICON_Temperature, F("Temperature")); - Draw_Float(PID_e_temp, row, false, 1); + Draw_Menu_Item(row, ICON_Temperature, GET_TEXT_F(MSG_TEMPERATURE)); + Draw_Float(temp_val.PID_e_temp, row, false, 1); } else - Modify_Value(PID_e_temp, MIN_E_TEMP, MAX_E_TEMP, 1); + Modify_Value(temp_val.PID_e_temp, MIN_E_TEMP, MAX_E_TEMP, 1); break; case HOTENDPID_KP: if (draw) { @@ -2172,21 +2460,19 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #define BEDPID_KD (BEDPID_KI + 1) #define BEDPID_TOTAL BEDPID_KD - static uint16_t PID_bed_temp = 60; - switch (item) { case BEDPID_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(PID, PID_BED); break; case BEDPID_TUNE: if (draw) - Draw_Menu_Item(row, ICON_HotendTemp, F("Autotune")); + Draw_Menu_Item(row, ICON_HotendTemp, GET_TEXT_F(MSG_PID_AUTOTUNE)); else { Popup_Handler(PIDWait); - sprintf_P(cmd, PSTR("M303 E-1 C%i S%i U1"), PID_cycles, PID_bed_temp); + sprintf_P(cmd, PSTR("M303 E-1 C%i S%i U1"), PID_cycles, temp_val.PID_bed_temp); gcode.process_subcommands_now(cmd); planner.synchronize(); Redraw_Menu(); @@ -2194,20 +2480,19 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case BEDPID_TEMP: if (draw) { - Draw_Menu_Item(row, ICON_Temperature, F("Temperature")); - Draw_Float(PID_bed_temp, row, false, 1); + Draw_Menu_Item(row, ICON_Temperature, GET_TEXT_F(MSG_TEMPERATURE)); + Draw_Float(temp_val.PID_bed_temp, row, false, 1); } else - Modify_Value(PID_bed_temp, MIN_BED_TEMP, MAX_BED_TEMP, 1); + Modify_Value(temp_val.PID_bed_temp, MIN_BED_TEMP, MAX_BED_TEMP, 1); break; case BEDPID_KP: if (draw) { Draw_Menu_Item(row, ICON_Version, F("Kp Value")); Draw_Float(thermalManager.temp_bed.pid.Kp, row, false, 100); } - else { + else Modify_Value(thermalManager.temp_bed.pid.Kp, 0, 5000, 100, thermalManager.updatePID); - } break; case BEDPID_KI: if (draw) { @@ -2241,53 +2526,62 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #define MOTION_SPEED (MOTION_HOMEOFFSETS + 1) #define MOTION_ACCEL (MOTION_SPEED + 1) #define MOTION_JERK (MOTION_ACCEL + ENABLED(HAS_CLASSIC_JERK)) - #define MOTION_STEPS (MOTION_JERK + 1) + #define MOTION_JD (MOTION_JERK + ENABLED(HAS_JUNCTION_DEVIATION)) + #define MOTION_STEPS (MOTION_JD + 1) #define MOTION_FLOW (MOTION_STEPS + ENABLED(HAS_HOTEND)) #define MOTION_TOTAL MOTION_FLOW switch (item) { case MOTION_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(Control, CONTROL_MOTION); break; case MOTION_HOMEOFFSETS: if (draw) - Draw_Menu_Item(row, ICON_SetHome, F("Home Offsets"), nullptr, true); + Draw_Menu_Item(row, ICON_SetHome, GET_TEXT_F(MSG_SET_HOME_OFFSETS), nullptr, true); else Draw_Menu(HomeOffsets); break; case MOTION_SPEED: if (draw) - Draw_Menu_Item(row, ICON_MaxSpeed, F("Max Speed"), nullptr, true); + Draw_Menu_Item(row, ICON_MaxSpeed, GET_TEXT_F(MSG_MAX_SPEED), nullptr, true); else Draw_Menu(MaxSpeed); break; case MOTION_ACCEL: if (draw) - Draw_Menu_Item(row, ICON_MaxAccelerated, F("Max Acceleration"), nullptr, true); + Draw_Menu_Item(row, ICON_MaxAccelerated, GET_TEXT_F(MSG_AMAX_EN), nullptr, true); else Draw_Menu(MaxAcceleration); break; #if HAS_CLASSIC_JERK case MOTION_JERK: if (draw) - Draw_Menu_Item(row, ICON_MaxJerk, F("Max Jerk"), nullptr, true); + Draw_Menu_Item(row, ICON_MaxJerk, GET_TEXT_F(MSG_JERK), nullptr, true); else Draw_Menu(MaxJerk); break; #endif + #if HAS_JUNCTION_DEVIATION + case MOTION_JD: + if (draw) + Draw_Menu_Item(row, ICON_MaxJerk, GET_TEXT_F(MSG_JUNCTION_DEVIATION), nullptr, true); + else + Draw_Menu(JDmenu); + break; + #endif case MOTION_STEPS: if (draw) - Draw_Menu_Item(row, ICON_Step, F("Steps/mm"), nullptr, true); + Draw_Menu_Item(row, ICON_Step, GET_TEXT_F(MSG_STEPS_PER_MM), nullptr, true); else Draw_Menu(Steps); break; #if HAS_HOTEND case MOTION_FLOW: if (draw) { - Draw_Menu_Item(row, ICON_Speed, F("Flow Rate")); + Draw_Menu_Item(row, ICON_Speed, GET_TEXT_F(MSG_FLOW)); Draw_Float(planner.flow_percentage[0], row, false, 1); } else @@ -2297,31 +2591,124 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ } break; - case HomeOffsets: + #if ENABLED(FWRETRACT) + case FwRetraction: - #define HOMEOFFSETS_BACK 0 - #define HOMEOFFSETS_XOFFSET (HOMEOFFSETS_BACK + 1) - #define HOMEOFFSETS_YOFFSET (HOMEOFFSETS_XOFFSET + 1) - #define HOMEOFFSETS_TOTAL HOMEOFFSETS_YOFFSET + #define FWR_BACK 0 + #define FWR_RET_AUTO (FWR_BACK + 1) + #define FWR_RET_LENGTH (FWR_RET_AUTO + 1) + #define FWR_RET_SPEED (FWR_RET_LENGTH + 1) + #define FWR_ZLIFT (FWR_RET_SPEED + 1) + #define FWR_REC_EXT_LENGTH (FWR_ZLIFT + 1) + #define FWR_REC_SPEED (FWR_REC_EXT_LENGTH + 1) + #define FWR_RESET (FWR_REC_SPEED + 1) + #define FWR_TOTAL FWR_RESET - switch (item) { - case HOMEOFFSETS_BACK: + switch (item) { + + case FWR_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); - else - Draw_Menu(Motion, MOTION_HOMEOFFSETS); - break; - case HOMEOFFSETS_XOFFSET: - if (draw) { - Draw_Menu_Item(row, ICON_StepX, F("X Offset")); - Draw_Float(home_offset.x, row, false, 100); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); + else { + if (temp_val.flag_tune) { + temp_val.flag_tune = false; + Redraw_Menu(false, true, true); + } + else + Draw_Menu(Control, CONTROL_FWRETRACT); } - else - Modify_Value(home_offset.x, -MAX_XY_OFFSET, MAX_XY_OFFSET, 100); + break; + case FWR_RET_AUTO: + if (draw) { + temp_val.auto_fw_retract = fwretract.autoretract_enabled; + Draw_Menu_Item(row, ICON_StepE, GET_TEXT_F(MSG_AUTORETRACT)); + Draw_Checkbox(row, temp_val.auto_fw_retract); + } + else { + if (MIN_AUTORETRACT <= MAX_AUTORETRACT) { + temp_val.auto_fw_retract = !temp_val.auto_fw_retract; + fwretract.enable_autoretract(temp_val.auto_fw_retract); + Draw_Checkbox(row, temp_val.auto_fw_retract); + } + } + break; + case FWR_RET_LENGTH: + if (draw) { + Draw_Menu_Item(row, ICON_FWRetLength, GET_TEXT_F(MSG_CONTROL_RETRACT)); + Draw_Float(fwretract.settings.retract_length, row, false, 10); + } + else + Modify_Value(fwretract.settings.retract_length, 0, 10, 10); + break; + case FWR_RET_SPEED: + if (draw) { + Draw_Menu_Item(row, ICON_FWRetSpeed, GET_TEXT_F(MSG_SINGLENOZZLE_RETRACT_SPEED)); + Draw_Float(fwretract.settings.retract_feedrate_mm_s, row, false, 10); + } + else + Modify_Value(fwretract.settings.retract_feedrate_mm_s, 1, 90, 10); + break; + case FWR_ZLIFT: + if (draw) { + Draw_Menu_Item(row, ICON_FWRetZRaise, GET_TEXT_F(MSG_CONTROL_RETRACT_ZHOP)); + Draw_Float(fwretract.settings.retract_zraise, row, false, 100); + } + else + Modify_Value(fwretract.settings.retract_zraise, 0, 10, 100); + break; + case FWR_REC_EXT_LENGTH: + if (draw) { + Draw_Menu_Item(row, ICON_FWRecExtLength, GET_TEXT_F(MSG_CONTROL_RETRACT_RECOVER)); + Draw_Float(fwretract.settings.retract_recover_extra, row, false, 10); + } + else + Modify_Value(fwretract.settings.retract_recover_extra, -10, 10, 10); + break; + case FWR_REC_SPEED: + if (draw) { + Draw_Menu_Item(row, ICON_FWRecSpeed, GET_TEXT_F(MSG_SINGLENOZZLE_UNRETRACT_SPEED)); + Draw_Float(fwretract.settings.retract_recover_feedrate_mm_s, row, false, 10); + } + else + Modify_Value(fwretract.settings.retract_recover_feedrate_mm_s, 1, 90, 10); + break; + case FWR_RESET: + if (draw) + Draw_Menu_Item(row, ICON_StepE, GET_TEXT_F(MSG_BUTTON_RESET)); + else { + fwretract.reset(); + Draw_Menu(FwRetraction); + } + break; + } + break; + #endif + + case HomeOffsets: + + #define HOMEOFFSETS_BACK 0 + #define HOMEOFFSETS_XOFFSET (HOMEOFFSETS_BACK + 1) + #define HOMEOFFSETS_YOFFSET (HOMEOFFSETS_XOFFSET + 1) + #define HOMEOFFSETS_TOTAL HOMEOFFSETS_YOFFSET + + switch (item) { + case HOMEOFFSETS_BACK: + if (draw) + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); + else + Draw_Menu(Motion, MOTION_HOMEOFFSETS); + break; + case HOMEOFFSETS_XOFFSET: + if (draw) { + Draw_Menu_Item(row, ICON_StepX, GET_TEXT_F(MSG_HOME_OFFSET_X)); + Draw_Float(home_offset.x, row, false, 100); + } + else + Modify_Value(home_offset.x, -MAX_XY_OFFSET, MAX_XY_OFFSET, 100); break; case HOMEOFFSETS_YOFFSET: if (draw) { - Draw_Menu_Item(row, ICON_StepY, F("Y Offset")); + Draw_Menu_Item(row, ICON_StepY, GET_TEXT_F(MSG_HOME_OFFSET_Y)); Draw_Float(home_offset.y, row, false, 100); } else @@ -2341,13 +2728,13 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case SPEED_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(Motion, MOTION_SPEED); break; case SPEED_X: if (draw) { - Draw_Menu_Item(row, ICON_MaxSpeedX, F("X Axis")); + Draw_Menu_Item(row, ICON_MaxSpeedX, GET_TEXT_F(MSG_VMAX_A)); Draw_Float(planner.settings.max_feedrate_mm_s[X_AXIS], row, false, 1); } else @@ -2357,7 +2744,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if HAS_Y_AXIS case SPEED_Y: if (draw) { - Draw_Menu_Item(row, ICON_MaxSpeedY, F("Y Axis")); + Draw_Menu_Item(row, ICON_MaxSpeedY, GET_TEXT_F(MSG_VMAX_B)); Draw_Float(planner.settings.max_feedrate_mm_s[Y_AXIS], row, false, 1); } else @@ -2368,7 +2755,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if HAS_Z_AXIS case SPEED_Z: if (draw) { - Draw_Menu_Item(row, ICON_MaxSpeedZ, F("Z Axis")); + Draw_Menu_Item(row, ICON_MaxSpeedZ, GET_TEXT_F(MSG_VMAX_C)); Draw_Float(planner.settings.max_feedrate_mm_s[Z_AXIS], row, false, 1); } else @@ -2379,7 +2766,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if HAS_HOTEND case SPEED_E: if (draw) { - Draw_Menu_Item(row, ICON_MaxSpeedE, F("Extruder")); + Draw_Menu_Item(row, ICON_MaxSpeedE, GET_TEXT_F(MSG_VMAX_E)); Draw_Float(planner.settings.max_feedrate_mm_s[E_AXIS], row, false, 1); } else @@ -2401,13 +2788,13 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case ACCEL_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(Motion, MOTION_ACCEL); break; case ACCEL_X: if (draw) { - Draw_Menu_Item(row, ICON_MaxAccX, F("X Axis")); + Draw_Menu_Item(row, ICON_MaxAccX, GET_TEXT_F(MSG_AMAX_A)); Draw_Float(planner.settings.max_acceleration_mm_per_s2[X_AXIS], row, false, 1); } else @@ -2415,7 +2802,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case ACCEL_Y: if (draw) { - Draw_Menu_Item(row, ICON_MaxAccY, F("Y Axis")); + Draw_Menu_Item(row, ICON_MaxAccY, GET_TEXT_F(MSG_AMAX_B)); Draw_Float(planner.settings.max_acceleration_mm_per_s2[Y_AXIS], row, false, 1); } else @@ -2423,7 +2810,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case ACCEL_Z: if (draw) { - Draw_Menu_Item(row, ICON_MaxAccZ, F("Z Axis")); + Draw_Menu_Item(row, ICON_MaxAccZ, GET_TEXT_F(MSG_AMAX_C)); Draw_Float(planner.settings.max_acceleration_mm_per_s2[Z_AXIS], row, false, 1); } else @@ -2432,7 +2819,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if HAS_HOTEND case ACCEL_E: if (draw) { - Draw_Menu_Item(row, ICON_MaxAccE, F("Extruder")); + Draw_Menu_Item(row, ICON_MaxAccE, GET_TEXT_F(MSG_AMAX_E)); Draw_Float(planner.settings.max_acceleration_mm_per_s2[E_AXIS], row, false, 1); } else @@ -2454,13 +2841,13 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case JERK_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(Motion, MOTION_JERK); break; case JERK_X: if (draw) { - Draw_Menu_Item(row, ICON_MaxSpeedJerkX, F("X Axis")); + Draw_Menu_Item(row, ICON_MaxSpeedJerkX, GET_TEXT_F(MSG_VA_JERK)); Draw_Float(planner.max_jerk[X_AXIS], row, false, 10); } else @@ -2468,7 +2855,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case JERK_Y: if (draw) { - Draw_Menu_Item(row, ICON_MaxSpeedJerkY, F("Y Axis")); + Draw_Menu_Item(row, ICON_MaxSpeedJerkY, GET_TEXT_F(MSG_VB_JERK)); Draw_Float(planner.max_jerk[Y_AXIS], row, false, 10); } else @@ -2476,7 +2863,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case JERK_Z: if (draw) { - Draw_Menu_Item(row, ICON_MaxSpeedJerkZ, F("Z Axis")); + Draw_Menu_Item(row, ICON_MaxSpeedJerkZ, GET_TEXT_F(MSG_VC_JERK)); Draw_Float(planner.max_jerk[Z_AXIS], row, false, 10); } else @@ -2485,7 +2872,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if HAS_HOTEND case JERK_E: if (draw) { - Draw_Menu_Item(row, ICON_MaxSpeedJerkE, F("Extruder")); + Draw_Menu_Item(row, ICON_MaxSpeedJerkE, GET_TEXT_F(MSG_VE_JERK)); Draw_Float(planner.max_jerk[E_AXIS], row, false, 10); } else @@ -2495,6 +2882,33 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ } break; #endif + #if HAS_JUNCTION_DEVIATION + case JDmenu: + + #define JD_BACK 0 + #define JD_SETTING_JD_MM (JD_BACK + ENABLED(HAS_HOTEND)) + #define JD_TOTAL JD_SETTING_JD_MM + + switch (item) { + case JD_BACK: + if (draw) + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); + else + Draw_Menu(Motion, MOTION_JD); + break; + #if HAS_HOTEND + case JD_SETTING_JD_MM: + if (draw) { + Draw_Menu_Item(row, ICON_MaxJerk, GET_TEXT_F(MSG_JUNCTION_DEVIATION)); + Draw_Float(planner.junction_deviation_mm, row, false, 100); + } + else + Modify_Value(planner.junction_deviation_mm, MIN_JD_MM, MAX_JD_MM, 100); + break; + #endif + } + break; + #endif case Steps: #define STEPS_BACK 0 @@ -2507,13 +2921,13 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case STEPS_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(Motion, MOTION_STEPS); break; case STEPS_X: if (draw) { - Draw_Menu_Item(row, ICON_StepX, F("X Axis")); + Draw_Menu_Item(row, ICON_StepX, GET_TEXT_F(MSG_A_STEPS)); Draw_Float(planner.settings.axis_steps_per_mm[X_AXIS], row, false, 10); } else @@ -2521,7 +2935,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case STEPS_Y: if (draw) { - Draw_Menu_Item(row, ICON_StepY, F("Y Axis")); + Draw_Menu_Item(row, ICON_StepY, GET_TEXT_F(MSG_B_STEPS)); Draw_Float(planner.settings.axis_steps_per_mm[Y_AXIS], row, false, 10); } else @@ -2529,7 +2943,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case STEPS_Z: if (draw) { - Draw_Menu_Item(row, ICON_StepZ, F("Z Axis")); + Draw_Menu_Item(row, ICON_StepZ, GET_TEXT_F(MSG_C_STEPS)); Draw_Float(planner.settings.axis_steps_per_mm[Z_AXIS], row, false, 10); } else @@ -2538,7 +2952,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if HAS_HOTEND case STEPS_E: if (draw) { - Draw_Menu_Item(row, ICON_StepE, F("Extruder")); + Draw_Menu_Item(row, ICON_StepE, GET_TEXT_F(MSG_E_STEPS)); Draw_Float(planner.settings.axis_steps_per_mm[E_AXIS], row, false, 10); } else @@ -2548,6 +2962,235 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ } break; + #if ANY(CASE_LIGHT_MENU, LED_CONTROL_MENU) + case Ledsmenu: + + #define LEDS_BACK 0 + #define LEDS_CASELIGHT (LEDS_BACK + ENABLED(CASE_LIGHT_MENU)) + #define LEDS_LED_CONTROL_MENU (LEDS_CASELIGHT + ENABLED(LED_CONTROL_MENU)) + #define LEDS_TOTAL LEDS_LED_CONTROL_MENU + + switch (item) { + + case LEDS_BACK: + if (draw) + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); + else + Draw_Menu(Control, CONTROL_LEDS); + break; + #if ENABLED(CASE_LIGHT_MENU) + case LEDS_CASELIGHT: + if (draw) { + #if ENABLED(CASELIGHT_USES_BRIGHTNESS) + Draw_Menu_Item(row, ICON_CaseLight, GET_TEXT_F(MSG_CASE_LIGHT), nullptr, true); + #else + Draw_Menu_Item(row, ICON_CaseLight, GET_TEXT_F(MSG_CASE_LIGHT)); + Draw_Checkbox(row, caselight.on); + #endif + } + else { + #if ENABLED(CASELIGHT_USES_BRIGHTNESS) + Draw_Menu(CaseLightmenu); + #else + caselight.on = !caselight.on; + caselight.update_enabled(); + Draw_Checkbox(row, caselight.on); + DWIN_UpdateLCD(); + #endif + } + break; + #endif + #if ENABLED(LED_CONTROL_MENU) + case LEDS_LED_CONTROL_MENU: + if (draw) + Draw_Menu_Item(row, ICON_LedControl, GET_TEXT_F(MSG_LED_CONTROL), nullptr, true); + else + Draw_Menu(LedControlmenu); + break; + #endif + } + break; + #endif + + #if ENABLED(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS) + case CaseLightmenu: + + #define CASE_LIGHT_BACK 0 + #define CASE_LIGHT_ON (CASE_LIGHT_BACK + 1) + #define CASE_LIGHT_USES_BRIGHT (CASE_LIGHT_ON + 1) + #define CASE_LIGHT_TOTAL CASE_LIGHT_USES_BRIGHT + + switch (item) { + + case CASE_LIGHT_BACK: + if (draw) + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); + else + Draw_Menu(Ledsmenu, LEDS_CASELIGHT); + break; + case CASE_LIGHT_ON: + if (draw) { + Draw_Menu_Item(row, ICON_CaseLight, GET_TEXT_F(MSG_CASE_LIGHT)); + Draw_Checkbox(row, caselight.on); + } + else { + caselight.on = !caselight.on; + caselight.update_enabled(); + Draw_Checkbox(row, caselight.on); + DWIN_UpdateLCD(); + } + break; + case CASE_LIGHT_USES_BRIGHT: + if (draw) { + Draw_Menu_Item(row, ICON_Brightness, GET_TEXT_F(MSG_CASE_LIGHT_BRIGHTNESS)); + Draw_Float(caselight.brightness, row); + } + else + Modify_Value(caselight.brightness, 0, 255, 1); + break; + } + break; + #endif + + #if ENABLED(LED_CONTROL_MENU) + case LedControlmenu: + + #define LEDCONTROL_BACK 0 + #define LEDCONTROL_LIGHTON (LEDCONTROL_BACK + !BOTH(CASE_LIGHT_MENU, CASE_LIGHT_USE_NEOPIXEL)) + #define LEDCONTROL_PRESETS_MENU (LEDCONTROL_LIGHTON + BOTH(HAS_COLOR_LEDS, LED_COLOR_PRESETS)) + #define LEDCONTROL_CUSTOM_MENU (LEDCONTROL_PRESETS_MENU + ENABLED(HAS_COLOR_LEDS) - DISABLED(LED_COLOR_PRESETS)) + #define LEDCONTROL_TOTAL LEDCONTROL_CUSTOM_MENU + + switch (item) { + case LEDCONTROL_BACK: + if (draw) + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); + else + Draw_Menu(Ledsmenu, LEDS_LED_CONTROL_MENU); + break; + #if !BOTH(CASE_LIGHT_MENU, CASE_LIGHT_USE_NEOPIXEL) + case LEDCONTROL_LIGHTON: + if (draw) { + Draw_Menu_Item(row, ICON_LedControl, GET_TEXT_F(MSG_LEDS)); + Draw_Checkbox(row, leds.lights_on); + } + else { + leds.toggle(); + Draw_Checkbox(row, leds.lights_on); + DWIN_UpdateLCD(); + } + break; + #endif + #if HAS_COLOR_LEDS + #if ENABLED(LED_COLOR_PRESETS) + case LEDCONTROL_PRESETS_MENU: + if (draw) + Draw_Menu_Item(row, ICON_LedControl, GET_TEXT_F(MSG_LED_PRESETS)); + else + Draw_Menu(LedControlpresets); + break; + #else + case LEDCONTROL_CUSTOM_MENU: + if (draw) + Draw_Menu_Item(row, ICON_LedControl, GET_TEXT_F(MSG_CUSTOM_LEDS)); + else + Draw_Menu(LedControlcustom); + break; + #endif + #endif + } + break; + + #if HAS_COLOR_LEDS + #if ENABLED(LED_COLOR_PRESETS) + case LedControlpresets: + + #define LEDCONTROL_PRESETS_BACK 0 + #define LEDCONTROL_PRESETS_WHITE (LEDCONTROL_PRESETS_BACK + 1) + #define LEDCONTROL_PRESETS_RED (LEDCONTROL_PRESETS_WHITE + 1) + #define LEDCONTROL_PRESETS_ORANGE (LEDCONTROL_PRESETS_RED + 1) + #define LEDCONTROL_PRESETS_YELLOW (LEDCONTROL_PRESETS_ORANGE + 1) + #define LEDCONTROL_PRESETS_GREEN (LEDCONTROL_PRESETS_YELLOW + 1) + #define LEDCONTROL_PRESETS_BLUE (LEDCONTROL_PRESETS_GREEN + 1) + #define LEDCONTROL_PRESETS_INDIGO (LEDCONTROL_PRESETS_BLUE + 1) + #define LEDCONTROL_PRESETS_VIOLET (LEDCONTROL_PRESETS_INDIGO + 1) + #define LEDCONTROL_PRESETS_TOTAL LEDCONTROL_PRESETS_VIOLET + + #define LEDCOLORITEM(MSG,FUNC) if (draw) Draw_Menu_Item(row, ICON_LedControl, GET_TEXT_F(MSG)); else FUNC; break; + + switch (item) { + case LEDCONTROL_PRESETS_BACK: + if (draw) + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); + else + Draw_Menu(LedControlmenu, LEDCONTROL_PRESETS_MENU); + break; + case LEDCONTROL_PRESETS_WHITE: LEDCOLORITEM(MSG_SET_LEDS_WHITE, leds.set_white()); + case LEDCONTROL_PRESETS_RED: LEDCOLORITEM(MSG_SET_LEDS_RED, leds.set_red()); + case LEDCONTROL_PRESETS_ORANGE: LEDCOLORITEM(MSG_SET_LEDS_ORANGE, leds.set_orange()); + case LEDCONTROL_PRESETS_YELLOW: LEDCOLORITEM(MSG_SET_LEDS_YELLOW, leds.set_yellow()); + case LEDCONTROL_PRESETS_GREEN: LEDCOLORITEM(MSG_SET_LEDS_GREEN, leds.set_green()); + case LEDCONTROL_PRESETS_BLUE: LEDCOLORITEM(MSG_SET_LEDS_BLUE, leds.set_blue()); + case LEDCONTROL_PRESETS_INDIGO: LEDCOLORITEM(MSG_SET_LEDS_INDIGO, leds.set_indigo()); + case LEDCONTROL_PRESETS_VIOLET: LEDCOLORITEM(MSG_SET_LEDS_VIOLET, leds.set_violet()); + } + break; + #else + case LedControlcustom: + + #define LEDCONTROL_CUSTOM_BACK 0 + #define LEDCONTROL_CUSTOM_RED (LEDCONTROL_CUSTOM_BACK + 1) + #define LEDCONTROL_CUSTOM_GREEN (LEDCONTROL_CUSTOM_RED + 1) + #define LEDCONTROL_CUSTOM_BLUE (LEDCONTROL_CUSTOM_GREEN + 1) + #define LEDCONTROL_CUSTOM_WHITE (LEDCONTROL_CUSTOM_BLUE + ENABLED(HAS_WHITE_LED)) + #define LEDCONTROL_CUSTOM_TOTAL LEDCONTROL_CUSTOM_WHITE + + switch (item) { + case LEDCONTROL_PRESETS_BACK: + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); + else + Draw_Menu(LedControlmenu, LEDCONTROL_CUSTOM_MENU); + break; + case LEDCONTROL_CUSTOM_RED: + if (draw) { + Draw_Menu_Item(row, ICON_LedControl, GET_TEXT_F(MSG_INTENSITY_R)); + Draw_Float(leds.color.r, row); + } + else + Modify_Value(leds.color.r, 0, 255, 1); + break; + case LEDCONTROL_CUSTOM_GREEN: + if (draw) { + Draw_Menu_Item(row, ICON_LedControl, GET_TEXT_F(MSG_INTENSITY_G)); + Draw_Float(leds.color.g, row); + } + else + Modify_Value(leds.color.g, 0, 255, 1); + break; + case LEDCONTROL_CUSTOM_BLUE: + if (draw) { + Draw_Menu_Item(row, ICON_LedControl, GET_TEXT_F(MSG_INTENSITY_B)); + Draw_Float(leds.color.b, row); + } + else + Modify_Value(leds.color.b, 0, 255, 1); + break; + #if HAS_WHITE_LED + case case LEDCONTROL_CUSTOM_WHITE: + if (draw) { + Draw_Menu_Item(row, ICON_LedControl, GET_TEXT_F(MSG_INTENSITY_W)); + Draw_Float(leds.color.w, row); + } + else + Modify_Value(leds.color.w, 0, 255, 1); + break; + #endif + } + break; + #endif + #endif + #endif + case Visual: #define VISUAL_BACK 0 @@ -2560,19 +3203,19 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case VISUAL_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(Control, CONTROL_VISUAL); break; case VISUAL_BACKLIGHT: if (draw) - Draw_Menu_Item(row, ICON_Brightness, F("Display Off")); + Draw_Menu_Item(row, ICON_Brightness, GET_TEXT_F(MSG_BRIGHTNESS_OFF)); else ui.set_brightness(0); break; case VISUAL_BRIGHTNESS: if (draw) { - Draw_Menu_Item(row, ICON_Brightness, F("LCD Brightness")); + Draw_Menu_Item(row, ICON_Brightness, GET_TEXT_F(MSG_BRIGHTNESS)); Draw_Float(ui.brightness, row, false, 1); } else @@ -2590,7 +3233,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case VISUAL_COLOR_THEMES: if (draw) - Draw_Menu_Item(row, ICON_MaxSpeed, F("UI Color Settings"), nullptr, true); + Draw_Menu_Item(row, ICON_MaxSpeed, GET_TEXT_F(MSG_COLORS_SELECT), nullptr, true); else Draw_Menu(ColorSettings); break; @@ -2616,7 +3259,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case COLORSETTINGS_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(Visual, VISUAL_COLOR_THEMES); break; @@ -2711,6 +3354,70 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ } // switch (item) break; + #if HAS_HOSTACTION_MENUS + case HostSettings: + + #define HOSTSETTINGS_BACK 0 + #define HOSTSETTINGS_ACTIONCOMMANDS (HOSTSETTINGS_BACK + 1) + #define HOSTSETTINGS_TOTAL HOSTSETTINGS_ACTIONCOMMANDS + + switch (item) { + case HOSTSETTINGS_BACK: + if (draw) + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); + else + Draw_Menu(Control, CONTROL_HOSTSETTINGS); + break; + case HOSTSETTINGS_ACTIONCOMMANDS: + if (draw) Draw_Menu_Item(row, ICON_File, F("Host Actions")); + else Draw_Menu(ActionCommands); + break; + } + break; + + case ActionCommands: + + #define ACTIONCOMMANDS_BACK 0 + #define ACTIONCOMMANDS_1 (ACTIONCOMMANDS_BACK + 1) + #define ACTIONCOMMANDS_2 (ACTIONCOMMANDS_1 + 1) + #define ACTIONCOMMANDS_3 (ACTIONCOMMANDS_2 + 1) + #define ACTIONCOMMANDS_TOTAL ACTIONCOMMANDS_3 + + switch (item) { + case ACTIONCOMMANDS_BACK: + if (draw) + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); + else + Draw_Menu(HostSettings, HOSTSETTINGS_ACTIONCOMMANDS); + break; + case ACTIONCOMMANDS_1: + if (draw) { + Draw_Menu_Item(row, ICON_File, F("Action #1")); + Draw_String(action1, row); + } + else + Modify_String(action1, 8, true); + break; + case ACTIONCOMMANDS_2: + if (draw) { + Draw_Menu_Item(row, ICON_File, F("Action #2")); + Draw_String(action2, row); + } + else + Modify_String(action2, 8, true); + break; + case ACTIONCOMMANDS_3: + if (draw) { + Draw_Menu_Item(row, ICON_File, F("Action #3")); + Draw_String(action3, row); + } + else + Modify_String(action3, 8, true); + break; + } + break; + #endif + case Advanced: #define ADVANCED_BACK 0 @@ -2724,12 +3431,15 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #define ADVANCED_FILSENSORENABLED (ADVANCED_COLD_EXTRUDE + ENABLED(FILAMENT_RUNOUT_SENSOR)) #define ADVANCED_FILSENSORDISTANCE (ADVANCED_FILSENSORENABLED + ENABLED(HAS_FILAMENT_RUNOUT_DISTANCE)) #define ADVANCED_POWER_LOSS (ADVANCED_FILSENSORDISTANCE + ENABLED(POWER_LOSS_RECOVERY)) - #define ADVANCED_TOTAL ADVANCED_POWER_LOSS + #define ADVANCED_BAUDRATE_MODE (ADVANCED_POWER_LOSS + ENABLED(BAUD_RATE_GCODE)) + #define ADVANCED_ESDIAG (ADVANCED_BAUDRATE_MODE + ENABLED(HAS_ESDIAG)) + #define ADVANCED_LOCKSCREEN (ADVANCED_ESDIAG + ENABLED(HAS_LOCKSCREEN)) + #define ADVANCED_TOTAL ADVANCED_LOCKSCREEN switch (item) { case ADVANCED_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(Control, CONTROL_ADVANCED); break; @@ -2737,7 +3447,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if ENABLED(SOUND_MENU_ITEM) case ADVANCED_BEEPER: if (draw) { - Draw_Menu_Item(row, ICON_Version, F("LCD Beeper")); + Draw_Menu_Item(row, ICON_Sound, GET_TEXT_F(MSG_SOUND_ENABLE)); Draw_Checkbox(row, ui.sound_on); } else { @@ -2750,7 +3460,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if HAS_BED_PROBE case ADVANCED_PROBE: if (draw) - Draw_Menu_Item(row, ICON_StepX, F("Probe"), nullptr, true); + Draw_Menu_Item(row, ICON_ProbeSet, GET_TEXT_F(MSG_ZPROBE_SETTINGS), nullptr, true); else Draw_Menu(ProbeMenu); break; @@ -2759,16 +3469,16 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case ADVANCED_CORNER: if (draw) { Draw_Menu_Item(row, ICON_MaxAccelerated, F("Bed Screw Inset")); - Draw_Float(corner_pos, row, false, 10); + Draw_Float(temp_val.corner_pos, row, false, 10); } else - Modify_Value(corner_pos, 1, 100, 10); + Modify_Value(temp_val.corner_pos, 1, 100, 10); break; #if ENABLED(LIN_ADVANCE) case ADVANCED_LA: if (draw) { - Draw_Menu_Item(row, ICON_MaxAccelerated, F("Lin Advance Kp")); + Draw_Menu_Item(row, ICON_MaxAccelerated, GET_TEXT_F(MSG_ADVANCE_K_E)); Draw_Float(planner.extruder_advance_K[0], row, false, 100); } else @@ -2779,7 +3489,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if ENABLED(ADVANCED_PAUSE_FEATURE) case ADVANCED_LOAD: if (draw) { - Draw_Menu_Item(row, ICON_WriteEEPROM, F("Load Length")); + Draw_Menu_Item(row, ICON_WriteEEPROM, GET_TEXT_F(MSG_FILAMENT_LOAD)); Draw_Float(fc_settings[0].load_length, row, false, 1); } else @@ -2787,7 +3497,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case ADVANCED_UNLOAD: if (draw) { - Draw_Menu_Item(row, ICON_ReadEEPROM, F("Unload Length")); + Draw_Menu_Item(row, ICON_ReadEEPROM, GET_TEXT_F(MSG_FILAMENT_UNLOAD)); Draw_Float(fc_settings[0].unload_length, row, false, 1); } else @@ -2811,7 +3521,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if ENABLED(FILAMENT_RUNOUT_SENSOR) case ADVANCED_FILSENSORENABLED: if (draw) { - Draw_Menu_Item(row, ICON_Extruder, F("Filament Sensor")); + Draw_Menu_Item(row, ICON_Extruder, GET_TEXT_F(MSG_RUNOUT_ENABLE)); Draw_Checkbox(row, runout.enabled); } else { @@ -2823,7 +3533,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if ENABLED(HAS_FILAMENT_RUNOUT_DISTANCE) case ADVANCED_FILSENSORDISTANCE: if (draw) { - Draw_Menu_Item(row, ICON_MaxAccE, F("Runout Distance")); + Draw_Menu_Item(row, ICON_MaxAccE, GET_TEXT_F(MSG_RUNOUT_DISTANCE_MM)); Draw_Float(runout.runout_distance(), row, false, 10); } else @@ -2835,7 +3545,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if ENABLED(POWER_LOSS_RECOVERY) case ADVANCED_POWER_LOSS: if (draw) { - Draw_Menu_Item(row, ICON_Motion, F("Power-loss recovery")); + Draw_Menu_Item(row, ICON_Motion, GET_TEXT_F(MSG_OUTAGE_RECOVERY)); Draw_Checkbox(row, recovery.enabled); } else { @@ -2844,6 +3554,34 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ } break; #endif + #if ENABLED(BAUD_RATE_GCODE) + case ADVANCED_BAUDRATE_MODE: + if (draw) { + Draw_Menu_Item(row, ICON_Setspeed, F("115k Baud")); + Draw_Checkbox(row, eeprom_settings.Baud115k); + } + else { + eeprom_settings.Baud115k = !eeprom_settings.Baud115k; + queue.inject(eeprom_settings.Baud115k ? F("M575 P0 B115200") : F("M575 P0 B250000")); + } + break; + #endif + #if HAS_ESDIAG + case ADVANCED_ESDIAG: + if (draw) + Draw_Menu_Item(row, ICON_ESDiag, F("End-stops diagnostic")); + else + DWIN_EndstopsDiag(); + break; + #endif + #if HAS_LOCKSCREEN + case ADVANCED_LOCKSCREEN: + if (draw) + Draw_Menu_Item(row, ICON_Lock, GET_TEXT_F(MSG_LOCKSCREEN)); + else + DWIN_LockScreen(); + break; + #endif } break; @@ -2853,7 +3591,12 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #define PROBE_BACK 0 #define PROBE_XOFFSET (PROBE_BACK + 1) #define PROBE_YOFFSET (PROBE_XOFFSET + 1) - #define PROBE_TEST (PROBE_YOFFSET + 1) + #define PROBE_ZOFFSET (PROBE_YOFFSET + 1) + #define PROBE_HSMODE (PROBE_ZOFFSET + ENABLED(BLTOUCH)) + #define PROBE_ALARMR (PROBE_HSMODE + ENABLED(BLTOUCH)) + #define PROBE_SELFTEST (PROBE_ALARMR + ENABLED(BLTOUCH)) + #define PROBE_MOVEP (PROBE_SELFTEST + ENABLED(BLTOUCH)) + #define PROBE_TEST (PROBE_MOVEP + 1) #define PROBE_TEST_COUNT (PROBE_TEST + 1) #define PROBE_TOTAL PROBE_TEST_COUNT @@ -2862,43 +3605,91 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case PROBE_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(Advanced, ADVANCED_PROBE); break; - - case PROBE_XOFFSET: + case PROBE_XOFFSET: + if (draw) { + Draw_Menu_Item(row, ICON_StepX, GET_TEXT_F(MSG_ZPROBE_XOFFSET)); + Draw_Float(probe.offset.x, row, false, 10); + } + else + Modify_Value(probe.offset.x, -MAX_XY_OFFSET, MAX_XY_OFFSET, 10); + break; + case PROBE_YOFFSET: + if (draw) { + Draw_Menu_Item(row, ICON_StepY, GET_TEXT_F(MSG_ZPROBE_YOFFSET)); + Draw_Float(probe.offset.y, row, false, 10); + } + else + Modify_Value(probe.offset.y, -MAX_XY_OFFSET, MAX_XY_OFFSET, 10); + break; + case PROBE_ZOFFSET: + if (draw) { + Draw_Menu_Item(row, ICON_StepZ, GET_TEXT_F(MSG_ZPROBE_ZOFFSET)); + Draw_Float(probe.offset.z, row, false, 100); + } + else + Modify_Value(probe.offset.z, MIN_Z_OFFSET, MAX_Z_OFFSET, 100); + break; + #if ENABLED(BLTOUCH) + case PROBE_HSMODE: if (draw) { - Draw_Menu_Item(row, ICON_StepX, F("Probe X Offset")); - Draw_Float(probe.offset.x, row, false, 10); + Draw_Menu_Item(row, ICON_HSMode, GET_TEXT(MSG_BLTOUCH_SPEED_MODE)); + Draw_Checkbox(row, bltouch.high_speed_mode); + } + else { + bltouch.high_speed_mode = !bltouch.high_speed_mode; + Draw_Checkbox(row, bltouch.high_speed_mode); } - else - Modify_Value(probe.offset.x, -MAX_XY_OFFSET, MAX_XY_OFFSET, 10); break; - case PROBE_YOFFSET: - if (draw) { - Draw_Menu_Item(row, ICON_StepY, F("Probe Y Offset")); - Draw_Float(probe.offset.y, row, false, 10); + case PROBE_ALARMR: + if (draw) + Draw_Menu_Item(row, ICON_ProbeAlarm, GET_TEXT_F(MSG_BLTOUCH_RESET)); + else { + gcode.process_subcommands_now(F("M280 P0 S160")); + AudioFeedback(); } - else - Modify_Value(probe.offset.y, -MAX_XY_OFFSET, MAX_XY_OFFSET, 10); break; - case PROBE_TEST: + case PROBE_SELFTEST: if (draw) - Draw_Menu_Item(row, ICON_StepY, F("M48 Probe Test")); + Draw_Menu_Item(row, ICON_ProbeSelfTest, GET_TEXT_F(MSG_BLTOUCH_SELFTEST)); else { - sprintf_P(cmd, PSTR("G28O\nM48 X%s Y%s P%i"), dtostrf((X_BED_SIZE + X_MIN_POS) / 2.0f, 1, 3, str_1), dtostrf((Y_BED_SIZE + Y_MIN_POS) / 2.0f, 1, 3, str_2), testcount); - gcode.process_subcommands_now(cmd); + gcode.process_subcommands_now(F("M280 P0 S120\nG4 P1000\nM280 P0 S160")); + planner.synchronize(); + AudioFeedback(); } break; - case PROBE_TEST_COUNT: + case PROBE_MOVEP: if (draw) { - Draw_Menu_Item(row, ICON_StepY, F("Probe Test Count")); - Draw_Float(testcount, row, false, 1); + Draw_Menu_Item(row, ICON_ProbeDeploy, GET_TEXT_F(MSG_BLTOUCH_DEPLOY)); + Draw_Checkbox(row, temp_val.probe_deployed); + } + else { + temp_val.probe_deployed = !temp_val.probe_deployed; + if (temp_val.probe_deployed == true) gcode.process_subcommands_now(F("M280 P0 S10")); + else gcode.process_subcommands_now(F("M280 P0 S90")); + Draw_Checkbox(row, temp_val.probe_deployed); } - else - Modify_Value(testcount, 4, 50, 1); break; + #endif + case PROBE_TEST: + if (draw) + Draw_Menu_Item(row, ICON_ProbeTest, GET_TEXT_F(MSG_M48_TEST)); + else { + sprintf_P(cmd, PSTR("G28O\nM48 X%s Y%s P%i"), dtostrf((X_BED_SIZE + X_MIN_POS) / 2.0f, 1, 3, str_1), dtostrf((Y_BED_SIZE + Y_MIN_POS) / 2.0f, 1, 3, str_2), testcount); + gcode.process_subcommands_now(cmd); + } + break; + case PROBE_TEST_COUNT: + if (draw) { + Draw_Menu_Item(row, ICON_ProbeTestCount, F("Probe Test Count")); + Draw_Float(testcount, row, false, 1); + } + else + Modify_Value(testcount, 4, 50, 1); + break; } break; #endif @@ -2917,7 +3708,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case INFO_BACK: if (draw) { - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); #if ENABLED(PRINTCOUNTER) char row1[50], row2[50], buf[32]; @@ -2966,22 +3757,19 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case LEVELING_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Main_Menu(3); break; case LEVELING_ACTIVE: if (draw) { - Draw_Menu_Item(row, ICON_StockConfiguration, F("Leveling Active")); + Draw_Menu_Item(row, ICON_MeshActive, GET_TEXT_F(MSG_MESH_LEVELING)); Draw_Checkbox(row, planner.leveling_active); } else { if (!planner.leveling_active) { set_bed_leveling_enabled(!planner.leveling_active); - if (!planner.leveling_active) { - Confirm_Handler(LevelError); - break; - } + if (!planner.leveling_active) { Confirm_Handler(LevelError); break; } } else set_bed_leveling_enabled(!planner.leveling_active); @@ -2993,10 +3781,8 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ if (draw) Draw_Menu_Item(row, ICON_Tilt, F("Autotilt Current Mesh")); else { - if (bedlevel.storage_slot < 0) { - Popup_Handler(MeshSlot); - break; - } + if (bedlevel.storage_slot < 0) { Popup_Handler(MeshSlot); break; } + PreheatBefore(); Popup_Handler(Home); gcode.home_all_axes(true); Popup_Handler(Level); @@ -3013,21 +3799,21 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #endif case LEVELING_GET_MESH: if (draw) - Draw_Menu_Item(row, ICON_Mesh, F("Create New Mesh")); + Draw_Menu_Item(row, ICON_Mesh, GET_TEXT_F(MSG_UBL_BUILD_MESH_MENU)); else { + #if ENABLED(AUTO_BED_LEVELING_UBL) + if (bedlevel.storage_slot < 0) { Popup_Handler(MeshSlot, true); break; } + #endif + PreheatBefore(); Popup_Handler(Home); gcode.home_all_axes(true); #if ENABLED(AUTO_BED_LEVELING_UBL) - #if ENABLED(PREHEAT_BEFORE_LEVELING) - Popup_Handler(Heating); - probe.preheat_for_probing(LEVELING_NOZZLE_TEMP, LEVELING_BED_TEMP); - #endif #if HAS_BED_PROBE Popup_Handler(Level); - gcode.process_subcommands_now(F("G29 P0\nG29 P1")); + gcode.process_subcommands_now(F("G29 P1")); gcode.process_subcommands_now(F("G29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nM420 S1")); planner.synchronize(); - Update_Status("Probed all reachable points"); + Update_Status(GET_TEXT_F(MSG_MESH_DONE)); Popup_Handler(SaveLevel); #else level_state = planner.leveling_active; @@ -3042,13 +3828,14 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ Popup_Handler(Level); gcode.process_subcommands_now(F("G29")); planner.synchronize(); + Update_Status(GET_TEXT_F(MSG_MESH_DONE)); Popup_Handler(SaveLevel); #else level_state = planner.leveling_active; set_bed_leveling_enabled(false); - gridpoint = 1; + temp_val.gridpoint = 1; Popup_Handler(MoveWait); - gcode.process_subcommands_now(F("G29")); + gcode.process_subcommands_now(F("M211 S0\nG29")); planner.synchronize(); Draw_Menu(ManualMesh); #endif @@ -3056,42 +3843,22 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case LEVELING_MANUAL: if (draw) - Draw_Menu_Item(row, ICON_Mesh, F("Manual Tuning"), nullptr, true); + Draw_Menu_Item(row, ICON_Mesh, GET_TEXT_F(MSG_UBL_MESH_EDIT), nullptr, true); else { #if ENABLED(AUTO_BED_LEVELING_BILINEAR) - if (!leveling_is_valid()) { - Confirm_Handler(InvalidMesh); - break; - } + if (!leveling_is_valid()) { Confirm_Handler(InvalidMesh); break; } #endif #if ENABLED(AUTO_BED_LEVELING_UBL) - if (bedlevel.storage_slot < 0) { - Popup_Handler(MeshSlot); - break; - } + if (bedlevel.storage_slot < 0) { Popup_Handler(MeshSlot); break; } #endif - if (axes_should_home()) { - Popup_Handler(Home); - gcode.home_all_axes(true); - } + PreheatBefore(); + if (axes_should_home()) { Popup_Handler(Home); gcode.home_all_axes(true); } level_state = planner.leveling_active; set_bed_leveling_enabled(false); mesh_conf.goto_mesh_value = false; - #if ENABLED(PREHEAT_BEFORE_LEVELING) - Popup_Handler(Heating); - #if HAS_HOTEND - if (thermalManager.degTargetHotend(0) < LEVELING_NOZZLE_TEMP) - thermalManager.setTargetHotend(LEVELING_NOZZLE_TEMP, 0); - #endif - #if HAS_HEATED_BED - if (thermalManager.degTargetBed() < LEVELING_BED_TEMP) - thermalManager.setTargetBed(LEVELING_BED_TEMP); - #endif - TERN_(HAS_HOTEND, thermalManager.wait_for_hotend(0)); - TERN_(HAS_HEATED_BED, thermalManager.wait_for_bed_heating()); - #endif Popup_Handler(MoveWait); mesh_conf.manual_mesh_move(); + gcode.process_subcommands_now(F("M211 S0")); Draw_Menu(LevelManual); } break; @@ -3100,24 +3867,21 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ Draw_Menu_Item(row, ICON_Mesh, GET_TEXT_F(MSG_MESH_VIEW), nullptr, true); else { #if ENABLED(AUTO_BED_LEVELING_UBL) - if (bedlevel.storage_slot < 0) { - Popup_Handler(MeshSlot); - break; - } + if (bedlevel.storage_slot < 0) { Popup_Handler(MeshSlot); break; } #endif Draw_Menu(LevelView); } break; case LEVELING_SETTINGS: if (draw) - Draw_Menu_Item(row, ICON_Step, F("Leveling Settings"), nullptr, true); + Draw_Menu_Item(row, ICON_Step, GET_TEXT_F(MSG_ADVANCED_SETTINGS), nullptr, true); else Draw_Menu(LevelSettings); break; #if ENABLED(AUTO_BED_LEVELING_UBL) case LEVELING_SLOT: if (draw) { - Draw_Menu_Item(row, ICON_PrintSize, F("Mesh Slot")); + Draw_Menu_Item(row, ICON_PrintSize, GET_TEXT_F(MSG_UBL_STORAGE_SLOT)); Draw_Float(bedlevel.storage_slot, row, false, 1); } else @@ -3125,12 +3889,9 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case LEVELING_LOAD: if (draw) - Draw_Menu_Item(row, ICON_ReadEEPROM, F("Load Mesh")); + Draw_Menu_Item(row, ICON_ReadEEPROM, GET_TEXT_F(MSG_UBL_LOAD_MESH)); else { - if (bedlevel.storage_slot < 0) { - Popup_Handler(MeshSlot); - break; - } + if (bedlevel.storage_slot < 0) { Popup_Handler(MeshSlot); break; } gcode.process_subcommands_now(F("G29 L")); planner.synchronize(); AudioFeedback(true); @@ -3138,12 +3899,9 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case LEVELING_SAVE: if (draw) - Draw_Menu_Item(row, ICON_WriteEEPROM, F("Save Mesh")); + Draw_Menu_Item(row, ICON_WriteEEPROM, GET_TEXT_F(MSG_UBL_SAVE_MESH)); else { - if (bedlevel.storage_slot < 0) { - Popup_Handler(MeshSlot); - break; - } + if (bedlevel.storage_slot < 0) { Popup_Handler(MeshSlot); break; } gcode.process_subcommands_now(F("G29 S")); planner.synchronize(); AudioFeedback(true); @@ -3164,7 +3922,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case LEVELING_VIEW_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(Leveling, LEVELING_VIEW); break; @@ -3200,7 +3958,10 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case LevelSettings: #define LEVELING_SETTINGS_BACK 0 - #define LEVELING_SETTINGS_FADE (LEVELING_SETTINGS_BACK + 1) + #define LEVELING_SETTINGS_LEVELTEMP_MODE (LEVELING_SETTINGS_BACK + ENABLED(PREHEAT_BEFORE_LEVELING)) + #define LEVELING_SETTINGS_HOTENDTEMP (LEVELING_SETTINGS_LEVELTEMP_MODE + ENABLED(PREHEAT_BEFORE_LEVELING)) + #define LEVELING_SETTINGS_BEDTEMP (LEVELING_SETTINGS_HOTENDTEMP + ENABLED(PREHEAT_BEFORE_LEVELING)) + #define LEVELING_SETTINGS_FADE (LEVELING_SETTINGS_BEDTEMP + 1) #define LEVELING_SETTINGS_TILT (LEVELING_SETTINGS_FADE + ENABLED(AUTO_BED_LEVELING_UBL)) #define LEVELING_SETTINGS_PLANE (LEVELING_SETTINGS_TILT + ENABLED(AUTO_BED_LEVELING_UBL)) #define LEVELING_SETTINGS_ZERO (LEVELING_SETTINGS_PLANE + ENABLED(AUTO_BED_LEVELING_UBL)) @@ -3210,31 +3971,59 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case LEVELING_SETTINGS_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else Draw_Menu(Leveling, LEVELING_SETTINGS); break; - case LEVELING_SETTINGS_FADE: + #if ENABLED(PREHEAT_BEFORE_LEVELING) + case LEVELING_SETTINGS_LEVELTEMP_MODE: + if (draw) { + Draw_Menu_Item(row, ICON_Homing, F("Preheat Mode")); + Draw_Option(temp_val.LevelingTempmode, preheat_levmodes, row); + } + else + Modify_Option(temp_val.LevelingTempmode, preheat_levmodes, 3); + break; + case LEVELING_SETTINGS_HOTENDTEMP: if (draw) { - Draw_Menu_Item(row, ICON_Fade, F("Fade Mesh within")); - Draw_Float(planner.z_fade_height, row, false, 1); - } - else { - Modify_Value(planner.z_fade_height, 0, Z_MAX_POS, 1); - planner.z_fade_height = -1; - set_z_fade_height(planner.z_fade_height); + Draw_Menu_Item(row, ICON_SetEndTemp, F("Preheat Hotend")); + Draw_Float(eeprom_settings.hotend_levtemp, row, false, 1); } + else + Modify_Value(eeprom_settings.hotend_levtemp, MIN_E_TEMP, MAX_E_TEMP, 1); break; + case LEVELING_SETTINGS_BEDTEMP: + if (draw) { + Draw_Menu_Item(row, ICON_SetBedTemp, F("Preheat Bed")); + Draw_Float(eeprom_settings.bed_levtemp, row, false, 1); + } + else + Modify_Value(eeprom_settings.bed_levtemp, MIN_BED_TEMP, MAX_BED_TEMP, 1); + break; + #endif + case LEVELING_SETTINGS_FADE: + if (draw) { + Draw_Menu_Item(row, ICON_Fade, GET_TEXT_F(MSG_Z_FADE_HEIGHT)); + Draw_Float(planner.z_fade_height, row, false, 1); + } + else { + Modify_Value(planner.z_fade_height, 0, Z_MAX_POS, 1); + planner.z_fade_height = -1; + set_z_fade_height(planner.z_fade_height); + } + break; #if ENABLED(AUTO_BED_LEVELING_UBL) + case LEVELING_SETTINGS_TILT: if (draw) { - Draw_Menu_Item(row, ICON_Tilt, F("Tilting Grid Size")); + Draw_Menu_Item(row, ICON_Tilt, F("Tilting Grid")); Draw_Float(mesh_conf.tilt_grid, row, false, 1); } else Modify_Value(mesh_conf.tilt_grid, 1, 8, 1); break; + case LEVELING_SETTINGS_PLANE: if (draw) Draw_Menu_Item(row, ICON_ResumeEEPROM, F("Convert Mesh to Plane")); @@ -3245,18 +4034,21 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ AudioFeedback(true); } break; + case LEVELING_SETTINGS_ZERO: if (draw) Draw_Menu_Item(row, ICON_Mesh, F("Zero Current Mesh")); else ZERO(bedlevel.z_values); break; + case LEVELING_SETTINGS_UNDEF: if (draw) Draw_Menu_Item(row, ICON_Mesh, F("Clear Current Mesh")); else bedlevel.invalidate(); break; + #endif // AUTO_BED_LEVELING_UBL } break; @@ -3267,7 +4059,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ if (item == MESHVIEW_BACK) { if (draw) { - Draw_Menu_Item(0, ICON_Back, F("Back")); + Draw_Menu_Item(0, ICON_Back, GET_TEXT_F(MSG_BACK)); mesh_conf.Draw_Bed_Mesh(); mesh_conf.Set_Mesh_Viewer_Status(); } @@ -3294,7 +4086,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case LEVELING_M_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else { set_bed_leveling_enabled(level_state); TERN_(AUTO_BED_LEVELING_BILINEAR, bedlevel.refresh_bed_level()); @@ -3303,7 +4095,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case LEVELING_M_X: if (draw) { - Draw_Menu_Item(row, ICON_MoveX, F("Mesh Point X")); + Draw_Menu_Item(row, ICON_MoveX, GET_TEXT_F(MSG_MESH_X)); Draw_Float(mesh_conf.mesh_x, row, 0, 1); } else @@ -3311,7 +4103,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case LEVELING_M_Y: if (draw) { - Draw_Menu_Item(row, ICON_MoveY, F("Mesh Point Y")); + Draw_Menu_Item(row, ICON_MoveY, GET_TEXT_F(MSG_MESH_Y)); Draw_Float(mesh_conf.mesh_y, row, 0, 1); } else @@ -3319,15 +4111,15 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case LEVELING_M_NEXT: if (draw) - Draw_Menu_Item(row, ICON_More, F("Next Point")); + Draw_Menu_Item(row, ICON_More, GET_TEXT_F(MSG_LEVEL_BED_NEXT_POINT)); else { if (mesh_conf.mesh_x != (GRID_MAX_POINTS_X - 1) || mesh_conf.mesh_y != (GRID_MAX_POINTS_Y - 1)) { - if ((mesh_conf.mesh_x == (GRID_MAX_POINTS_X - 1) && mesh_conf.mesh_y % 2 == 0) || (mesh_conf.mesh_x == 0 && mesh_conf.mesh_y % 2 == 1)) + if ((mesh_conf.mesh_x == (GRID_MAX_POINTS_X - 1) && !(mesh_conf.mesh_y & 1)) || (!mesh_conf.mesh_x && (mesh_conf.mesh_y & 1))) mesh_conf.mesh_y++; - else if (mesh_conf.mesh_y % 2 == 0) - mesh_conf.mesh_x++; - else + else if (mesh_conf.mesh_y & 1) mesh_conf.mesh_x--; + else + mesh_conf.mesh_x++; mesh_conf.manual_mesh_move(); } } @@ -3407,7 +4199,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case UBL_M_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); else { set_bed_leveling_enabled(level_state); Draw_Menu(Leveling, LEVELING_GET_MESH); @@ -3416,18 +4208,18 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case UBL_M_NEXT: if (draw) { if (mesh_conf.mesh_x != (GRID_MAX_POINTS_X - 1) || mesh_conf.mesh_y != (GRID_MAX_POINTS_Y - 1)) - Draw_Menu_Item(row, ICON_More, F("Next Point")); + Draw_Menu_Item(row, ICON_More, GET_TEXT_F(MSG_LEVEL_BED_NEXT_POINT)); else - Draw_Menu_Item(row, ICON_More, F("Save Mesh")); + Draw_Menu_Item(row, ICON_More, GET_TEXT_F(MSG_UBL_SAVE_MESH)); } else { if (mesh_conf.mesh_x != (GRID_MAX_POINTS_X - 1) || mesh_conf.mesh_y != (GRID_MAX_POINTS_Y - 1)) { - if ((mesh_conf.mesh_x == (GRID_MAX_POINTS_X - 1) && mesh_conf.mesh_y % 2 == 0) || (mesh_conf.mesh_x == 0 && mesh_conf.mesh_y % 2 == 1)) + if ((mesh_conf.mesh_x == (GRID_MAX_POINTS_X - 1) && !(mesh_conf.mesh_y & 1)) || (!mesh_conf.mesh_x && (mesh_conf.mesh_y & 1))) mesh_conf.mesh_y++; - else if (mesh_conf.mesh_y % 2 == 0) - mesh_conf.mesh_x++; - else + else if (mesh_conf.mesh_y & 1) mesh_conf.mesh_x--; + else + mesh_conf.mesh_x++; mesh_conf.manual_mesh_move(); } else { @@ -3443,12 +4235,12 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ Draw_Menu_Item(row, ICON_More, F("Previous Point")); else { if (mesh_conf.mesh_x != 0 || mesh_conf.mesh_y != 0) { - if ((mesh_conf.mesh_x == (GRID_MAX_POINTS_X - 1) && mesh_conf.mesh_y % 2 == 1) || (mesh_conf.mesh_x == 0 && mesh_conf.mesh_y % 2 == 0)) + if ((mesh_conf.mesh_x == (GRID_MAX_POINTS_X - 1) && (mesh_conf.mesh_y & 1)) || (!mesh_conf.mesh_x && !(mesh_conf.mesh_y & 1))) mesh_conf.mesh_y--; - else if (mesh_conf.mesh_y % 2 == 0) - mesh_conf.mesh_x--; - else + else if (mesh_conf.mesh_y & 1) mesh_conf.mesh_x++; + else + mesh_conf.mesh_x--; mesh_conf.manual_mesh_move(); } } @@ -3506,7 +4298,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ switch (item) { case MMESH_BACK: if (draw) - Draw_Menu_Item(row, ICON_Back, F("Cancel")); + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BUTTON_CANCEL)); else { gcode.process_subcommands_now(F("G29 A")); planner.synchronize(); @@ -3516,16 +4308,16 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case MMESH_NEXT: if (draw) { - if (gridpoint < GRID_MAX_POINTS) - Draw_Menu_Item(row, ICON_More, F("Next Point")); + if (temp_val.gridpoint < GRID_MAX_POINTS) + Draw_Menu_Item(row, ICON_More, GET_TEXT_F(MSG_LEVEL_BED_NEXT_POINT)); else - Draw_Menu_Item(row, ICON_More, F("Save Mesh")); + Draw_Menu_Item(row, ICON_More, GET_TEXT_F(MSG_UBL_SAVE_MESH)); } - else if (gridpoint < GRID_MAX_POINTS) { + else if (temp_val.gridpoint < GRID_MAX_POINTS) { Popup_Handler(MoveWait); gcode.process_subcommands_now(F("G29")); planner.synchronize(); - gridpoint++; + temp_val.gridpoint++; Redraw_Menu(); } else { @@ -3569,16 +4361,16 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case MMESH_OLD: uint8_t mesh_x, mesh_y; // 0,0 -> 1,0 -> 2,0 -> 2,1 -> 1,1 -> 0,1 -> 0,2 -> 1,2 -> 2,2 - mesh_y = (gridpoint - 1) / (GRID_MAX_POINTS_Y); - mesh_x = (gridpoint - 1) % (GRID_MAX_POINTS_X); + mesh_y = (temp_val.gridpoint - 1) / (GRID_MAX_POINTS_Y); + mesh_x = (temp_val.gridpoint - 1) % (GRID_MAX_POINTS_X); - if (mesh_y % 2 == 1) + if (mesh_y & 1) mesh_x = (GRID_MAX_POINTS_X) - mesh_x - 1; const float currval = bedlevel.z_values[mesh_x][mesh_y]; if (draw) { - Draw_Menu_Item(row, ICON_Zoffset, F("Goto Mesh Value")); + Draw_Menu_Item(row, ICON_Zoffset, GET_TEXT_F(MSG_MESH_EDIT_Z)); Draw_Float(currval, row, false, 100); } else if (!isnan(currval)) { @@ -3604,22 +4396,25 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #define TUNE_ZOFFSET (TUNE_FAN + ENABLED(HAS_ZOFFSET_ITEM)) #define TUNE_ZUP (TUNE_ZOFFSET + ENABLED(HAS_ZOFFSET_ITEM)) #define TUNE_ZDOWN (TUNE_ZUP + ENABLED(HAS_ZOFFSET_ITEM)) - #define TUNE_CHANGEFIL (TUNE_ZDOWN + ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)) + #define TUNE_FWRETRACT (TUNE_ZDOWN + ENABLED(FWRETRACT)) + #define TUNE_HOSTACTIONS (TUNE_FWRETRACT + ENABLED(HAS_HOSTACTION_MENUS)) + #define TUNE_CHANGEFIL (TUNE_HOSTACTIONS + ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)) #define TUNE_FILSENSORENABLED (TUNE_CHANGEFIL + ENABLED(FILAMENT_RUNOUT_SENSOR)) #define TUNE_BACKLIGHT_OFF (TUNE_FILSENSORENABLED + 1) #define TUNE_BACKLIGHT (TUNE_BACKLIGHT_OFF + 1) - #define TUNE_TOTAL TUNE_BACKLIGHT + #define TUNE_CASELIGHT (TUNE_BACKLIGHT + ENABLED(CASE_LIGHT_MENU)) + #define TUNE_LEDCONTROL (TUNE_CASELIGHT + (ENABLED(LED_CONTROL_MENU) && DISABLED(CASE_LIGHT_USE_NEOPIXEL))) + #define TUNE_LOCKSCREEN (TUNE_LEDCONTROL + ENABLED(HAS_LOCKSCREEN)) + #define TUNE_TOTAL TUNE_LOCKSCREEN switch (item) { case TUNE_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); - else - Draw_Print_Screen(); + if (draw) Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); + else Draw_Print_Screen(); break; case TUNE_SPEED: if (draw) { - Draw_Menu_Item(row, ICON_Speed, F("Print Speed")); + Draw_Menu_Item(row, ICON_Speed, GET_TEXT_F(MSG_SPEED)); Draw_Float(feedrate_percentage, row, false, 1); } else @@ -3629,7 +4424,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if HAS_HOTEND case TUNE_FLOW: if (draw) { - Draw_Menu_Item(row, ICON_Speed, F("Flow Rate")); + Draw_Menu_Item(row, ICON_Speed, GET_TEXT_F(MSG_FLOW)); Draw_Float(planner.flow_percentage[0], row, false, 1); } else @@ -3659,7 +4454,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if HAS_FAN case TUNE_FAN: if (draw) { - Draw_Menu_Item(row, ICON_FanSpeed, F("Fan")); + Draw_Menu_Item(row, ICON_FanSpeed, GET_TEXT_F(MSG_FAN_SPEED)); Draw_Float(thermalManager.fan_speed[0], row, false, 1); } else @@ -3671,44 +4466,66 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case TUNE_ZOFFSET: if (draw) { Draw_Menu_Item(row, ICON_FanSpeed, F("Z-Offset")); - Draw_Float(zoffsetvalue, row, false, 100); + Draw_Float(temp_val.zoffsetvalue, row, false, 100); } else - Modify_Value(zoffsetvalue, MIN_Z_OFFSET, MAX_Z_OFFSET, 100); + Modify_Value(temp_val.zoffsetvalue, MIN_Z_OFFSET, MAX_Z_OFFSET, 100); break; case TUNE_ZUP: if (draw) - Draw_Menu_Item(row, ICON_Axis, F("Z-Offset Up")); - else if (zoffsetvalue < MAX_Z_OFFSET) { - gcode.process_subcommands_now(F("M290 Z0.01")); - zoffsetvalue += 0.01; - Draw_Float(zoffsetvalue, row - 1, false, 100); + Draw_Menu_Item(row, ICON_Axis, F("Z-Offset Up")); + else if (temp_val.zoffsetvalue < MAX_Z_OFFSET) { + gcode.process_subcommands_now(F("M290 Z0.01")); + temp_val.zoffsetvalue += 0.01; + Draw_Float(temp_val.zoffsetvalue, row - 1, false, 100); + } + break; + case TUNE_ZDOWN: + if (draw) + Draw_Menu_Item(row, ICON_AxisD, F("Z-Offset Down")); + else if (temp_val.zoffsetvalue > MIN_Z_OFFSET) { + gcode.process_subcommands_now(F("M290 Z-0.01")); + temp_val.zoffsetvalue -= 0.01; + Draw_Float(temp_val.zoffsetvalue, row - 2, false, 100); + } + break; + #endif + + #if ENABLED(FWRETRACT) + case TUNE_FWRETRACT: + if (draw) + Draw_Menu_Item(row, ICON_StepE, GET_TEXT_F(MSG_AUTORETRACT), nullptr, true); + else { + temp_val.flag_tune = true; + last_pos_selection = selection; + Draw_Menu(FwRetraction); } break; - case TUNE_ZDOWN: + #endif + + #if HAS_HOSTACTION_MENUS + case TUNE_HOSTACTIONS: if (draw) - Draw_Menu_Item(row, ICON_AxisD, F("Z-Offset Down")); - else if (zoffsetvalue > MIN_Z_OFFSET) { - gcode.process_subcommands_now(F("M290 Z-0.01")); - zoffsetvalue -= 0.01; - Draw_Float(zoffsetvalue, row - 2, false, 100); + Draw_Menu_Item(row, ICON_SetHome, F("Host Actions"), nullptr, true); + else { + temp_val.flag_tune = true; + last_pos_selection = selection; + Draw_Menu(HostActions); } break; #endif #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) case TUNE_CHANGEFIL: - if (draw) - Draw_Menu_Item(row, ICON_ResumeEEPROM, F("Change Filament")); - else - Popup_Handler(ConfFilChange); + if (draw) Draw_Menu_Item(row, ICON_ResumeEEPROM, GET_TEXT_F(MSG_FILAMENTCHANGE)); + else Popup_Handler(ConfFilChange); break; #endif #if ENABLED(FILAMENT_RUNOUT_SENSOR) case TUNE_FILSENSORENABLED: if (draw) { - Draw_Menu_Item(row, ICON_Extruder, F("Filament Sensor")); + Draw_Menu_Item(row, ICON_Extruder, GET_TEXT_F(MSG_RUNOUT_SENSOR)); Draw_Checkbox(row, runout.enabled); } else { @@ -3719,106 +4536,138 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #endif case TUNE_BACKLIGHT_OFF: - if (draw) - Draw_Menu_Item(row, ICON_Brightness, F("Display Off")); - else - ui.set_brightness(0); + if (draw) Draw_Menu_Item(row, ICON_Brightness, GET_TEXT_F(MSG_BRIGHTNESS_OFF)); + else ui.set_brightness(0); break; case TUNE_BACKLIGHT: if (draw) { - Draw_Menu_Item(row, ICON_Brightness, F("LCD Brightness")); + Draw_Menu_Item(row, ICON_Brightness, GET_TEXT_F(MSG_BRIGHTNESS)); Draw_Float(ui.brightness, row, false, 1); } else Modify_Value(ui.brightness, LCD_BRIGHTNESS_MIN, LCD_BRIGHTNESS_MAX, 1, ui.refresh_brightness); break; - } - break; - - #if HAS_PREHEAT && HAS_HOTEND - - case PreheatHotend: - - #define PREHEATHOTEND_BACK 0 - #define PREHEATHOTEND_CONTINUE (PREHEATHOTEND_BACK + 1) - #define PREHEATHOTEND_1 (PREHEATHOTEND_CONTINUE + (PREHEAT_COUNT >= 1)) - #define PREHEATHOTEND_2 (PREHEATHOTEND_1 + (PREHEAT_COUNT >= 2)) - #define PREHEATHOTEND_3 (PREHEATHOTEND_2 + (PREHEAT_COUNT >= 3)) - #define PREHEATHOTEND_4 (PREHEATHOTEND_3 + (PREHEAT_COUNT >= 4)) - #define PREHEATHOTEND_5 (PREHEATHOTEND_4 + (PREHEAT_COUNT >= 5)) - #define PREHEATHOTEND_CUSTOM (PREHEATHOTEND_5 + 1) - #define PREHEATHOTEND_TOTAL PREHEATHOTEND_CUSTOM - - switch (item) { - case PREHEATHOTEND_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, F("Cancel")); + #if ENABLED(CASE_LIGHT_MENU) + case TUNE_CASELIGHT: + if (draw) { + Draw_Menu_Item(row, ICON_CaseLight, GET_TEXT_F(MSG_CASE_LIGHT)); + Draw_Checkbox(row, caselight.on); + } else { - thermalManager.setTargetHotend(0, 0); - thermalManager.set_fan_speed(0, 0); - Redraw_Menu(false, true, true); + caselight.on = !caselight.on; + caselight.update_enabled(); + Draw_Checkbox(row, caselight.on); } break; - case PREHEATHOTEND_CONTINUE: - if (draw) - Draw_Menu_Item(row, ICON_SetEndTemp, F("Continue")); + #endif + #if ENABLED(LED_CONTROL_MENU) && DISABLED(CASE_LIGHT_USE_NEOPIXEL) + case TUNE_LEDCONTROL: + if (draw) { + Draw_Menu_Item(row, ICON_LedControl, GET_TEXT_F(MSG_LEDS)); + Draw_Checkbox(row, leds.lights_on); + } else { - Popup_Handler(Heating); - thermalManager.wait_for_hotend(0); - switch (last_menu) { - case Prepare: - Popup_Handler(FilChange); - sprintf_P(cmd, PSTR("M600 B1 R%i"), thermalManager.temp_hotend[0].target); - gcode.process_subcommands_now(cmd); - break; - #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) - case ChangeFilament: - switch (last_selection) { - case CHANGEFIL_LOAD: - Popup_Handler(FilLoad); - gcode.process_subcommands_now(F("M701")); - planner.synchronize(); - Redraw_Menu(true, true, true); - break; - case CHANGEFIL_UNLOAD: - Popup_Handler(FilLoad, true); - gcode.process_subcommands_now(F("M702")); - planner.synchronize(); - Redraw_Menu(true, true, true); - break; - case CHANGEFIL_CHANGE: - Popup_Handler(FilChange); - sprintf_P(cmd, PSTR("M600 B1 R%i"), thermalManager.temp_hotend[0].target); - gcode.process_subcommands_now(cmd); - break; - } - break; - #endif - default: - Redraw_Menu(true, true, true); - break; - } + leds.toggle(); + Draw_Checkbox(row, leds.lights_on); } break; + #endif + #if HAS_LOCKSCREEN + case TUNE_LOCKSCREEN: + if (draw) Draw_Menu_Item(row, ICON_Lock, GET_TEXT_F(MSG_LOCKSCREEN)); + else DWIN_LockScreen(); + break; + #endif + } + break; + #if HAS_PREHEAT && HAS_HOTEND + case PreheatHotend: - #define _PREHEAT_HOTEND_CASE(N) \ - case PREHEATHOTEND_##N: \ - if (draw) Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_## N ##_LABEL)); \ - else ui.preheat_hotend_and_fan((N) - 1); \ + #define PREHEATHOTEND_BACK 0 + #define PREHEATHOTEND_CONTINUE (PREHEATHOTEND_BACK + 1) + #define PREHEATHOTEND_1 (PREHEATHOTEND_CONTINUE + (PREHEAT_COUNT >= 1)) + #define PREHEATHOTEND_2 (PREHEATHOTEND_1 + (PREHEAT_COUNT >= 2)) + #define PREHEATHOTEND_3 (PREHEATHOTEND_2 + (PREHEAT_COUNT >= 3)) + #define PREHEATHOTEND_4 (PREHEATHOTEND_3 + (PREHEAT_COUNT >= 4)) + #define PREHEATHOTEND_5 (PREHEATHOTEND_4 + (PREHEAT_COUNT >= 5)) + #define PREHEATHOTEND_CUSTOM (PREHEATHOTEND_5 + 1) + #define PREHEATHOTEND_TOTAL PREHEATHOTEND_CUSTOM + + switch (item) { + case PREHEATHOTEND_BACK: + if (draw) + Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BUTTON_CANCEL)); + else { + thermalManager.setTargetHotend(0, 0); + thermalManager.set_fan_speed(0, 0); + Redraw_Menu(false, true, true); + } + break; + case PREHEATHOTEND_CONTINUE: + if (draw) + Draw_Menu_Item(row, ICON_SetEndTemp, GET_TEXT_F(MSG_BUTTON_CONTINUE)); + else { + Popup_Handler(Heating); + thermalManager.wait_for_hotend(0); + switch (last_menu) { + case Prepare: + Popup_Handler(FilChange); + sprintf_P(cmd, PSTR("M600 B1 R%i"), thermalManager.temp_hotend[0].target); + gcode.process_subcommands_now(cmd); + Draw_Menu(Prepare, PREPARE_CHANGEFIL); + break; + #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) + case ChangeFilament: + switch (last_selection) { + case CHANGEFIL_LOAD: + Popup_Handler(FilLoad); + Update_Status(GET_TEXT(MSG_FILAMENTLOAD)); + gcode.process_subcommands_now(F("M701")); + planner.synchronize(); + Draw_Menu(ChangeFilament, CHANGEFIL_LOAD); + break; + case CHANGEFIL_UNLOAD: + Popup_Handler(FilLoad, true); + Update_Status(GET_TEXT(MSG_FILAMENTUNLOAD)); + gcode.process_subcommands_now(F("M702")); + planner.synchronize(); + Draw_Menu(ChangeFilament, CHANGEFIL_UNLOAD); + break; + case CHANGEFIL_CHANGE: + Popup_Handler(FilChange); + Update_Status(GET_TEXT(MSG_FILAMENTCHANGE)); + sprintf_P(cmd, PSTR("M600 B1 R%i"), thermalManager.temp_hotend[0].target); + gcode.process_subcommands_now(cmd); + Draw_Menu(ChangeFilament, CHANGEFIL_CHANGE); + break; + } + break; + #endif + default: + Redraw_Menu(true, true, true); + break; + } + } break; - REPEAT_1(PREHEAT_COUNT, _PREHEAT_HOTEND_CASE) + #define _PREHEAT_HOTEND_CASE(N) \ + case PREHEATHOTEND_##N: \ + if (draw) Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_## N ##_LABEL)); \ + else ui.preheat_hotend_and_fan((N) - 1); \ + break; - case PREHEATHOTEND_CUSTOM: - if (draw) { - Draw_Menu_Item(row, ICON_Temperature, F("Custom")); - Draw_Float(thermalManager.temp_hotend[0].target, row, false, 1); - } - else - Modify_Value(thermalManager.temp_hotend[0].target, EXTRUDE_MINTEMP, MAX_E_TEMP, 1); - break; - } + REPEAT_1(PREHEAT_COUNT, _PREHEAT_HOTEND_CASE) + + case PREHEATHOTEND_CUSTOM: + if (draw) { + Draw_Menu_Item(row, ICON_Temperature, GET_TEXT_F(MSG_PREHEAT_CUSTOM)); + Draw_Float(thermalManager.temp_hotend[0].target, row, false, 1); + } + else + Modify_Value(thermalManager.temp_hotend[0].target, EXTRUDE_MINTEMP, MAX_E_TEMP, 1); + break; + } break; #endif // HAS_PREHEAT && HAS_HOTEND @@ -3827,11 +4676,11 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ FSTR_P CrealityDWINClass::Get_Menu_Title(uint8_t menu) { switch (menu) { - case MainMenu: return F("Main Menu"); - case Prepare: return F("Prepare"); - case HomeMenu: return F("Homing Menu"); - case Move: return F("Move"); - case ManualLevel: return F("Manual Leveling"); + case MainMenu: return GET_TEXT_F(MSG_MAIN); + case Prepare: return GET_TEXT_F(MSG_PREPARE); + case HomeMenu: return GET_TEXT_F(MSG_HOMING); + case Move: return GET_TEXT_F(MSG_MOVE_AXIS); + case ManualLevel: return GET_TEXT_F(MSG_BED_TRAMMING_MANUAL); #if HAS_ZOFFSET_ITEM case ZOffset: return F("Z Offset"); #endif @@ -3839,7 +4688,10 @@ FSTR_P CrealityDWINClass::Get_Menu_Title(uint8_t menu) { case Preheat: return F("Preheat"); #endif #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) - case ChangeFilament: return F("Change Filament"); + case ChangeFilament: return GET_TEXT_F(MSG_FILAMENTCHANGE); + #endif + #if HAS_HOSTACTION_MENUS + case HostActions: return F("Host Actions"); #endif #if HAS_CUSTOM_MENU case MenuCustom: @@ -3849,8 +4701,8 @@ FSTR_P CrealityDWINClass::Get_Menu_Title(uint8_t menu) { return F("Custom Commands"); #endif #endif - case Control: return F("Control"); - case TempMenu: return F("Temperature"); + case Control: return GET_TEXT_F(MSG_CONTROL); + case TempMenu: return GET_TEXT_F(MSG_TEMPERATURE); #if HAS_HOTEND || HAS_HEATED_BED case PID: return F("PID Menu"); #endif @@ -3865,36 +4717,62 @@ FSTR_P CrealityDWINClass::Get_Menu_Title(uint8_t menu) { REPEAT_1(PREHEAT_COUNT, _PREHEAT_TITLE_CASE) #endif case Motion: return F("Motion Settings"); - case HomeOffsets: return F("Home Offsets"); - case MaxSpeed: return F("Max Speed"); - case MaxAcceleration: return F("Max Acceleration"); + #if ENABLED(FWRETRACT) + case FwRetraction: return F("Firmware Retract"); + #endif + case HomeOffsets: return GET_TEXT_F(MSG_SET_HOME_OFFSETS); + case MaxSpeed: return GET_TEXT_F(MSG_SPEED); + case MaxAcceleration: return GET_TEXT_F(MSG_ACCELERATION); #if HAS_CLASSIC_JERK - case MaxJerk: return F("Max Jerk"); + case MaxJerk: return GET_TEXT_F(MSG_JERK); + #endif + #if HAS_JUNCTION_DEVIATION + case JDmenu: return GET_TEXT_F(MSG_JUNCTION_DEVIATION); #endif - case Steps: return F("Steps/mm"); + case Steps: return GET_TEXT_F(MSG_STEPS_PER_MM); case Visual: return F("Visual Settings"); - case Advanced: return F("Advanced Settings"); + #if HAS_HOSTACTION_MENUS + case HostSettings: return F("Host Settings"); + case ActionCommands: return F("Host Actions"); + #endif + case Advanced: return GET_TEXT_F(MSG_ADVANCED_SETTINGS); #if HAS_BED_PROBE - case ProbeMenu: return F("Probe Menu"); + case ProbeMenu: return GET_TEXT_F(MSG_ZPROBE_SETTINGS); #endif case ColorSettings: return F("UI Color Settings"); - case Info: return F("Info"); - case InfoMain: return F("Info"); + case Info: + case InfoMain: return GET_TEXT_F(MSG_INFO_SCREEN); #if HAS_MESH - case Leveling: return F("Leveling"); + case Leveling: return GET_TEXT_F(MSG_BED_LEVELING); case LevelView: return GET_TEXT_F(MSG_MESH_VIEW); case LevelSettings: return F("Leveling Settings"); case MeshViewer: return GET_TEXT_F(MSG_MESH_VIEW); - case LevelManual: return F("Manual Tuning"); + case LevelManual: return GET_TEXT_F(MSG_UBL_FINE_TUNE_MESH); #endif #if ENABLED(AUTO_BED_LEVELING_UBL) && !HAS_BED_PROBE - case UBLMesh: return F("UBL Bed Leveling"); + case UBLMesh: return GET_TEXT_F(MSG_UBL_LEVEL_BED); #endif #if ENABLED(PROBE_MANUALLY) - case ManualMesh: return F("Mesh Bed Leveling"); + case ManualMesh: return GET_TEXT_F(MSG_MESH_LEVELING); #endif - case Tune: return F("Tune"); + case Tune: return GET_TEXT_F(MSG_TUNE); case PreheatHotend: return F("Preheat Hotend"); + #if ANY(CASE_LIGHT_MENU, LED_CONTROL_MENU) + case Ledsmenu: return F("Light Settings"); + #if ENABLED(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS) + case CaseLightmenu: return GET_TEXT_F(MSG_CASE_LIGHT); + #endif + #if ENABLED(LED_CONTROL_MENU) + case LedControlmenu: return GET_TEXT_F(MSG_LED_CONTROL); + #if HAS_COLOR_LEDS + #if ENABLED(LED_COLOR_PRESETS) + case LedControlpresets: return GET_TEXT_F(MSG_LED_PRESETS); + #else + case LedControlcustom: return GET_TEXT_F(MSG_CUSTOM_LEDS); + #endif + #endif + #endif + #endif } return F(""); } @@ -3914,6 +4792,9 @@ uint8_t CrealityDWINClass::Get_Menu_Size(uint8_t menu) { #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) case ChangeFilament: return CHANGEFIL_TOTAL; #endif + #if HAS_HOSTACTION_MENUS + case HostActions: return HOSTACTIONS_TOTAL; + #endif #if HAS_CUSTOM_MENU case MenuCustom: return CUSTOM_MENU_TOTAL; #endif @@ -3933,14 +4814,24 @@ uint8_t CrealityDWINClass::Get_Menu_Size(uint8_t menu) { return PREHEAT_SUBMENU_TOTAL; #endif case Motion: return MOTION_TOTAL; + #if ENABLED(FWRETRACT) + case FwRetraction: return FWR_TOTAL; + #endif case HomeOffsets: return HOMEOFFSETS_TOTAL; case MaxSpeed: return SPEED_TOTAL; case MaxAcceleration: return ACCEL_TOTAL; #if HAS_CLASSIC_JERK case MaxJerk: return JERK_TOTAL; #endif + #if HAS_JUNCTION_DEVIATION + case JDmenu: return JD_TOTAL; + #endif case Steps: return STEPS_TOTAL; case Visual: return VISUAL_TOTAL; + #if HAS_HOSTACTION_MENUS + case HostSettings: return HOSTSETTINGS_TOTAL; + case ActionCommands: return ACTIONCOMMANDS_TOTAL; + #endif case Advanced: return ADVANCED_TOTAL; #if HAS_BED_PROBE case ProbeMenu: return PROBE_TOTAL; @@ -3967,6 +4858,22 @@ uint8_t CrealityDWINClass::Get_Menu_Size(uint8_t menu) { #endif case ColorSettings: return COLORSETTINGS_TOTAL; + #if ANY(CASE_LIGHT_MENU, LED_CONTROL_MENU) + case Ledsmenu: return LEDS_TOTAL; + #if ENABLED(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS) + case CaseLightmenu: return CASE_LIGHT_TOTAL; + #endif + #if ENABLED(LED_CONTROL_MENU) + case LedControlmenu: return LEDCONTROL_TOTAL; + #if HAS_COLOR_LEDS + #if ENABLED(LED_COLOR_PRESETS) + case LedControlpresets: return LEDCONTROL_PRESETS_TOTAL; + #else + case LedControlcustom: return LEDCONTROL_CUSTOM_TOTAL; + #endif + #endif + #endif + #endif } return 0; } @@ -3976,36 +4883,42 @@ uint8_t CrealityDWINClass::Get_Menu_Size(uint8_t menu) { void CrealityDWINClass::Popup_Handler(PopupID popupid, bool option/*=false*/) { popup = last_popup = popupid; switch (popupid) { - case Pause: Draw_Popup(F("Pause Print"), F(""), F(""), Popup); break; - case Stop: Draw_Popup(F("Stop Print"), F(""), F(""), Popup); break; - case Resume: Draw_Popup(F("Resume Print?"), F("Looks Like the last"), F("print was interrupted."), Popup); break; + case Pause: Draw_Popup(GET_TEXT_F(MSG_PAUSE_PRINT), F(""), F(""), Popup); break; + case Stop: Draw_Popup(GET_TEXT_F(MSG_STOP_PRINT), F(""), F(""), Popup); break; + case Resume: Draw_Popup(GET_TEXT_F(MSG_RESUME_PRINT), F("Looks Like the last"), F("print was interrupted."), Popup); break; case ConfFilChange: Draw_Popup(F("Confirm Filament Change"), F(""), F(""), Popup); break; case PurgeMore: Draw_Popup(F("Purge more filament?"), F("(Cancel to finish process)"), F(""), Popup); break; case SaveLevel: Draw_Popup(F("Leveling Complete"), F("Save to EEPROM?"), F(""), Popup); break; case MeshSlot: Draw_Popup(F("Mesh slot not selected"), F("(Confirm to select slot 0)"), F(""), Popup); break; - case ETemp: Draw_Popup(F("Nozzle is too cold"), F("Open Preheat Menu?"), F(""), Popup); break; + case ETemp: Draw_Popup(GET_TEXT_F(MSG_HOTEND_TOO_COLD), GET_TEXT_F(MSG_PLEASE_PREHEAT), F(""), Popup); break; case ManualProbing: Draw_Popup(F("Manual Probing"), F("(Confirm to probe)"), F("(cancel to exit)"), Popup); break; - case Level: Draw_Popup(F("Auto Bed Leveling"), F("Please wait until done."), F(""), Wait, ICON_AutoLeveling); break; - case Home: Draw_Popup(option ? F("Parking") : F("Homing"), F("Please wait until done."), F(""), Wait, ICON_BLTouch); break; - case MoveWait: Draw_Popup(F("Moving to Point"), F("Please wait until done."), F(""), Wait, ICON_BLTouch); break; - case Heating: Draw_Popup(F("Heating"), F("Please wait until done."), F(""), Wait, ICON_BLTouch); break; - case FilLoad: Draw_Popup(option ? F("Unloading Filament") : F("Loading Filament"), F("Please wait until done."), F(""), Wait, ICON_BLTouch); break; + case Level: Draw_Popup(F("Auto Bed Leveling"), GET_TEXT_F(MSG_PLEASE_WAIT), F(""), Wait, ICON_AutoLeveling); break; + case Home: Draw_Popup(option ? GET_TEXT_F(MSG_PAUSE_PRINT_PARKING) : GET_TEXT_F(MSG_HOMING), GET_TEXT_F(MSG_PLEASE_WAIT), F(""), Wait, ICON_BLTouch); break; + case MoveWait: Draw_Popup(GET_TEXT_F(MSG_MOVING), GET_TEXT_F(MSG_PLEASE_WAIT), F(""), Wait, ICON_BLTouch); break; + case Heating: Draw_Popup(GET_TEXT_F(MSG_HEATING), GET_TEXT_F(MSG_PLEASE_WAIT), F(""), Wait, ICON_BLTouch); break; + case FilLoad: Draw_Popup(option ? F("Unloading Filament") : F("Loading Filament"), GET_TEXT_F(MSG_PLEASE_WAIT), F(""), Wait, ICON_BLTouch); break; case FilChange: Draw_Popup(F("Filament Change"), F("Please wait for prompt."), F(""), Wait, ICON_BLTouch); break; - case TempWarn: Draw_Popup(option ? F("Nozzle temp too low!") : F("Nozzle temp too high!"), F(""), F(""), Wait, option ? ICON_TempTooLow : ICON_TempTooHigh); break; + case TempWarn: Draw_Popup(option ? GET_TEXT_F(MSG_HOTEND_TOO_COLD) : F("Nozzle temp too high!"), F(""), F(""), Wait, option ? ICON_TempTooLow : ICON_TempTooHigh); break; case Runout: Draw_Popup(F("Filament Runout"), F(""), F(""), Wait, ICON_BLTouch); break; - case PIDWait: Draw_Popup(F("PID Autotune"), F("in process"), F("Please wait until done."), Wait, ICON_BLTouch); break; - case Resuming: Draw_Popup(F("Resuming Print"), F("Please wait until done."), F(""), Wait, ICON_BLTouch); break; - case Custom: Draw_Popup(F("Running Custom GCode"), F("Please wait until done."), F(""), Wait, ICON_BLTouch); break; + #if !HAS_PIDPLOT + case PIDWait: Draw_Popup(F("PID Autotune"), F("in process"), GET_TEXT_F(MSG_PLEASE_WAIT), Wait, ICON_BLTouch); break; + #endif + case Resuming: Draw_Popup(F("Resuming Print"), GET_TEXT_F(MSG_PLEASE_WAIT), F(""), Wait, ICON_BLTouch); break; + #if HAS_CUSTOM_MENU + case Custom: Draw_Popup(F("Running Custom GCode"), GET_TEXT_F(MSG_PLEASE_WAIT), F(""), Wait, ICON_BLTouch); break; + #endif + case PrintConfirm: Draw_Popup(option ? F("") : F("Print file?"), F(""), F(""), Popup); break; default: break; } } -void CrealityDWINClass::Confirm_Handler(PopupID popupid) { +void CrealityDWINClass::Confirm_Handler(PopupID popupid, bool option/*=false*/) { popup = popupid; switch (popupid) { case FilInsert: Draw_Popup(F("Insert Filament"), F("Press to Continue"), F(""), Confirm); break; - case HeaterTime: Draw_Popup(F("Heater Timed Out"), F("Press to Reheat"), F(""), Confirm); break; - case UserInput: Draw_Popup(F("Waiting for Input"), F("Press to Continue"), F(""), Confirm); break; + case HeaterTime: Draw_Popup(GET_TEXT_F(MSG_HEATER_TIMEOUT), GET_TEXT_F(MSG_FILAMENT_CHANGE_HEAT), F(""), Confirm); break; + case UserInput: Draw_Popup(option ? GET_TEXT_F(MSG_STOPPED) : F("Waiting for Input"), GET_TEXT_F(MSG_ADVANCED_PAUSE_WAITING), F(""), Confirm); break; + case Level: Draw_Popup(F("Bed Leveling"), GET_TEXT_F(MSG_PLEASE_WAIT), F(""), Cancel, ICON_AutoLeveling); break; case LevelError: Draw_Popup(F("Couldn't enable Leveling"), F("(Valid mesh must exist)"), F(""), Confirm); break; case InvalidMesh: Draw_Popup(F("Valid mesh must exist"), F("before tuning can be"), F("performed"), Confirm); break; default: break; @@ -4039,24 +4952,24 @@ void CrealityDWINClass::Menu_Control() { EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState == ENCODER_DIFF_NO) return; if (encoder_diffState == ENCODER_DIFF_CW && selection < Get_Menu_Size(active_menu)) { - DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); + DWIN_Draw_Rectangle(1, Def_Background_Color, 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); selection++; // Select Down if (selection > scrollpos+MROWS) { scrollpos++; - DWIN_Frame_AreaMove(1, 2, MLINE, Color_Bg_Black, 0, 31, DWIN_WIDTH, 349); + DWIN_Frame_AreaMove(1, 2, MLINE, Def_Background_Color, 0, 31, DWIN_WIDTH, 349); Menu_Item_Handler(active_menu, selection); } - DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Rectangle_Color), 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); + DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Def_Cursor_color), 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); } else if (encoder_diffState == ENCODER_DIFF_CCW && selection > 0) { - DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); + DWIN_Draw_Rectangle(1, Def_Background_Color, 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); selection--; // Select Up if (selection < scrollpos) { scrollpos--; - DWIN_Frame_AreaMove(1, 3, MLINE, Color_Bg_Black, 0, 31, DWIN_WIDTH, 349); + DWIN_Frame_AreaMove(1, 3, MLINE, Def_Background_Color, 0, 31, DWIN_WIDTH, 349); Menu_Item_Handler(active_menu, selection); } - DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Rectangle_Color), 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); + DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Def_Cursor_color), 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); } else if (encoder_diffState == ENCODER_DIFF_ENTER) Menu_Item_Handler(active_menu, selection, false); @@ -4065,25 +4978,32 @@ void CrealityDWINClass::Menu_Control() { void CrealityDWINClass::Value_Control() { EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); + float difvalue = 0; if (encoder_diffState == ENCODER_DIFF_NO) return; - if (encoder_diffState == ENCODER_DIFF_CW) + if (encoder_diffState == ENCODER_DIFF_CW) { tempvalue += EncoderRate.encoderMoveValue; - else if (encoder_diffState == ENCODER_DIFF_CCW) + difvalue = EncoderRate.encoderMoveValue; + } + else if (encoder_diffState == ENCODER_DIFF_CCW) { tempvalue -= EncoderRate.encoderMoveValue; + difvalue = - EncoderRate.encoderMoveValue; + } else if (encoder_diffState == ENCODER_DIFF_ENTER) { process = Menu; EncoderRate.enabled = false; Draw_Float(tempvalue / valueunit, selection - scrollpos, false, valueunit); DWIN_UpdateLCD(); - if (active_menu == ZOffset && liveadjust) { + if (active_menu == ZOffset && temp_val.zoffsetmode != 0) { planner.synchronize(); - current_position.z += (tempvalue / valueunit - zoffsetvalue); - planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder); + if (temp_val.zoffsetmode == 1) { + current_position.z += (tempvalue / valueunit - temp_val.zoffsetvalue); + planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder); + } current_position.z = 0; sync_plan_position(); } else if (active_menu == Tune && selection == TUNE_ZOFFSET) { - sprintf_P(cmd, PSTR("M290 Z%s"), dtostrf((tempvalue / valueunit - zoffsetvalue), 1, 3, str_1)); + sprintf_P(cmd, PSTR("M290 Z%s"), dtostrf((tempvalue / valueunit - temp_val.zoffsetvalue), 1, 3, str_1)); gcode.process_subcommands_now(cmd); } if (TERN0(HAS_HOTEND, valuepointer == &thermalManager.temp_hotend[0].pid.Ki) || TERN0(HAS_HEATED_BED, valuepointer == &thermalManager.temp_bed.pid.Ki)) @@ -4104,17 +5024,33 @@ void CrealityDWINClass::Value_Control() { planner.buffer_line(current_position, manual_feedrate_mm_s[selection - 1], active_extruder); break; #if HAS_MESH - case ManualMesh: - planner.synchronize(); - planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder); - planner.synchronize(); - break; - case UBLMesh: mesh_conf.manual_mesh_move(true); break; + #if ENABLED(PROBE_MANUALLY) + case ManualMesh: + planner.synchronize(); + planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder); + planner.synchronize(); + break; + #endif + #if ENABLED(AUTO_BED_LEVELING_UBL) && !HAS_BED_PROBE + case UBLMesh: mesh_conf.manual_mesh_move(true); break; + #endif case LevelManual: mesh_conf.manual_mesh_move(selection == LEVELING_M_OFFSET); break; #endif } if (valuepointer == &planner.flow_percentage[0]) planner.refresh_e_factor(0); + #if ENABLED(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS) + if (valuepointer == &caselight.brightness) + caselight.update_brightness(); + #endif + #if HAS_COLOR_LEDS + if ((valuepointer == &leds.color.r) || (valuepointer == &leds.color.g) || (valuepointer == &leds.color.b)) + ApplyLEDColor(); + #if HAS_WHITE_LED + if (valuepointer == &leds.color.w) ApplyLEDColor(); + #endif + #endif + if (funcpointer) funcpointer(); return; } @@ -4122,9 +5058,48 @@ void CrealityDWINClass::Value_Control() { NOMORE(tempvalue, (valuemax * valueunit)); Draw_Float(tempvalue / valueunit, selection - scrollpos, true, valueunit); DWIN_UpdateLCD(); - if (active_menu == Move && livemove) { - *(float*)valuepointer = tempvalue / valueunit; - planner.buffer_line(current_position, manual_feedrate_mm_s[selection - 1], active_extruder); + + if (valuepointer == &ui.brightness) { + *(uint8_t*)valuepointer = tempvalue / valueunit; + ui.refresh_brightness(); + } + + switch (active_menu) { + case Move: + if (temp_val.livemove) { + *(float*)valuepointer = tempvalue / valueunit; + planner.buffer_line(current_position, manual_feedrate_mm_s[selection - 1], active_extruder); + } + break; + case ZOffset: + if (temp_val.zoffsetmode == 2) { + planner.synchronize(); + sprintf_P(cmd, PSTR("M290 Z%s"), dtostrf((difvalue / valueunit), 1, 3, str_1)); + gcode.process_subcommands_now(cmd); + planner.synchronize(); + } + break; + case Tune: + if (selection == TUNE_ZOFFSET) { + planner.synchronize(); + sprintf_P(cmd, PSTR("M290 Z%s"), dtostrf((difvalue / valueunit), 1, 3, str_1)); + gcode.process_subcommands_now(cmd); + planner.synchronize(); + } + break; + #if ENABLED(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS) + case CaseLightmenu: + *(uint8_t*)valuepointer = tempvalue / valueunit; + caselight.update_brightness(); + break; + #endif + #if ENABLED(LED_CONTROL_MENU, HAS_COLOR_LEDS) + case LedControlmenu: + *(uint8_t*)valuepointer = tempvalue / valueunit; + leds.update(); + break; + #endif + default : break; } } @@ -4155,7 +5130,37 @@ void CrealityDWINClass::Option_Control() { Redraw_Screen(); } else if (valuepointer == &preheat_modes) - preheatmode = tempvalue; + temp_val.preheatmode = tempvalue; + #if ENABLED(PREHEAT_BEFORE_LEVELING) + else if (valuepointer == &preheat_levmodes) { + temp_val.LevelingTempmode = tempvalue; + eeprom_settings.ena_hotend_levtemp = false; + eeprom_settings.ena_bed_levtemp = false; + if (temp_val.LevelingTempmode == 0 || temp_val.LevelingTempmode == 1) eeprom_settings.ena_hotend_levtemp = true; + if (temp_val.LevelingTempmode == 0 || temp_val.LevelingTempmode == 2) eeprom_settings.ena_bed_levtemp = true; + } + #endif + else if (valuepointer == &zoffset_modes) { + temp_val.zoffsetmode = tempvalue; + if (temp_val.zoffsetmode == 1 || temp_val.zoffsetmode == 2) { + if (axes_should_home()) { + Popup_Handler(Home); + gcode.home_all_axes(true); + } + Popup_Handler(MoveWait); + #if ENABLED(Z_SAFE_HOMING) + planner.synchronize(); + sprintf_P(cmd, PSTR("G0 F4000 X%s Y%s"), dtostrf(Z_SAFE_HOMING_X_POINT, 1, 3, str_1), dtostrf(Z_SAFE_HOMING_Y_POINT, 1, 3, str_2)); + gcode.process_subcommands_now(cmd); + #else + sprintf_P(cmd, PSTR("G0 F4000 X%s Y%s"), dtostrf((X_BED_SIZE + X_MIN_POS) / 2.0f, 1, 3, str_1), dtostrf((Y_BED_SIZE + Y_MIN_POS) / 2.0f, 1, 3, str_2)); + gcode.process_subcommands_now(cmd); + #endif + gcode.process_subcommands_now(F("G0 F300 Z0")); + planner.synchronize(); + Redraw_Menu(); + } + } Draw_Option(tempvalue, static_cast(valuepointer), selection - scrollpos, false, (valuepointer == &color_names)); DWIN_UpdateLCD(); @@ -4193,7 +5198,7 @@ void CrealityDWINClass::File_Control() { LOOP_S_L_N(i, MENU_CHAR_LIMIT + pos, MENU_CHAR_LIMIT) name[i] = filename[i - (MENU_CHAR_LIMIT + pos)]; } name[len] = '\0'; - DWIN_Draw_Rectangle(1, Color_Bg_Black, LBLX, MBASE(selection - scrollpos) - 14, 271, MBASE(selection - scrollpos) + 28); + DWIN_Draw_Rectangle(1, Def_Background_Color, LBLX, MBASE(selection - scrollpos) - 14, 271, MBASE(selection - scrollpos) + 28); Draw_Menu_Item(selection - scrollpos, card.flag.filenameIsDir ? ICON_More : ICON_File, name); if (-pos >= MENU_CHAR_LIMIT) filescrl = 0; filescrl++; @@ -4203,32 +5208,32 @@ void CrealityDWINClass::File_Control() { return; } if (encoder_diffState == ENCODER_DIFF_CW && selection < card.get_num_Files()) { - DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); + DWIN_Draw_Rectangle(1, Def_Background_Color, 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); if (selection > 0) { - DWIN_Draw_Rectangle(1, Color_Bg_Black, LBLX, MBASE(selection - scrollpos) - 14, 271, MBASE(selection - scrollpos) + 28); + DWIN_Draw_Rectangle(1, Def_Background_Color, LBLX, MBASE(selection - scrollpos) - 14, 271, MBASE(selection - scrollpos) + 28); Draw_SD_Item(selection, selection - scrollpos); } filescrl = 0; selection++; // Select Down if (selection > scrollpos + MROWS) { scrollpos++; - DWIN_Frame_AreaMove(1, 2, MLINE, Color_Bg_Black, 0, 31, DWIN_WIDTH, 349); + DWIN_Frame_AreaMove(1, 2, MLINE, Def_Background_Color, 0, 31, DWIN_WIDTH, 349); Draw_SD_Item(selection, selection - scrollpos); } - DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Rectangle_Color), 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); + DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Def_Cursor_color), 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); } else if (encoder_diffState == ENCODER_DIFF_CCW && selection > 0) { - DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); - DWIN_Draw_Rectangle(1, Color_Bg_Black, LBLX, MBASE(selection - scrollpos) - 14, 271, MBASE(selection - scrollpos) + 28); + DWIN_Draw_Rectangle(1, Def_Background_Color, 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); + DWIN_Draw_Rectangle(1, Def_Background_Color, LBLX, MBASE(selection - scrollpos) - 14, 271, MBASE(selection - scrollpos) + 28); Draw_SD_Item(selection, selection - scrollpos); filescrl = 0; selection--; // Select Up if (selection < scrollpos) { scrollpos--; - DWIN_Frame_AreaMove(1, 3, MLINE, Color_Bg_Black, 0, 31, DWIN_WIDTH, 349); + DWIN_Frame_AreaMove(1, 3, MLINE, Def_Background_Color, 0, 31, DWIN_WIDTH, 349); Draw_SD_Item(selection, selection - scrollpos); } - DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Rectangle_Color), 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); + DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Def_Cursor_color), 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); } else if (encoder_diffState == ENCODER_DIFF_ENTER) { if (selection == 0) { @@ -4248,7 +5253,11 @@ void CrealityDWINClass::File_Control() { Draw_SD_List(); } else { - card.openAndPrintFile(card.filename); + #if HAS_GCODE_PREVIEW + Preview_DrawFromSD(); + #else + card.openAndPrintFile(card.filename); + #endif } } } @@ -4273,8 +5282,8 @@ void CrealityDWINClass::Print_Screen_Control() { Update_Status_Bar(true); break; case PRINT_PAUSE_RESUME: - if (paused) { - if (sdprint) { + if (temp_val.paused) { + if (temp_val.sdprint) { wait_for_user = false; #if ENABLED(PARK_HEAD_ON_PAUSE) card.startOrResumeFilePrinting(); @@ -4282,14 +5291,14 @@ void CrealityDWINClass::Print_Screen_Control() { #else char cmd[20]; #if HAS_HEATED_BED - sprintf_P(cmd, PSTR("M140 S%i"), pausebed); + sprintf_P(cmd, PSTR("M140 S%i"), temp_val.pausebed); gcode.process_subcommands_now(cmd); #endif #if HAS_EXTRUDERS - sprintf_P(cmd, PSTR("M109 S%i"), pausetemp); + sprintf_P(cmd, PSTR("M109 S%i"), temp_val.pausetemp); gcode.process_subcommands_now(cmd); #endif - TERN_(HAS_FAN, thermalManager.fan_speed[0] = pausefan); + TERN_(HAS_FAN, thermalManager.fan_speed[0] = temp_val.pausefan); planner.synchronize(); TERN_(SDSUPPORT, queue.inject(F("M24"))); #endif @@ -4323,7 +5332,7 @@ void CrealityDWINClass::Popup_Control() { switch (popup) { case Pause: if (selection == 0) { - if (sdprint) { + if (temp_val.sdprint) { #if ENABLED(POWER_LOSS_RECOVERY) if (recovery.enabled) recovery.save(true); #endif @@ -4337,9 +5346,9 @@ void CrealityDWINClass::Popup_Control() { planner.synchronize(); #else queue.inject(F("M25")); - TERN_(HAS_HOTEND, pausetemp = thermalManager.temp_hotend[0].target); - TERN_(HAS_HEATED_BED, pausebed = thermalManager.temp_bed.target); - TERN_(HAS_FAN, pausefan = thermalManager.fan_speed[0]); + TERN_(HAS_HOTEND, temp_val.pausetemp = thermalManager.temp_hotend[0].target); + TERN_(HAS_HEATED_BED, temp_val.pausebed = thermalManager.temp_bed.target); + TERN_(HAS_FAN, temp_val.pausefan = thermalManager.fan_speed[0]); thermalManager.cooldown(); #endif } @@ -4351,7 +5360,7 @@ void CrealityDWINClass::Popup_Control() { break; case Stop: if (selection == 0) { - if (sdprint) { + if (temp_val.sdprint) { ui.abort_print(); thermalManager.cooldown(); } @@ -4387,7 +5396,7 @@ void CrealityDWINClass::Popup_Control() { case ManualProbing: if (selection == 0) { char buf[80]; - const float dif = probe.probe_at_point(current_position.x, current_position.y, PROBE_PT_STOW, 0, false) - corner_avg; + const float dif = probe.probe_at_point(current_position.x, current_position.y, PROBE_PT_STOW, 0, false) - temp_val.corner_avg; sprintf_P(buf, dif > 0 ? PSTR("Corner is %smm high") : PSTR("Corner is %smm low"), dtostrf(abs(dif), 1, 3, str_1)); Update_Status(buf); } @@ -4423,12 +5432,20 @@ void CrealityDWINClass::Popup_Control() { } else { pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT; - if (printing) Popup_Handler(Resuming); + if (temp_val.printing) Popup_Handler(Resuming); else Redraw_Menu(true, true, (active_menu==PreheatHotend)); } break; #endif // ADVANCED_PAUSE_FEATURE + case PrintConfirm: + if (selection==0) { + card.openAndPrintFile(card.filename);} + else{ + Redraw_Menu(true, true, true); + gcode.process_subcommands_now(F("M117"));} + break; + #if HAS_MESH case SaveLevel: if (selection == 0) { @@ -4470,8 +5487,15 @@ void CrealityDWINClass::Confirm_Control() { break; case HeaterTime: Popup_Handler(Heating); + Update_Status(GET_TEXT_F(MSG_HEATING)); wait_for_user = false; break; + #if HAS_ESDIAG + case ESDiagPopup: + wait_for_user = false; + Redraw_Menu(true, true, false); + break; + #endif default: Redraw_Menu(true, true, false); wait_for_user = false; @@ -4481,6 +5505,126 @@ void CrealityDWINClass::Confirm_Control() { DWIN_UpdateLCD(); } +#if HAS_HOSTACTION_MENUS + + void CrealityDWINClass::Keyboard_Control() { + const uint8_t keyboard_size = 34; + static uint8_t key_selection = 0, cursor = 0; + static char string[31]; + static bool uppercase = false, locked = false; + if (reset_keyboard) { + if (strcmp(stringpointer, "-") == 0) stringpointer[0] = '\0'; + key_selection = 0, cursor = strlen(stringpointer); + uppercase = false, locked = false; + reset_keyboard = false; + strcpy(string, stringpointer); + } + EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); + if (encoder_diffState == ENCODER_DIFF_NO) return; + if (encoder_diffState == ENCODER_DIFF_CW && key_selection < keyboard_size) { + Draw_Keys(key_selection, false, uppercase, locked); + key_selection++; + Draw_Keys(key_selection, true, uppercase, locked); + } + else if (encoder_diffState == ENCODER_DIFF_CCW && key_selection > 0) { + Draw_Keys(key_selection, false, uppercase, locked); + key_selection--; + Draw_Keys(key_selection, true, uppercase, locked); + } + else if (encoder_diffState == ENCODER_DIFF_ENTER) { + if (key_selection < 28) { + if (key_selection == 19) { + if (!numeric_keyboard) { + if (locked) { + uppercase = false, locked = false; + Draw_Keyboard(keyboard_restrict, false, key_selection, uppercase, locked); + } else if (uppercase) { + locked = true; + Draw_Keyboard(keyboard_restrict, false, key_selection, uppercase, locked); + } + else { + uppercase = true; + Draw_Keyboard(keyboard_restrict, false, key_selection, uppercase, locked); + } + } + } + else if (key_selection == 27) { + cursor--; + string[cursor] = '\0'; + } + else { + uint8_t index = key_selection; + if (index > 19) index--; + if (index > 27) index--; + const char *keys; + if (numeric_keyboard) keys = "1234567890&<>() {}[]*\"\':;!?"; + else keys = (uppercase) ? "QWERTYUIOPASDFGHJKLZXCVBNM" : "qwertyuiopasdfghjklzxcvbnm"; + if (!(keyboard_restrict && numeric_keyboard && index > 9)) { + string[cursor] = keys[index]; + cursor++; + string[cursor] = '\0'; + } + if (!locked && uppercase) { + uppercase = false; + Draw_Keyboard(keyboard_restrict, false, key_selection, uppercase, locked); + } + } + } + else { + switch (key_selection) { + case 28: + if (!numeric_keyboard) uppercase = false, locked = false; + Draw_Keyboard(keyboard_restrict, !numeric_keyboard, key_selection, uppercase, locked); + break; + case 29: + string[cursor] = '-'; + cursor++; + string[cursor] = '\0'; + break; + case 30: + string[cursor] = '_'; + cursor++; + string[cursor] = '\0'; + break; + case 31: + if (!keyboard_restrict) { + string[cursor] = ' '; + cursor++; + string[cursor] = '\0'; + } + break; + case 32: + if (!keyboard_restrict) { + string[cursor] = '.'; + cursor++; + string[cursor] = '\0'; + } + break; + case 33: + if (!keyboard_restrict) { + string[cursor] = '/'; + cursor++; + string[cursor] = '\0'; + } + break; + case 34: + if (string[0] == '\0') strcpy(string, "-"); + strcpy(stringpointer, string); + process = Menu; + DWIN_Draw_Rectangle(1, Def_Background_Color, 0, KEY_Y_START, DWIN_WIDTH-2, DWIN_HEIGHT-2); + Draw_Status_Area(true); + Update_Status_Bar(true); + break; + } + } + if (strlen(string) > maxstringlen) string[maxstringlen] = '\0', cursor = maxstringlen; + Draw_String(string, selection, (process==Keyboard), (maxstringlen > 10)); + } + DWIN_UpdateLCD(); + } + +#endif // HAS_HOSTACTION_MENUS + /* In-Menu Value Modification */ void CrealityDWINClass::Setup_Value(float value, float min, float max, float unit, uint8_t type) { @@ -4540,24 +5684,37 @@ void CrealityDWINClass::Modify_Option(uint8_t value, const char * const * option Draw_Option(value, options, selection - scrollpos, true); } +#if HAS_HOSTACTION_MENUS + void CrealityDWINClass::Modify_String(char * string, uint8_t maxlength, bool restrict) { + stringpointer = string; + maxstringlen = maxlength; + reset_keyboard = true; + Draw_Keyboard(restrict, false); + Draw_String(string, selection, true, (maxstringlen > 10)); + } +#endif + /* Main Functions */ +void CrealityDWINClass::Update_Print_Filename(const char * const text) { + LOOP_L_N(i, _MIN((size_t)LONG_FILENAME_LENGTH, strlen(text))) filename[i] = text[i]; + filename[_MIN((size_t)LONG_FILENAME_LENGTH - 1, strlen(text))] = '\0'; + Draw_Print_Filename(true); +} + void CrealityDWINClass::Update_Status(const char * const text) { - if (strncmp_P(text, PSTR(""), 3) == 0) { - LOOP_L_N(i, _MIN((size_t)LONG_FILENAME_LENGTH, strlen(text))) filename[i] = text[i + 3]; - filename[_MIN((size_t)LONG_FILENAME_LENGTH - 1, strlen(text))] = '\0'; - Draw_Print_Filename(true); - } - else { - LOOP_L_N(i, _MIN((size_t)64, strlen(text))) statusmsg[i] = text[i]; - statusmsg[_MIN((size_t)64, strlen(text))] = '\0'; - } + LOOP_L_N(i, _MIN((size_t)64, strlen(text))) statusmsg[i] = text[i]; + statusmsg[_MIN((size_t)64, strlen(text))] = '\0'; +} + +void CrealityDWINClass::Update_Status(FSTR_P text) { + Update_Status(FTOP(text)); } void CrealityDWINClass::Start_Print(bool sd) { - sdprint = sd; - if (!printing) { - printing = true; + temp_val.sdprint = sd; + if (!temp_val.printing) { + temp_val.printing = true; statusmsg[0] = '\0'; if (sd) { #if ENABLED(POWER_LOSS_RECOVERY) @@ -4569,8 +5726,6 @@ void CrealityDWINClass::Start_Print(bool sd) { #endif strcpy(filename, card.longest_filename()); } - else - strcpy_P(filename, PSTR("Host Print")); TERN_(LCD_SET_PROGRESS_MANUALLY, ui.set_progress(0)); TERN_(USE_M73_REMAINING_TIME, ui.set_remaining_time(0)); Draw_Print_Screen(); @@ -4578,12 +5733,13 @@ void CrealityDWINClass::Start_Print(bool sd) { } void CrealityDWINClass::Stop_Print() { - printing = false; - sdprint = false; + temp_val.printing = false; + temp_val.sdprint = false; thermalManager.cooldown(); TERN_(LCD_SET_PROGRESS_MANUALLY, ui.set_progress(100 * (PROGRESS_SCALE))); TERN_(USE_M73_REMAINING_TIME, ui.set_remaining_time(0)); - Draw_Print_confirm(); + Draw_PrintDone_confirm(); + filename[0] = '\0'; } void CrealityDWINClass::Update() { @@ -4598,6 +5754,13 @@ void CrealityDWINClass::Update() { case Print: Print_Screen_Control(); break; case Popup: Popup_Control(); break; case Confirm: Confirm_Control(); break; + #if HAS_HOSTACTION_MENUS + case Keyboard: Keyboard_Control(); break; + #endif + case Cancel: Confirm_Control(); break; + #if HAS_LOCKSCREEN + case Locked: HMI_LockScreen(); break; + #endif } } @@ -4608,14 +5771,14 @@ void MarlinUI::update() { CrealityDWIN.Update(); } #endif void CrealityDWINClass::State_Update() { - if ((print_job_timer.isRunning() || print_job_timer.isPaused()) != printing) { - if (!printing) Start_Print(card.isFileOpen() || TERN0(POWER_LOSS_RECOVERY, recovery.valid())); + if ((print_job_timer.isRunning() || print_job_timer.isPaused()) != temp_val.printing) { + if (!temp_val.printing) Start_Print(card.isFileOpen() || TERN0(POWER_LOSS_RECOVERY, recovery.valid())); else Stop_Print(); } - if (print_job_timer.isPaused() != paused) { - paused = print_job_timer.isPaused(); + if (print_job_timer.isPaused() != temp_val.paused) { + temp_val.paused = print_job_timer.isPaused(); if (process == Print) Print_Screen_Icons(); - if (process == Wait && !paused) Redraw_Menu(true, true); + if (process == Wait && !temp_val.paused) Redraw_Menu(true, true); } if (wait_for_user && !(process == Confirm) && !print_job_timer.isPaused()) Confirm_Handler(UserInput); @@ -4624,7 +5787,7 @@ void CrealityDWINClass::State_Update() { if (pause_menu_response == PAUSE_RESPONSE_EXTRUDE_MORE) Popup_Handler(FilChange); else if (pause_menu_response == PAUSE_RESPONSE_RESUME_PRINT) { - if (printing) Popup_Handler(Resuming); + if (temp_val.printing) Popup_Handler(Resuming); else Redraw_Menu(true, true, (active_menu==PreheatHotend)); } } @@ -4643,14 +5806,20 @@ void CrealityDWINClass::Screen_Update() { static millis_t scrltime = 0; if (ELAPSED(ms, scrltime)) { scrltime = ms + 200; - Update_Status_Bar(); + if (process != Keyboard) Update_Status_Bar(); if (process == Print) Draw_Print_Filename(); } static millis_t statustime = 0; - if (ELAPSED(ms, statustime)) { + if (ELAPSED(ms, statustime) && process != Keyboard) { statustime = ms + 500; Draw_Status_Area(); + #if HAS_ESDIAG + if (process == Confirm && popup == ESDiagPopup) ESDiag.Update(); + #endif + #if HAS_PIDPLOT + if (process == Wait && (popup == PIDWaitH || popup == PIDWaitB)) Plot.Update((popup == PIDWaitH) ? thermalManager.wholeDegHotend(0) : thermalManager.wholeDegBed()); + #endif } static millis_t printtime = 0; @@ -4681,22 +5850,22 @@ void CrealityDWINClass::Screen_Update() { #endif #if HAS_ZOFFSET_ITEM - static float lastzoffset = zoffsetvalue; - if (zoffsetvalue != lastzoffset) { - lastzoffset = zoffsetvalue; + static float lastzoffset = temp_val.zoffsetvalue; + if (temp_val.zoffsetvalue != lastzoffset) { + lastzoffset = temp_val.zoffsetvalue; #if HAS_BED_PROBE - probe.offset.z = zoffsetvalue; + probe.offset.z = temp_val.zoffsetvalue; #else - set_home_offset(Z_AXIS, -zoffsetvalue); + set_home_offset(Z_AXIS, -temp_val.zoffsetvalue); #endif } #if HAS_BED_PROBE if (probe.offset.z != lastzoffset) - zoffsetvalue = lastzoffset = probe.offset.z; + temp_val.zoffsetvalue = lastzoffset = probe.offset.z; #else if (-home_offset.z != lastzoffset) - zoffsetvalue = lastzoffset = -home_offset.z; + temp_val.zoffsetvalue = lastzoffset = -home_offset.z; #endif #endif // HAS_ZOFFSET_ITEM @@ -4772,8 +5941,15 @@ void CrealityDWINClass::AudioFeedback(const bool success/*=true*/) { } void CrealityDWINClass::Save_Settings(char *buff) { + TERN_(DEBUG_DWIN, SERIAL_ECHOLNPGM("Save_Settings")); TERN_(AUTO_BED_LEVELING_UBL, eeprom_settings.tilt_grid_size = mesh_conf.tilt_grid - 1); - eeprom_settings.corner_pos = corner_pos * 10; + eeprom_settings.corner_pos = temp_val.corner_pos * 10; + #if HAS_HOSTACTION_MENUS + eeprom_settings.host_action_label_1 = Encode_String(action1); + eeprom_settings.host_action_label_2 = Encode_String(action2); + eeprom_settings.host_action_label_3 = Encode_String(action3); + #endif + TERN_(DEBUG_DWIN, SERIAL_ECHOLNPGM("eeprom_settings size: ", sizeof(eeprom_settings_t))); memcpy(buff, &eeprom_settings, _MIN(sizeof(eeprom_settings), eeprom_data_size)); } @@ -4781,7 +5957,29 @@ void CrealityDWINClass::Load_Settings(const char *buff) { memcpy(&eeprom_settings, buff, _MIN(sizeof(eeprom_settings), eeprom_data_size)); TERN_(AUTO_BED_LEVELING_UBL, mesh_conf.tilt_grid = eeprom_settings.tilt_grid_size + 1); if (eeprom_settings.corner_pos == 0) eeprom_settings.corner_pos = 325; - corner_pos = eeprom_settings.corner_pos / 10.0f; + temp_val.corner_pos = eeprom_settings.corner_pos / 10.0f; + #if ENABLED(BAUD_RATE_GCODE) + if (eeprom_settings.Baud115k) queue.inject(F("M575 P0 B115200")); + #endif + #if ENABLED(FWRETRACT) + temp_val.auto_fw_retract = fwretract.autoretract_enabled; + #endif + #if ENABLED(PREHEAT_BEFORE_LEVELING) + temp_val.LevelingTempmode = 2 * !eeprom_settings.ena_hotend_levtemp + !eeprom_settings.ena_bed_levtemp; + #endif + #if ENABLED(LED_CONTROL_MENU, HAS_COLOR_LEDS) + leds.set_color( + (temp_val.LED_Color >> 16) & 0xFF, + (temp_val.LED_Color >> 8) & 0xFF, + (temp_val.LED_Color >> 0) & 0xFF + OPTARG(HAS_WHITE_LED, (temp_val.LED_Color >> 24) & 0xFF) + ); + #endif + #if HAS_HOSTACTION_MENUS + Decode_String(eeprom_settings.host_action_label_1, action1); + Decode_String(eeprom_settings.host_action_label_2, action2); + Decode_String(eeprom_settings.host_action_label_3, action3); + #endif Redraw_Screen(); #if ENABLED(POWER_LOSS_RECOVERY) static bool init = true; @@ -4808,26 +6006,69 @@ void CrealityDWINClass::Reset_Settings() { eeprom_settings.coordinates_text = 0; eeprom_settings.coordinates_split_line = 0; TERN_(AUTO_BED_LEVELING_UBL, mesh_conf.tilt_grid = eeprom_settings.tilt_grid_size + 1); - corner_pos = eeprom_settings.corner_pos / 10.0f; + temp_val.corner_pos = eeprom_settings.corner_pos / 10.0f; TERN_(SOUND_MENU_ITEM, ui.sound_on = ENABLED(SOUND_ON_DEFAULT)); + TERN_(BAUD_RATE_GCODE, eeprom_settings.Baud115k = false); + TERN_(FWRETRACT, temp_val.auto_fw_retract = fwretract.autoretract_enabled); + #if ENABLED(PREHEAT_BEFORE_LEVELING) + eeprom_settings.ena_hotend_levtemp = true; + eeprom_settings.ena_bed_levtemp = true; + eeprom_settings.hotend_levtemp = LEVELING_NOZZLE_TEMP; + eeprom_settings.bed_levtemp = LEVELING_BED_TEMP; + #endif + #if ENABLED(LED_CONTROL_MENU, HAS_COLOR_LEDS) + leds.setup(); + #if ENABLED(LED_COLOR_PRESETS) + leds.set_default(); + #endif + temp_val.LED_Color = Def_Leds_Color; + leds.set_color( + (temp_val.LED_Color >> 16) & 0xFF, + (temp_val.LED_Color >> 8) & 0xFF, + (temp_val.LED_Color >> 0) & 0xFF + OPTARG(HAS_WHITE_LED, (temp_val.LED_Color >> 24) & 0xFF) + ); + #endif + #if HAS_HOSTACTION_MENUS + eeprom_settings.host_action_label_1 = 0; + eeprom_settings.host_action_label_2 = 0; + eeprom_settings.host_action_label_3 = 0; + action1[0] = action2[0] = action3[0] = '-'; + #endif Redraw_Screen(); } +void CrealityDWINClass::PreheatBefore() { + #if ENABLED(PREHEAT_BEFORE_LEVELING) + Popup_Handler(Heating); + #if HAS_BED_PROBE + probe.preheat_for_probing(eeprom_settings.ena_hotend_levtemp, eeprom_settings.ena_bed_levtemp); + #else + #if HAS_HOTEND + if (thermalManager.degTargetHotend(0) < eeprom_settings.hotend_levtemp && (eeprom_settings.ena_hotend_levtemp)) + thermalManager.setTargetHotend(eeprom_settings.hotend_levtemp, 0); + #endif + #if HAS_HEATED_BED + if (thermalManager.degTargetBed() < eeprom_settings.bed_levtemp && (eeprom_settings.ena_bed_levtemp)) + thermalManager.setTargetBed(eeprom_settings.bed_levtemp); + #endif + TERN_(HAS_HOTEND, if (eeprom_settings.ena_hotend_levtemp) thermalManager.wait_for_hotend(0)); + TERN_(HAS_HEATED_BED, if (eeprom_settings.ena_bed_levtemp) thermalManager.wait_for_bed_heating()); + #endif + Update_Status(""); + #endif +} + void MarlinUI::init_lcd() { - delay(800); - 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) + DWINUI::init(); Encoder_Configuration(); + DWIN_JPG_ShowAndCache(0); for (uint16_t t = 0; t <= 100; t += 2) { - DWIN_ICON_Show(ICON, ICON_Bar, 15, 260); - DWIN_Draw_Rectangle(1, Color_Bg_Black, 15 + t * 242 / 100, 260, 257, 280); + DWINUI::DRAW_IconWB(ICON, ICON_Bar, 15, 260); + DWIN_Draw_Rectangle(1, Def_Background_Color, 15 + t * 242 / 100, 260, 257, 280); DWIN_UpdateLCD(); delay(20); } - - DWIN_JPG_ShowAndCache(3); DWIN_JPG_CacheTo1(Language_English); CrealityDWIN.Redraw_Screen(); } @@ -4836,8 +6077,8 @@ void MarlinUI::init_lcd() { void MarlinUI::pause_show_message(const PauseMessage message, const PauseMode mode/*=PAUSE_MODE_SAME*/, const uint8_t extruder/*=active_extruder*/) { switch (message) { case PAUSE_MESSAGE_INSERT: CrealityDWIN.Confirm_Handler(FilInsert); break; - case PAUSE_MESSAGE_PURGE: - case PAUSE_MESSAGE_OPTION: CrealityDWIN.Popup_Handler(PurgeMore); break; + case PAUSE_MESSAGE_PURGE: break; + case PAUSE_MESSAGE_OPTION: pause_menu_response = PAUSE_RESPONSE_WAIT_FOR; CrealityDWIN.Popup_Handler(PurgeMore); break; case PAUSE_MESSAGE_HEAT: CrealityDWIN.Confirm_Handler(HeaterTime); break; case PAUSE_MESSAGE_WAITING: CrealityDWIN.Draw_Print_Screen(); break; default: break; @@ -4845,4 +6086,109 @@ void MarlinUI::init_lcd() { } #endif +// End-stops diagnostic from DWIN PROUI +#if HAS_ESDIAG + void CrealityDWINClass::DWIN_EndstopsDiag() { + last_process = process; + last_selection = selection; + process = Confirm; + popup = ESDiagPopup; + ESDiag.Draw(); + } +#endif + +// Lock screen from DWIN PROUI +#if HAS_LOCKSCREEN + void CrealityDWINClass::DWIN_LockScreen() { + if (process != Locked) { + lockScreen.rprocess = process; + process = Locked; + lockScreen.init(); + } + } + + void CrealityDWINClass::DWIN_UnLockScreen() { + if (process == Locked) { + process = lockScreen.rprocess; + if (!temp_val.printing) Draw_Main_Menu(); else Draw_Print_Screen(); + } + } + + void CrealityDWINClass::HMI_LockScreen() { + EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); + if (encoder_diffState == ENCODER_DIFF_NO) return; + lockScreen.onEncoder(encoder_diffState); + if (lockScreen.isUnlocked()) DWIN_UnLockScreen(); + } +#endif + +// Reboot screen from DWIN PROUI +void CrealityDWINClass::DWIN_RebootScreen() { + DWIN_Frame_Clear(Def_Background_Color); + DWIN_JPG_ShowAndCache(0); + DWINUI::Draw_CenteredString(Def_Text_Color, 220, GET_TEXT_F(MSG_PLEASE_WAIT_REBOOT)); + DWIN_UpdateLCD(); + delay(500); +} + +// Reboot Printer from DWIN PROUI +void CrealityDWINClass::RebootPrinter() { + wait_for_heatup = wait_for_user = false; // Stop waiting for heating/user + thermalManager.disable_all_heaters(); + planner.finish_and_disable(); + DWIN_RebootScreen(); + hal.reboot(); +} + +#if ENABLED(LED_CONTROL_MENU, HAS_COLOR_LEDS) + void CrealityDWINClass::ApplyLEDColor() { + temp_val.LED_Color = TERN0(HAS_WHITE_LED,(leds.color.w << 24)) | (leds.color.r << 16) | (leds.color.g << 8) | (leds.color.b); + } +#endif + +#if HAS_PIDPLOT + void CrealityDWINClass::DWIN_Draw_PIDPopup(const pidresult_t pidresult) { + frame_rect_t gfrm = {40, 160, DWIN_WIDTH - 80, 150}; + DWINUI::ClearMainArea(); + DWIN_Draw_Rectangle(1, Def_PopupBg_color, 14, 60, 258, 330); + DWIN_Draw_Rectangle(0, Def_Highlight_Color, 14, 60, 258, 330); + DWINUI::Draw_CenteredString(Def_PopupTxt_Color, 80, GET_TEXT_F(MSG_PID_AUTOTUNE)); + DWINUI::Draw_String(Def_PopupTxt_Color, gfrm.x, gfrm.y - DWINUI::fontHeight() - 4, F("PID target: Celsius")); + switch (pidresult) { + case PID_EXTR_START: + DWINUI::Draw_CenteredString(Def_PopupTxt_Color, 100, F("for Nozzle is running.")); + Plot.Draw(gfrm, thermalManager.hotend_maxtemp[0], temp_val.PID_e_temp); + DWINUI::Draw_Int(Def_PopupTxt_Color, 3, gfrm.x + 90, gfrm.y - DWINUI::fontHeight() - 4, temp_val.PID_e_temp); + break; + case PID_BED_START: + DWINUI::Draw_CenteredString(Def_PopupTxt_Color, 100, F("for BED is running.")); + Plot.Draw(gfrm, BED_MAXTEMP, temp_val.PID_bed_temp); + DWINUI::Draw_Int(Def_PopupTxt_Color, 3, gfrm.x + 90, gfrm.y - DWINUI::fontHeight() - 4, temp_val.PID_bed_temp); + break; + default: + break; + } + } +#endif + +#if HAS_PID_HEATING + void CrealityDWINClass::DWIN_PidTuning(const pidresult_t pidresult) { + switch (pidresult) { + case PID_STARTED: break; + #if HAS_PIDPLOT + case PID_EXTR_START: last_process = process; last_selection = selection; process = Wait; popup = PIDWaitH; DWIN_Draw_PIDPopup(pidresult); break; + case PID_BED_START: last_process = process; last_selection = selection; process = Wait; popup = PIDWaitB; DWIN_Draw_PIDPopup(pidresult); break; + #else + case PID_EXTR_START: Popup_Handler(PIDWait); break; + case PID_BED_START: Popup_Handler(PIDWait, true); break; + #endif + case PID_BAD_EXTRUDER_NUM: Confirm_Handler(BadextruderNumber); break; + case PID_TEMP_TOO_HIGH: Confirm_Handler(TempTooHigh); break; + case PID_TUNING_TIMEOUT: Confirm_Handler(PIDTimeout); break; + case PID_DONE: Confirm_Handler(PIDDone); break; + default: break; + } + } +#endif + #endif // DWIN_CREALITY_LCD_JYERSUI diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.h b/Marlin/src/lcd/e3v2/jyersui/dwin.h index 8985647cd131..c42c0677dce1 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.h +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.h @@ -23,27 +23,26 @@ /** * lcd/e3v2/jyersui/dwin.h + * JYERSUI Author: Jacob Myers + * + * JYERSUI Enhanced by LCH-77 + * Version: 1.9 + * Date: Jun 16, 2022 */ -#include "dwin_lcd.h" -#include "../common/dwin_set.h" -#include "../common/dwin_font.h" -#include "../common/dwin_color.h" -#include "../common/encoder.h" -#include "../../../libs/BL24CXX.h" - -#include "../../../inc/MarlinConfigPre.h" +#include "dwin_defines.h" -//#define DWIN_CREALITY_LCD_CUSTOM_ICONS +#include "../../../inc/MarlinConfig.h" enum processID : uint8_t { - Main, Print, Menu, Value, Option, File, Popup, Confirm, Wait + Main, Print, Menu, Value, Option, File, Popup, Confirm, Wait, Locked, Cancel, Keyboard }; enum PopupID : uint8_t { Pause, Stop, Resume, SaveLevel, ETemp, ConfFilChange, PurgeMore, MeshSlot, - Level, Home, MoveWait, Heating, FilLoad, FilChange, TempWarn, Runout, PIDWait, Resuming, ManualProbing, - FilInsert, HeaterTime, UserInput, LevelError, InvalidMesh, UI, Complete, Custom + Level, Home, MoveWait, Heating, FilLoad, FilChange, TempWarn, Runout, Resuming, ManualProbing, + FilInsert, HeaterTime, UserInput, LevelError, InvalidMesh, UI, Complete, Custom, ESDiagPopup, PrintConfirm, + PIDWait, PIDWaitH, PIDWaitB, BadextruderNumber, TempTooHigh, PIDTimeout, PIDDone }; enum menuID : uint8_t { @@ -55,6 +54,7 @@ enum menuID : uint8_t { ZOffset, Preheat, ChangeFilament, + HostActions, MenuCustom, Control, TempMenu, @@ -69,105 +69,108 @@ enum menuID : uint8_t { HomeOffsets, MaxSpeed, MaxAcceleration, - MaxJerk, + #if HAS_CLASSIC_JERK + MaxJerk, + #endif + #if HAS_JUNCTION_DEVIATION + JDmenu, + #endif Steps, + #if ENABLED(FWRETRACT) + FwRetraction, + #endif Visual, ColorSettings, + HostSettings, + ActionCommands, Advanced, - ProbeMenu, + #if HAS_BED_PROBE + ProbeMenu, + #endif Info, - Leveling, - LevelManual, - LevelView, - MeshViewer, - LevelSettings, - ManualMesh, - UBLMesh, + #if HAS_MESH + Leveling, + LevelManual, + LevelView, + MeshViewer, + LevelSettings, + #if ENABLED(PROBE_MANUALLY) + ManualMesh, + #endif + #if ENABLED(AUTO_BED_LEVELING_UBL) && !HAS_BED_PROBE + UBLMesh, + #endif + #endif InfoMain, Tune, - PreheatHotend + PreheatHotend, + #if ANY(CASE_LIGHT_MENU, LED_CONTROL_MENU) + Ledsmenu, + #if BOTH(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS) + CaseLightmenu, + #endif + #if ENABLED(LED_CONTROL_MENU) + LedControlmenu, + #if HAS_COLOR_LEDS + #if ENABLED(LED_COLOR_PRESETS) + LedControlpresets, + #else + LedControlcustom, + #endif + #endif + #endif + #endif }; -// Custom icons -#if ENABLED(DWIN_CREALITY_LCD_CUSTOM_ICONS) - // index of every custom icon should be >= CUSTOM_ICON_START - #define CUSTOM_ICON_START ICON_Checkbox_F - #define ICON_Checkbox_F 200 - #define ICON_Checkbox_T 201 - #define ICON_Fade 202 - #define ICON_Mesh 203 - #define ICON_Tilt 204 - #define ICON_Brightness 205 - #define ICON_AxisD 249 - #define ICON_AxisBR 250 - #define ICON_AxisTR 251 - #define ICON_AxisBL 252 - #define ICON_AxisTL 253 - #define ICON_AxisC 254 -#else - #define ICON_Fade ICON_Version - #define ICON_Mesh ICON_Version - #define ICON_Tilt ICON_Version - #define ICON_Brightness ICON_Version - #define ICON_AxisD ICON_Axis - #define ICON_AxisBR ICON_Axis - #define ICON_AxisTR ICON_Axis - #define ICON_AxisBL ICON_Axis - #define ICON_AxisTL ICON_Axis - #define ICON_AxisC ICON_Axis -#endif +typedef struct { + // Flags + bool flag_tune = false; + bool auto_fw_retract = false; + bool printing = false; + bool paused = false; + bool sdprint = false; + bool livemove = false; + bool liveadjust = false; + bool probe_deployed = false; + // Auxiliary values + AxisEnum axis = X_AXIS; // Axis Select + int16_t pausetemp = 0; + int16_t pausebed = 0; + int16_t pausefan = 0; + uint8_t preheatmode = 0; + uint8_t zoffsetmode = 0; + float zoffsetvalue = 0; + uint8_t gridpoint; + float corner_avg; + float corner_pos; + float zval; + #if ENABLED(PREHEAT_BEFORE_LEVELING) + uint8_t LevelingTempmode = 0; + #endif + #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS) + uint32_t LED_Color = Def_Leds_Color; + #endif + #if HAS_PID_HEATING + uint16_t PID_e_temp = 180; + uint16_t PID_bed_temp = 60; + #endif +} temp_val_t; +extern temp_val_t temp_val; +#define Custom_Colors 10 enum colorID : uint8_t { Default, White, Green, Cyan, Blue, Magenta, Red, Orange, Yellow, Brown, Black }; - -#define Custom_Colors 10 -#define Color_Aqua RGB(0x00,0x3F,0x1F) -#define Color_Light_White 0xBDD7 -#define Color_Green RGB(0x00,0x3F,0x00) -#define Color_Light_Green 0x3460 -#define Color_Cyan 0x07FF -#define Color_Light_Cyan 0x04F3 -#define Color_Blue 0x015F -#define Color_Light_Blue 0x3A6A -#define Color_Magenta 0xF81F -#define Color_Light_Magenta 0x9813 -#define Color_Light_Red 0x8800 -#define Color_Orange 0xFA20 -#define Color_Light_Orange 0xFBC0 -#define Color_Light_Yellow 0x8BE0 -#define Color_Brown 0xCC27 -#define Color_Light_Brown 0x6204 -#define Color_Black 0x0000 -#define Color_Grey 0x18E3 -#define Check_Color 0x4E5C // Check-box check color -#define Confirm_Color 0x34B9 -#define Cancel_Color 0x3186 +enum pidresult_t : uint8_t { PID_STARTED, PID_EXTR_START, PID_BED_START, PID_BAD_EXTRUDER_NUM, PID_TEMP_TOO_HIGH, PID_TUNING_TIMEOUT, PID_DONE }; class CrealityDWINClass { public: - static constexpr size_t eeprom_data_size = 48; - static struct EEPROM_Settings { // use bit fields to save space, max 48 bytes - bool time_format_textual : 1; - #if ENABLED(AUTO_BED_LEVELING_UBL) - uint8_t tilt_grid_size : 3; - #endif - uint16_t corner_pos : 10; - uint8_t cursor_color : 4; - uint8_t menu_split_line : 4; - uint8_t menu_top_bg : 4; - uint8_t menu_top_txt : 4; - uint8_t highlight_box : 4; - uint8_t progress_percent : 4; - uint8_t progress_time : 4; - uint8_t status_bar_text : 4; - uint8_t status_area_text : 4; - uint8_t coordinates_text : 4; - uint8_t coordinates_split_line : 4; - } eeprom_settings; - static constexpr const char * const color_names[11] = { "Default", "White", "Green", "Cyan", "Blue", "Magenta", "Red", "Orange", "Yellow", "Brown", "Black" }; static constexpr const char * const preheat_modes[3] = { "Both", "Hotend", "Bed" }; + static constexpr const char * const zoffset_modes[3] = { "No Live" , "OnClick", " Live" }; + #if ENABLED(PREHEAT_BEFORE_LEVELING) + static constexpr const char * const preheat_levmodes[4] = { " Both", " Hotend", " Bed", " None" }; + #endif static void Clear_Screen(uint8_t e=3); static void Draw_Float(float value, uint8_t row, bool selected=false, uint8_t minunit=10); @@ -192,7 +195,7 @@ class CrealityDWINClass { static void Draw_Print_ProgressRemain(); #endif static void Draw_Print_ProgressElapsed(); - static void Draw_Print_confirm(); + static void Draw_PrintDone_confirm(); static void Draw_SD_Item(uint8_t item, uint8_t row); static void Draw_SD_List(bool removed=false); static void Draw_Status_Area(bool icons=false); @@ -209,8 +212,8 @@ class CrealityDWINClass { static uint8_t Get_Menu_Size(uint8_t menu); static void Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw=true); - static void Popup_Handler(PopupID popupid, bool option = false); - static void Confirm_Handler(PopupID popupid); + static void Popup_Handler(PopupID popupid, bool option=false); + static void Confirm_Handler(PopupID popupid, bool option=false); static void Main_Menu_Control(); static void Menu_Control(); @@ -231,6 +234,7 @@ class CrealityDWINClass { static void Modify_Option(uint8_t value, const char * const * options, uint8_t max); static void Update_Status(const char * const text); + static void Update_Status(FSTR_P text); static void Start_Print(bool sd); static void Stop_Print(); static void Update(); @@ -240,6 +244,40 @@ class CrealityDWINClass { static void Save_Settings(char *buff); static void Load_Settings(const char *buff); static void Reset_Settings(); + static void PreheatBefore(); + + #if HAS_ESDIAG + static void DWIN_EndstopsDiag(); + #endif + #if HAS_LOCKSCREEN + static void DWIN_LockScreen(); + static void DWIN_UnLockScreen(); + static void HMI_LockScreen(); + #endif + static void DWIN_RebootScreen(); + static void RebootPrinter(); + static void Update_Print_Filename(const char * const text); + #if ENABLED(LED_CONTROL_MENU, HAS_COLOR_LEDS) + static void ApplyLEDColor(); + #endif + + #if HAS_HOSTACTION_MENUS + static void Draw_String(char * string, uint8_t row, bool selected=false, bool below=false); + static const uint64_t Encode_String(const char * string); + static void Decode_String(uint64_t num, char * string); + static void Draw_Keyboard(bool restrict, bool numeric, uint8_t selected=0, bool uppercase=false, bool lock=false); + static void Draw_Keys(uint8_t index, bool selected, bool uppercase=false, bool lock=false); + static void Modify_String(char * string, uint8_t maxlength, bool restrict); + static void Keyboard_Control(); + #endif + + #if HAS_PIDPLOT + static void DWIN_Draw_PIDPopup(const pidresult_t pidresult); + #endif + + #if HAS_PID_HEATING + static void DWIN_PidTuning(const pidresult_t pidresult); + #endif }; extern CrealityDWINClass CrealityDWIN; diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin_defines.h b/Marlin/src/lcd/e3v2/jyersui/dwin_defines.h new file mode 100644 index 000000000000..72d428448899 --- /dev/null +++ b/Marlin/src/lcd/e3v2/jyersui/dwin_defines.h @@ -0,0 +1,131 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * DWIN general defines and data structs for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 3.11.2 + * Date: 2022/02/28 + * + * Modded for JYERSUI by LCH-77 + * Version: 1.9 + * Date: Jun 16, 2022 + */ + +#include "../../../inc/MarlinConfigPre.h" + +#define HAS_ESDIAG 1 +#define HAS_LOCKSCREEN 1 +#define HAS_PIDPLOT 1 +#define HAS_GCODE_PREVIEW 1 +//#define DEBUG_DWIN 1 +//#define NEED_HEX_PRINT 1 + +#if ENABLED(HOST_ACTION_COMMANDS) + #define HAS_HOSTACTION_MENUS 1 +#endif + +#include "../../../core/types.h" +#include "../common/dwin_color.h" + +// Default UI Colors +#define Def_Background_Color RGB(4,4,0) +#define Def_Cursor_color RGB(24,24,0) +#define Def_TitleBg_color RGB(12,12,0) +#define Def_TitleTxt_color Color_White +#define Def_Text_Color Color_White +#define Def_Selected_Color RGB(24,24,0) +#define Def_SplitLine_Color RGB(24,24,0) +#define Def_Highlight_Color RGB(31,40,0) +#define Def_StatusBg_Color RGB(12,12,0) +#define Def_StatusTxt_Color Color_White +#define Def_PopupBg_color Color_Bg_Window +#define Def_PopupTxt_Color Popup_Text_Color +#define Def_AlertBg_Color Color_Bg_Red +#define Def_AlertTxt_Color Color_Yellow +#define Def_PercentTxt_Color RGB(31,48,8) +#define Def_Barfill_Color RGB(12,12,0) +#define Def_Indicator_Color RGB(31,48,8) +#define Def_Coordinate_Color Color_White +#define Def_Button_Color RGB(12,12,0) + +#if ENABLED(LED_CONTROL_MENU, HAS_COLOR_LEDS) + #define Def_Leds_Color 0xFFFFFFFF +#endif +#if ENABLED(CASELIGHT_USES_BRIGHTNESS) + #define Def_CaseLight_Brightness 255 +#endif + +#if HAS_MESH + #ifndef MESH_INSET + #define MESH_INSET 25 + #endif + #ifndef MESH_MIN_X + #define MESH_MIN_X MESH_INSET + #endif + #ifndef MESH_MIN_Y + #define MESH_MIN_Y MESH_INSET + #endif + #ifndef MESH_MAX_X + #define MESH_MAX_X X_BED_SIZE - (MESH_INSET) + #endif + #ifndef MESH_MAX_Y + #define MESH_MAX_Y X_BED_SIZE - (MESH_INSET) + #endif +#endif + +typedef struct { + bool time_format_textual : 1; + #if ENABLED(AUTO_BED_LEVELING_UBL) + uint8_t tilt_grid_size : 3; + #endif + uint16_t corner_pos : 10; + uint8_t cursor_color : 4; + uint8_t menu_split_line : 4; + uint8_t menu_top_bg : 4; + uint8_t menu_top_txt : 4; + uint8_t highlight_box : 4; + uint8_t progress_percent : 4; + uint8_t progress_time : 4; + uint8_t status_bar_text : 4; + uint8_t status_area_text : 4; + uint8_t coordinates_text : 4; + uint8_t coordinates_split_line : 4; + #if ENABLED(BAUD_RATE_GCODE) + bool Baud115k : 1; + #endif + #if ENABLED(PREHEAT_BEFORE_LEVELING) + bool ena_hotend_levtemp : 1; + bool ena_bed_levtemp : 1; + celsius_t hotend_levtemp = LEVELING_NOZZLE_TEMP; + celsius_t bed_levtemp = LEVELING_BED_TEMP; + #endif + #if HAS_HOSTACTION_MENUS + uint64_t host_action_label_1 : 48; + uint64_t host_action_label_2 : 48; + uint64_t host_action_label_3 : 48; + #endif +} eeprom_settings_t; + +static constexpr size_t eeprom_data_size = 48; +extern eeprom_settings_t eeprom_settings; diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin_lcd.cpp b/Marlin/src/lcd/e3v2/jyersui/dwin_lcd.cpp index 04889e92b038..24d55272a3e9 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin_lcd.cpp +++ b/Marlin/src/lcd/e3v2/jyersui/dwin_lcd.cpp @@ -53,12 +53,41 @@ void DWIN_Draw_DegreeSymbol(uint16_t Color, uint16_t x, uint16_t y) { /*---------------------------------------- Picture related functions ----------------------------------------*/ -// Draw an Icon +// Draw an Icon with transparent background // libID: Icon library ID // picID: Icon ID // x/y: Upper-left point void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) { - DWIN_ICON_Show(true, false, false, libID, picID, x, y); + DWIN_ICON_Show(false, false, true, libID, picID, x, y); +} + +// From DWIN Enhanced implementation for PRO UI v3.10.1 +// Write buffer data to the SRAM or Flash +// mem: 0x5A=32KB SRAM, 0xA5=16KB Flash +// addr: start address +// length: Bytes to write +// data: address of the buffer with data +void DWIN_WriteToMem(uint8_t mem, uint16_t addr, uint16_t length, uint8_t *data) { + const uint8_t max_size = 128; + uint16_t pending = length; + uint16_t to_send; + uint16_t indx; + uint8_t block = 0; + + while (pending > 0) { + indx = block * max_size; + to_send = _MIN(pending, max_size); + size_t i = 0; + DWIN_Byte(i, 0x31); + DWIN_Byte(i, mem); + DWIN_Word(i, addr + indx); // start address of the data block + ++i; + LOOP_L_N(j, i) { LCD_SERIAL.write(DWIN_SendBuf[j]); delayMicroseconds(1); } // Buf header + for (uint16_t j = indx; j <= indx + to_send - 1; j++) LCD_SERIAL.write(*(data + j)); delayMicroseconds(1); // write block of data + LOOP_L_N(j, 4) { LCD_SERIAL.write(DWIN_BufTail[j]); delayMicroseconds(1); } + block++; + pending -= to_send; + } } #endif // DWIN_CREALITY_LCD_JYERSUI diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin_lcd.h b/Marlin/src/lcd/e3v2/jyersui/dwin_lcd.h index f76cfb5d3e5f..b1aeadbbc51b 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin_lcd.h +++ b/Marlin/src/lcd/e3v2/jyersui/dwin_lcd.h @@ -32,3 +32,11 @@ // Color: color // x/y: Upper-left coordinate of the first pixel void DWIN_Draw_DegreeSymbol(uint16_t Color, uint16_t x, uint16_t y); + +// From DWIN Enhanced implementation for PRO UI v3.10.1 +// Write buffer data to the SRAM or Flash +// mem: 0x5A=32KB SRAM, 0xA5=16KB Flash +// addr: start address +// length: Bytes to write +// data: address of the buffer with data +void DWIN_WriteToMem(uint8_t mem, uint16_t addr, uint16_t length, uint8_t *data); diff --git a/Marlin/src/lcd/e3v2/jyersui/dwinui.cpp b/Marlin/src/lcd/e3v2/jyersui/dwinui.cpp new file mode 100644 index 000000000000..1573bff552d9 --- /dev/null +++ b/Marlin/src/lcd/e3v2/jyersui/dwinui.cpp @@ -0,0 +1,340 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * DWIN Enhanced implementation for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 3.17.1 + * Date: 2022/04/12 + * + * Modded for JYERSUI by LCH-77 + * Version: 1.9 + * Date: Jun 16, 2022 + */ + +#include "../../../inc/MarlinConfigPre.h" + +#if ENABLED(DWIN_CREALITY_LCD_JYERSUI) + +#include "../../../inc/MarlinConfig.h" +#include "dwin_lcd.h" +#include "dwinui.h" +#include "dwin_defines.h" + +//#define DEBUG_OUT 1 +#include "../../../core/debug_out.h" + +xy_int_t DWINUI::cursor = { 0 }; +uint16_t DWINUI::pencolor = Color_White; +uint16_t DWINUI::textcolor = Def_Text_Color; +uint16_t DWINUI::backcolor = Def_Background_Color; +uint16_t DWINUI::buttoncolor = Def_Button_Color; +uint8_t DWINUI::font = font8x16; +FSTR_P const DWINUI::Author = F(STRING_CONFIG_H_AUTHOR); + +void DWINUI::init() { + delay(750); // Delay for wait to wakeup screen + const bool hs = DWIN_Handshake(); UNUSED(hs); + #if ENABLED(DEBUG_DWIN) + SERIAL_ECHOPGM("DWIN_Handshake "); + SERIAL_ECHOLNF(hs ? F("ok.") : F("error.")); + #endif + DWIN_Frame_SetDir(1); + cursor.reset(); + pencolor = Color_White; + textcolor = Def_Text_Color; + backcolor = Def_Background_Color; + buttoncolor = Def_Button_Color; + font = font8x16; +} + +// Set text/number font +void DWINUI::setFont(uint8_t cfont) { + font = cfont; +} + +// Get font character width +uint8_t DWINUI::fontWidth(uint8_t cfont) { + switch (cfont) { + case font6x12 : return 6; + case font8x16 : return 8; + case font10x20: return 10; + case font12x24: return 12; + case font14x28: return 14; + case font16x32: return 16; + case font20x40: return 20; + case font24x48: return 24; + case font28x56: return 28; + case font32x64: return 32; + default: return 0; + } +} + +// Get font character height +uint8_t DWINUI::fontHeight(uint8_t cfont) { + switch (cfont) { + case font6x12 : return 12; + case font8x16 : return 16; + case font10x20: return 20; + case font12x24: return 24; + case font14x28: return 28; + case font16x32: return 32; + case font20x40: return 40; + case font24x48: return 48; + case font28x56: return 56; + case font32x64: return 64; + default: return 0; + } +} + +// Get screen x coordinates from text column +uint16_t DWINUI::ColToX(uint8_t col) { + return col * fontWidth(font); +} + +// Get screen y coordinates from text row +uint16_t DWINUI::RowToY(uint8_t row) { + return row * fontHeight(font); +} + +// Set text/number color +void DWINUI::SetColors(uint16_t fgcolor, uint16_t bgcolor, uint16_t alcolor) { + textcolor = fgcolor; + backcolor = bgcolor; + buttoncolor = alcolor; +} +void DWINUI::SetTextColor(uint16_t fgcolor) { + textcolor = fgcolor; +} +void DWINUI::SetBackgroundColor(uint16_t bgcolor) { + backcolor = bgcolor; +} + +// Moves cursor to point +// x: abscissa of the display +// y: ordinate of the display +// point: xy coordinate +void DWINUI::MoveTo(int16_t x, int16_t y) { + cursor.x = x; + cursor.y = y; +} +void DWINUI::MoveTo(xy_int_t point) { + cursor = point; +} + +// Moves cursor relative to the actual position +// x: abscissa of the display +// y: ordinate of the display +// point: xy coordinate +void DWINUI::MoveBy(int16_t x, int16_t y) { + cursor.x += x; + cursor.y += y; +} +void DWINUI::MoveBy(xy_int_t point) { + cursor += point; +} + +// Draw a Centered string using arbitrary x1 and x2 margins +void DWINUI::Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x1, uint16_t x2, uint16_t y, const char * const string) { + const uint16_t x = _MAX(0U, x2 + x1 - strlen_P(string) * fontWidth(size)) / 2 - 1; + DWIN_Draw_String(bShow, size, color, bColor, x, y, string); +} + +// Draw a char +// color: Character color +// x: abscissa of the display +// y: ordinate of the display +// c: ASCII code of char +void DWINUI::Draw_Char(uint16_t color, uint16_t x, uint16_t y, const char c) { + const char string[2] = { c, 0}; + DWIN_Draw_String(false, font, color, backcolor, x, y, string, 1); +} + +// Draw a char at cursor position and increment cursor +void DWINUI::Draw_Char(uint16_t color, const char c) { + Draw_Char(color, cursor.x, cursor.y, c); + MoveBy(fontWidth(font), 0); +} + +// Draw a string at cursor position +// color: Character color +// *string: The string +// rlimit: For draw less chars than string length use rlimit +void DWINUI::Draw_String(const char * const string, uint16_t rlimit) { + DWIN_Draw_String(false, font, textcolor, backcolor, cursor.x, cursor.y, string, rlimit); + MoveBy(strlen(string) * fontWidth(font), 0); +} +void DWINUI::Draw_String(uint16_t color, const char * const string, uint16_t rlimit) { + DWIN_Draw_String(false, font, color, backcolor, cursor.x, cursor.y, string, rlimit); + MoveBy(strlen(string) * fontWidth(font), 0); +} + +// Draw a numeric integer value +// bShow: true=display background color; false=don't display background color +// signedMode: 1=signed; 0=unsigned +// size: Font size +// color: Character color +// bColor: Background color +// iNum: Number of digits +// x/y: Upper-left coordinate +// value: Integer value +void DWINUI::Draw_Int(uint8_t bShow, bool signedMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, int32_t value) { + char nstr[10]; + sprintf_P(nstr, PSTR("%*li"), (signedMode ? iNum + 1 : iNum), value); + DWIN_Draw_String(bShow, size, color, bColor, x, y, nstr); +} + +// Draw a numeric float value +// bShow: true=display background color; false=don't display background color +// signedMode: 1=signed; 0=unsigned +// size: Font size +// color: Character color +// bColor: Background color +// iNum: Number of digits +// fNum: Number of decimal digits +// x/y: Upper-left coordinate +// value: float value +void DWINUI::Draw_Float(uint8_t bShow, bool signedMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + char nstr[10]; + DWIN_Draw_String(bShow, size, color, bColor, x, y, dtostrf(value, iNum + (signedMode ? 2:1) + fNum, fNum, nstr)); +} + +// ------------------------- Buttons ------------------------------// + +void DWINUI::Draw_Button(uint16_t color, uint16_t bcolor, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, const char * const caption) { + DWIN_Draw_Rectangle(1, bcolor, x1, y1, x2, y2); + Draw_CenteredString(0, font, color, bcolor, x1, x2, (y2 + y1 - fontHeight())/2, caption); +} + +void DWINUI::Draw_Button(uint8_t id, uint16_t x, uint16_t y) { + switch (id) { + case BTN_Cancel : Draw_Button(GET_TEXT_F(MSG_BUTTON_CANCEL), x, y); break; + case BTN_Confirm : Draw_Button(GET_TEXT_F(MSG_BUTTON_CONFIRM), x, y); break; + case BTN_Continue: Draw_Button(GET_TEXT_F(MSG_BUTTON_CONTINUE), x, y); break; + case BTN_Print : Draw_Button(GET_TEXT_F(MSG_BUTTON_PRINT), x, y); break; + case BTN_Save : Draw_Button(GET_TEXT_F(MSG_BUTTON_SAVE), x, y); break; + case BTN_Purge : Draw_Button(GET_TEXT_F(MSG_BUTTON_PURGE), x, y); break; + default: break; + } +} + +// -------------------------- Extra -------------------------------// + +// Draw a circle +// color: circle color +// x: the abscissa of the center of the circle +// y: ordinate of the center of the circle +// r: circle radius +void DWINUI::Draw_Circle(uint16_t color, uint16_t x, uint16_t y, uint8_t r) { + int a = 0, b = 0; + while (a <= b) { + b = SQRT(sq(r) - sq(a)); + if (a == 0) b--; + DWIN_Draw_Point(color, 1, 1, x + a, y + b); // Draw some sector 1 + DWIN_Draw_Point(color, 1, 1, x + b, y + a); // Draw some sector 2 + DWIN_Draw_Point(color, 1, 1, x + b, y - a); // Draw some sector 3 + DWIN_Draw_Point(color, 1, 1, x + a, y - b); // Draw some sector 4 + DWIN_Draw_Point(color, 1, 1, x - a, y - b); // Draw some sector 5 + DWIN_Draw_Point(color, 1, 1, x - b, y - a); // Draw some sector 6 + DWIN_Draw_Point(color, 1, 1, x - b, y + a); // Draw some sector 7 + DWIN_Draw_Point(color, 1, 1, x - a, y + b); // Draw some sector 8 + a++; + } +} + +// Draw a circle filled with color +// bcolor: fill color +// x: the abscissa of the center of the circle +// y: ordinate of the center of the circle +// r: circle radius +void DWINUI::Draw_FillCircle(uint16_t bcolor, uint16_t x,uint16_t y,uint8_t r) { + int a = 0, b = 0; + while (a <= b) { + b = SQRT(sq(r) - sq(a)); // b=sqrt(r*r-a*a); + if (a == 0) b--; + DWIN_Draw_Line(bcolor, x-b,y-a,x+b,y-a); + DWIN_Draw_Line(bcolor, x-a,y-b,x+a,y-b); + DWIN_Draw_Line(bcolor, x-b,y+a,x+b,y+a); + DWIN_Draw_Line(bcolor, x-a,y+b,x+a,y+b); + a++; + } +} + +// Color Interpolator +// val : Interpolator minv..maxv +// minv : Minimum value +// maxv : Maximum value +// color1 : Start color +// color2 : End color +uint16_t DWINUI::ColorInt(int16_t val, int16_t minv, int16_t maxv, uint16_t color1, uint16_t color2) { + uint8_t B, G, R; + const float n = (float)(val - minv) / (maxv - minv); + R = (1 - n) * GetRColor(color1) + n * GetRColor(color2); + G = (1 - n) * GetGColor(color1) + n * GetGColor(color2); + B = (1 - n) * GetBColor(color1) + n * GetBColor(color2); + return RGB(R, G, B); +} + +// Color Interpolator through Red->Yellow->Green->Blue (Pro UI) +// val : Interpolator minv..maxv +// minv : Minimum value +// maxv : Maximum value +uint16_t DWINUI::RainbowInt(int16_t val, int16_t minv, int16_t maxv) { + uint8_t B, G, R; + const uint8_t maxB = 28, maxR = 28, maxG = 38; + const int16_t limv = _MAX(abs(minv), abs(maxv)); + float n = minv >= 0 ? (float)(val - minv) / (maxv - minv) : (float)val / limv; + LIMIT(n, -1, 1); + if (n < 0) { + R = 0; + G = (1 + n) * maxG; + B = (-n) * maxB; + } + else if (n < 0.5) { + R = maxR * n * 2; + G = maxG; + B = 0; + } + else { + R = maxR; + G = maxG * (1 - n); + B = 0; + } + return RGB(R, G, B); +} + +// Draw a checkbox +// Color: frame color +// bColor: Background color +// x/y: Upper-left point +// mode : 0 : unchecked, 1 : checked +void DWINUI::Draw_Checkbox(uint16_t color, uint16_t bcolor, uint16_t x, uint16_t y, bool checked=false) { + DWIN_Draw_String(true, font8x16, color, bcolor, x + 4, y, checked ? F("x") : F(" ")); + DWIN_Draw_Rectangle(0, color, x + 2, y + 2, x + 17, y + 17); +} + +// Clear Menu by filling the menu area with background color +void DWINUI::ClearMainArea() { + DWIN_Draw_Rectangle(1, backcolor, 0, TITLE_HEIGHT, DWIN_WIDTH - 1, STATUS_Y - 1); +} + +#endif // DWIN_CREALITY_LCD_JYERSUI diff --git a/Marlin/src/lcd/e3v2/jyersui/dwinui.h b/Marlin/src/lcd/e3v2/jyersui/dwinui.h new file mode 100644 index 000000000000..779e6270a128 --- /dev/null +++ b/Marlin/src/lcd/e3v2/jyersui/dwinui.h @@ -0,0 +1,527 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * DWIN Enhanced implementation for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 3.17.1 + * Date: 2022/04/12 + * + * Modded for JYERSUI by LCH-77 + * Version: 1.9 + * Date: Jun 16, 2022 + */ + +#include "dwin_lcd.h" +#include "../common/dwin_set.h" +#include "../common/dwin_font.h" +#include "../common/dwin_color.h" +#include "../common/dwin_api.h" + +// Custom icons +//#define DWIN_CREALITY_LCD_CUSTOM_ICONS +#if ENABLED(DWIN_CREALITY_LCD_CUSTOM_ICONS) + // index of every custom icon should be >= CUSTOM_ICON_START + #define CUSTOM_ICON_START ICON_Checkbox_F + #define ICON_Checkbox_F 200 + #define ICON_Checkbox_T 201 + #define ICON_Fade 202 + #define ICON_Mesh 203 + #define ICON_Tilt 204 + #define ICON_Brightness 205 + #define ICON_AxisD 249 + #define ICON_AxisBR 250 + #define ICON_AxisTR 251 + #define ICON_AxisBL 252 + #define ICON_AxisTL 253 + #define ICON_AxisC 254 +#else + #define ICON_Fade ICON_Version + #define ICON_Mesh ICON_Version + #define ICON_Tilt ICON_Version + #define ICON_Brightness ICON_Version + #define ICON_AxisD ICON_Axis + #define ICON_AxisBR ICON_Axis + #define ICON_AxisTR ICON_Axis + #define ICON_AxisBL ICON_Axis + #define ICON_AxisTL ICON_Axis + #define ICON_AxisC ICON_Axis + #define ICON_ESDiag ICON_Info + #define ICON_Lock ICON_Cool + #define ICON_Reboot ICON_ResumeEEPROM + #define ICON_ProbeAlarm ICON_SetEndTemp + #define ICON_ProbeMargin ICON_PrintSize + #define ICON_ProbeSelfTest ICON_SetEndTemp + #define ICON_ProbeSet ICON_SetEndTemp + #define ICON_ProbeDeploy ICON_SetEndTemp + #define ICON_ProbeTest ICON_SetEndTemp + #define ICON_ProbeTestCount ICON_SetEndTemp + #define ICON_ProbeZSpeed ICON_MaxSpeedZ + #define ICON_FWRetLength ICON_StepE + #define ICON_FWRetSpeed ICON_Setspeed + #define ICON_FWRetZRaise ICON_MoveZ + #define ICON_FWRecExtLength ICON_StepE + #define ICON_FWRecSpeed ICON_Setspeed + #define ICON_HSMode ICON_StockConfiguration + #define ICON_Sound ICON_Cool + #define ICON_CaseLight ICON_Motion + #define ICON_LedControl ICON_Motion + #define ICON_MeshActive ICON_HotendTemp + #define ICON_Park ICON_Motion +#endif + +// Buttons +#define BTN_Continue 85 +#define BTN_Cancel 87 +#define BTN_Confirm 89 +#define BTN_Print 90 +#define BTN_Save 91 +#define BTN_Purge 92 + +// Extended UI Colors +#define Color_Aqua RGB(0,63,31) +#define Color_Light_White 0xBDD7 +#define Color_Green RGB(0,63,0) +#define Color_Light_Green 0x3460 +#define Color_Cyan 0x07FF +#define Color_Light_Cyan 0x04F3 +#define Color_Blue RGB(0,0,31) +#define Color_Light_Blue 0x3A6A +#define Color_Magenta 0xF81F +#define Color_Light_Magenta 0x9813 +#define Color_Light_Red 0x8800 +#define Color_Orange 0xFA20 +#define Color_Light_Orange 0xFBC0 +#define Color_Light_Yellow 0x8BE0 +#define Color_Brown 0xCC27 +#define Color_Light_Brown 0x6204 +#define Color_Black 0x0000 +#define Color_Grey 0x18E3 +#define Check_Color 0x4E5C +#define Confirm_Color 0x34B9 +#define Cancel_Color 0x3186 + +// UI element defines and constants +#define DWIN_FONT_MENU font8x16 +#define DWIN_FONT_STAT font10x20 +#define DWIN_FONT_HEAD font10x20 +#define DWIN_FONT_ALERT font10x20 +#define STATUS_Y 354 +#define LCD_WIDTH (DWIN_WIDTH / 8) // only if the default font is font8x16 + +// Minimum unit (0.1) : multiple (10) +#define UNITFDIGITS 1 +#define MINUNITMULT POW(10, UNITFDIGITS) + +constexpr uint8_t TITLE_HEIGHT = 30, // Title bar height + MLINE = 53, // Menu line height + TROWS = (STATUS_Y - TITLE_HEIGHT) / MLINE, // Total rows + MROWS = TROWS - 1, // Other-than-Back + ICOX = 26, // Menu item icon X position + LBLX = 60, // Menu item label X position + VALX = 210, // Menu item value X position + MENU_CHR_W = 8, MENU_CHR_H = 16, // Menu font 8x16 + STAT_CHR_W = 10; + +// Menuitem Y position +#define MYPOS(L) (TITLE_HEIGHT + MLINE * (L)) + +// Menuitem caption Offset +#define CAPOFF ((MLINE - MENU_CHR_H) / 2) + +// Menuitem caption Y position +#define MBASE(L) (MYPOS(L) + CAPOFF) + +typedef struct { uint16_t left, top, right, bottom; } rect_t; +typedef struct { uint16_t x, y, w, h; } frame_rect_t; + +namespace DWINUI { + extern xy_int_t cursor; + extern uint16_t pencolor; + extern uint16_t textcolor; + extern uint16_t backcolor; + extern uint16_t buttoncolor; + extern uint8_t font; + extern FSTR_P const Author; + + // DWIN LCD Initialization + void init(); + + // Set text/number font + void setFont(uint8_t cfont); + + // Get font character width + uint8_t fontWidth(uint8_t cfont); + inline uint8_t fontWidth() { return fontWidth(font); }; + + // Get font character height + uint8_t fontHeight(uint8_t cfont); + inline uint8_t fontHeight() { return fontHeight(font); }; + + // Get screen x coordinates from text column + uint16_t ColToX(uint8_t col); + + // Get screen y coordinates from text row + uint16_t RowToY(uint8_t row); + + // Set text/number color + void SetColors(uint16_t fgcolor, uint16_t bgcolor, uint16_t alcolor); + void SetTextColor(uint16_t fgcolor); + void SetBackgroundColor(uint16_t bgcolor); + + // Moves cursor to point + // x: abscissa of the display + // y: ordinate of the display + // point: xy coordinate + void MoveTo(int16_t x, int16_t y); + void MoveTo(xy_int_t point); + + // Moves cursor relative to the actual position + // x: abscissa of the display + // y: ordinate of the display + // point: xy coordinate + void MoveBy(int16_t x, int16_t y); + void MoveBy(xy_int_t point); + + // Draw a line from the cursor to xy position + // color: Line segment color + // x/y: End point + inline void LineTo(uint16_t color, uint16_t x, uint16_t y) { + DWIN_Draw_Line(color, cursor.x, cursor.y, x, y); + } + inline void LineTo(uint16_t x, uint16_t y) { + DWIN_Draw_Line(pencolor, cursor.x, cursor.y, x, y); + } + + // Extend a frame box + // v: value to extend + inline frame_rect_t ExtendFrame(frame_rect_t frame, uint8_t v) { + frame_rect_t t; + t.x = frame.x - v; + t.y = frame.y - v; + t.w = frame.w + 2 * v; + t.h = frame.h + 2 * v; + return t; + } + + // Draw an Icon with transparent background from the library ICON + // icon: Icon ID + // x/y: Upper-left point + inline void Draw_Icon(uint8_t icon, uint16_t x, uint16_t y) { + DWIN_ICON_Show(ICON, icon, x, y); + } + + // Draw an Icon from the library ICON with its background + // icon: Icon ID + // x/y: Upper-left point + inline void Draw_IconWB(uint8_t icon, uint16_t x, uint16_t y) { + DWIN_ICON_Show(true, false, false, ICON, icon, x, y); + } + inline void DRAW_IconWB(uint8_t libID, uint8_t icon, uint16_t x, uint16_t y) { + DWIN_ICON_Show(true, false, false, libID, icon, x, y); + } + + // Draw a numeric integer value + // bShow: true=display background color; false=don't display background color + // signedMode: 1=signed; 0=unsigned + // size: Font size + // color: Character color + // bColor: Background color + // iNum: Number of digits + // x/y: Upper-left coordinate + // value: Integer value + void Draw_Int(uint8_t bShow, bool signedMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, int32_t value); + + // Draw a positive integer + inline void Draw_Int(uint8_t bShow, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { + Draw_Int(bShow, 0, size, color, bColor, iNum, x, y, value); + } + inline void Draw_Int(uint8_t iNum, long value) { + Draw_Int(false, 0, font, textcolor, backcolor, iNum, cursor.x, cursor.y, value); + MoveBy(iNum * fontWidth(font), 0); + } + inline void Draw_Int(uint8_t iNum, uint16_t x, uint16_t y, long value) { + Draw_Int(false, 0, font, textcolor, backcolor, iNum, x, y, value); + } + inline void Draw_Int(uint16_t color, uint8_t iNum, uint16_t x, uint16_t y, long value) { + Draw_Int(false, 0, font, color, backcolor, iNum, x, y, value); + } + inline void Draw_Int(uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { + Draw_Int(true, 0, font, color, bColor, iNum, x, y, value); + } + inline void Draw_Int(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { + Draw_Int(true, 0, size, color, bColor, iNum, x, y, value); + } + + // Draw a signed integer + inline void Draw_Signed_Int(uint8_t bShow, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { + Draw_Int(bShow, 1, size, color, bColor, iNum, x, y, value); + } + inline void Draw_Signed_Int(uint8_t iNum, long value) { + Draw_Int(false, 1, font, textcolor, backcolor, iNum, cursor.x, cursor.y, value); + MoveBy(iNum * fontWidth(font), 0); + } + inline void Draw_Signed_Int(uint8_t iNum, uint16_t x, uint16_t y, long value) { + Draw_Int(false, 1, font, textcolor, backcolor, iNum, x, y, value); + } + inline void Draw_Signed_Int(uint16_t color, uint8_t iNum, uint16_t x, uint16_t y, long value) { + Draw_Int(false, 1, font, color, backcolor, iNum, x, y, value); + } + inline void Draw_Signed_Int(uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { + Draw_Int(true, 1, font, color, bColor, iNum, x, y, value); + } + inline void Draw_Signed_Int(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { + Draw_Int(true, 1, size, color, bColor, iNum, x, y, value); + } + + // Draw a numeric float value + // bShow: true=display background color; false=don't display background color + // signedMode: 1=signed; 0=unsigned + // size: Font size + // color: Character color + // bColor: Background color + // iNum: Number of digits + // fNum: Number of decimal digits + // x/y: Upper-left coordinate + // value: float value + void Draw_Float(uint8_t bShow, bool signedMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value); + + // Draw a positive floating point number + inline void Draw_Float(uint8_t bShow, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(bShow, 0, size, color, bColor, iNum, fNum, x, y, value); + } + inline void Draw_Float(uint8_t iNum, uint8_t fNum, float value) { + Draw_Float(false, 0, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value); + MoveBy((iNum + fNum + 1) * fontWidth(font), 0); + } + inline void Draw_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(false, 0, font, textcolor, backcolor, iNum, fNum, x, y, value); + } + inline void Draw_Float(uint8_t size, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(false, 0, size, textcolor, backcolor, iNum, fNum, x, y, value); + } + inline void Draw_Float(uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(true, 0, font, color, bColor, iNum, fNum, x, y, value); + } + inline void Draw_Float(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(true, 0, size, color, bColor, iNum, fNum, x, y, value); + } + + // Draw a signed floating point number + inline void Draw_Signed_Float(uint8_t bShow, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(bShow, 1, size, color, bColor, iNum, fNum, x, y, value); + } + inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, float value) { + Draw_Float(false, 1, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value); + MoveBy((iNum + fNum + 1) * fontWidth(font), 0); + } + inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(false, 1, font, textcolor, backcolor, iNum, fNum, x, y, value); + } + inline void Draw_Signed_Float(uint8_t size, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(false, 1, size, textcolor, backcolor, iNum, fNum, x, y, value); + } + inline void Draw_Signed_Float(uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(true, 1, font, color, bColor, iNum, fNum, x, y, value); + } + inline void Draw_Signed_Float(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(true, 1, size, color, bColor, iNum, fNum, x, y, value); + } + + // Draw a char + // color: Character color + // x: abscissa of the display + // y: ordinate of the display + // c: ASCII code of char + void Draw_Char(uint16_t color, uint16_t x, uint16_t y, const char c); + inline void Draw_Char(uint16_t x, uint16_t y, const char c) { Draw_Char(textcolor, x, y, c); }; + // Draw a char at cursor position and increment cursor + void Draw_Char(uint16_t color, const char c); + inline void Draw_Char(const char c) { Draw_Char(textcolor, c); } + + // Draw a string at cursor position + // color: Character color + // *string: The string + // rlimit: For draw less chars than string length use rlimit + void Draw_String(const char * const string, uint16_t rlimit = 0xFFFF); + void Draw_String(uint16_t color, const char * const string, uint16_t rlimit = 0xFFFF); + inline void Draw_String(FSTR_P string, uint16_t rlimit = 0xFFFF) { + Draw_String(FTOP(string), rlimit); + } + inline void Draw_String(uint16_t color, FSTR_P string, uint16_t rlimit = 0xFFFF) { + Draw_String(color, FTOP(string), rlimit); + } + + // Draw a string + // size: Font size + // color: Character color + // bColor: Background color + // x/y: Upper-left coordinate of the string + // *string: The string + inline void Draw_String(uint16_t x, uint16_t y, const char * const string) { + DWIN_Draw_String(false, font, textcolor, backcolor, x, y, string); + } + inline void Draw_String(uint16_t x, uint16_t y, FSTR_P title) { + DWIN_Draw_String(false, font, textcolor, backcolor, x, y, FTOP(title)); + } + inline void Draw_String(uint16_t color, uint16_t x, uint16_t y, const char * const string) { + DWIN_Draw_String(false, font, color, backcolor, x, y, string); + } + inline void Draw_String(uint16_t color, uint16_t x, uint16_t y, FSTR_P title) { + DWIN_Draw_String(false, font, color, backcolor, x, y, title); + } + inline void Draw_String(uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, const char * const string) { + DWIN_Draw_String(true, font, color, bgcolor, x, y, string); + } + inline void Draw_String(uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, FSTR_P title) { + DWIN_Draw_String(true, font, color, bgcolor, x, y, title); + } + inline void Draw_String(uint8_t size, uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, const char * const string) { + DWIN_Draw_String(true, size, color, bgcolor, x, y, string); + } + inline void Draw_String(uint8_t size, uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, FSTR_P title) { + DWIN_Draw_String(true, size, color, bgcolor, x, y, title); + } + + // Draw a centered string using DWIN_WIDTH + // bShow: true=display background color; false=don't display background color + // size: Font size + // color: Character color + // bColor: Background color + // y: Upper coordinate of the string + // *string: The string + void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x1, uint16_t x2, uint16_t y, const char * const string); + inline void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, const char * const string) { + Draw_CenteredString(bShow, size, color, bColor, 0, DWIN_WIDTH, y, string); + } + inline void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, FSTR_P string) { + Draw_CenteredString(bShow, size, color, bColor, y, FTOP(string)); + } + inline void Draw_CenteredString(uint16_t color, uint16_t bcolor, uint16_t y, const char * const string) { + Draw_CenteredString(true, font, color, bcolor, y, string); + } + inline void Draw_CenteredString(uint8_t size, uint16_t color, uint16_t y, const char * const string) { + Draw_CenteredString(false, size, color, backcolor, y, string); + } + inline void Draw_CenteredString(uint8_t size, uint16_t color, uint16_t y, FSTR_P title) { + Draw_CenteredString(false, size, color, backcolor, y, title); + } + inline void Draw_CenteredString(uint16_t color, uint16_t y, const char * const string) { + Draw_CenteredString(false, font, color, backcolor, y, string); + } + inline void Draw_CenteredString(uint16_t color, uint16_t y, FSTR_P title) { + Draw_CenteredString(false, font, color, backcolor, y, title); + } + inline void Draw_CenteredString(uint16_t y, const char * const string) { + Draw_CenteredString(false, font, textcolor, backcolor, y, string); + } + inline void Draw_CenteredString(uint16_t y, FSTR_P title) { + Draw_CenteredString(false, font, textcolor, backcolor, y, title); + } + + // Draw a box + // mode: 0=frame, 1=fill, 2=XOR fill + // color: Rectangle color + // frame: Box coordinates and size + inline void Draw_Box(uint8_t mode, uint16_t color, frame_rect_t frame) { + DWIN_Draw_Box(mode, color, frame.x, frame.y, frame.w, frame.h); + } + + // Draw a circle + // Color: circle color + // x: abscissa of the center of the circle + // y: ordinate of the center of the circle + // r: circle radius + void Draw_Circle(uint16_t color, uint16_t x,uint16_t y,uint8_t r); + inline void Draw_Circle(uint16_t color, uint8_t r) { + Draw_Circle(color, cursor.x, cursor.y, r); + } + + // Draw a checkbox + // Color: frame color + // bColor: Background color + // x/y: Upper-left point + // checked : 0 : unchecked, 1 : checked + void Draw_Checkbox(uint16_t color, uint16_t bcolor, uint16_t x, uint16_t y, bool checked); + inline void Draw_Checkbox(uint16_t x, uint16_t y, bool checked=false) { + Draw_Checkbox(textcolor, backcolor, x, y, checked); + } + + // Color Interpolator + // val : Interpolator minv..maxv + // minv : Minimum value + // maxv : Maximum value + // color1 : Start color + // color2 : End color + uint16_t ColorInt(int16_t val, int16_t minv, int16_t maxv, uint16_t color1, uint16_t color2); + + // ------------------------- Buttons ------------------------------// + + void Draw_Button(uint16_t color, uint16_t bcolor, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, const char * const caption); + inline void Draw_Button(uint16_t color, uint16_t bcolor, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, FSTR_P caption) { + Draw_Button(color, bcolor, x1, y1, x2, y2, FTOP(caption)); + } + inline void Draw_Button(FSTR_P caption, uint16_t x, uint16_t y) { + Draw_Button(textcolor, buttoncolor, x, y, x + 99, y + 37, caption); + } + void Draw_Button(uint8_t id, uint16_t x, uint16_t y); + + // -------------------------- Extra -------------------------------// + + // Draw a circle filled with color + // bcolor: fill color + // x: abscissa of the center of the circle + // y: ordinate of the center of the circle + // r: circle radius + void Draw_FillCircle(uint16_t bcolor, uint16_t x,uint16_t y,uint8_t r); + inline void Draw_FillCircle(uint16_t bcolor, uint8_t r) { + Draw_FillCircle(bcolor, cursor.x, cursor.y, r); + } + + // Color Interpolator through Red->Yellow->Green->Blue + // val : Interpolator minv..maxv + // minv : Minimum value + // maxv : Maximum value + uint16_t RainbowInt(int16_t val, int16_t minv, int16_t maxv); + + // Write buffer data to the SRAM + // addr: SRAM start address 0x0000-0x7FFF + // length: Bytes to write + // data: address of the buffer with data + inline void WriteToSRAM(uint16_t addr, uint16_t length, uint8_t *data) { + DWIN_WriteToMem(0x5A, addr, length, data); + } + + // Write buffer data to the Flash + // addr: Flash start address 0x0000-0x3FFF + // length: Bytes to write + // data: address of the buffer with data + inline void WriteToFlash(uint16_t addr, uint16_t length, uint8_t *data) { + DWIN_WriteToMem(0xA5, addr, length, data); + } + + // Clear by filling the area with background color + // Area (0, TITLE_HEIGHT, DWIN_WIDTH, STATUS_Y - 1) + void ClearMainArea(); + +}; diff --git a/Marlin/src/lcd/e3v2/jyersui/endstop_diag.cpp b/Marlin/src/lcd/e3v2/jyersui/endstop_diag.cpp new file mode 100644 index 000000000000..5c4549619fb1 --- /dev/null +++ b/Marlin/src/lcd/e3v2/jyersui/endstop_diag.cpp @@ -0,0 +1,111 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * DWIN End Stops diagnostic page + * Author: Miguel A. Risco-Castillo + * Version: 1.0 + * Date: 2021/11/06 + * + * Modded for JYERSUI by LCH-77 + */ + +#include "../../../inc/MarlinConfigPre.h" + +#if ENABLED(DWIN_CREALITY_LCD_JYERSUI) + +#include "dwin_defines.h" + +#if HAS_ESDIAG + +#include "endstop_diag.h" +#include "dwinui.h" +#include "dwin.h" + +#if HAS_FILAMENT_SENSOR + #include "../../../feature/runout.h" +#endif + +#if HAS_BED_PROBE + #include "../../../module/probe.h" +#endif + +ESDiagClass ESDiag; + +void draw_es_label(FSTR_P const flabel=nullptr) { + DWINUI::cursor.x = 40; + if (flabel) DWINUI::Draw_String(F(flabel)); + DWINUI::Draw_String(F(": ")); + DWINUI::MoveBy(0, 25); +} + +void draw_es_state(const bool is_hit) { + const uint8_t LM = 130; + DWINUI::cursor.x = LM; + DWIN_Draw_Rectangle(1, Color_Bg_Window, LM, DWINUI::cursor.y, LM + 100, DWINUI::cursor.y + 20); + is_hit ? DWINUI::Draw_String(RGB(31,31,16), F(STR_ENDSTOP_HIT)) : DWINUI::Draw_String(RGB(16,63,16), F(STR_ENDSTOP_OPEN)); + DWINUI::MoveBy(0, 25); +} + +void ESDiagClass::Draw() { + CrealityDWINClass::Clear_Screen(1); + CrealityDWINClass::Draw_Title(F("End-stops Diagnostic")); + DWINUI::ClearMainArea(); + DWIN_Draw_Rectangle(0, Color_White, 14, 60, 258, 330); + DWINUI::Draw_Button(BTN_Continue, 86, 250); + DWINUI::cursor.y = 80; + #define ES_LABEL(S) draw_es_label(F(STR_##S)) + #if HAS_X_MIN + ES_LABEL(X_MIN); + #endif + #if HAS_Y_MIN + ES_LABEL(Y_MIN); + #endif + #if HAS_Z_MIN + ES_LABEL(Z_MIN); + #endif + #if HAS_FILAMENT_SENSOR + draw_es_label(F(STR_FILAMENT)); + #endif + Update(); +} + +void ESDiagClass::Update() { + DWINUI::cursor.y = 80; + #define ES_REPORT(S) draw_es_state(READ(S##_PIN) != S##_ENDSTOP_INVERTING) + #if HAS_X_MIN + ES_REPORT(X_MIN); + #endif + #if HAS_Y_MIN + ES_REPORT(Y_MIN); + #endif + #if HAS_Z_MIN + ES_REPORT(Z_MIN); + #endif + #if HAS_FILAMENT_SENSOR + draw_es_state(READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE); + #endif + DWIN_UpdateLCD(); +} + +#endif // HAS_ES_DIAG +#endif // DWIN_CREALITY_LCD_JYERSUI diff --git a/Marlin/src/lcd/e3v2/jyersui/endstop_diag.h b/Marlin/src/lcd/e3v2/jyersui/endstop_diag.h new file mode 100644 index 000000000000..59509739d047 --- /dev/null +++ b/Marlin/src/lcd/e3v2/jyersui/endstop_diag.h @@ -0,0 +1,39 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * DWIN End Stops diagnostic page + * Author: Miguel A. Risco-Castillo + * Version: 1.0 + * Date: 2021/11/06 + * + * Modded for JYERSUI by LCH-77 + */ + +class ESDiagClass { +public: + void Draw(); + void Update(); +}; + +extern ESDiagClass ESDiag; diff --git a/Marlin/src/lcd/e3v2/jyersui/gcode_preview.cpp b/Marlin/src/lcd/e3v2/jyersui/gcode_preview.cpp new file mode 100644 index 000000000000..26037a9ce9ba --- /dev/null +++ b/Marlin/src/lcd/e3v2/jyersui/gcode_preview.cpp @@ -0,0 +1,244 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * DWIN G-code thumbnail preview + * Author: Miguel A. Risco-Castillo + * version: 2.1 + * Date: 2021/06/19 + * + * Modded for JYERSUI by LCH-77 + */ + +#include "../../../inc/MarlinConfigPre.h" +#if ENABLED(DWIN_CREALITY_LCD_JYERSUI) + +#include "dwin_defines.h" + +#if HAS_GCODE_PREVIEW + +#include "../../../core/types.h" +#include "../../marlinui.h" +#include "../../../sd/cardreader.h" +#include "../../../MarlinCore.h" // for wait_for_user +#include "dwin_lcd.h" +#include "dwinui.h" +#include "dwin.h" +#include "base64.hpp" +#include "gcode_preview.h" + +typedef struct { + char name[13] = ""; //8.3 + null + uint32_t thumbstart = 0; + int thumbsize = 0; + int thumbheight = 0; + int thumbwidth = 0; + uint8_t *thumbdata = nullptr; + float time = 0; + float filament = 0; + float layer = 0; + float width = 0; + float height = 0; + float length = 0; + void setname(const char * const fn); + void clear(); +} fileprop_t; +fileprop_t fileprop; + +void fileprop_t::setname(const char * const fn) { + const uint8_t len = _MIN(sizeof(name) - 1, strlen(fn)); + memcpy(&name[0], fn, len); + name[len] = '\0'; +} + +void fileprop_t::clear() { + fileprop.name[0] = '\0'; + fileprop.thumbstart = 0; + fileprop.thumbsize = 0; + fileprop.thumbheight = 0; + fileprop.thumbwidth = 0; + fileprop.thumbdata = nullptr; + fileprop.time = 0; + fileprop.filament = 0; + fileprop.layer = 0; + fileprop.height = 0; + fileprop.width = 0; + fileprop.length = 0; +} + +void Get_Value(char *buf, const char * const key, float &value) { + char num[10] = ""; + char * posptr = 0; + uint8_t i = 0; + if (!!value) return; + posptr = strstr(buf, key); + if (posptr != nullptr) { + while (i < sizeof(num)) { + char c = posptr[0]; + if (!ISEOL(c) && (c != 0)) { + if ((c > 47 && c < 58) || (c == '.')) num[i++] = c; + posptr++; + } + else { + num[i] = '\0'; + value = atof(num); + return; + } + } + } +} + +bool Has_Preview() { + const char * tbstart = "; thumbnail begin 230x180"; + char * posptr = 0; + uint8_t nbyte = 1; + uint32_t indx = 0; + char buf[256]; + float tmp = 0; + + fileprop.clear(); + fileprop.setname(card.filename); + + card.openFileRead(fileprop.name); + + while ((nbyte > 0) && (indx < 4 * sizeof(buf)) && !fileprop.thumbstart) { + nbyte = card.read(buf, sizeof(buf) - 1); + if (nbyte > 0) { + buf[nbyte] = '\0'; + Get_Value(buf, ";TIME:", fileprop.time); + Get_Value(buf, ";Filament used:", fileprop.filament); + Get_Value(buf, ";Layer height:", fileprop.layer); + Get_Value(buf, ";MINX:", tmp); + Get_Value(buf, ";MAXX:", fileprop.width); + fileprop.width -= tmp; + tmp = 0; + Get_Value(buf, ";MINY:", tmp); + Get_Value(buf, ";MAXY:", fileprop.length); + fileprop.length -= tmp; + tmp = 0; + Get_Value(buf, ";MINZ:", tmp); + Get_Value(buf, ";MAXZ:", fileprop.height); + fileprop.height -= tmp; + posptr = strstr(buf, tbstart); + if (posptr != NULL) { + fileprop.thumbstart = indx + (posptr - &buf[0]); + } + else { + indx += _MAX(10, nbyte - (signed)strlen(tbstart)); + card.setIndex(indx); + } + } + } + + if (!fileprop.thumbstart) { + card.closefile(); + LCD_MESSAGE_F("Thumbnail not found"); + return 0; + } + + // Get the size of the thumbnail + card.setIndex(fileprop.thumbstart + strlen(tbstart)); + for (uint8_t i = 0; i < 16; i++) { + char c = card.get(); + if (!ISEOL(c)) { + buf[i] = c; + } + else { + buf[i] = '\0'; + break; + } + } + fileprop.thumbsize = atoi(buf); + + // Exit if there isn't a thumbnail + if (!fileprop.thumbsize) { + card.closefile(); + LCD_MESSAGE_F("Invalid Thumbnail Size"); + return 0; + } + + uint16_t readed = 0; + uint8_t buf64[fileprop.thumbsize]; + + fileprop.thumbdata = new uint8_t[3 + 3 * (fileprop.thumbsize / 4)]; // Reserve space for the JPEG thumbnail + + while (readed < fileprop.thumbsize) { + uint8_t c = card.get(); + if (!ISEOL(c) && (c != ';') && (c != ' ')) { + buf64[readed] = c; + readed++; + } + } + card.closefile(); + buf64[readed] = 0; + + fileprop.thumbsize = decode_base64(buf64, fileprop.thumbdata); card.closefile(); + DWINUI::WriteToSRAM(0x00, fileprop.thumbsize, fileprop.thumbdata); + delete[] fileprop.thumbdata; + return true; +} + +void Preview_DrawFromSD() { + bool _has_preview = Has_Preview(); + CrealityDWIN.Popup_Handler(PrintConfirm, _has_preview); + if (_has_preview) { + char buf[46]; + char str_1[6] = "", str_2[6] = "", str_3[6] = ""; + // DWIN_Draw_Rectangle(1, Def_Background_Color, 0, 0, DWIN_WIDTH, STATUS_Y - 1); + if (fileprop.time) { + sprintf_P(buf, PSTR("Estimated time: %i:%02i"), (uint16_t)fileprop.time / 3600, ((uint16_t)fileprop.time % 3600) / 60); + DWINUI::Draw_String(20, 10, buf); + } + if (fileprop.filament) { + sprintf_P(buf, PSTR("Filament used: %s m"), dtostrf(fileprop.filament, 1, 2, str_1)); + DWINUI::Draw_String(20, 30, buf); + } + if (fileprop.layer) { + sprintf_P(buf, PSTR("Layer height: %s mm"), dtostrf(fileprop.layer, 1, 2, str_1)); + DWINUI::Draw_String(20, 50, buf); + } + if (fileprop.width) { + sprintf_P(buf, PSTR("Volume: %sx%sx%s mm"), dtostrf(fileprop.width, 1, 1, str_1), dtostrf(fileprop.length, 1, 1, str_2), dtostrf(fileprop.height, 1, 1, str_3)); + DWINUI::Draw_String(20, 70, buf); + } + // DWINUI::Draw_Button(BTN_Print, 26, 290); + // DWINUI::Draw_Button(BTN_Cancel, 146, 290); + DWIN_ICON_Show(0, 0, 1, 21, 90, 0x00); + // Draw_Select_Highlight(true, 290); + DWIN_UpdateLCD(); + } + // else { + // HMI_flag.select_flag = 1; + // wait_for_user = false; + // } +} + +bool Preview_Valid() { + return !!fileprop.thumbstart; +} + +void Preview_Reset() { + fileprop.thumbsize = 0; +} + +#endif // HAS_GCODE_PREVIEW +#endif // DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/jyersui/gcode_preview.h b/Marlin/src/lcd/e3v2/jyersui/gcode_preview.h new file mode 100644 index 000000000000..d10663e08bb0 --- /dev/null +++ b/Marlin/src/lcd/e3v2/jyersui/gcode_preview.h @@ -0,0 +1,34 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * DWIN G-code thumbnail preview + * Author: Miguel A. Risco-Castillo + * version: 2.1 + * Date: 2021/06/19 + */ + +#pragma once + +void Preview_DrawFromSD(); +bool Preview_Valid(); +void Preview_Reset(); diff --git a/Marlin/src/lcd/e3v2/jyersui/lockscreen.cpp b/Marlin/src/lcd/e3v2/jyersui/lockscreen.cpp new file mode 100644 index 000000000000..5ed6dd3317b1 --- /dev/null +++ b/Marlin/src/lcd/e3v2/jyersui/lockscreen.cpp @@ -0,0 +1,83 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * Lock screen implementation for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 2.2.0 + * Date: 2022/04/11 + * + * Modded for JYERSUI by LCH-77 + */ + +#include "../../../inc/MarlinConfigPre.h" + +#if ENABLED(DWIN_CREALITY_LCD_JYERSUI) + +#include "dwin_defines.h" + +#if HAS_LOCKSCREEN + +#include "../common/dwin_color.h" +#include "dwinui.h" +#include "dwin.h" +#include "lockscreen.h" + +LockScreenClass lockScreen; + +uint8_t LockScreenClass::lock_pos = 0; +bool LockScreenClass::unlocked = false; +uint8_t LockScreenClass::rprocess = 0; + +void LockScreenClass::init() { + lock_pos = 0; + unlocked = false; + draw(); +} + +void LockScreenClass::draw() { + CrealityDWINClass::Clear_Screen(1); + CrealityDWINClass::Draw_Title(GET_TEXT_F(MSG_LOCKSCREEN)); + DWINUI::ClearMainArea(); + DWINUI::Draw_Icon(ICON_LOGO, 71, 120); // CREALITY logo + DWINUI::Draw_CenteredString(Color_White, 180, GET_TEXT_F(MSG_LOCKSCREEN_LOCKED)); + DWINUI::Draw_CenteredString(Color_White, 200, GET_TEXT_F(MSG_LOCKSCREEN_UNLOCK)); + DWINUI::Draw_CenteredString(Color_White, 240, F("-> | <-")); + DWIN_Draw_Box(1, BarFill_Color, 0, 260, DWIN_WIDTH, 20); + DWIN_Draw_VLine(Color_Yellow, lock_pos * DWIN_WIDTH / 255, 260, 20); + DWIN_UpdateLCD(); +} + +void LockScreenClass::onEncoder(EncoderState encoder_diffState) { + switch (encoder_diffState) { + case ENCODER_DIFF_CW: lock_pos += 8; break; + case ENCODER_DIFF_CCW: lock_pos -= 8; break; + case ENCODER_DIFF_ENTER: unlocked = (lock_pos == 128); break; + default: break; + } + DWIN_Draw_Box(1, BarFill_Color, 0, 260, DWIN_WIDTH, 20); + DWIN_Draw_VLine(Color_Yellow, lock_pos * DWIN_WIDTH / 255, 260, 20); + DWIN_UpdateLCD(); +} + +#endif // HAS_LOCKSCREEN +#endif // DWIN_CREALITY_LCD_JYERSUI diff --git a/Marlin/src/lcd/e3v2/jyersui/lockscreen.h b/Marlin/src/lcd/e3v2/jyersui/lockscreen.h new file mode 100644 index 000000000000..99c22a37da23 --- /dev/null +++ b/Marlin/src/lcd/e3v2/jyersui/lockscreen.h @@ -0,0 +1,49 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * Lock screen implementation for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 2.2.0 + * Date: 2022/04/11 + * + * Modded for JYERSUI by LCH-77 + */ + +#include "../../../core/types.h" +#include "../common/encoder.h" +#include + +class LockScreenClass { +private: + static bool unlocked; + static uint8_t lock_pos; +public: + static uint8_t rprocess; + static void init(); + static void onEncoder(EncoderState encoder_diffState); + static void draw(); + static bool isUnlocked() { return unlocked; } +}; + +extern LockScreenClass lockScreen; diff --git a/Marlin/src/lcd/e3v2/jyersui/plot.cpp b/Marlin/src/lcd/e3v2/jyersui/plot.cpp new file mode 100644 index 000000000000..c0c283f5c0be --- /dev/null +++ b/Marlin/src/lcd/e3v2/jyersui/plot.cpp @@ -0,0 +1,86 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * DWIN Single var plot + * Author: Miguel A. Risco-Castillo + * Version: 2.0 + * Date: 2022/01/31 + * + * Modded for JYERSUI by LCH-77 + */ + +#include "../../../inc/MarlinConfigPre.h" + +#ifdef DWIN_CREALITY_LCD_JYERSUI + +#include "dwin_defines.h" + +#ifdef HAS_PIDPLOT + +#include "plot.h" + +#include "../../../core/types.h" +#include "../../marlinui.h" +#include "dwin_lcd.h" +#include "dwinui.h" +#include "dwin.h" + +#define Plot_Bg_Color RGB( 1, 12, 8) + +PlotClass Plot; + +uint16_t grphpoints, r, x2, y2 = 0; +frame_rect_t grphframe = {0}; +float scale = 0; + +void PlotClass::Draw(const frame_rect_t frame, const float max, const float ref) { + grphframe = frame; + grphpoints = 0; + scale = frame.h / max; + x2 = frame.x + frame.w - 1; + y2 = frame.y + frame.h - 1; + r = round((y2) - ref * scale); + DWINUI::Draw_Box(1, Plot_Bg_Color, frame); + for (uint8_t i = 1; i < 4; i++) if (i*50 < frame.w) DWIN_Draw_VLine(Line_Color, i*50 + frame.x, frame.y, frame.h); + DWINUI::Draw_Box(0, Color_White, DWINUI::ExtendFrame(frame, 1)); + DWIN_Draw_HLine(Color_Red, frame.x, r, frame.w); +} + +void PlotClass::Update(const float value) { + if (!scale) return; + uint16_t y = round((y2) - value * scale); + if (grphpoints < grphframe.w) { + DWIN_Draw_Point(Color_Yellow, 1, 1, grphpoints + grphframe.x, y); + } + else { + DWIN_Frame_AreaMove(1, 0, 1, Plot_Bg_Color, grphframe.x, grphframe.y, x2, y2); + if ((grphpoints % 50) == 0) DWIN_Draw_VLine(Line_Color, x2 - 1, grphframe.y + 1, grphframe.h - 2); + DWIN_Draw_Point(Color_Red, 1, 1, x2 - 1, r); + DWIN_Draw_Point(Color_Yellow, 1, 1, x2 - 1, y); + } + grphpoints++; +} + +#endif // HAS_PIDPLOT + +#endif // DWIN_CREALITY_LCD_JYERSUI diff --git a/Marlin/src/lcd/e3v2/jyersui/plot.h b/Marlin/src/lcd/e3v2/jyersui/plot.h new file mode 100644 index 000000000000..1f97eafb71ba --- /dev/null +++ b/Marlin/src/lcd/e3v2/jyersui/plot.h @@ -0,0 +1,41 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * DWIN Single var plot + * Author: Miguel A. Risco-Castillo + * Version: 1.0 + * Date: 2022/01/30 + * + * Modded for JYERSUI by LCH-77 + */ + +#include "dwinui.h" + +class PlotClass { +public: + void Draw(frame_rect_t frame, float max, float ref = 0); + void Update(float value); +}; + +extern PlotClass Plot; diff --git a/Marlin/src/lcd/e3v2/proui/base64.hpp b/Marlin/src/lcd/e3v2/proui/base64.hpp index d82d0b27e8ac..7a933df321b8 100644 --- a/Marlin/src/lcd/e3v2/proui/base64.hpp +++ b/Marlin/src/lcd/e3v2/proui/base64.hpp @@ -152,7 +152,7 @@ uint16_t encode_base64(unsigned char input[], uint16_t input_length, unsigned ch output += 4; } - switch(input_length % 3) { + switch (input_length % 3) { case 0: output[0] = '\0'; break; @@ -192,7 +192,7 @@ uint16_t decode_base64(unsigned char input[], uint16_t input_length, unsigned ch output += 3; } - switch(output_length % 3) { + switch (output_length % 3) { case 1: output[0] = base64_to_binary(input[0]) << 2 | base64_to_binary(input[1]) >> 4; break; @@ -205,4 +205,4 @@ uint16_t decode_base64(unsigned char input[], uint16_t input_length, unsigned ch return output_length; } -#endif // ifndef +#endif // BASE64_H_INCLUDED diff --git a/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp b/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp index adb23a96646b..4257728f73e3 100644 --- a/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp +++ b/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp @@ -21,7 +21,7 @@ */ /** - * DWIN g-code thumbnail preview + * DWIN G-code thumbnail preview * Author: Miguel A. Risco-Castillo * version: 2.1 * Date: 2021/06/19 @@ -214,9 +214,7 @@ bool Has_Preview() { void Preview_DrawFromSD() { if (Has_Preview()) { char buf[46]; - char str_1[6] = ""; - char str_2[6] = ""; - char str_3[6] = ""; + char str_1[6] = "", str_2[6] = "", str_3[6] = ""; DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 0, 0, DWIN_WIDTH, STATUS_Y - 1); if (fileprop.time) { sprintf_P(buf, PSTR("Estimated time: %i:%02i"), (uint16_t)fileprop.time / 3600, ((uint16_t)fileprop.time % 3600) / 60); diff --git a/Marlin/src/lcd/e3v2/proui/gcode_preview.h b/Marlin/src/lcd/e3v2/proui/gcode_preview.h index 4417084a242d..97cf7fe5ac9d 100644 --- a/Marlin/src/lcd/e3v2/proui/gcode_preview.h +++ b/Marlin/src/lcd/e3v2/proui/gcode_preview.h @@ -1,5 +1,5 @@ /** - * DWIN g-code thumbnail preview + * DWIN G-code thumbnail preview * Author: Miguel A. Risco-Castillo * version: 2.1 * Date: 2021/06/19 diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 7ee3a87fce39..3d6e14b5f7f1 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -503,7 +503,7 @@ typedef struct SettingsDataStruct { #if ENABLED(DWIN_LCD_PROUI) uint8_t dwin_data[eeprom_data_size]; #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) - uint8_t dwin_settings[CrealityDWIN.eeprom_data_size]; + uint8_t dwin_settings[eeprom_data_size]; #endif // @@ -1525,7 +1525,7 @@ void MarlinSettings::postprocess() { #if ENABLED(DWIN_CREALITY_LCD_JYERSUI) { _FIELD_TEST(dwin_settings); - char dwin_settings[CrealityDWIN.eeprom_data_size] = { 0 }; + char dwin_settings[eeprom_data_size] = { 0 }; CrealityDWIN.Save_Settings(dwin_settings); EEPROM_WRITE(dwin_settings); } @@ -2497,7 +2497,7 @@ void MarlinSettings::postprocess() { } #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) { - const char dwin_settings[CrealityDWIN.eeprom_data_size] = { 0 }; + const char dwin_settings[eeprom_data_size] = { 0 }; _FIELD_TEST(dwin_settings); EEPROM_READ(dwin_settings); if (!validating) CrealityDWIN.Load_Settings(dwin_settings); diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 65b79d8bc464..f03213be1fb2 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -53,6 +53,8 @@ #include "../lcd/e3v2/creality/dwin.h" #elif ENABLED(DWIN_LCD_PROUI) #include "../lcd/e3v2/proui/dwin.h" +#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) + #include "../lcd/e3v2/jyersui/dwin.h" #endif #if ENABLED(EXTENSIBLE_UI) @@ -644,12 +646,14 @@ volatile bool Temperature::raw_temps_ready = false; TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_STARTED)); TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(isbed ? PID_BED_START : PID_EXTR_START)); + TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWINClass::DWIN_PidTuning(isbed ? PID_BED_START : PID_EXTR_START)); if (target > GHV(CHAMBER_MAX_TARGET, BED_MAX_TARGET, temp_range[heater_id].maxtemp - (HOTEND_OVERSHOOT))) { SERIAL_ECHOPGM(STR_PID_AUTOTUNE); SERIAL_ECHOLNPGM(STR_PID_TEMP_TOO_HIGH); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH)); TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_TEMP_TOO_HIGH)); + TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWINClass::DWIN_PidTuning(PID_TEMP_TOO_HIGH)); TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_TEMP_TOO_HIGH))); return; } @@ -744,6 +748,7 @@ volatile bool Temperature::raw_temps_ready = false; SERIAL_ECHOLNPGM(STR_PID_TEMP_TOO_HIGH); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH)); TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_TEMP_TOO_HIGH)); + TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWINClass::DWIN_PidTuning(PID_TEMP_TOO_HIGH)); TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_TEMP_TOO_HIGH))); break; } @@ -782,6 +787,7 @@ volatile bool Temperature::raw_temps_ready = false; TERN_(DWIN_CREALITY_LCD, DWIN_Popup_Temperature(0)); TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_TUNING_TIMEOUT)); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TUNING_TIMEOUT)); + TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWINClass::DWIN_PidTuning(PID_TUNING_TIMEOUT)); TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_TIMEOUT))); SERIAL_ECHOPGM(STR_PID_AUTOTUNE); SERIAL_ECHOLNPGM(STR_PID_TIMEOUT); @@ -839,6 +845,7 @@ volatile bool Temperature::raw_temps_ready = false; TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_DONE)); TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_DONE)); + TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWINClass::DWIN_PidTuning(PID_DONE)); goto EXIT_M303; } @@ -857,6 +864,7 @@ volatile bool Temperature::raw_temps_ready = false; TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_DONE)); TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_DONE)); + TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWINClass::DWIN_PidTuning(PID_DONE)); EXIT_M303: TERN_(NO_FAN_SLOWING_IN_PID_TUNING, adaptive_fan_slowing = true); From 0fdedfa2fb46d665fbd5686bc58e7126ee82bd97 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 6 Jul 2022 19:29:07 -0500 Subject: [PATCH 12/32] =?UTF-8?q?=F0=9F=93=9D=20Configurations=2002010100?= =?UTF-8?q?=20(#24458)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration.h | 177 ++++++++++++++++++++++++++++++++--- Marlin/Configuration_adv.h | 2 +- Marlin/src/inc/Version.h | 2 +- buildroot/share/git/mfconfig | 46 +-------- 4 files changed, 168 insertions(+), 59 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index ce2b8fcd6f56..88b92e1837f4 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -35,7 +35,7 @@ * * Advanced settings can be found in Configuration_adv.h */ -#define CONFIGURATION_H_VERSION 02010000 +#define CONFIGURATION_H_VERSION 02010100 //=========================================================================== //============================= Getting Started ============================= @@ -57,15 +57,6 @@ * https://www.thingiverse.com/thing:1278865 */ -//=========================================================================== -//========================== DELTA / SCARA / TPARA ========================== -//=========================================================================== -// -// Download configurations from the link above and customize for your machine. -// Examples are located in config/examples/delta, .../SCARA, and .../TPARA. -// -//=========================================================================== - // @section info // Author info of this build printed to the host during boot and M115 @@ -865,7 +856,135 @@ #define POLAR_SEGMENTS_PER_SECOND 5 #endif -// Enable for an articulated robot (robot arm). Joints are directly mapped to axes (no kinematics). +// Enable for DELTA kinematics and configure below +//#define DELTA +#if ENABLED(DELTA) + + // Make delta curves from many straight lines (linear interpolation). + // This is a trade-off between visible corners (not enough segments) + // and processor overload (too many expensive sqrt calls). + #define DELTA_SEGMENTS_PER_SECOND 200 + + // After homing move down to a height where XY movement is unconstrained + //#define DELTA_HOME_TO_SAFE_ZONE + + // Delta calibration menu + // uncomment to add three points calibration menu option. + // See http://minow.blogspot.com/index.html#4918805519571907051 + //#define DELTA_CALIBRATION_MENU + + // uncomment to add G33 Delta Auto-Calibration (Enable EEPROM_SETTINGS to store results) + //#define DELTA_AUTO_CALIBRATION + + // NOTE NB all values for DELTA_* values MUST be floating point, so always have a decimal point in them + + #if ENABLED(DELTA_AUTO_CALIBRATION) + // set the default number of probe points : n*n (1 -> 7) + #define DELTA_CALIBRATION_DEFAULT_POINTS 4 + #endif + + #if EITHER(DELTA_AUTO_CALIBRATION, DELTA_CALIBRATION_MENU) + // Set the steprate for papertest probing + #define PROBE_MANUALLY_STEP 0.05 // (mm) + #endif + + // Print surface diameter/2 minus unreachable space (avoid collisions with vertical towers). + #define DELTA_PRINTABLE_RADIUS 140.0 // (mm) + + // Maximum reachable area + #define DELTA_MAX_RADIUS 140.0 // (mm) + + // Center-to-center distance of the holes in the diagonal push rods. + #define DELTA_DIAGONAL_ROD 250.0 // (mm) + + // Distance between bed and nozzle Z home position + #define DELTA_HEIGHT 250.00 // (mm) Get this value from G33 auto calibrate + + #define DELTA_ENDSTOP_ADJ { 0.0, 0.0, 0.0 } // Get these values from G33 auto calibrate + + // Horizontal distance bridged by diagonal push rods when effector is centered. + #define DELTA_RADIUS 124.0 // (mm) Get this value from G33 auto calibrate + + // Trim adjustments for individual towers + // tower angle corrections for X and Y tower / rotate XYZ so Z tower angle = 0 + // measured in degrees anticlockwise looking from above the printer + #define DELTA_TOWER_ANGLE_TRIM { 0.0, 0.0, 0.0 } // Get these values from G33 auto calibrate + + // Delta radius and diagonal rod adjustments (mm) + //#define DELTA_RADIUS_TRIM_TOWER { 0.0, 0.0, 0.0 } + //#define DELTA_DIAGONAL_ROD_TRIM_TOWER { 0.0, 0.0, 0.0 } +#endif + +/** + * MORGAN_SCARA was developed by QHARLEY in South Africa in 2012-2013. + * Implemented and slightly reworked by JCERNY in June, 2014. + * + * Mostly Printed SCARA is an open source design by Tyler Williams. See: + * https://www.thingiverse.com/thing:2487048 + * https://www.thingiverse.com/thing:1241491 + */ +//#define MORGAN_SCARA +//#define MP_SCARA +#if EITHER(MORGAN_SCARA, MP_SCARA) + // If movement is choppy try lowering this value + #define SCARA_SEGMENTS_PER_SECOND 200 + + // Length of inner and outer support arms. Measure arm lengths precisely. + #define SCARA_LINKAGE_1 150 // (mm) + #define SCARA_LINKAGE_2 150 // (mm) + + // SCARA tower offset (position of Tower relative to bed zero position) + // This needs to be reasonably accurate as it defines the printbed position in the SCARA space. + #define SCARA_OFFSET_X 100 // (mm) + #define SCARA_OFFSET_Y -56 // (mm) + + #if ENABLED(MORGAN_SCARA) + + //#define DEBUG_SCARA_KINEMATICS + #define SCARA_FEEDRATE_SCALING // Convert XY feedrate from mm/s to degrees/s on the fly + + // Radius around the center where the arm cannot reach + #define MIDDLE_DEAD_ZONE_R 0 // (mm) + + #define THETA_HOMING_OFFSET 0 // Calculated from Calibration Guide and M360 / M114. See http://reprap.harleystudio.co.za/?page_id=1073 + #define PSI_HOMING_OFFSET 0 // Calculated from Calibration Guide and M364 / M114. See http://reprap.harleystudio.co.za/?page_id=1073 + + #elif ENABLED(MP_SCARA) + + #define SCARA_OFFSET_THETA1 12 // degrees + #define SCARA_OFFSET_THETA2 131 // degrees + + #endif + +#endif + +// Enable for TPARA kinematics and configure below +//#define AXEL_TPARA +#if ENABLED(AXEL_TPARA) + #define DEBUG_ROBOT_KINEMATICS + #define ROBOT_SEGMENTS_PER_SECOND 200 + + // Length of inner and outer support arms. Measure arm lengths precisely. + #define ROBOT_LINKAGE_1 120 // (mm) + #define ROBOT_LINKAGE_2 120 // (mm) + + // SCARA tower offset (position of Tower relative to bed zero position) + // This needs to be reasonably accurate as it defines the printbed position in the SCARA space. + #define ROBOT_OFFSET_X 0 // (mm) + #define ROBOT_OFFSET_Y 0 // (mm) + #define ROBOT_OFFSET_Z 0 // (mm) + + #define SCARA_FEEDRATE_SCALING // Convert XY feedrate from mm/s to degrees/s on the fly + + // Radius around the center where the arm cannot reach + #define MIDDLE_DEAD_ZONE_R 0 // (mm) + + // Calculated from Calibration Guide and M360 / M114. See http://reprap.harleystudio.co.za/?page_id=1073 + #define THETA_HOMING_OFFSET 0 + #define PSI_HOMING_OFFSET 0 +#endif + +// Articulated robot (arm). Joints are directly mapped to axes with no kinematics. //#define ARTICULATED_ROBOT_ARM // For a hot wire cutter with parallel horizontal axes (X, I) where the heights of the two wire @@ -1239,9 +1358,37 @@ */ //#define SENSORLESS_PROBING -// -// For Z_PROBE_ALLEN_KEY see the Delta example configurations. -// +/** + * Allen key retractable z-probe as seen on many Kossel delta printers - https://reprap.org/wiki/Kossel#Automatic_bed_leveling_probe + * Deploys by touching z-axis belt. Retracts by pushing the probe down. + */ +//#define Z_PROBE_ALLEN_KEY +#if ENABLED(Z_PROBE_ALLEN_KEY) + // 2 or 3 sets of coordinates for deploying and retracting the spring loaded touch probe on G29, + // if servo actuated touch probe is not defined. Uncomment as appropriate for your printer/probe. + + #define Z_PROBE_ALLEN_KEY_DEPLOY_1 { 30.0, DELTA_PRINTABLE_RADIUS, 100.0 } + #define Z_PROBE_ALLEN_KEY_DEPLOY_1_FEEDRATE XY_PROBE_FEEDRATE + + #define Z_PROBE_ALLEN_KEY_DEPLOY_2 { 0.0, DELTA_PRINTABLE_RADIUS, 100.0 } + #define Z_PROBE_ALLEN_KEY_DEPLOY_2_FEEDRATE (XY_PROBE_FEEDRATE)/10 + + #define Z_PROBE_ALLEN_KEY_DEPLOY_3 { 0.0, (DELTA_PRINTABLE_RADIUS) * 0.75, 100.0 } + #define Z_PROBE_ALLEN_KEY_DEPLOY_3_FEEDRATE XY_PROBE_FEEDRATE + + #define Z_PROBE_ALLEN_KEY_STOW_1 { -64.0, 56.0, 23.0 } // Move the probe into position + #define Z_PROBE_ALLEN_KEY_STOW_1_FEEDRATE XY_PROBE_FEEDRATE + + #define Z_PROBE_ALLEN_KEY_STOW_2 { -64.0, 56.0, 3.0 } // Push it down + #define Z_PROBE_ALLEN_KEY_STOW_2_FEEDRATE (XY_PROBE_FEEDRATE)/10 + + #define Z_PROBE_ALLEN_KEY_STOW_3 { -64.0, 56.0, 50.0 } // Move it up to clear + #define Z_PROBE_ALLEN_KEY_STOW_3_FEEDRATE XY_PROBE_FEEDRATE + + #define Z_PROBE_ALLEN_KEY_STOW_4 { 0.0, 0.0, 50.0 } + #define Z_PROBE_ALLEN_KEY_STOW_4_FEEDRATE XY_PROBE_FEEDRATE + +#endif // Z_PROBE_ALLEN_KEY /** * Nozzle-to-Probe offsets { X, Y, Z } @@ -1816,7 +1963,7 @@ //#define LCD_BED_TRAMMING #if ENABLED(LCD_BED_TRAMMING) - #define BED_TRAMMING_INSET_LFRB { 30, 30, 30, 30 } // (mm) Left, Front, Right, Back insets + #define BED_TRAMMING_INSET_LFRB { 30, 30, 30, 30 } // (mm) Left, Front, Right, Back insets #define BED_TRAMMING_HEIGHT 0.0 // (mm) Z height of nozzle at leveling points #define BED_TRAMMING_Z_HOP 4.0 // (mm) Z height of nozzle between leveling points //#define BED_TRAMMING_INCLUDE_CENTER // Move to the center after the last corner diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index db664477f44c..63c3730364a9 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -30,7 +30,7 @@ * * Basic settings can be found in Configuration.h */ -#define CONFIGURATION_ADV_H_VERSION 02010000 +#define CONFIGURATION_ADV_H_VERSION 02010100 //=========================================================================== //============================= Thermal Settings ============================ diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 4070a801a5d4..7abbeac785b6 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -52,7 +52,7 @@ * to alert users to major changes. */ -#define MARLIN_HEX_VERSION 02010000 +#define MARLIN_HEX_VERSION 02010100 #ifndef REQUIRED_CONFIGURATION_H_VERSION #define REQUIRED_CONFIGURATION_H_VERSION MARLIN_HEX_VERSION #endif diff --git a/buildroot/share/git/mfconfig b/buildroot/share/git/mfconfig index 7092bc822002..b379317d9866 100755 --- a/buildroot/share/git/mfconfig +++ b/buildroot/share/git/mfconfig @@ -110,53 +110,15 @@ if [[ $ACTION == "init" ]]; then ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Commit for comparison" >/dev/null # Init Cartesian/SCARA/TPARA configurations to default - echo "- Initializing Cartesian/SCARA/TPARA configs to default state..." + echo "- Initializing configs to default state..." - find "$CEXA" -name $BC ! -path */delta/* -print0 \ + find "$CEXA" -name $BC -print0 \ | while read -d $'\0' F ; do cp "$CDEF/$BC" "$F" ; done - find "$CEXA" -name $AC ! -path */delta/* -print0 \ + find "$CEXA" -name $AC -print0 \ | while read -d $'\0' F ; do cp "$CDEF/$AC" "$F" ; done # DEBUG: Commit the reset for review - ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Reset Cartesian/SCARA/TPARA configs..." >/dev/null - - # Create base Delta configurations - cp "$CDEF"/* "$CEXA/delta/generic" - - # DEBUG: Commit the reset for review - ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Reset Generic Delta..." >/dev/null - - cp -R "$TEMP/$CEXA/delta/generic"/Conf* "$CEXA/delta/generic" - - # DEBUG: Commit Generic Delta changes for review - ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Apply Generic Delta..." >/dev/null - - # Reset all Delta configs to the generic version - find "$CEXA/delta" -name $BC ! -path */generic/* -print0 \ - | while read -d $'\0' F ; do cp "$CEXA/delta/generic/$BC" "$F" ; done - find "$CEXA/delta" -name $AC ! -path */generic/* -print0 \ - | while read -d $'\0' F ; do cp "$CEXA/delta/generic/$AC" "$F" ; done - - # DEBUG: Commit the Delta reset for review - ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Reset Delta configs..." >/dev/null - - # Reset all SCARA configs to the default cartesian - find "$CEXA/SCARA" -name $BC \ - | while read -d $'\0' F ; do cp "$CDEF/$BC" "$F" ; done - find "$CEXA/SCARA" -name $AC \ - | while read -d $'\0' F ; do cp "$CDEF/$AC" "$F" ; done - - # DEBUG: Commit the SCARA reset for review - ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Reset SCARA..." >/dev/null - - # Reset all TPARA configs to the default cartesian - find "$CEXA/TPARA" -name $BC \ - | while read -d $'\0' F ; do cp "$CDEF/$BC" "$F" ; done - find "$CEXA/TPARA" -name $AC \ - | while read -d $'\0' F ; do cp "$CDEF/$AC" "$F" ; done - - # DEBUG: Commit the TPARA reset for review - ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Reset TPARA..." >/dev/null + ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Reset configs..." >/dev/null # Update the %VERSION% in the README.md file VERS=$( echo $EXPORT | $SED 's/release-//' ) From 6c2ffe9d341f8f61bca8e19b07c3fc6a1d904375 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 6 Jul 2022 19:34:45 -0500 Subject: [PATCH 13/32] =?UTF-8?q?=F0=9F=94=A5=20Remove=20JyersUI=20(#24459?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration.h | 1 - Marlin/Configuration_adv.h | 2 +- Marlin/src/MarlinCore.cpp | 2 - Marlin/src/gcode/bedlevel/abl/G29.cpp | 2 - Marlin/src/gcode/config/M575.cpp | 9 +- Marlin/src/gcode/control/M997.cpp | 3 - Marlin/src/gcode/feature/powerloss/M1000.cpp | 4 - Marlin/src/gcode/lcd/M0_M1.cpp | 4 - Marlin/src/gcode/probe/G30.cpp | 10 +- Marlin/src/gcode/stats/M75-M78.cpp | 16 +- Marlin/src/gcode/temp/M303.cpp | 3 - Marlin/src/inc/Conditionals_LCD.h | 15 +- Marlin/src/inc/Conditionals_post.h | 4 +- Marlin/src/inc/SanityCheck.h | 6 +- Marlin/src/lcd/e3v2/common/dwin_api.cpp | 10 +- Marlin/src/lcd/e3v2/jyersui/README.md | 7 - Marlin/src/lcd/e3v2/jyersui/base64.hpp | 208 - Marlin/src/lcd/e3v2/jyersui/dwin.cpp | 6194 ----------------- Marlin/src/lcd/e3v2/jyersui/dwin.h | 283 - Marlin/src/lcd/e3v2/jyersui/dwin_defines.h | 131 - Marlin/src/lcd/e3v2/jyersui/dwin_lcd.cpp | 93 - Marlin/src/lcd/e3v2/jyersui/dwin_lcd.h | 42 - Marlin/src/lcd/e3v2/jyersui/dwinui.cpp | 340 - Marlin/src/lcd/e3v2/jyersui/dwinui.h | 527 -- Marlin/src/lcd/e3v2/jyersui/endstop_diag.cpp | 111 - Marlin/src/lcd/e3v2/jyersui/endstop_diag.h | 39 - Marlin/src/lcd/e3v2/jyersui/gcode_preview.cpp | 244 - Marlin/src/lcd/e3v2/jyersui/gcode_preview.h | 34 - Marlin/src/lcd/e3v2/jyersui/lockscreen.cpp | 83 - Marlin/src/lcd/e3v2/jyersui/lockscreen.h | 49 - Marlin/src/lcd/e3v2/jyersui/plot.cpp | 86 - Marlin/src/lcd/e3v2/jyersui/plot.h | 41 - Marlin/src/lcd/e3v2/proui/base64.hpp | 6 +- Marlin/src/lcd/e3v2/proui/gcode_preview.cpp | 6 +- Marlin/src/lcd/e3v2/proui/gcode_preview.h | 2 +- Marlin/src/lcd/extui/ui_api.h | 2 +- Marlin/src/lcd/marlinui.cpp | 5 +- Marlin/src/lcd/marlinui.h | 10 +- Marlin/src/module/settings.cpp | 22 - Marlin/src/module/temperature.cpp | 8 - buildroot/tests/STM32F103RE_creality | 5 - ini/features.ini | 1 - 42 files changed, 39 insertions(+), 8631 deletions(-) delete mode 100644 Marlin/src/lcd/e3v2/jyersui/README.md delete mode 100644 Marlin/src/lcd/e3v2/jyersui/base64.hpp delete mode 100644 Marlin/src/lcd/e3v2/jyersui/dwin.cpp delete mode 100644 Marlin/src/lcd/e3v2/jyersui/dwin.h delete mode 100644 Marlin/src/lcd/e3v2/jyersui/dwin_defines.h delete mode 100644 Marlin/src/lcd/e3v2/jyersui/dwin_lcd.cpp delete mode 100644 Marlin/src/lcd/e3v2/jyersui/dwin_lcd.h delete mode 100644 Marlin/src/lcd/e3v2/jyersui/dwinui.cpp delete mode 100644 Marlin/src/lcd/e3v2/jyersui/dwinui.h delete mode 100644 Marlin/src/lcd/e3v2/jyersui/endstop_diag.cpp delete mode 100644 Marlin/src/lcd/e3v2/jyersui/endstop_diag.h delete mode 100644 Marlin/src/lcd/e3v2/jyersui/gcode_preview.cpp delete mode 100644 Marlin/src/lcd/e3v2/jyersui/gcode_preview.h delete mode 100644 Marlin/src/lcd/e3v2/jyersui/lockscreen.cpp delete mode 100644 Marlin/src/lcd/e3v2/jyersui/lockscreen.h delete mode 100644 Marlin/src/lcd/e3v2/jyersui/plot.cpp delete mode 100644 Marlin/src/lcd/e3v2/jyersui/plot.h diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 88b92e1837f4..788bd6407553 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -3064,7 +3064,6 @@ // //#define DWIN_CREALITY_LCD // Creality UI //#define DWIN_LCD_PROUI // Pro UI by MRiscoC -//#define DWIN_CREALITY_LCD_JYERSUI // Jyers UI by Jacob Myers //#define DWIN_MARLINUI_PORTRAIT // MarlinUI (portrait orientation) //#define DWIN_MARLINUI_LANDSCAPE // MarlinUI (landscape orientation) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 63c3730364a9..b4627a9830a0 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1335,7 +1335,7 @@ #endif // HAS_MARLINUI_MENU -#if ANY(HAS_DISPLAY, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) +#if EITHER(HAS_DISPLAY, DWIN_LCD_PROUI) //#define SOUND_MENU_ITEM // Add a mute option to the LCD menu #define SOUND_ON_DEFAULT // Buzzer/speaker default enabled state #endif diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index c1bd973b4a1d..7a835da4979c 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -76,8 +76,6 @@ #include "lcd/e3v2/creality/dwin.h" #elif ENABLED(DWIN_LCD_PROUI) #include "lcd/e3v2/proui/dwin.h" - #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) - #include "lcd/e3v2/jyersui/dwin.h" #endif #endif diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index e8c9c4a1857c..a2c53b5ab253 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -51,8 +51,6 @@ #include "../../../lcd/e3v2/creality/dwin.h" #elif ENABLED(DWIN_LCD_PROUI) #include "../../../lcd/e3v2/proui/dwin.h" -#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) - #include "../../../lcd/e3v2/jyersui/dwin.h" #endif #if HAS_MULTI_HOTEND diff --git a/Marlin/src/gcode/config/M575.cpp b/Marlin/src/gcode/config/M575.cpp index f96bca8a3ee3..2c12428d982a 100644 --- a/Marlin/src/gcode/config/M575.cpp +++ b/Marlin/src/gcode/config/M575.cpp @@ -26,10 +26,6 @@ #include "../gcode.h" -#if ENABLED(DWIN_CREALITY_LCD_JYERSUI) - #include "../../lcd/e3v2/jyersui/dwin.h" -#endif - /** * M575 - Change serial baud rate * @@ -69,10 +65,7 @@ void GcodeSuite::M575() { SERIAL_FLUSH(); - if (set1) { - MYSERIAL1.end(); MYSERIAL1.begin(baud); - TERN_(DWIN_CREALITY_LCD_JYERSUI, eeprom_settings.Baud115k = (baud == 115200)); - } + if (set1) { MYSERIAL1.end(); MYSERIAL1.begin(baud); } #if HAS_MULTI_SERIAL if (set2) { MYSERIAL2.end(); MYSERIAL2.begin(baud); } #ifdef SERIAL_PORT_3 diff --git a/Marlin/src/gcode/control/M997.cpp b/Marlin/src/gcode/control/M997.cpp index 66a0256c44ef..74ed8b0d073e 100644 --- a/Marlin/src/gcode/control/M997.cpp +++ b/Marlin/src/gcode/control/M997.cpp @@ -26,8 +26,6 @@ #if ENABLED(DWIN_LCD_PROUI) #include "../../lcd/e3v2/proui/dwin.h" -#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) - #include "../../lcd/e3v2/jyersui/dwin.h" #endif /** @@ -36,7 +34,6 @@ void GcodeSuite::M997() { TERN_(DWIN_LCD_PROUI, DWIN_RebootScreen()); - TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWIN.DWIN_RebootScreen()); flashFirmware(parser.intval('S')); diff --git a/Marlin/src/gcode/feature/powerloss/M1000.cpp b/Marlin/src/gcode/feature/powerloss/M1000.cpp index 1629a154bce3..5466b6e127d6 100644 --- a/Marlin/src/gcode/feature/powerloss/M1000.cpp +++ b/Marlin/src/gcode/feature/powerloss/M1000.cpp @@ -35,8 +35,6 @@ #include "../../../lcd/e3v2/creality/dwin.h" #elif ENABLED(DWIN_LCD_PROUI) #include "../../../lcd/e3v2/proui/dwin.h" -#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) - #include "../../../lcd/e3v2/jyersui/dwin.h" // Temporary fix until it can be better implemented #endif #define DEBUG_OUT ENABLED(DEBUG_POWER_LOSS_RECOVERY) @@ -71,8 +69,6 @@ void GcodeSuite::M1000() { ui.goto_screen(menu_job_recovery); #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); #elif ENABLED(EXTENSIBLE_UI) ExtUI::onPowerLossResume(); #else diff --git a/Marlin/src/gcode/lcd/M0_M1.cpp b/Marlin/src/gcode/lcd/M0_M1.cpp index b6d2131555c6..af03fcb0b1a1 100644 --- a/Marlin/src/gcode/lcd/M0_M1.cpp +++ b/Marlin/src/gcode/lcd/M0_M1.cpp @@ -38,8 +38,6 @@ #elif ENABLED(DWIN_LCD_PROUI) #include "../../lcd/e3v2/proui/dwin_popup.h" #include "../../lcd/e3v2/proui/dwin.h" -#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) - #include "../../lcd/e3v2/jyersui/dwin.h" #endif #if ENABLED(HOST_PROMPT_SUPPORT) @@ -78,8 +76,6 @@ void GcodeSuite::M0_M1() { DWIN_Popup_Confirm(ICON_BLTouch, parser.string_arg, GET_TEXT_F(MSG_USERWAIT)); else DWIN_Popup_Confirm(ICON_BLTouch, GET_TEXT_F(MSG_STOPPED), GET_TEXT_F(MSG_USERWAIT)); - #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) - CrealityDWIN.Confirm_Handler(UserInput, parser.string_arg == nullptr); #else if (parser.string_arg) { diff --git a/Marlin/src/gcode/probe/G30.cpp b/Marlin/src/gcode/probe/G30.cpp index b22ec6eb7f7f..a16853bdf894 100644 --- a/Marlin/src/gcode/probe/G30.cpp +++ b/Marlin/src/gcode/probe/G30.cpp @@ -33,7 +33,7 @@ #include "../../feature/probe_temp_comp.h" #endif -#if EITHER(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) +#if ENABLED(DWIN_LCD_PROUI) #include "../../lcd/marlinui.h" #endif @@ -53,7 +53,7 @@ void GcodeSuite::G30() { parser.linearval('Y', current_position.y + probe.offset_xy.y) }; if (!probe.can_reach(pos)) { - #if EITHER(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) + #if ENABLED(DWIN_LCD_PROUI) SERIAL_ECHOLNF(GET_EN_TEXT_F(MSG_ZPROBE_OUT)); LCD_MESSAGE(MSG_ZPROBE_OUT); #endif @@ -65,9 +65,7 @@ void GcodeSuite::G30() { remember_feedrate_scaling_off(); - #if EITHER(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) - process_subcommands_now(F("G28O")); - #endif + TERN_(DWIN_LCD_PROUI, process_subcommands_now(F("G28O"))); const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE; @@ -76,7 +74,7 @@ void GcodeSuite::G30() { TERN_(HAS_PTC, ptc.set_enabled(true)); if (!isnan(measured_z)) { SERIAL_ECHOLNPGM("Bed X: ", pos.x, " Y: ", pos.y, " Z: ", measured_z); - #if EITHER(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) + #if ENABLED(DWIN_LCD_PROUI) char msg[31], str_1[6], str_2[6], str_3[6]; sprintf_P(msg, PSTR("X:%s, Y:%s, Z:%s"), dtostrf(pos.x, 1, 1, str_1), diff --git a/Marlin/src/gcode/stats/M75-M78.cpp b/Marlin/src/gcode/stats/M75-M78.cpp index 13a593bc30f1..0ed1e6693013 100644 --- a/Marlin/src/gcode/stats/M75-M78.cpp +++ b/Marlin/src/gcode/stats/M75-M78.cpp @@ -33,23 +33,15 @@ #include "../../lcd/e3v2/proui/dwin.h" #endif -#if ENABLED(DWIN_CREALITY_LCD_JYERSUI) - #include "../../lcd/e3v2/jyersui/dwin.h" -#endif - /** * M75: Start print timer */ void GcodeSuite::M75() { startOrResumeJob(); - TERN_(DWIN_LCD_PROUI, DWIN_Print_Started(false)); - if (!IS_SD_PRINTING()) { - #if ENABLED(DWIN_LCD_PROUI) - DWIN_Print_Header(parser.string_arg && parser.string_arg[0] ? parser.string_arg : GET_TEXT(MSG_HOST_START_PRINT)); - #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) - CrealityDWIN.Update_Print_Filename(parser.string_arg && parser.string_arg[0] ? parser.string_arg : GET_TEXT(MSG_HOST_START_PRINT)); - #endif - } + #if ENABLED(DWIN_LCD_PROUI) + 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 } /** diff --git a/Marlin/src/gcode/temp/M303.cpp b/Marlin/src/gcode/temp/M303.cpp index 2bd05f75373c..ce362984a6ca 100644 --- a/Marlin/src/gcode/temp/M303.cpp +++ b/Marlin/src/gcode/temp/M303.cpp @@ -32,8 +32,6 @@ #include "../../lcd/extui/ui_api.h" #elif ENABLED(DWIN_LCD_PROUI) #include "../../lcd/e3v2/proui/dwin.h" -#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) - #include "../../lcd/e3v2/jyersui/dwin.h" #endif /** @@ -77,7 +75,6 @@ void GcodeSuite::M303() { SERIAL_ECHOLNPGM(STR_PID_BAD_HEATER_ID); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_BAD_EXTRUDER_NUM)); TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_BAD_EXTRUDER_NUM)); - TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWINClass::DWIN_PidTuning(PID_BAD_EXTRUDER_NUM)); return; } diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index bf8d5e122a5e..b8cf66c8c41a 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -477,8 +477,6 @@ // Aliases for LCD features #if EITHER(DWIN_CREALITY_LCD, DWIN_LCD_PROUI) #define HAS_DWIN_E3V2_BASIC 1 -#endif -#if EITHER(HAS_DWIN_E3V2_BASIC, DWIN_CREALITY_LCD_JYERSUI) #define HAS_DWIN_E3V2 1 #endif #if ENABLED(DWIN_LCD_PROUI) @@ -508,7 +506,7 @@ #endif #endif -#if ANY(HAS_WIRED_LCD, EXTENSIBLE_UI, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) +#if ANY(HAS_WIRED_LCD, EXTENSIBLE_UI, DWIN_LCD_PROUI) #define HAS_DISPLAY 1 #endif @@ -528,7 +526,7 @@ #define HAS_MANUAL_MOVE_MENU 1 #endif -#if ANY(HAS_MARLINUI_U8GLIB, EXTENSIBLE_UI, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL, IS_DWIN_MARLINUI, DWIN_CREALITY_LCD_JYERSUI) +#if ANY(HAS_MARLINUI_U8GLIB, EXTENSIBLE_UI, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL, IS_DWIN_MARLINUI) #define CAN_SHOW_REMAINING_TIME 1 #endif @@ -1256,8 +1254,6 @@ #endif #if ANY(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_3POINT) #define HAS_ABL_NOT_UBL 1 -#else - #undef PROBE_MANUALLY #endif #if ANY(AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_UBL, MESH_BED_LEVELING) #define HAS_MESH 1 @@ -1276,11 +1272,14 @@ #if DISABLED(AUTO_BED_LEVELING_UBL) #define PLANNER_LEVELING 1 #endif -#else +#endif +#if !HAS_LEVELING #undef RESTORE_LEVELING_AFTER_G28 #undef ENABLE_LEVELING_AFTER_G28 #undef G29_RETRY_AND_RECOVER - #undef PREHEAT_BEFORE_LEVELING +#endif +#if !HAS_LEVELING || EITHER(MESH_BED_LEVELING, AUTO_BED_LEVELING_UBL) + #undef PROBE_MANUALLY #endif #if ANY(HAS_BED_PROBE, PROBE_MANUALLY, MESH_BED_LEVELING) #define PROBE_SELECTED 1 diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 0f4cf1381a7f..dfccd9b8f5c5 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -3428,7 +3428,7 @@ * Advanced Pause - Filament Change */ #if ENABLED(ADVANCED_PAUSE_FEATURE) - #if ANY(HAS_MARLINUI_MENU, EXTENSIBLE_UI, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) || BOTH(EMERGENCY_PARSER, HOST_PROMPT_SUPPORT) + #if ANY(HAS_MARLINUI_MENU, EXTENSIBLE_UI, DWIN_LCD_PROUI) || BOTH(EMERGENCY_PARSER, HOST_PROMPT_SUPPORT) #define M600_PURGE_MORE_RESUMABLE 1 #endif #ifndef FILAMENT_CHANGE_SLOW_LOAD_LENGTH @@ -3541,7 +3541,7 @@ #ifndef MESH_MAX_Y #define MESH_MAX_Y _MESH_MAX_Y #endif -#elif DISABLED(DWIN_CREALITY_LCD_JYERSUI) +#else #undef MESH_MIN_X #undef MESH_MIN_Y #undef MESH_MAX_X diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 8ef8a3d2d64a..f75a59b9b4c1 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -873,7 +873,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "PROGRESS_MSG_EXPIRE must be greater than or equal to 0." #endif #elif ENABLED(LCD_SET_PROGRESS_MANUALLY) && NONE(HAS_MARLINUI_U8GLIB, HAS_GRAPHICAL_TFT, HAS_MARLINUI_HD44780, EXTENSIBLE_UI, HAS_DWIN_E3V2, IS_DWIN_MARLINUI) - #error "LCD_SET_PROGRESS_MANUALLY requires LCD_PROGRESS_BAR, Character LCD, Graphical LCD, TFT, DWIN_CREALITY_LCD, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI, DWIN_MARLINUI_*, OR EXTENSIBLE_UI." + #error "LCD_SET_PROGRESS_MANUALLY requires LCD_PROGRESS_BAR, Character LCD, Graphical LCD, TFT, DWIN_CREALITY_LCD, DWIN_LCD_PROUI, DWIN_MARLINUI_*, OR EXTENSIBLE_UI." #endif #if ENABLED(USE_M73_REMAINING_TIME) && DISABLED(LCD_SET_PROGRESS_MANUALLY) @@ -2846,7 +2846,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS + COUNT_ENABLED(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON, ANYCUBIC_TFT35) \ + COUNT_ENABLED(DGUS_LCD_UI_ORIGIN, DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_HIPRECY, DGUS_LCD_UI_MKS, DGUS_LCD_UI_RELOADED) \ + COUNT_ENABLED(ENDER2_STOCKDISPLAY, CR10_STOCKDISPLAY) \ - + COUNT_ENABLED(DWIN_CREALITY_LCD, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI, DWIN_MARLINUI_PORTRAIT, DWIN_MARLINUI_LANDSCAPE) \ + + COUNT_ENABLED(DWIN_CREALITY_LCD, DWIN_LCD_PROUI, DWIN_MARLINUI_PORTRAIT, DWIN_MARLINUI_LANDSCAPE) \ + COUNT_ENABLED(FYSETC_MINI_12864_X_X, FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0, FYSETC_GENERIC_12864_1_1) \ + COUNT_ENABLED(LCD_SAINSMART_I2C_1602, LCD_SAINSMART_I2C_2004) \ + COUNT_ENABLED(MKS_12864OLED, MKS_12864OLED_SSD1306) \ @@ -3671,7 +3671,7 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #error "A very large BLOCK_BUFFER_SIZE is not needed and takes longer to drain the buffer on pause / cancel." #endif -#if ENABLED(LED_CONTROL_MENU) && NONE(HAS_MARLINUI_MENU, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) +#if ENABLED(LED_CONTROL_MENU) && NONE(HAS_MARLINUI_MENU, DWIN_LCD_PROUI) #error "LED_CONTROL_MENU requires an LCD controller that implements the menu." #endif diff --git a/Marlin/src/lcd/e3v2/common/dwin_api.cpp b/Marlin/src/lcd/e3v2/common/dwin_api.cpp index 79998219a95e..3f699465a9c8 100644 --- a/Marlin/src/lcd/e3v2/common/dwin_api.cpp +++ b/Marlin/src/lcd/e3v2/common/dwin_api.cpp @@ -234,7 +234,7 @@ void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis, // *string: The string // rlimit: To limit the drawn string length void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const char * const string, uint16_t rlimit/*=0xFFFF*/) { - #if NONE(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) + #if DISABLED(DWIN_LCD_PROUI) DWIN_Draw_Rectangle(1, bColor, x, y, x + (fontWidth(size) * strlen_P(string)), y + fontHeight(size)); #endif constexpr uint8_t widthAdjust = 0; @@ -266,9 +266,7 @@ void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, uint32_t value) { size_t i = 0; - #if DISABLED(DWIN_CREALITY_LCD_JYERSUI) - DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * iNum + 1, y + fontHeight(size)); - #endif + DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * iNum + 1, y + fontHeight(size)); DWIN_Byte(i, 0x14); // Bit 7: bshow // Bit 6: 1 = signed; 0 = unsigned number; @@ -316,9 +314,7 @@ void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_ uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, int32_t value) { //uint8_t *fvalue = (uint8_t*)&value; size_t i = 0; - #if DISABLED(DWIN_CREALITY_LCD_JYERSUI) - DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * (iNum+fNum+1), y + fontHeight(size)); - #endif + DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * (iNum+fNum+1), y + fontHeight(size)); DWIN_Byte(i, 0x14); DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size); DWIN_Word(i, color); diff --git a/Marlin/src/lcd/e3v2/jyersui/README.md b/Marlin/src/lcd/e3v2/jyersui/README.md deleted file mode 100644 index 91f25e2433bf..000000000000 --- a/Marlin/src/lcd/e3v2/jyersui/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# DWIN for Creality Ender 3 v2 - -Marlin's Ender 3 v2 support requires the `DWIN_SET` included with the Ender 3 V2 [example configuration](https://github.com/MarlinFirmware/Configurations/tree/bugfix-2.1.x/config/examples/Creality/Ender-3%20V2). - -## Easy Install - -Copy the `DWIN_SET` folder onto a Micro-SD card and insert the card into the slot on the DWIN screen. Cycle the machine and wait for the screen to go from blue to orange. Turn the machine off and remove the SD card. When you turn on the machine the screen will display a "Creality" loading screen. diff --git a/Marlin/src/lcd/e3v2/jyersui/base64.hpp b/Marlin/src/lcd/e3v2/jyersui/base64.hpp deleted file mode 100644 index 7a933df321b8..000000000000 --- a/Marlin/src/lcd/e3v2/jyersui/base64.hpp +++ /dev/null @@ -1,208 +0,0 @@ -/** - * Base64 encoder/decoder for arduino repo - * Uses common web conventions - '+' for 62, '/' for 63, '=' for padding. - * Note that invalid base64 characters are interpreted as padding. - * Author: Densaugeo - * Maintainer: Densaugeo - * Version: 1.2.1.1 - * Changed unsigned int to uint16_t for use in the professional Ender 3V2/S1 firmware - * Url: https://www.arduino.cc/reference/en/libraries/base64/ - */ - -#ifndef BASE64_H_INCLUDED -#define BASE64_H_INCLUDED - -/* binary_to_base64: - * Description: - * Converts a single byte from a binary value to the corresponding base64 character - * Parameters: - * v - Byte to convert - * Returns: - * ascii code of base64 character. If byte is >= 64, then there is not corresponding base64 character - * and 255 is returned - */ -unsigned char binary_to_base64(unsigned char v); - -/* base64_to_binary: - * Description: - * Converts a single byte from a base64 character to the corresponding binary value - * Parameters: - * c - Base64 character (as ascii code) - * Returns: - * 6-bit binary value - */ -unsigned char base64_to_binary(unsigned char c); - -/* encode_base64_length: - * Description: - * Calculates length of base64 string needed for a given number of binary bytes - * Parameters: - * input_length - Amount of binary data in bytes - * Returns: - * Number of base64 characters needed to encode input_length bytes of binary data - */ -uint16_t encode_base64_length(uint16_t input_length); - -/* decode_base64_length: - * Description: - * Calculates number of bytes of binary data in a base64 string - * Variant that does not use input_length no longer used within library, retained for API compatibility - * Parameters: - * input - Base64-encoded null-terminated string - * input_length (optional) - Number of bytes to read from input pointer - * Returns: - * Number of bytes of binary data in input - */ -uint16_t decode_base64_length(unsigned char input[]); -uint16_t decode_base64_length(unsigned char input[], uint16_t input_length); - -/* encode_base64: - * Description: - * Converts an array of bytes to a base64 null-terminated string - * Parameters: - * input - Pointer to input data - * input_length - Number of bytes to read from input pointer - * output - Pointer to output string. Null terminator will be added automatically - * Returns: - * Length of encoded string in bytes (not including null terminator) - */ -uint16_t encode_base64(unsigned char input[], uint16_t input_length, unsigned char output[]); - -/* decode_base64: - * Description: - * Converts a base64 null-terminated string to an array of bytes - * Parameters: - * input - Pointer to input string - * input_length (optional) - Number of bytes to read from input pointer - * output - Pointer to output array - * Returns: - * Number of bytes in the decoded binary - */ -uint16_t decode_base64(unsigned char input[], unsigned char output[]); -uint16_t decode_base64(unsigned char input[], uint16_t input_length, unsigned char output[]); - -unsigned char binary_to_base64(unsigned char v) { - // Capital letters - 'A' is ascii 65 and base64 0 - if (v < 26) return v + 'A'; - - // Lowercase letters - 'a' is ascii 97 and base64 26 - if (v < 52) return v + 71; - - // Digits - '0' is ascii 48 and base64 52 - if (v < 62) return v - 4; - - // '+' is ascii 43 and base64 62 - if (v == 62) return '+'; - - // '/' is ascii 47 and base64 63 - if (v == 63) return '/'; - - return 64; -} - -unsigned char base64_to_binary(unsigned char c) { - // Capital letters - 'A' is ascii 65 and base64 0 - if ('A' <= c && c <= 'Z') return c - 'A'; - - // Lowercase letters - 'a' is ascii 97 and base64 26 - if ('a' <= c && c <= 'z') return c - 71; - - // Digits - '0' is ascii 48 and base64 52 - if ('0' <= c && c <= '9') return c + 4; - - // '+' is ascii 43 and base64 62 - if (c == '+') return 62; - - // '/' is ascii 47 and base64 63 - if (c == '/') return 63; - - return 255; -} - -uint16_t encode_base64_length(uint16_t input_length) { - return (input_length + 2)/3*4; -} - -uint16_t decode_base64_length(unsigned char input[]) { - return decode_base64_length(input, -1); -} - -uint16_t decode_base64_length(unsigned char input[], uint16_t input_length) { - unsigned char *start = input; - - while (base64_to_binary(input[0]) < 64 && (unsigned char)(input - start) < input_length) { - ++input; - } - - input_length = input - start; - return input_length/4*3 + (input_length % 4 ? input_length % 4 - 1 : 0); -} - -uint16_t encode_base64(unsigned char input[], uint16_t input_length, unsigned char output[]) { - uint16_t full_sets = input_length/3; - - // While there are still full sets of 24 bits... - for (uint16_t i = 0; i < full_sets; ++i) { - output[0] = binary_to_base64( input[0] >> 2); - output[1] = binary_to_base64((input[0] & 0x03) << 4 | input[1] >> 4); - output[2] = binary_to_base64((input[1] & 0x0F) << 2 | input[2] >> 6); - output[3] = binary_to_base64( input[2] & 0x3F); - - input += 3; - output += 4; - } - - switch (input_length % 3) { - case 0: - output[0] = '\0'; - break; - case 1: - output[0] = binary_to_base64( input[0] >> 2); - output[1] = binary_to_base64((input[0] & 0x03) << 4); - output[2] = '='; - output[3] = '='; - output[4] = '\0'; - break; - case 2: - output[0] = binary_to_base64( input[0] >> 2); - output[1] = binary_to_base64((input[0] & 0x03) << 4 | input[1] >> 4); - output[2] = binary_to_base64((input[1] & 0x0F) << 2); - output[3] = '='; - output[4] = '\0'; - break; - } - - return encode_base64_length(input_length); -} - -uint16_t decode_base64(unsigned char input[], unsigned char output[]) { - return decode_base64(input, -1, output); -} - -uint16_t decode_base64(unsigned char input[], uint16_t input_length, unsigned char output[]) { - uint16_t output_length = decode_base64_length(input, input_length); - - // While there are still full sets of 24 bits... - for (uint16_t i = 2; i < output_length; i += 3) { - output[0] = base64_to_binary(input[0]) << 2 | base64_to_binary(input[1]) >> 4; - output[1] = base64_to_binary(input[1]) << 4 | base64_to_binary(input[2]) >> 2; - output[2] = base64_to_binary(input[2]) << 6 | base64_to_binary(input[3]); - - input += 4; - output += 3; - } - - switch (output_length % 3) { - case 1: - output[0] = base64_to_binary(input[0]) << 2 | base64_to_binary(input[1]) >> 4; - break; - case 2: - output[0] = base64_to_binary(input[0]) << 2 | base64_to_binary(input[1]) >> 4; - output[1] = base64_to_binary(input[1]) << 4 | base64_to_binary(input[2]) >> 2; - break; - } - - return output_length; -} - -#endif // BASE64_H_INCLUDED diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp deleted file mode 100644 index e62bb04a43a2..000000000000 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp +++ /dev/null @@ -1,6194 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -/** - * lcd/e3v2/jyersui/dwin.cpp - * JYERSUI Author: Jacob Myers - * - * JYERSUI Enhanced by LCH-77 - * Version: 1.9 - * Date: Jun 16, 2022 - */ - -#include "../../../inc/MarlinConfigPre.h" - -#if ENABLED(DWIN_CREALITY_LCD_JYERSUI) - -#include "dwin_defines.h" -#include "dwin.h" -#include "dwinui.h" - -#include "../../marlinui.h" -#include "../../../MarlinCore.h" -#include "../../../gcode/gcode.h" -#include "../../../module/temperature.h" -#include "../../../module/planner.h" -#include "../../../module/settings.h" -#include "../../../libs/buzzer.h" -#include "../../../inc/Conditionals_post.h" -#include "../common/encoder.h" - -//#define DEBUG_OUT 1 -#include "../../../core/debug_out.h" - -#if ENABLED(ADVANCED_PAUSE_FEATURE) - #include "../../../feature/pause.h" -#endif - -#if ENABLED(FILAMENT_RUNOUT_SENSOR) - #include "../../../feature/runout.h" -#endif - -#if ENABLED(HOST_ACTION_COMMANDS) - #include "../../../feature/host_actions.h" -#endif - -#if ANY(BABYSTEPPING, HAS_BED_PROBE, HAS_WORKSPACE_OFFSET) - #define HAS_ZOFFSET_ITEM 1 -#endif - -#ifndef strcasecmp_P - #define strcasecmp_P(a, b) strcasecmp((a), (b)) -#endif - -#if HAS_LEVELING - #include "../../../feature/bedlevel/bedlevel.h" -#endif - -#ifdef BLTOUCH_HS_MODE - #include "../../../feature/bltouch.h" -#endif - -#if ENABLED(AUTO_BED_LEVELING_UBL) - #include "../../../libs/least_squares_fit.h" - #include "../../../libs/vector_3.h" -#endif - -#if HAS_BED_PROBE - #include "../../../module/probe.h" -#endif - -#if ENABLED(POWER_LOSS_RECOVERY) - #include "../../../feature/powerloss.h" -#endif - -#if HAS_ESDIAG - #include "endstop_diag.h" -#endif - -#if HAS_LOCKSCREEN - #include "lockscreen.h" -#endif - -#if ENABLED(CASE_LIGHT_MENU) - #include "../../../feature/caselight.h" -#endif - -#if ENABLED(LED_CONTROL_MENU) - #include "../../../feature/leds/leds.h" -#endif - -#if HAS_PIDPLOT - #include "plot.h" -#endif -#if HAS_GCODE_PREVIEW - #include "gcode_preview.h" -#endif - -#define MACHINE_SIZE STRINGIFY(X_BED_SIZE) "x" STRINGIFY(Y_BED_SIZE) "x" STRINGIFY(Z_MAX_POS) - -#define MENU_CHAR_LIMIT 24 -#define STATUS_CHAR_LIMIT 30 - -#define MAX_PRINT_SPEED 500 -#define MIN_PRINT_SPEED 10 - -#if HAS_FAN - #define MAX_FAN_SPEED 255 - #define MIN_FAN_SPEED 0 -#endif - -#define MAX_XY_OFFSET 100 - -#if HAS_ZOFFSET_ITEM - #define MAX_Z_OFFSET 9.99 - #if HAS_BED_PROBE - #define MIN_Z_OFFSET -9.99 - #else - #define MIN_Z_OFFSET -1 - #endif -#endif - -#if HAS_HOTEND - #define MAX_FLOW_RATE 200 - #define MIN_FLOW_RATE 10 - - #define MAX_E_TEMP (HEATER_0_MAXTEMP - HOTEND_OVERSHOOT) - #define MIN_E_TEMP 0 -#endif - -#if HAS_HEATED_BED - #define MAX_BED_TEMP BED_MAXTEMP - #define MIN_BED_TEMP 0 -#endif - -#if HAS_JUNCTION_DEVIATION - #define MIN_JD_MM 0.01 - #define MAX_JD_MM 0.3 -#endif - -/** - * Custom menu items with jyersLCD - */ -#if ENABLED(CUSTOM_MENU_CONFIG) - #ifdef CONFIG_MENU_ITEM_5_DESC - #define CUSTOM_MENU_COUNT 5 - #elif defined(CONFIG_MENU_ITEM_4_DESC) - #define CUSTOM_MENU_COUNT 4 - #elif defined(CONFIG_MENU_ITEM_3_DESC) - #define CUSTOM_MENU_COUNT 3 - #elif defined(CONFIG_MENU_ITEM_2_DESC) - #define CUSTOM_MENU_COUNT 2 - #elif defined(CONFIG_MENU_ITEM_1_DESC) - #define CUSTOM_MENU_COUNT 1 - #endif - #if CUSTOM_MENU_COUNT - #define HAS_CUSTOM_MENU 1 - #endif -#endif - -constexpr float default_max_feedrate[] = DEFAULT_MAX_FEEDRATE; -constexpr float default_max_acceleration[] = DEFAULT_MAX_ACCELERATION; -constexpr float default_steps[] = DEFAULT_AXIS_STEPS_PER_UNIT; -#if HAS_CLASSIC_JERK - constexpr float default_max_jerk[] = { DEFAULT_XJERK, DEFAULT_YJERK, DEFAULT_ZJERK, DEFAULT_EJERK }; -#endif - -enum SelectItem : uint8_t { - PAGE_PRINT = 0, - PAGE_PREPARE, - PAGE_CONTROL, - PAGE_INFO_LEVELING, - PAGE_COUNT, - - PRINT_SETUP = 0, - PRINT_PAUSE_RESUME, - PRINT_STOP, - PRINT_COUNT -}; - -eeprom_settings_t eeprom_settings = {0}; -temp_val_t temp_val = {0}; -uint8_t active_menu = MainMenu, last_menu = MainMenu; -uint8_t selection = 0, last_selection = 0, last_pos_selection = 0; -uint8_t scrollpos = 0; -uint8_t process = Main, last_process = Main; -PopupID popup, last_popup; - -void (*funcpointer)() = nullptr; -void *valuepointer = nullptr; -float tempvalue; -float valuemin; -float valuemax; -uint8_t valueunit; -uint8_t valuetype; - -char cmd[MAX_CMD_SIZE + 16], str_1[16], str_2[16], str_3[16]; -char statusmsg[64]; -char filename[LONG_FILENAME_LENGTH]; - -#if HAS_HOSTACTION_MENUS - #define KEY_WIDTH 26 - #define KEY_HEIGHT 30 - #define KEY_INSET 5 - #define KEY_PADDING 3 - #define KEY_Y_START DWIN_HEIGHT - (4 * (KEY_HEIGHT) + 2 * (KEY_INSET + 1)) - - bool keyboard_restrict, reset_keyboard, numeric_keyboard = false; - uint8_t maxstringlen; - char *stringpointer = nullptr; - char action1[9], action2[9], action3[9]; -#endif - -CrealityDWINClass CrealityDWIN; - -#if HAS_MESH - - struct Mesh_Settings { - bool viewer_asymmetric_range = false; - bool viewer_print_value = false; - bool goto_mesh_value = false; - bool drawing_mesh = false; - uint8_t mesh_x = 0; - uint8_t mesh_y = 0; - - #if ENABLED(AUTO_BED_LEVELING_UBL) - - uint8_t tilt_grid = 1; - - void manual_value_update(bool undefined=false) { - sprintf_P(cmd, PSTR("M421 I%i J%i Z%s %s"), mesh_x, mesh_y, dtostrf(current_position.z, 1, 3, str_1), undefined ? "N" : ""); - gcode.process_subcommands_now(cmd); - planner.synchronize(); - } - - bool create_plane_from_mesh() { - struct linear_fit_data lsf_results; - incremental_LSF_reset(&lsf_results); - GRID_LOOP(x, y) { - if (!isnan(bedlevel.z_values[x][y])) { - xy_pos_t rpos = { bedlevel.get_mesh_x(x), bedlevel.get_mesh_y(y) }; - incremental_LSF(&lsf_results, rpos, bedlevel.z_values[x][y]); - } - } - - if (finish_incremental_LSF(&lsf_results)) { - SERIAL_ECHOPGM("Could not complete LSF!"); - return true; - } - - bedlevel.set_all_mesh_points_to_value(0); - - matrix_3x3 rotation = matrix_3x3::create_look_at(vector_3(lsf_results.A, lsf_results.B, 1)); - GRID_LOOP(i, j) { - float mx = bedlevel.get_mesh_x(i), - my = bedlevel.get_mesh_y(j), - mz = bedlevel.z_values[i][j]; - - if (DEBUGGING(LEVELING)) { - DEBUG_ECHOPAIR_F("before rotation = [", mx, 7); - DEBUG_CHAR(','); - DEBUG_ECHO_F(my, 7); - DEBUG_CHAR(','); - DEBUG_ECHO_F(mz, 7); - DEBUG_ECHOPGM("] ---> "); - DEBUG_DELAY(20); - } - - rotation.apply_rotation_xyz(mx, my, mz); - - if (DEBUGGING(LEVELING)) { - DEBUG_ECHOPAIR_F("after rotation = [", mx, 7); - DEBUG_CHAR(','); - DEBUG_ECHO_F(my, 7); - DEBUG_CHAR(','); - DEBUG_ECHO_F(mz, 7); - DEBUG_ECHOLNPGM("]"); - DEBUG_DELAY(20); - } - - bedlevel.z_values[i][j] = mz - lsf_results.D; - } - return false; - } - - #else - - void manual_value_update() { - sprintf_P(cmd, PSTR("G29 I%i J%i Z%s"), mesh_x, mesh_y, dtostrf(current_position.z, 1, 3, str_1)); - gcode.process_subcommands_now(cmd); - planner.synchronize(); - } - - #endif - - void manual_mesh_move(const bool zmove=false) { - if (zmove) { - planner.synchronize(); - current_position.z = goto_mesh_value ? bedlevel.z_values[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES; - planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder); - planner.synchronize(); - } - else { - CrealityDWIN.Popup_Handler(MoveWait); - sprintf_P(cmd, PSTR("G0 F300 Z%s"), dtostrf(Z_CLEARANCE_BETWEEN_PROBES, 1, 3, str_1)); - gcode.process_subcommands_now(cmd); - sprintf_P(cmd, PSTR("G42 F4000 I%i J%i"), mesh_x, mesh_y); - gcode.process_subcommands_now(cmd); - planner.synchronize(); - current_position.z = goto_mesh_value ? bedlevel.z_values[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES; - planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder); - planner.synchronize(); - CrealityDWIN.Redraw_Menu(); - } - } - - float get_max_value() { - float max = __FLT_MIN__; - GRID_LOOP(x, y) { - if (!isnan(bedlevel.z_values[x][y]) && bedlevel.z_values[x][y] > max) - max = bedlevel.z_values[x][y]; - } - return max; - } - - float get_min_value() { - float min = __FLT_MAX__; - GRID_LOOP(x, y) { - if (!isnan(bedlevel.z_values[x][y]) && bedlevel.z_values[x][y] < min) - min = bedlevel.z_values[x][y]; - } - return min; - } - - void Draw_Bed_Mesh(int16_t selected = -1, uint8_t gridline_width = 1, uint16_t padding_x = 8, uint16_t padding_y_top = 40 + 53 - 7) { - drawing_mesh = true; - const uint16_t total_width_px = DWIN_WIDTH - padding_x - padding_x, - cell_width_px = total_width_px / (GRID_MAX_POINTS_X), - cell_height_px = total_width_px / (GRID_MAX_POINTS_Y); - const float v_max = abs(get_max_value()), v_min = abs(get_min_value()), range = _MAX(v_min, v_max); - - // Clear background from previous selection and select new square - DWIN_Draw_Rectangle(1, Def_Background_Color, _MAX(0, padding_x - gridline_width), _MAX(0, padding_y_top - gridline_width), padding_x + total_width_px, padding_y_top + total_width_px); - if (selected >= 0) { - const auto selected_y = selected / (GRID_MAX_POINTS_X); - const auto selected_x = selected - (GRID_MAX_POINTS_X) * selected_y; - const auto start_y_px = padding_y_top + selected_y * cell_height_px; - const auto start_x_px = padding_x + selected_x * cell_width_px; - DWIN_Draw_Rectangle(1, Def_Highlight_Color, _MAX(0, start_x_px - gridline_width), _MAX(0, start_y_px - gridline_width), start_x_px + cell_width_px, start_y_px + cell_height_px); - } - - // Draw value square grid - char buf[8]; - GRID_LOOP(x, y) { - const auto start_x_px = padding_x + x * cell_width_px; - const auto end_x_px = start_x_px + cell_width_px - 1 - gridline_width; - const auto start_y_px = padding_y_top + (GRID_MAX_POINTS_Y - y - 1) * cell_height_px; - const auto end_y_px = start_y_px + cell_height_px - 1 - gridline_width; - DWIN_Draw_Rectangle(1, // RGB565 colors: http://www.barth-dev.de/online/rgb565-color-picker/ - isnan(bedlevel.z_values[x][y]) ? Color_Grey : ( // gray if undefined - (bedlevel.z_values[x][y] < 0 ? - (uint16_t)round(0x1F * -bedlevel.z_values[x][y] / (!viewer_asymmetric_range ? range : v_min)) << 11 : // red if mesh point value is negative - (uint16_t)round(0x3F * bedlevel.z_values[x][y] / (!viewer_asymmetric_range ? range : v_max)) << 5) | // green if mesh point value is positive - _MIN(0x1F, (((uint8_t)abs(bedlevel.z_values[x][y]) / 10) * 4))), // + blue stepping for every mm - start_x_px, start_y_px, end_x_px, end_y_px - ); - - safe_delay(10); - LCD_SERIAL.flushTX(); - - // Draw value text on - if (viewer_print_value) { - int8_t offset_x, offset_y = cell_height_px / 2 - 6; - if (isnan(bedlevel.z_values[x][y])) { // undefined - DWINUI::Draw_String(font6x12, Def_Text_Color, Color_Bg_Blue, start_x_px + cell_width_px / 2 - 5, start_y_px + offset_y, F("X")); - } - else { // has value - if (GRID_MAX_POINTS_X < 10) - sprintf_P(buf, PSTR("%s"), dtostrf(abs(bedlevel.z_values[x][y]), 1, 2, str_1)); - else - sprintf_P(buf, PSTR("%02i"), (uint16_t)(abs(bedlevel.z_values[x][y] - (int16_t)bedlevel.z_values[x][y]) * 100)); - offset_x = cell_width_px / 2 - 3 * (strlen(buf)) - 2; - if (!(GRID_MAX_POINTS_X < 10)) - DWINUI::Draw_String(font6x12, Def_Text_Color, Color_Bg_Blue, start_x_px - 2 + offset_x, start_y_px + offset_y /*+ square / 2 - 6*/, F(".")); - DWINUI::Draw_String(font6x12, Def_Text_Color, Color_Bg_Blue, start_x_px + 1 + offset_x, start_y_px + offset_y /*+ square / 2 - 6*/, buf); - } - safe_delay(10); - LCD_SERIAL.flushTX(); - } - } - } - - void Set_Mesh_Viewer_Status() { // TODO: draw gradient with values as a legend instead - float v_max = abs(get_max_value()), v_min = abs(get_min_value()), range = _MAX(v_min, v_max); - if (v_min > 3e+10F) v_min = 0.0000001; - if (v_max > 3e+10F) v_max = 0.0000001; - if (range > 3e+10F) range = 0.0000001; - char msg[46]; - if (viewer_asymmetric_range) { - dtostrf(-v_min, 1, 3, str_1); - dtostrf( v_max, 1, 3, str_2); - } - else { - dtostrf(-range, 1, 3, str_1); - dtostrf( range, 1, 3, str_2); - } - sprintf_P(msg, PSTR("Red %s..0..%s Green"), str_1, str_2); - CrealityDWIN.Update_Status(msg); - drawing_mesh = false; - } - - }; - Mesh_Settings mesh_conf; - -#endif // HAS_MESH - -/* General Display Functions */ -constexpr const char * const CrealityDWINClass::color_names[11]; -constexpr const char * const CrealityDWINClass::preheat_modes[3]; -constexpr const char * const CrealityDWINClass::zoffset_modes[3]; -#if ENABLED(PREHEAT_BEFORE_LEVELING) - constexpr const char * const CrealityDWINClass::preheat_levmodes[4]; -#endif - -// Clear a part of the screen -// 4=Entire screen -// 3=Title bar and Menu area (default) -// 2=Menu area -// 1=Title bar -void CrealityDWINClass::Clear_Screen(uint8_t e/*=3*/) { - if (e == 1 || e == 3 || e == 4) DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.menu_top_bg, Def_TitleBg_color, false), 0, 0, DWIN_WIDTH, TITLE_HEIGHT); // Clear Title Bar - if (e == 2 || e == 3) DWIN_Draw_Rectangle(1, Def_Background_Color, 0, 31, DWIN_WIDTH, STATUS_Y); // Clear Menu Area - if (e == 4) DWIN_Draw_Rectangle(1, Def_Background_Color, 0, 31, DWIN_WIDTH, DWIN_HEIGHT); // Clear Popup Area -} - -void CrealityDWINClass::Draw_Float(float value, uint8_t row, bool selected/*=false*/, uint8_t minunit/*=10*/) { - const uint8_t digits = (uint8_t)floor(log10(abs(value))) + log10(minunit) + (minunit > 1); - const uint16_t bColor = (selected) ? Def_Selected_Color : Def_Background_Color; - const uint16_t xpos = 240 - (digits * 8); - DWIN_Draw_Rectangle(1, Def_Background_Color, 194, MBASE(row), 234 - (digits * 8), MBASE(row) + 16); - if (isnan(value)) - DWINUI::Draw_String(Def_Text_Color, bColor, xpos - 8, MBASE(row), F(" NaN")); - else { - DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, Def_Text_Color, bColor, digits - log10(minunit) + 1, log10(minunit), xpos, MBASE(row), (value < 0 ? -value : value)); - DWINUI::Draw_String(Def_Text_Color, bColor, xpos - 8, MBASE(row), value < 0 ? F("-") : F(" ")); - } -} - -void CrealityDWINClass::Draw_Option(uint8_t value, const char * const * options, uint8_t row, bool selected/*=false*/, bool color/*=false*/) { - uint16_t bColor = (selected) ? Def_Selected_Color : Def_Background_Color, - tColor = (color) ? GetColor(value, Def_Text_Color, false) : Def_Text_Color; - DWIN_Draw_Rectangle(1, bColor, 202, MBASE(row) + 14, 258, MBASE(row) - 2); - DWINUI::Draw_String(tColor, bColor, 202, MBASE(row) - 1, options[value]); -} - -#if HAS_HOSTACTION_MENUS - - void CrealityDWINClass::Draw_String(char * string, uint8_t row, bool selected/*=false*/, bool below/*=false*/) { - if (!string) string[0] = '\0'; - const uint8_t offset_x = DWIN_WIDTH - strlen(string) * 8 - 20; - const uint8_t offset_y = (below) ? MENU_CHR_H * 3 / 5 : 0; - DWIN_Draw_Rectangle(1, Def_Background_Color, offset_x - 10, MBASE(row) + offset_y - 1, offset_x, MBASE(row) + 16 + offset_y); - DWINUI::Draw_String(Def_Text_Color, (selected) ? Def_Selected_Color : Def_Background_Color, offset_x, MBASE(row) - 1 + offset_y, string); - } - - const uint64_t CrealityDWINClass::Encode_String(const char * string) { - const char table[65] = "-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz"; - uint64_t output = 0; - LOOP_L_N(i, strlen(string)) { - uint8_t upper_bound = 63, lower_bound = 0; - uint8_t midpoint; - LOOP_L_N(x, 6) { - midpoint = (uint8_t)(0.5 * (upper_bound + lower_bound)); - if (string[i] == table[midpoint]) break; - if (string[i] > table[midpoint]) - lower_bound = midpoint; - else - upper_bound = midpoint; - } - output += midpoint * pow(64, i); - } - return output; - } - - void CrealityDWINClass::Decode_String(uint64_t num, char * string) { - const char table[65] = "-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz"; - LOOP_L_N(i, 30) { - string[i] = table[num % 64]; - num /= 64; - if (num == 0) { - string[i + 1] = '\0'; - break; - } - } - } - -#endif // HAS_HOSTACTION_MENUS - -uint16_t CrealityDWINClass::GetColor(uint8_t color, uint16_t original, bool light/*=false*/) { - switch (color) { - case Default: return original; - case White: return (light) ? Color_Light_White : Color_White; - case Green: return (light) ? Color_Light_Green : Color_Green; - case Cyan: return (light) ? Color_Light_Cyan : Color_Cyan; - case Blue: return (light) ? Color_Light_Blue : Color_Blue; - case Magenta: return (light) ? Color_Light_Magenta : Color_Magenta; - case Red: return (light) ? Color_Light_Red : Color_Red; - case Orange: return (light) ? Color_Light_Orange : Color_Orange; - case Yellow: return (light) ? Color_Light_Yellow : Color_Yellow; - case Brown: return (light) ? Color_Light_Brown : Color_Brown; - case Black: return Color_Black; - } - return Color_White; -} - -void CrealityDWINClass::Draw_Title(const char * ctitle) { - DWINUI::Draw_CenteredString((uint8_t)DWIN_FONT_HEAD, GetColor(eeprom_settings.menu_top_txt, Def_TitleTxt_color, false), 5, ctitle); -} -void CrealityDWINClass::Draw_Title(FSTR_P const ftitle) { - DWINUI::Draw_CenteredString((uint8_t)DWIN_FONT_HEAD, GetColor(eeprom_settings.menu_top_txt, Def_TitleTxt_color, false), 5, ftitle); -} - -void _Decorate_Menu_Item(uint8_t row, uint8_t icon, bool more) { - if (icon) DWIN_ICON_Show(ICON, icon, 26, MBASE(row) - 3); //Draw Menu Icon - if (more) DWIN_ICON_Show(ICON, ICON_More, 226, MBASE(row) - 3); // Draw More Arrow - DWIN_Draw_HLine(CrealityDWIN.GetColor(eeprom_settings.menu_split_line, Def_SplitLine_Color, true), 16, MBASE(row) + 33, 240); // Draw Menu Line -} - -void CrealityDWINClass::Draw_Menu_Item(uint8_t row, uint8_t icon/*=0*/, const char * label1, const char * label2, bool more/*=false*/, bool centered/*=false*/) { - const uint8_t label_offset_y = (label1 && label2) ? MENU_CHR_H * 3 / 5 : 0, - label1_offset_x = !centered ? LBLX : LBLX * 4/5 + _MAX(LBLX * 1/5U, (DWIN_WIDTH - LBLX - (label1 ? strlen(label1) : 0) * MENU_CHR_W) / 2), - label2_offset_x = !centered ? LBLX : LBLX * 4/5 + _MAX(LBLX * 1/5U, (DWIN_WIDTH - LBLX - (label2 ? strlen(label2) : 0) * MENU_CHR_W) / 2); - if (label1) DWINUI::Draw_String(label1_offset_x, MBASE(row) - 1 - label_offset_y, label1); // Draw Label - if (label2) DWINUI::Draw_String(label2_offset_x, MBASE(row) - 1 + label_offset_y, label2); // Draw Label - _Decorate_Menu_Item(row, icon, more); -} - -void CrealityDWINClass::Draw_Menu_Item(uint8_t row, uint8_t icon/*=0*/, FSTR_P const flabel1, FSTR_P const flabel2, bool more/*=false*/, bool centered/*=false*/) { - const uint8_t label_offset_y = (flabel1 && flabel2) ? MENU_CHR_H * 3 / 5 : 0, - label1_offset_x = !centered ? LBLX : LBLX * 4/5 + _MAX(LBLX * 1/5U, (DWIN_WIDTH - LBLX - (flabel1 ? strlen_P(FTOP(flabel1)) : 0) * MENU_CHR_W) / 2), - label2_offset_x = !centered ? LBLX : LBLX * 4/5 + _MAX(LBLX * 1/5U, (DWIN_WIDTH - LBLX - (flabel2 ? strlen_P(FTOP(flabel2)) : 0) * MENU_CHR_W) / 2); - if (flabel1) DWINUI::Draw_String(label1_offset_x, MBASE(row) - 1 - label_offset_y, flabel1); // Draw Label - if (flabel2) DWINUI::Draw_String(label2_offset_x, MBASE(row) - 1 + label_offset_y, flabel2); // Draw Label - _Decorate_Menu_Item(row, icon, more); -} - -void CrealityDWINClass::Draw_Checkbox(uint8_t row, bool value) { - #if ENABLED(DWIN_CREALITY_LCD_CUSTOM_ICONS) // Draw appropriate checkbox icon - DWIN_ICON_Show(ICON, (value ? ICON_Checkbox_T : ICON_Checkbox_F), 226, MBASE(row) - 3); - #else // Draw a basic checkbox using rectangles and lines - DWIN_Draw_Rectangle(1, Def_Background_Color, 226, MBASE(row) - 3, 226 + 20, MBASE(row) - 3 + 20); - DWIN_Draw_Rectangle(0, Def_Text_Color, 226, MBASE(row) - 3, 226 + 20, MBASE(row) - 3 + 20); - if (value) { - DWIN_Draw_Line(Check_Color, 227, MBASE(row) - 3 + 11, 226 + 8, MBASE(row) - 3 + 17); - DWIN_Draw_Line(Check_Color, 227 + 8, MBASE(row) - 3 + 17, 226 + 19, MBASE(row) - 3 + 1); - DWIN_Draw_Line(Check_Color, 227, MBASE(row) - 3 + 12, 226 + 8, MBASE(row) - 3 + 18); - DWIN_Draw_Line(Check_Color, 227 + 8, MBASE(row) - 3 + 18, 226 + 19, MBASE(row) - 3 + 2); - DWIN_Draw_Line(Check_Color, 227, MBASE(row) - 3 + 13, 226 + 8, MBASE(row) - 3 + 19); - DWIN_Draw_Line(Check_Color, 227 + 8, MBASE(row) - 3 + 19, 226 + 19, MBASE(row) - 3 + 3); - } - #endif -} - -void CrealityDWINClass::Draw_Menu(uint8_t menu, uint8_t select/*=0*/, uint8_t scroll/*=0*/) { - if (active_menu != menu) { - last_menu = active_menu; - if (process == Menu) last_selection = selection; - } - selection = _MIN(select, Get_Menu_Size(menu)); - scrollpos = scroll; - if (selection - scrollpos > MROWS) - scrollpos = selection - MROWS; - process = Menu; - active_menu = menu; - Clear_Screen(); - Draw_Title(Get_Menu_Title(menu)); - LOOP_L_N(i, TROWS) Menu_Item_Handler(menu, i + scrollpos); - DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Def_Cursor_color), 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); -} - -void CrealityDWINClass::Redraw_Menu(bool lastprocess/*=true*/, bool lastselection/*=false*/, bool lastmenu/*=false*/) { - switch ((lastprocess) ? last_process : process) { - case Menu: - Draw_Menu((lastmenu) ? last_menu : active_menu, (lastselection) ? last_selection : selection, (lastmenu) ? 0 : scrollpos); - break; - case Main: Draw_Main_Menu((lastselection) ? last_selection : selection); break; - case Print: Draw_Print_Screen(); break; - case File: Draw_SD_List(); break; - default: break; - } -} - -void CrealityDWINClass::Redraw_Screen() { - if (printingIsActive()) Draw_Print_Screen(); - else Redraw_Menu(false); - Draw_Status_Area(true); - Update_Status_Bar(true); -} - -/* Primary Menus and Screen Elements */ - -void CrealityDWINClass::Main_Menu_Icons() { - - if (selection == 0) { - DWINUI::DRAW_IconWB(ICON, ICON_Print_1, 17, 110); - DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Def_Highlight_Color), 17, 110, 126, 209); - } - else - DWINUI::DRAW_IconWB(ICON, ICON_Print_0, 17, 110); - - DWINUI::Draw_String(52, 180, GET_TEXT_F(MSG_BUTTON_PRINT)); - - if (selection == 1) { - DWINUI::DRAW_IconWB(ICON, ICON_Prepare_1, 145, 110); - DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Def_Highlight_Color), 145, 110, 254, 209); - } - else - DWINUI::DRAW_IconWB(ICON, ICON_Prepare_0, 145, 110); - - DWINUI::Draw_String(170, 180, GET_TEXT_F(MSG_PREPARE)); - - if (selection == 2) { - DWINUI::DRAW_IconWB(ICON, ICON_Control_1, 17, 226); - DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Def_Highlight_Color), 17, 226, 126, 325); - } - else - DWINUI::DRAW_IconWB(ICON, ICON_Control_0, 17, 226); - - DWINUI::Draw_String(43, 297, GET_TEXT_F(MSG_CONTROL)); - - #if HAS_ABL_OR_UBL - - if (selection == 3) { - DWINUI::DRAW_IconWB(ICON, ICON_Leveling_1, 145, 226); - DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Def_Highlight_Color), 145, 226, 254, 325); - } - else - DWINUI::DRAW_IconWB(ICON, ICON_Leveling_0, 145, 226); - - DWINUI::Draw_String(179, 297, GET_TEXT_F(MSG_BUTTON_LEVEL)); - - #else - - if (selection == 3) { - DWINUI::DRAW_IconWB(ICON, ICON_Info_1, 145, 226); - DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Def_Highlight_Color), 145, 226, 254, 325); - } - else - DWINUI::DRAW_IconWB(ICON, ICON_Info_0, 145, 226); - - DWINUI::Draw_String(181, 297, GET_TEXT_F(MSG_BUTTON_INFO)); - - #endif -} - -void CrealityDWINClass::Draw_Main_Menu(uint8_t select/*=0*/) { - process = Main; - active_menu = MainMenu; - selection = select; - Clear_Screen(); - Draw_Title(Get_Menu_Title(MainMenu)); - SERIAL_ECHOPGM("\nDWIN handshake "); - DWIN_ICON_Show(ICON, ICON_LOGO, 71, 62); - Main_Menu_Icons(); -} - -void CrealityDWINClass::Print_Screen_Icons() { - if (selection == 0) { - DWINUI::DRAW_IconWB(ICON, ICON_Setup_1, 8, 252); - DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Def_Highlight_Color), 8, 252, 87, 351); - } - else - DWINUI::DRAW_IconWB(ICON, ICON_Setup_0, 8, 252); - - DWINUI::Draw_String(30, 322, GET_TEXT_F(MSG_TUNE)); - - if (selection == 2) { - DWINUI::DRAW_IconWB(ICON, ICON_Stop_1, 184, 252); - DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Def_Highlight_Color), 184, 252, 263, 351); - } - else - DWINUI::DRAW_IconWB(ICON, ICON_Stop_0, 184, 252); - - DWINUI::Draw_String(205, 322, GET_TEXT_F(MSG_BUTTON_STOP)); - - if (temp_val.paused) { - if (selection == 1) { - DWINUI::DRAW_IconWB(ICON, ICON_Continue_1, 96, 252); - DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Def_Highlight_Color), 96, 252, 175, 351); - } - else - DWINUI::DRAW_IconWB(ICON, ICON_Continue_0, 96, 252); - - DWINUI::Draw_String(114, 322, GET_TEXT_F(MSG_BUTTON_RESUME)); - } - else { - if (selection == 1) { - DWINUI::DRAW_IconWB(ICON, ICON_Pause_1, 96, 252); - DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Def_Highlight_Color), 96, 252, 175, 351); - } - else - DWINUI::DRAW_IconWB(ICON, ICON_Pause_0, 96, 252); - - DWINUI::Draw_String(114, 322, GET_TEXT_F(MSG_BUTTON_PAUSE)); - } -} - -void CrealityDWINClass::Draw_Print_Screen() { - process = Print; - selection = 0; - Clear_Screen(); - DWIN_Draw_Rectangle(1, Def_Background_Color, 8, 352, DWIN_WIDTH - 8, 376); - Draw_Title(GET_TEXT(MSG_PRINTING)); - Print_Screen_Icons(); - DWIN_ICON_Show(ICON, ICON_PrintTime, 14, 171); - DWIN_ICON_Show(ICON, ICON_RemainTime, 147, 169); - DWINUI::Draw_String(Def_PercentTxt_Color, 41, 163, GET_TEXT_F(MSG_INFO_PRINT_TIME)); - DWINUI::Draw_String(Def_PercentTxt_Color, 176, 163, GET_TEXT_F(MSG_REMAINING_TIME)); - Update_Status_Bar(true); - Draw_Print_ProgressBar(); - Draw_Print_ProgressElapsed(); - TERN_(USE_M73_REMAINING_TIME, Draw_Print_ProgressRemain()); - Draw_Print_Filename(true); -} - -void CrealityDWINClass::Draw_Print_Filename(const bool reset/*=false*/) { - static uint8_t namescrl = 0; - if (reset) namescrl = 0; - if (process == Print) { - size_t len = strlen(filename); - int8_t pos = len; - if (pos > STATUS_CHAR_LIMIT) { - pos -= namescrl; - len = _MIN((size_t)pos, (size_t)STATUS_CHAR_LIMIT); - char dispname[len + 1]; - if (pos >= 0) { - LOOP_L_N(i, len) dispname[i] = filename[i + namescrl]; - } - else { - LOOP_L_N(i, STATUS_CHAR_LIMIT + pos) dispname[i] = ' '; - LOOP_S_L_N(i, STATUS_CHAR_LIMIT + pos, STATUS_CHAR_LIMIT) dispname[i] = filename[i - (STATUS_CHAR_LIMIT + pos)]; - } - dispname[len] = '\0'; - DWIN_Draw_Rectangle(1, Def_Background_Color, 8, 50, DWIN_WIDTH - 8, 80); - const int8_t npos = (DWIN_WIDTH - STATUS_CHAR_LIMIT * MENU_CHR_W) / 2; - DWINUI::Draw_String(npos, 60, dispname); - if (-pos >= STATUS_CHAR_LIMIT) namescrl = 0; - namescrl++; - } - else { - DWIN_Draw_Rectangle(1, Def_Background_Color, 8, 50, DWIN_WIDTH - 8, 80); - const int8_t npos = (DWIN_WIDTH - strlen(filename) * MENU_CHR_W) / 2; - DWINUI::Draw_String(npos, 60, filename); - } - } -} - -void CrealityDWINClass::Draw_Print_ProgressBar() { - uint8_t printpercent = temp_val.sdprint ? card.percentDone() : (ui._get_progress() / 100); - DWINUI::DRAW_IconWB(ICON, ICON_Bar, 15, 93); - DWIN_Draw_Rectangle(1, Def_Barfill_Color, 16 + printpercent * 240 / 100, 93, 256, 113); - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_percent, Def_PercentTxt_Color), Def_Background_Color, 3, 109, 133, printpercent); - DWINUI::Draw_String(GetColor(eeprom_settings.progress_percent, Def_PercentTxt_Color), Def_Background_Color, 134, 133, F("%")); -} - -#if ENABLED(USE_M73_REMAINING_TIME) - - void CrealityDWINClass::Draw_Print_ProgressRemain() { - uint16_t remainingtime = ui.get_remaining_time(); - DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Def_PercentTxt_Color), Def_Background_Color, 2, 176, 187, remainingtime / 3600); - DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Def_PercentTxt_Color), Def_Background_Color, 2, 201, 187, (remainingtime % 3600) / 60); - if (eeprom_settings.time_format_textual) { - DWINUI::Draw_String(GetColor(eeprom_settings.progress_time, Def_PercentTxt_Color), Def_Background_Color, 193, 187, F("h")); - DWINUI::Draw_String(GetColor(eeprom_settings.progress_time, Def_PercentTxt_Color), Def_Background_Color, 217, 187, F("m")); - } - else - DWINUI::Draw_String(GetColor(eeprom_settings.progress_time, Def_PercentTxt_Color), Def_Background_Color, 193, 187, F(":")); - } - -#endif - -void CrealityDWINClass::Draw_Print_ProgressElapsed() { - duration_t elapsed = print_job_timer.duration(); - DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Def_PercentTxt_Color), Def_Background_Color, 2, 42, 187, elapsed.value / 3600); - DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Def_PercentTxt_Color), Def_Background_Color, 2, 67, 187, (elapsed.value % 3600) / 60); - if (eeprom_settings.time_format_textual) { - DWINUI::Draw_String(GetColor(eeprom_settings.progress_time, Def_PercentTxt_Color), Def_Background_Color, 59, 187, F("h")); - DWINUI::Draw_String(GetColor(eeprom_settings.progress_time, Def_PercentTxt_Color), Def_Background_Color, 83, 187, F("m")); - } - else - DWINUI::Draw_String(GetColor(eeprom_settings.progress_time, Def_PercentTxt_Color), Def_Background_Color, 59, 187, F(":")); -} - -void CrealityDWINClass::Draw_PrintDone_confirm() { - process = Confirm; - popup = Complete; - if (TERN0(HAS_GCODE_PREVIEW, Preview_Valid())) { - Clear_Screen(); - Draw_Title(GET_TEXT(MSG_PRINT_DONE)); - DWIN_ICON_Show(0, 0, 1, 21, 100, 0x00); - DWINUI::Draw_Button(BTN_Continue, 87, 300); - } - else { - Draw_Print_Screen(); - DWIN_Draw_Rectangle(1, Def_Background_Color, 8, 252, 263, 351); - DWINUI::Draw_Button(BTN_Continue, 87, 283); - DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Def_Highlight_Color), 86, 282, 187, 321); - DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Def_Highlight_Color), 85, 281, 188, 322); - } -} - -void CrealityDWINClass::Draw_SD_Item(uint8_t item, uint8_t row) { - if (item == 0) - Draw_Menu_Item(0, ICON_Back, card.flag.workDirIsRoot ? GET_TEXT_F(MSG_BACK) : F("..")); - else { - card.getfilename_sorted(SD_ORDER(item - 1, card.get_num_Files())); - char * const filename = card.longest_filename(); - size_t max = MENU_CHAR_LIMIT; - size_t pos = strlen(filename), len = pos; - if (!card.flag.filenameIsDir) - while (pos && filename[pos] != '.') pos--; - len = pos; - NOMORE(len, max); - char name[len + 1]; - memcpy(name, filename, len); - if (pos > max) LOOP_S_L_N(i, len - 3, len) name[i] = '.'; - name[len] = '\0'; - Draw_Menu_Item(row, card.flag.filenameIsDir ? ICON_More : ICON_File, name); - } -} - -void CrealityDWINClass::Draw_SD_List(bool removed/*=false*/) { - Clear_Screen(); - Draw_Title("Select File"); - selection = 0; - scrollpos = 0; - process = File; - if (card.isMounted() && !removed) { - LOOP_L_N(i, _MIN(card.get_num_Files() + 1, TROWS)) - Draw_SD_Item(i, i); - } - else { - Draw_Menu_Item(0, ICON_Back, GET_TEXT_F(MSG_BACK)); - DWIN_Draw_Rectangle(1, Def_AlertBg_Color, 10, MBASE(3) - 10, DWIN_WIDTH - 10, MBASE(4)); - DWINUI::Draw_String(font16x32, Def_AlertTxt_Color, Def_AlertBg_Color, ((DWIN_WIDTH) - 8 * 16) / 2, MBASE(3), GET_TEXT_F(MSG_NO_MEDIA)); - } - DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Def_Cursor_color), 0, MBASE(0) - 18, 14, MBASE(0) + 33); -} - -void CrealityDWINClass::Draw_Status_Area(bool icons/*=false*/) { - - if (icons) DWIN_Draw_Rectangle(1, Def_Background_Color, 0, STATUS_Y, DWIN_WIDTH, DWIN_HEIGHT - 1); - - #if HAS_HOTEND - static float hotend = -1; - static int16_t hotendtarget = -1, flow = -1; - if (icons) { - hotend = -1; - hotendtarget = -1; - DWIN_ICON_Show(ICON, ICON_HotendTemp, 10, 383); - DWINUI::Draw_String(DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), Def_Background_Color, 25 + 3 * STAT_CHR_W + 5, 384, F("/")); - } - if (thermalManager.temp_hotend[0].celsius != hotend) { - hotend = thermalManager.temp_hotend[0].celsius; - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), Def_Background_Color, 3, 28, 384, thermalManager.temp_hotend[0].celsius); - DWIN_Draw_DegreeSymbol(GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), 25 + 3 * STAT_CHR_W + 5, 386); - } - if (thermalManager.temp_hotend[0].target != hotendtarget) { - hotendtarget = thermalManager.temp_hotend[0].target; - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), Def_Background_Color, 3, 25 + 4 * STAT_CHR_W + 6, 384, thermalManager.temp_hotend[0].target); - DWIN_Draw_DegreeSymbol(GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), 25 + 4 * STAT_CHR_W + 39, 386); - } - if (icons) { - flow = -1; - DWIN_ICON_Show(ICON, ICON_StepE, 112, 417); - DWINUI::Draw_String(DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), Def_Background_Color, 116 + 5 * STAT_CHR_W + 2, 417, F("%")); - } - if (planner.flow_percentage[0] != flow) { - flow = planner.flow_percentage[0]; - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), Def_Background_Color, 3, 116 + 2 * STAT_CHR_W, 417, planner.flow_percentage[0]); - } - #endif - - #if HAS_HEATED_BED - static float bed = -1; - static int16_t bedtarget = -1; - if (icons) { - bed = -1; - bedtarget = -1; - DWIN_ICON_Show(ICON, ICON_BedTemp, 10, 416); - DWINUI::Draw_String(DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), Def_Background_Color, 25 + 3 * STAT_CHR_W + 5, 417, F("/")); - } - if (thermalManager.temp_bed.celsius != bed) { - bed = thermalManager.temp_bed.celsius; - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), Def_Background_Color, 3, 28, 417, thermalManager.temp_bed.celsius); - DWIN_Draw_DegreeSymbol(GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), 25 + 3 * STAT_CHR_W + 5, 419); - } - if (thermalManager.temp_bed.target != bedtarget) { - bedtarget = thermalManager.temp_bed.target; - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), Def_Background_Color, 3, 25 + 4 * STAT_CHR_W + 6, 417, thermalManager.temp_bed.target); - DWIN_Draw_DegreeSymbol(GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), 25 + 4 * STAT_CHR_W + 39, 419); - } - #endif - - #if HAS_FAN - static uint8_t fan = -1; - if (icons) { - fan = -1; - DWIN_ICON_Show(ICON, ICON_FanSpeed, 187, 383); - } - if (thermalManager.fan_speed[0] != fan) { - fan = thermalManager.fan_speed[0]; - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), Def_Background_Color, 3, 195 + 2 * STAT_CHR_W, 384, thermalManager.fan_speed[0]); - } - #endif - - #if HAS_ZOFFSET_ITEM - static float offset = -1; - - #if HAS_MESH - static bool _leveling_active = false, - _printing_leveling_active = false; - if (printingIsActive()) { - _printing_leveling_active = ((planner.leveling_active && planner.leveling_active_at_z(current_position.z)) || _printing_leveling_active ); - if ((_printing_leveling_active = (planner.leveling_active && planner.leveling_active_at_z(current_position.z)) && ui.get_blink())) - DWIN_Draw_Rectangle(1, Def_SplitLine_Color, 186, 415, 205, 436); - else - DWIN_Draw_Rectangle(1, Def_Background_Color, 186, 415, 205, 436); - } - else { - _leveling_active = (planner.leveling_active || _leveling_active); - if ((_leveling_active = planner.leveling_active && ui.get_blink())) - DWIN_Draw_Rectangle(1, Def_SplitLine_Color, 186, 415, 205, 436); - else - DWIN_Draw_Rectangle(1, Def_Background_Color, 186, 415, 205, 436); - } - DWIN_ICON_Show(ICON, ICON_Zoffset, 187, 416); - #else - if (icons) DWIN_ICON_Show(ICON, ICON_Zoffset, 187, 416); - #endif - if (temp_val.zoffsetvalue != offset || icons) { - offset = temp_val.zoffsetvalue; - DWINUI::Draw_Signed_Float(DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Def_Indicator_Color),Def_Background_Color, 1, 2, 202, 417, temp_val.zoffsetvalue); - } - #endif - - static int16_t feedrate = -1; - if (icons) { - feedrate = -1; - DWIN_ICON_Show(ICON, ICON_Speed, 113, 383); - DWINUI::Draw_String(DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), Def_Background_Color, 116 + 5 * STAT_CHR_W + 2, 384, F("%")); - } - if (feedrate_percentage != feedrate) { - feedrate = feedrate_percentage; - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Def_Indicator_Color), Def_Background_Color, 3, 116 + 2 * STAT_CHR_W, 384, feedrate_percentage); - } - - static float x = -1, y = -1, z = -1; - static bool update_x = false, update_y = false, update_z = false; - update_x = (current_position.x != x || axis_should_home(X_AXIS) || update_x); - update_y = (current_position.y != y || axis_should_home(Y_AXIS) || update_y); - update_z = (current_position.z != z || axis_should_home(Z_AXIS) || update_z); - if (icons) { - x = y = z = -1; - DWIN_Draw_Line(GetColor(eeprom_settings.coordinates_split_line, Def_SplitLine_Color, true), 16, 450, 256, 450); - DWIN_ICON_Show(ICON, ICON_MaxSpeedX, 10, 456); - DWIN_ICON_Show(ICON, ICON_MaxSpeedY, 95, 456); - DWIN_ICON_Show(ICON, ICON_MaxSpeedZ, 180, 456); - } - if (update_x) { - x = current_position.x; - if ((update_x = axis_should_home(X_AXIS) && ui.get_blink())) - DWINUI::Draw_String(GetColor(eeprom_settings.coordinates_text, Def_Coordinate_Color), Def_Background_Color, 39, 459, F(" -?- ")); - else - DWINUI::Draw_Signed_Float(DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Def_Coordinate_Color), Def_Background_Color, 3, 1, 31, 459, current_position.x); - } - if (update_y) { - y = current_position.y; - if ((update_y = axis_should_home(Y_AXIS) && ui.get_blink())) - DWINUI::Draw_String(GetColor(eeprom_settings.coordinates_text, Def_Coordinate_Color), Def_Background_Color, 124, 459, F(" -?- ")); - else - DWINUI::Draw_Signed_Float(DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Def_Coordinate_Color), Def_Background_Color, 3, 1, 116, 459, current_position.y); - } - if (update_z) { - z = current_position.z; - if ((update_z = axis_should_home(Z_AXIS) && ui.get_blink())) - DWINUI::Draw_String(GetColor(eeprom_settings.coordinates_text, Def_Coordinate_Color), Def_Background_Color, 205, 459, F(" -?- ")); - else - DWINUI::Draw_Signed_Float(DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Def_Coordinate_Color), Def_Background_Color, 3, 2, 197, 459, current_position.z); - } - DWIN_UpdateLCD(); -} - -void CrealityDWINClass::Draw_Popup(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, uint8_t mode, uint8_t icon/*=0*/) { - if (process != Confirm && process != Popup && process != Wait && process != Cancel) last_process = process; - if ((process == Menu || process == Wait) && mode == Popup) last_selection = selection; - process = mode; - if (popup != PrintConfirm) { - Clear_Screen(); - DWIN_Draw_Rectangle(0, Def_Highlight_Color, 13, 59, 259, 346); - DWIN_Draw_Rectangle(1, Def_PopupBg_color, 14, 60, 258, 345); - } - else DWIN_Draw_Rectangle(1, Def_Background_Color, 0, 0, DWIN_WIDTH, STATUS_Y - 1); - const uint8_t ypos = (mode == Popup || mode == Confirm) ? 150 : (mode == Cancel) ? 200 : 230; - if (icon > 0) DWIN_ICON_Show(ICON, icon, 101, 105); - if (line1) DWINUI::Draw_String(Def_PopupTxt_Color, (272 - 8 * strlen_P(FTOP(line1))) / 2, ypos, line1); - if (line2) DWINUI::Draw_String(Def_PopupTxt_Color, (272 - 8 * strlen_P(FTOP(line2))) / 2, ypos + 30, line2); - if (line3) DWINUI::Draw_String(Def_PopupTxt_Color, (272 - 8 * strlen_P(FTOP(line3))) / 2, ypos + 60, line3); - if (mode == Popup) { - selection = 0; - DWINUI::Draw_Button(BTN_Confirm, 26, 280); - DWINUI::Draw_Button(BTN_Cancel, 146, 280); - Popup_Select(); - } - else if (mode == Confirm) DWINUI::Draw_Button(BTN_Continue, 87, 280); - else if (mode == Cancel) DWINUI::Draw_Button(BTN_Cancel, 87, 280); -} - -void MarlinUI::kill_screen(FSTR_P const error, FSTR_P const) { - CrealityDWIN.Draw_Popup(GET_TEXT_F(MSG_KILLED), error, GET_TEXT_F(MSG_SWITCH_PS_OFF), Wait, ICON_BLTouch); -} - -void CrealityDWINClass::Popup_Select() { - const uint16_t c1 = (selection == 0) ? GetColor(eeprom_settings.highlight_box, Def_Highlight_Color) : Def_Background_Color, - c2 = (selection == 0) ? Def_Background_Color : GetColor(eeprom_settings.highlight_box, Def_Highlight_Color); - DWIN_Draw_Rectangle(0, c1, 25, 279, 126, 318); - DWIN_Draw_Rectangle(0, c1, 24, 278, 127, 319); - DWIN_Draw_Rectangle(0, c2, 145, 279, 246, 318); - DWIN_Draw_Rectangle(0, c2, 144, 278, 247, 319); -} - -void CrealityDWINClass::Update_Status_Bar(bool refresh/*=false*/) { - static bool new_msg; - static uint8_t msgscrl = 0; - static char lastmsg[128]; - if (strcmp(lastmsg, statusmsg) != 0 || refresh) { - strcpy(lastmsg, statusmsg); - msgscrl = 0; - new_msg = true; - } - size_t len = strlen(statusmsg); - int8_t pos = len; - if (pos > STATUS_CHAR_LIMIT) { - pos -= msgscrl; - len = _MIN((size_t)pos, (size_t)STATUS_CHAR_LIMIT); - char dispmsg[len + 1]; - if (pos >= 0) { - LOOP_L_N(i, len) dispmsg[i] = statusmsg[i + msgscrl]; - } - else { - LOOP_L_N(i, STATUS_CHAR_LIMIT + pos) dispmsg[i] = ' '; - LOOP_S_L_N(i, STATUS_CHAR_LIMIT + pos, STATUS_CHAR_LIMIT) dispmsg[i] = statusmsg[i - (STATUS_CHAR_LIMIT + pos)]; - } - dispmsg[len] = '\0'; - if (process == Print) { - DWIN_Draw_Rectangle(1, Def_StatusBg_Color, 8, 214, DWIN_WIDTH - 8, 238); - const int8_t npos = (DWIN_WIDTH - STATUS_CHAR_LIMIT * MENU_CHR_W) / 2; - DWINUI::Draw_String(GetColor(eeprom_settings.status_bar_text, Def_StatusTxt_Color), Def_StatusBg_Color, npos, 219, dispmsg); - } - else { - DWIN_Draw_Rectangle(1, Def_StatusBg_Color, 8, 352, DWIN_WIDTH - 8, 376); - const int8_t npos = (DWIN_WIDTH - STATUS_CHAR_LIMIT * MENU_CHR_W) / 2; - DWINUI::Draw_String(GetColor(eeprom_settings.status_bar_text, Def_StatusTxt_Color), Def_StatusBg_Color, npos, 357, dispmsg); - } - if (-pos >= STATUS_CHAR_LIMIT) msgscrl = 0; - msgscrl++; - } - else { - if (new_msg) { - new_msg = false; - if (process == Print) { - DWIN_Draw_Rectangle(1, Def_StatusBg_Color, 8, 214, DWIN_WIDTH - 8, 238); - const int8_t npos = (DWIN_WIDTH - strlen(statusmsg) * MENU_CHR_W) / 2; - DWINUI::Draw_String(GetColor(eeprom_settings.status_bar_text, Def_StatusTxt_Color), Def_StatusBg_Color, npos, 219, statusmsg); - } - else { - DWIN_Draw_Rectangle(1, Def_StatusBg_Color, 8, 352, DWIN_WIDTH - 8, 376); - const int8_t npos = (DWIN_WIDTH - strlen(statusmsg) * MENU_CHR_W) / 2; - DWINUI::Draw_String(GetColor(eeprom_settings.status_bar_text, Def_StatusTxt_Color), Def_StatusBg_Color, npos, 357, statusmsg); - } - } - } -} - -#if HAS_HOSTACTION_MENUS - - void CrealityDWINClass::Draw_Keyboard(bool restrict, bool numeric, uint8_t selected, bool uppercase/*=false*/, bool lock/*=false*/) { - process = Keyboard; - keyboard_restrict = restrict; - numeric_keyboard = numeric; - DWIN_Draw_Rectangle(0, Def_SplitLine_Color, 0, KEY_Y_START, DWIN_WIDTH-2, DWIN_HEIGHT-2); - DWIN_Draw_Rectangle(1, Def_Background_Color, 1, KEY_Y_START+1, DWIN_WIDTH-3, DWIN_HEIGHT-3); - LOOP_L_N(i, 36) Draw_Keys(i, (i == selected), uppercase, lock); - } - - void CrealityDWINClass::Draw_Keys(uint8_t index, bool selected, bool uppercase/*=false*/, bool lock/*=false*/) { - const char *keys; - if (numeric_keyboard) keys = "1234567890&<>() {}[]*\"\':;!?"; - else keys = (uppercase) ? "QWERTYUIOPASDFGHJKLZXCVBNM" : "qwertyuiopasdfghjklzxcvbnm"; - #define KEY_X1(x) x*KEY_WIDTH+KEY_INSET+KEY_PADDING - #define KEY_X2(x) (x+1) * KEY_WIDTH+KEY_INSET-KEY_PADDING - #define KEY_Y1(y) KEY_Y_START+KEY_INSET+KEY_PADDING+y*KEY_HEIGHT - #define KEY_Y2(y) KEY_Y_START+KEY_INSET-KEY_PADDING+(y+1) * KEY_HEIGHT - - const uint8_t rowCount[3] = { 10, 9, 7 }; - const float xOffset[3] = { 0, 0.5f * KEY_WIDTH, 1.5f * KEY_WIDTH }; - - if (index < 28) { - if (index == 19) { - DWIN_Draw_Rectangle(0, Color_Light_Blue, KEY_X1(0), KEY_Y1(2), KEY_X2(0) + xOffset[1], KEY_Y2(2)); - DWIN_Draw_Rectangle(0, (selected) ? Def_Selected_Color : Def_Background_Color, KEY_X1(0) + 1, KEY_Y1(2) + 1, KEY_X2(0) + xOffset[1] - 1, KEY_Y2(2) - 1); - if (!numeric_keyboard) { - if (lock) { - DWIN_Draw_Line(Def_Selected_Color, KEY_X1(0) + 17, KEY_Y1(2) + 16, KEY_X1(0) + 25, KEY_Y1(2) + 8); - DWIN_Draw_Line(Def_Selected_Color, KEY_X1(0) + 17, KEY_Y1(2) + 16, KEY_X1(0) + 9, KEY_Y1(2) + 8); - } - else { - DWIN_Draw_Line((uppercase) ? Def_Selected_Color : Def_Text_Color, KEY_X1(0) + 17, KEY_Y1(2) + 8, KEY_X1(0) + 25, KEY_Y1(2) + 16); - DWIN_Draw_Line((uppercase) ? Def_Selected_Color : Def_Text_Color, KEY_X1(0) + 17, KEY_Y1(2) + 8, KEY_X1(0) + 9, KEY_Y1(2) + 16); - } - } - } - else if (index == 27) { - DWIN_Draw_Rectangle(0, Color_Light_Blue, KEY_X1(7) + xOffset[2], KEY_Y1(2), KEY_X2(9), KEY_Y2(2)); - DWIN_Draw_Rectangle(0, (selected) ? Def_Selected_Color : Def_Background_Color, KEY_X1(7) + xOffset[2] + 1, KEY_Y1(2) + 1, KEY_X2(9) - 1, KEY_Y2(2) - 1); - DWINUI::Draw_String(Color_Red, KEY_X1(7) + xOffset[2] + 3, KEY_Y1(2) + 5, F("<--")); - } - else { - if (index > 19) index--; - if (index > 27) index--; - uint8_t y, x; - if (index < rowCount[0]) y = 0, x = index; - else if (index < (rowCount[0] + rowCount[1])) y = 1, x = index-rowCount[0]; - else y = 2, x = index-(rowCount[0] + rowCount[1]); - const char keyStr[2] = {keys[(y > 0) * rowCount[0] + (y > 1) * rowCount[1] + x], '\0'}; - DWIN_Draw_Rectangle(0, Color_Light_Blue, KEY_X1(x) + xOffset[y], KEY_Y1(y), KEY_X2(x) + xOffset[y], KEY_Y2(y)); - DWIN_Draw_Rectangle(0, (selected) ? Def_Selected_Color : Def_Background_Color, KEY_X1(x) + xOffset[y] + 1, KEY_Y1(y) + 1, KEY_X2(x) + xOffset[y] - 1, KEY_Y2(y) - 1); - DWINUI::Draw_String(KEY_X1(x) + xOffset[y] + 5, KEY_Y1(y) + 5, keyStr); - if (keyboard_restrict && numeric_keyboard && index > 9) { - DWIN_Draw_Line(Color_Light_Red, KEY_X1(x) + xOffset[y] + 1, KEY_Y1(y) + 1, KEY_X2(x) + xOffset[y] - 1, KEY_Y2(y) - 1); - DWIN_Draw_Line(Color_Light_Red, KEY_X1(x) + xOffset[y] + 1, KEY_Y2(y) - 1, KEY_X2(x) + xOffset[y] - 1, KEY_Y1(y) + 1); - } - } - } - else { - switch (index) { - case 28: - DWIN_Draw_Rectangle(0, Color_Light_Blue, KEY_X1(0), KEY_Y1(3), KEY_X2(0) + xOffset[1], KEY_Y2(3)); - DWIN_Draw_Rectangle(0, (selected) ? Def_Selected_Color : Def_Background_Color, KEY_X1(0) + 1, KEY_Y1(3) + 1, KEY_X2(0) + xOffset[1] - 1, KEY_Y2(3) - 1); - DWINUI::Draw_String(KEY_X1(0) - 1, KEY_Y1(3) + 5, F("?123")); - break; - case 29: - DWIN_Draw_Rectangle(0, Color_Light_Blue, KEY_X1(1) + xOffset[1], KEY_Y1(3), KEY_X2(1) + xOffset[1], KEY_Y2(3)); - DWIN_Draw_Rectangle(0, (selected) ? Def_Selected_Color : Def_Background_Color, KEY_X1(1) + xOffset[1] + 1, KEY_Y1(3) + 1, KEY_X2(1) + xOffset[1] - 1, KEY_Y2(3) - 1); - DWINUI::Draw_String(KEY_X1(1) + xOffset[1] + 5, KEY_Y1(3) + 5, F("-")); - break; - case 30: - DWIN_Draw_Rectangle(0, Color_Light_Blue, KEY_X1(2) + xOffset[1], KEY_Y1(3), KEY_X2(2) + xOffset[1], KEY_Y2(3)); - DWIN_Draw_Rectangle(0, (selected) ? Def_Selected_Color : Def_Background_Color, KEY_X1(2) + xOffset[1] + 1, KEY_Y1(3) + 1, KEY_X2(2) + xOffset[1] - 1, KEY_Y2(3) - 1); - DWINUI::Draw_String(KEY_X1(2) + xOffset[1] + 5, KEY_Y1(3) + 5, F("_")); - break; - case 31: - DWIN_Draw_Rectangle(0, Color_Light_Blue, KEY_X1(3) + xOffset[1], KEY_Y1(3), KEY_X2(5) + xOffset[1], KEY_Y2(3)); - DWIN_Draw_Rectangle(0, (selected) ? Def_Selected_Color : Def_Background_Color, KEY_X1(3) + xOffset[1] + 1, KEY_Y1(3) + 1, KEY_X2(5) + xOffset[1] - 1, KEY_Y2(3) - 1); - DWINUI::Draw_String(KEY_X1(3) + xOffset[1] + 14, KEY_Y1(3) + 5, F("Space")); - if (keyboard_restrict) { - DWIN_Draw_Line(Color_Light_Red, KEY_X1(3) + xOffset[1] + 1, KEY_Y1(3) + 1, KEY_X2(5) + xOffset[1] - 1, KEY_Y2(3) - 1); - DWIN_Draw_Line(Color_Light_Red, KEY_X1(3) + xOffset[1] + 1, KEY_Y2(3) - 1, KEY_X2(5) + xOffset[1] - 1, KEY_Y1(3) + 1); - } - break; - case 32: - DWIN_Draw_Rectangle(0, Color_Light_Blue, KEY_X1(6) + xOffset[1], KEY_Y1(3), KEY_X2(6) + xOffset[1], KEY_Y2(3)); - DWIN_Draw_Rectangle(0, (selected) ? Def_Selected_Color : Def_Background_Color, KEY_X1(6) + xOffset[1] + 1, KEY_Y1(3) + 1, KEY_X2(6) + xOffset[1] - 1, KEY_Y2(3) - 1); - DWINUI::Draw_String(KEY_X1(6) + xOffset[1] + 7, KEY_Y1(3) + 5, F(".")); - if (keyboard_restrict) { - DWIN_Draw_Line(Color_Light_Red, KEY_X1(6) + xOffset[1] + 1, KEY_Y1(3) + 1, KEY_X2(6) + xOffset[1] - 1, KEY_Y2(3) - 1); - DWIN_Draw_Line(Color_Light_Red, KEY_X1(6) + xOffset[1] + 1, KEY_Y2(3) - 1, KEY_X2(6) + xOffset[1] - 1, KEY_Y1(3) + 1); - } - break; - case 33: - DWIN_Draw_Rectangle(0, Color_Light_Blue, KEY_X1(7) + xOffset[1], KEY_Y1(3), KEY_X2(7) + xOffset[1], KEY_Y2(3)); - DWIN_Draw_Rectangle(0, (selected) ? Def_Selected_Color : Def_Background_Color, KEY_X1(7) + xOffset[1] + 1, KEY_Y1(3) + 1, KEY_X2(7) + xOffset[1] - 1, KEY_Y2(3) - 1); - DWINUI::Draw_String(KEY_X1(7) + xOffset[1] + 4, KEY_Y1(3) + 5, F("/")); - if (keyboard_restrict) { - DWIN_Draw_Line(Color_Light_Red, KEY_X1(7) + xOffset[1] + 1, KEY_Y1(3) + 1, KEY_X2(7) + xOffset[1] - 1, KEY_Y2(3) - 1); - DWIN_Draw_Line(Color_Light_Red, KEY_X1(7) + xOffset[1] + 1, KEY_Y2(3) - 1, KEY_X2(7) + xOffset[1] - 1, KEY_Y1(3) + 1); - } - break; - case 34: - DWIN_Draw_Rectangle(0, Color_Light_Blue, KEY_X1(7) + xOffset[2], KEY_Y1(3), KEY_X2(9), KEY_Y2(3)); - DWIN_Draw_Rectangle(0, (selected) ? Def_Selected_Color : Def_Background_Color, KEY_X1(7) + xOffset[2] + 1, KEY_Y1(3) + 1, KEY_X2(9) - 1, KEY_Y2(3) - 1); - DWINUI::Draw_String(Color_Cyan, KEY_X1(7) + xOffset[2] + 3, KEY_Y1(3) + 5, F("-->")); - break; - } - } - } -#endif // HAS_HOSTACTION_MENUS - -/* Menu Item Config */ - -void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/*=true*/) { - const uint8_t row = item - scrollpos; - #if HAS_LEVELING - static bool level_state; - #endif - - #if HAS_PREHEAT - - #define PREHEAT_BACK 0 - #define PREHEAT_SUBMENU_HOTEND (PREHEAT_BACK + ENABLED(HAS_HOTEND)) - #define PREHEAT_SUBMENU_BED (PREHEAT_SUBMENU_HOTEND + ENABLED(HAS_HEATED_BED)) - #define PREHEAT_SUBMENU_FAN (PREHEAT_SUBMENU_BED + ENABLED(HAS_FAN)) - #define PREHEAT_SUBMENU_TOTAL PREHEAT_SUBMENU_FAN - - auto preheat_submenu = [&](const int index, const uint8_t item, const uint8_t sel) { - switch (item) { - case PREHEAT_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else - Draw_Menu(TempMenu, sel); - break; - #if HAS_HOTEND - case PREHEAT_SUBMENU_HOTEND: - if (draw) { - Draw_Menu_Item(row, ICON_SetEndTemp, F("Hotend")); - Draw_Float(ui.material_preset[index].hotend_temp, row, false, 1); - } - else - Modify_Value(ui.material_preset[index].hotend_temp, MIN_E_TEMP, MAX_E_TEMP, 1); - break; - #endif - #if HAS_HEATED_BED - case PREHEAT_SUBMENU_BED: - if (draw) { - Draw_Menu_Item(row, ICON_SetBedTemp, F("Bed")); - Draw_Float(ui.material_preset[index].bed_temp, row, false, 1); - } - else - Modify_Value(ui.material_preset[index].bed_temp, MIN_BED_TEMP, MAX_BED_TEMP, 1); - break; - #endif - #if HAS_FAN - case PREHEAT_SUBMENU_FAN: - if (draw) { - Draw_Menu_Item(row, ICON_FanSpeed, GET_TEXT_F(MSG_FAN_SPEED)); - Draw_Float(ui.material_preset[index].fan_speed, row, false, 1); - } - else - Modify_Value(ui.material_preset[index].fan_speed, MIN_FAN_SPEED, MAX_FAN_SPEED, 1); - break; - #endif - } - }; - - #endif - - switch (menu) { - case Prepare: - - #define PREPARE_BACK 0 - #define PREPARE_MOVE (PREPARE_BACK + 1) - #define PREPARE_DISABLE (PREPARE_MOVE + 1) - #define PREPARE_HOME (PREPARE_DISABLE + 1) - #define PREPARE_MANUALLEVEL (PREPARE_HOME + 1) - #define PREPARE_ZOFFSET (PREPARE_MANUALLEVEL + ENABLED(HAS_ZOFFSET_ITEM)) - #define PREPARE_PREHEAT (PREPARE_ZOFFSET + ENABLED(HAS_PREHEAT)) - #define PREPARE_COOLDOWN (PREPARE_PREHEAT + EITHER(HAS_HOTEND, HAS_HEATED_BED)) - #define PREPARE_CHANGEFIL (PREPARE_COOLDOWN + ENABLED(ADVANCED_PAUSE_FEATURE)) - #define PREPARE_ACTIONCOMMANDS (PREPARE_CHANGEFIL + ENABLED(HAS_HOSTACTION_MENUS)) - #define PREPARE_CUSTOM_MENU (PREPARE_ACTIONCOMMANDS + ENABLED(HAS_CUSTOM_MENU)) - #define PREPARE_TOTAL PREPARE_ACTIONCOMMANDS - - switch (item) { - case PREPARE_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else - Draw_Main_Menu(1); - break; - case PREPARE_MOVE: - if (draw) - Draw_Menu_Item(row, ICON_Axis, GET_TEXT_F(MSG_MOVE_AXIS), nullptr, true); - else - Draw_Menu(Move); - break; - case PREPARE_DISABLE: - if (draw) - Draw_Menu_Item(row, ICON_CloseMotor, GET_TEXT_F(MSG_DISABLE_STEPPERS)); - else - queue.inject(F("M84")); - break; - case PREPARE_HOME: - if (draw) - Draw_Menu_Item(row, ICON_SetHome, GET_TEXT_F(MSG_HOMING), nullptr, true); - else - Draw_Menu(HomeMenu); - break; - case PREPARE_MANUALLEVEL: - if (draw) - Draw_Menu_Item(row, ICON_PrintSize, GET_TEXT_F(MSG_BED_TRAMMING_MANUAL), nullptr, true); - else { - if (axes_should_home()) { - Popup_Handler(Home); - gcode.home_all_axes(true); - } - #if HAS_LEVELING - level_state = planner.leveling_active; - set_bed_leveling_enabled(false); - #endif - Draw_Menu(ManualLevel); - } - break; - - #if HAS_ZOFFSET_ITEM - case PREPARE_ZOFFSET: - if (draw) - Draw_Menu_Item(row, ICON_Zoffset, F("Z-Offset"), nullptr, true); - else { - #if HAS_LEVELING - level_state = planner.leveling_active; - set_bed_leveling_enabled(false); - #endif - Draw_Menu(ZOffset); - } - break; - #endif - - #if HAS_PREHEAT - case PREPARE_PREHEAT: - if (draw) - Draw_Menu_Item(row, ICON_Temperature, F("Preheat"), nullptr, true); - else - Draw_Menu(Preheat); - break; - #endif - - #if HAS_HOTEND || HAS_HEATED_BED - case PREPARE_COOLDOWN: - if (draw) - Draw_Menu_Item(row, ICON_Cool, GET_TEXT_F(MSG_COOLDOWN)); - else { - thermalManager.cooldown(); - Update_Status(GET_TEXT(MSG_COOLDOWN)); - } - break; - #endif - - #if HAS_HOSTACTION_MENUS - case PREPARE_ACTIONCOMMANDS: - if (draw) - Draw_Menu_Item(row, ICON_SetHome, F("Host Actions"), nullptr, true); - else - Draw_Menu(HostActions); - break; - #endif - - #if HAS_CUSTOM_MENU - case PREPARE_CUSTOM_MENU: - #ifndef CUSTOM_MENU_CONFIG_TITLE - #define CUSTOM_MENU_CONFIG_TITLE "Custom Commands" - #endif - if (draw) - Draw_Menu_Item(row, ICON_Version, F(CUSTOM_MENU_CONFIG_TITLE)); - else - Draw_Menu(MenuCustom); - break; - #endif - - #if ENABLED(ADVANCED_PAUSE_FEATURE) - case PREPARE_CHANGEFIL: - if (draw) { - Draw_Menu_Item(row, ICON_ResumeEEPROM, GET_TEXT_F(MSG_FILAMENTCHANGE) - #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) - , nullptr, true - #endif - ); - } - else { - #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) - Draw_Menu(ChangeFilament); - #else - if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) - Popup_Handler(ETemp); - else { - if (thermalManager.temp_hotend[0].is_below_target(-2)) { - Popup_Handler(Heating); - thermalManager.wait_for_hotend(0); - } - Popup_Handler(FilChange); - sprintf_P(cmd, PSTR("M600 B1 R%i"), thermalManager.temp_hotend[0].target); - gcode.process_subcommands_now(cmd); - } - #endif - } - break; - #endif - } - break; - - case HomeMenu: - - #define HOME_BACK 0 - #define HOME_ALL (HOME_BACK + 1) - #define HOME_X (HOME_ALL + 1) - #define HOME_Y (HOME_X + 1) - #define HOME_Z (HOME_Y + 1) - #define HOME_SET (HOME_Z + 1) - #define HOME_TOTAL HOME_SET - - switch (item) { - case HOME_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else - Draw_Menu(Prepare, PREPARE_HOME); - break; - case HOME_ALL: - if (draw) - Draw_Menu_Item(row, ICON_Homing, GET_TEXT_F(MSG_AUTO_HOME)); - else { - Popup_Handler(Home); - gcode.home_all_axes(true); - Redraw_Menu(); - } - break; - case HOME_X: - if (draw) - Draw_Menu_Item(row, ICON_MoveX, GET_TEXT_F(MSG_AUTO_HOME_X)); - else { - Popup_Handler(Home); - gcode.process_subcommands_now(F("G28 X")); - planner.synchronize(); - Redraw_Menu(); - } - break; - case HOME_Y: - if (draw) - Draw_Menu_Item(row, ICON_MoveY, GET_TEXT_F(MSG_AUTO_HOME_Y)); - else { - Popup_Handler(Home); - gcode.process_subcommands_now(F("G28 Y")); - planner.synchronize(); - Redraw_Menu(); - } - break; - case HOME_Z: - if (draw) - Draw_Menu_Item(row, ICON_MoveZ, GET_TEXT_F(MSG_AUTO_HOME_Z)); - else { - Popup_Handler(Home); - gcode.process_subcommands_now(F("G28 Z")); - planner.synchronize(); - Redraw_Menu(); - } - break; - case HOME_SET: - if (draw) - Draw_Menu_Item(row, ICON_SetHome, GET_TEXT_F(MSG_SET_HOME_OFFSETS)); - else { - gcode.process_subcommands_now(F("G92X0Y0Z0")); - AudioFeedback(); - } - break; - } - break; - - case Move: - - #define MOVE_BACK 0 - #define MOVE_X (MOVE_BACK + 1) - #define MOVE_Y (MOVE_X + 1) - #define MOVE_Z (MOVE_Y + 1) - #define MOVE_E (MOVE_Z + ENABLED(HAS_HOTEND)) - #define MOVE_P (MOVE_E + ENABLED(HAS_BED_PROBE)) - #define MOVE_LIVE (MOVE_P + 1) - #define MOVE_TOTAL MOVE_LIVE - - switch (item) { - case MOVE_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else { - #if HAS_BED_PROBE - temp_val.probe_deployed = false; - probe.set_deployed(temp_val.probe_deployed); - #endif - Draw_Menu(Prepare, PREPARE_MOVE); - } - break; - case MOVE_X: - if (draw) { - Draw_Menu_Item(row, ICON_MoveX, GET_TEXT_F(MSG_MOVE_X)); - Draw_Float(current_position.x, row, false); - } - else - Modify_Value(current_position.x, X_MIN_POS, X_MAX_POS, 10); - break; - case MOVE_Y: - if (draw) { - Draw_Menu_Item(row, ICON_MoveY, GET_TEXT_F(MSG_MOVE_Y)); - Draw_Float(current_position.y, row); - } - else - Modify_Value(current_position.y, Y_MIN_POS, Y_MAX_POS, 10); - break; - case MOVE_Z: - if (draw) { - Draw_Menu_Item(row, ICON_MoveZ, GET_TEXT_F(MSG_MOVE_Z)); - Draw_Float(current_position.z, row); - } - else - Modify_Value(current_position.z, Z_MIN_POS, Z_MAX_POS, 10); - break; - - #if HAS_HOTEND - case MOVE_E: - if (draw) { - Draw_Menu_Item(row, ICON_Extruder, GET_TEXT_F(MSG_MOVE_E)); - current_position.e = 0; - sync_plan_position(); - Draw_Float(current_position.e, row); - } - else { - if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) - Popup_Handler(ETemp); - else { - if (thermalManager.temp_hotend[0].is_below_target(-2)) { - Popup_Handler(Heating); - thermalManager.wait_for_hotend(0); - Redraw_Menu(); - } - current_position.e = 0; - sync_plan_position(); - Modify_Value(current_position.e, -500, 500, 10); - } - } - break; - #endif // HAS_HOTEND - - #if HAS_BED_PROBE - case MOVE_P: - if (draw) { - Draw_Menu_Item(row, ICON_ProbeDeploy, GET_TEXT_F(MSG_MANUAL_DEPLOY)); - Draw_Checkbox(row, temp_val.probe_deployed); - } - else { - temp_val.probe_deployed = !temp_val.probe_deployed; - probe.set_deployed(temp_val.probe_deployed); - Draw_Checkbox(row, temp_val.probe_deployed); - } - break; - #endif - - case MOVE_LIVE: - if (draw) { - Draw_Menu_Item(row, ICON_Axis, F("Live Movement")); - Draw_Checkbox(row, temp_val.livemove); - } - else { - temp_val.livemove = !temp_val.livemove; - Draw_Checkbox(row, temp_val.livemove); - } - break; - } - break; - case ManualLevel: - - #define MLEVEL_BACK 0 - #define MLEVEL_PROBE (MLEVEL_BACK + ENABLED(HAS_BED_PROBE)) - #define MLEVEL_FL (MLEVEL_PROBE + 1) - #define MLEVEL_BL (MLEVEL_FL + 1) - #define MLEVEL_BR (MLEVEL_BL + 1) - #define MLEVEL_FR (MLEVEL_BR + 1) - #define MLEVEL_C (MLEVEL_FR + 1) - #define MLEVEL_ZPOS (MLEVEL_C + 1) - #define MLEVEL_TOTAL MLEVEL_ZPOS - - static float mlev_z_pos = 0; - static bool use_probe = false; - - switch (item) { - case MLEVEL_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else { - TERN_(HAS_LEVELING, set_bed_leveling_enabled(level_state)); - Draw_Menu(Prepare, PREPARE_MANUALLEVEL); - } - break; - #if HAS_BED_PROBE - case MLEVEL_PROBE: - if (draw) { - Draw_Menu_Item(row, ICON_Zoffset, F("Use Probe")); - Draw_Checkbox(row, use_probe); - } - else { - use_probe = !use_probe; - Draw_Checkbox(row, use_probe); - if (use_probe) { - Popup_Handler(Level); - do_z_clearance(Z_HOMING_HEIGHT); - temp_val.corner_avg = 0; - #define PROBE_X_MIN _MAX(temp_val.corner_pos, PROBING_MARGIN, MESH_MIN_X) - probe.offset.x - #define PROBE_X_MAX _MIN(X_BED_SIZE - temp_val.corner_pos, X_BED_SIZE - PROBING_MARGIN, MESH_MAX_X) - probe.offset.x - #define PROBE_Y_MIN _MAX(temp_val.corner_pos, PROBING_MARGIN, MESH_MIN_Y) - probe.offset.y - #define PROBE_Y_MAX _MIN(Y_BED_SIZE - temp_val.corner_pos, Y_BED_SIZE - PROBING_MARGIN, MESH_MAX_Y) - probe.offset.y - temp_val.zval = probe.probe_at_point(PROBE_X_MIN, PROBE_Y_MIN, PROBE_PT_RAISE, 0, false); - const char * MSG_UNREACHABLE = "Position unreachable. Check Probe Offsets and Bed Screw Inset."; - if (isnan(temp_val.zval)) { - Update_Status(MSG_UNREACHABLE); - Redraw_Menu(); - } - temp_val.corner_avg += temp_val.zval; - temp_val.zval = probe.probe_at_point(PROBE_X_MIN, PROBE_Y_MAX, PROBE_PT_RAISE, 0, false); - if (isnan(temp_val.zval)) { - Update_Status(MSG_UNREACHABLE); - Redraw_Menu(); - } - temp_val.corner_avg += temp_val.zval; - temp_val.zval = probe.probe_at_point(PROBE_X_MAX, PROBE_Y_MAX, PROBE_PT_RAISE, 0, false); - if (isnan(temp_val.zval)) { - Update_Status(MSG_UNREACHABLE); - Redraw_Menu(); - } - temp_val.corner_avg += temp_val.zval; - temp_val.zval = probe.probe_at_point(PROBE_X_MAX, PROBE_Y_MIN, PROBE_PT_STOW, 0, false); - if (isnan(temp_val.zval)) { - Update_Status(MSG_UNREACHABLE); - Redraw_Menu(); - } - temp_val.corner_avg += temp_val.zval; - temp_val.corner_avg /= 4; - Redraw_Menu(); - } - } - break; - #endif - case MLEVEL_FL: - if (draw) - Draw_Menu_Item(row, ICON_AxisBL, GET_TEXT_F(MSG_LEVBED_FL)); - else { - Popup_Handler(MoveWait); - if (use_probe) { - #if HAS_BED_PROBE - sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s"), dtostrf(PROBE_X_MIN, 1, 3, str_1), dtostrf(PROBE_Y_MIN, 1, 3, str_2)); - gcode.process_subcommands_now(cmd); - planner.synchronize(); - Popup_Handler(ManualProbing); - #endif - } - else { - sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s\nG0 F300 Z%s"), dtostrf(temp_val.corner_pos, 1, 3, str_1), dtostrf(temp_val.corner_pos, 1, 3, str_2), dtostrf(mlev_z_pos, 1, 3, str_3)); - gcode.process_subcommands_now(cmd); - planner.synchronize(); - Redraw_Menu(); - } - } - break; - case MLEVEL_BL: - if (draw) - Draw_Menu_Item(row, ICON_AxisTL, GET_TEXT_F(MSG_LEVBED_BL)); - else { - Popup_Handler(MoveWait); - if (use_probe) { - #if HAS_BED_PROBE - sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s"), dtostrf(PROBE_X_MIN, 1, 3, str_1), dtostrf(PROBE_Y_MAX, 1, 3, str_2)); - gcode.process_subcommands_now(cmd); - planner.synchronize(); - Popup_Handler(ManualProbing); - #endif - } - else { - sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s\nG0 F300 Z%s"), dtostrf(temp_val.corner_pos, 1, 3, str_1), dtostrf(Y_BED_SIZE - temp_val.corner_pos, 1, 3, str_2), dtostrf(mlev_z_pos, 1, 3, str_3)); - gcode.process_subcommands_now(cmd); - planner.synchronize(); - Redraw_Menu(); - } - } - break; - case MLEVEL_BR: - if (draw) - Draw_Menu_Item(row, ICON_AxisTR, GET_TEXT_F(MSG_LEVBED_BR)); - else { - Popup_Handler(MoveWait); - if (use_probe) { - #if HAS_BED_PROBE - sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s"), dtostrf(PROBE_X_MAX, 1, 3, str_1), dtostrf(PROBE_Y_MAX, 1, 3, str_2)); - gcode.process_subcommands_now(cmd); - planner.synchronize(); - Popup_Handler(ManualProbing); - #endif - } - else { - sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s\nG0 F300 Z%s"), dtostrf(X_BED_SIZE - temp_val.corner_pos, 1, 3, str_1), dtostrf(Y_BED_SIZE - temp_val.corner_pos, 1, 3, str_2), dtostrf(mlev_z_pos, 1, 3, str_3)); - gcode.process_subcommands_now(cmd); - planner.synchronize(); - Redraw_Menu(); - } - } - break; - case MLEVEL_FR: - if (draw) - Draw_Menu_Item(row, ICON_AxisBR, GET_TEXT_F(MSG_LEVBED_FR)); - else { - Popup_Handler(MoveWait); - if (use_probe) { - #if HAS_BED_PROBE - sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s"), dtostrf(PROBE_X_MAX, 1, 3, str_1), dtostrf(PROBE_Y_MIN, 1, 3, str_2)); - gcode.process_subcommands_now(cmd); - planner.synchronize(); - Popup_Handler(ManualProbing); - #endif - } - else { - sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s\nG0 F300 Z%s"), dtostrf(X_BED_SIZE - temp_val.corner_pos, 1, 3, str_1), dtostrf(temp_val.corner_pos, 1, 3, str_2), dtostrf(mlev_z_pos, 1, 3, str_3)); - gcode.process_subcommands_now(cmd); - planner.synchronize(); - Redraw_Menu(); - } - } - break; - case MLEVEL_C: - if (draw) - Draw_Menu_Item(row, ICON_AxisC, GET_TEXT_F(MSG_LEVBED_C)); - else { - Popup_Handler(MoveWait); - if (use_probe) { - #if HAS_BED_PROBE - sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s"), dtostrf((PROBE_X_MIN + PROBE_X_MAX) / 2.0f, 1, 3, str_1), dtostrf((PROBE_Y_MIN + PROBE_Y_MAX) / 2.0f, 1, 3, str_2)); - gcode.process_subcommands_now(cmd); - planner.synchronize(); - Popup_Handler(ManualProbing); - #endif - } - else { - sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s\nG0 F300 Z%s"), dtostrf(X_BED_SIZE / 2.0f, 1, 3, str_1), dtostrf(Y_BED_SIZE / 2.0f, 1, 3, str_2), dtostrf(mlev_z_pos, 1, 3, str_3)); - gcode.process_subcommands_now(cmd); - planner.synchronize(); - Redraw_Menu(); - } - } - break; - case MLEVEL_ZPOS: - if (draw) { - Draw_Menu_Item(row, ICON_SetZOffset, GET_TEXT_F(MSG_MOVE_Z)); - Draw_Float(mlev_z_pos, row, false, 100); - } - else - Modify_Value(mlev_z_pos, 0, MAX_Z_OFFSET, 100); - break; - } - break; - #if HAS_ZOFFSET_ITEM - case ZOffset: - - #define ZOFFSET_BACK 0 - #define ZOFFSET_HOME (ZOFFSET_BACK + 1) - #define ZOFFSET_MODE (ZOFFSET_HOME + 1) - #define ZOFFSET_OFFSET (ZOFFSET_MODE + 1) - #define ZOFFSET_UP (ZOFFSET_OFFSET + 1) - #define ZOFFSET_DOWN (ZOFFSET_UP + 1) - #define ZOFFSET_SAVE (ZOFFSET_DOWN + ENABLED(EEPROM_SETTINGS)) - #define ZOFFSET_TOTAL ZOFFSET_SAVE - - switch (item) { - case ZOFFSET_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else { - temp_val.zoffsetmode = 0; - #if !HAS_BED_PROBE - gcode.process_subcommands_now(F("M211 S1")); // Soft end-stops - #endif - TERN_(HAS_LEVELING, set_bed_leveling_enabled(level_state)); - Draw_Menu(Prepare, PREPARE_ZOFFSET); - } - break; - case ZOFFSET_HOME: - if (draw) - Draw_Menu_Item(row, ICON_Homing, GET_TEXT_F(MSG_AUTO_HOME_Z)); - else { - Popup_Handler(Home); - gcode.process_subcommands_now(F("G28 Z")); - Popup_Handler(MoveWait); - #if ENABLED(Z_SAFE_HOMING) - planner.synchronize(); - sprintf_P(cmd, PSTR("G0 F4000 X%s Y%s"), dtostrf(Z_SAFE_HOMING_X_POINT, 1, 3, str_1), dtostrf(Z_SAFE_HOMING_Y_POINT, 1, 3, str_2)); - gcode.process_subcommands_now(cmd); - #else - sprintf_P(cmd, PSTR("G0 F4000 X%s Y%s"), dtostrf((X_BED_SIZE + X_MIN_POS) / 2.0f, 1, 3, str_1), dtostrf((Y_BED_SIZE + Y_MIN_POS) / 2.0f, 1, 3, str_2)); - gcode.process_subcommands_now(cmd); - #endif - gcode.process_subcommands_now(F("G0 F300 Z0")); - planner.synchronize(); - Redraw_Menu(); - } - break; - case ZOFFSET_MODE: - if (draw) { - Draw_Menu_Item(row, ICON_Zoffset, F("Live Adjustment")); - Draw_Option(temp_val.zoffsetmode, zoffset_modes, row); - } - else - Modify_Option(temp_val.zoffsetmode, zoffset_modes, 2); - break; - case ZOFFSET_OFFSET: - if (draw) { - Draw_Menu_Item(row, ICON_SetZOffset, F("Z Offset")); - Draw_Float(temp_val.zoffsetvalue, row, false, 100); - } - else - Modify_Value(temp_val.zoffsetvalue, MIN_Z_OFFSET, MAX_Z_OFFSET, 100); - break; - case ZOFFSET_UP: - if (draw) - Draw_Menu_Item(row, ICON_Axis, F("Microstep Up")); - else { - if (temp_val.zoffsetvalue < MAX_Z_OFFSET) { - if (temp_val.zoffsetmode != 0) { - gcode.process_subcommands_now(F("M290 Z0.01")); - planner.synchronize(); - } - temp_val.zoffsetvalue += 0.01; - Draw_Float(temp_val.zoffsetvalue, row - 1, false, 100); - } - } - break; - case ZOFFSET_DOWN: - if (draw) - Draw_Menu_Item(row, ICON_AxisD, F("Microstep Down")); - else { - if (temp_val.zoffsetvalue > MIN_Z_OFFSET) { - if (temp_val.zoffsetmode != 0) { - gcode.process_subcommands_now(F("M290 Z-0.01")); - planner.synchronize(); - } - temp_val.zoffsetvalue -= 0.01; - Draw_Float(temp_val.zoffsetvalue, row - 2, false, 100); - } - } - break; - #if ENABLED(EEPROM_SETTINGS) - case ZOFFSET_SAVE: - if (draw) - Draw_Menu_Item(row, ICON_WriteEEPROM, GET_TEXT_F(MSG_BUTTON_SAVE)); - else - AudioFeedback(settings.save()); - break; - #endif - } - break; - #endif - - #if HAS_PREHEAT - case Preheat: { - #define PREHEAT_MODE (PREHEAT_BACK + 1) - #define PREHEAT_1 (PREHEAT_MODE + 1) - #define PREHEAT_2 (PREHEAT_1 + (PREHEAT_COUNT >= 2)) - #define PREHEAT_3 (PREHEAT_2 + (PREHEAT_COUNT >= 3)) - #define PREHEAT_4 (PREHEAT_3 + (PREHEAT_COUNT >= 4)) - #define PREHEAT_5 (PREHEAT_4 + (PREHEAT_COUNT >= 5)) - #define PREHEAT_TOTAL PREHEAT_5 - - auto do_preheat = [](const uint8_t m) { - thermalManager.cooldown(); - if (temp_val.preheatmode == 0 || temp_val.preheatmode == 1) { ui.preheat_hotend_and_fan(m); } - if (temp_val.preheatmode == 0 || temp_val.preheatmode == 2) ui.preheat_bed(m); - }; - - switch (item) { - case PREHEAT_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else - Draw_Menu(Prepare, PREPARE_PREHEAT); - break; - - case PREHEAT_MODE: - if (draw) { - Draw_Menu_Item(row, ICON_Homing, GET_TEXT_F(MSG_CONFIGURATION)); - Draw_Option(temp_val.preheatmode, preheat_modes, row); - } - else - Modify_Option(temp_val.preheatmode, preheat_modes, 2); - break; - - #define _PREHEAT_CASE(N) \ - case PREHEAT_##N: { \ - if (draw) Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_## N ##_LABEL)); \ - else do_preheat(N - 1); \ - } break; - - REPEAT_1(PREHEAT_COUNT, _PREHEAT_CASE) - } - } break; - #endif // HAS_PREHEAT - - #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) - case ChangeFilament: - - #define CHANGEFIL_BACK 0 - #define CHANGEFIL_PARKHEAD (CHANGEFIL_BACK + 1) - #define CHANGEFIL_LOAD (CHANGEFIL_PARKHEAD + 1) - #define CHANGEFIL_UNLOAD (CHANGEFIL_LOAD + 1) - #define CHANGEFIL_CHANGE (CHANGEFIL_UNLOAD + 1) - #define CHANGEFIL_TOTAL CHANGEFIL_CHANGE - - switch (item) { - case CHANGEFIL_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else - Draw_Menu(Prepare, PREPARE_CHANGEFIL); - break; - case CHANGEFIL_PARKHEAD: - if (draw) - Draw_Menu_Item(row, ICON_Park, GET_TEXT_F(MSG_FILAMENT_PARK_ENABLED)); - else { - #if ENABLED(NOZZLE_PARK_FEATURE) - queue.inject(F("G28O\nG27 P2")); - #else - sprintf_P(cmd, PSTR("G28O\nG0 F4000 X%i Y%i\nG0 F3000 Z%i"), 0 , 0, 20); - queue.inject(cmd); - #endif - } - break; - case CHANGEFIL_LOAD: - if (draw) - Draw_Menu_Item(row, ICON_WriteEEPROM, GET_TEXT_F(MSG_FILAMENTLOAD)); - else { - if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) - Popup_Handler(ETemp); - else { - if (thermalManager.temp_hotend[0].is_below_target(-2)) { - Popup_Handler(Heating); - thermalManager.wait_for_hotend(0); - } - Popup_Handler(FilLoad); - gcode.process_subcommands_now(F("M701")); - planner.synchronize(); - Redraw_Menu(); - } - } - break; - case CHANGEFIL_UNLOAD: - if (draw) - Draw_Menu_Item(row, ICON_ReadEEPROM, GET_TEXT_F(MSG_FILAMENTUNLOAD)); - else { - if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) { - Popup_Handler(ETemp); - } - else { - if (thermalManager.temp_hotend[0].is_below_target(-2)) { - Popup_Handler(Heating); - thermalManager.wait_for_hotend(0); - } - Popup_Handler(FilLoad, true); - gcode.process_subcommands_now(F("M702")); - planner.synchronize(); - Redraw_Menu(); - } - } - break; - case CHANGEFIL_CHANGE: - if (draw) - Draw_Menu_Item(row, ICON_ResumeEEPROM, GET_TEXT_F(MSG_FILAMENTCHANGE)); - else { - if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) - Popup_Handler(ETemp); - else { - if (thermalManager.temp_hotend[0].is_below_target(-2)) { - Popup_Handler(Heating); - thermalManager.wait_for_hotend(0); - } - Popup_Handler(FilChange); - sprintf_P(cmd, PSTR("M600 B1 R%i"), thermalManager.temp_hotend[0].target); - gcode.process_subcommands_now(cmd); - } - } - break; - } - break; - #endif // FILAMENT_LOAD_UNLOAD_GCODES - - #if HAS_HOSTACTION_MENUS - case HostActions: - - #define HOSTACTIONS_BACK 0 - #define HOSTACTIONS_1 (HOSTACTIONS_BACK + 1) - #define HOSTACTIONS_2 (HOSTACTIONS_1 + 1) - #define HOSTACTIONS_3 (HOSTACTIONS_2 + 1) - #define HOSTACTIONS_TOTAL HOSTACTIONS_3 - - switch (item) { - case HOSTACTIONS_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else { - if (temp_val.flag_tune) { - temp_val.flag_tune = false; - Redraw_Menu(false, true, true); - } - else - Draw_Menu(Prepare, PREPARE_ACTIONCOMMANDS); - } - break; - case HOSTACTIONS_1: - if (draw) Draw_Menu_Item(row, ICON_File, action1); - else if (!strcmp(action1, "-") == 0) hostui.action(F(action1)); - break; - case HOSTACTIONS_2: - if (draw) Draw_Menu_Item(row, ICON_File, action2); - else if (!strcmp(action2, "-") == 0) hostui.action(F(action2)); - break; - case HOSTACTIONS_3: - if (draw) Draw_Menu_Item(row, ICON_File, action3); - else if (!strcmp(action3, "-") == 0) hostui.action(F(action3)); - break; - } - break; - #endif - - #if HAS_CUSTOM_MENU - - case MenuCustom: - - #define CUSTOM_MENU_BACK 0 - #define CUSTOM_MENU_1 1 - #define CUSTOM_MENU_2 2 - #define CUSTOM_MENU_3 3 - #define CUSTOM_MENU_4 4 - #define CUSTOM_MENU_5 5 - #define CUSTOM_MENU_TOTAL CUSTOM_MENU_COUNT - - switch (item) { - case CUSTOM_MENU_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); - else - Draw_Menu(Prepare, PREPARE_CUSTOM_MENU); - break; - - #if CUSTOM_MENU_COUNT >= 1 - case CUSTOM_MENU_1: - if (draw) - Draw_Menu_Item(row, ICON_Info, F(CONFIG_MENU_ITEM_1_DESC)); - else { - Popup_Handler(Custom); - //queue.inject(F(CONFIG_MENU_ITEM_1_GCODE)); // Old code - gcode.process_subcommands_now(F(CONFIG_MENU_ITEM_1_GCODE)); - planner.synchronize(); - Redraw_Menu(); - #if ENABLED(CUSTOM_MENU_CONFIG_SCRIPT_AUDIBLE_FEEDBACK) - AudioFeedback(); - #endif - #ifdef CUSTOM_MENU_CONFIG_SCRIPT_RETURN - queue.inject(F(CUSTOM_MENU_CONFIG_SCRIPT_DONE)); - #endif - } - break; - #endif - - #if CUSTOM_MENU_COUNT >= 2 - case CUSTOM_MENU_2: - if (draw) - Draw_Menu_Item(row, ICON_Info, F(CONFIG_MENU_ITEM_2_DESC)); - else { - Popup_Handler(Custom); - gcode.process_subcommands_now(F(CONFIG_MENU_ITEM_2_GCODE)); - planner.synchronize(); - Redraw_Menu(); - #if ENABLED(CUSTOM_MENU_CONFIG_SCRIPT_AUDIBLE_FEEDBACK) - AudioFeedback(); - #endif - #ifdef CUSTOM_MENU_CONFIG_SCRIPT_RETURN - queue.inject(F(CUSTOM_MENU_CONFIG_SCRIPT_DONE)); - #endif - } - break; - #endif - - #if CUSTOM_MENU_COUNT >= 3 - case CUSTOM_MENU_3: - if (draw) - Draw_Menu_Item(row, ICON_Info, F(CONFIG_MENU_ITEM_3_DESC)); - else { - Popup_Handler(Custom); - gcode.process_subcommands_now(F(CONFIG_MENU_ITEM_3_GCODE)); - planner.synchronize(); - Redraw_Menu(); - #if ENABLED(CUSTOM_MENU_CONFIG_SCRIPT_AUDIBLE_FEEDBACK) - AudioFeedback(); - #endif - #ifdef CUSTOM_MENU_CONFIG_SCRIPT_RETURN - queue.inject(F(CUSTOM_MENU_CONFIG_SCRIPT_DONE)); - #endif - } - break; - #endif - - #if CUSTOM_MENU_COUNT >= 4 - case CUSTOM_MENU_4: - if (draw) - Draw_Menu_Item(row, ICON_Info, F(CONFIG_MENU_ITEM_4_DESC)); - else { - Popup_Handler(Custom); - gcode.process_subcommands_now(F(CONFIG_MENU_ITEM_4_GCODE)); - planner.synchronize(); - Redraw_Menu(); - #if ENABLED(CUSTOM_MENU_CONFIG_SCRIPT_AUDIBLE_FEEDBACK) - AudioFeedback(); - #endif - #ifdef CUSTOM_MENU_CONFIG_SCRIPT_RETURN - queue.inject(F(CUSTOM_MENU_CONFIG_SCRIPT_DONE)); - #endif - } - break; - #endif - - #if CUSTOM_MENU_COUNT >= 5 - case CUSTOM_MENU_5: - if (draw) - Draw_Menu_Item(row, ICON_Info, F(CONFIG_MENU_ITEM_5_DESC)); - else { - Popup_Handler(Custom); - gcode.process_subcommands_now(F(CONFIG_MENU_ITEM_5_GCODE)); - planner.synchronize(); - Redraw_Menu(); - #if ENABLED(CUSTOM_MENU_CONFIG_SCRIPT_AUDIBLE_FEEDBACK) - AudioFeedback(); - #endif - #ifdef CUSTOM_MENU_CONFIG_SCRIPT_RETURN - queue.inject(F(CUSTOM_MENU_CONFIG_SCRIPT_DONE)); - #endif - } - break; - #endif // Custom Menu - } - break; - - #endif // HAS_CUSTOM_MENU - - case Control: - - #define CONTROL_BACK 0 - #define CONTROL_TEMP (CONTROL_BACK + 1) - #define CONTROL_MOTION (CONTROL_TEMP + 1) - #define CONTROL_FWRETRACT (CONTROL_MOTION + ENABLED(FWRETRACT)) - #define CONTROL_LEDS (CONTROL_FWRETRACT + ANY(CASE_LIGHT_MENU, LED_CONTROL_MENU)) - #define CONTROL_VISUAL (CONTROL_LEDS + 1) - #define CONTROL_HOSTSETTINGS (CONTROL_VISUAL + ENABLED(HAS_HOSTACTION_MENUS)) - #define CONTROL_ADVANCED (CONTROL_HOSTSETTINGS + 1) - #define CONTROL_SAVE (CONTROL_ADVANCED + ENABLED(EEPROM_SETTINGS)) - #define CONTROL_RESTORE (CONTROL_SAVE + ENABLED(EEPROM_SETTINGS)) - #define CONTROL_RESET (CONTROL_RESTORE + ENABLED(EEPROM_SETTINGS)) - #define CONTROL_REBOOT (CONTROL_RESET + 1) - #define CONTROL_INFO (CONTROL_REBOOT + 1) - #define CONTROL_TOTAL CONTROL_INFO - - switch (item) { - case CONTROL_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else - Draw_Main_Menu(2); - break; - case CONTROL_TEMP: - if (draw) - Draw_Menu_Item(row, ICON_Temperature, GET_TEXT_F(MSG_TEMPERATURE), nullptr, true); - else - Draw_Menu(TempMenu); - break; - case CONTROL_MOTION: - if (draw) - Draw_Menu_Item(row, ICON_Motion, GET_TEXT_F(MSG_MOTION), nullptr, true); - else - Draw_Menu(Motion); - break; - #if ENABLED(FWRETRACT) - case CONTROL_FWRETRACT: - if (draw) - Draw_Menu_Item(row, ICON_StepE, GET_TEXT_F(MSG_AUTORETRACT), nullptr, true); - else - Draw_Menu(FwRetraction); - break; - #endif - #if ANY(CASE_LIGHT_MENU, LED_CONTROL_MENU) - case CONTROL_LEDS: - if (draw) - Draw_Menu_Item(row, ICON_LedControl, GET_TEXT_F(MSG_LEDS), nullptr, true); - else - Draw_Menu(Ledsmenu); - break; - #endif - case CONTROL_VISUAL: - if (draw) - Draw_Menu_Item(row, ICON_PrintSize, F("Visual"), nullptr, true); - else - Draw_Menu(Visual); - break; - #if HAS_HOSTACTION_MENUS - case CONTROL_HOSTSETTINGS: - if (draw) - Draw_Menu_Item(row, ICON_Contact, F("Host Settings"), nullptr, true); - else - Draw_Menu(HostSettings); - break; - #endif - case CONTROL_ADVANCED: - if (draw) - Draw_Menu_Item(row, ICON_Version, GET_TEXT_F(MSG_ADVANCED_SETTINGS), nullptr, true); - else - Draw_Menu(Advanced); - break; - #if ENABLED(EEPROM_SETTINGS) - case CONTROL_SAVE: - if (draw) - Draw_Menu_Item(row, ICON_WriteEEPROM, GET_TEXT_F(MSG_STORE_EEPROM)); - else - AudioFeedback(settings.save()); - break; - case CONTROL_RESTORE: - if (draw) - Draw_Menu_Item(row, ICON_ReadEEPROM, GET_TEXT_F(MSG_LOAD_EEPROM)); - else - AudioFeedback(settings.load()); - break; - case CONTROL_RESET: - if (draw) - Draw_Menu_Item(row, ICON_Temperature, GET_TEXT_F(MSG_RESTORE_DEFAULTS)); - else { - settings.reset(); - AudioFeedback(); - } - break; - #endif - case CONTROL_REBOOT: - if (draw) - Draw_Menu_Item(row, ICON_Reboot, GET_TEXT_F(MSG_RESET_PRINTER)); - else - RebootPrinter(); - break; - case CONTROL_INFO: - if (draw) - Draw_Menu_Item(row, ICON_Info, GET_TEXT_F(MSG_INFO_SCREEN)); - else - Draw_Menu(Info); - break; - } - break; - - case TempMenu: - - #define TEMP_BACK 0 - #define TEMP_HOTEND (TEMP_BACK + ENABLED(HAS_HOTEND)) - #define TEMP_BED (TEMP_HOTEND + ENABLED(HAS_HEATED_BED)) - #define TEMP_FAN (TEMP_BED + ENABLED(HAS_FAN)) - #define TEMP_PID (TEMP_FAN + ANY(HAS_HOTEND, HAS_HEATED_BED)) - #define TEMP_PREHEAT1 (TEMP_PID + (PREHEAT_COUNT >= 1)) - #define TEMP_PREHEAT2 (TEMP_PREHEAT1 + (PREHEAT_COUNT >= 2)) - #define TEMP_PREHEAT3 (TEMP_PREHEAT2 + (PREHEAT_COUNT >= 3)) - #define TEMP_PREHEAT4 (TEMP_PREHEAT3 + (PREHEAT_COUNT >= 4)) - #define TEMP_PREHEAT5 (TEMP_PREHEAT4 + (PREHEAT_COUNT >= 5)) - #define TEMP_TOTAL TEMP_PREHEAT5 - - switch (item) { - case TEMP_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else - Draw_Menu(Control, CONTROL_TEMP); - break; - #if HAS_HOTEND - case TEMP_HOTEND: - if (draw) { - Draw_Menu_Item(row, ICON_SetEndTemp, F("Hotend")); - Draw_Float(thermalManager.temp_hotend[0].target, row, false, 1); - } - else - Modify_Value(thermalManager.temp_hotend[0].target, MIN_E_TEMP, MAX_E_TEMP, 1); - break; - #endif - #if HAS_HEATED_BED - case TEMP_BED: - if (draw) { - Draw_Menu_Item(row, ICON_SetBedTemp, F("Bed")); - Draw_Float(thermalManager.temp_bed.target, row, false, 1); - } - else - Modify_Value(thermalManager.temp_bed.target, MIN_BED_TEMP, MAX_BED_TEMP, 1); - break; - #endif - #if HAS_FAN - case TEMP_FAN: - if (draw) { - Draw_Menu_Item(row, ICON_FanSpeed, GET_TEXT_F(MSG_FAN_SPEED)); - Draw_Float(thermalManager.fan_speed[0], row, false, 1); - } - else - Modify_Value(thermalManager.fan_speed[0], MIN_FAN_SPEED, MAX_FAN_SPEED, 1); - break; - #endif - #if HAS_HOTEND || HAS_HEATED_BED - case TEMP_PID: - if (draw) - Draw_Menu_Item(row, ICON_Step, F("PID"), nullptr, true); - else - Draw_Menu(PID); - break; - #endif - - #define _TEMP_PREHEAT_CASE(N) \ - case TEMP_PREHEAT##N: { \ - if (draw) Draw_Menu_Item(row, ICON_Step, F(PREHEAT_## N ##_LABEL), nullptr, true); \ - else Draw_Menu(Preheat##N); \ - } break; - - REPEAT_1(PREHEAT_COUNT, _TEMP_PREHEAT_CASE) - } - break; - - #if HAS_HOTEND || HAS_HEATED_BED - case PID: - - #define PID_BACK 0 - #define PID_HOTEND (PID_BACK + ENABLED(HAS_HOTEND)) - #define PID_BED (PID_HOTEND + ENABLED(HAS_HEATED_BED)) - #define PID_CYCLES (PID_BED + 1) - #define PID_TOTAL PID_CYCLES - - static uint8_t PID_cycles = 5; - - switch (item) { - case PID_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else - Draw_Menu(TempMenu, TEMP_PID); - break; - #if HAS_HOTEND - case PID_HOTEND: - if (draw) - Draw_Menu_Item(row, ICON_HotendTemp, F(STR_HOTEND_PID), nullptr, true); - else - Draw_Menu(HotendPID); - break; - #endif - #if HAS_HEATED_BED - case PID_BED: - if (draw) - Draw_Menu_Item(row, ICON_BedTemp, F(STR_BED_PID), nullptr, true); - else - Draw_Menu(BedPID); - break; - #endif - case PID_CYCLES: - if (draw) { - Draw_Menu_Item(row, ICON_FanSpeed, GET_TEXT_F(MSG_PID_CYCLE)); - Draw_Float(PID_cycles, row, false, 1); - } - else - Modify_Value(PID_cycles, 3, 50, 1); - break; - } - break; - #endif // HAS_HOTEND || HAS_HEATED_BED - - #if HAS_HOTEND - case HotendPID: - - #define HOTENDPID_BACK 0 - #define HOTENDPID_TUNE (HOTENDPID_BACK + 1) - #define HOTENDPID_TEMP (HOTENDPID_TUNE + 1) - #define HOTENDPID_KP (HOTENDPID_TEMP + 1) - #define HOTENDPID_KI (HOTENDPID_KP + 1) - #define HOTENDPID_KD (HOTENDPID_KI + 1) - #define HOTENDPID_TOTAL HOTENDPID_KD - - switch (item) { - case HOTENDPID_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else - Draw_Menu(PID, PID_HOTEND); - break; - case HOTENDPID_TUNE: - if (draw) - Draw_Menu_Item(row, ICON_HotendTemp, GET_TEXT_F(MSG_PID_AUTOTUNE)); - else { - Popup_Handler(PIDWait); - sprintf_P(cmd, PSTR("M303 E0 C%i S%i U1"), PID_cycles, temp_val.PID_e_temp); - gcode.process_subcommands_now(cmd); - planner.synchronize(); - Redraw_Menu(); - } - break; - case HOTENDPID_TEMP: - if (draw) { - Draw_Menu_Item(row, ICON_Temperature, GET_TEXT_F(MSG_TEMPERATURE)); - Draw_Float(temp_val.PID_e_temp, row, false, 1); - } - else - Modify_Value(temp_val.PID_e_temp, MIN_E_TEMP, MAX_E_TEMP, 1); - break; - case HOTENDPID_KP: - if (draw) { - Draw_Menu_Item(row, ICON_Version, F("Kp Value")); - Draw_Float(thermalManager.temp_hotend[0].pid.Kp, row, false, 100); - } - else - Modify_Value(thermalManager.temp_hotend[0].pid.Kp, 0, 5000, 100, thermalManager.updatePID); - break; - case HOTENDPID_KI: - if (draw) { - Draw_Menu_Item(row, ICON_Version, F("Ki Value")); - Draw_Float(unscalePID_i(thermalManager.temp_hotend[0].pid.Ki), row, false, 100); - } - else - Modify_Value(thermalManager.temp_hotend[0].pid.Ki, 0, 5000, 100, thermalManager.updatePID); - break; - case HOTENDPID_KD: - if (draw) { - Draw_Menu_Item(row, ICON_Version, F("Kd Value")); - Draw_Float(unscalePID_d(thermalManager.temp_hotend[0].pid.Kd), row, false, 100); - } - else - Modify_Value(thermalManager.temp_hotend[0].pid.Kd, 0, 5000, 100, thermalManager.updatePID); - break; - } - break; - #endif // HAS_HOTEND - - #if HAS_HEATED_BED - case BedPID: - - #define BEDPID_BACK 0 - #define BEDPID_TUNE (BEDPID_BACK + 1) - #define BEDPID_TEMP (BEDPID_TUNE + 1) - #define BEDPID_KP (BEDPID_TEMP + 1) - #define BEDPID_KI (BEDPID_KP + 1) - #define BEDPID_KD (BEDPID_KI + 1) - #define BEDPID_TOTAL BEDPID_KD - - switch (item) { - case BEDPID_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else - Draw_Menu(PID, PID_BED); - break; - case BEDPID_TUNE: - if (draw) - Draw_Menu_Item(row, ICON_HotendTemp, GET_TEXT_F(MSG_PID_AUTOTUNE)); - else { - Popup_Handler(PIDWait); - sprintf_P(cmd, PSTR("M303 E-1 C%i S%i U1"), PID_cycles, temp_val.PID_bed_temp); - gcode.process_subcommands_now(cmd); - planner.synchronize(); - Redraw_Menu(); - } - break; - case BEDPID_TEMP: - if (draw) { - Draw_Menu_Item(row, ICON_Temperature, GET_TEXT_F(MSG_TEMPERATURE)); - Draw_Float(temp_val.PID_bed_temp, row, false, 1); - } - else - Modify_Value(temp_val.PID_bed_temp, MIN_BED_TEMP, MAX_BED_TEMP, 1); - break; - case BEDPID_KP: - if (draw) { - Draw_Menu_Item(row, ICON_Version, F("Kp Value")); - Draw_Float(thermalManager.temp_bed.pid.Kp, row, false, 100); - } - else - Modify_Value(thermalManager.temp_bed.pid.Kp, 0, 5000, 100, thermalManager.updatePID); - break; - case BEDPID_KI: - if (draw) { - Draw_Menu_Item(row, ICON_Version, F("Ki Value")); - Draw_Float(unscalePID_i(thermalManager.temp_bed.pid.Ki), row, false, 100); - } - else - Modify_Value(thermalManager.temp_bed.pid.Ki, 0, 5000, 100, thermalManager.updatePID); - break; - case BEDPID_KD: - if (draw) { - Draw_Menu_Item(row, ICON_Version, F("Kd Value")); - Draw_Float(unscalePID_d(thermalManager.temp_bed.pid.Kd), row, false, 100); - } - else - Modify_Value(thermalManager.temp_bed.pid.Kd, 0, 5000, 100, thermalManager.updatePID); - break; - } - break; - #endif // HAS_HEATED_BED - - #if HAS_PREHEAT - #define _PREHEAT_SUBMENU_CASE(N) case Preheat##N: preheat_submenu((N) - 1, item, TEMP_PREHEAT##N); break; - REPEAT_1(PREHEAT_COUNT, _PREHEAT_SUBMENU_CASE) - #endif - - case Motion: - - #define MOTION_BACK 0 - #define MOTION_HOMEOFFSETS (MOTION_BACK + 1) - #define MOTION_SPEED (MOTION_HOMEOFFSETS + 1) - #define MOTION_ACCEL (MOTION_SPEED + 1) - #define MOTION_JERK (MOTION_ACCEL + ENABLED(HAS_CLASSIC_JERK)) - #define MOTION_JD (MOTION_JERK + ENABLED(HAS_JUNCTION_DEVIATION)) - #define MOTION_STEPS (MOTION_JD + 1) - #define MOTION_FLOW (MOTION_STEPS + ENABLED(HAS_HOTEND)) - #define MOTION_TOTAL MOTION_FLOW - - switch (item) { - case MOTION_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else - Draw_Menu(Control, CONTROL_MOTION); - break; - case MOTION_HOMEOFFSETS: - if (draw) - Draw_Menu_Item(row, ICON_SetHome, GET_TEXT_F(MSG_SET_HOME_OFFSETS), nullptr, true); - else - Draw_Menu(HomeOffsets); - break; - case MOTION_SPEED: - if (draw) - Draw_Menu_Item(row, ICON_MaxSpeed, GET_TEXT_F(MSG_MAX_SPEED), nullptr, true); - else - Draw_Menu(MaxSpeed); - break; - case MOTION_ACCEL: - if (draw) - Draw_Menu_Item(row, ICON_MaxAccelerated, GET_TEXT_F(MSG_AMAX_EN), nullptr, true); - else - Draw_Menu(MaxAcceleration); - break; - #if HAS_CLASSIC_JERK - case MOTION_JERK: - if (draw) - Draw_Menu_Item(row, ICON_MaxJerk, GET_TEXT_F(MSG_JERK), nullptr, true); - else - Draw_Menu(MaxJerk); - break; - #endif - #if HAS_JUNCTION_DEVIATION - case MOTION_JD: - if (draw) - Draw_Menu_Item(row, ICON_MaxJerk, GET_TEXT_F(MSG_JUNCTION_DEVIATION), nullptr, true); - else - Draw_Menu(JDmenu); - break; - #endif - case MOTION_STEPS: - if (draw) - Draw_Menu_Item(row, ICON_Step, GET_TEXT_F(MSG_STEPS_PER_MM), nullptr, true); - else - Draw_Menu(Steps); - break; - #if HAS_HOTEND - case MOTION_FLOW: - if (draw) { - Draw_Menu_Item(row, ICON_Speed, GET_TEXT_F(MSG_FLOW)); - Draw_Float(planner.flow_percentage[0], row, false, 1); - } - else - Modify_Value(planner.flow_percentage[0], MIN_FLOW_RATE, MAX_FLOW_RATE, 1); - break; - #endif - } - break; - - #if ENABLED(FWRETRACT) - case FwRetraction: - - #define FWR_BACK 0 - #define FWR_RET_AUTO (FWR_BACK + 1) - #define FWR_RET_LENGTH (FWR_RET_AUTO + 1) - #define FWR_RET_SPEED (FWR_RET_LENGTH + 1) - #define FWR_ZLIFT (FWR_RET_SPEED + 1) - #define FWR_REC_EXT_LENGTH (FWR_ZLIFT + 1) - #define FWR_REC_SPEED (FWR_REC_EXT_LENGTH + 1) - #define FWR_RESET (FWR_REC_SPEED + 1) - #define FWR_TOTAL FWR_RESET - - switch (item) { - - case FWR_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else { - if (temp_val.flag_tune) { - temp_val.flag_tune = false; - Redraw_Menu(false, true, true); - } - else - Draw_Menu(Control, CONTROL_FWRETRACT); - } - break; - case FWR_RET_AUTO: - if (draw) { - temp_val.auto_fw_retract = fwretract.autoretract_enabled; - Draw_Menu_Item(row, ICON_StepE, GET_TEXT_F(MSG_AUTORETRACT)); - Draw_Checkbox(row, temp_val.auto_fw_retract); - } - else { - if (MIN_AUTORETRACT <= MAX_AUTORETRACT) { - temp_val.auto_fw_retract = !temp_val.auto_fw_retract; - fwretract.enable_autoretract(temp_val.auto_fw_retract); - Draw_Checkbox(row, temp_val.auto_fw_retract); - } - } - break; - case FWR_RET_LENGTH: - if (draw) { - Draw_Menu_Item(row, ICON_FWRetLength, GET_TEXT_F(MSG_CONTROL_RETRACT)); - Draw_Float(fwretract.settings.retract_length, row, false, 10); - } - else - Modify_Value(fwretract.settings.retract_length, 0, 10, 10); - break; - case FWR_RET_SPEED: - if (draw) { - Draw_Menu_Item(row, ICON_FWRetSpeed, GET_TEXT_F(MSG_SINGLENOZZLE_RETRACT_SPEED)); - Draw_Float(fwretract.settings.retract_feedrate_mm_s, row, false, 10); - } - else - Modify_Value(fwretract.settings.retract_feedrate_mm_s, 1, 90, 10); - break; - case FWR_ZLIFT: - if (draw) { - Draw_Menu_Item(row, ICON_FWRetZRaise, GET_TEXT_F(MSG_CONTROL_RETRACT_ZHOP)); - Draw_Float(fwretract.settings.retract_zraise, row, false, 100); - } - else - Modify_Value(fwretract.settings.retract_zraise, 0, 10, 100); - break; - case FWR_REC_EXT_LENGTH: - if (draw) { - Draw_Menu_Item(row, ICON_FWRecExtLength, GET_TEXT_F(MSG_CONTROL_RETRACT_RECOVER)); - Draw_Float(fwretract.settings.retract_recover_extra, row, false, 10); - } - else - Modify_Value(fwretract.settings.retract_recover_extra, -10, 10, 10); - break; - case FWR_REC_SPEED: - if (draw) { - Draw_Menu_Item(row, ICON_FWRecSpeed, GET_TEXT_F(MSG_SINGLENOZZLE_UNRETRACT_SPEED)); - Draw_Float(fwretract.settings.retract_recover_feedrate_mm_s, row, false, 10); - } - else - Modify_Value(fwretract.settings.retract_recover_feedrate_mm_s, 1, 90, 10); - break; - case FWR_RESET: - if (draw) - Draw_Menu_Item(row, ICON_StepE, GET_TEXT_F(MSG_BUTTON_RESET)); - else { - fwretract.reset(); - Draw_Menu(FwRetraction); - } - break; - } - break; - #endif - - case HomeOffsets: - - #define HOMEOFFSETS_BACK 0 - #define HOMEOFFSETS_XOFFSET (HOMEOFFSETS_BACK + 1) - #define HOMEOFFSETS_YOFFSET (HOMEOFFSETS_XOFFSET + 1) - #define HOMEOFFSETS_TOTAL HOMEOFFSETS_YOFFSET - - switch (item) { - case HOMEOFFSETS_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else - Draw_Menu(Motion, MOTION_HOMEOFFSETS); - break; - case HOMEOFFSETS_XOFFSET: - if (draw) { - Draw_Menu_Item(row, ICON_StepX, GET_TEXT_F(MSG_HOME_OFFSET_X)); - Draw_Float(home_offset.x, row, false, 100); - } - else - Modify_Value(home_offset.x, -MAX_XY_OFFSET, MAX_XY_OFFSET, 100); - break; - case HOMEOFFSETS_YOFFSET: - if (draw) { - Draw_Menu_Item(row, ICON_StepY, GET_TEXT_F(MSG_HOME_OFFSET_Y)); - Draw_Float(home_offset.y, row, false, 100); - } - else - Modify_Value(home_offset.y, -MAX_XY_OFFSET, MAX_XY_OFFSET, 100); - break; - } - break; - case MaxSpeed: - - #define SPEED_BACK 0 - #define SPEED_X (SPEED_BACK + 1) - #define SPEED_Y (SPEED_X + 1) - #define SPEED_Z (SPEED_Y + 1) - #define SPEED_E (SPEED_Z + ENABLED(HAS_HOTEND)) - #define SPEED_TOTAL SPEED_E - - switch (item) { - case SPEED_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else - Draw_Menu(Motion, MOTION_SPEED); - break; - case SPEED_X: - if (draw) { - Draw_Menu_Item(row, ICON_MaxSpeedX, GET_TEXT_F(MSG_VMAX_A)); - Draw_Float(planner.settings.max_feedrate_mm_s[X_AXIS], row, false, 1); - } - else - Modify_Value(planner.settings.max_feedrate_mm_s[X_AXIS], 0, default_max_feedrate[X_AXIS] * 2, 1); - break; - - #if HAS_Y_AXIS - case SPEED_Y: - if (draw) { - Draw_Menu_Item(row, ICON_MaxSpeedY, GET_TEXT_F(MSG_VMAX_B)); - Draw_Float(planner.settings.max_feedrate_mm_s[Y_AXIS], row, false, 1); - } - else - Modify_Value(planner.settings.max_feedrate_mm_s[Y_AXIS], 0, default_max_feedrate[Y_AXIS] * 2, 1); - break; - #endif - - #if HAS_Z_AXIS - case SPEED_Z: - if (draw) { - Draw_Menu_Item(row, ICON_MaxSpeedZ, GET_TEXT_F(MSG_VMAX_C)); - Draw_Float(planner.settings.max_feedrate_mm_s[Z_AXIS], row, false, 1); - } - else - Modify_Value(planner.settings.max_feedrate_mm_s[Z_AXIS], 0, default_max_feedrate[Z_AXIS] * 2, 1); - break; - #endif - - #if HAS_HOTEND - case SPEED_E: - if (draw) { - Draw_Menu_Item(row, ICON_MaxSpeedE, GET_TEXT_F(MSG_VMAX_E)); - Draw_Float(planner.settings.max_feedrate_mm_s[E_AXIS], row, false, 1); - } - else - Modify_Value(planner.settings.max_feedrate_mm_s[E_AXIS], 0, default_max_feedrate[E_AXIS] * 2, 1); - break; - #endif - } - break; - - case MaxAcceleration: - - #define ACCEL_BACK 0 - #define ACCEL_X (ACCEL_BACK + 1) - #define ACCEL_Y (ACCEL_X + 1) - #define ACCEL_Z (ACCEL_Y + 1) - #define ACCEL_E (ACCEL_Z + ENABLED(HAS_HOTEND)) - #define ACCEL_TOTAL ACCEL_E - - switch (item) { - case ACCEL_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else - Draw_Menu(Motion, MOTION_ACCEL); - break; - case ACCEL_X: - if (draw) { - Draw_Menu_Item(row, ICON_MaxAccX, GET_TEXT_F(MSG_AMAX_A)); - Draw_Float(planner.settings.max_acceleration_mm_per_s2[X_AXIS], row, false, 1); - } - else - Modify_Value(planner.settings.max_acceleration_mm_per_s2[X_AXIS], 0, default_max_acceleration[X_AXIS] * 2, 1); - break; - case ACCEL_Y: - if (draw) { - Draw_Menu_Item(row, ICON_MaxAccY, GET_TEXT_F(MSG_AMAX_B)); - Draw_Float(planner.settings.max_acceleration_mm_per_s2[Y_AXIS], row, false, 1); - } - else - Modify_Value(planner.settings.max_acceleration_mm_per_s2[Y_AXIS], 0, default_max_acceleration[Y_AXIS] * 2, 1); - break; - case ACCEL_Z: - if (draw) { - Draw_Menu_Item(row, ICON_MaxAccZ, GET_TEXT_F(MSG_AMAX_C)); - Draw_Float(planner.settings.max_acceleration_mm_per_s2[Z_AXIS], row, false, 1); - } - else - Modify_Value(planner.settings.max_acceleration_mm_per_s2[Z_AXIS], 0, default_max_acceleration[Z_AXIS] * 2, 1); - break; - #if HAS_HOTEND - case ACCEL_E: - if (draw) { - Draw_Menu_Item(row, ICON_MaxAccE, GET_TEXT_F(MSG_AMAX_E)); - Draw_Float(planner.settings.max_acceleration_mm_per_s2[E_AXIS], row, false, 1); - } - else - Modify_Value(planner.settings.max_acceleration_mm_per_s2[E_AXIS], 0, default_max_acceleration[E_AXIS] * 2, 1); - break; - #endif - } - break; - #if HAS_CLASSIC_JERK - case MaxJerk: - - #define JERK_BACK 0 - #define JERK_X (JERK_BACK + 1) - #define JERK_Y (JERK_X + 1) - #define JERK_Z (JERK_Y + 1) - #define JERK_E (JERK_Z + ENABLED(HAS_HOTEND)) - #define JERK_TOTAL JERK_E - - switch (item) { - case JERK_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else - Draw_Menu(Motion, MOTION_JERK); - break; - case JERK_X: - if (draw) { - Draw_Menu_Item(row, ICON_MaxSpeedJerkX, GET_TEXT_F(MSG_VA_JERK)); - Draw_Float(planner.max_jerk[X_AXIS], row, false, 10); - } - else - Modify_Value(planner.max_jerk[X_AXIS], 0, default_max_jerk[X_AXIS] * 2, 10); - break; - case JERK_Y: - if (draw) { - Draw_Menu_Item(row, ICON_MaxSpeedJerkY, GET_TEXT_F(MSG_VB_JERK)); - Draw_Float(planner.max_jerk[Y_AXIS], row, false, 10); - } - else - Modify_Value(planner.max_jerk[Y_AXIS], 0, default_max_jerk[Y_AXIS] * 2, 10); - break; - case JERK_Z: - if (draw) { - Draw_Menu_Item(row, ICON_MaxSpeedJerkZ, GET_TEXT_F(MSG_VC_JERK)); - Draw_Float(planner.max_jerk[Z_AXIS], row, false, 10); - } - else - Modify_Value(planner.max_jerk[Z_AXIS], 0, default_max_jerk[Z_AXIS] * 2, 10); - break; - #if HAS_HOTEND - case JERK_E: - if (draw) { - Draw_Menu_Item(row, ICON_MaxSpeedJerkE, GET_TEXT_F(MSG_VE_JERK)); - Draw_Float(planner.max_jerk[E_AXIS], row, false, 10); - } - else - Modify_Value(planner.max_jerk[E_AXIS], 0, default_max_jerk[E_AXIS] * 2, 10); - break; - #endif - } - break; - #endif - #if HAS_JUNCTION_DEVIATION - case JDmenu: - - #define JD_BACK 0 - #define JD_SETTING_JD_MM (JD_BACK + ENABLED(HAS_HOTEND)) - #define JD_TOTAL JD_SETTING_JD_MM - - switch (item) { - case JD_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else - Draw_Menu(Motion, MOTION_JD); - break; - #if HAS_HOTEND - case JD_SETTING_JD_MM: - if (draw) { - Draw_Menu_Item(row, ICON_MaxJerk, GET_TEXT_F(MSG_JUNCTION_DEVIATION)); - Draw_Float(planner.junction_deviation_mm, row, false, 100); - } - else - Modify_Value(planner.junction_deviation_mm, MIN_JD_MM, MAX_JD_MM, 100); - break; - #endif - } - break; - #endif - case Steps: - - #define STEPS_BACK 0 - #define STEPS_X (STEPS_BACK + 1) - #define STEPS_Y (STEPS_X + 1) - #define STEPS_Z (STEPS_Y + 1) - #define STEPS_E (STEPS_Z + ENABLED(HAS_HOTEND)) - #define STEPS_TOTAL STEPS_E - - switch (item) { - case STEPS_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else - Draw_Menu(Motion, MOTION_STEPS); - break; - case STEPS_X: - if (draw) { - Draw_Menu_Item(row, ICON_StepX, GET_TEXT_F(MSG_A_STEPS)); - Draw_Float(planner.settings.axis_steps_per_mm[X_AXIS], row, false, 10); - } - else - Modify_Value(planner.settings.axis_steps_per_mm[X_AXIS], 0, default_steps[X_AXIS] * 2, 10); - break; - case STEPS_Y: - if (draw) { - Draw_Menu_Item(row, ICON_StepY, GET_TEXT_F(MSG_B_STEPS)); - Draw_Float(planner.settings.axis_steps_per_mm[Y_AXIS], row, false, 10); - } - else - Modify_Value(planner.settings.axis_steps_per_mm[Y_AXIS], 0, default_steps[Y_AXIS] * 2, 10); - break; - case STEPS_Z: - if (draw) { - Draw_Menu_Item(row, ICON_StepZ, GET_TEXT_F(MSG_C_STEPS)); - Draw_Float(planner.settings.axis_steps_per_mm[Z_AXIS], row, false, 10); - } - else - Modify_Value(planner.settings.axis_steps_per_mm[Z_AXIS], 0, default_steps[Z_AXIS] * 2, 10); - break; - #if HAS_HOTEND - case STEPS_E: - if (draw) { - Draw_Menu_Item(row, ICON_StepE, GET_TEXT_F(MSG_E_STEPS)); - Draw_Float(planner.settings.axis_steps_per_mm[E_AXIS], row, false, 10); - } - else - Modify_Value(planner.settings.axis_steps_per_mm[E_AXIS], 0, 1000, 10); - break; - #endif - } - break; - - #if ANY(CASE_LIGHT_MENU, LED_CONTROL_MENU) - case Ledsmenu: - - #define LEDS_BACK 0 - #define LEDS_CASELIGHT (LEDS_BACK + ENABLED(CASE_LIGHT_MENU)) - #define LEDS_LED_CONTROL_MENU (LEDS_CASELIGHT + ENABLED(LED_CONTROL_MENU)) - #define LEDS_TOTAL LEDS_LED_CONTROL_MENU - - switch (item) { - - case LEDS_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else - Draw_Menu(Control, CONTROL_LEDS); - break; - #if ENABLED(CASE_LIGHT_MENU) - case LEDS_CASELIGHT: - if (draw) { - #if ENABLED(CASELIGHT_USES_BRIGHTNESS) - Draw_Menu_Item(row, ICON_CaseLight, GET_TEXT_F(MSG_CASE_LIGHT), nullptr, true); - #else - Draw_Menu_Item(row, ICON_CaseLight, GET_TEXT_F(MSG_CASE_LIGHT)); - Draw_Checkbox(row, caselight.on); - #endif - } - else { - #if ENABLED(CASELIGHT_USES_BRIGHTNESS) - Draw_Menu(CaseLightmenu); - #else - caselight.on = !caselight.on; - caselight.update_enabled(); - Draw_Checkbox(row, caselight.on); - DWIN_UpdateLCD(); - #endif - } - break; - #endif - #if ENABLED(LED_CONTROL_MENU) - case LEDS_LED_CONTROL_MENU: - if (draw) - Draw_Menu_Item(row, ICON_LedControl, GET_TEXT_F(MSG_LED_CONTROL), nullptr, true); - else - Draw_Menu(LedControlmenu); - break; - #endif - } - break; - #endif - - #if ENABLED(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS) - case CaseLightmenu: - - #define CASE_LIGHT_BACK 0 - #define CASE_LIGHT_ON (CASE_LIGHT_BACK + 1) - #define CASE_LIGHT_USES_BRIGHT (CASE_LIGHT_ON + 1) - #define CASE_LIGHT_TOTAL CASE_LIGHT_USES_BRIGHT - - switch (item) { - - case CASE_LIGHT_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else - Draw_Menu(Ledsmenu, LEDS_CASELIGHT); - break; - case CASE_LIGHT_ON: - if (draw) { - Draw_Menu_Item(row, ICON_CaseLight, GET_TEXT_F(MSG_CASE_LIGHT)); - Draw_Checkbox(row, caselight.on); - } - else { - caselight.on = !caselight.on; - caselight.update_enabled(); - Draw_Checkbox(row, caselight.on); - DWIN_UpdateLCD(); - } - break; - case CASE_LIGHT_USES_BRIGHT: - if (draw) { - Draw_Menu_Item(row, ICON_Brightness, GET_TEXT_F(MSG_CASE_LIGHT_BRIGHTNESS)); - Draw_Float(caselight.brightness, row); - } - else - Modify_Value(caselight.brightness, 0, 255, 1); - break; - } - break; - #endif - - #if ENABLED(LED_CONTROL_MENU) - case LedControlmenu: - - #define LEDCONTROL_BACK 0 - #define LEDCONTROL_LIGHTON (LEDCONTROL_BACK + !BOTH(CASE_LIGHT_MENU, CASE_LIGHT_USE_NEOPIXEL)) - #define LEDCONTROL_PRESETS_MENU (LEDCONTROL_LIGHTON + BOTH(HAS_COLOR_LEDS, LED_COLOR_PRESETS)) - #define LEDCONTROL_CUSTOM_MENU (LEDCONTROL_PRESETS_MENU + ENABLED(HAS_COLOR_LEDS) - DISABLED(LED_COLOR_PRESETS)) - #define LEDCONTROL_TOTAL LEDCONTROL_CUSTOM_MENU - - switch (item) { - case LEDCONTROL_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else - Draw_Menu(Ledsmenu, LEDS_LED_CONTROL_MENU); - break; - #if !BOTH(CASE_LIGHT_MENU, CASE_LIGHT_USE_NEOPIXEL) - case LEDCONTROL_LIGHTON: - if (draw) { - Draw_Menu_Item(row, ICON_LedControl, GET_TEXT_F(MSG_LEDS)); - Draw_Checkbox(row, leds.lights_on); - } - else { - leds.toggle(); - Draw_Checkbox(row, leds.lights_on); - DWIN_UpdateLCD(); - } - break; - #endif - #if HAS_COLOR_LEDS - #if ENABLED(LED_COLOR_PRESETS) - case LEDCONTROL_PRESETS_MENU: - if (draw) - Draw_Menu_Item(row, ICON_LedControl, GET_TEXT_F(MSG_LED_PRESETS)); - else - Draw_Menu(LedControlpresets); - break; - #else - case LEDCONTROL_CUSTOM_MENU: - if (draw) - Draw_Menu_Item(row, ICON_LedControl, GET_TEXT_F(MSG_CUSTOM_LEDS)); - else - Draw_Menu(LedControlcustom); - break; - #endif - #endif - } - break; - - #if HAS_COLOR_LEDS - #if ENABLED(LED_COLOR_PRESETS) - case LedControlpresets: - - #define LEDCONTROL_PRESETS_BACK 0 - #define LEDCONTROL_PRESETS_WHITE (LEDCONTROL_PRESETS_BACK + 1) - #define LEDCONTROL_PRESETS_RED (LEDCONTROL_PRESETS_WHITE + 1) - #define LEDCONTROL_PRESETS_ORANGE (LEDCONTROL_PRESETS_RED + 1) - #define LEDCONTROL_PRESETS_YELLOW (LEDCONTROL_PRESETS_ORANGE + 1) - #define LEDCONTROL_PRESETS_GREEN (LEDCONTROL_PRESETS_YELLOW + 1) - #define LEDCONTROL_PRESETS_BLUE (LEDCONTROL_PRESETS_GREEN + 1) - #define LEDCONTROL_PRESETS_INDIGO (LEDCONTROL_PRESETS_BLUE + 1) - #define LEDCONTROL_PRESETS_VIOLET (LEDCONTROL_PRESETS_INDIGO + 1) - #define LEDCONTROL_PRESETS_TOTAL LEDCONTROL_PRESETS_VIOLET - - #define LEDCOLORITEM(MSG,FUNC) if (draw) Draw_Menu_Item(row, ICON_LedControl, GET_TEXT_F(MSG)); else FUNC; break; - - switch (item) { - case LEDCONTROL_PRESETS_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else - Draw_Menu(LedControlmenu, LEDCONTROL_PRESETS_MENU); - break; - case LEDCONTROL_PRESETS_WHITE: LEDCOLORITEM(MSG_SET_LEDS_WHITE, leds.set_white()); - case LEDCONTROL_PRESETS_RED: LEDCOLORITEM(MSG_SET_LEDS_RED, leds.set_red()); - case LEDCONTROL_PRESETS_ORANGE: LEDCOLORITEM(MSG_SET_LEDS_ORANGE, leds.set_orange()); - case LEDCONTROL_PRESETS_YELLOW: LEDCOLORITEM(MSG_SET_LEDS_YELLOW, leds.set_yellow()); - case LEDCONTROL_PRESETS_GREEN: LEDCOLORITEM(MSG_SET_LEDS_GREEN, leds.set_green()); - case LEDCONTROL_PRESETS_BLUE: LEDCOLORITEM(MSG_SET_LEDS_BLUE, leds.set_blue()); - case LEDCONTROL_PRESETS_INDIGO: LEDCOLORITEM(MSG_SET_LEDS_INDIGO, leds.set_indigo()); - case LEDCONTROL_PRESETS_VIOLET: LEDCOLORITEM(MSG_SET_LEDS_VIOLET, leds.set_violet()); - } - break; - #else - case LedControlcustom: - - #define LEDCONTROL_CUSTOM_BACK 0 - #define LEDCONTROL_CUSTOM_RED (LEDCONTROL_CUSTOM_BACK + 1) - #define LEDCONTROL_CUSTOM_GREEN (LEDCONTROL_CUSTOM_RED + 1) - #define LEDCONTROL_CUSTOM_BLUE (LEDCONTROL_CUSTOM_GREEN + 1) - #define LEDCONTROL_CUSTOM_WHITE (LEDCONTROL_CUSTOM_BLUE + ENABLED(HAS_WHITE_LED)) - #define LEDCONTROL_CUSTOM_TOTAL LEDCONTROL_CUSTOM_WHITE - - switch (item) { - case LEDCONTROL_PRESETS_BACK: - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else - Draw_Menu(LedControlmenu, LEDCONTROL_CUSTOM_MENU); - break; - case LEDCONTROL_CUSTOM_RED: - if (draw) { - Draw_Menu_Item(row, ICON_LedControl, GET_TEXT_F(MSG_INTENSITY_R)); - Draw_Float(leds.color.r, row); - } - else - Modify_Value(leds.color.r, 0, 255, 1); - break; - case LEDCONTROL_CUSTOM_GREEN: - if (draw) { - Draw_Menu_Item(row, ICON_LedControl, GET_TEXT_F(MSG_INTENSITY_G)); - Draw_Float(leds.color.g, row); - } - else - Modify_Value(leds.color.g, 0, 255, 1); - break; - case LEDCONTROL_CUSTOM_BLUE: - if (draw) { - Draw_Menu_Item(row, ICON_LedControl, GET_TEXT_F(MSG_INTENSITY_B)); - Draw_Float(leds.color.b, row); - } - else - Modify_Value(leds.color.b, 0, 255, 1); - break; - #if HAS_WHITE_LED - case case LEDCONTROL_CUSTOM_WHITE: - if (draw) { - Draw_Menu_Item(row, ICON_LedControl, GET_TEXT_F(MSG_INTENSITY_W)); - Draw_Float(leds.color.w, row); - } - else - Modify_Value(leds.color.w, 0, 255, 1); - break; - #endif - } - break; - #endif - #endif - #endif - - case Visual: - - #define VISUAL_BACK 0 - #define VISUAL_BACKLIGHT (VISUAL_BACK + 1) - #define VISUAL_BRIGHTNESS (VISUAL_BACKLIGHT + 1) - #define VISUAL_TIME_FORMAT (VISUAL_BRIGHTNESS + 1) - #define VISUAL_COLOR_THEMES (VISUAL_TIME_FORMAT + 1) - #define VISUAL_TOTAL VISUAL_COLOR_THEMES - - switch (item) { - case VISUAL_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else - Draw_Menu(Control, CONTROL_VISUAL); - break; - case VISUAL_BACKLIGHT: - if (draw) - Draw_Menu_Item(row, ICON_Brightness, GET_TEXT_F(MSG_BRIGHTNESS_OFF)); - else - ui.set_brightness(0); - break; - case VISUAL_BRIGHTNESS: - if (draw) { - Draw_Menu_Item(row, ICON_Brightness, GET_TEXT_F(MSG_BRIGHTNESS)); - Draw_Float(ui.brightness, row, false, 1); - } - else - Modify_Value(ui.brightness, LCD_BRIGHTNESS_MIN, LCD_BRIGHTNESS_MAX, 1, ui.refresh_brightness); - break; - case VISUAL_TIME_FORMAT: - if (draw) { - Draw_Menu_Item(row, ICON_PrintTime, F("Progress as __h__m")); - Draw_Checkbox(row, eeprom_settings.time_format_textual); - } - else { - eeprom_settings.time_format_textual = !eeprom_settings.time_format_textual; - Draw_Checkbox(row, eeprom_settings.time_format_textual); - } - break; - case VISUAL_COLOR_THEMES: - if (draw) - Draw_Menu_Item(row, ICON_MaxSpeed, GET_TEXT_F(MSG_COLORS_SELECT), nullptr, true); - else - Draw_Menu(ColorSettings); - break; - } - break; - - case ColorSettings: - - #define COLORSETTINGS_BACK 0 - #define COLORSETTINGS_CURSOR (COLORSETTINGS_BACK + 1) - #define COLORSETTINGS_SPLIT_LINE (COLORSETTINGS_CURSOR + 1) - #define COLORSETTINGS_MENU_TOP_TXT (COLORSETTINGS_SPLIT_LINE + 1) - #define COLORSETTINGS_MENU_TOP_BG (COLORSETTINGS_MENU_TOP_TXT + 1) - #define COLORSETTINGS_HIGHLIGHT_BORDER (COLORSETTINGS_MENU_TOP_BG + 1) - #define COLORSETTINGS_PROGRESS_PERCENT (COLORSETTINGS_HIGHLIGHT_BORDER + 1) - #define COLORSETTINGS_PROGRESS_TIME (COLORSETTINGS_PROGRESS_PERCENT + 1) - #define COLORSETTINGS_PROGRESS_STATUS_BAR (COLORSETTINGS_PROGRESS_TIME + 1) - #define COLORSETTINGS_PROGRESS_STATUS_AREA (COLORSETTINGS_PROGRESS_STATUS_BAR + 1) - #define COLORSETTINGS_PROGRESS_COORDINATES (COLORSETTINGS_PROGRESS_STATUS_AREA + 1) - #define COLORSETTINGS_PROGRESS_COORDINATES_LINE (COLORSETTINGS_PROGRESS_COORDINATES + 1) - #define COLORSETTINGS_TOTAL COLORSETTINGS_PROGRESS_COORDINATES_LINE - - switch (item) { - case COLORSETTINGS_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else - Draw_Menu(Visual, VISUAL_COLOR_THEMES); - break; - case COLORSETTINGS_CURSOR: - if (draw) { - Draw_Menu_Item(row, ICON_MaxSpeed, F("Cursor")); - Draw_Option(eeprom_settings.cursor_color, color_names, row, false, true); - } - else - Modify_Option(eeprom_settings.cursor_color, color_names, Custom_Colors); - break; - case COLORSETTINGS_SPLIT_LINE: - if (draw) { - Draw_Menu_Item(row, ICON_MaxSpeed, F("Menu Split Line")); - Draw_Option(eeprom_settings.menu_split_line, color_names, row, false, true); - } - else - Modify_Option(eeprom_settings.menu_split_line, color_names, Custom_Colors); - break; - case COLORSETTINGS_MENU_TOP_TXT: - if (draw) { - Draw_Menu_Item(row, ICON_MaxSpeed, F("Menu Header Text")); - Draw_Option(eeprom_settings.menu_top_txt, color_names, row, false, true); - } - else - Modify_Option(eeprom_settings.menu_top_txt, color_names, Custom_Colors); - break; - case COLORSETTINGS_MENU_TOP_BG: - if (draw) { - Draw_Menu_Item(row, ICON_MaxSpeed, F("Menu Header Bg")); - Draw_Option(eeprom_settings.menu_top_bg, color_names, row, false, true); - } - else - Modify_Option(eeprom_settings.menu_top_bg, color_names, Custom_Colors); - break; - case COLORSETTINGS_HIGHLIGHT_BORDER: - if (draw) { - Draw_Menu_Item(row, ICON_MaxSpeed, F("Highlight Box")); - Draw_Option(eeprom_settings.highlight_box, color_names, row, false, true); - } - else - Modify_Option(eeprom_settings.highlight_box, color_names, Custom_Colors); - break; - case COLORSETTINGS_PROGRESS_PERCENT: - if (draw) { - Draw_Menu_Item(row, ICON_MaxSpeed, F("Progress Percent")); - Draw_Option(eeprom_settings.progress_percent, color_names, row, false, true); - } - else - Modify_Option(eeprom_settings.progress_percent, color_names, Custom_Colors); - break; - case COLORSETTINGS_PROGRESS_TIME: - if (draw) { - Draw_Menu_Item(row, ICON_MaxSpeed, F("Progress Time")); - Draw_Option(eeprom_settings.progress_time, color_names, row, false, true); - } - else - Modify_Option(eeprom_settings.progress_time, color_names, Custom_Colors); - break; - case COLORSETTINGS_PROGRESS_STATUS_BAR: - if (draw) { - Draw_Menu_Item(row, ICON_MaxSpeed, F("Status Bar Text")); - Draw_Option(eeprom_settings.status_bar_text, color_names, row, false, true); - } - else - Modify_Option(eeprom_settings.status_bar_text, color_names, Custom_Colors); - break; - case COLORSETTINGS_PROGRESS_STATUS_AREA: - if (draw) { - Draw_Menu_Item(row, ICON_MaxSpeed, F("Status Area Text")); - Draw_Option(eeprom_settings.status_area_text, color_names, row, false, true); - } - else - Modify_Option(eeprom_settings.status_area_text, color_names, Custom_Colors); - break; - case COLORSETTINGS_PROGRESS_COORDINATES: - if (draw) { - Draw_Menu_Item(row, ICON_MaxSpeed, F("Coordinates Text")); - Draw_Option(eeprom_settings.coordinates_text, color_names, row, false, true); - } - else - Modify_Option(eeprom_settings.coordinates_text, color_names, Custom_Colors); - break; - case COLORSETTINGS_PROGRESS_COORDINATES_LINE: - if (draw) { - Draw_Menu_Item(row, ICON_MaxSpeed, F("Coordinates Line")); - Draw_Option(eeprom_settings.coordinates_split_line, color_names, row, false, true); - } - else - Modify_Option(eeprom_settings.coordinates_split_line, color_names, Custom_Colors); - break; - } // switch (item) - break; - - #if HAS_HOSTACTION_MENUS - case HostSettings: - - #define HOSTSETTINGS_BACK 0 - #define HOSTSETTINGS_ACTIONCOMMANDS (HOSTSETTINGS_BACK + 1) - #define HOSTSETTINGS_TOTAL HOSTSETTINGS_ACTIONCOMMANDS - - switch (item) { - case HOSTSETTINGS_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else - Draw_Menu(Control, CONTROL_HOSTSETTINGS); - break; - case HOSTSETTINGS_ACTIONCOMMANDS: - if (draw) Draw_Menu_Item(row, ICON_File, F("Host Actions")); - else Draw_Menu(ActionCommands); - break; - } - break; - - case ActionCommands: - - #define ACTIONCOMMANDS_BACK 0 - #define ACTIONCOMMANDS_1 (ACTIONCOMMANDS_BACK + 1) - #define ACTIONCOMMANDS_2 (ACTIONCOMMANDS_1 + 1) - #define ACTIONCOMMANDS_3 (ACTIONCOMMANDS_2 + 1) - #define ACTIONCOMMANDS_TOTAL ACTIONCOMMANDS_3 - - switch (item) { - case ACTIONCOMMANDS_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else - Draw_Menu(HostSettings, HOSTSETTINGS_ACTIONCOMMANDS); - break; - case ACTIONCOMMANDS_1: - if (draw) { - Draw_Menu_Item(row, ICON_File, F("Action #1")); - Draw_String(action1, row); - } - else - Modify_String(action1, 8, true); - break; - case ACTIONCOMMANDS_2: - if (draw) { - Draw_Menu_Item(row, ICON_File, F("Action #2")); - Draw_String(action2, row); - } - else - Modify_String(action2, 8, true); - break; - case ACTIONCOMMANDS_3: - if (draw) { - Draw_Menu_Item(row, ICON_File, F("Action #3")); - Draw_String(action3, row); - } - else - Modify_String(action3, 8, true); - break; - } - break; - #endif - - case Advanced: - - #define ADVANCED_BACK 0 - #define ADVANCED_BEEPER (ADVANCED_BACK + ENABLED(SOUND_MENU_ITEM)) - #define ADVANCED_PROBE (ADVANCED_BEEPER + ENABLED(HAS_BED_PROBE)) - #define ADVANCED_CORNER (ADVANCED_PROBE + 1) - #define ADVANCED_LA (ADVANCED_CORNER + ENABLED(LIN_ADVANCE)) - #define ADVANCED_LOAD (ADVANCED_LA + ENABLED(ADVANCED_PAUSE_FEATURE)) - #define ADVANCED_UNLOAD (ADVANCED_LOAD + ENABLED(ADVANCED_PAUSE_FEATURE)) - #define ADVANCED_COLD_EXTRUDE (ADVANCED_UNLOAD + ENABLED(PREVENT_COLD_EXTRUSION)) - #define ADVANCED_FILSENSORENABLED (ADVANCED_COLD_EXTRUDE + ENABLED(FILAMENT_RUNOUT_SENSOR)) - #define ADVANCED_FILSENSORDISTANCE (ADVANCED_FILSENSORENABLED + ENABLED(HAS_FILAMENT_RUNOUT_DISTANCE)) - #define ADVANCED_POWER_LOSS (ADVANCED_FILSENSORDISTANCE + ENABLED(POWER_LOSS_RECOVERY)) - #define ADVANCED_BAUDRATE_MODE (ADVANCED_POWER_LOSS + ENABLED(BAUD_RATE_GCODE)) - #define ADVANCED_ESDIAG (ADVANCED_BAUDRATE_MODE + ENABLED(HAS_ESDIAG)) - #define ADVANCED_LOCKSCREEN (ADVANCED_ESDIAG + ENABLED(HAS_LOCKSCREEN)) - #define ADVANCED_TOTAL ADVANCED_LOCKSCREEN - - switch (item) { - case ADVANCED_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else - Draw_Menu(Control, CONTROL_ADVANCED); - break; - - #if ENABLED(SOUND_MENU_ITEM) - case ADVANCED_BEEPER: - if (draw) { - Draw_Menu_Item(row, ICON_Sound, GET_TEXT_F(MSG_SOUND_ENABLE)); - Draw_Checkbox(row, ui.sound_on); - } - else { - ui.sound_on = !ui.sound_on; - Draw_Checkbox(row, ui.sound_on); - } - break; - #endif - - #if HAS_BED_PROBE - case ADVANCED_PROBE: - if (draw) - Draw_Menu_Item(row, ICON_ProbeSet, GET_TEXT_F(MSG_ZPROBE_SETTINGS), nullptr, true); - else - Draw_Menu(ProbeMenu); - break; - #endif - - case ADVANCED_CORNER: - if (draw) { - Draw_Menu_Item(row, ICON_MaxAccelerated, F("Bed Screw Inset")); - Draw_Float(temp_val.corner_pos, row, false, 10); - } - else - Modify_Value(temp_val.corner_pos, 1, 100, 10); - break; - - #if ENABLED(LIN_ADVANCE) - case ADVANCED_LA: - if (draw) { - Draw_Menu_Item(row, ICON_MaxAccelerated, GET_TEXT_F(MSG_ADVANCE_K_E)); - Draw_Float(planner.extruder_advance_K[0], row, false, 100); - } - else - Modify_Value(planner.extruder_advance_K[0], 0, 10, 100); - break; - #endif - - #if ENABLED(ADVANCED_PAUSE_FEATURE) - case ADVANCED_LOAD: - if (draw) { - Draw_Menu_Item(row, ICON_WriteEEPROM, GET_TEXT_F(MSG_FILAMENT_LOAD)); - Draw_Float(fc_settings[0].load_length, row, false, 1); - } - else - Modify_Value(fc_settings[0].load_length, 0, EXTRUDE_MAXLENGTH, 1); - break; - case ADVANCED_UNLOAD: - if (draw) { - Draw_Menu_Item(row, ICON_ReadEEPROM, GET_TEXT_F(MSG_FILAMENT_UNLOAD)); - Draw_Float(fc_settings[0].unload_length, row, false, 1); - } - else - Modify_Value(fc_settings[0].unload_length, 0, EXTRUDE_MAXLENGTH, 1); - break; - #endif // ADVANCED_PAUSE_FEATURE - - #if ENABLED(PREVENT_COLD_EXTRUSION) - case ADVANCED_COLD_EXTRUDE: - if (draw) { - Draw_Menu_Item(row, ICON_Cool, F("Min Extrusion T")); - Draw_Float(thermalManager.extrude_min_temp, row, false, 1); - } - else { - Modify_Value(thermalManager.extrude_min_temp, 0, MAX_E_TEMP, 1); - thermalManager.allow_cold_extrude = (thermalManager.extrude_min_temp == 0); - } - break; - #endif - - #if ENABLED(FILAMENT_RUNOUT_SENSOR) - case ADVANCED_FILSENSORENABLED: - if (draw) { - Draw_Menu_Item(row, ICON_Extruder, GET_TEXT_F(MSG_RUNOUT_ENABLE)); - Draw_Checkbox(row, runout.enabled); - } - else { - runout.enabled = !runout.enabled; - Draw_Checkbox(row, runout.enabled); - } - break; - - #if ENABLED(HAS_FILAMENT_RUNOUT_DISTANCE) - case ADVANCED_FILSENSORDISTANCE: - if (draw) { - Draw_Menu_Item(row, ICON_MaxAccE, GET_TEXT_F(MSG_RUNOUT_DISTANCE_MM)); - Draw_Float(runout.runout_distance(), row, false, 10); - } - else - Modify_Value(runout.runout_distance(), 0, 999, 10); - break; - #endif - #endif // FILAMENT_RUNOUT_SENSOR - - #if ENABLED(POWER_LOSS_RECOVERY) - case ADVANCED_POWER_LOSS: - if (draw) { - Draw_Menu_Item(row, ICON_Motion, GET_TEXT_F(MSG_OUTAGE_RECOVERY)); - Draw_Checkbox(row, recovery.enabled); - } - else { - recovery.enable(!recovery.enabled); - Draw_Checkbox(row, recovery.enabled); - } - break; - #endif - #if ENABLED(BAUD_RATE_GCODE) - case ADVANCED_BAUDRATE_MODE: - if (draw) { - Draw_Menu_Item(row, ICON_Setspeed, F("115k Baud")); - Draw_Checkbox(row, eeprom_settings.Baud115k); - } - else { - eeprom_settings.Baud115k = !eeprom_settings.Baud115k; - queue.inject(eeprom_settings.Baud115k ? F("M575 P0 B115200") : F("M575 P0 B250000")); - } - break; - #endif - #if HAS_ESDIAG - case ADVANCED_ESDIAG: - if (draw) - Draw_Menu_Item(row, ICON_ESDiag, F("End-stops diagnostic")); - else - DWIN_EndstopsDiag(); - break; - #endif - #if HAS_LOCKSCREEN - case ADVANCED_LOCKSCREEN: - if (draw) - Draw_Menu_Item(row, ICON_Lock, GET_TEXT_F(MSG_LOCKSCREEN)); - else - DWIN_LockScreen(); - break; - #endif - } - break; - - #if HAS_BED_PROBE - case ProbeMenu: - - #define PROBE_BACK 0 - #define PROBE_XOFFSET (PROBE_BACK + 1) - #define PROBE_YOFFSET (PROBE_XOFFSET + 1) - #define PROBE_ZOFFSET (PROBE_YOFFSET + 1) - #define PROBE_HSMODE (PROBE_ZOFFSET + ENABLED(BLTOUCH)) - #define PROBE_ALARMR (PROBE_HSMODE + ENABLED(BLTOUCH)) - #define PROBE_SELFTEST (PROBE_ALARMR + ENABLED(BLTOUCH)) - #define PROBE_MOVEP (PROBE_SELFTEST + ENABLED(BLTOUCH)) - #define PROBE_TEST (PROBE_MOVEP + 1) - #define PROBE_TEST_COUNT (PROBE_TEST + 1) - #define PROBE_TOTAL PROBE_TEST_COUNT - - static uint8_t testcount = 4; - - switch (item) { - case PROBE_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else - Draw_Menu(Advanced, ADVANCED_PROBE); - break; - case PROBE_XOFFSET: - if (draw) { - Draw_Menu_Item(row, ICON_StepX, GET_TEXT_F(MSG_ZPROBE_XOFFSET)); - Draw_Float(probe.offset.x, row, false, 10); - } - else - Modify_Value(probe.offset.x, -MAX_XY_OFFSET, MAX_XY_OFFSET, 10); - break; - case PROBE_YOFFSET: - if (draw) { - Draw_Menu_Item(row, ICON_StepY, GET_TEXT_F(MSG_ZPROBE_YOFFSET)); - Draw_Float(probe.offset.y, row, false, 10); - } - else - Modify_Value(probe.offset.y, -MAX_XY_OFFSET, MAX_XY_OFFSET, 10); - break; - case PROBE_ZOFFSET: - if (draw) { - Draw_Menu_Item(row, ICON_StepZ, GET_TEXT_F(MSG_ZPROBE_ZOFFSET)); - Draw_Float(probe.offset.z, row, false, 100); - } - else - Modify_Value(probe.offset.z, MIN_Z_OFFSET, MAX_Z_OFFSET, 100); - break; - #if ENABLED(BLTOUCH) - case PROBE_HSMODE: - if (draw) { - Draw_Menu_Item(row, ICON_HSMode, GET_TEXT(MSG_BLTOUCH_SPEED_MODE)); - Draw_Checkbox(row, bltouch.high_speed_mode); - } - else { - bltouch.high_speed_mode = !bltouch.high_speed_mode; - Draw_Checkbox(row, bltouch.high_speed_mode); - } - break; - case PROBE_ALARMR: - if (draw) - Draw_Menu_Item(row, ICON_ProbeAlarm, GET_TEXT_F(MSG_BLTOUCH_RESET)); - else { - gcode.process_subcommands_now(F("M280 P0 S160")); - AudioFeedback(); - } - break; - case PROBE_SELFTEST: - if (draw) - Draw_Menu_Item(row, ICON_ProbeSelfTest, GET_TEXT_F(MSG_BLTOUCH_SELFTEST)); - else { - gcode.process_subcommands_now(F("M280 P0 S120\nG4 P1000\nM280 P0 S160")); - planner.synchronize(); - AudioFeedback(); - } - break; - case PROBE_MOVEP: - if (draw) { - Draw_Menu_Item(row, ICON_ProbeDeploy, GET_TEXT_F(MSG_BLTOUCH_DEPLOY)); - Draw_Checkbox(row, temp_val.probe_deployed); - } - else { - temp_val.probe_deployed = !temp_val.probe_deployed; - if (temp_val.probe_deployed == true) gcode.process_subcommands_now(F("M280 P0 S10")); - else gcode.process_subcommands_now(F("M280 P0 S90")); - Draw_Checkbox(row, temp_val.probe_deployed); - } - break; - #endif - case PROBE_TEST: - if (draw) - Draw_Menu_Item(row, ICON_ProbeTest, GET_TEXT_F(MSG_M48_TEST)); - else { - sprintf_P(cmd, PSTR("G28O\nM48 X%s Y%s P%i"), dtostrf((X_BED_SIZE + X_MIN_POS) / 2.0f, 1, 3, str_1), dtostrf((Y_BED_SIZE + Y_MIN_POS) / 2.0f, 1, 3, str_2), testcount); - gcode.process_subcommands_now(cmd); - } - break; - case PROBE_TEST_COUNT: - if (draw) { - Draw_Menu_Item(row, ICON_ProbeTestCount, F("Probe Test Count")); - Draw_Float(testcount, row, false, 1); - } - else - Modify_Value(testcount, 4, 50, 1); - break; - } - break; - #endif - - case InfoMain: - case Info: - - #define INFO_BACK 0 - #define INFO_PRINTCOUNT (INFO_BACK + ENABLED(PRINTCOUNTER)) - #define INFO_PRINTTIME (INFO_PRINTCOUNT + ENABLED(PRINTCOUNTER)) - #define INFO_SIZE (INFO_PRINTTIME + 1) - #define INFO_VERSION (INFO_SIZE + 1) - #define INFO_CONTACT (INFO_VERSION + 1) - #define INFO_TOTAL INFO_BACK - - switch (item) { - case INFO_BACK: - if (draw) { - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - - #if ENABLED(PRINTCOUNTER) - char row1[50], row2[50], buf[32]; - printStatistics ps = print_job_timer.getStats(); - - sprintf_P(row1, PSTR("%i prints, %i finished"), ps.totalPrints, ps.finishedPrints); - sprintf_P(row2, PSTR("%s m filament used"), dtostrf(ps.filamentUsed / 1000, 1, 2, str_1)); - Draw_Menu_Item(INFO_PRINTCOUNT, ICON_HotendTemp, row1, row2, false, true); - - duration_t(print_job_timer.getStats().printTime).toString(buf); - sprintf_P(row1, PSTR("Printed: %s"), buf); - duration_t(print_job_timer.getStats().longestPrint).toString(buf); - sprintf_P(row2, PSTR("Longest: %s"), buf); - Draw_Menu_Item(INFO_PRINTTIME, ICON_PrintTime, row1, row2, false, true); - #endif - - Draw_Menu_Item(INFO_SIZE, ICON_PrintSize, F(MACHINE_SIZE), nullptr, false, true); - Draw_Menu_Item(INFO_VERSION, ICON_Version, F(SHORT_BUILD_VERSION), nullptr, false, true); - Draw_Menu_Item(INFO_CONTACT, ICON_Contact, F(CORP_WEBSITE), nullptr, false, true); - } - else { - if (menu == Info) - Draw_Menu(Control, CONTROL_INFO); - else - Draw_Main_Menu(3); - } - break; - } - break; - - #if HAS_MESH - case Leveling: - - #define LEVELING_BACK 0 - #define LEVELING_ACTIVE (LEVELING_BACK + 1) - #define LEVELING_GET_TILT (LEVELING_ACTIVE + BOTH(HAS_BED_PROBE, AUTO_BED_LEVELING_UBL)) - #define LEVELING_GET_MESH (LEVELING_GET_TILT + 1) - #define LEVELING_MANUAL (LEVELING_GET_MESH + 1) - #define LEVELING_VIEW (LEVELING_MANUAL + 1) - #define LEVELING_SETTINGS (LEVELING_VIEW + 1) - #define LEVELING_SLOT (LEVELING_SETTINGS + ENABLED(AUTO_BED_LEVELING_UBL)) - #define LEVELING_LOAD (LEVELING_SLOT + ENABLED(AUTO_BED_LEVELING_UBL)) - #define LEVELING_SAVE (LEVELING_LOAD + ENABLED(AUTO_BED_LEVELING_UBL)) - #define LEVELING_TOTAL LEVELING_SAVE - - switch (item) { - case LEVELING_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else - Draw_Main_Menu(3); - break; - case LEVELING_ACTIVE: - if (draw) { - Draw_Menu_Item(row, ICON_MeshActive, GET_TEXT_F(MSG_MESH_LEVELING)); - Draw_Checkbox(row, planner.leveling_active); - } - else { - if (!planner.leveling_active) { - set_bed_leveling_enabled(!planner.leveling_active); - if (!planner.leveling_active) { Confirm_Handler(LevelError); break; } - } - else - set_bed_leveling_enabled(!planner.leveling_active); - Draw_Checkbox(row, planner.leveling_active); - } - break; - #if BOTH(HAS_BED_PROBE, AUTO_BED_LEVELING_UBL) - case LEVELING_GET_TILT: - if (draw) - Draw_Menu_Item(row, ICON_Tilt, F("Autotilt Current Mesh")); - else { - if (bedlevel.storage_slot < 0) { Popup_Handler(MeshSlot); break; } - PreheatBefore(); - Popup_Handler(Home); - gcode.home_all_axes(true); - Popup_Handler(Level); - if (mesh_conf.tilt_grid > 1) { - sprintf_P(cmd, PSTR("G29 J%i"), mesh_conf.tilt_grid); - gcode.process_subcommands_now(cmd); - } - else - gcode.process_subcommands_now(F("G29 J")); - planner.synchronize(); - Redraw_Menu(); - } - break; - #endif - case LEVELING_GET_MESH: - if (draw) - Draw_Menu_Item(row, ICON_Mesh, GET_TEXT_F(MSG_UBL_BUILD_MESH_MENU)); - else { - #if ENABLED(AUTO_BED_LEVELING_UBL) - if (bedlevel.storage_slot < 0) { Popup_Handler(MeshSlot, true); break; } - #endif - PreheatBefore(); - Popup_Handler(Home); - gcode.home_all_axes(true); - #if ENABLED(AUTO_BED_LEVELING_UBL) - #if HAS_BED_PROBE - Popup_Handler(Level); - gcode.process_subcommands_now(F("G29 P1")); - gcode.process_subcommands_now(F("G29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nM420 S1")); - planner.synchronize(); - Update_Status(GET_TEXT_F(MSG_MESH_DONE)); - Popup_Handler(SaveLevel); - #else - level_state = planner.leveling_active; - set_bed_leveling_enabled(false); - mesh_conf.goto_mesh_value = true; - mesh_conf.mesh_x = mesh_conf.mesh_y = 0; - Popup_Handler(MoveWait); - mesh_conf.manual_mesh_move(); - Draw_Menu(UBLMesh); - #endif - #elif HAS_BED_PROBE - Popup_Handler(Level); - gcode.process_subcommands_now(F("G29")); - planner.synchronize(); - Update_Status(GET_TEXT_F(MSG_MESH_DONE)); - Popup_Handler(SaveLevel); - #else - level_state = planner.leveling_active; - set_bed_leveling_enabled(false); - temp_val.gridpoint = 1; - Popup_Handler(MoveWait); - gcode.process_subcommands_now(F("M211 S0\nG29")); - planner.synchronize(); - Draw_Menu(ManualMesh); - #endif - } - break; - case LEVELING_MANUAL: - if (draw) - Draw_Menu_Item(row, ICON_Mesh, GET_TEXT_F(MSG_UBL_MESH_EDIT), nullptr, true); - else { - #if ENABLED(AUTO_BED_LEVELING_BILINEAR) - if (!leveling_is_valid()) { Confirm_Handler(InvalidMesh); break; } - #endif - #if ENABLED(AUTO_BED_LEVELING_UBL) - if (bedlevel.storage_slot < 0) { Popup_Handler(MeshSlot); break; } - #endif - PreheatBefore(); - if (axes_should_home()) { Popup_Handler(Home); gcode.home_all_axes(true); } - level_state = planner.leveling_active; - set_bed_leveling_enabled(false); - mesh_conf.goto_mesh_value = false; - Popup_Handler(MoveWait); - mesh_conf.manual_mesh_move(); - gcode.process_subcommands_now(F("M211 S0")); - Draw_Menu(LevelManual); - } - break; - case LEVELING_VIEW: - if (draw) - Draw_Menu_Item(row, ICON_Mesh, GET_TEXT_F(MSG_MESH_VIEW), nullptr, true); - else { - #if ENABLED(AUTO_BED_LEVELING_UBL) - if (bedlevel.storage_slot < 0) { Popup_Handler(MeshSlot); break; } - #endif - Draw_Menu(LevelView); - } - break; - case LEVELING_SETTINGS: - if (draw) - Draw_Menu_Item(row, ICON_Step, GET_TEXT_F(MSG_ADVANCED_SETTINGS), nullptr, true); - else - Draw_Menu(LevelSettings); - break; - #if ENABLED(AUTO_BED_LEVELING_UBL) - case LEVELING_SLOT: - if (draw) { - Draw_Menu_Item(row, ICON_PrintSize, GET_TEXT_F(MSG_UBL_STORAGE_SLOT)); - Draw_Float(bedlevel.storage_slot, row, false, 1); - } - else - Modify_Value(bedlevel.storage_slot, 0, settings.calc_num_meshes() - 1, 1); - break; - case LEVELING_LOAD: - if (draw) - Draw_Menu_Item(row, ICON_ReadEEPROM, GET_TEXT_F(MSG_UBL_LOAD_MESH)); - else { - if (bedlevel.storage_slot < 0) { Popup_Handler(MeshSlot); break; } - gcode.process_subcommands_now(F("G29 L")); - planner.synchronize(); - AudioFeedback(true); - } - break; - case LEVELING_SAVE: - if (draw) - Draw_Menu_Item(row, ICON_WriteEEPROM, GET_TEXT_F(MSG_UBL_SAVE_MESH)); - else { - if (bedlevel.storage_slot < 0) { Popup_Handler(MeshSlot); break; } - gcode.process_subcommands_now(F("G29 S")); - planner.synchronize(); - AudioFeedback(true); - } - break; - #endif - } - break; - - case LevelView: - - #define LEVELING_VIEW_BACK 0 - #define LEVELING_VIEW_MESH (LEVELING_VIEW_BACK + 1) - #define LEVELING_VIEW_TEXT (LEVELING_VIEW_MESH + 1) - #define LEVELING_VIEW_ASYMMETRIC (LEVELING_VIEW_TEXT + 1) - #define LEVELING_VIEW_TOTAL LEVELING_VIEW_ASYMMETRIC - - switch (item) { - case LEVELING_VIEW_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else - Draw_Menu(Leveling, LEVELING_VIEW); - break; - case LEVELING_VIEW_MESH: - if (draw) - Draw_Menu_Item(row, ICON_PrintSize, GET_TEXT_F(MSG_MESH_VIEW), nullptr, true); - else - Draw_Menu(MeshViewer); - break; - case LEVELING_VIEW_TEXT: - if (draw) { - Draw_Menu_Item(row, ICON_Contact, F("Viewer Show Values")); - Draw_Checkbox(row, mesh_conf.viewer_print_value); - } - else { - mesh_conf.viewer_print_value = !mesh_conf.viewer_print_value; - Draw_Checkbox(row, mesh_conf.viewer_print_value); - } - break; - case LEVELING_VIEW_ASYMMETRIC: - if (draw) { - Draw_Menu_Item(row, ICON_Axis, F("Viewer Asymmetric")); - Draw_Checkbox(row, mesh_conf.viewer_asymmetric_range); - } - else { - mesh_conf.viewer_asymmetric_range = !mesh_conf.viewer_asymmetric_range; - Draw_Checkbox(row, mesh_conf.viewer_asymmetric_range); - } - break; - } - break; - - case LevelSettings: - - #define LEVELING_SETTINGS_BACK 0 - #define LEVELING_SETTINGS_LEVELTEMP_MODE (LEVELING_SETTINGS_BACK + ENABLED(PREHEAT_BEFORE_LEVELING)) - #define LEVELING_SETTINGS_HOTENDTEMP (LEVELING_SETTINGS_LEVELTEMP_MODE + ENABLED(PREHEAT_BEFORE_LEVELING)) - #define LEVELING_SETTINGS_BEDTEMP (LEVELING_SETTINGS_HOTENDTEMP + ENABLED(PREHEAT_BEFORE_LEVELING)) - #define LEVELING_SETTINGS_FADE (LEVELING_SETTINGS_BEDTEMP + 1) - #define LEVELING_SETTINGS_TILT (LEVELING_SETTINGS_FADE + ENABLED(AUTO_BED_LEVELING_UBL)) - #define LEVELING_SETTINGS_PLANE (LEVELING_SETTINGS_TILT + ENABLED(AUTO_BED_LEVELING_UBL)) - #define LEVELING_SETTINGS_ZERO (LEVELING_SETTINGS_PLANE + ENABLED(AUTO_BED_LEVELING_UBL)) - #define LEVELING_SETTINGS_UNDEF (LEVELING_SETTINGS_ZERO + ENABLED(AUTO_BED_LEVELING_UBL)) - #define LEVELING_SETTINGS_TOTAL LEVELING_SETTINGS_UNDEF - - switch (item) { - case LEVELING_SETTINGS_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else - Draw_Menu(Leveling, LEVELING_SETTINGS); - break; - #if ENABLED(PREHEAT_BEFORE_LEVELING) - case LEVELING_SETTINGS_LEVELTEMP_MODE: - if (draw) { - Draw_Menu_Item(row, ICON_Homing, F("Preheat Mode")); - Draw_Option(temp_val.LevelingTempmode, preheat_levmodes, row); - } - else - Modify_Option(temp_val.LevelingTempmode, preheat_levmodes, 3); - break; - case LEVELING_SETTINGS_HOTENDTEMP: - if (draw) { - Draw_Menu_Item(row, ICON_SetEndTemp, F("Preheat Hotend")); - Draw_Float(eeprom_settings.hotend_levtemp, row, false, 1); - } - else - Modify_Value(eeprom_settings.hotend_levtemp, MIN_E_TEMP, MAX_E_TEMP, 1); - break; - case LEVELING_SETTINGS_BEDTEMP: - if (draw) { - Draw_Menu_Item(row, ICON_SetBedTemp, F("Preheat Bed")); - Draw_Float(eeprom_settings.bed_levtemp, row, false, 1); - } - else - Modify_Value(eeprom_settings.bed_levtemp, MIN_BED_TEMP, MAX_BED_TEMP, 1); - break; - #endif - case LEVELING_SETTINGS_FADE: - if (draw) { - Draw_Menu_Item(row, ICON_Fade, GET_TEXT_F(MSG_Z_FADE_HEIGHT)); - Draw_Float(planner.z_fade_height, row, false, 1); - } - else { - Modify_Value(planner.z_fade_height, 0, Z_MAX_POS, 1); - planner.z_fade_height = -1; - set_z_fade_height(planner.z_fade_height); - } - break; - - #if ENABLED(AUTO_BED_LEVELING_UBL) - - case LEVELING_SETTINGS_TILT: - if (draw) { - Draw_Menu_Item(row, ICON_Tilt, F("Tilting Grid")); - Draw_Float(mesh_conf.tilt_grid, row, false, 1); - } - else - Modify_Value(mesh_conf.tilt_grid, 1, 8, 1); - break; - - case LEVELING_SETTINGS_PLANE: - if (draw) - Draw_Menu_Item(row, ICON_ResumeEEPROM, F("Convert Mesh to Plane")); - else { - if (mesh_conf.create_plane_from_mesh()) break; - gcode.process_subcommands_now(F("M420 S1")); - planner.synchronize(); - AudioFeedback(true); - } - break; - - case LEVELING_SETTINGS_ZERO: - if (draw) - Draw_Menu_Item(row, ICON_Mesh, F("Zero Current Mesh")); - else - ZERO(bedlevel.z_values); - break; - - case LEVELING_SETTINGS_UNDEF: - if (draw) - Draw_Menu_Item(row, ICON_Mesh, F("Clear Current Mesh")); - else - bedlevel.invalidate(); - break; - - #endif // AUTO_BED_LEVELING_UBL - } - break; - - case MeshViewer: - #define MESHVIEW_BACK 0 - #define MESHVIEW_TOTAL MESHVIEW_BACK - - if (item == MESHVIEW_BACK) { - if (draw) { - Draw_Menu_Item(0, ICON_Back, GET_TEXT_F(MSG_BACK)); - mesh_conf.Draw_Bed_Mesh(); - mesh_conf.Set_Mesh_Viewer_Status(); - } - else if (!mesh_conf.drawing_mesh) { - Draw_Menu(LevelView, LEVELING_VIEW_MESH); - Update_Status(""); - } - } - break; - - case LevelManual: - - #define LEVELING_M_BACK 0 - #define LEVELING_M_X (LEVELING_M_BACK + 1) - #define LEVELING_M_Y (LEVELING_M_X + 1) - #define LEVELING_M_NEXT (LEVELING_M_Y + 1) - #define LEVELING_M_OFFSET (LEVELING_M_NEXT + 1) - #define LEVELING_M_UP (LEVELING_M_OFFSET + 1) - #define LEVELING_M_DOWN (LEVELING_M_UP + 1) - #define LEVELING_M_GOTO_VALUE (LEVELING_M_DOWN + 1) - #define LEVELING_M_UNDEF (LEVELING_M_GOTO_VALUE + ENABLED(AUTO_BED_LEVELING_UBL)) - #define LEVELING_M_TOTAL LEVELING_M_UNDEF - - switch (item) { - case LEVELING_M_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else { - set_bed_leveling_enabled(level_state); - TERN_(AUTO_BED_LEVELING_BILINEAR, bedlevel.refresh_bed_level()); - Draw_Menu(Leveling, LEVELING_MANUAL); - } - break; - case LEVELING_M_X: - if (draw) { - Draw_Menu_Item(row, ICON_MoveX, GET_TEXT_F(MSG_MESH_X)); - Draw_Float(mesh_conf.mesh_x, row, 0, 1); - } - else - Modify_Value(mesh_conf.mesh_x, 0, GRID_MAX_POINTS_X - 1, 1); - break; - case LEVELING_M_Y: - if (draw) { - Draw_Menu_Item(row, ICON_MoveY, GET_TEXT_F(MSG_MESH_Y)); - Draw_Float(mesh_conf.mesh_y, row, 0, 1); - } - else - Modify_Value(mesh_conf.mesh_y, 0, GRID_MAX_POINTS_Y - 1, 1); - break; - case LEVELING_M_NEXT: - if (draw) - Draw_Menu_Item(row, ICON_More, GET_TEXT_F(MSG_LEVEL_BED_NEXT_POINT)); - else { - if (mesh_conf.mesh_x != (GRID_MAX_POINTS_X - 1) || mesh_conf.mesh_y != (GRID_MAX_POINTS_Y - 1)) { - if ((mesh_conf.mesh_x == (GRID_MAX_POINTS_X - 1) && !(mesh_conf.mesh_y & 1)) || (!mesh_conf.mesh_x && (mesh_conf.mesh_y & 1))) - mesh_conf.mesh_y++; - else if (mesh_conf.mesh_y & 1) - mesh_conf.mesh_x--; - else - mesh_conf.mesh_x++; - mesh_conf.manual_mesh_move(); - } - } - break; - case LEVELING_M_OFFSET: - if (draw) { - Draw_Menu_Item(row, ICON_SetZOffset, F("Point Z Offset")); - Draw_Float(bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], row, false, 100); - } - else { - if (isnan(bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y])) - bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] = 0; - Modify_Value(bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], MIN_Z_OFFSET, MAX_Z_OFFSET, 100); - } - break; - case LEVELING_M_UP: - if (draw) - Draw_Menu_Item(row, ICON_Axis, F("Microstep Up")); - else if (bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] < MAX_Z_OFFSET) { - bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] += 0.01; - gcode.process_subcommands_now(F("M290 Z0.01")); - planner.synchronize(); - current_position.z += 0.01f; - sync_plan_position(); - Draw_Float(bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 1, false, 100); - } - break; - case LEVELING_M_DOWN: - if (draw) - Draw_Menu_Item(row, ICON_AxisD, F("Microstep Down")); - else if (bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] > MIN_Z_OFFSET) { - bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] -= 0.01; - gcode.process_subcommands_now(F("M290 Z-0.01")); - planner.synchronize(); - current_position.z -= 0.01f; - sync_plan_position(); - Draw_Float(bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 2, false, 100); - } - break; - case LEVELING_M_GOTO_VALUE: - if (draw) { - Draw_Menu_Item(row, ICON_StockConfiguration, F("Go to Mesh Z Value")); - Draw_Checkbox(row, mesh_conf.goto_mesh_value); - } - else { - mesh_conf.goto_mesh_value = !mesh_conf.goto_mesh_value; - current_position.z = 0; - mesh_conf.manual_mesh_move(true); - Draw_Checkbox(row, mesh_conf.goto_mesh_value); - } - break; - #if ENABLED(AUTO_BED_LEVELING_UBL) - case LEVELING_M_UNDEF: - if (draw) - Draw_Menu_Item(row, ICON_ResumeEEPROM, F("Clear Point Value")); - else { - mesh_conf.manual_value_update(true); - Redraw_Menu(false); - } - break; - #endif - } - break; - #endif // HAS_MESH - - #if ENABLED(AUTO_BED_LEVELING_UBL) && !HAS_BED_PROBE - case UBLMesh: - - #define UBL_M_BACK 0 - #define UBL_M_NEXT (UBL_M_BACK + 1) - #define UBL_M_PREV (UBL_M_NEXT + 1) - #define UBL_M_OFFSET (UBL_M_PREV + 1) - #define UBL_M_UP (UBL_M_OFFSET + 1) - #define UBL_M_DOWN (UBL_M_UP + 1) - #define UBL_M_TOTAL UBL_M_DOWN - - switch (item) { - case UBL_M_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else { - set_bed_leveling_enabled(level_state); - Draw_Menu(Leveling, LEVELING_GET_MESH); - } - break; - case UBL_M_NEXT: - if (draw) { - if (mesh_conf.mesh_x != (GRID_MAX_POINTS_X - 1) || mesh_conf.mesh_y != (GRID_MAX_POINTS_Y - 1)) - Draw_Menu_Item(row, ICON_More, GET_TEXT_F(MSG_LEVEL_BED_NEXT_POINT)); - else - Draw_Menu_Item(row, ICON_More, GET_TEXT_F(MSG_UBL_SAVE_MESH)); - } - else { - if (mesh_conf.mesh_x != (GRID_MAX_POINTS_X - 1) || mesh_conf.mesh_y != (GRID_MAX_POINTS_Y - 1)) { - if ((mesh_conf.mesh_x == (GRID_MAX_POINTS_X - 1) && !(mesh_conf.mesh_y & 1)) || (!mesh_conf.mesh_x && (mesh_conf.mesh_y & 1))) - mesh_conf.mesh_y++; - else if (mesh_conf.mesh_y & 1) - mesh_conf.mesh_x--; - else - mesh_conf.mesh_x++; - mesh_conf.manual_mesh_move(); - } - else { - gcode.process_subcommands_now(F("G29 S")); - planner.synchronize(); - AudioFeedback(true); - Draw_Menu(Leveling, LEVELING_GET_MESH); - } - } - break; - case UBL_M_PREV: - if (draw) - Draw_Menu_Item(row, ICON_More, F("Previous Point")); - else { - if (mesh_conf.mesh_x != 0 || mesh_conf.mesh_y != 0) { - if ((mesh_conf.mesh_x == (GRID_MAX_POINTS_X - 1) && (mesh_conf.mesh_y & 1)) || (!mesh_conf.mesh_x && !(mesh_conf.mesh_y & 1))) - mesh_conf.mesh_y--; - else if (mesh_conf.mesh_y & 1) - mesh_conf.mesh_x++; - else - mesh_conf.mesh_x--; - mesh_conf.manual_mesh_move(); - } - } - break; - case UBL_M_OFFSET: - if (draw) { - Draw_Menu_Item(row, ICON_SetZOffset, F("Point Z Offset")); - Draw_Float(bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], row, false, 100); - } - else { - if (isnan(bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y])) - bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] = 0; - Modify_Value(bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], MIN_Z_OFFSET, MAX_Z_OFFSET, 100); - } - break; - case UBL_M_UP: - if (draw) - Draw_Menu_Item(row, ICON_Axis, F("Microstep Up")); - else if (bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] < MAX_Z_OFFSET) { - bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] += 0.01; - gcode.process_subcommands_now(F("M290 Z0.01")); - planner.synchronize(); - current_position.z += 0.01f; - sync_plan_position(); - Draw_Float(bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 1, false, 100); - } - break; - case UBL_M_DOWN: - if (draw) - Draw_Menu_Item(row, ICON_Axis, F("Microstep Down")); - else if (bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] > MIN_Z_OFFSET) { - bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] -= 0.01; - gcode.process_subcommands_now(F("M290 Z-0.01")); - planner.synchronize(); - current_position.z -= 0.01f; - sync_plan_position(); - Draw_Float(bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 2, false, 100); - } - break; - } - break; - #endif // AUTO_BED_LEVELING_UBL && !HAS_BED_PROBE - - #if ENABLED(PROBE_MANUALLY) - case ManualMesh: - - #define MMESH_BACK 0 - #define MMESH_NEXT (MMESH_BACK + 1) - #define MMESH_OFFSET (MMESH_NEXT + 1) - #define MMESH_UP (MMESH_OFFSET + 1) - #define MMESH_DOWN (MMESH_UP + 1) - #define MMESH_OLD (MMESH_DOWN + 1) - #define MMESH_TOTAL MMESH_OLD - - switch (item) { - case MMESH_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BUTTON_CANCEL)); - else { - gcode.process_subcommands_now(F("G29 A")); - planner.synchronize(); - set_bed_leveling_enabled(level_state); - Draw_Menu(Leveling, LEVELING_GET_MESH); - } - break; - case MMESH_NEXT: - if (draw) { - if (temp_val.gridpoint < GRID_MAX_POINTS) - Draw_Menu_Item(row, ICON_More, GET_TEXT_F(MSG_LEVEL_BED_NEXT_POINT)); - else - Draw_Menu_Item(row, ICON_More, GET_TEXT_F(MSG_UBL_SAVE_MESH)); - } - else if (temp_val.gridpoint < GRID_MAX_POINTS) { - Popup_Handler(MoveWait); - gcode.process_subcommands_now(F("G29")); - planner.synchronize(); - temp_val.gridpoint++; - Redraw_Menu(); - } - else { - gcode.process_subcommands_now(F("G29")); - planner.synchronize(); - AudioFeedback(settings.save()); - Draw_Menu(Leveling, LEVELING_GET_MESH); - } - break; - case MMESH_OFFSET: - if (draw) { - Draw_Menu_Item(row, ICON_SetZOffset, F("Z Position")); - current_position.z = MANUAL_PROBE_START_Z; - Draw_Float(current_position.z, row, false, 100); - } - else - Modify_Value(current_position.z, MIN_Z_OFFSET, MAX_Z_OFFSET, 100); - break; - case MMESH_UP: - if (draw) - Draw_Menu_Item(row, ICON_Axis, F("Microstep Up")); - else if (current_position.z < MAX_Z_OFFSET) { - gcode.process_subcommands_now(F("M290 Z0.01")); - planner.synchronize(); - current_position.z += 0.01f; - sync_plan_position(); - Draw_Float(current_position.z, row - 1, false, 100); - } - break; - case MMESH_DOWN: - if (draw) - Draw_Menu_Item(row, ICON_AxisD, F("Microstep Down")); - else if (current_position.z > MIN_Z_OFFSET) { - gcode.process_subcommands_now(F("M290 Z-0.01")); - planner.synchronize(); - current_position.z -= 0.01f; - sync_plan_position(); - Draw_Float(current_position.z, row - 2, false, 100); - } - break; - case MMESH_OLD: - uint8_t mesh_x, mesh_y; - // 0,0 -> 1,0 -> 2,0 -> 2,1 -> 1,1 -> 0,1 -> 0,2 -> 1,2 -> 2,2 - mesh_y = (temp_val.gridpoint - 1) / (GRID_MAX_POINTS_Y); - mesh_x = (temp_val.gridpoint - 1) % (GRID_MAX_POINTS_X); - - if (mesh_y & 1) - mesh_x = (GRID_MAX_POINTS_X) - mesh_x - 1; - - const float currval = bedlevel.z_values[mesh_x][mesh_y]; - - if (draw) { - Draw_Menu_Item(row, ICON_Zoffset, GET_TEXT_F(MSG_MESH_EDIT_Z)); - Draw_Float(currval, row, false, 100); - } - else if (!isnan(currval)) { - current_position.z = currval; - planner.synchronize(); - planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder); - planner.synchronize(); - Draw_Float(current_position.z, row - 3, false, 100); - } - break; - } - break; - #endif // PROBE_MANUALLY - - case Tune: - - #define TUNE_BACK 0 - #define TUNE_SPEED (TUNE_BACK + 1) - #define TUNE_FLOW (TUNE_SPEED + ENABLED(HAS_HOTEND)) - #define TUNE_HOTEND (TUNE_FLOW + ENABLED(HAS_HOTEND)) - #define TUNE_BED (TUNE_HOTEND + ENABLED(HAS_HEATED_BED)) - #define TUNE_FAN (TUNE_BED + ENABLED(HAS_FAN)) - #define TUNE_ZOFFSET (TUNE_FAN + ENABLED(HAS_ZOFFSET_ITEM)) - #define TUNE_ZUP (TUNE_ZOFFSET + ENABLED(HAS_ZOFFSET_ITEM)) - #define TUNE_ZDOWN (TUNE_ZUP + ENABLED(HAS_ZOFFSET_ITEM)) - #define TUNE_FWRETRACT (TUNE_ZDOWN + ENABLED(FWRETRACT)) - #define TUNE_HOSTACTIONS (TUNE_FWRETRACT + ENABLED(HAS_HOSTACTION_MENUS)) - #define TUNE_CHANGEFIL (TUNE_HOSTACTIONS + ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)) - #define TUNE_FILSENSORENABLED (TUNE_CHANGEFIL + ENABLED(FILAMENT_RUNOUT_SENSOR)) - #define TUNE_BACKLIGHT_OFF (TUNE_FILSENSORENABLED + 1) - #define TUNE_BACKLIGHT (TUNE_BACKLIGHT_OFF + 1) - #define TUNE_CASELIGHT (TUNE_BACKLIGHT + ENABLED(CASE_LIGHT_MENU)) - #define TUNE_LEDCONTROL (TUNE_CASELIGHT + (ENABLED(LED_CONTROL_MENU) && DISABLED(CASE_LIGHT_USE_NEOPIXEL))) - #define TUNE_LOCKSCREEN (TUNE_LEDCONTROL + ENABLED(HAS_LOCKSCREEN)) - #define TUNE_TOTAL TUNE_LOCKSCREEN - - switch (item) { - case TUNE_BACK: - if (draw) Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BACK)); - else Draw_Print_Screen(); - break; - case TUNE_SPEED: - if (draw) { - Draw_Menu_Item(row, ICON_Speed, GET_TEXT_F(MSG_SPEED)); - Draw_Float(feedrate_percentage, row, false, 1); - } - else - Modify_Value(feedrate_percentage, MIN_PRINT_SPEED, MAX_PRINT_SPEED, 1); - break; - - #if HAS_HOTEND - case TUNE_FLOW: - if (draw) { - Draw_Menu_Item(row, ICON_Speed, GET_TEXT_F(MSG_FLOW)); - Draw_Float(planner.flow_percentage[0], row, false, 1); - } - else - Modify_Value(planner.flow_percentage[0], MIN_FLOW_RATE, MAX_FLOW_RATE, 1); - break; - case TUNE_HOTEND: - if (draw) { - Draw_Menu_Item(row, ICON_SetEndTemp, F("Hotend")); - Draw_Float(thermalManager.temp_hotend[0].target, row, false, 1); - } - else - Modify_Value(thermalManager.temp_hotend[0].target, MIN_E_TEMP, MAX_E_TEMP, 1); - break; - #endif - - #if HAS_HEATED_BED - case TUNE_BED: - if (draw) { - Draw_Menu_Item(row, ICON_SetBedTemp, F("Bed")); - Draw_Float(thermalManager.temp_bed.target, row, false, 1); - } - else - Modify_Value(thermalManager.temp_bed.target, MIN_BED_TEMP, MAX_BED_TEMP, 1); - break; - #endif - - #if HAS_FAN - case TUNE_FAN: - if (draw) { - Draw_Menu_Item(row, ICON_FanSpeed, GET_TEXT_F(MSG_FAN_SPEED)); - Draw_Float(thermalManager.fan_speed[0], row, false, 1); - } - else - Modify_Value(thermalManager.fan_speed[0], MIN_FAN_SPEED, MAX_FAN_SPEED, 1); - break; - #endif - - #if HAS_ZOFFSET_ITEM - case TUNE_ZOFFSET: - if (draw) { - Draw_Menu_Item(row, ICON_FanSpeed, F("Z-Offset")); - Draw_Float(temp_val.zoffsetvalue, row, false, 100); - } - else - Modify_Value(temp_val.zoffsetvalue, MIN_Z_OFFSET, MAX_Z_OFFSET, 100); - break; - case TUNE_ZUP: - if (draw) - Draw_Menu_Item(row, ICON_Axis, F("Z-Offset Up")); - else if (temp_val.zoffsetvalue < MAX_Z_OFFSET) { - gcode.process_subcommands_now(F("M290 Z0.01")); - temp_val.zoffsetvalue += 0.01; - Draw_Float(temp_val.zoffsetvalue, row - 1, false, 100); - } - break; - case TUNE_ZDOWN: - if (draw) - Draw_Menu_Item(row, ICON_AxisD, F("Z-Offset Down")); - else if (temp_val.zoffsetvalue > MIN_Z_OFFSET) { - gcode.process_subcommands_now(F("M290 Z-0.01")); - temp_val.zoffsetvalue -= 0.01; - Draw_Float(temp_val.zoffsetvalue, row - 2, false, 100); - } - break; - #endif - - #if ENABLED(FWRETRACT) - case TUNE_FWRETRACT: - if (draw) - Draw_Menu_Item(row, ICON_StepE, GET_TEXT_F(MSG_AUTORETRACT), nullptr, true); - else { - temp_val.flag_tune = true; - last_pos_selection = selection; - Draw_Menu(FwRetraction); - } - break; - #endif - - #if HAS_HOSTACTION_MENUS - case TUNE_HOSTACTIONS: - if (draw) - Draw_Menu_Item(row, ICON_SetHome, F("Host Actions"), nullptr, true); - else { - temp_val.flag_tune = true; - last_pos_selection = selection; - Draw_Menu(HostActions); - } - break; - #endif - - #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) - case TUNE_CHANGEFIL: - if (draw) Draw_Menu_Item(row, ICON_ResumeEEPROM, GET_TEXT_F(MSG_FILAMENTCHANGE)); - else Popup_Handler(ConfFilChange); - break; - #endif - - #if ENABLED(FILAMENT_RUNOUT_SENSOR) - case TUNE_FILSENSORENABLED: - if (draw) { - Draw_Menu_Item(row, ICON_Extruder, GET_TEXT_F(MSG_RUNOUT_SENSOR)); - Draw_Checkbox(row, runout.enabled); - } - else { - runout.enabled = !runout.enabled; - Draw_Checkbox(row, runout.enabled); - } - break; - #endif - - case TUNE_BACKLIGHT_OFF: - if (draw) Draw_Menu_Item(row, ICON_Brightness, GET_TEXT_F(MSG_BRIGHTNESS_OFF)); - else ui.set_brightness(0); - break; - case TUNE_BACKLIGHT: - if (draw) { - Draw_Menu_Item(row, ICON_Brightness, GET_TEXT_F(MSG_BRIGHTNESS)); - Draw_Float(ui.brightness, row, false, 1); - } - else - Modify_Value(ui.brightness, LCD_BRIGHTNESS_MIN, LCD_BRIGHTNESS_MAX, 1, ui.refresh_brightness); - break; - #if ENABLED(CASE_LIGHT_MENU) - case TUNE_CASELIGHT: - if (draw) { - Draw_Menu_Item(row, ICON_CaseLight, GET_TEXT_F(MSG_CASE_LIGHT)); - Draw_Checkbox(row, caselight.on); - } - else { - caselight.on = !caselight.on; - caselight.update_enabled(); - Draw_Checkbox(row, caselight.on); - } - break; - #endif - #if ENABLED(LED_CONTROL_MENU) && DISABLED(CASE_LIGHT_USE_NEOPIXEL) - case TUNE_LEDCONTROL: - if (draw) { - Draw_Menu_Item(row, ICON_LedControl, GET_TEXT_F(MSG_LEDS)); - Draw_Checkbox(row, leds.lights_on); - } - else { - leds.toggle(); - Draw_Checkbox(row, leds.lights_on); - } - break; - #endif - #if HAS_LOCKSCREEN - case TUNE_LOCKSCREEN: - if (draw) Draw_Menu_Item(row, ICON_Lock, GET_TEXT_F(MSG_LOCKSCREEN)); - else DWIN_LockScreen(); - break; - #endif - } - break; - - #if HAS_PREHEAT && HAS_HOTEND - case PreheatHotend: - - #define PREHEATHOTEND_BACK 0 - #define PREHEATHOTEND_CONTINUE (PREHEATHOTEND_BACK + 1) - #define PREHEATHOTEND_1 (PREHEATHOTEND_CONTINUE + (PREHEAT_COUNT >= 1)) - #define PREHEATHOTEND_2 (PREHEATHOTEND_1 + (PREHEAT_COUNT >= 2)) - #define PREHEATHOTEND_3 (PREHEATHOTEND_2 + (PREHEAT_COUNT >= 3)) - #define PREHEATHOTEND_4 (PREHEATHOTEND_3 + (PREHEAT_COUNT >= 4)) - #define PREHEATHOTEND_5 (PREHEATHOTEND_4 + (PREHEAT_COUNT >= 5)) - #define PREHEATHOTEND_CUSTOM (PREHEATHOTEND_5 + 1) - #define PREHEATHOTEND_TOTAL PREHEATHOTEND_CUSTOM - - switch (item) { - case PREHEATHOTEND_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, GET_TEXT_F(MSG_BUTTON_CANCEL)); - else { - thermalManager.setTargetHotend(0, 0); - thermalManager.set_fan_speed(0, 0); - Redraw_Menu(false, true, true); - } - break; - case PREHEATHOTEND_CONTINUE: - if (draw) - Draw_Menu_Item(row, ICON_SetEndTemp, GET_TEXT_F(MSG_BUTTON_CONTINUE)); - else { - Popup_Handler(Heating); - thermalManager.wait_for_hotend(0); - switch (last_menu) { - case Prepare: - Popup_Handler(FilChange); - sprintf_P(cmd, PSTR("M600 B1 R%i"), thermalManager.temp_hotend[0].target); - gcode.process_subcommands_now(cmd); - Draw_Menu(Prepare, PREPARE_CHANGEFIL); - break; - #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) - case ChangeFilament: - switch (last_selection) { - case CHANGEFIL_LOAD: - Popup_Handler(FilLoad); - Update_Status(GET_TEXT(MSG_FILAMENTLOAD)); - gcode.process_subcommands_now(F("M701")); - planner.synchronize(); - Draw_Menu(ChangeFilament, CHANGEFIL_LOAD); - break; - case CHANGEFIL_UNLOAD: - Popup_Handler(FilLoad, true); - Update_Status(GET_TEXT(MSG_FILAMENTUNLOAD)); - gcode.process_subcommands_now(F("M702")); - planner.synchronize(); - Draw_Menu(ChangeFilament, CHANGEFIL_UNLOAD); - break; - case CHANGEFIL_CHANGE: - Popup_Handler(FilChange); - Update_Status(GET_TEXT(MSG_FILAMENTCHANGE)); - sprintf_P(cmd, PSTR("M600 B1 R%i"), thermalManager.temp_hotend[0].target); - gcode.process_subcommands_now(cmd); - Draw_Menu(ChangeFilament, CHANGEFIL_CHANGE); - break; - } - break; - #endif - default: - Redraw_Menu(true, true, true); - break; - } - } - break; - - #define _PREHEAT_HOTEND_CASE(N) \ - case PREHEATHOTEND_##N: \ - if (draw) Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_## N ##_LABEL)); \ - else ui.preheat_hotend_and_fan((N) - 1); \ - break; - - REPEAT_1(PREHEAT_COUNT, _PREHEAT_HOTEND_CASE) - - case PREHEATHOTEND_CUSTOM: - if (draw) { - Draw_Menu_Item(row, ICON_Temperature, GET_TEXT_F(MSG_PREHEAT_CUSTOM)); - Draw_Float(thermalManager.temp_hotend[0].target, row, false, 1); - } - else - Modify_Value(thermalManager.temp_hotend[0].target, EXTRUDE_MINTEMP, MAX_E_TEMP, 1); - break; - } - break; - - #endif // HAS_PREHEAT && HAS_HOTEND - } -} - -FSTR_P CrealityDWINClass::Get_Menu_Title(uint8_t menu) { - switch (menu) { - case MainMenu: return GET_TEXT_F(MSG_MAIN); - case Prepare: return GET_TEXT_F(MSG_PREPARE); - case HomeMenu: return GET_TEXT_F(MSG_HOMING); - case Move: return GET_TEXT_F(MSG_MOVE_AXIS); - case ManualLevel: return GET_TEXT_F(MSG_BED_TRAMMING_MANUAL); - #if HAS_ZOFFSET_ITEM - case ZOffset: return F("Z Offset"); - #endif - #if HAS_PREHEAT - case Preheat: return F("Preheat"); - #endif - #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) - case ChangeFilament: return GET_TEXT_F(MSG_FILAMENTCHANGE); - #endif - #if HAS_HOSTACTION_MENUS - case HostActions: return F("Host Actions"); - #endif - #if HAS_CUSTOM_MENU - case MenuCustom: - #ifdef CUSTOM_MENU_CONFIG_TITLE - return F(CUSTOM_MENU_CONFIG_TITLE); - #else - return F("Custom Commands"); - #endif - #endif - case Control: return GET_TEXT_F(MSG_CONTROL); - case TempMenu: return GET_TEXT_F(MSG_TEMPERATURE); - #if HAS_HOTEND || HAS_HEATED_BED - case PID: return F("PID Menu"); - #endif - #if HAS_HOTEND - case HotendPID: return F("Hotend PID Settings"); - #endif - #if HAS_HEATED_BED - case BedPID: return F("Bed PID Settings"); - #endif - #if HAS_PREHEAT - #define _PREHEAT_TITLE_CASE(N) case Preheat##N: return F(PREHEAT_## N ##_LABEL " Settings"); - REPEAT_1(PREHEAT_COUNT, _PREHEAT_TITLE_CASE) - #endif - case Motion: return F("Motion Settings"); - #if ENABLED(FWRETRACT) - case FwRetraction: return F("Firmware Retract"); - #endif - case HomeOffsets: return GET_TEXT_F(MSG_SET_HOME_OFFSETS); - case MaxSpeed: return GET_TEXT_F(MSG_SPEED); - case MaxAcceleration: return GET_TEXT_F(MSG_ACCELERATION); - #if HAS_CLASSIC_JERK - case MaxJerk: return GET_TEXT_F(MSG_JERK); - #endif - #if HAS_JUNCTION_DEVIATION - case JDmenu: return GET_TEXT_F(MSG_JUNCTION_DEVIATION); - #endif - case Steps: return GET_TEXT_F(MSG_STEPS_PER_MM); - case Visual: return F("Visual Settings"); - #if HAS_HOSTACTION_MENUS - case HostSettings: return F("Host Settings"); - case ActionCommands: return F("Host Actions"); - #endif - case Advanced: return GET_TEXT_F(MSG_ADVANCED_SETTINGS); - #if HAS_BED_PROBE - case ProbeMenu: return GET_TEXT_F(MSG_ZPROBE_SETTINGS); - #endif - case ColorSettings: return F("UI Color Settings"); - case Info: - case InfoMain: return GET_TEXT_F(MSG_INFO_SCREEN); - #if HAS_MESH - case Leveling: return GET_TEXT_F(MSG_BED_LEVELING); - case LevelView: return GET_TEXT_F(MSG_MESH_VIEW); - case LevelSettings: return F("Leveling Settings"); - case MeshViewer: return GET_TEXT_F(MSG_MESH_VIEW); - case LevelManual: return GET_TEXT_F(MSG_UBL_FINE_TUNE_MESH); - #endif - #if ENABLED(AUTO_BED_LEVELING_UBL) && !HAS_BED_PROBE - case UBLMesh: return GET_TEXT_F(MSG_UBL_LEVEL_BED); - #endif - #if ENABLED(PROBE_MANUALLY) - case ManualMesh: return GET_TEXT_F(MSG_MESH_LEVELING); - #endif - case Tune: return GET_TEXT_F(MSG_TUNE); - case PreheatHotend: return F("Preheat Hotend"); - #if ANY(CASE_LIGHT_MENU, LED_CONTROL_MENU) - case Ledsmenu: return F("Light Settings"); - #if ENABLED(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS) - case CaseLightmenu: return GET_TEXT_F(MSG_CASE_LIGHT); - #endif - #if ENABLED(LED_CONTROL_MENU) - case LedControlmenu: return GET_TEXT_F(MSG_LED_CONTROL); - #if HAS_COLOR_LEDS - #if ENABLED(LED_COLOR_PRESETS) - case LedControlpresets: return GET_TEXT_F(MSG_LED_PRESETS); - #else - case LedControlcustom: return GET_TEXT_F(MSG_CUSTOM_LEDS); - #endif - #endif - #endif - #endif - } - return F(""); -} - -uint8_t CrealityDWINClass::Get_Menu_Size(uint8_t menu) { - switch (menu) { - case Prepare: return PREPARE_TOTAL; - case HomeMenu: return HOME_TOTAL; - case Move: return MOVE_TOTAL; - case ManualLevel: return MLEVEL_TOTAL; - #if HAS_ZOFFSET_ITEM - case ZOffset: return ZOFFSET_TOTAL; - #endif - #if HAS_PREHEAT - case Preheat: return PREHEAT_TOTAL; - #endif - #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) - case ChangeFilament: return CHANGEFIL_TOTAL; - #endif - #if HAS_HOSTACTION_MENUS - case HostActions: return HOSTACTIONS_TOTAL; - #endif - #if HAS_CUSTOM_MENU - case MenuCustom: return CUSTOM_MENU_TOTAL; - #endif - case Control: return CONTROL_TOTAL; - case TempMenu: return TEMP_TOTAL; - #if HAS_HOTEND || HAS_HEATED_BED - case PID: return PID_TOTAL; - #endif - #if HAS_HOTEND - case HotendPID: return HOTENDPID_TOTAL; - #endif - #if HAS_HEATED_BED - case BedPID: return BEDPID_TOTAL; - #endif - #if HAS_PREHEAT - case Preheat1 ... CAT(Preheat, PREHEAT_COUNT): - return PREHEAT_SUBMENU_TOTAL; - #endif - case Motion: return MOTION_TOTAL; - #if ENABLED(FWRETRACT) - case FwRetraction: return FWR_TOTAL; - #endif - case HomeOffsets: return HOMEOFFSETS_TOTAL; - case MaxSpeed: return SPEED_TOTAL; - case MaxAcceleration: return ACCEL_TOTAL; - #if HAS_CLASSIC_JERK - case MaxJerk: return JERK_TOTAL; - #endif - #if HAS_JUNCTION_DEVIATION - case JDmenu: return JD_TOTAL; - #endif - case Steps: return STEPS_TOTAL; - case Visual: return VISUAL_TOTAL; - #if HAS_HOSTACTION_MENUS - case HostSettings: return HOSTSETTINGS_TOTAL; - case ActionCommands: return ACTIONCOMMANDS_TOTAL; - #endif - case Advanced: return ADVANCED_TOTAL; - #if HAS_BED_PROBE - case ProbeMenu: return PROBE_TOTAL; - #endif - case Info: return INFO_TOTAL; - case InfoMain: return INFO_TOTAL; - #if ENABLED(AUTO_BED_LEVELING_UBL) && !HAS_BED_PROBE - case UBLMesh: return UBL_M_TOTAL; - #endif - #if ENABLED(PROBE_MANUALLY) - case ManualMesh: return MMESH_TOTAL; - #endif - #if HAS_MESH - case Leveling: return LEVELING_TOTAL; - case LevelView: return LEVELING_VIEW_TOTAL; - case LevelSettings: return LEVELING_SETTINGS_TOTAL; - case MeshViewer: return MESHVIEW_TOTAL; - case LevelManual: return LEVELING_M_TOTAL; - #endif - case Tune: return TUNE_TOTAL; - - #if HAS_PREHEAT && HAS_HOTEND - case PreheatHotend: return PREHEATHOTEND_TOTAL; - #endif - - case ColorSettings: return COLORSETTINGS_TOTAL; - #if ANY(CASE_LIGHT_MENU, LED_CONTROL_MENU) - case Ledsmenu: return LEDS_TOTAL; - #if ENABLED(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS) - case CaseLightmenu: return CASE_LIGHT_TOTAL; - #endif - #if ENABLED(LED_CONTROL_MENU) - case LedControlmenu: return LEDCONTROL_TOTAL; - #if HAS_COLOR_LEDS - #if ENABLED(LED_COLOR_PRESETS) - case LedControlpresets: return LEDCONTROL_PRESETS_TOTAL; - #else - case LedControlcustom: return LEDCONTROL_CUSTOM_TOTAL; - #endif - #endif - #endif - #endif - } - return 0; -} - -/* Popup Config */ - -void CrealityDWINClass::Popup_Handler(PopupID popupid, bool option/*=false*/) { - popup = last_popup = popupid; - switch (popupid) { - case Pause: Draw_Popup(GET_TEXT_F(MSG_PAUSE_PRINT), F(""), F(""), Popup); break; - case Stop: Draw_Popup(GET_TEXT_F(MSG_STOP_PRINT), F(""), F(""), Popup); break; - case Resume: Draw_Popup(GET_TEXT_F(MSG_RESUME_PRINT), F("Looks Like the last"), F("print was interrupted."), Popup); break; - case ConfFilChange: Draw_Popup(F("Confirm Filament Change"), F(""), F(""), Popup); break; - case PurgeMore: Draw_Popup(F("Purge more filament?"), F("(Cancel to finish process)"), F(""), Popup); break; - case SaveLevel: Draw_Popup(F("Leveling Complete"), F("Save to EEPROM?"), F(""), Popup); break; - case MeshSlot: Draw_Popup(F("Mesh slot not selected"), F("(Confirm to select slot 0)"), F(""), Popup); break; - case ETemp: Draw_Popup(GET_TEXT_F(MSG_HOTEND_TOO_COLD), GET_TEXT_F(MSG_PLEASE_PREHEAT), F(""), Popup); break; - case ManualProbing: Draw_Popup(F("Manual Probing"), F("(Confirm to probe)"), F("(cancel to exit)"), Popup); break; - case Level: Draw_Popup(F("Auto Bed Leveling"), GET_TEXT_F(MSG_PLEASE_WAIT), F(""), Wait, ICON_AutoLeveling); break; - case Home: Draw_Popup(option ? GET_TEXT_F(MSG_PAUSE_PRINT_PARKING) : GET_TEXT_F(MSG_HOMING), GET_TEXT_F(MSG_PLEASE_WAIT), F(""), Wait, ICON_BLTouch); break; - case MoveWait: Draw_Popup(GET_TEXT_F(MSG_MOVING), GET_TEXT_F(MSG_PLEASE_WAIT), F(""), Wait, ICON_BLTouch); break; - case Heating: Draw_Popup(GET_TEXT_F(MSG_HEATING), GET_TEXT_F(MSG_PLEASE_WAIT), F(""), Wait, ICON_BLTouch); break; - case FilLoad: Draw_Popup(option ? F("Unloading Filament") : F("Loading Filament"), GET_TEXT_F(MSG_PLEASE_WAIT), F(""), Wait, ICON_BLTouch); break; - case FilChange: Draw_Popup(F("Filament Change"), F("Please wait for prompt."), F(""), Wait, ICON_BLTouch); break; - case TempWarn: Draw_Popup(option ? GET_TEXT_F(MSG_HOTEND_TOO_COLD) : F("Nozzle temp too high!"), F(""), F(""), Wait, option ? ICON_TempTooLow : ICON_TempTooHigh); break; - case Runout: Draw_Popup(F("Filament Runout"), F(""), F(""), Wait, ICON_BLTouch); break; - #if !HAS_PIDPLOT - case PIDWait: Draw_Popup(F("PID Autotune"), F("in process"), GET_TEXT_F(MSG_PLEASE_WAIT), Wait, ICON_BLTouch); break; - #endif - case Resuming: Draw_Popup(F("Resuming Print"), GET_TEXT_F(MSG_PLEASE_WAIT), F(""), Wait, ICON_BLTouch); break; - #if HAS_CUSTOM_MENU - case Custom: Draw_Popup(F("Running Custom GCode"), GET_TEXT_F(MSG_PLEASE_WAIT), F(""), Wait, ICON_BLTouch); break; - #endif - case PrintConfirm: Draw_Popup(option ? F("") : F("Print file?"), F(""), F(""), Popup); break; - default: break; - } -} - -void CrealityDWINClass::Confirm_Handler(PopupID popupid, bool option/*=false*/) { - popup = popupid; - switch (popupid) { - case FilInsert: Draw_Popup(F("Insert Filament"), F("Press to Continue"), F(""), Confirm); break; - case HeaterTime: Draw_Popup(GET_TEXT_F(MSG_HEATER_TIMEOUT), GET_TEXT_F(MSG_FILAMENT_CHANGE_HEAT), F(""), Confirm); break; - case UserInput: Draw_Popup(option ? GET_TEXT_F(MSG_STOPPED) : F("Waiting for Input"), GET_TEXT_F(MSG_ADVANCED_PAUSE_WAITING), F(""), Confirm); break; - case Level: Draw_Popup(F("Bed Leveling"), GET_TEXT_F(MSG_PLEASE_WAIT), F(""), Cancel, ICON_AutoLeveling); break; - case LevelError: Draw_Popup(F("Couldn't enable Leveling"), F("(Valid mesh must exist)"), F(""), Confirm); break; - case InvalidMesh: Draw_Popup(F("Valid mesh must exist"), F("before tuning can be"), F("performed"), Confirm); break; - default: break; - } -} - -/* Navigation and Control */ - -void CrealityDWINClass::Main_Menu_Control() { - EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); - if (encoder_diffState == ENCODER_DIFF_NO) return; - if (encoder_diffState == ENCODER_DIFF_CW && selection < PAGE_COUNT - 1) { - selection++; // Select Down - Main_Menu_Icons(); - } - else if (encoder_diffState == ENCODER_DIFF_CCW && selection > 0) { - selection--; // Select Up - Main_Menu_Icons(); - } - else if (encoder_diffState == ENCODER_DIFF_ENTER) - switch (selection) { - case PAGE_PRINT: card.mount(); Draw_SD_List(); break; - case PAGE_PREPARE: Draw_Menu(Prepare); break; - case PAGE_CONTROL: Draw_Menu(Control); break; - case PAGE_INFO_LEVELING: Draw_Menu(TERN(HAS_MESH, Leveling, InfoMain)); break; - } - DWIN_UpdateLCD(); -} - -void CrealityDWINClass::Menu_Control() { - EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); - if (encoder_diffState == ENCODER_DIFF_NO) return; - if (encoder_diffState == ENCODER_DIFF_CW && selection < Get_Menu_Size(active_menu)) { - DWIN_Draw_Rectangle(1, Def_Background_Color, 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); - selection++; // Select Down - if (selection > scrollpos+MROWS) { - scrollpos++; - DWIN_Frame_AreaMove(1, 2, MLINE, Def_Background_Color, 0, 31, DWIN_WIDTH, 349); - Menu_Item_Handler(active_menu, selection); - } - DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Def_Cursor_color), 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); - } - else if (encoder_diffState == ENCODER_DIFF_CCW && selection > 0) { - DWIN_Draw_Rectangle(1, Def_Background_Color, 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); - selection--; // Select Up - if (selection < scrollpos) { - scrollpos--; - DWIN_Frame_AreaMove(1, 3, MLINE, Def_Background_Color, 0, 31, DWIN_WIDTH, 349); - Menu_Item_Handler(active_menu, selection); - } - DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Def_Cursor_color), 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); - } - else if (encoder_diffState == ENCODER_DIFF_ENTER) - Menu_Item_Handler(active_menu, selection, false); - DWIN_UpdateLCD(); -} - -void CrealityDWINClass::Value_Control() { - EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); - float difvalue = 0; - if (encoder_diffState == ENCODER_DIFF_NO) return; - if (encoder_diffState == ENCODER_DIFF_CW) { - tempvalue += EncoderRate.encoderMoveValue; - difvalue = EncoderRate.encoderMoveValue; - } - else if (encoder_diffState == ENCODER_DIFF_CCW) { - tempvalue -= EncoderRate.encoderMoveValue; - difvalue = - EncoderRate.encoderMoveValue; - } - else if (encoder_diffState == ENCODER_DIFF_ENTER) { - process = Menu; - EncoderRate.enabled = false; - Draw_Float(tempvalue / valueunit, selection - scrollpos, false, valueunit); - DWIN_UpdateLCD(); - if (active_menu == ZOffset && temp_val.zoffsetmode != 0) { - planner.synchronize(); - if (temp_val.zoffsetmode == 1) { - current_position.z += (tempvalue / valueunit - temp_val.zoffsetvalue); - planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder); - } - current_position.z = 0; - sync_plan_position(); - } - else if (active_menu == Tune && selection == TUNE_ZOFFSET) { - sprintf_P(cmd, PSTR("M290 Z%s"), dtostrf((tempvalue / valueunit - temp_val.zoffsetvalue), 1, 3, str_1)); - gcode.process_subcommands_now(cmd); - } - if (TERN0(HAS_HOTEND, valuepointer == &thermalManager.temp_hotend[0].pid.Ki) || TERN0(HAS_HEATED_BED, valuepointer == &thermalManager.temp_bed.pid.Ki)) - tempvalue = scalePID_i(tempvalue); - if (TERN0(HAS_HOTEND, valuepointer == &thermalManager.temp_hotend[0].pid.Kd) || TERN0(HAS_HEATED_BED, valuepointer == &thermalManager.temp_bed.pid.Kd)) - tempvalue = scalePID_d(tempvalue); - switch (valuetype) { - case 0: *(float*)valuepointer = tempvalue / valueunit; break; - case 1: *(uint8_t*)valuepointer = tempvalue / valueunit; break; - case 2: *(uint16_t*)valuepointer = tempvalue / valueunit; break; - case 3: *(int16_t*)valuepointer = tempvalue / valueunit; break; - case 4: *(uint32_t*)valuepointer = tempvalue / valueunit; break; - case 5: *(int8_t*)valuepointer = tempvalue / valueunit; break; - } - switch (active_menu) { - case Move: - planner.synchronize(); - planner.buffer_line(current_position, manual_feedrate_mm_s[selection - 1], active_extruder); - break; - #if HAS_MESH - #if ENABLED(PROBE_MANUALLY) - case ManualMesh: - planner.synchronize(); - planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder); - planner.synchronize(); - break; - #endif - #if ENABLED(AUTO_BED_LEVELING_UBL) && !HAS_BED_PROBE - case UBLMesh: mesh_conf.manual_mesh_move(true); break; - #endif - case LevelManual: mesh_conf.manual_mesh_move(selection == LEVELING_M_OFFSET); break; - #endif - } - if (valuepointer == &planner.flow_percentage[0]) - planner.refresh_e_factor(0); - #if ENABLED(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS) - if (valuepointer == &caselight.brightness) - caselight.update_brightness(); - #endif - #if HAS_COLOR_LEDS - if ((valuepointer == &leds.color.r) || (valuepointer == &leds.color.g) || (valuepointer == &leds.color.b)) - ApplyLEDColor(); - #if HAS_WHITE_LED - if (valuepointer == &leds.color.w) ApplyLEDColor(); - #endif - #endif - - if (funcpointer) funcpointer(); - return; - } - NOLESS(tempvalue, (valuemin * valueunit)); - NOMORE(tempvalue, (valuemax * valueunit)); - Draw_Float(tempvalue / valueunit, selection - scrollpos, true, valueunit); - DWIN_UpdateLCD(); - - if (valuepointer == &ui.brightness) { - *(uint8_t*)valuepointer = tempvalue / valueunit; - ui.refresh_brightness(); - } - - switch (active_menu) { - case Move: - if (temp_val.livemove) { - *(float*)valuepointer = tempvalue / valueunit; - planner.buffer_line(current_position, manual_feedrate_mm_s[selection - 1], active_extruder); - } - break; - case ZOffset: - if (temp_val.zoffsetmode == 2) { - planner.synchronize(); - sprintf_P(cmd, PSTR("M290 Z%s"), dtostrf((difvalue / valueunit), 1, 3, str_1)); - gcode.process_subcommands_now(cmd); - planner.synchronize(); - } - break; - case Tune: - if (selection == TUNE_ZOFFSET) { - planner.synchronize(); - sprintf_P(cmd, PSTR("M290 Z%s"), dtostrf((difvalue / valueunit), 1, 3, str_1)); - gcode.process_subcommands_now(cmd); - planner.synchronize(); - } - break; - #if ENABLED(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS) - case CaseLightmenu: - *(uint8_t*)valuepointer = tempvalue / valueunit; - caselight.update_brightness(); - break; - #endif - #if ENABLED(LED_CONTROL_MENU, HAS_COLOR_LEDS) - case LedControlmenu: - *(uint8_t*)valuepointer = tempvalue / valueunit; - leds.update(); - break; - #endif - default : break; - } -} - -void CrealityDWINClass::Option_Control() { - EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); - if (encoder_diffState == ENCODER_DIFF_NO) return; - if (encoder_diffState == ENCODER_DIFF_CW) - tempvalue += EncoderRate.encoderMoveValue; - else if (encoder_diffState == ENCODER_DIFF_CCW) - tempvalue -= EncoderRate.encoderMoveValue; - else if (encoder_diffState == ENCODER_DIFF_ENTER) { - process = Menu; - EncoderRate.enabled = false; - if (valuepointer == &color_names) { - switch (selection) { - case COLORSETTINGS_CURSOR: eeprom_settings.cursor_color = tempvalue; break; - case COLORSETTINGS_SPLIT_LINE: eeprom_settings.menu_split_line = tempvalue; break; - case COLORSETTINGS_MENU_TOP_BG: eeprom_settings.menu_top_bg = tempvalue; break; - case COLORSETTINGS_MENU_TOP_TXT: eeprom_settings.menu_top_txt = tempvalue; break; - case COLORSETTINGS_HIGHLIGHT_BORDER: eeprom_settings.highlight_box = tempvalue; break; - case COLORSETTINGS_PROGRESS_PERCENT: eeprom_settings.progress_percent = tempvalue; break; - case COLORSETTINGS_PROGRESS_TIME: eeprom_settings.progress_time = tempvalue; break; - case COLORSETTINGS_PROGRESS_STATUS_BAR: eeprom_settings.status_bar_text = tempvalue; break; - case COLORSETTINGS_PROGRESS_STATUS_AREA: eeprom_settings.status_area_text = tempvalue; break; - case COLORSETTINGS_PROGRESS_COORDINATES: eeprom_settings.coordinates_text = tempvalue; break; - case COLORSETTINGS_PROGRESS_COORDINATES_LINE: eeprom_settings.coordinates_split_line = tempvalue; break; - } - Redraw_Screen(); - } - else if (valuepointer == &preheat_modes) - temp_val.preheatmode = tempvalue; - #if ENABLED(PREHEAT_BEFORE_LEVELING) - else if (valuepointer == &preheat_levmodes) { - temp_val.LevelingTempmode = tempvalue; - eeprom_settings.ena_hotend_levtemp = false; - eeprom_settings.ena_bed_levtemp = false; - if (temp_val.LevelingTempmode == 0 || temp_val.LevelingTempmode == 1) eeprom_settings.ena_hotend_levtemp = true; - if (temp_val.LevelingTempmode == 0 || temp_val.LevelingTempmode == 2) eeprom_settings.ena_bed_levtemp = true; - } - #endif - else if (valuepointer == &zoffset_modes) { - temp_val.zoffsetmode = tempvalue; - if (temp_val.zoffsetmode == 1 || temp_val.zoffsetmode == 2) { - if (axes_should_home()) { - Popup_Handler(Home); - gcode.home_all_axes(true); - } - Popup_Handler(MoveWait); - #if ENABLED(Z_SAFE_HOMING) - planner.synchronize(); - sprintf_P(cmd, PSTR("G0 F4000 X%s Y%s"), dtostrf(Z_SAFE_HOMING_X_POINT, 1, 3, str_1), dtostrf(Z_SAFE_HOMING_Y_POINT, 1, 3, str_2)); - gcode.process_subcommands_now(cmd); - #else - sprintf_P(cmd, PSTR("G0 F4000 X%s Y%s"), dtostrf((X_BED_SIZE + X_MIN_POS) / 2.0f, 1, 3, str_1), dtostrf((Y_BED_SIZE + Y_MIN_POS) / 2.0f, 1, 3, str_2)); - gcode.process_subcommands_now(cmd); - #endif - gcode.process_subcommands_now(F("G0 F300 Z0")); - planner.synchronize(); - Redraw_Menu(); - } - } - - Draw_Option(tempvalue, static_cast(valuepointer), selection - scrollpos, false, (valuepointer == &color_names)); - DWIN_UpdateLCD(); - return; - } - NOLESS(tempvalue, valuemin); - NOMORE(tempvalue, valuemax); - Draw_Option(tempvalue, static_cast(valuepointer), selection - scrollpos, true); - DWIN_UpdateLCD(); -} - -void CrealityDWINClass::File_Control() { - EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); - static uint8_t filescrl = 0; - if (encoder_diffState == ENCODER_DIFF_NO) { - if (selection > 0) { - card.getfilename_sorted(SD_ORDER(selection - 1, card.get_num_Files())); - char * const filename = card.longest_filename(); - size_t len = strlen(filename); - int8_t pos = len; - if (!card.flag.filenameIsDir) - while (pos && filename[pos] != '.') pos--; - if (pos > MENU_CHAR_LIMIT) { - static millis_t time = 0; - if (PENDING(millis(), time)) return; - time = millis() + 200; - pos -= filescrl; - len = _MIN(pos, MENU_CHAR_LIMIT); - char name[len + 1]; - if (pos >= 0) { - LOOP_L_N(i, len) name[i] = filename[i + filescrl]; - } - else { - LOOP_L_N(i, MENU_CHAR_LIMIT + pos) name[i] = ' '; - LOOP_S_L_N(i, MENU_CHAR_LIMIT + pos, MENU_CHAR_LIMIT) name[i] = filename[i - (MENU_CHAR_LIMIT + pos)]; - } - name[len] = '\0'; - DWIN_Draw_Rectangle(1, Def_Background_Color, LBLX, MBASE(selection - scrollpos) - 14, 271, MBASE(selection - scrollpos) + 28); - Draw_Menu_Item(selection - scrollpos, card.flag.filenameIsDir ? ICON_More : ICON_File, name); - if (-pos >= MENU_CHAR_LIMIT) filescrl = 0; - filescrl++; - DWIN_UpdateLCD(); - } - } - return; - } - if (encoder_diffState == ENCODER_DIFF_CW && selection < card.get_num_Files()) { - DWIN_Draw_Rectangle(1, Def_Background_Color, 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); - if (selection > 0) { - DWIN_Draw_Rectangle(1, Def_Background_Color, LBLX, MBASE(selection - scrollpos) - 14, 271, MBASE(selection - scrollpos) + 28); - Draw_SD_Item(selection, selection - scrollpos); - } - filescrl = 0; - selection++; // Select Down - if (selection > scrollpos + MROWS) { - scrollpos++; - DWIN_Frame_AreaMove(1, 2, MLINE, Def_Background_Color, 0, 31, DWIN_WIDTH, 349); - Draw_SD_Item(selection, selection - scrollpos); - } - DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Def_Cursor_color), 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); - } - else if (encoder_diffState == ENCODER_DIFF_CCW && selection > 0) { - DWIN_Draw_Rectangle(1, Def_Background_Color, 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); - DWIN_Draw_Rectangle(1, Def_Background_Color, LBLX, MBASE(selection - scrollpos) - 14, 271, MBASE(selection - scrollpos) + 28); - Draw_SD_Item(selection, selection - scrollpos); - filescrl = 0; - selection--; // Select Up - if (selection < scrollpos) { - scrollpos--; - DWIN_Frame_AreaMove(1, 3, MLINE, Def_Background_Color, 0, 31, DWIN_WIDTH, 349); - Draw_SD_Item(selection, selection - scrollpos); - } - DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Def_Cursor_color), 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); - } - else if (encoder_diffState == ENCODER_DIFF_ENTER) { - if (selection == 0) { - if (card.flag.workDirIsRoot) { - process = Main; - Draw_Main_Menu(); - } - else { - card.cdup(); - Draw_SD_List(); - } - } - else { - card.getfilename_sorted(SD_ORDER(selection - 1, card.get_num_Files())); - if (card.flag.filenameIsDir) { - card.cd(card.filename); - Draw_SD_List(); - } - else { - #if HAS_GCODE_PREVIEW - Preview_DrawFromSD(); - #else - card.openAndPrintFile(card.filename); - #endif - } - } - } - DWIN_UpdateLCD(); -} - -void CrealityDWINClass::Print_Screen_Control() { - EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); - if (encoder_diffState == ENCODER_DIFF_NO) return; - if (encoder_diffState == ENCODER_DIFF_CW && selection < PRINT_COUNT - 1) { - selection++; // Select Down - Print_Screen_Icons(); - } - else if (encoder_diffState == ENCODER_DIFF_CCW && selection > 0) { - selection--; // Select Up - Print_Screen_Icons(); - } - else if (encoder_diffState == ENCODER_DIFF_ENTER) { - switch (selection) { - case PRINT_SETUP: - Draw_Menu(Tune); - Update_Status_Bar(true); - break; - case PRINT_PAUSE_RESUME: - if (temp_val.paused) { - if (temp_val.sdprint) { - wait_for_user = false; - #if ENABLED(PARK_HEAD_ON_PAUSE) - card.startOrResumeFilePrinting(); - TERN_(POWER_LOSS_RECOVERY, recovery.prepare()); - #else - char cmd[20]; - #if HAS_HEATED_BED - sprintf_P(cmd, PSTR("M140 S%i"), temp_val.pausebed); - gcode.process_subcommands_now(cmd); - #endif - #if HAS_EXTRUDERS - sprintf_P(cmd, PSTR("M109 S%i"), temp_val.pausetemp); - gcode.process_subcommands_now(cmd); - #endif - TERN_(HAS_FAN, thermalManager.fan_speed[0] = temp_val.pausefan); - planner.synchronize(); - TERN_(SDSUPPORT, queue.inject(F("M24"))); - #endif - } - else { - TERN_(HOST_ACTION_COMMANDS, hostui.resume()); - } - Draw_Print_Screen(); - } - else - Popup_Handler(Pause); - break; - case PRINT_STOP: Popup_Handler(Stop); break; - } - } - DWIN_UpdateLCD(); -} - -void CrealityDWINClass::Popup_Control() { - EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); - if (encoder_diffState == ENCODER_DIFF_NO) return; - if (encoder_diffState == ENCODER_DIFF_CW && selection < 1) { - selection++; - Popup_Select(); - } - else if (encoder_diffState == ENCODER_DIFF_CCW && selection > 0) { - selection--; - Popup_Select(); - } - else if (encoder_diffState == ENCODER_DIFF_ENTER) { - switch (popup) { - case Pause: - if (selection == 0) { - if (temp_val.sdprint) { - #if ENABLED(POWER_LOSS_RECOVERY) - if (recovery.enabled) recovery.save(true); - #endif - #if ENABLED(PARK_HEAD_ON_PAUSE) - Popup_Handler(Home, true); - #if ENABLED(SDSUPPORT) - if (IS_SD_PRINTING()) card.pauseSDPrint(); - #endif - planner.synchronize(); - queue.inject(F("M125")); - planner.synchronize(); - #else - queue.inject(F("M25")); - TERN_(HAS_HOTEND, temp_val.pausetemp = thermalManager.temp_hotend[0].target); - TERN_(HAS_HEATED_BED, temp_val.pausebed = thermalManager.temp_bed.target); - TERN_(HAS_FAN, temp_val.pausefan = thermalManager.fan_speed[0]); - thermalManager.cooldown(); - #endif - } - else { - TERN_(HOST_ACTION_COMMANDS, hostui.pause()); - } - } - Draw_Print_Screen(); - break; - case Stop: - if (selection == 0) { - if (temp_val.sdprint) { - ui.abort_print(); - thermalManager.cooldown(); - } - else { - TERN_(HOST_ACTION_COMMANDS, hostui.cancel()); - } - } - else - Draw_Print_Screen(); - break; - case Resume: - if (selection == 0) - queue.inject(F("M1000")); - else { - queue.inject(F("M1000 C")); - Draw_Main_Menu(); - } - break; - - #if HAS_HOTEND - case ETemp: - if (selection == 0) { - thermalManager.setTargetHotend(EXTRUDE_MINTEMP, 0); - thermalManager.set_fan_speed(0, MAX_FAN_SPEED); - Draw_Menu(PreheatHotend); - } - else - Redraw_Menu(true, true, false); - break; - #endif - - #if HAS_BED_PROBE - case ManualProbing: - if (selection == 0) { - char buf[80]; - const float dif = probe.probe_at_point(current_position.x, current_position.y, PROBE_PT_STOW, 0, false) - temp_val.corner_avg; - sprintf_P(buf, dif > 0 ? PSTR("Corner is %smm high") : PSTR("Corner is %smm low"), dtostrf(abs(dif), 1, 3, str_1)); - Update_Status(buf); - } - else { - Redraw_Menu(true, true, false); - Update_Status(""); - } - break; - #endif - - #if ENABLED(ADVANCED_PAUSE_FEATURE) - case ConfFilChange: - if (selection == 0) { - if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) - Popup_Handler(ETemp); - else { - if (thermalManager.temp_hotend[0].is_below_target(-2)) { - Popup_Handler(Heating); - thermalManager.wait_for_hotend(0); - } - Popup_Handler(FilChange); - sprintf_P(cmd, PSTR("M600 B1 R%i"), thermalManager.temp_hotend[0].target); - gcode.process_subcommands_now(cmd); - } - } - else - Redraw_Menu(true, true, false); - break; - case PurgeMore: - if (selection == 0) { - pause_menu_response = PAUSE_RESPONSE_EXTRUDE_MORE; - Popup_Handler(FilChange); - } - else { - pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT; - if (temp_val.printing) Popup_Handler(Resuming); - else Redraw_Menu(true, true, (active_menu==PreheatHotend)); - } - break; - #endif // ADVANCED_PAUSE_FEATURE - - case PrintConfirm: - if (selection==0) { - card.openAndPrintFile(card.filename);} - else{ - Redraw_Menu(true, true, true); - gcode.process_subcommands_now(F("M117"));} - break; - - #if HAS_MESH - case SaveLevel: - if (selection == 0) { - #if ENABLED(AUTO_BED_LEVELING_UBL) - gcode.process_subcommands_now(F("G29 S")); - planner.synchronize(); - AudioFeedback(true); - #else - AudioFeedback(settings.save()); - #endif - } - Draw_Menu(Leveling, LEVELING_GET_MESH); - break; - #endif - - #if ENABLED(AUTO_BED_LEVELING_UBL) - case MeshSlot: - if (selection == 0) bedlevel.storage_slot = 0; - Redraw_Menu(true, true); - break; - #endif - default: break; - } - } - DWIN_UpdateLCD(); -} - -void CrealityDWINClass::Confirm_Control() { - EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); - if (encoder_diffState == ENCODER_DIFF_NO) return; - if (encoder_diffState == ENCODER_DIFF_ENTER) { - switch (popup) { - case Complete: - Draw_Main_Menu(); - break; - case FilInsert: - Popup_Handler(FilChange); - wait_for_user = false; - break; - case HeaterTime: - Popup_Handler(Heating); - Update_Status(GET_TEXT_F(MSG_HEATING)); - wait_for_user = false; - break; - #if HAS_ESDIAG - case ESDiagPopup: - wait_for_user = false; - Redraw_Menu(true, true, false); - break; - #endif - default: - Redraw_Menu(true, true, false); - wait_for_user = false; - break; - } - } - DWIN_UpdateLCD(); -} - -#if HAS_HOSTACTION_MENUS - - void CrealityDWINClass::Keyboard_Control() { - const uint8_t keyboard_size = 34; - static uint8_t key_selection = 0, cursor = 0; - static char string[31]; - static bool uppercase = false, locked = false; - if (reset_keyboard) { - if (strcmp(stringpointer, "-") == 0) stringpointer[0] = '\0'; - key_selection = 0, cursor = strlen(stringpointer); - uppercase = false, locked = false; - reset_keyboard = false; - strcpy(string, stringpointer); - } - EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); - if (encoder_diffState == ENCODER_DIFF_NO) return; - if (encoder_diffState == ENCODER_DIFF_CW && key_selection < keyboard_size) { - Draw_Keys(key_selection, false, uppercase, locked); - key_selection++; - Draw_Keys(key_selection, true, uppercase, locked); - } - else if (encoder_diffState == ENCODER_DIFF_CCW && key_selection > 0) { - Draw_Keys(key_selection, false, uppercase, locked); - key_selection--; - Draw_Keys(key_selection, true, uppercase, locked); - } - else if (encoder_diffState == ENCODER_DIFF_ENTER) { - if (key_selection < 28) { - if (key_selection == 19) { - if (!numeric_keyboard) { - if (locked) { - uppercase = false, locked = false; - Draw_Keyboard(keyboard_restrict, false, key_selection, uppercase, locked); - } else if (uppercase) { - locked = true; - Draw_Keyboard(keyboard_restrict, false, key_selection, uppercase, locked); - } - else { - uppercase = true; - Draw_Keyboard(keyboard_restrict, false, key_selection, uppercase, locked); - } - } - } - else if (key_selection == 27) { - cursor--; - string[cursor] = '\0'; - } - else { - uint8_t index = key_selection; - if (index > 19) index--; - if (index > 27) index--; - const char *keys; - if (numeric_keyboard) keys = "1234567890&<>() {}[]*\"\':;!?"; - else keys = (uppercase) ? "QWERTYUIOPASDFGHJKLZXCVBNM" : "qwertyuiopasdfghjklzxcvbnm"; - if (!(keyboard_restrict && numeric_keyboard && index > 9)) { - string[cursor] = keys[index]; - cursor++; - string[cursor] = '\0'; - } - if (!locked && uppercase) { - uppercase = false; - Draw_Keyboard(keyboard_restrict, false, key_selection, uppercase, locked); - } - } - } - else { - switch (key_selection) { - case 28: - if (!numeric_keyboard) uppercase = false, locked = false; - Draw_Keyboard(keyboard_restrict, !numeric_keyboard, key_selection, uppercase, locked); - break; - case 29: - string[cursor] = '-'; - cursor++; - string[cursor] = '\0'; - break; - case 30: - string[cursor] = '_'; - cursor++; - string[cursor] = '\0'; - break; - case 31: - if (!keyboard_restrict) { - string[cursor] = ' '; - cursor++; - string[cursor] = '\0'; - } - break; - case 32: - if (!keyboard_restrict) { - string[cursor] = '.'; - cursor++; - string[cursor] = '\0'; - } - break; - case 33: - if (!keyboard_restrict) { - string[cursor] = '/'; - cursor++; - string[cursor] = '\0'; - } - break; - case 34: - if (string[0] == '\0') strcpy(string, "-"); - strcpy(stringpointer, string); - process = Menu; - DWIN_Draw_Rectangle(1, Def_Background_Color, 0, KEY_Y_START, DWIN_WIDTH-2, DWIN_HEIGHT-2); - Draw_Status_Area(true); - Update_Status_Bar(true); - break; - } - } - if (strlen(string) > maxstringlen) string[maxstringlen] = '\0', cursor = maxstringlen; - Draw_String(string, selection, (process==Keyboard), (maxstringlen > 10)); - } - DWIN_UpdateLCD(); - } - -#endif // HAS_HOSTACTION_MENUS - -/* In-Menu Value Modification */ - -void CrealityDWINClass::Setup_Value(float value, float min, float max, float unit, uint8_t type) { - if (TERN0(HAS_HOTEND, valuepointer == &thermalManager.temp_hotend[0].pid.Ki) || TERN0(HAS_HEATED_BED, valuepointer == &thermalManager.temp_bed.pid.Ki)) - tempvalue = unscalePID_i(value) * unit; - else if (TERN0(HAS_HOTEND, valuepointer == &thermalManager.temp_hotend[0].pid.Kd) || TERN0(HAS_HEATED_BED, valuepointer == &thermalManager.temp_bed.pid.Kd)) - tempvalue = unscalePID_d(value) * unit; - else - tempvalue = value * unit; - valuemin = min; - valuemax = max; - valueunit = unit; - valuetype = type; - process = Value; - EncoderRate.enabled = true; - Draw_Float(tempvalue / unit, selection - scrollpos, true, valueunit); -} - -void CrealityDWINClass::Modify_Value(float &value, float min, float max, float unit, void (*f)()/*=nullptr*/) { - valuepointer = &value; - funcpointer = f; - Setup_Value((float)value, min, max, unit, 0); -} -void CrealityDWINClass::Modify_Value(uint8_t &value, float min, float max, float unit, void (*f)()/*=nullptr*/) { - valuepointer = &value; - funcpointer = f; - Setup_Value((float)value, min, max, unit, 1); -} -void CrealityDWINClass::Modify_Value(uint16_t &value, float min, float max, float unit, void (*f)()/*=nullptr*/) { - valuepointer = &value; - funcpointer = f; - Setup_Value((float)value, min, max, unit, 2); -} -void CrealityDWINClass::Modify_Value(int16_t &value, float min, float max, float unit, void (*f)()/*=nullptr*/) { - valuepointer = &value; - funcpointer = f; - Setup_Value((float)value, min, max, unit, 3); -} -void CrealityDWINClass::Modify_Value(uint32_t &value, float min, float max, float unit, void (*f)()/*=nullptr*/) { - valuepointer = &value; - funcpointer = f; - Setup_Value((float)value, min, max, unit, 4); -} -void CrealityDWINClass::Modify_Value(int8_t &value, float min, float max, float unit, void (*f)()/*=nullptr*/) { - valuepointer = &value; - funcpointer = f; - Setup_Value((float)value, min, max, unit, 5); -} - -void CrealityDWINClass::Modify_Option(uint8_t value, const char * const * options, uint8_t max) { - tempvalue = value; - valuepointer = const_cast(options); - valuemin = 0; - valuemax = max; - process = Option; - EncoderRate.enabled = true; - Draw_Option(value, options, selection - scrollpos, true); -} - -#if HAS_HOSTACTION_MENUS - void CrealityDWINClass::Modify_String(char * string, uint8_t maxlength, bool restrict) { - stringpointer = string; - maxstringlen = maxlength; - reset_keyboard = true; - Draw_Keyboard(restrict, false); - Draw_String(string, selection, true, (maxstringlen > 10)); - } -#endif - -/* Main Functions */ - -void CrealityDWINClass::Update_Print_Filename(const char * const text) { - LOOP_L_N(i, _MIN((size_t)LONG_FILENAME_LENGTH, strlen(text))) filename[i] = text[i]; - filename[_MIN((size_t)LONG_FILENAME_LENGTH - 1, strlen(text))] = '\0'; - Draw_Print_Filename(true); -} - -void CrealityDWINClass::Update_Status(const char * const text) { - LOOP_L_N(i, _MIN((size_t)64, strlen(text))) statusmsg[i] = text[i]; - statusmsg[_MIN((size_t)64, strlen(text))] = '\0'; -} - -void CrealityDWINClass::Update_Status(FSTR_P text) { - Update_Status(FTOP(text)); -} - -void CrealityDWINClass::Start_Print(bool sd) { - temp_val.sdprint = sd; - if (!temp_val.printing) { - temp_val.printing = true; - statusmsg[0] = '\0'; - if (sd) { - #if ENABLED(POWER_LOSS_RECOVERY) - if (recovery.valid()) { - SdFile *diveDir = nullptr; - const char * const fname = card.diveToFile(true, diveDir, recovery.info.sd_filename); - card.selectFileByName(fname); - } - #endif - strcpy(filename, card.longest_filename()); - } - TERN_(LCD_SET_PROGRESS_MANUALLY, ui.set_progress(0)); - TERN_(USE_M73_REMAINING_TIME, ui.set_remaining_time(0)); - Draw_Print_Screen(); - } -} - -void CrealityDWINClass::Stop_Print() { - temp_val.printing = false; - temp_val.sdprint = false; - thermalManager.cooldown(); - TERN_(LCD_SET_PROGRESS_MANUALLY, ui.set_progress(100 * (PROGRESS_SCALE))); - TERN_(USE_M73_REMAINING_TIME, ui.set_remaining_time(0)); - Draw_PrintDone_confirm(); - filename[0] = '\0'; -} - -void CrealityDWINClass::Update() { - State_Update(); - Screen_Update(); - switch (process) { - case Main: Main_Menu_Control(); break; - case Menu: Menu_Control(); break; - case Value: Value_Control(); break; - case Option: Option_Control(); break; - case File: File_Control(); break; - case Print: Print_Screen_Control(); break; - case Popup: Popup_Control(); break; - case Confirm: Confirm_Control(); break; - #if HAS_HOSTACTION_MENUS - case Keyboard: Keyboard_Control(); break; - #endif - case Cancel: Confirm_Control(); break; - #if HAS_LOCKSCREEN - case Locked: HMI_LockScreen(); break; - #endif - } -} - -void MarlinUI::update() { CrealityDWIN.Update(); } - -#if HAS_LCD_BRIGHTNESS - void MarlinUI::_set_brightness() { DWIN_LCD_Brightness(backlight ? brightness : 0); } -#endif - -void CrealityDWINClass::State_Update() { - if ((print_job_timer.isRunning() || print_job_timer.isPaused()) != temp_val.printing) { - if (!temp_val.printing) Start_Print(card.isFileOpen() || TERN0(POWER_LOSS_RECOVERY, recovery.valid())); - else Stop_Print(); - } - if (print_job_timer.isPaused() != temp_val.paused) { - temp_val.paused = print_job_timer.isPaused(); - if (process == Print) Print_Screen_Icons(); - if (process == Wait && !temp_val.paused) Redraw_Menu(true, true); - } - if (wait_for_user && !(process == Confirm) && !print_job_timer.isPaused()) - Confirm_Handler(UserInput); - #if ENABLED(ADVANCED_PAUSE_FEATURE) - if (process == Popup && popup == PurgeMore) { - if (pause_menu_response == PAUSE_RESPONSE_EXTRUDE_MORE) - Popup_Handler(FilChange); - else if (pause_menu_response == PAUSE_RESPONSE_RESUME_PRINT) { - if (temp_val.printing) Popup_Handler(Resuming); - else Redraw_Menu(true, true, (active_menu==PreheatHotend)); - } - } - #endif - #if ENABLED(FILAMENT_RUNOUT_SENSOR) - static bool ranout = false; - if (runout.filament_ran_out != ranout) { - ranout = runout.filament_ran_out; - if (ranout) Popup_Handler(Runout); - } - #endif -} - -void CrealityDWINClass::Screen_Update() { - const millis_t ms = millis(); - static millis_t scrltime = 0; - if (ELAPSED(ms, scrltime)) { - scrltime = ms + 200; - if (process != Keyboard) Update_Status_Bar(); - if (process == Print) Draw_Print_Filename(); - } - - static millis_t statustime = 0; - if (ELAPSED(ms, statustime) && process != Keyboard) { - statustime = ms + 500; - Draw_Status_Area(); - #if HAS_ESDIAG - if (process == Confirm && popup == ESDiagPopup) ESDiag.Update(); - #endif - #if HAS_PIDPLOT - if (process == Wait && (popup == PIDWaitH || popup == PIDWaitB)) Plot.Update((popup == PIDWaitH) ? thermalManager.wholeDegHotend(0) : thermalManager.wholeDegBed()); - #endif - } - - static millis_t printtime = 0; - if (ELAPSED(ms, printtime)) { - printtime = ms + 1000; - if (process == Print) { - Draw_Print_ProgressBar(); - Draw_Print_ProgressElapsed(); - TERN_(USE_M73_REMAINING_TIME, Draw_Print_ProgressRemain()); - } - } - - static bool mounted = card.isMounted(); - if (mounted != card.isMounted()) { - mounted = card.isMounted(); - if (process == File) - Draw_SD_List(); - } - - #if HAS_HOTEND - static int16_t hotendtarget = -1; - #endif - #if HAS_HEATED_BED - static int16_t bedtarget = -1; - #endif - #if HAS_FAN - static int16_t fanspeed = -1; - #endif - - #if HAS_ZOFFSET_ITEM - static float lastzoffset = temp_val.zoffsetvalue; - if (temp_val.zoffsetvalue != lastzoffset) { - lastzoffset = temp_val.zoffsetvalue; - #if HAS_BED_PROBE - probe.offset.z = temp_val.zoffsetvalue; - #else - set_home_offset(Z_AXIS, -temp_val.zoffsetvalue); - #endif - } - - #if HAS_BED_PROBE - if (probe.offset.z != lastzoffset) - temp_val.zoffsetvalue = lastzoffset = probe.offset.z; - #else - if (-home_offset.z != lastzoffset) - temp_val.zoffsetvalue = lastzoffset = -home_offset.z; - #endif - #endif // HAS_ZOFFSET_ITEM - - if (process == Menu || process == Value) { - switch (active_menu) { - case TempMenu: - #if HAS_HOTEND - if (thermalManager.temp_hotend[0].target != hotendtarget) { - hotendtarget = thermalManager.temp_hotend[0].target; - if (scrollpos <= TEMP_HOTEND && TEMP_HOTEND <= scrollpos + MROWS) { - if (process != Value || selection != TEMP_HOTEND - scrollpos) - Draw_Float(thermalManager.temp_hotend[0].target, TEMP_HOTEND - scrollpos, false, 1); - } - } - #endif - #if HAS_HEATED_BED - if (thermalManager.temp_bed.target != bedtarget) { - bedtarget = thermalManager.temp_bed.target; - if (scrollpos <= TEMP_BED && TEMP_BED <= scrollpos + MROWS) { - if (process != Value || selection != TEMP_HOTEND - scrollpos) - Draw_Float(thermalManager.temp_bed.target, TEMP_BED - scrollpos, false, 1); - } - } - #endif - #if HAS_FAN - if (thermalManager.fan_speed[0] != fanspeed) { - fanspeed = thermalManager.fan_speed[0]; - if (scrollpos <= TEMP_FAN && TEMP_FAN <= scrollpos + MROWS) { - if (process != Value || selection != TEMP_HOTEND - scrollpos) - Draw_Float(thermalManager.fan_speed[0], TEMP_FAN - scrollpos, false, 1); - } - } - #endif - break; - case Tune: - #if HAS_HOTEND - if (thermalManager.temp_hotend[0].target != hotendtarget) { - hotendtarget = thermalManager.temp_hotend[0].target; - if (scrollpos <= TUNE_HOTEND && TUNE_HOTEND <= scrollpos + MROWS) { - if (process != Value || selection != TEMP_HOTEND - scrollpos) - Draw_Float(thermalManager.temp_hotend[0].target, TUNE_HOTEND - scrollpos, false, 1); - } - } - #endif - #if HAS_HEATED_BED - if (thermalManager.temp_bed.target != bedtarget) { - bedtarget = thermalManager.temp_bed.target; - if (scrollpos <= TUNE_BED && TUNE_BED <= scrollpos + MROWS) { - if (process != Value || selection != TEMP_HOTEND - scrollpos) - Draw_Float(thermalManager.temp_bed.target, TUNE_BED - scrollpos, false, 1); - } - } - #endif - #if HAS_FAN - if (thermalManager.fan_speed[0] != fanspeed) { - fanspeed = thermalManager.fan_speed[0]; - if (scrollpos <= TUNE_FAN && TUNE_FAN <= scrollpos + MROWS) { - if (process != Value || selection != TEMP_HOTEND - scrollpos) - Draw_Float(thermalManager.fan_speed[0], TUNE_FAN - scrollpos, false, 1); - } - } - #endif - break; - } - } -} - -void CrealityDWINClass::AudioFeedback(const bool success/*=true*/) { - if (ui.sound_on) - DONE_BUZZ(success); - else - Update_Status(success ? "Success" : "Failed"); -} - -void CrealityDWINClass::Save_Settings(char *buff) { - TERN_(DEBUG_DWIN, SERIAL_ECHOLNPGM("Save_Settings")); - TERN_(AUTO_BED_LEVELING_UBL, eeprom_settings.tilt_grid_size = mesh_conf.tilt_grid - 1); - eeprom_settings.corner_pos = temp_val.corner_pos * 10; - #if HAS_HOSTACTION_MENUS - eeprom_settings.host_action_label_1 = Encode_String(action1); - eeprom_settings.host_action_label_2 = Encode_String(action2); - eeprom_settings.host_action_label_3 = Encode_String(action3); - #endif - TERN_(DEBUG_DWIN, SERIAL_ECHOLNPGM("eeprom_settings size: ", sizeof(eeprom_settings_t))); - memcpy(buff, &eeprom_settings, _MIN(sizeof(eeprom_settings), eeprom_data_size)); -} - -void CrealityDWINClass::Load_Settings(const char *buff) { - memcpy(&eeprom_settings, buff, _MIN(sizeof(eeprom_settings), eeprom_data_size)); - TERN_(AUTO_BED_LEVELING_UBL, mesh_conf.tilt_grid = eeprom_settings.tilt_grid_size + 1); - if (eeprom_settings.corner_pos == 0) eeprom_settings.corner_pos = 325; - temp_val.corner_pos = eeprom_settings.corner_pos / 10.0f; - #if ENABLED(BAUD_RATE_GCODE) - if (eeprom_settings.Baud115k) queue.inject(F("M575 P0 B115200")); - #endif - #if ENABLED(FWRETRACT) - temp_val.auto_fw_retract = fwretract.autoretract_enabled; - #endif - #if ENABLED(PREHEAT_BEFORE_LEVELING) - temp_val.LevelingTempmode = 2 * !eeprom_settings.ena_hotend_levtemp + !eeprom_settings.ena_bed_levtemp; - #endif - #if ENABLED(LED_CONTROL_MENU, HAS_COLOR_LEDS) - leds.set_color( - (temp_val.LED_Color >> 16) & 0xFF, - (temp_val.LED_Color >> 8) & 0xFF, - (temp_val.LED_Color >> 0) & 0xFF - OPTARG(HAS_WHITE_LED, (temp_val.LED_Color >> 24) & 0xFF) - ); - #endif - #if HAS_HOSTACTION_MENUS - Decode_String(eeprom_settings.host_action_label_1, action1); - Decode_String(eeprom_settings.host_action_label_2, action2); - Decode_String(eeprom_settings.host_action_label_3, action3); - #endif - Redraw_Screen(); - #if ENABLED(POWER_LOSS_RECOVERY) - static bool init = true; - if (init) { - init = false; - queue.inject(F("M1000 S")); - } - #endif -} - -void CrealityDWINClass::Reset_Settings() { - eeprom_settings.time_format_textual = false; - TERN_(AUTO_BED_LEVELING_UBL, eeprom_settings.tilt_grid_size = 0); - eeprom_settings.corner_pos = 325; - eeprom_settings.cursor_color = 0; - eeprom_settings.menu_split_line = 0; - eeprom_settings.menu_top_bg = 0; - eeprom_settings.menu_top_txt = 0; - eeprom_settings.highlight_box = 0; - eeprom_settings.progress_percent = 0; - eeprom_settings.progress_time = 0; - eeprom_settings.status_bar_text = 0; - eeprom_settings.status_area_text = 0; - eeprom_settings.coordinates_text = 0; - eeprom_settings.coordinates_split_line = 0; - TERN_(AUTO_BED_LEVELING_UBL, mesh_conf.tilt_grid = eeprom_settings.tilt_grid_size + 1); - temp_val.corner_pos = eeprom_settings.corner_pos / 10.0f; - TERN_(SOUND_MENU_ITEM, ui.sound_on = ENABLED(SOUND_ON_DEFAULT)); - TERN_(BAUD_RATE_GCODE, eeprom_settings.Baud115k = false); - TERN_(FWRETRACT, temp_val.auto_fw_retract = fwretract.autoretract_enabled); - #if ENABLED(PREHEAT_BEFORE_LEVELING) - eeprom_settings.ena_hotend_levtemp = true; - eeprom_settings.ena_bed_levtemp = true; - eeprom_settings.hotend_levtemp = LEVELING_NOZZLE_TEMP; - eeprom_settings.bed_levtemp = LEVELING_BED_TEMP; - #endif - #if ENABLED(LED_CONTROL_MENU, HAS_COLOR_LEDS) - leds.setup(); - #if ENABLED(LED_COLOR_PRESETS) - leds.set_default(); - #endif - temp_val.LED_Color = Def_Leds_Color; - leds.set_color( - (temp_val.LED_Color >> 16) & 0xFF, - (temp_val.LED_Color >> 8) & 0xFF, - (temp_val.LED_Color >> 0) & 0xFF - OPTARG(HAS_WHITE_LED, (temp_val.LED_Color >> 24) & 0xFF) - ); - #endif - #if HAS_HOSTACTION_MENUS - eeprom_settings.host_action_label_1 = 0; - eeprom_settings.host_action_label_2 = 0; - eeprom_settings.host_action_label_3 = 0; - action1[0] = action2[0] = action3[0] = '-'; - #endif - Redraw_Screen(); -} - -void CrealityDWINClass::PreheatBefore() { - #if ENABLED(PREHEAT_BEFORE_LEVELING) - Popup_Handler(Heating); - #if HAS_BED_PROBE - probe.preheat_for_probing(eeprom_settings.ena_hotend_levtemp, eeprom_settings.ena_bed_levtemp); - #else - #if HAS_HOTEND - if (thermalManager.degTargetHotend(0) < eeprom_settings.hotend_levtemp && (eeprom_settings.ena_hotend_levtemp)) - thermalManager.setTargetHotend(eeprom_settings.hotend_levtemp, 0); - #endif - #if HAS_HEATED_BED - if (thermalManager.degTargetBed() < eeprom_settings.bed_levtemp && (eeprom_settings.ena_bed_levtemp)) - thermalManager.setTargetBed(eeprom_settings.bed_levtemp); - #endif - TERN_(HAS_HOTEND, if (eeprom_settings.ena_hotend_levtemp) thermalManager.wait_for_hotend(0)); - TERN_(HAS_HEATED_BED, if (eeprom_settings.ena_bed_levtemp) thermalManager.wait_for_bed_heating()); - #endif - Update_Status(""); - #endif -} - -void MarlinUI::init_lcd() { - DWINUI::init(); - Encoder_Configuration(); - DWIN_JPG_ShowAndCache(0); - for (uint16_t t = 0; t <= 100; t += 2) { - DWINUI::DRAW_IconWB(ICON, ICON_Bar, 15, 260); - DWIN_Draw_Rectangle(1, Def_Background_Color, 15 + t * 242 / 100, 260, 257, 280); - DWIN_UpdateLCD(); - delay(20); - } - DWIN_JPG_CacheTo1(Language_English); - CrealityDWIN.Redraw_Screen(); -} - -#if ENABLED(ADVANCED_PAUSE_FEATURE) - void MarlinUI::pause_show_message(const PauseMessage message, const PauseMode mode/*=PAUSE_MODE_SAME*/, const uint8_t extruder/*=active_extruder*/) { - switch (message) { - case PAUSE_MESSAGE_INSERT: CrealityDWIN.Confirm_Handler(FilInsert); break; - case PAUSE_MESSAGE_PURGE: break; - case PAUSE_MESSAGE_OPTION: pause_menu_response = PAUSE_RESPONSE_WAIT_FOR; CrealityDWIN.Popup_Handler(PurgeMore); break; - case PAUSE_MESSAGE_HEAT: CrealityDWIN.Confirm_Handler(HeaterTime); break; - case PAUSE_MESSAGE_WAITING: CrealityDWIN.Draw_Print_Screen(); break; - default: break; - } - } -#endif - -// End-stops diagnostic from DWIN PROUI -#if HAS_ESDIAG - void CrealityDWINClass::DWIN_EndstopsDiag() { - last_process = process; - last_selection = selection; - process = Confirm; - popup = ESDiagPopup; - ESDiag.Draw(); - } -#endif - -// Lock screen from DWIN PROUI -#if HAS_LOCKSCREEN - void CrealityDWINClass::DWIN_LockScreen() { - if (process != Locked) { - lockScreen.rprocess = process; - process = Locked; - lockScreen.init(); - } - } - - void CrealityDWINClass::DWIN_UnLockScreen() { - if (process == Locked) { - process = lockScreen.rprocess; - if (!temp_val.printing) Draw_Main_Menu(); else Draw_Print_Screen(); - } - } - - void CrealityDWINClass::HMI_LockScreen() { - EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); - if (encoder_diffState == ENCODER_DIFF_NO) return; - lockScreen.onEncoder(encoder_diffState); - if (lockScreen.isUnlocked()) DWIN_UnLockScreen(); - } -#endif - -// Reboot screen from DWIN PROUI -void CrealityDWINClass::DWIN_RebootScreen() { - DWIN_Frame_Clear(Def_Background_Color); - DWIN_JPG_ShowAndCache(0); - DWINUI::Draw_CenteredString(Def_Text_Color, 220, GET_TEXT_F(MSG_PLEASE_WAIT_REBOOT)); - DWIN_UpdateLCD(); - delay(500); -} - -// Reboot Printer from DWIN PROUI -void CrealityDWINClass::RebootPrinter() { - wait_for_heatup = wait_for_user = false; // Stop waiting for heating/user - thermalManager.disable_all_heaters(); - planner.finish_and_disable(); - DWIN_RebootScreen(); - hal.reboot(); -} - -#if ENABLED(LED_CONTROL_MENU, HAS_COLOR_LEDS) - void CrealityDWINClass::ApplyLEDColor() { - temp_val.LED_Color = TERN0(HAS_WHITE_LED,(leds.color.w << 24)) | (leds.color.r << 16) | (leds.color.g << 8) | (leds.color.b); - } -#endif - -#if HAS_PIDPLOT - void CrealityDWINClass::DWIN_Draw_PIDPopup(const pidresult_t pidresult) { - frame_rect_t gfrm = {40, 160, DWIN_WIDTH - 80, 150}; - DWINUI::ClearMainArea(); - DWIN_Draw_Rectangle(1, Def_PopupBg_color, 14, 60, 258, 330); - DWIN_Draw_Rectangle(0, Def_Highlight_Color, 14, 60, 258, 330); - DWINUI::Draw_CenteredString(Def_PopupTxt_Color, 80, GET_TEXT_F(MSG_PID_AUTOTUNE)); - DWINUI::Draw_String(Def_PopupTxt_Color, gfrm.x, gfrm.y - DWINUI::fontHeight() - 4, F("PID target: Celsius")); - switch (pidresult) { - case PID_EXTR_START: - DWINUI::Draw_CenteredString(Def_PopupTxt_Color, 100, F("for Nozzle is running.")); - Plot.Draw(gfrm, thermalManager.hotend_maxtemp[0], temp_val.PID_e_temp); - DWINUI::Draw_Int(Def_PopupTxt_Color, 3, gfrm.x + 90, gfrm.y - DWINUI::fontHeight() - 4, temp_val.PID_e_temp); - break; - case PID_BED_START: - DWINUI::Draw_CenteredString(Def_PopupTxt_Color, 100, F("for BED is running.")); - Plot.Draw(gfrm, BED_MAXTEMP, temp_val.PID_bed_temp); - DWINUI::Draw_Int(Def_PopupTxt_Color, 3, gfrm.x + 90, gfrm.y - DWINUI::fontHeight() - 4, temp_val.PID_bed_temp); - break; - default: - break; - } - } -#endif - -#if HAS_PID_HEATING - void CrealityDWINClass::DWIN_PidTuning(const pidresult_t pidresult) { - switch (pidresult) { - case PID_STARTED: break; - #if HAS_PIDPLOT - case PID_EXTR_START: last_process = process; last_selection = selection; process = Wait; popup = PIDWaitH; DWIN_Draw_PIDPopup(pidresult); break; - case PID_BED_START: last_process = process; last_selection = selection; process = Wait; popup = PIDWaitB; DWIN_Draw_PIDPopup(pidresult); break; - #else - case PID_EXTR_START: Popup_Handler(PIDWait); break; - case PID_BED_START: Popup_Handler(PIDWait, true); break; - #endif - case PID_BAD_EXTRUDER_NUM: Confirm_Handler(BadextruderNumber); break; - case PID_TEMP_TOO_HIGH: Confirm_Handler(TempTooHigh); break; - case PID_TUNING_TIMEOUT: Confirm_Handler(PIDTimeout); break; - case PID_DONE: Confirm_Handler(PIDDone); break; - default: break; - } - } -#endif - -#endif // DWIN_CREALITY_LCD_JYERSUI diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.h b/Marlin/src/lcd/e3v2/jyersui/dwin.h deleted file mode 100644 index c42c0677dce1..000000000000 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.h +++ /dev/null @@ -1,283 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ -#pragma once - -/** - * lcd/e3v2/jyersui/dwin.h - * JYERSUI Author: Jacob Myers - * - * JYERSUI Enhanced by LCH-77 - * Version: 1.9 - * Date: Jun 16, 2022 - */ - -#include "dwin_defines.h" - -#include "../../../inc/MarlinConfig.h" - -enum processID : uint8_t { - Main, Print, Menu, Value, Option, File, Popup, Confirm, Wait, Locked, Cancel, Keyboard -}; - -enum PopupID : uint8_t { - Pause, Stop, Resume, SaveLevel, ETemp, ConfFilChange, PurgeMore, MeshSlot, - Level, Home, MoveWait, Heating, FilLoad, FilChange, TempWarn, Runout, Resuming, ManualProbing, - FilInsert, HeaterTime, UserInput, LevelError, InvalidMesh, UI, Complete, Custom, ESDiagPopup, PrintConfirm, - PIDWait, PIDWaitH, PIDWaitB, BadextruderNumber, TempTooHigh, PIDTimeout, PIDDone -}; - -enum menuID : uint8_t { - MainMenu, - Prepare, - Move, - HomeMenu, - ManualLevel, - ZOffset, - Preheat, - ChangeFilament, - HostActions, - MenuCustom, - Control, - TempMenu, - PID, - HotendPID, - BedPID, - #if HAS_PREHEAT - #define _PREHEAT_ID(N) Preheat##N, - REPEAT_1(PREHEAT_COUNT, _PREHEAT_ID) - #endif - Motion, - HomeOffsets, - MaxSpeed, - MaxAcceleration, - #if HAS_CLASSIC_JERK - MaxJerk, - #endif - #if HAS_JUNCTION_DEVIATION - JDmenu, - #endif - Steps, - #if ENABLED(FWRETRACT) - FwRetraction, - #endif - Visual, - ColorSettings, - HostSettings, - ActionCommands, - Advanced, - #if HAS_BED_PROBE - ProbeMenu, - #endif - Info, - #if HAS_MESH - Leveling, - LevelManual, - LevelView, - MeshViewer, - LevelSettings, - #if ENABLED(PROBE_MANUALLY) - ManualMesh, - #endif - #if ENABLED(AUTO_BED_LEVELING_UBL) && !HAS_BED_PROBE - UBLMesh, - #endif - #endif - InfoMain, - Tune, - PreheatHotend, - #if ANY(CASE_LIGHT_MENU, LED_CONTROL_MENU) - Ledsmenu, - #if BOTH(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS) - CaseLightmenu, - #endif - #if ENABLED(LED_CONTROL_MENU) - LedControlmenu, - #if HAS_COLOR_LEDS - #if ENABLED(LED_COLOR_PRESETS) - LedControlpresets, - #else - LedControlcustom, - #endif - #endif - #endif - #endif -}; - -typedef struct { - // Flags - bool flag_tune = false; - bool auto_fw_retract = false; - bool printing = false; - bool paused = false; - bool sdprint = false; - bool livemove = false; - bool liveadjust = false; - bool probe_deployed = false; - // Auxiliary values - AxisEnum axis = X_AXIS; // Axis Select - int16_t pausetemp = 0; - int16_t pausebed = 0; - int16_t pausefan = 0; - uint8_t preheatmode = 0; - uint8_t zoffsetmode = 0; - float zoffsetvalue = 0; - uint8_t gridpoint; - float corner_avg; - float corner_pos; - float zval; - #if ENABLED(PREHEAT_BEFORE_LEVELING) - uint8_t LevelingTempmode = 0; - #endif - #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS) - uint32_t LED_Color = Def_Leds_Color; - #endif - #if HAS_PID_HEATING - uint16_t PID_e_temp = 180; - uint16_t PID_bed_temp = 60; - #endif -} temp_val_t; -extern temp_val_t temp_val; - -#define Custom_Colors 10 -enum colorID : uint8_t { - Default, White, Green, Cyan, Blue, Magenta, Red, Orange, Yellow, Brown, Black -}; -enum pidresult_t : uint8_t { PID_STARTED, PID_EXTR_START, PID_BED_START, PID_BAD_EXTRUDER_NUM, PID_TEMP_TOO_HIGH, PID_TUNING_TIMEOUT, PID_DONE }; - -class CrealityDWINClass { -public: - static constexpr const char * const color_names[11] = { "Default", "White", "Green", "Cyan", "Blue", "Magenta", "Red", "Orange", "Yellow", "Brown", "Black" }; - static constexpr const char * const preheat_modes[3] = { "Both", "Hotend", "Bed" }; - static constexpr const char * const zoffset_modes[3] = { "No Live" , "OnClick", " Live" }; - #if ENABLED(PREHEAT_BEFORE_LEVELING) - static constexpr const char * const preheat_levmodes[4] = { " Both", " Hotend", " Bed", " None" }; - #endif - - static void Clear_Screen(uint8_t e=3); - static void Draw_Float(float value, uint8_t row, bool selected=false, uint8_t minunit=10); - static void Draw_Option(uint8_t value, const char * const * options, uint8_t row, bool selected=false, bool color=false); - static uint16_t GetColor(uint8_t color, uint16_t original, bool light=false); - static void Draw_Checkbox(uint8_t row, bool value); - static void Draw_Title(const char * title); - static void Draw_Title(FSTR_P const title); - static void Draw_Menu_Item(uint8_t row, uint8_t icon=0, const char * const label1=nullptr, const char * const label2=nullptr, bool more=false, bool centered=false); - static void Draw_Menu_Item(uint8_t row, uint8_t icon=0, FSTR_P const flabel1=nullptr, FSTR_P const flabel2=nullptr, bool more=false, bool centered=false); - static void Draw_Menu(uint8_t menu, uint8_t select=0, uint8_t scroll=0); - static void Redraw_Menu(bool lastprocess=true, bool lastselection=false, bool lastmenu=false); - static void Redraw_Screen(); - - static void Main_Menu_Icons(); - static void Draw_Main_Menu(uint8_t select=0); - static void Print_Screen_Icons(); - static void Draw_Print_Screen(); - static void Draw_Print_Filename(const bool reset=false); - static void Draw_Print_ProgressBar(); - #if ENABLED(USE_M73_REMAINING_TIME) - static void Draw_Print_ProgressRemain(); - #endif - static void Draw_Print_ProgressElapsed(); - static void Draw_PrintDone_confirm(); - static void Draw_SD_Item(uint8_t item, uint8_t row); - static void Draw_SD_List(bool removed=false); - static void Draw_Status_Area(bool icons=false); - static void Draw_Popup(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, uint8_t mode, uint8_t icon=0); - static void Popup_Select(); - static void Update_Status_Bar(bool refresh=false); - - #if ENABLED(AUTO_BED_LEVELING_UBL) - static void Draw_Bed_Mesh(int16_t selected = -1, uint8_t gridline_width = 1, uint16_t padding_x = 8, uint16_t padding_y_top = 40 + 53 - 7); - static void Set_Mesh_Viewer_Status(); - #endif - - static FSTR_P Get_Menu_Title(uint8_t menu); - static uint8_t Get_Menu_Size(uint8_t menu); - static void Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw=true); - - static void Popup_Handler(PopupID popupid, bool option=false); - static void Confirm_Handler(PopupID popupid, bool option=false); - - static void Main_Menu_Control(); - static void Menu_Control(); - static void Value_Control(); - static void Option_Control(); - static void File_Control(); - static void Print_Screen_Control(); - static void Popup_Control(); - static void Confirm_Control(); - - static void Setup_Value(float value, float min, float max, float unit, uint8_t type); - static void Modify_Value(float &value, float min, float max, float unit, void (*f)()=nullptr); - static void Modify_Value(uint8_t &value, float min, float max, float unit, void (*f)()=nullptr); - static void Modify_Value(uint16_t &value, float min, float max, float unit, void (*f)()=nullptr); - static void Modify_Value(int16_t &value, float min, float max, float unit, void (*f)()=nullptr); - static void Modify_Value(uint32_t &value, float min, float max, float unit, void (*f)()=nullptr); - static void Modify_Value(int8_t &value, float min, float max, float unit, void (*f)()=nullptr); - static void Modify_Option(uint8_t value, const char * const * options, uint8_t max); - - static void Update_Status(const char * const text); - static void Update_Status(FSTR_P text); - static void Start_Print(bool sd); - static void Stop_Print(); - static void Update(); - static void State_Update(); - static void Screen_Update(); - static void AudioFeedback(const bool success=true); - static void Save_Settings(char *buff); - static void Load_Settings(const char *buff); - static void Reset_Settings(); - static void PreheatBefore(); - - #if HAS_ESDIAG - static void DWIN_EndstopsDiag(); - #endif - #if HAS_LOCKSCREEN - static void DWIN_LockScreen(); - static void DWIN_UnLockScreen(); - static void HMI_LockScreen(); - #endif - static void DWIN_RebootScreen(); - static void RebootPrinter(); - static void Update_Print_Filename(const char * const text); - #if ENABLED(LED_CONTROL_MENU, HAS_COLOR_LEDS) - static void ApplyLEDColor(); - #endif - - #if HAS_HOSTACTION_MENUS - static void Draw_String(char * string, uint8_t row, bool selected=false, bool below=false); - static const uint64_t Encode_String(const char * string); - static void Decode_String(uint64_t num, char * string); - static void Draw_Keyboard(bool restrict, bool numeric, uint8_t selected=0, bool uppercase=false, bool lock=false); - static void Draw_Keys(uint8_t index, bool selected, bool uppercase=false, bool lock=false); - static void Modify_String(char * string, uint8_t maxlength, bool restrict); - static void Keyboard_Control(); - #endif - - #if HAS_PIDPLOT - static void DWIN_Draw_PIDPopup(const pidresult_t pidresult); - #endif - - #if HAS_PID_HEATING - static void DWIN_PidTuning(const pidresult_t pidresult); - #endif -}; - -extern CrealityDWINClass CrealityDWIN; diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin_defines.h b/Marlin/src/lcd/e3v2/jyersui/dwin_defines.h deleted file mode 100644 index 72d428448899..000000000000 --- a/Marlin/src/lcd/e3v2/jyersui/dwin_defines.h +++ /dev/null @@ -1,131 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ -#pragma once - -/** - * DWIN general defines and data structs for PRO UI - * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 3.11.2 - * Date: 2022/02/28 - * - * Modded for JYERSUI by LCH-77 - * Version: 1.9 - * Date: Jun 16, 2022 - */ - -#include "../../../inc/MarlinConfigPre.h" - -#define HAS_ESDIAG 1 -#define HAS_LOCKSCREEN 1 -#define HAS_PIDPLOT 1 -#define HAS_GCODE_PREVIEW 1 -//#define DEBUG_DWIN 1 -//#define NEED_HEX_PRINT 1 - -#if ENABLED(HOST_ACTION_COMMANDS) - #define HAS_HOSTACTION_MENUS 1 -#endif - -#include "../../../core/types.h" -#include "../common/dwin_color.h" - -// Default UI Colors -#define Def_Background_Color RGB(4,4,0) -#define Def_Cursor_color RGB(24,24,0) -#define Def_TitleBg_color RGB(12,12,0) -#define Def_TitleTxt_color Color_White -#define Def_Text_Color Color_White -#define Def_Selected_Color RGB(24,24,0) -#define Def_SplitLine_Color RGB(24,24,0) -#define Def_Highlight_Color RGB(31,40,0) -#define Def_StatusBg_Color RGB(12,12,0) -#define Def_StatusTxt_Color Color_White -#define Def_PopupBg_color Color_Bg_Window -#define Def_PopupTxt_Color Popup_Text_Color -#define Def_AlertBg_Color Color_Bg_Red -#define Def_AlertTxt_Color Color_Yellow -#define Def_PercentTxt_Color RGB(31,48,8) -#define Def_Barfill_Color RGB(12,12,0) -#define Def_Indicator_Color RGB(31,48,8) -#define Def_Coordinate_Color Color_White -#define Def_Button_Color RGB(12,12,0) - -#if ENABLED(LED_CONTROL_MENU, HAS_COLOR_LEDS) - #define Def_Leds_Color 0xFFFFFFFF -#endif -#if ENABLED(CASELIGHT_USES_BRIGHTNESS) - #define Def_CaseLight_Brightness 255 -#endif - -#if HAS_MESH - #ifndef MESH_INSET - #define MESH_INSET 25 - #endif - #ifndef MESH_MIN_X - #define MESH_MIN_X MESH_INSET - #endif - #ifndef MESH_MIN_Y - #define MESH_MIN_Y MESH_INSET - #endif - #ifndef MESH_MAX_X - #define MESH_MAX_X X_BED_SIZE - (MESH_INSET) - #endif - #ifndef MESH_MAX_Y - #define MESH_MAX_Y X_BED_SIZE - (MESH_INSET) - #endif -#endif - -typedef struct { - bool time_format_textual : 1; - #if ENABLED(AUTO_BED_LEVELING_UBL) - uint8_t tilt_grid_size : 3; - #endif - uint16_t corner_pos : 10; - uint8_t cursor_color : 4; - uint8_t menu_split_line : 4; - uint8_t menu_top_bg : 4; - uint8_t menu_top_txt : 4; - uint8_t highlight_box : 4; - uint8_t progress_percent : 4; - uint8_t progress_time : 4; - uint8_t status_bar_text : 4; - uint8_t status_area_text : 4; - uint8_t coordinates_text : 4; - uint8_t coordinates_split_line : 4; - #if ENABLED(BAUD_RATE_GCODE) - bool Baud115k : 1; - #endif - #if ENABLED(PREHEAT_BEFORE_LEVELING) - bool ena_hotend_levtemp : 1; - bool ena_bed_levtemp : 1; - celsius_t hotend_levtemp = LEVELING_NOZZLE_TEMP; - celsius_t bed_levtemp = LEVELING_BED_TEMP; - #endif - #if HAS_HOSTACTION_MENUS - uint64_t host_action_label_1 : 48; - uint64_t host_action_label_2 : 48; - uint64_t host_action_label_3 : 48; - #endif -} eeprom_settings_t; - -static constexpr size_t eeprom_data_size = 48; -extern eeprom_settings_t eeprom_settings; diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin_lcd.cpp b/Marlin/src/lcd/e3v2/jyersui/dwin_lcd.cpp deleted file mode 100644 index 24d55272a3e9..000000000000 --- a/Marlin/src/lcd/e3v2/jyersui/dwin_lcd.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -/******************************************************************************** - * @file lcd/e3v2/jyersui/dwin_lcd.cpp - * @brief DWIN screen control functions - ********************************************************************************/ - -#include "../../../inc/MarlinConfigPre.h" - -#if ENABLED(DWIN_CREALITY_LCD_JYERSUI) - -#include "dwin_lcd.h" - -/*-------------------------------------- System variable function --------------------------------------*/ - -void DWIN_Startup() {} - -/*---------------------------------------- Drawing functions ----------------------------------------*/ - -// Draw the degree (°) symbol -// Color: color -// x/y: Upper-left coordinate of the first pixel -void DWIN_Draw_DegreeSymbol(uint16_t Color, uint16_t x, uint16_t y) { - DWIN_Draw_Point(Color, 1, 1, x + 1, y); - DWIN_Draw_Point(Color, 1, 1, x + 2, y); - DWIN_Draw_Point(Color, 1, 1, x, y + 1); - DWIN_Draw_Point(Color, 1, 1, x + 3, y + 1); - DWIN_Draw_Point(Color, 1, 1, x, y + 2); - DWIN_Draw_Point(Color, 1, 1, x + 3, y + 2); - DWIN_Draw_Point(Color, 1, 1, x + 1, y + 3); - DWIN_Draw_Point(Color, 1, 1, x + 2, y + 3); -} - -/*---------------------------------------- Picture related functions ----------------------------------------*/ - -// Draw an Icon with transparent background -// libID: Icon library ID -// picID: Icon ID -// x/y: Upper-left point -void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) { - DWIN_ICON_Show(false, false, true, libID, picID, x, y); -} - -// From DWIN Enhanced implementation for PRO UI v3.10.1 -// Write buffer data to the SRAM or Flash -// mem: 0x5A=32KB SRAM, 0xA5=16KB Flash -// addr: start address -// length: Bytes to write -// data: address of the buffer with data -void DWIN_WriteToMem(uint8_t mem, uint16_t addr, uint16_t length, uint8_t *data) { - const uint8_t max_size = 128; - uint16_t pending = length; - uint16_t to_send; - uint16_t indx; - uint8_t block = 0; - - while (pending > 0) { - indx = block * max_size; - to_send = _MIN(pending, max_size); - size_t i = 0; - DWIN_Byte(i, 0x31); - DWIN_Byte(i, mem); - DWIN_Word(i, addr + indx); // start address of the data block - ++i; - LOOP_L_N(j, i) { LCD_SERIAL.write(DWIN_SendBuf[j]); delayMicroseconds(1); } // Buf header - for (uint16_t j = indx; j <= indx + to_send - 1; j++) LCD_SERIAL.write(*(data + j)); delayMicroseconds(1); // write block of data - LOOP_L_N(j, 4) { LCD_SERIAL.write(DWIN_BufTail[j]); delayMicroseconds(1); } - block++; - pending -= to_send; - } -} - -#endif // DWIN_CREALITY_LCD_JYERSUI diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin_lcd.h b/Marlin/src/lcd/e3v2/jyersui/dwin_lcd.h deleted file mode 100644 index b1aeadbbc51b..000000000000 --- a/Marlin/src/lcd/e3v2/jyersui/dwin_lcd.h +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ -#pragma once - -/******************************************************************************** - * @file lcd/e3v2/jyersui/dwin_lcd.h - * @brief DWIN screen control functions - ********************************************************************************/ - -#include "../common/dwin_api.h" - -// Draw the degree (°) symbol -// Color: color -// x/y: Upper-left coordinate of the first pixel -void DWIN_Draw_DegreeSymbol(uint16_t Color, uint16_t x, uint16_t y); - -// From DWIN Enhanced implementation for PRO UI v3.10.1 -// Write buffer data to the SRAM or Flash -// mem: 0x5A=32KB SRAM, 0xA5=16KB Flash -// addr: start address -// length: Bytes to write -// data: address of the buffer with data -void DWIN_WriteToMem(uint8_t mem, uint16_t addr, uint16_t length, uint8_t *data); diff --git a/Marlin/src/lcd/e3v2/jyersui/dwinui.cpp b/Marlin/src/lcd/e3v2/jyersui/dwinui.cpp deleted file mode 100644 index 1573bff552d9..000000000000 --- a/Marlin/src/lcd/e3v2/jyersui/dwinui.cpp +++ /dev/null @@ -1,340 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -/** - * DWIN Enhanced implementation for PRO UI - * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 3.17.1 - * Date: 2022/04/12 - * - * Modded for JYERSUI by LCH-77 - * Version: 1.9 - * Date: Jun 16, 2022 - */ - -#include "../../../inc/MarlinConfigPre.h" - -#if ENABLED(DWIN_CREALITY_LCD_JYERSUI) - -#include "../../../inc/MarlinConfig.h" -#include "dwin_lcd.h" -#include "dwinui.h" -#include "dwin_defines.h" - -//#define DEBUG_OUT 1 -#include "../../../core/debug_out.h" - -xy_int_t DWINUI::cursor = { 0 }; -uint16_t DWINUI::pencolor = Color_White; -uint16_t DWINUI::textcolor = Def_Text_Color; -uint16_t DWINUI::backcolor = Def_Background_Color; -uint16_t DWINUI::buttoncolor = Def_Button_Color; -uint8_t DWINUI::font = font8x16; -FSTR_P const DWINUI::Author = F(STRING_CONFIG_H_AUTHOR); - -void DWINUI::init() { - delay(750); // Delay for wait to wakeup screen - const bool hs = DWIN_Handshake(); UNUSED(hs); - #if ENABLED(DEBUG_DWIN) - SERIAL_ECHOPGM("DWIN_Handshake "); - SERIAL_ECHOLNF(hs ? F("ok.") : F("error.")); - #endif - DWIN_Frame_SetDir(1); - cursor.reset(); - pencolor = Color_White; - textcolor = Def_Text_Color; - backcolor = Def_Background_Color; - buttoncolor = Def_Button_Color; - font = font8x16; -} - -// Set text/number font -void DWINUI::setFont(uint8_t cfont) { - font = cfont; -} - -// Get font character width -uint8_t DWINUI::fontWidth(uint8_t cfont) { - switch (cfont) { - case font6x12 : return 6; - case font8x16 : return 8; - case font10x20: return 10; - case font12x24: return 12; - case font14x28: return 14; - case font16x32: return 16; - case font20x40: return 20; - case font24x48: return 24; - case font28x56: return 28; - case font32x64: return 32; - default: return 0; - } -} - -// Get font character height -uint8_t DWINUI::fontHeight(uint8_t cfont) { - switch (cfont) { - case font6x12 : return 12; - case font8x16 : return 16; - case font10x20: return 20; - case font12x24: return 24; - case font14x28: return 28; - case font16x32: return 32; - case font20x40: return 40; - case font24x48: return 48; - case font28x56: return 56; - case font32x64: return 64; - default: return 0; - } -} - -// Get screen x coordinates from text column -uint16_t DWINUI::ColToX(uint8_t col) { - return col * fontWidth(font); -} - -// Get screen y coordinates from text row -uint16_t DWINUI::RowToY(uint8_t row) { - return row * fontHeight(font); -} - -// Set text/number color -void DWINUI::SetColors(uint16_t fgcolor, uint16_t bgcolor, uint16_t alcolor) { - textcolor = fgcolor; - backcolor = bgcolor; - buttoncolor = alcolor; -} -void DWINUI::SetTextColor(uint16_t fgcolor) { - textcolor = fgcolor; -} -void DWINUI::SetBackgroundColor(uint16_t bgcolor) { - backcolor = bgcolor; -} - -// Moves cursor to point -// x: abscissa of the display -// y: ordinate of the display -// point: xy coordinate -void DWINUI::MoveTo(int16_t x, int16_t y) { - cursor.x = x; - cursor.y = y; -} -void DWINUI::MoveTo(xy_int_t point) { - cursor = point; -} - -// Moves cursor relative to the actual position -// x: abscissa of the display -// y: ordinate of the display -// point: xy coordinate -void DWINUI::MoveBy(int16_t x, int16_t y) { - cursor.x += x; - cursor.y += y; -} -void DWINUI::MoveBy(xy_int_t point) { - cursor += point; -} - -// Draw a Centered string using arbitrary x1 and x2 margins -void DWINUI::Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x1, uint16_t x2, uint16_t y, const char * const string) { - const uint16_t x = _MAX(0U, x2 + x1 - strlen_P(string) * fontWidth(size)) / 2 - 1; - DWIN_Draw_String(bShow, size, color, bColor, x, y, string); -} - -// Draw a char -// color: Character color -// x: abscissa of the display -// y: ordinate of the display -// c: ASCII code of char -void DWINUI::Draw_Char(uint16_t color, uint16_t x, uint16_t y, const char c) { - const char string[2] = { c, 0}; - DWIN_Draw_String(false, font, color, backcolor, x, y, string, 1); -} - -// Draw a char at cursor position and increment cursor -void DWINUI::Draw_Char(uint16_t color, const char c) { - Draw_Char(color, cursor.x, cursor.y, c); - MoveBy(fontWidth(font), 0); -} - -// Draw a string at cursor position -// color: Character color -// *string: The string -// rlimit: For draw less chars than string length use rlimit -void DWINUI::Draw_String(const char * const string, uint16_t rlimit) { - DWIN_Draw_String(false, font, textcolor, backcolor, cursor.x, cursor.y, string, rlimit); - MoveBy(strlen(string) * fontWidth(font), 0); -} -void DWINUI::Draw_String(uint16_t color, const char * const string, uint16_t rlimit) { - DWIN_Draw_String(false, font, color, backcolor, cursor.x, cursor.y, string, rlimit); - MoveBy(strlen(string) * fontWidth(font), 0); -} - -// Draw a numeric integer value -// bShow: true=display background color; false=don't display background color -// signedMode: 1=signed; 0=unsigned -// size: Font size -// color: Character color -// bColor: Background color -// iNum: Number of digits -// x/y: Upper-left coordinate -// value: Integer value -void DWINUI::Draw_Int(uint8_t bShow, bool signedMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, int32_t value) { - char nstr[10]; - sprintf_P(nstr, PSTR("%*li"), (signedMode ? iNum + 1 : iNum), value); - DWIN_Draw_String(bShow, size, color, bColor, x, y, nstr); -} - -// Draw a numeric float value -// bShow: true=display background color; false=don't display background color -// signedMode: 1=signed; 0=unsigned -// size: Font size -// color: Character color -// bColor: Background color -// iNum: Number of digits -// fNum: Number of decimal digits -// x/y: Upper-left coordinate -// value: float value -void DWINUI::Draw_Float(uint8_t bShow, bool signedMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - char nstr[10]; - DWIN_Draw_String(bShow, size, color, bColor, x, y, dtostrf(value, iNum + (signedMode ? 2:1) + fNum, fNum, nstr)); -} - -// ------------------------- Buttons ------------------------------// - -void DWINUI::Draw_Button(uint16_t color, uint16_t bcolor, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, const char * const caption) { - DWIN_Draw_Rectangle(1, bcolor, x1, y1, x2, y2); - Draw_CenteredString(0, font, color, bcolor, x1, x2, (y2 + y1 - fontHeight())/2, caption); -} - -void DWINUI::Draw_Button(uint8_t id, uint16_t x, uint16_t y) { - switch (id) { - case BTN_Cancel : Draw_Button(GET_TEXT_F(MSG_BUTTON_CANCEL), x, y); break; - case BTN_Confirm : Draw_Button(GET_TEXT_F(MSG_BUTTON_CONFIRM), x, y); break; - case BTN_Continue: Draw_Button(GET_TEXT_F(MSG_BUTTON_CONTINUE), x, y); break; - case BTN_Print : Draw_Button(GET_TEXT_F(MSG_BUTTON_PRINT), x, y); break; - case BTN_Save : Draw_Button(GET_TEXT_F(MSG_BUTTON_SAVE), x, y); break; - case BTN_Purge : Draw_Button(GET_TEXT_F(MSG_BUTTON_PURGE), x, y); break; - default: break; - } -} - -// -------------------------- Extra -------------------------------// - -// Draw a circle -// color: circle color -// x: the abscissa of the center of the circle -// y: ordinate of the center of the circle -// r: circle radius -void DWINUI::Draw_Circle(uint16_t color, uint16_t x, uint16_t y, uint8_t r) { - int a = 0, b = 0; - while (a <= b) { - b = SQRT(sq(r) - sq(a)); - if (a == 0) b--; - DWIN_Draw_Point(color, 1, 1, x + a, y + b); // Draw some sector 1 - DWIN_Draw_Point(color, 1, 1, x + b, y + a); // Draw some sector 2 - DWIN_Draw_Point(color, 1, 1, x + b, y - a); // Draw some sector 3 - DWIN_Draw_Point(color, 1, 1, x + a, y - b); // Draw some sector 4 - DWIN_Draw_Point(color, 1, 1, x - a, y - b); // Draw some sector 5 - DWIN_Draw_Point(color, 1, 1, x - b, y - a); // Draw some sector 6 - DWIN_Draw_Point(color, 1, 1, x - b, y + a); // Draw some sector 7 - DWIN_Draw_Point(color, 1, 1, x - a, y + b); // Draw some sector 8 - a++; - } -} - -// Draw a circle filled with color -// bcolor: fill color -// x: the abscissa of the center of the circle -// y: ordinate of the center of the circle -// r: circle radius -void DWINUI::Draw_FillCircle(uint16_t bcolor, uint16_t x,uint16_t y,uint8_t r) { - int a = 0, b = 0; - while (a <= b) { - b = SQRT(sq(r) - sq(a)); // b=sqrt(r*r-a*a); - if (a == 0) b--; - DWIN_Draw_Line(bcolor, x-b,y-a,x+b,y-a); - DWIN_Draw_Line(bcolor, x-a,y-b,x+a,y-b); - DWIN_Draw_Line(bcolor, x-b,y+a,x+b,y+a); - DWIN_Draw_Line(bcolor, x-a,y+b,x+a,y+b); - a++; - } -} - -// Color Interpolator -// val : Interpolator minv..maxv -// minv : Minimum value -// maxv : Maximum value -// color1 : Start color -// color2 : End color -uint16_t DWINUI::ColorInt(int16_t val, int16_t minv, int16_t maxv, uint16_t color1, uint16_t color2) { - uint8_t B, G, R; - const float n = (float)(val - minv) / (maxv - minv); - R = (1 - n) * GetRColor(color1) + n * GetRColor(color2); - G = (1 - n) * GetGColor(color1) + n * GetGColor(color2); - B = (1 - n) * GetBColor(color1) + n * GetBColor(color2); - return RGB(R, G, B); -} - -// Color Interpolator through Red->Yellow->Green->Blue (Pro UI) -// val : Interpolator minv..maxv -// minv : Minimum value -// maxv : Maximum value -uint16_t DWINUI::RainbowInt(int16_t val, int16_t minv, int16_t maxv) { - uint8_t B, G, R; - const uint8_t maxB = 28, maxR = 28, maxG = 38; - const int16_t limv = _MAX(abs(minv), abs(maxv)); - float n = minv >= 0 ? (float)(val - minv) / (maxv - minv) : (float)val / limv; - LIMIT(n, -1, 1); - if (n < 0) { - R = 0; - G = (1 + n) * maxG; - B = (-n) * maxB; - } - else if (n < 0.5) { - R = maxR * n * 2; - G = maxG; - B = 0; - } - else { - R = maxR; - G = maxG * (1 - n); - B = 0; - } - return RGB(R, G, B); -} - -// Draw a checkbox -// Color: frame color -// bColor: Background color -// x/y: Upper-left point -// mode : 0 : unchecked, 1 : checked -void DWINUI::Draw_Checkbox(uint16_t color, uint16_t bcolor, uint16_t x, uint16_t y, bool checked=false) { - DWIN_Draw_String(true, font8x16, color, bcolor, x + 4, y, checked ? F("x") : F(" ")); - DWIN_Draw_Rectangle(0, color, x + 2, y + 2, x + 17, y + 17); -} - -// Clear Menu by filling the menu area with background color -void DWINUI::ClearMainArea() { - DWIN_Draw_Rectangle(1, backcolor, 0, TITLE_HEIGHT, DWIN_WIDTH - 1, STATUS_Y - 1); -} - -#endif // DWIN_CREALITY_LCD_JYERSUI diff --git a/Marlin/src/lcd/e3v2/jyersui/dwinui.h b/Marlin/src/lcd/e3v2/jyersui/dwinui.h deleted file mode 100644 index 779e6270a128..000000000000 --- a/Marlin/src/lcd/e3v2/jyersui/dwinui.h +++ /dev/null @@ -1,527 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ -#pragma once - -/** - * DWIN Enhanced implementation for PRO UI - * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 3.17.1 - * Date: 2022/04/12 - * - * Modded for JYERSUI by LCH-77 - * Version: 1.9 - * Date: Jun 16, 2022 - */ - -#include "dwin_lcd.h" -#include "../common/dwin_set.h" -#include "../common/dwin_font.h" -#include "../common/dwin_color.h" -#include "../common/dwin_api.h" - -// Custom icons -//#define DWIN_CREALITY_LCD_CUSTOM_ICONS -#if ENABLED(DWIN_CREALITY_LCD_CUSTOM_ICONS) - // index of every custom icon should be >= CUSTOM_ICON_START - #define CUSTOM_ICON_START ICON_Checkbox_F - #define ICON_Checkbox_F 200 - #define ICON_Checkbox_T 201 - #define ICON_Fade 202 - #define ICON_Mesh 203 - #define ICON_Tilt 204 - #define ICON_Brightness 205 - #define ICON_AxisD 249 - #define ICON_AxisBR 250 - #define ICON_AxisTR 251 - #define ICON_AxisBL 252 - #define ICON_AxisTL 253 - #define ICON_AxisC 254 -#else - #define ICON_Fade ICON_Version - #define ICON_Mesh ICON_Version - #define ICON_Tilt ICON_Version - #define ICON_Brightness ICON_Version - #define ICON_AxisD ICON_Axis - #define ICON_AxisBR ICON_Axis - #define ICON_AxisTR ICON_Axis - #define ICON_AxisBL ICON_Axis - #define ICON_AxisTL ICON_Axis - #define ICON_AxisC ICON_Axis - #define ICON_ESDiag ICON_Info - #define ICON_Lock ICON_Cool - #define ICON_Reboot ICON_ResumeEEPROM - #define ICON_ProbeAlarm ICON_SetEndTemp - #define ICON_ProbeMargin ICON_PrintSize - #define ICON_ProbeSelfTest ICON_SetEndTemp - #define ICON_ProbeSet ICON_SetEndTemp - #define ICON_ProbeDeploy ICON_SetEndTemp - #define ICON_ProbeTest ICON_SetEndTemp - #define ICON_ProbeTestCount ICON_SetEndTemp - #define ICON_ProbeZSpeed ICON_MaxSpeedZ - #define ICON_FWRetLength ICON_StepE - #define ICON_FWRetSpeed ICON_Setspeed - #define ICON_FWRetZRaise ICON_MoveZ - #define ICON_FWRecExtLength ICON_StepE - #define ICON_FWRecSpeed ICON_Setspeed - #define ICON_HSMode ICON_StockConfiguration - #define ICON_Sound ICON_Cool - #define ICON_CaseLight ICON_Motion - #define ICON_LedControl ICON_Motion - #define ICON_MeshActive ICON_HotendTemp - #define ICON_Park ICON_Motion -#endif - -// Buttons -#define BTN_Continue 85 -#define BTN_Cancel 87 -#define BTN_Confirm 89 -#define BTN_Print 90 -#define BTN_Save 91 -#define BTN_Purge 92 - -// Extended UI Colors -#define Color_Aqua RGB(0,63,31) -#define Color_Light_White 0xBDD7 -#define Color_Green RGB(0,63,0) -#define Color_Light_Green 0x3460 -#define Color_Cyan 0x07FF -#define Color_Light_Cyan 0x04F3 -#define Color_Blue RGB(0,0,31) -#define Color_Light_Blue 0x3A6A -#define Color_Magenta 0xF81F -#define Color_Light_Magenta 0x9813 -#define Color_Light_Red 0x8800 -#define Color_Orange 0xFA20 -#define Color_Light_Orange 0xFBC0 -#define Color_Light_Yellow 0x8BE0 -#define Color_Brown 0xCC27 -#define Color_Light_Brown 0x6204 -#define Color_Black 0x0000 -#define Color_Grey 0x18E3 -#define Check_Color 0x4E5C -#define Confirm_Color 0x34B9 -#define Cancel_Color 0x3186 - -// UI element defines and constants -#define DWIN_FONT_MENU font8x16 -#define DWIN_FONT_STAT font10x20 -#define DWIN_FONT_HEAD font10x20 -#define DWIN_FONT_ALERT font10x20 -#define STATUS_Y 354 -#define LCD_WIDTH (DWIN_WIDTH / 8) // only if the default font is font8x16 - -// Minimum unit (0.1) : multiple (10) -#define UNITFDIGITS 1 -#define MINUNITMULT POW(10, UNITFDIGITS) - -constexpr uint8_t TITLE_HEIGHT = 30, // Title bar height - MLINE = 53, // Menu line height - TROWS = (STATUS_Y - TITLE_HEIGHT) / MLINE, // Total rows - MROWS = TROWS - 1, // Other-than-Back - ICOX = 26, // Menu item icon X position - LBLX = 60, // Menu item label X position - VALX = 210, // Menu item value X position - MENU_CHR_W = 8, MENU_CHR_H = 16, // Menu font 8x16 - STAT_CHR_W = 10; - -// Menuitem Y position -#define MYPOS(L) (TITLE_HEIGHT + MLINE * (L)) - -// Menuitem caption Offset -#define CAPOFF ((MLINE - MENU_CHR_H) / 2) - -// Menuitem caption Y position -#define MBASE(L) (MYPOS(L) + CAPOFF) - -typedef struct { uint16_t left, top, right, bottom; } rect_t; -typedef struct { uint16_t x, y, w, h; } frame_rect_t; - -namespace DWINUI { - extern xy_int_t cursor; - extern uint16_t pencolor; - extern uint16_t textcolor; - extern uint16_t backcolor; - extern uint16_t buttoncolor; - extern uint8_t font; - extern FSTR_P const Author; - - // DWIN LCD Initialization - void init(); - - // Set text/number font - void setFont(uint8_t cfont); - - // Get font character width - uint8_t fontWidth(uint8_t cfont); - inline uint8_t fontWidth() { return fontWidth(font); }; - - // Get font character height - uint8_t fontHeight(uint8_t cfont); - inline uint8_t fontHeight() { return fontHeight(font); }; - - // Get screen x coordinates from text column - uint16_t ColToX(uint8_t col); - - // Get screen y coordinates from text row - uint16_t RowToY(uint8_t row); - - // Set text/number color - void SetColors(uint16_t fgcolor, uint16_t bgcolor, uint16_t alcolor); - void SetTextColor(uint16_t fgcolor); - void SetBackgroundColor(uint16_t bgcolor); - - // Moves cursor to point - // x: abscissa of the display - // y: ordinate of the display - // point: xy coordinate - void MoveTo(int16_t x, int16_t y); - void MoveTo(xy_int_t point); - - // Moves cursor relative to the actual position - // x: abscissa of the display - // y: ordinate of the display - // point: xy coordinate - void MoveBy(int16_t x, int16_t y); - void MoveBy(xy_int_t point); - - // Draw a line from the cursor to xy position - // color: Line segment color - // x/y: End point - inline void LineTo(uint16_t color, uint16_t x, uint16_t y) { - DWIN_Draw_Line(color, cursor.x, cursor.y, x, y); - } - inline void LineTo(uint16_t x, uint16_t y) { - DWIN_Draw_Line(pencolor, cursor.x, cursor.y, x, y); - } - - // Extend a frame box - // v: value to extend - inline frame_rect_t ExtendFrame(frame_rect_t frame, uint8_t v) { - frame_rect_t t; - t.x = frame.x - v; - t.y = frame.y - v; - t.w = frame.w + 2 * v; - t.h = frame.h + 2 * v; - return t; - } - - // Draw an Icon with transparent background from the library ICON - // icon: Icon ID - // x/y: Upper-left point - inline void Draw_Icon(uint8_t icon, uint16_t x, uint16_t y) { - DWIN_ICON_Show(ICON, icon, x, y); - } - - // Draw an Icon from the library ICON with its background - // icon: Icon ID - // x/y: Upper-left point - inline void Draw_IconWB(uint8_t icon, uint16_t x, uint16_t y) { - DWIN_ICON_Show(true, false, false, ICON, icon, x, y); - } - inline void DRAW_IconWB(uint8_t libID, uint8_t icon, uint16_t x, uint16_t y) { - DWIN_ICON_Show(true, false, false, libID, icon, x, y); - } - - // Draw a numeric integer value - // bShow: true=display background color; false=don't display background color - // signedMode: 1=signed; 0=unsigned - // size: Font size - // color: Character color - // bColor: Background color - // iNum: Number of digits - // x/y: Upper-left coordinate - // value: Integer value - void Draw_Int(uint8_t bShow, bool signedMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, int32_t value); - - // Draw a positive integer - inline void Draw_Int(uint8_t bShow, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(bShow, 0, size, color, bColor, iNum, x, y, value); - } - inline void Draw_Int(uint8_t iNum, long value) { - Draw_Int(false, 0, font, textcolor, backcolor, iNum, cursor.x, cursor.y, value); - MoveBy(iNum * fontWidth(font), 0); - } - inline void Draw_Int(uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(false, 0, font, textcolor, backcolor, iNum, x, y, value); - } - inline void Draw_Int(uint16_t color, uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(false, 0, font, color, backcolor, iNum, x, y, value); - } - inline void Draw_Int(uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(true, 0, font, color, bColor, iNum, x, y, value); - } - inline void Draw_Int(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(true, 0, size, color, bColor, iNum, x, y, value); - } - - // Draw a signed integer - inline void Draw_Signed_Int(uint8_t bShow, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(bShow, 1, size, color, bColor, iNum, x, y, value); - } - inline void Draw_Signed_Int(uint8_t iNum, long value) { - Draw_Int(false, 1, font, textcolor, backcolor, iNum, cursor.x, cursor.y, value); - MoveBy(iNum * fontWidth(font), 0); - } - inline void Draw_Signed_Int(uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(false, 1, font, textcolor, backcolor, iNum, x, y, value); - } - inline void Draw_Signed_Int(uint16_t color, uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(false, 1, font, color, backcolor, iNum, x, y, value); - } - inline void Draw_Signed_Int(uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(true, 1, font, color, bColor, iNum, x, y, value); - } - inline void Draw_Signed_Int(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(true, 1, size, color, bColor, iNum, x, y, value); - } - - // Draw a numeric float value - // bShow: true=display background color; false=don't display background color - // signedMode: 1=signed; 0=unsigned - // size: Font size - // color: Character color - // bColor: Background color - // iNum: Number of digits - // fNum: Number of decimal digits - // x/y: Upper-left coordinate - // value: float value - void Draw_Float(uint8_t bShow, bool signedMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value); - - // Draw a positive floating point number - inline void Draw_Float(uint8_t bShow, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(bShow, 0, size, color, bColor, iNum, fNum, x, y, value); - } - inline void Draw_Float(uint8_t iNum, uint8_t fNum, float value) { - Draw_Float(false, 0, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value); - MoveBy((iNum + fNum + 1) * fontWidth(font), 0); - } - inline void Draw_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(false, 0, font, textcolor, backcolor, iNum, fNum, x, y, value); - } - inline void Draw_Float(uint8_t size, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(false, 0, size, textcolor, backcolor, iNum, fNum, x, y, value); - } - inline void Draw_Float(uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(true, 0, font, color, bColor, iNum, fNum, x, y, value); - } - inline void Draw_Float(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(true, 0, size, color, bColor, iNum, fNum, x, y, value); - } - - // Draw a signed floating point number - inline void Draw_Signed_Float(uint8_t bShow, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(bShow, 1, size, color, bColor, iNum, fNum, x, y, value); - } - inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, float value) { - Draw_Float(false, 1, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value); - MoveBy((iNum + fNum + 1) * fontWidth(font), 0); - } - inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(false, 1, font, textcolor, backcolor, iNum, fNum, x, y, value); - } - inline void Draw_Signed_Float(uint8_t size, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(false, 1, size, textcolor, backcolor, iNum, fNum, x, y, value); - } - inline void Draw_Signed_Float(uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(true, 1, font, color, bColor, iNum, fNum, x, y, value); - } - inline void Draw_Signed_Float(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(true, 1, size, color, bColor, iNum, fNum, x, y, value); - } - - // Draw a char - // color: Character color - // x: abscissa of the display - // y: ordinate of the display - // c: ASCII code of char - void Draw_Char(uint16_t color, uint16_t x, uint16_t y, const char c); - inline void Draw_Char(uint16_t x, uint16_t y, const char c) { Draw_Char(textcolor, x, y, c); }; - // Draw a char at cursor position and increment cursor - void Draw_Char(uint16_t color, const char c); - inline void Draw_Char(const char c) { Draw_Char(textcolor, c); } - - // Draw a string at cursor position - // color: Character color - // *string: The string - // rlimit: For draw less chars than string length use rlimit - void Draw_String(const char * const string, uint16_t rlimit = 0xFFFF); - void Draw_String(uint16_t color, const char * const string, uint16_t rlimit = 0xFFFF); - inline void Draw_String(FSTR_P string, uint16_t rlimit = 0xFFFF) { - Draw_String(FTOP(string), rlimit); - } - inline void Draw_String(uint16_t color, FSTR_P string, uint16_t rlimit = 0xFFFF) { - Draw_String(color, FTOP(string), rlimit); - } - - // Draw a string - // size: Font size - // color: Character color - // bColor: Background color - // x/y: Upper-left coordinate of the string - // *string: The string - inline void Draw_String(uint16_t x, uint16_t y, const char * const string) { - DWIN_Draw_String(false, font, textcolor, backcolor, x, y, string); - } - inline void Draw_String(uint16_t x, uint16_t y, FSTR_P title) { - DWIN_Draw_String(false, font, textcolor, backcolor, x, y, FTOP(title)); - } - inline void Draw_String(uint16_t color, uint16_t x, uint16_t y, const char * const string) { - DWIN_Draw_String(false, font, color, backcolor, x, y, string); - } - inline void Draw_String(uint16_t color, uint16_t x, uint16_t y, FSTR_P title) { - DWIN_Draw_String(false, font, color, backcolor, x, y, title); - } - inline void Draw_String(uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, const char * const string) { - DWIN_Draw_String(true, font, color, bgcolor, x, y, string); - } - inline void Draw_String(uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, FSTR_P title) { - DWIN_Draw_String(true, font, color, bgcolor, x, y, title); - } - inline void Draw_String(uint8_t size, uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, const char * const string) { - DWIN_Draw_String(true, size, color, bgcolor, x, y, string); - } - inline void Draw_String(uint8_t size, uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, FSTR_P title) { - DWIN_Draw_String(true, size, color, bgcolor, x, y, title); - } - - // Draw a centered string using DWIN_WIDTH - // bShow: true=display background color; false=don't display background color - // size: Font size - // color: Character color - // bColor: Background color - // y: Upper coordinate of the string - // *string: The string - void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x1, uint16_t x2, uint16_t y, const char * const string); - inline void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, const char * const string) { - Draw_CenteredString(bShow, size, color, bColor, 0, DWIN_WIDTH, y, string); - } - inline void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, FSTR_P string) { - Draw_CenteredString(bShow, size, color, bColor, y, FTOP(string)); - } - inline void Draw_CenteredString(uint16_t color, uint16_t bcolor, uint16_t y, const char * const string) { - Draw_CenteredString(true, font, color, bcolor, y, string); - } - inline void Draw_CenteredString(uint8_t size, uint16_t color, uint16_t y, const char * const string) { - Draw_CenteredString(false, size, color, backcolor, y, string); - } - inline void Draw_CenteredString(uint8_t size, uint16_t color, uint16_t y, FSTR_P title) { - Draw_CenteredString(false, size, color, backcolor, y, title); - } - inline void Draw_CenteredString(uint16_t color, uint16_t y, const char * const string) { - Draw_CenteredString(false, font, color, backcolor, y, string); - } - inline void Draw_CenteredString(uint16_t color, uint16_t y, FSTR_P title) { - Draw_CenteredString(false, font, color, backcolor, y, title); - } - inline void Draw_CenteredString(uint16_t y, const char * const string) { - Draw_CenteredString(false, font, textcolor, backcolor, y, string); - } - inline void Draw_CenteredString(uint16_t y, FSTR_P title) { - Draw_CenteredString(false, font, textcolor, backcolor, y, title); - } - - // Draw a box - // mode: 0=frame, 1=fill, 2=XOR fill - // color: Rectangle color - // frame: Box coordinates and size - inline void Draw_Box(uint8_t mode, uint16_t color, frame_rect_t frame) { - DWIN_Draw_Box(mode, color, frame.x, frame.y, frame.w, frame.h); - } - - // Draw a circle - // Color: circle color - // x: abscissa of the center of the circle - // y: ordinate of the center of the circle - // r: circle radius - void Draw_Circle(uint16_t color, uint16_t x,uint16_t y,uint8_t r); - inline void Draw_Circle(uint16_t color, uint8_t r) { - Draw_Circle(color, cursor.x, cursor.y, r); - } - - // Draw a checkbox - // Color: frame color - // bColor: Background color - // x/y: Upper-left point - // checked : 0 : unchecked, 1 : checked - void Draw_Checkbox(uint16_t color, uint16_t bcolor, uint16_t x, uint16_t y, bool checked); - inline void Draw_Checkbox(uint16_t x, uint16_t y, bool checked=false) { - Draw_Checkbox(textcolor, backcolor, x, y, checked); - } - - // Color Interpolator - // val : Interpolator minv..maxv - // minv : Minimum value - // maxv : Maximum value - // color1 : Start color - // color2 : End color - uint16_t ColorInt(int16_t val, int16_t minv, int16_t maxv, uint16_t color1, uint16_t color2); - - // ------------------------- Buttons ------------------------------// - - void Draw_Button(uint16_t color, uint16_t bcolor, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, const char * const caption); - inline void Draw_Button(uint16_t color, uint16_t bcolor, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, FSTR_P caption) { - Draw_Button(color, bcolor, x1, y1, x2, y2, FTOP(caption)); - } - inline void Draw_Button(FSTR_P caption, uint16_t x, uint16_t y) { - Draw_Button(textcolor, buttoncolor, x, y, x + 99, y + 37, caption); - } - void Draw_Button(uint8_t id, uint16_t x, uint16_t y); - - // -------------------------- Extra -------------------------------// - - // Draw a circle filled with color - // bcolor: fill color - // x: abscissa of the center of the circle - // y: ordinate of the center of the circle - // r: circle radius - void Draw_FillCircle(uint16_t bcolor, uint16_t x,uint16_t y,uint8_t r); - inline void Draw_FillCircle(uint16_t bcolor, uint8_t r) { - Draw_FillCircle(bcolor, cursor.x, cursor.y, r); - } - - // Color Interpolator through Red->Yellow->Green->Blue - // val : Interpolator minv..maxv - // minv : Minimum value - // maxv : Maximum value - uint16_t RainbowInt(int16_t val, int16_t minv, int16_t maxv); - - // Write buffer data to the SRAM - // addr: SRAM start address 0x0000-0x7FFF - // length: Bytes to write - // data: address of the buffer with data - inline void WriteToSRAM(uint16_t addr, uint16_t length, uint8_t *data) { - DWIN_WriteToMem(0x5A, addr, length, data); - } - - // Write buffer data to the Flash - // addr: Flash start address 0x0000-0x3FFF - // length: Bytes to write - // data: address of the buffer with data - inline void WriteToFlash(uint16_t addr, uint16_t length, uint8_t *data) { - DWIN_WriteToMem(0xA5, addr, length, data); - } - - // Clear by filling the area with background color - // Area (0, TITLE_HEIGHT, DWIN_WIDTH, STATUS_Y - 1) - void ClearMainArea(); - -}; diff --git a/Marlin/src/lcd/e3v2/jyersui/endstop_diag.cpp b/Marlin/src/lcd/e3v2/jyersui/endstop_diag.cpp deleted file mode 100644 index 5c4549619fb1..000000000000 --- a/Marlin/src/lcd/e3v2/jyersui/endstop_diag.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -/** - * DWIN End Stops diagnostic page - * Author: Miguel A. Risco-Castillo - * Version: 1.0 - * Date: 2021/11/06 - * - * Modded for JYERSUI by LCH-77 - */ - -#include "../../../inc/MarlinConfigPre.h" - -#if ENABLED(DWIN_CREALITY_LCD_JYERSUI) - -#include "dwin_defines.h" - -#if HAS_ESDIAG - -#include "endstop_diag.h" -#include "dwinui.h" -#include "dwin.h" - -#if HAS_FILAMENT_SENSOR - #include "../../../feature/runout.h" -#endif - -#if HAS_BED_PROBE - #include "../../../module/probe.h" -#endif - -ESDiagClass ESDiag; - -void draw_es_label(FSTR_P const flabel=nullptr) { - DWINUI::cursor.x = 40; - if (flabel) DWINUI::Draw_String(F(flabel)); - DWINUI::Draw_String(F(": ")); - DWINUI::MoveBy(0, 25); -} - -void draw_es_state(const bool is_hit) { - const uint8_t LM = 130; - DWINUI::cursor.x = LM; - DWIN_Draw_Rectangle(1, Color_Bg_Window, LM, DWINUI::cursor.y, LM + 100, DWINUI::cursor.y + 20); - is_hit ? DWINUI::Draw_String(RGB(31,31,16), F(STR_ENDSTOP_HIT)) : DWINUI::Draw_String(RGB(16,63,16), F(STR_ENDSTOP_OPEN)); - DWINUI::MoveBy(0, 25); -} - -void ESDiagClass::Draw() { - CrealityDWINClass::Clear_Screen(1); - CrealityDWINClass::Draw_Title(F("End-stops Diagnostic")); - DWINUI::ClearMainArea(); - DWIN_Draw_Rectangle(0, Color_White, 14, 60, 258, 330); - DWINUI::Draw_Button(BTN_Continue, 86, 250); - DWINUI::cursor.y = 80; - #define ES_LABEL(S) draw_es_label(F(STR_##S)) - #if HAS_X_MIN - ES_LABEL(X_MIN); - #endif - #if HAS_Y_MIN - ES_LABEL(Y_MIN); - #endif - #if HAS_Z_MIN - ES_LABEL(Z_MIN); - #endif - #if HAS_FILAMENT_SENSOR - draw_es_label(F(STR_FILAMENT)); - #endif - Update(); -} - -void ESDiagClass::Update() { - DWINUI::cursor.y = 80; - #define ES_REPORT(S) draw_es_state(READ(S##_PIN) != S##_ENDSTOP_INVERTING) - #if HAS_X_MIN - ES_REPORT(X_MIN); - #endif - #if HAS_Y_MIN - ES_REPORT(Y_MIN); - #endif - #if HAS_Z_MIN - ES_REPORT(Z_MIN); - #endif - #if HAS_FILAMENT_SENSOR - draw_es_state(READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE); - #endif - DWIN_UpdateLCD(); -} - -#endif // HAS_ES_DIAG -#endif // DWIN_CREALITY_LCD_JYERSUI diff --git a/Marlin/src/lcd/e3v2/jyersui/endstop_diag.h b/Marlin/src/lcd/e3v2/jyersui/endstop_diag.h deleted file mode 100644 index 59509739d047..000000000000 --- a/Marlin/src/lcd/e3v2/jyersui/endstop_diag.h +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ -#pragma once - -/** - * DWIN End Stops diagnostic page - * Author: Miguel A. Risco-Castillo - * Version: 1.0 - * Date: 2021/11/06 - * - * Modded for JYERSUI by LCH-77 - */ - -class ESDiagClass { -public: - void Draw(); - void Update(); -}; - -extern ESDiagClass ESDiag; diff --git a/Marlin/src/lcd/e3v2/jyersui/gcode_preview.cpp b/Marlin/src/lcd/e3v2/jyersui/gcode_preview.cpp deleted file mode 100644 index 26037a9ce9ba..000000000000 --- a/Marlin/src/lcd/e3v2/jyersui/gcode_preview.cpp +++ /dev/null @@ -1,244 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -/** - * DWIN G-code thumbnail preview - * Author: Miguel A. Risco-Castillo - * version: 2.1 - * Date: 2021/06/19 - * - * Modded for JYERSUI by LCH-77 - */ - -#include "../../../inc/MarlinConfigPre.h" -#if ENABLED(DWIN_CREALITY_LCD_JYERSUI) - -#include "dwin_defines.h" - -#if HAS_GCODE_PREVIEW - -#include "../../../core/types.h" -#include "../../marlinui.h" -#include "../../../sd/cardreader.h" -#include "../../../MarlinCore.h" // for wait_for_user -#include "dwin_lcd.h" -#include "dwinui.h" -#include "dwin.h" -#include "base64.hpp" -#include "gcode_preview.h" - -typedef struct { - char name[13] = ""; //8.3 + null - uint32_t thumbstart = 0; - int thumbsize = 0; - int thumbheight = 0; - int thumbwidth = 0; - uint8_t *thumbdata = nullptr; - float time = 0; - float filament = 0; - float layer = 0; - float width = 0; - float height = 0; - float length = 0; - void setname(const char * const fn); - void clear(); -} fileprop_t; -fileprop_t fileprop; - -void fileprop_t::setname(const char * const fn) { - const uint8_t len = _MIN(sizeof(name) - 1, strlen(fn)); - memcpy(&name[0], fn, len); - name[len] = '\0'; -} - -void fileprop_t::clear() { - fileprop.name[0] = '\0'; - fileprop.thumbstart = 0; - fileprop.thumbsize = 0; - fileprop.thumbheight = 0; - fileprop.thumbwidth = 0; - fileprop.thumbdata = nullptr; - fileprop.time = 0; - fileprop.filament = 0; - fileprop.layer = 0; - fileprop.height = 0; - fileprop.width = 0; - fileprop.length = 0; -} - -void Get_Value(char *buf, const char * const key, float &value) { - char num[10] = ""; - char * posptr = 0; - uint8_t i = 0; - if (!!value) return; - posptr = strstr(buf, key); - if (posptr != nullptr) { - while (i < sizeof(num)) { - char c = posptr[0]; - if (!ISEOL(c) && (c != 0)) { - if ((c > 47 && c < 58) || (c == '.')) num[i++] = c; - posptr++; - } - else { - num[i] = '\0'; - value = atof(num); - return; - } - } - } -} - -bool Has_Preview() { - const char * tbstart = "; thumbnail begin 230x180"; - char * posptr = 0; - uint8_t nbyte = 1; - uint32_t indx = 0; - char buf[256]; - float tmp = 0; - - fileprop.clear(); - fileprop.setname(card.filename); - - card.openFileRead(fileprop.name); - - while ((nbyte > 0) && (indx < 4 * sizeof(buf)) && !fileprop.thumbstart) { - nbyte = card.read(buf, sizeof(buf) - 1); - if (nbyte > 0) { - buf[nbyte] = '\0'; - Get_Value(buf, ";TIME:", fileprop.time); - Get_Value(buf, ";Filament used:", fileprop.filament); - Get_Value(buf, ";Layer height:", fileprop.layer); - Get_Value(buf, ";MINX:", tmp); - Get_Value(buf, ";MAXX:", fileprop.width); - fileprop.width -= tmp; - tmp = 0; - Get_Value(buf, ";MINY:", tmp); - Get_Value(buf, ";MAXY:", fileprop.length); - fileprop.length -= tmp; - tmp = 0; - Get_Value(buf, ";MINZ:", tmp); - Get_Value(buf, ";MAXZ:", fileprop.height); - fileprop.height -= tmp; - posptr = strstr(buf, tbstart); - if (posptr != NULL) { - fileprop.thumbstart = indx + (posptr - &buf[0]); - } - else { - indx += _MAX(10, nbyte - (signed)strlen(tbstart)); - card.setIndex(indx); - } - } - } - - if (!fileprop.thumbstart) { - card.closefile(); - LCD_MESSAGE_F("Thumbnail not found"); - return 0; - } - - // Get the size of the thumbnail - card.setIndex(fileprop.thumbstart + strlen(tbstart)); - for (uint8_t i = 0; i < 16; i++) { - char c = card.get(); - if (!ISEOL(c)) { - buf[i] = c; - } - else { - buf[i] = '\0'; - break; - } - } - fileprop.thumbsize = atoi(buf); - - // Exit if there isn't a thumbnail - if (!fileprop.thumbsize) { - card.closefile(); - LCD_MESSAGE_F("Invalid Thumbnail Size"); - return 0; - } - - uint16_t readed = 0; - uint8_t buf64[fileprop.thumbsize]; - - fileprop.thumbdata = new uint8_t[3 + 3 * (fileprop.thumbsize / 4)]; // Reserve space for the JPEG thumbnail - - while (readed < fileprop.thumbsize) { - uint8_t c = card.get(); - if (!ISEOL(c) && (c != ';') && (c != ' ')) { - buf64[readed] = c; - readed++; - } - } - card.closefile(); - buf64[readed] = 0; - - fileprop.thumbsize = decode_base64(buf64, fileprop.thumbdata); card.closefile(); - DWINUI::WriteToSRAM(0x00, fileprop.thumbsize, fileprop.thumbdata); - delete[] fileprop.thumbdata; - return true; -} - -void Preview_DrawFromSD() { - bool _has_preview = Has_Preview(); - CrealityDWIN.Popup_Handler(PrintConfirm, _has_preview); - if (_has_preview) { - char buf[46]; - char str_1[6] = "", str_2[6] = "", str_3[6] = ""; - // DWIN_Draw_Rectangle(1, Def_Background_Color, 0, 0, DWIN_WIDTH, STATUS_Y - 1); - if (fileprop.time) { - sprintf_P(buf, PSTR("Estimated time: %i:%02i"), (uint16_t)fileprop.time / 3600, ((uint16_t)fileprop.time % 3600) / 60); - DWINUI::Draw_String(20, 10, buf); - } - if (fileprop.filament) { - sprintf_P(buf, PSTR("Filament used: %s m"), dtostrf(fileprop.filament, 1, 2, str_1)); - DWINUI::Draw_String(20, 30, buf); - } - if (fileprop.layer) { - sprintf_P(buf, PSTR("Layer height: %s mm"), dtostrf(fileprop.layer, 1, 2, str_1)); - DWINUI::Draw_String(20, 50, buf); - } - if (fileprop.width) { - sprintf_P(buf, PSTR("Volume: %sx%sx%s mm"), dtostrf(fileprop.width, 1, 1, str_1), dtostrf(fileprop.length, 1, 1, str_2), dtostrf(fileprop.height, 1, 1, str_3)); - DWINUI::Draw_String(20, 70, buf); - } - // DWINUI::Draw_Button(BTN_Print, 26, 290); - // DWINUI::Draw_Button(BTN_Cancel, 146, 290); - DWIN_ICON_Show(0, 0, 1, 21, 90, 0x00); - // Draw_Select_Highlight(true, 290); - DWIN_UpdateLCD(); - } - // else { - // HMI_flag.select_flag = 1; - // wait_for_user = false; - // } -} - -bool Preview_Valid() { - return !!fileprop.thumbstart; -} - -void Preview_Reset() { - fileprop.thumbsize = 0; -} - -#endif // HAS_GCODE_PREVIEW -#endif // DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/jyersui/gcode_preview.h b/Marlin/src/lcd/e3v2/jyersui/gcode_preview.h deleted file mode 100644 index d10663e08bb0..000000000000 --- a/Marlin/src/lcd/e3v2/jyersui/gcode_preview.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -/** - * DWIN G-code thumbnail preview - * Author: Miguel A. Risco-Castillo - * version: 2.1 - * Date: 2021/06/19 - */ - -#pragma once - -void Preview_DrawFromSD(); -bool Preview_Valid(); -void Preview_Reset(); diff --git a/Marlin/src/lcd/e3v2/jyersui/lockscreen.cpp b/Marlin/src/lcd/e3v2/jyersui/lockscreen.cpp deleted file mode 100644 index 5ed6dd3317b1..000000000000 --- a/Marlin/src/lcd/e3v2/jyersui/lockscreen.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -/** - * Lock screen implementation for PRO UI - * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 2.2.0 - * Date: 2022/04/11 - * - * Modded for JYERSUI by LCH-77 - */ - -#include "../../../inc/MarlinConfigPre.h" - -#if ENABLED(DWIN_CREALITY_LCD_JYERSUI) - -#include "dwin_defines.h" - -#if HAS_LOCKSCREEN - -#include "../common/dwin_color.h" -#include "dwinui.h" -#include "dwin.h" -#include "lockscreen.h" - -LockScreenClass lockScreen; - -uint8_t LockScreenClass::lock_pos = 0; -bool LockScreenClass::unlocked = false; -uint8_t LockScreenClass::rprocess = 0; - -void LockScreenClass::init() { - lock_pos = 0; - unlocked = false; - draw(); -} - -void LockScreenClass::draw() { - CrealityDWINClass::Clear_Screen(1); - CrealityDWINClass::Draw_Title(GET_TEXT_F(MSG_LOCKSCREEN)); - DWINUI::ClearMainArea(); - DWINUI::Draw_Icon(ICON_LOGO, 71, 120); // CREALITY logo - DWINUI::Draw_CenteredString(Color_White, 180, GET_TEXT_F(MSG_LOCKSCREEN_LOCKED)); - DWINUI::Draw_CenteredString(Color_White, 200, GET_TEXT_F(MSG_LOCKSCREEN_UNLOCK)); - DWINUI::Draw_CenteredString(Color_White, 240, F("-> | <-")); - DWIN_Draw_Box(1, BarFill_Color, 0, 260, DWIN_WIDTH, 20); - DWIN_Draw_VLine(Color_Yellow, lock_pos * DWIN_WIDTH / 255, 260, 20); - DWIN_UpdateLCD(); -} - -void LockScreenClass::onEncoder(EncoderState encoder_diffState) { - switch (encoder_diffState) { - case ENCODER_DIFF_CW: lock_pos += 8; break; - case ENCODER_DIFF_CCW: lock_pos -= 8; break; - case ENCODER_DIFF_ENTER: unlocked = (lock_pos == 128); break; - default: break; - } - DWIN_Draw_Box(1, BarFill_Color, 0, 260, DWIN_WIDTH, 20); - DWIN_Draw_VLine(Color_Yellow, lock_pos * DWIN_WIDTH / 255, 260, 20); - DWIN_UpdateLCD(); -} - -#endif // HAS_LOCKSCREEN -#endif // DWIN_CREALITY_LCD_JYERSUI diff --git a/Marlin/src/lcd/e3v2/jyersui/lockscreen.h b/Marlin/src/lcd/e3v2/jyersui/lockscreen.h deleted file mode 100644 index 99c22a37da23..000000000000 --- a/Marlin/src/lcd/e3v2/jyersui/lockscreen.h +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ -#pragma once - -/** - * Lock screen implementation for PRO UI - * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 2.2.0 - * Date: 2022/04/11 - * - * Modded for JYERSUI by LCH-77 - */ - -#include "../../../core/types.h" -#include "../common/encoder.h" -#include - -class LockScreenClass { -private: - static bool unlocked; - static uint8_t lock_pos; -public: - static uint8_t rprocess; - static void init(); - static void onEncoder(EncoderState encoder_diffState); - static void draw(); - static bool isUnlocked() { return unlocked; } -}; - -extern LockScreenClass lockScreen; diff --git a/Marlin/src/lcd/e3v2/jyersui/plot.cpp b/Marlin/src/lcd/e3v2/jyersui/plot.cpp deleted file mode 100644 index c0c283f5c0be..000000000000 --- a/Marlin/src/lcd/e3v2/jyersui/plot.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -/** - * DWIN Single var plot - * Author: Miguel A. Risco-Castillo - * Version: 2.0 - * Date: 2022/01/31 - * - * Modded for JYERSUI by LCH-77 - */ - -#include "../../../inc/MarlinConfigPre.h" - -#ifdef DWIN_CREALITY_LCD_JYERSUI - -#include "dwin_defines.h" - -#ifdef HAS_PIDPLOT - -#include "plot.h" - -#include "../../../core/types.h" -#include "../../marlinui.h" -#include "dwin_lcd.h" -#include "dwinui.h" -#include "dwin.h" - -#define Plot_Bg_Color RGB( 1, 12, 8) - -PlotClass Plot; - -uint16_t grphpoints, r, x2, y2 = 0; -frame_rect_t grphframe = {0}; -float scale = 0; - -void PlotClass::Draw(const frame_rect_t frame, const float max, const float ref) { - grphframe = frame; - grphpoints = 0; - scale = frame.h / max; - x2 = frame.x + frame.w - 1; - y2 = frame.y + frame.h - 1; - r = round((y2) - ref * scale); - DWINUI::Draw_Box(1, Plot_Bg_Color, frame); - for (uint8_t i = 1; i < 4; i++) if (i*50 < frame.w) DWIN_Draw_VLine(Line_Color, i*50 + frame.x, frame.y, frame.h); - DWINUI::Draw_Box(0, Color_White, DWINUI::ExtendFrame(frame, 1)); - DWIN_Draw_HLine(Color_Red, frame.x, r, frame.w); -} - -void PlotClass::Update(const float value) { - if (!scale) return; - uint16_t y = round((y2) - value * scale); - if (grphpoints < grphframe.w) { - DWIN_Draw_Point(Color_Yellow, 1, 1, grphpoints + grphframe.x, y); - } - else { - DWIN_Frame_AreaMove(1, 0, 1, Plot_Bg_Color, grphframe.x, grphframe.y, x2, y2); - if ((grphpoints % 50) == 0) DWIN_Draw_VLine(Line_Color, x2 - 1, grphframe.y + 1, grphframe.h - 2); - DWIN_Draw_Point(Color_Red, 1, 1, x2 - 1, r); - DWIN_Draw_Point(Color_Yellow, 1, 1, x2 - 1, y); - } - grphpoints++; -} - -#endif // HAS_PIDPLOT - -#endif // DWIN_CREALITY_LCD_JYERSUI diff --git a/Marlin/src/lcd/e3v2/jyersui/plot.h b/Marlin/src/lcd/e3v2/jyersui/plot.h deleted file mode 100644 index 1f97eafb71ba..000000000000 --- a/Marlin/src/lcd/e3v2/jyersui/plot.h +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ -#pragma once - -/** - * DWIN Single var plot - * Author: Miguel A. Risco-Castillo - * Version: 1.0 - * Date: 2022/01/30 - * - * Modded for JYERSUI by LCH-77 - */ - -#include "dwinui.h" - -class PlotClass { -public: - void Draw(frame_rect_t frame, float max, float ref = 0); - void Update(float value); -}; - -extern PlotClass Plot; diff --git a/Marlin/src/lcd/e3v2/proui/base64.hpp b/Marlin/src/lcd/e3v2/proui/base64.hpp index 7a933df321b8..d82d0b27e8ac 100644 --- a/Marlin/src/lcd/e3v2/proui/base64.hpp +++ b/Marlin/src/lcd/e3v2/proui/base64.hpp @@ -152,7 +152,7 @@ uint16_t encode_base64(unsigned char input[], uint16_t input_length, unsigned ch output += 4; } - switch (input_length % 3) { + switch(input_length % 3) { case 0: output[0] = '\0'; break; @@ -192,7 +192,7 @@ uint16_t decode_base64(unsigned char input[], uint16_t input_length, unsigned ch output += 3; } - switch (output_length % 3) { + switch(output_length % 3) { case 1: output[0] = base64_to_binary(input[0]) << 2 | base64_to_binary(input[1]) >> 4; break; @@ -205,4 +205,4 @@ uint16_t decode_base64(unsigned char input[], uint16_t input_length, unsigned ch return output_length; } -#endif // BASE64_H_INCLUDED +#endif // ifndef diff --git a/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp b/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp index 4257728f73e3..adb23a96646b 100644 --- a/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp +++ b/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp @@ -21,7 +21,7 @@ */ /** - * DWIN G-code thumbnail preview + * DWIN g-code thumbnail preview * Author: Miguel A. Risco-Castillo * version: 2.1 * Date: 2021/06/19 @@ -214,7 +214,9 @@ bool Has_Preview() { void Preview_DrawFromSD() { if (Has_Preview()) { char buf[46]; - char str_1[6] = "", str_2[6] = "", str_3[6] = ""; + char str_1[6] = ""; + char str_2[6] = ""; + char str_3[6] = ""; DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 0, 0, DWIN_WIDTH, STATUS_Y - 1); if (fileprop.time) { sprintf_P(buf, PSTR("Estimated time: %i:%02i"), (uint16_t)fileprop.time / 3600, ((uint16_t)fileprop.time % 3600) / 60); diff --git a/Marlin/src/lcd/e3v2/proui/gcode_preview.h b/Marlin/src/lcd/e3v2/proui/gcode_preview.h index 97cf7fe5ac9d..4417084a242d 100644 --- a/Marlin/src/lcd/e3v2/proui/gcode_preview.h +++ b/Marlin/src/lcd/e3v2/proui/gcode_preview.h @@ -1,5 +1,5 @@ /** - * DWIN G-code thumbnail preview + * DWIN g-code thumbnail preview * Author: Miguel A. Risco-Castillo * version: 2.1 * Date: 2021/06/19 diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index 84555187677a..933f6a568ee4 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -199,7 +199,7 @@ namespace ExtUI { #endif inline void simulateUserClick() { - #if ANY(HAS_MARLINUI_MENU, EXTENSIBLE_UI, DWIN_CREALITY_LCD_JYERSUI) + #if EITHER(HAS_MARLINUI_MENU, EXTENSIBLE_UI) ui.lcd_clicked = true; #endif } diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 7d9cb1b679d6..7707cbb05201 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -49,8 +49,6 @@ MarlinUI ui; #include "e3v2/creality/dwin.h" #elif ENABLED(DWIN_LCD_PROUI) #include "e3v2/proui/dwin.h" -#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) - #include "e3v2/jyersui/dwin.h" #endif #if ENABLED(LCD_PROGRESS_BAR) && !IS_TFTGLCD_PANEL @@ -161,7 +159,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; bool MarlinUI::lcd_clicked; #endif -#if EITHER(HAS_WIRED_LCD, DWIN_CREALITY_LCD_JYERSUI) +#if HAS_WIRED_LCD bool MarlinUI::get_blink() { static uint8_t blink = 0; @@ -1575,7 +1573,6 @@ void MarlinUI::init() { TERN_(EXTENSIBLE_UI, ExtUI::onStatusChanged(status_message)); TERN_(DWIN_CREALITY_LCD, DWIN_StatusChanged(status_message)); TERN_(DWIN_LCD_PROUI, DWIN_CheckStatusMessage()); - TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWIN.Update_Status(status_message)); } #if ENABLED(STATUS_MESSAGE_SCROLLING) diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index 1c2c48432322..82b8d78a022c 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -87,11 +87,9 @@ typedef bool (*statusResetFunc_t)(); #endif // HAS_MARLINUI_MENU -#endif // HAS_WIRED_LCD - -#if EITHER(HAS_WIRED_LCD, DWIN_CREALITY_LCD_JYERSUI) #define LCD_UPDATE_INTERVAL TERN(HAS_TOUCH_BUTTONS, 50, 100) -#endif + +#endif // HAS_WIRED_LCD #if HAS_MARLINUI_U8GLIB enum MarlinFont : uint8_t { @@ -393,7 +391,7 @@ class MarlinUI { static void poweroff(); #endif - #if EITHER(HAS_WIRED_LCD, DWIN_CREALITY_LCD_JYERSUI) + #if HAS_WIRED_LCD static bool get_blink(); #endif @@ -630,7 +628,7 @@ class MarlinUI { static bool use_click() { return false; } #endif - #if ENABLED(ADVANCED_PAUSE_FEATURE) && ANY(HAS_MARLINUI_MENU, EXTENSIBLE_UI, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) + #if ENABLED(ADVANCED_PAUSE_FEATURE) && ANY(HAS_MARLINUI_MENU, EXTENSIBLE_UI, DWIN_LCD_PROUI) static void pause_show_message(const PauseMessage message, const PauseMode mode=PAUSE_MODE_SAME, const uint8_t extruder=active_extruder); #else static void _pause_show_message() {} diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 3d6e14b5f7f1..d21dc92c67c4 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -76,8 +76,6 @@ #include "../lcd/extui/ui_api.h" #elif ENABLED(DWIN_LCD_PROUI) #include "../lcd/e3v2/proui/dwin.h" -#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) - #include "../lcd/e3v2/jyersui/dwin.h" #endif #if ENABLED(HOST_PROMPT_SUPPORT) @@ -502,8 +500,6 @@ typedef struct SettingsDataStruct { // #if ENABLED(DWIN_LCD_PROUI) uint8_t dwin_data[eeprom_data_size]; - #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) - uint8_t dwin_settings[eeprom_data_size]; #endif // @@ -1522,15 +1518,6 @@ void MarlinSettings::postprocess() { } #endif - #if ENABLED(DWIN_CREALITY_LCD_JYERSUI) - { - _FIELD_TEST(dwin_settings); - char dwin_settings[eeprom_data_size] = { 0 }; - CrealityDWIN.Save_Settings(dwin_settings); - EEPROM_WRITE(dwin_settings); - } - #endif - // // Case Light Brightness // @@ -2495,13 +2482,6 @@ void MarlinSettings::postprocess() { EEPROM_READ(dwin_data); if (!validating) DWIN_CopySettingsFrom(dwin_data); } - #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) - { - const char dwin_settings[eeprom_data_size] = { 0 }; - _FIELD_TEST(dwin_settings); - EEPROM_READ(dwin_settings); - if (!validating) CrealityDWIN.Load_Settings(dwin_settings); - } #endif // @@ -2929,8 +2909,6 @@ void MarlinSettings::reset() { #endif #endif - TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWIN.Reset_Settings()); - // // Case Light Brightness // diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index f03213be1fb2..65b79d8bc464 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -53,8 +53,6 @@ #include "../lcd/e3v2/creality/dwin.h" #elif ENABLED(DWIN_LCD_PROUI) #include "../lcd/e3v2/proui/dwin.h" -#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) - #include "../lcd/e3v2/jyersui/dwin.h" #endif #if ENABLED(EXTENSIBLE_UI) @@ -646,14 +644,12 @@ volatile bool Temperature::raw_temps_ready = false; TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_STARTED)); TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(isbed ? PID_BED_START : PID_EXTR_START)); - TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWINClass::DWIN_PidTuning(isbed ? PID_BED_START : PID_EXTR_START)); if (target > GHV(CHAMBER_MAX_TARGET, BED_MAX_TARGET, temp_range[heater_id].maxtemp - (HOTEND_OVERSHOOT))) { SERIAL_ECHOPGM(STR_PID_AUTOTUNE); SERIAL_ECHOLNPGM(STR_PID_TEMP_TOO_HIGH); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH)); TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_TEMP_TOO_HIGH)); - TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWINClass::DWIN_PidTuning(PID_TEMP_TOO_HIGH)); TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_TEMP_TOO_HIGH))); return; } @@ -748,7 +744,6 @@ volatile bool Temperature::raw_temps_ready = false; SERIAL_ECHOLNPGM(STR_PID_TEMP_TOO_HIGH); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH)); TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_TEMP_TOO_HIGH)); - TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWINClass::DWIN_PidTuning(PID_TEMP_TOO_HIGH)); TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_TEMP_TOO_HIGH))); break; } @@ -787,7 +782,6 @@ volatile bool Temperature::raw_temps_ready = false; TERN_(DWIN_CREALITY_LCD, DWIN_Popup_Temperature(0)); TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_TUNING_TIMEOUT)); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TUNING_TIMEOUT)); - TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWINClass::DWIN_PidTuning(PID_TUNING_TIMEOUT)); TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_TIMEOUT))); SERIAL_ECHOPGM(STR_PID_AUTOTUNE); SERIAL_ECHOLNPGM(STR_PID_TIMEOUT); @@ -845,7 +839,6 @@ volatile bool Temperature::raw_temps_ready = false; TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_DONE)); TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_DONE)); - TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWINClass::DWIN_PidTuning(PID_DONE)); goto EXIT_M303; } @@ -864,7 +857,6 @@ volatile bool Temperature::raw_temps_ready = false; TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_DONE)); TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_DONE)); - TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWINClass::DWIN_PidTuning(PID_DONE)); EXIT_M303: TERN_(NO_FAN_SLOWING_IN_PID_TUNING, adaptive_fan_slowing = true); diff --git a/buildroot/tests/STM32F103RE_creality b/buildroot/tests/STM32F103RE_creality index f1478bc2c421..bf1634544937 100755 --- a/buildroot/tests/STM32F103RE_creality +++ b/buildroot/tests/STM32F103RE_creality @@ -13,11 +13,6 @@ use_example_configs "Creality/Ender-3 V2/CrealityV422/CrealityUI" opt_enable MARLIN_DEV_MODE BUFFER_MONITORING BLTOUCH AUTO_BED_LEVELING_BILINEAR Z_SAFE_HOMING exec_test $1 $2 "Ender 3 v2 with CrealityUI" "$3" -use_example_configs "Creality/Ender-3 V2/CrealityV422/CrealityUI" -opt_disable DWIN_CREALITY_LCD -opt_enable DWIN_CREALITY_LCD_JYERSUI AUTO_BED_LEVELING_BILINEAR PROBE_MANUALLY -exec_test $1 $2 "Ender 3 v2 with JyersUI" "$3" - use_example_configs "Creality/Ender-3 S1/STM32F1" opt_disable DWIN_CREALITY_LCD Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN AUTO_BED_LEVELING_BILINEAR CONFIGURATION_EMBEDDING CANCEL_OBJECTS FWRETRACT opt_enable DWIN_LCD_PROUI INDIVIDUAL_AXIS_HOMING_SUBMENU LCD_SET_PROGRESS_MANUALLY STATUS_MESSAGE_SCROLLING \ diff --git a/ini/features.ini b/ini/features.ini index 355544029e0c..6fd8a7950bae 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -49,7 +49,6 @@ SPI_EEPROM = src_filter=+ DWIN_CREALITY_LCD = src_filter=+ DWIN_LCD_PROUI = src_filter=+ -DWIN_CREALITY_LCD_JYERSUI = src_filter=+ IS_DWIN_MARLINUI = src_filter=+ HAS_GRAPHICAL_TFT = src_filter=+ IS_TFTGLCD_PANEL = src_filter=+ From 527fe2496af924c47411c7aa3c3622b22d04b42e Mon Sep 17 00:00:00 2001 From: Farva42 <100859196+Farva42@users.noreply.github.com> Date: Wed, 6 Jul 2022 19:40:09 -0600 Subject: [PATCH 14/32] =?UTF-8?q?=E2=9C=A8=20MAG=5FMOUNTED=5FPROBE=20(#244?= =?UTF-8?q?20)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Scott Lahteine --- Marlin/Configuration.h | 21 +++++++++++ Marlin/Configuration_adv.h | 3 ++ Marlin/src/inc/Conditionals_LCD.h | 11 +++--- Marlin/src/inc/Conditionals_adv.h | 4 +++ Marlin/src/inc/SanityCheck.h | 13 +++++-- Marlin/src/lcd/menu/menu_motion.cpp | 8 +++++ Marlin/src/module/probe.cpp | 54 +++++++++++++++++++++++++++-- 7 files changed, 105 insertions(+), 9 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 788bd6407553..e05428ad08d8 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1343,6 +1343,27 @@ #define Z_PROBE_RETRACT_X X_MAX_POS #endif +/** + * Magnetically Mounted Probe + * For probes such as Euclid, Klicky, Klackender, etc. + */ +//#define MAG_MOUNTED_PROBE +#if ENABLED(MAG_MOUNTED_PROBE) + #define PROBE_DEPLOY_FEEDRATE (133*60) // (mm/min) Probe deploy speed + #define PROBE_STOW_FEEDRATE (133*60) // (mm/min) Probe stow speed + + #define MAG_MOUNTED_DEPLOY_1 { PROBE_DEPLOY_FEEDRATE, { 245, 114, 30 } } // Move to side Dock & Attach probe + #define MAG_MOUNTED_DEPLOY_2 { PROBE_DEPLOY_FEEDRATE, { 210, 114, 30 } } // Move probe off dock + #define MAG_MOUNTED_DEPLOY_3 { PROBE_DEPLOY_FEEDRATE, { 0, 0, 0 } } // Extra move if needed + #define MAG_MOUNTED_DEPLOY_4 { PROBE_DEPLOY_FEEDRATE, { 0, 0, 0 } } // Extra move if needed + #define MAG_MOUNTED_DEPLOY_5 { PROBE_DEPLOY_FEEDRATE, { 0, 0, 0 } } // Extra move if needed + #define MAG_MOUNTED_STOW_1 { PROBE_STOW_FEEDRATE, { 245, 114, 20 } } // Move to dock + #define MAG_MOUNTED_STOW_2 { PROBE_STOW_FEEDRATE, { 245, 114, 0 } } // Place probe beside remover + #define MAG_MOUNTED_STOW_3 { PROBE_STOW_FEEDRATE, { 230, 114, 0 } } // Side move to remove probe + #define MAG_MOUNTED_STOW_4 { PROBE_STOW_FEEDRATE, { 210, 114, 20 } } // Side move to remove probe + #define MAG_MOUNTED_STOW_5 { PROBE_STOW_FEEDRATE, { 0, 0, 0 } } // Extra move if needed +#endif + // Duet Smart Effector (for delta printers) - https://bit.ly/2ul5U7J // When the pin is defined you can use M672 to set/reset the probe sensitivity. //#define DUET_SMART_EFFECTOR diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index b4627a9830a0..7f85b241a2ea 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1319,6 +1319,9 @@ #define XATC_Y_POSITION Y_CENTER // (mm) Y position to probe #define XATC_Z_OFFSETS { 0, 0, 0 } // Z offsets for X axis sample points #endif + + // Show Deploy / Stow Probe options in the Motion menu. + #define PROBE_DEPLOY_STOW_MENU #endif // Include a page of printer information in the LCD Main Menu diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index b8cf66c8c41a..fc66f5359ccd 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -1047,9 +1047,12 @@ #endif /** - * Set a flag for any type of bed probe, including the paper-test + * Set flags for any form of bed probe */ -#if ANY(HAS_Z_SERVO_PROBE, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, TOUCH_MI_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, SOLENOID_PROBE, SENSORLESS_PROBING, RACK_AND_PINION_PROBE, MAGLEV4) +#if ANY(TOUCH_MI_PROBE, Z_PROBE_ALLEN_KEY, SOLENOID_PROBE, Z_PROBE_SLED, RACK_AND_PINION_PROBE, SENSORLESS_PROBING, MAGLEV4, MAG_MOUNTED_PROBE) + #define HAS_STOWABLE_PROBE 1 +#endif +#if ANY(HAS_STOWABLE_PROBE, HAS_Z_SERVO_PROBE, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE) #define HAS_BED_PROBE 1 #endif @@ -1207,13 +1210,13 @@ #if NONE(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN, HAS_DELTA_SENSORLESS_PROBING) #define USES_Z_MIN_PROBE_PIN 1 #endif - #if Z_HOME_TO_MIN && TERN1(USES_Z_MIN_PROBE_PIN, ENABLED(USE_PROBE_FOR_Z_HOMING)) + #if Z_HOME_TO_MIN && (DISABLED(USES_Z_MIN_PROBE_PIN) || USE_PROBE_FOR_Z_HOMING) #define HOMING_Z_WITH_PROBE 1 #endif #ifndef Z_PROBE_LOW_POINT #define Z_PROBE_LOW_POINT -5 #endif - #if ENABLED(Z_PROBE_ALLEN_KEY) + #if EITHER(Z_PROBE_ALLEN_KEY, MAG_MOUNTED_PROBE) #define PROBE_TRIGGERED_WHEN_STOWED_TEST 1 // Extra test for Allen Key Probe #endif #if MULTIPLE_PROBING > 1 diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 2a204c6cf3c2..9931409976b6 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -79,6 +79,10 @@ #define SERVO_DELAY { 50 } #endif +#if !HAS_STOWABLE_PROBE + #undef PROBE_DEPLOY_STOW_MENU +#endif + #if !HAS_EXTRUDERS #define NO_VOLUMETRICS #undef TEMP_SENSOR_0 diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index f75a59b9b4c1..4412fbb41e5e 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1627,8 +1627,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS */ #if 1 < 0 \ + (DISABLED(BLTOUCH) && HAS_Z_SERVO_PROBE) \ - + COUNT_ENABLED(PROBE_MANUALLY, BLTOUCH, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, TOUCH_MI_PROBE, SOLENOID_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, RACK_AND_PINION_PROBE, SENSORLESS_PROBING, MAGLEV4) - #error "Please enable only one probe option: PROBE_MANUALLY, SENSORLESS_PROBING, BLTOUCH, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, TOUCH_MI_PROBE, SOLENOID_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, MAGLEV4, or Z Servo." + + COUNT_ENABLED(PROBE_MANUALLY, BLTOUCH, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, TOUCH_MI_PROBE, SOLENOID_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, RACK_AND_PINION_PROBE, SENSORLESS_PROBING, MAGLEV4, MAG_MOUNTED_PROBE) + #error "Please enable only one probe option: PROBE_MANUALLY, SENSORLESS_PROBING, BLTOUCH, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, TOUCH_MI_PROBE, SOLENOID_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, MAGLEV4, MAG_MOUNTED_PROBE or Z Servo." #endif #if HAS_BED_PROBE @@ -1734,13 +1734,20 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #endif + /** + * Mag mounted probe requirements + */ + #if BOTH(MAG_MOUNTED_PROBE, USE_PROBE_FOR_Z_HOMING) && DISABLED(Z_SAFE_HOMING) + #error "MAG_MOUNTED_PROBE requires Z_SAFE_HOMING if it's being used to home Z." + #endif + /** * MagLev V4 probe requirements */ #if ENABLED(MAGLEV4) #if !PIN_EXISTS(MAGLEV_TRIGGER) #error "MAGLEV4 requires MAGLEV_TRIGGER_PIN to be defined." - #elif DISABLED(Z_SAFE_HOMING) + #elif ENABLED(HOMING_Z_WITH_PROBE) && DISABLED(Z_SAFE_HOMING) #error "MAGLEV4 requires Z_SAFE_HOMING." #elif MAGLEV_TRIGGER_DELAY != 15 #error "MAGLEV_TRIGGER_DELAY should not be changed. Comment out this line to continue." diff --git a/Marlin/src/lcd/menu/menu_motion.cpp b/Marlin/src/lcd/menu/menu_motion.cpp index cebc2eb31734..3765fe1e4a47 100644 --- a/Marlin/src/lcd/menu/menu_motion.cpp +++ b/Marlin/src/lcd/menu/menu_motion.cpp @@ -348,6 +348,14 @@ void menu_motion() { GCODES_ITEM(MSG_AUTO_Z_ALIGN, F("G34")); #endif + // + // Probe Deploy/Stow + // + #if ENABLED(PROBE_DEPLOY_STOW_MENU) + GCODES_ITEM(MSG_MANUAL_DEPLOY, F("M401")); + GCODES_ITEM(MSG_MANUAL_STOW, F("M402")); + #endif + // // Assisted Bed Tramming // diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index ed8d4a1429a7..afe5ba7a7416 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -264,7 +264,57 @@ xyz_pos_t Probe::offset; // Initialized by settings.load() #endif } -#endif // Z_PROBE_ALLEN_KEY +#elif ENABLED(MAG_MOUNTED_PROBE) + + typedef struct { float fr_mm_min; xyz_pos_t where; } mag_probe_move_t; + + inline void run_deploy_moves_script() { + #ifdef MAG_MOUNTED_DEPLOY_1 + constexpr mag_probe_move_t deploy_1 = MAG_MOUNTED_DEPLOY_1; + do_blocking_move_to(deploy_1.where, MMM_TO_MMS(deploy_1.fr_mm_min)); + #endif + #ifdef MAG_MOUNTED_DEPLOY_2 + constexpr mag_probe_move_t deploy_2 = MAG_MOUNTED_DEPLOY_2; + do_blocking_move_to(deploy_2.where, MMM_TO_MMS(deploy_2.fr_mm_min)); + #endif + #ifdef MAG_MOUNTED_DEPLOY_3 + constexpr mag_probe_move_t deploy_3 = MAG_MOUNTED_DEPLOY_3; + do_blocking_move_to(deploy_3.where, MMM_TO_MMS(deploy_3.fr_mm_min)); + #endif + #ifdef MAG_MOUNTED_DEPLOY_4 + constexpr mag_probe_move_t deploy_4 = MAG_MOUNTED_DEPLOY_4; + do_blocking_move_to(deploy_4.where, MMM_TO_MMS(deploy_4.fr_mm_min)); + #endif + #ifdef MAG_MOUNTED_DEPLOY_5 + constexpr mag_probe_move_t deploy_5 = MAG_MOUNTED_DEPLOY_5; + do_blocking_move_to(deploy_5.where, MMM_TO_MMS(deploy_5.fr_mm_min)); + #endif + } + + inline void run_stow_moves_script() { + #ifdef MAG_MOUNTED_STOW_1 + constexpr mag_probe_move_t stow_1 = MAG_MOUNTED_STOW_1; + do_blocking_move_to(stow_1.where, MMM_TO_MMS(stow_1.fr_mm_min)); + #endif + #ifdef MAG_MOUNTED_STOW_2 + constexpr mag_probe_move_t stow_2 = MAG_MOUNTED_STOW_2; + do_blocking_move_to(stow_2.where, MMM_TO_MMS(stow_2.fr_mm_min)); + #endif + #ifdef MAG_MOUNTED_STOW_3 + constexpr mag_probe_move_t stow_3 = MAG_MOUNTED_STOW_3; + do_blocking_move_to(stow_3.where, MMM_TO_MMS(stow_3.fr_mm_min)); + #endif + #ifdef MAG_MOUNTED_STOW_4 + constexpr mag_probe_move_t stow_4 = MAG_MOUNTED_STOW_4; + do_blocking_move_to(stow_4.where, MMM_TO_MMS(stow_4.fr_mm_min)); + #endif + #ifdef MAG_MOUNTED_STOW_5 + constexpr mag_probe_move_t stow_5 = MAG_MOUNTED_STOW_5; + do_blocking_move_to(stow_5.where, MMM_TO_MMS(stow_5.fr_mm_min)); + #endif + } + +#endif // MAG_MOUNTED_PROBE #if HAS_QUIET_PROBING @@ -350,7 +400,7 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { servo[Z_PROBE_SERVO_NR].move(servo_angles[Z_PROBE_SERVO_NR][deploy ? 0 : 1]); - #elif EITHER(TOUCH_MI_PROBE, Z_PROBE_ALLEN_KEY) + #elif ANY(TOUCH_MI_PROBE, Z_PROBE_ALLEN_KEY, MAG_MOUNTED_PROBE) deploy ? run_deploy_moves_script() : run_stow_moves_script(); From d9ecbdcdbb8f5073987c848573d89cfb63719201 Mon Sep 17 00:00:00 2001 From: Pauli Jokela Date: Thu, 7 Jul 2022 18:59:23 +0300 Subject: [PATCH 15/32] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20safe=20homing=20sani?= =?UTF-8?q?ty-check=20(#24462)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/Conditionals_LCD.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index fc66f5359ccd..12314e649285 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -1210,7 +1210,7 @@ #if NONE(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN, HAS_DELTA_SENSORLESS_PROBING) #define USES_Z_MIN_PROBE_PIN 1 #endif - #if Z_HOME_TO_MIN && (DISABLED(USES_Z_MIN_PROBE_PIN) || USE_PROBE_FOR_Z_HOMING) + #if Z_HOME_TO_MIN && (DISABLED(USES_Z_MIN_PROBE_PIN) || ENABLED(USE_PROBE_FOR_Z_HOMING)) #define HOMING_Z_WITH_PROBE 1 #endif #ifndef Z_PROBE_LOW_POINT From 79a332b57ea4a1ddb0e6b06d8dabae34268ed3bd Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Thu, 7 Jul 2022 21:43:56 -0700 Subject: [PATCH 16/32] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20LCD=5FBACKLIGHT=5FTI?= =?UTF-8?q?MEOUT=20compile=20(#24463)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/gcode/gcode.h | 2 +- Marlin/src/gcode/lcd/M255.cpp | 2 +- Marlin/src/inc/Conditionals_adv.h | 4 ++++ Marlin/src/lcd/marlinui.h | 8 ++------ buildroot/tests/mega2560 | 9 +++++---- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 1efcb1cf9345..a6b530a2682a 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -886,7 +886,7 @@ class GcodeSuite { static void M250_report(const bool forReplay=true); #endif - #if HAS_DISPLAY_SLEEP + #if HAS_GCODE_M255 static void M255(); static void M255_report(const bool forReplay=true); #endif diff --git a/Marlin/src/gcode/lcd/M255.cpp b/Marlin/src/gcode/lcd/M255.cpp index cfdf27b8a1fc..4a9049ab2c61 100644 --- a/Marlin/src/gcode/lcd/M255.cpp +++ b/Marlin/src/gcode/lcd/M255.cpp @@ -36,7 +36,7 @@ void GcodeSuite::M255() { const int m = parser.value_int(); ui.sleep_timeout_minutes = constrain(m, SLEEP_TIMEOUT_MIN, SLEEP_TIMEOUT_MAX); #else - const int s = parser.value_int() * 60; + const unsigned int s = parser.value_ushort() * 60; ui.lcd_backlight_timeout = constrain(s, LCD_BKL_TIMEOUT_MIN, LCD_BKL_TIMEOUT_MAX); #endif } diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 9931409976b6..0cc1556a837e 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -591,6 +591,10 @@ #define HAS_PRINT_PROGRESS 1 #endif +#if ANY(HAS_MARLINUI_MENU, ULTIPANEL_FEEDMULTIPLY, SOFT_RESET_ON_KILL) + #define HAS_ENCODER_ACTION 1 +#endif + #if STATUS_MESSAGE_TIMEOUT_SEC > 0 #define HAS_STATUS_MESSAGE_TIMEOUT 1 #endif diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index 82b8d78a022c..3e7a9ca1b105 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -32,10 +32,6 @@ #include "tft_io/touch_calibration.h" #endif -#if ANY(HAS_MARLINUI_MENU, ULTIPANEL_FEEDMULTIPLY, SOFT_RESET_ON_KILL) - #define HAS_ENCODER_ACTION 1 -#endif - #if E_MANUAL > 1 #define MULTI_E_MANUAL 1 #endif @@ -271,8 +267,8 @@ class MarlinUI { #endif #if LCD_BACKLIGHT_TIMEOUT - #define LCD_BKL_TIMEOUT_MIN 1 - #define LCD_BKL_TIMEOUT_MAX (60*60*18) // 18 hours max within uint16_t + #define LCD_BKL_TIMEOUT_MIN 1u + #define LCD_BKL_TIMEOUT_MAX UINT16_MAX // Slightly more than 18 hours static uint16_t lcd_backlight_timeout; static millis_t backlight_off_ms; static void refresh_backlight_timeout(); diff --git a/buildroot/tests/mega2560 b/buildroot/tests/mega2560 index 969b3b14ccbc..aa425564fcad 100755 --- a/buildroot/tests/mega2560 +++ b/buildroot/tests/mega2560 @@ -206,16 +206,17 @@ opt_enable REPRAP_DISCOUNT_SMART_CONTROLLER SDSUPPORT EEPROM_SETTINGS EEPROM_BOO exec_test $1 $2 "MEGA2560 RAMPS | Laser Feature | Air Evacuation | Air Assist | Cooler | Laser Safety Timeout | Flowmeter | 44780 LCD " "$3" # -# Test redundant temperature sensors + MAX TC +# Test redundant temperature sensors + MAX TC + Backlight Timeout # restore_configs opt_set MOTHERBOARD BOARD_RAMPS_14_EFB EXTRUDERS 1 \ TEMP_SENSOR_0 -2 TEMP_SENSOR_REDUNDANT -2 \ TEMP_SENSOR_REDUNDANT_SOURCE E1 TEMP_SENSOR_REDUNDANT_TARGET E0 \ - TEMP_0_CS_PIN 11 TEMP_1_CS_PIN 12 -opt_enable MPCTEMP + TEMP_0_CS_PIN 11 TEMP_1_CS_PIN 12 \ + LCD_BACKLIGHT_TIMEOUT 30 +opt_enable MPCTEMP MINIPANEL opt_disable PIDTEMP -exec_test $1 $2 "MEGA2560 RAMPS | Redundant temperature sensor | 2x MAX6675" "$3" +exec_test $1 $2 "MEGA2560 RAMPS | Redundant temperature sensor | 2x MAX6675 | BL Timeout" "$3" # # Polargraph Config From 0c78a6f65791e1c2c3f4278ed2b48bcf20b9b063 Mon Sep 17 00:00:00 2001 From: tombrazier <68918209+tombrazier@users.noreply.github.com> Date: Fri, 8 Jul 2022 20:41:39 +0100 Subject: [PATCH 17/32] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Optimize=20G2-G3=20A?= =?UTF-8?q?rcs=20(#24366)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/feature/bedlevel/ubl/ubl_motion.cpp | 17 +- Marlin/src/feature/joystick.cpp | 3 +- Marlin/src/gcode/motion/G2_G3.cpp | 26 +- Marlin/src/module/motion.cpp | 32 +- Marlin/src/module/planner.cpp | 426 +++++++++--------- Marlin/src/module/planner.h | 61 ++- Marlin/src/module/planner_bezier.cpp | 7 +- Marlin/src/module/stepper.cpp | 27 +- 8 files changed, 327 insertions(+), 272 deletions(-) diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp index 9fa2257dc8a6..8121a0b9b5bb 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp @@ -374,11 +374,12 @@ #endif NOLESS(segments, 1U); // Must have at least one segment - const float inv_segments = 1.0f / segments, // Reciprocal to save calculation - segment_xyz_mm = SQRT(cart_xy_mm_2 + sq(total.z)) * inv_segments; // Length of each segment + const float inv_segments = 1.0f / segments; // Reciprocal to save calculation + // Add hints to help optimize the move + PlannerHints hints(SQRT(cart_xy_mm_2 + sq(total.z)) * inv_segments); // Length of each segment #if ENABLED(SCARA_FEEDRATE_SCALING) - const float inv_duration = scaled_fr_mm_s / segment_xyz_mm; + hints.inv_duration = scaled_fr_mm_s / hints.millimeters; #endif xyze_float_t diff = total * inv_segments; @@ -392,13 +393,9 @@ if (!planner.leveling_active || !planner.leveling_active_at_z(destination.z)) { while (--segments) { raw += diff; - planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, segment_xyz_mm - OPTARG(SCARA_FEEDRATE_SCALING, inv_duration) - ); + planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, hints); } - planner.buffer_line(destination, scaled_fr_mm_s, active_extruder, segment_xyz_mm - OPTARG(SCARA_FEEDRATE_SCALING, inv_duration) - ); + planner.buffer_line(destination, scaled_fr_mm_s, active_extruder, hints); return false; // Did not set current from destination } @@ -467,7 +464,7 @@ TERN_(ENABLE_LEVELING_FADE_HEIGHT, * fade_scaling_factor); // apply fade factor to interpolated height const float oldz = raw.z; raw.z += z_cxcy; - planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, segment_xyz_mm OPTARG(SCARA_FEEDRATE_SCALING, inv_duration) ); + planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, hints); raw.z = oldz; if (segments == 0) // done with last segment diff --git a/Marlin/src/feature/joystick.cpp b/Marlin/src/feature/joystick.cpp index daa642d32e36..acab5d7437a2 100644 --- a/Marlin/src/feature/joystick.cpp +++ b/Marlin/src/feature/joystick.cpp @@ -172,8 +172,9 @@ Joystick joystick; current_position += move_dist; apply_motion_limits(current_position); const float length = sqrt(hypot2); + PlannerHints hints(length); injecting_now = true; - planner.buffer_line(current_position, length / seg_time, active_extruder, length); + planner.buffer_line(current_position, length / seg_time, active_extruder, hints); injecting_now = false; } } diff --git a/Marlin/src/gcode/motion/G2_G3.cpp b/Marlin/src/gcode/motion/G2_G3.cpp index 14ef9ac2a6f4..c45204c6f6f2 100644 --- a/Marlin/src/gcode/motion/G2_G3.cpp +++ b/Marlin/src/gcode/motion/G2_G3.cpp @@ -214,9 +214,12 @@ void plan_arc( const uint16_t segments = nominal_segment_mm > (MAX_ARC_SEGMENT_MM) ? CEIL(flat_mm / (MAX_ARC_SEGMENT_MM)) : nominal_segment_mm < (MIN_ARC_SEGMENT_MM) ? _MAX(1, FLOOR(flat_mm / (MIN_ARC_SEGMENT_MM))) : nominal_segments; + const float segment_mm = flat_mm / segments; + // Add hints to help optimize the move + PlannerHints hints; #if ENABLED(SCARA_FEEDRATE_SCALING) - const float inv_duration = (scaled_fr_mm_s / flat_mm) * segments; + hints.inv_duration = (scaled_fr_mm_s / flat_mm) * segments; #endif /** @@ -288,6 +291,16 @@ void plan_arc( int8_t arc_recalc_count = N_ARC_CORRECTION; #endif + // An arc can always complete within limits from a speed which... + // a) is <= any configured maximum speed, + // b) does not require centripetal force greater than any configured maximum acceleration, + // c) allows the print head to stop in the remining length of the curve within all configured maximum accelerations. + // The last has to be calculated every time through the loop. + const float limiting_accel = _MIN(planner.settings.max_acceleration_mm_per_s2[axis_p], planner.settings.max_acceleration_mm_per_s2[axis_q]), + limiting_speed = _MIN(planner.settings.max_feedrate_mm_s[axis_p], planner.settings.max_acceleration_mm_per_s2[axis_q]), + limiting_speed_sqr = _MIN(sq(limiting_speed), limiting_accel * radius); + float arc_mm_remaining = flat_mm; + for (uint16_t i = 1; i < segments; i++) { // Iterate (segments-1) times thermalManager.task(); @@ -342,7 +355,13 @@ void plan_arc( planner.apply_leveling(raw); #endif - if (!planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, 0 OPTARG(SCARA_FEEDRATE_SCALING, inv_duration))) + // calculate safe speed for stopping by the end of the arc + arc_mm_remaining -= segment_mm; + + hints.curve_radius = i > 1 ? radius : 0; + hints.safe_exit_speed_sqr = _MIN(limiting_speed_sqr, 2 * limiting_accel * arc_mm_remaining); + + if (!planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, hints)) break; } } @@ -363,7 +382,8 @@ void plan_arc( planner.apply_leveling(raw); #endif - planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, 0 OPTARG(SCARA_FEEDRATE_SCALING, inv_duration)); + hints.curve_radius = 0; + planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, hints); #if ENABLED(AUTO_BED_LEVELING_UBL) ARC_LIJKUVW_CODE( diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index b3b607e677a8..eaf3ab540957 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -1041,19 +1041,18 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { NOLESS(segments, 1U); // The approximate length of each segment - const float inv_segments = 1.0f / float(segments), - cartesian_segment_mm = cartesian_mm * inv_segments; + const float inv_segments = 1.0f / float(segments); const xyze_float_t segment_distance = diff * inv_segments; - #if ENABLED(SCARA_FEEDRATE_SCALING) - const float inv_duration = scaled_fr_mm_s / cartesian_segment_mm; - #endif + // Add hints to help optimize the move + PlannerHints hints(cartesian_mm * inv_segments); + TERN_(SCARA_FEEDRATE_SCALING, hints.inv_duration = scaled_fr_mm_s / hints.millimeters); /* SERIAL_ECHOPGM("mm=", cartesian_mm); SERIAL_ECHOPGM(" seconds=", seconds); SERIAL_ECHOPGM(" segments=", segments); - SERIAL_ECHOPGM(" segment_mm=", cartesian_segment_mm); + SERIAL_ECHOPGM(" segment_mm=", hints.millimeters); SERIAL_EOL(); //*/ @@ -1065,11 +1064,12 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { while (--segments) { segment_idle(next_idle_ms); raw += segment_distance; - if (!planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, cartesian_segment_mm OPTARG(SCARA_FEEDRATE_SCALING, inv_duration))) break; + if (!planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, hints)) + break; } // Ensure last segment arrives at target location. - planner.buffer_line(destination, scaled_fr_mm_s, active_extruder, cartesian_segment_mm OPTARG(SCARA_FEEDRATE_SCALING, inv_duration)); + planner.buffer_line(destination, scaled_fr_mm_s, active_extruder, hints); return false; // caller will update current_position } @@ -1108,17 +1108,16 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { NOLESS(segments, 1U); // The approximate length of each segment - const float inv_segments = 1.0f / float(segments), - cartesian_segment_mm = cartesian_mm * inv_segments; + const float inv_segments = 1.0f / float(segments); const xyze_float_t segment_distance = diff * inv_segments; - #if ENABLED(SCARA_FEEDRATE_SCALING) - const float inv_duration = scaled_fr_mm_s / cartesian_segment_mm; - #endif + // Add hints to help optimize the move + PlannerHints hints(cartesian_mm * inv_segments); + TERN_(SCARA_FEEDRATE_SCALING, hints.inv_duration = scaled_fr_mm_s / hints.millimeters); //SERIAL_ECHOPGM("mm=", cartesian_mm); //SERIAL_ECHOLNPGM(" segments=", segments); - //SERIAL_ECHOLNPGM(" segment_mm=", cartesian_segment_mm); + //SERIAL_ECHOLNPGM(" segment_mm=", hints.millimeters); // Get the raw current position as starting point xyze_pos_t raw = current_position; @@ -1128,12 +1127,13 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { while (--segments) { segment_idle(next_idle_ms); raw += segment_distance; - if (!planner.buffer_line(raw, fr_mm_s, active_extruder, cartesian_segment_mm OPTARG(SCARA_FEEDRATE_SCALING, inv_duration))) break; + if (!planner.buffer_line(raw, fr_mm_s, active_extruder, hints)) + break; } // Since segment_distance is only approximate, // the final move must be to the exact destination. - planner.buffer_line(destination, fr_mm_s, active_extruder, cartesian_segment_mm OPTARG(SCARA_FEEDRATE_SCALING, inv_duration)); + planner.buffer_line(destination, fr_mm_s, active_extruder, hints); } #endif // SEGMENT_LEVELED_MOVES && !AUTO_BED_LEVELING_UBL diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index bc5bfd3dfcc4..7b00552dffa2 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -843,20 +843,22 @@ void Planner::calculate_trapezoid_for_block(block_t * const block, const_float_t /** * Laser Trapezoid Calculations * - * Approximate the trapezoid with the laser, incrementing the power every `trap_ramp_entry_incr` steps while accelerating, - * and decrementing the power every `trap_ramp_exit_decr` while decelerating, to keep power proportional to feedrate. - * Laser power trap will reduce the initial power to no less than the laser_power_floor value. Based on the number - * of calculated accel/decel steps the power is distributed over the trapezoid entry- and exit-ramp steps. + * Approximate the trapezoid with the laser, incrementing the power every `trap_ramp_entry_incr` + * steps while accelerating, and decrementing the power every `trap_ramp_exit_decr` while decelerating, + * to keep power proportional to feedrate. Laser power trap will reduce the initial power to no less + * than the laser_power_floor value. Based on the number of calculated accel/decel steps the power is + * distributed over the trapezoid entry- and exit-ramp steps. * - * trap_ramp_active_pwr - The active power is initially set at a reduced level factor of initial power / accel steps and - * will be additively incremented using a trap_ramp_entry_incr value for each accel step processed later in the stepper code. - * The trap_ramp_exit_decr value is calculated as power / decel steps and is also adjusted to no less than the power floor. + * trap_ramp_active_pwr - The active power is initially set at a reduced level factor of initial + * power / accel steps and will be additively incremented using a trap_ramp_entry_incr value for each + * accel step processed later in the stepper code. The trap_ramp_exit_decr value is calculated as + * power / decel steps and is also adjusted to no less than the power floor. * - * If the power == 0 the inline mode variables need to be set to zero to prevent stepper processing. The method allows - * for simpler non-powered moves like G0 or G28. + * If the power == 0 the inline mode variables need to be set to zero to prevent stepper processing. + * The method allows for simpler non-powered moves like G0 or G28. * - * Laser Trap Power works for all Jerk and Curve modes; however Arc-based moves will have issues since the segments are - * usually too small. + * Laser Trap Power works for all Jerk and Curve modes; however Arc-based moves will have issues since + * the segments are usually too small. */ if (cutter.cutter_mode == CUTTER_MODE_CONTINUOUS) { if (planner.laser_inline.status.isPowered && planner.laser_inline.status.isEnabled) { @@ -937,20 +939,30 @@ void Planner::calculate_trapezoid_for_block(block_t * const block, const_float_t this block can never be less than block_buffer_tail and will always be pushed forward and maintain this requirement when encountered by the Planner::release_current_block() routine during a cycle. - NOTE: Since the planner only computes on what's in the planner buffer, some motions with lots of short - line segments, like G2/3 arcs or complex curves, may seem to move slow. This is because there simply isn't - enough combined distance traveled in the entire buffer to accelerate up to the nominal speed and then - decelerate to a complete stop at the end of the buffer, as stated by the guidelines. If this happens and - becomes an annoyance, there are a few simple solutions: (1) Maximize the machine acceleration. The planner - will be able to compute higher velocity profiles within the same combined distance. (2) Maximize line - motion(s) distance per block to a desired tolerance. The more combined distance the planner has to use, - the faster it can go. (3) Maximize the planner buffer size. This also will increase the combined distance - for the planner to compute over. It also increases the number of computations the planner has to perform - to compute an optimal plan, so select carefully. + NOTE: Since the planner only computes on what's in the planner buffer, some motions with many short + segments (e.g., complex curves) may seem to move slowly. This is because there simply isn't + enough combined distance traveled in the entire buffer to accelerate up to the nominal speed and + then decelerate to a complete stop at the end of the buffer, as stated by the guidelines. If this + happens and becomes an annoyance, there are a few simple solutions: + + - Maximize the machine acceleration. The planner will be able to compute higher velocity profiles + within the same combined distance. + + - Maximize line motion(s) distance per block to a desired tolerance. The more combined distance the + planner has to use, the faster it can go. + + - Maximize the planner buffer size. This also will increase the combined distance for the planner to + compute over. It also increases the number of computations the planner has to perform to compute an + optimal plan, so select carefully. + + - Use G2/G3 arcs instead of many short segments. Arcs inform the planner of a safe exit speed at the + end of the last segment, which alleviates this problem. */ // The kernel called by recalculate() when scanning the plan from last to first entry. -void Planner::reverse_pass_kernel(block_t * const current, const block_t * const next) { +void Planner::reverse_pass_kernel(block_t * const current, const block_t * const next + OPTARG(HINTS_SAFE_EXIT_SPEED, const_float_t safe_exit_speed_sqr) +) { if (current) { // If entry speed is already at the maximum entry speed, and there was no change of speed // in the next block, there is no need to recheck. Block is cruising and there is no need to @@ -970,9 +982,10 @@ void Planner::reverse_pass_kernel(block_t * const current, const block_t * const // the reverse and forward planners, the corresponding block junction speed will always be at the // the maximum junction speed and may always be ignored for any speed reduction checks. - const float new_entry_speed_sqr = current->flag.nominal_length - ? max_entry_speed_sqr - : _MIN(max_entry_speed_sqr, max_allowable_speed_sqr(-current->acceleration, next ? next->entry_speed_sqr : sq(float(MINIMUM_PLANNER_SPEED)), current->millimeters)); + const float next_entry_speed_sqr = next ? next->entry_speed_sqr : _MAX(TERN0(HINTS_SAFE_EXIT_SPEED, safe_exit_speed_sqr), sq(float(MINIMUM_PLANNER_SPEED))), + new_entry_speed_sqr = current->flag.nominal_length + ? max_entry_speed_sqr + : _MIN(max_entry_speed_sqr, max_allowable_speed_sqr(-current->acceleration, next_entry_speed_sqr, current->millimeters)); if (current->entry_speed_sqr != new_entry_speed_sqr) { // Need to recalculate the block speed - Mark it now, so the stepper @@ -1001,7 +1014,7 @@ void Planner::reverse_pass_kernel(block_t * const current, const block_t * const * recalculate() needs to go over the current plan twice. * Once in reverse and once forward. This implements the reverse pass. */ -void Planner::reverse_pass() { +void Planner::reverse_pass(TERN_(HINTS_SAFE_EXIT_SPEED, const_float_t safe_exit_speed_sqr)) { // Initialize block index to the last block in the planner buffer. uint8_t block_index = prev_block_index(block_buffer_head); @@ -1025,7 +1038,7 @@ void Planner::reverse_pass() { // Only process movement blocks if (current->is_move()) { - reverse_pass_kernel(current, next); + reverse_pass_kernel(current, next OPTARG(HINTS_SAFE_EXIT_SPEED, safe_exit_speed_sqr)); next = current; } @@ -1138,7 +1151,7 @@ void Planner::forward_pass() { * according to the entry_factor for each junction. Must be called by * recalculate() after updating the blocks. */ -void Planner::recalculate_trapezoids() { +void Planner::recalculate_trapezoids(TERN_(HINTS_SAFE_EXIT_SPEED, const_float_t safe_exit_speed_sqr)) { // The tail may be changed by the ISR so get a local copy. uint8_t block_index = block_buffer_tail, head_block_index = block_buffer_head; @@ -1211,8 +1224,10 @@ void Planner::recalculate_trapezoids() { block_index = next_block_index(block_index); } - // Last/newest block in buffer. Exit speed is set with MINIMUM_PLANNER_SPEED. Always recalculated. - if (next) { + // Last/newest block in buffer. Always recalculated. + if (block) { + // Exit speed is set with MINIMUM_PLANNER_SPEED unless some code higher up knows better. + next_entry_speed = _MAX(TERN0(HINTS_SAFE_EXIT_SPEED, SQRT(safe_exit_speed_sqr)), float(MINIMUM_PLANNER_SPEED)); // Mark the next(last) block as RECALCULATE, to prevent the Stepper ISR running it. // As the last block is always recalculated here, there is a chance the block isn't @@ -1225,33 +1240,33 @@ void Planner::recalculate_trapezoids() { if (!stepper.is_block_busy(block)) { // Block is not BUSY, we won the race against the Stepper ISR: - const float next_nominal_speed = SQRT(next->nominal_speed_sqr), - nomr = 1.0f / next_nominal_speed; - calculate_trapezoid_for_block(next, next_entry_speed * nomr, float(MINIMUM_PLANNER_SPEED) * nomr); + const float current_nominal_speed = SQRT(block->nominal_speed_sqr), + nomr = 1.0f / current_nominal_speed; + calculate_trapezoid_for_block(block, current_entry_speed * nomr, next_entry_speed * nomr); #if ENABLED(LIN_ADVANCE) - if (next->use_advance_lead) { - const float comp = next->e_D_ratio * extruder_advance_K[active_extruder] * settings.axis_steps_per_mm[E_AXIS]; - next->max_adv_steps = next_nominal_speed * comp; - next->final_adv_steps = (MINIMUM_PLANNER_SPEED) * comp; + if (block->use_advance_lead) { + const float comp = block->e_D_ratio * extruder_advance_K[active_extruder] * settings.axis_steps_per_mm[E_AXIS]; + block->max_adv_steps = current_nominal_speed * comp; + block->final_adv_steps = next_entry_speed * comp; } #endif } - // Reset next only to ensure its trapezoid is computed - The stepper is free to use + // Reset block to ensure its trapezoid is computed - The stepper is free to use // the block from now on. - next->flag.recalculate = false; + block->flag.recalculate = false; } } -void Planner::recalculate() { +void Planner::recalculate(TERN_(HINTS_SAFE_EXIT_SPEED, const_float_t safe_exit_speed_sqr)) { // Initialize block index to the last block in the planner buffer. const uint8_t block_index = prev_block_index(block_buffer_head); // If there is just one block, no planning can be done. Avoid it! if (block_index != block_buffer_planned) { - reverse_pass(); + reverse_pass(TERN_(HINTS_SAFE_EXIT_SPEED, safe_exit_speed_sqr)); forward_pass(); } - recalculate_trapezoids(); + recalculate_trapezoids(TERN_(HINTS_SAFE_EXIT_SPEED, safe_exit_speed_sqr)); } /** @@ -1777,22 +1792,21 @@ float Planner::get_axis_position_mm(const AxisEnum axis) { void Planner::synchronize() { while (busy()) idle(); } /** - * Planner::_buffer_steps - * - * Add a new linear movement to the planner queue (in terms of steps). + * @brief Add a new linear movement to the planner queue (in terms of steps). * - * target - target position in steps units - * target_float - target position in direct (mm, degrees) units. optional - * fr_mm_s - (target) speed of the move - * extruder - target extruder - * millimeters - the length of the movement, if known + * @param target Target position in steps units + * @param target_float Target position in direct (mm, degrees) units. + * @param cart_dist_mm The pre-calculated move lengths for all axes, in mm + * @param fr_mm_s (target) speed of the move + * @param extruder target extruder + * @param hints parameters to aid planner calculations * - * Returns true if movement was properly queued, false otherwise (if cleaning) + * @return true if movement was properly queued, false otherwise (if cleaning) */ bool Planner::_buffer_steps(const xyze_long_t &target OPTARG(HAS_POSITION_FLOAT, const xyze_pos_t &target_float) OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm) - , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters + , feedRate_t fr_mm_s, const uint8_t extruder, const PlannerHints &hints ) { // Wait for the next available block @@ -1808,7 +1822,7 @@ bool Planner::_buffer_steps(const xyze_long_t &target if (!_populate_block(block, target OPTARG(HAS_POSITION_FLOAT, target_float) OPTARG(HAS_DIST_MM_ARG, cart_dist_mm) - , fr_mm_s, extruder, millimeters + , fr_mm_s, extruder, hints ) ) { // Movement was not queued, probably because it was too short. @@ -1830,7 +1844,7 @@ bool Planner::_buffer_steps(const xyze_long_t &target block_buffer_head = next_buffer_head; // Recalculate and optimize trapezoidal speed profiles - recalculate(); + recalculate(TERN_(HINTS_SAFE_EXIT_SPEED, hints.safe_exit_speed_sqr)); // Movement successfully queued! return true; @@ -1848,8 +1862,7 @@ bool Planner::_buffer_steps(const xyze_long_t &target * @param cart_dist_mm The pre-calculated move lengths for all axes, in mm * @param fr_mm_s (target) speed of the move * @param extruder target extruder - * @param millimeters A pre-calculated linear distance for the move, in mm, - * or 0.0 to have the distance calculated here. + * @param hints parameters to aid planner calculations * * @return true if movement is acceptable, false otherwise */ @@ -1858,7 +1871,7 @@ bool Planner::_populate_block( const abce_long_t &target OPTARG(HAS_POSITION_FLOAT, const xyze_pos_t &target_float) OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm) - , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters/*=0.0*/ + , feedRate_t fr_mm_s, const uint8_t extruder, const PlannerHints &hints ) { int32_t LOGICAL_AXIS_LIST( de = target.e - position.e, @@ -2134,8 +2147,8 @@ bool Planner::_populate_block( block->millimeters = TERN0(HAS_EXTRUDERS, ABS(steps_dist_mm.e)); } else { - if (millimeters) - block->millimeters = millimeters; + if (hints.millimeters) + block->millimeters = hints.millimeters; else { /** * Distance for interpretation of feedrate in accordance with LinuxCNC (the successor of NIST @@ -2243,15 +2256,9 @@ bool Planner::_populate_block( #if ENABLED(AUTO_POWER_CONTROL) if (NUM_AXIS_GANG( - block->steps.x, - || block->steps.y, - || block->steps.z, - || block->steps.i, - || block->steps.j, - || block->steps.k, - || block->steps.u, - || block->steps.v, - || block->steps.w + block->steps.x, || block->steps.y, || block->steps.z, + || block->steps.i, || block->steps.j, || block->steps.k, + || block->steps.u, || block->steps.v, || block->steps.w )) powerManager.power_on(); #endif @@ -2562,29 +2569,17 @@ bool Planner::_populate_block( if (block->step_event_count <= acceleration_long_cutoff) { LOGICAL_AXIS_CODE( LIMIT_ACCEL_LONG(E_AXIS, E_INDEX_N(extruder)), - LIMIT_ACCEL_LONG(A_AXIS, 0), - LIMIT_ACCEL_LONG(B_AXIS, 0), - LIMIT_ACCEL_LONG(C_AXIS, 0), - LIMIT_ACCEL_LONG(I_AXIS, 0), - LIMIT_ACCEL_LONG(J_AXIS, 0), - LIMIT_ACCEL_LONG(K_AXIS, 0), - LIMIT_ACCEL_LONG(U_AXIS, 0), - LIMIT_ACCEL_LONG(V_AXIS, 0), - LIMIT_ACCEL_LONG(W_AXIS, 0) + LIMIT_ACCEL_LONG(A_AXIS, 0), LIMIT_ACCEL_LONG(B_AXIS, 0), LIMIT_ACCEL_LONG(C_AXIS, 0), + LIMIT_ACCEL_LONG(I_AXIS, 0), LIMIT_ACCEL_LONG(J_AXIS, 0), LIMIT_ACCEL_LONG(K_AXIS, 0), + LIMIT_ACCEL_LONG(U_AXIS, 0), LIMIT_ACCEL_LONG(V_AXIS, 0), LIMIT_ACCEL_LONG(W_AXIS, 0) ); } else { LOGICAL_AXIS_CODE( LIMIT_ACCEL_FLOAT(E_AXIS, E_INDEX_N(extruder)), - LIMIT_ACCEL_FLOAT(A_AXIS, 0), - LIMIT_ACCEL_FLOAT(B_AXIS, 0), - LIMIT_ACCEL_FLOAT(C_AXIS, 0), - LIMIT_ACCEL_FLOAT(I_AXIS, 0), - LIMIT_ACCEL_FLOAT(J_AXIS, 0), - LIMIT_ACCEL_FLOAT(K_AXIS, 0), - LIMIT_ACCEL_FLOAT(U_AXIS, 0), - LIMIT_ACCEL_FLOAT(V_AXIS, 0), - LIMIT_ACCEL_FLOAT(W_AXIS, 0) + LIMIT_ACCEL_FLOAT(A_AXIS, 0), LIMIT_ACCEL_FLOAT(B_AXIS, 0), LIMIT_ACCEL_FLOAT(C_AXIS, 0), + LIMIT_ACCEL_FLOAT(I_AXIS, 0), LIMIT_ACCEL_FLOAT(J_AXIS, 0), LIMIT_ACCEL_FLOAT(K_AXIS, 0), + LIMIT_ACCEL_FLOAT(U_AXIS, 0), LIMIT_ACCEL_FLOAT(V_AXIS, 0), LIMIT_ACCEL_FLOAT(W_AXIS, 0) ); } } @@ -2649,7 +2644,10 @@ bool Planner::_populate_block( #if HAS_DIST_MM_ARG cart_dist_mm #else - LOGICAL_AXIS_ARRAY(steps_dist_mm.e, steps_dist_mm.x, steps_dist_mm.y, steps_dist_mm.z, steps_dist_mm.i, steps_dist_mm.j, steps_dist_mm.k, steps_dist_mm.u, steps_dist_mm.v, steps_dist_mm.w) + LOGICAL_AXIS_ARRAY(steps_dist_mm.e, + steps_dist_mm.x, steps_dist_mm.y, steps_dist_mm.z, + steps_dist_mm.i, steps_dist_mm.j, steps_dist_mm.k, + steps_dist_mm.u, steps_dist_mm.v, steps_dist_mm.w) #endif ; @@ -2670,7 +2668,7 @@ bool Planner::_populate_block( // NOTE: Max junction velocity is computed without sin() or acos() by trig half angle identity. float junction_cos_theta = LOGICAL_AXIS_GANG( + (-prev_unit_vec.e * unit_vec.e), - (-prev_unit_vec.x * unit_vec.x), + + (-prev_unit_vec.x * unit_vec.x), + (-prev_unit_vec.y * unit_vec.y), + (-prev_unit_vec.z * unit_vec.z), + (-prev_unit_vec.i * unit_vec.i), @@ -2687,104 +2685,110 @@ bool Planner::_populate_block( vmax_junction_sqr = sq(float(MINIMUM_PLANNER_SPEED)); } else { - NOLESS(junction_cos_theta, -0.999999f); // Check for numerical round-off to avoid divide by zero. - // Convert delta vector to unit vector xyze_float_t junction_unit_vec = unit_vec - prev_unit_vec; normalize_junction_vector(junction_unit_vec); - const float junction_acceleration = limit_value_by_axis_maximum(block->acceleration, junction_unit_vec), - sin_theta_d2 = SQRT(0.5f * (1.0f - junction_cos_theta)); // Trig half angle identity. Always positive. - - vmax_junction_sqr = junction_acceleration * junction_deviation_mm * sin_theta_d2 / (1.0f - sin_theta_d2); - - #if ENABLED(JD_HANDLE_SMALL_SEGMENTS) - - // For small moves with >135° junction (octagon) find speed for approximate arc - if (block->millimeters < 1 && junction_cos_theta < -0.7071067812f) { - - #if ENABLED(JD_USE_MATH_ACOS) - - #error "TODO: Inline maths with the MCU / FPU." - - #elif ENABLED(JD_USE_LOOKUP_TABLE) - - // Fast acos approximation (max. error +-0.01 rads) - // Based on LUT table and linear interpolation - - /** - * // Generate the JD Lookup Table - * constexpr float c = 1.00751495f; // Correction factor to center error around 0 - * for (int i = 0; i < jd_lut_count - 1; ++i) { - * const float x0 = (sq(i) - 1) / sq(i), - * y0 = acos(x0) * (i == 0 ? 1 : c), - * x1 = i < jd_lut_count - 1 ? 0.5 * x0 + 0.5 : 0.999999f, - * y1 = acos(x1) * (i < jd_lut_count - 1 ? c : 1); - * jd_lut_k[i] = (y0 - y1) / (x0 - x1); - * jd_lut_b[i] = (y1 * x0 - y0 * x1) / (x0 - x1); - * } - * - * // Compute correction factor (Set c to 1.0f first!) - * float min = INFINITY, max = -min; - * for (float t = 0; t <= 1; t += 0.0003f) { - * const float e = acos(t) / approx(t); - * if (isfinite(e)) { - * if (e < min) min = e; - * if (e > max) max = e; - * } - * } - * fprintf(stderr, "%.9gf, ", (min + max) / 2); - */ - static constexpr int16_t jd_lut_count = 16; - static constexpr uint16_t jd_lut_tll = _BV(jd_lut_count - 1); - static constexpr int16_t jd_lut_tll0 = __builtin_clz(jd_lut_tll) + 1; // i.e., 16 - jd_lut_count + 1 - static constexpr float jd_lut_k[jd_lut_count] PROGMEM = { - -1.03145837f, -1.30760646f, -1.75205851f, -2.41705704f, - -3.37769222f, -4.74888992f, -6.69649887f, -9.45661736f, - -13.3640480f, -18.8928222f, -26.7136841f, -37.7754593f, - -53.4201813f, -75.5458374f, -106.836761f, -218.532821f }; - static constexpr float jd_lut_b[jd_lut_count] PROGMEM = { - 1.57079637f, 1.70887053f, 2.04220939f, 2.62408352f, - 3.52467871f, 4.85302639f, 6.77020454f, 9.50875854f, - 13.4009285f, 18.9188995f, 26.7321243f, 37.7885055f, - 53.4293975f, 75.5523529f, 106.841369f, 218.534011f }; - - const float neg = junction_cos_theta < 0 ? -1 : 1, - t = neg * junction_cos_theta; - - const int16_t idx = (t < 0.00000003f) ? 0 : __builtin_clz(uint16_t((1.0f - t) * jd_lut_tll)) - jd_lut_tll0; - - float junction_theta = t * pgm_read_float(&jd_lut_k[idx]) + pgm_read_float(&jd_lut_b[idx]); - if (neg > 0) junction_theta = RADIANS(180) - junction_theta; // acos(-t) - - #else - - // Fast acos(-t) approximation (max. error +-0.033rad = 1.89°) - // Based on MinMax polynomial published by W. Randolph Franklin, see - // https://wrf.ecse.rpi.edu/Research/Short_Notes/arcsin/onlyelem.html - // acos( t) = pi / 2 - asin(x) - // acos(-t) = pi - acos(t) ... pi / 2 + asin(x) - - const float neg = junction_cos_theta < 0 ? -1 : 1, - t = neg * junction_cos_theta, - asinx = 0.032843707f - + t * (-1.451838349f - + t * ( 29.66153956f - + t * (-131.1123477f - + t * ( 262.8130562f - + t * (-242.7199627f - + t * ( 84.31466202f ) ))))), - junction_theta = RADIANS(90) + neg * asinx; // acos(-t) - - // NOTE: junction_theta bottoms out at 0.033 which avoids divide by 0. - - #endif - - const float limit_sqr = (block->millimeters * junction_acceleration) / junction_theta; - NOMORE(vmax_junction_sqr, limit_sqr); - } + const float junction_acceleration = limit_value_by_axis_maximum(block->acceleration, junction_unit_vec); - #endif // JD_HANDLE_SMALL_SEGMENTS + if (TERN0(HINTS_CURVE_RADIUS, hints.curve_radius)) { + TERN_(HINTS_CURVE_RADIUS, vmax_junction_sqr = junction_acceleration * hints.curve_radius); + } + else { + NOLESS(junction_cos_theta, -0.999999f); // Check for numerical round-off to avoid divide by zero. + + const float sin_theta_d2 = SQRT(0.5f * (1.0f - junction_cos_theta)); // Trig half angle identity. Always positive. + + vmax_junction_sqr = junction_acceleration * junction_deviation_mm * sin_theta_d2 / (1.0f - sin_theta_d2); + + #if ENABLED(JD_HANDLE_SMALL_SEGMENTS) + + // For small moves with >135° junction (octagon) find speed for approximate arc + if (block->millimeters < 1 && junction_cos_theta < -0.7071067812f) { + + #if ENABLED(JD_USE_MATH_ACOS) + + #error "TODO: Inline maths with the MCU / FPU." + + #elif ENABLED(JD_USE_LOOKUP_TABLE) + + // Fast acos approximation (max. error +-0.01 rads) + // Based on LUT table and linear interpolation + + /** + * // Generate the JD Lookup Table + * constexpr float c = 1.00751495f; // Correction factor to center error around 0 + * for (int i = 0; i < jd_lut_count - 1; ++i) { + * const float x0 = (sq(i) - 1) / sq(i), + * y0 = acos(x0) * (i == 0 ? 1 : c), + * x1 = i < jd_lut_count - 1 ? 0.5 * x0 + 0.5 : 0.999999f, + * y1 = acos(x1) * (i < jd_lut_count - 1 ? c : 1); + * jd_lut_k[i] = (y0 - y1) / (x0 - x1); + * jd_lut_b[i] = (y1 * x0 - y0 * x1) / (x0 - x1); + * } + * + * // Compute correction factor (Set c to 1.0f first!) + * float min = INFINITY, max = -min; + * for (float t = 0; t <= 1; t += 0.0003f) { + * const float e = acos(t) / approx(t); + * if (isfinite(e)) { + * if (e < min) min = e; + * if (e > max) max = e; + * } + * } + * fprintf(stderr, "%.9gf, ", (min + max) / 2); + */ + static constexpr int16_t jd_lut_count = 16; + static constexpr uint16_t jd_lut_tll = _BV(jd_lut_count - 1); + static constexpr int16_t jd_lut_tll0 = __builtin_clz(jd_lut_tll) + 1; // i.e., 16 - jd_lut_count + 1 + static constexpr float jd_lut_k[jd_lut_count] PROGMEM = { + -1.03145837f, -1.30760646f, -1.75205851f, -2.41705704f, + -3.37769222f, -4.74888992f, -6.69649887f, -9.45661736f, + -13.3640480f, -18.8928222f, -26.7136841f, -37.7754593f, + -53.4201813f, -75.5458374f, -106.836761f, -218.532821f }; + static constexpr float jd_lut_b[jd_lut_count] PROGMEM = { + 1.57079637f, 1.70887053f, 2.04220939f, 2.62408352f, + 3.52467871f, 4.85302639f, 6.77020454f, 9.50875854f, + 13.4009285f, 18.9188995f, 26.7321243f, 37.7885055f, + 53.4293975f, 75.5523529f, 106.841369f, 218.534011f }; + + const float neg = junction_cos_theta < 0 ? -1 : 1, + t = neg * junction_cos_theta; + + const int16_t idx = (t < 0.00000003f) ? 0 : __builtin_clz(uint16_t((1.0f - t) * jd_lut_tll)) - jd_lut_tll0; + + float junction_theta = t * pgm_read_float(&jd_lut_k[idx]) + pgm_read_float(&jd_lut_b[idx]); + if (neg > 0) junction_theta = RADIANS(180) - junction_theta; // acos(-t) + + #else + + // Fast acos(-t) approximation (max. error +-0.033rad = 1.89°) + // Based on MinMax polynomial published by W. Randolph Franklin, see + // https://wrf.ecse.rpi.edu/Research/Short_Notes/arcsin/onlyelem.html + // acos( t) = pi / 2 - asin(x) + // acos(-t) = pi - acos(t) ... pi / 2 + asin(x) + + const float neg = junction_cos_theta < 0 ? -1 : 1, + t = neg * junction_cos_theta, + asinx = 0.032843707f + + t * (-1.451838349f + + t * ( 29.66153956f + + t * (-131.1123477f + + t * ( 262.8130562f + + t * (-242.7199627f + + t * ( 84.31466202f ) ))))), + junction_theta = RADIANS(90) + neg * asinx; // acos(-t) + + // NOTE: junction_theta bottoms out at 0.033 which avoids divide by 0. + + #endif + + const float limit_sqr = (block->millimeters * junction_acceleration) / junction_theta; + NOMORE(vmax_junction_sqr, limit_sqr); + } + + #endif // JD_HANDLE_SMALL_SEGMENTS + } } // Get the lowest speed @@ -2944,12 +2948,11 @@ bool Planner::_populate_block( } // _populate_block() /** - * Planner::buffer_sync_block - * Add a block to the buffer that just updates the position - * @param sync_flag BLOCK_FLAG_SYNC_FANS & BLOCK_FLAG_LASER_PWR - * Supports LASER_SYNCHRONOUS_M106_M107 and LASER_POWER_SYNC power sync block buffer queueing. + * @brief Add a block to the buffer that just updates the position + * Supports LASER_SYNCHRONOUS_M106_M107 and LASER_POWER_SYNC power sync block buffer queueing. + * + * @param sync_flag The sync flag to set, determining the type of sync the block will do */ - void Planner::buffer_sync_block(const BlockFlagBit sync_flag/*=BLOCK_BIT_SYNC_POSITION*/) { // Wait for the next available block @@ -2957,14 +2960,13 @@ void Planner::buffer_sync_block(const BlockFlagBit sync_flag/*=BLOCK_BIT_SYNC_PO block_t * const block = get_next_free_block(next_buffer_head); // Clear block - memset(block, 0, sizeof(block_t)); + block->reset(); block->flag.apply(sync_flag); block->position = position; #if ENABLED(BACKLASH_COMPENSATION) LOOP_NUM_AXES(axis) block->position[axis] += backlash.get_applied_steps((AxisEnum)axis); #endif - #if BOTH(HAS_FAN, LASER_SYNCHRONOUS_M106_M107) FANS_LOOP(i) block->fan_speed[i] = thermalManager.fan_speed[i]; #endif @@ -2991,22 +2993,24 @@ void Planner::buffer_sync_block(const BlockFlagBit sync_flag/*=BLOCK_BIT_SYNC_PO } // buffer_sync_block() /** - * Planner::buffer_segment - * - * Add a new linear movement to the buffer in axis units. + * @brief Add a single linear movement * - * Leveling and kinematics should be applied ahead of calling this. + * @description Add a new linear movement to the buffer in axis units. + * Leveling and kinematics should be applied before calling this. * - * a,b,c,e - target positions in mm and/or degrees - * fr_mm_s - (target) speed of the move - * extruder - target extruder - * millimeters - the length of the movement, if known + * @param abce Target position in mm and/or degrees + * @param cart_dist_mm The pre-calculated move lengths for all axes, in mm + * @param fr_mm_s (target) speed of the move + * @param extruder optional target extruder (otherwise active_extruder) + * @param hints optional parameters to aid planner calculations * - * Return 'false' if no segment was queued due to cleaning, cold extrusion, full queue, etc. + * @return false if no segment was queued due to cleaning, cold extrusion, full queue, etc. */ bool Planner::buffer_segment(const abce_pos_t &abce OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm) - , const_feedRate_t fr_mm_s, const uint8_t extruder/*=active_extruder*/, const_float_t millimeters/*=0.0*/ + , const_feedRate_t fr_mm_s + , const uint8_t extruder/*=active_extruder*/ + , const PlannerHints &hints/*=PlannerHints()*/ ) { // If we are cleaning, do not accept queuing of movements @@ -3112,8 +3116,8 @@ bool Planner::buffer_segment(const abce_pos_t &abce if (!_buffer_steps(target OPTARG(HAS_POSITION_FLOAT, target_float) OPTARG(HAS_DIST_MM_ARG, cart_dist_mm) - , fr_mm_s, extruder, millimeters) - ) return false; + , fr_mm_s, extruder, hints + )) return false; stepper.wake_up(); return true; @@ -3126,12 +3130,12 @@ bool Planner::buffer_segment(const abce_pos_t &abce * * cart - target position in mm or degrees * fr_mm_s - (target) speed of the move (mm/s) - * extruder - target extruder - * millimeters - the length of the movement, if known - * inv_duration - the reciprocal if the duration of the movement, if known (kinematic only if feeedrate scaling is enabled) + * extruder - optional target extruder (otherwise active_extruder) + * hints - optional parameters to aid planner calculations */ -bool Planner::buffer_line(const xyze_pos_t &cart, const_feedRate_t fr_mm_s, const uint8_t extruder/*=active_extruder*/, const float millimeters/*=0.0*/ - OPTARG(SCARA_FEEDRATE_SCALING, const_float_t inv_duration/*=0.0*/) +bool Planner::buffer_line(const xyze_pos_t &cart, const_feedRate_t fr_mm_s + , const uint8_t extruder/*=active_extruder*/ + , const PlannerHints &hints/*=PlannerHints()*/ ) { xyze_pos_t machine = cart; TERN_(HAS_POSITION_MODIFIERS, apply_modifiers(machine)); @@ -3153,28 +3157,30 @@ bool Planner::buffer_line(const xyze_pos_t &cart, const_feedRate_t fr_mm_s, cons ); #endif - const float mm = millimeters ?: (cart_dist_mm.x || cart_dist_mm.y) ? cart_dist_mm.magnitude() : TERN0(HAS_Z_AXIS, ABS(cart_dist_mm.z)); - // Cartesian XYZ to kinematic ABC, stored in global 'delta' inverse_kinematics(machine); + PlannerHints ph = hints; + if (!hints.millimeters) + ph.millimeters = (cart_dist_mm.x || cart_dist_mm.y) ? cart_dist_mm.magnitude() : TERN0(HAS_Z_AXIS, ABS(cart_dist_mm.z)); + #if ENABLED(SCARA_FEEDRATE_SCALING) // For SCARA scale the feedrate from mm/s to degrees/s // i.e., Complete the angular vector in the given time. - const float duration_recip = inv_duration ?: fr_mm_s / mm; + const float duration_recip = hints.inv_duration ?: fr_mm_s / ph.millimeters; const xyz_pos_t diff = delta - position_float; const feedRate_t feedrate = diff.magnitude() * duration_recip; #else const feedRate_t feedrate = fr_mm_s; #endif TERN_(HAS_EXTRUDERS, delta.e = machine.e); - if (buffer_segment(delta OPTARG(HAS_DIST_MM_ARG, cart_dist_mm), feedrate, extruder, mm)) { + if (buffer_segment(delta OPTARG(HAS_DIST_MM_ARG, cart_dist_mm), feedrate, extruder, ph)) { position_cart = cart; return true; } return false; #else - return buffer_segment(machine, fr_mm_s, extruder, millimeters); + return buffer_segment(machine, fr_mm_s, extruder, hints); #endif } // buffer_line() diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index e0aa89ab7228..5a0de47bf2f0 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -280,6 +280,8 @@ typedef struct block_t { block_laser_t laser; #endif + void reset() { memset((char*)this, 0, sizeof(*this)); } + } block_t; #if ANY(LIN_ADVANCE, SCARA_FEEDRATE_SCALING, GRADIENT_MIX, LCD_SHOW_E_TOTAL, POWER_LOSS_RECOVERY) @@ -349,6 +351,30 @@ typedef struct { typedef IF<(BLOCK_BUFFER_SIZE > 64), uint16_t, uint8_t>::type last_move_t; #endif +#if ENABLED(ARC_SUPPORT) + #define HINTS_CURVE_RADIUS + #define HINTS_SAFE_EXIT_SPEED +#endif + +struct PlannerHints { + float millimeters = 0.0; // Move Length, if known, else 0. + #if ENABLED(SCARA_FEEDRATE_SCALING) + float inv_duration = 0.0; // Reciprocal of the move duration, if known + #endif + #if ENABLED(HINTS_CURVE_RADIUS) + float curve_radius = 0.0; // Radius of curvature of the motion path - to calculate cornering speed + #else + static constexpr float curve_radius = 0.0; + #endif + #if ENABLED(HINTS_SAFE_EXIT_SPEED) + float safe_exit_speed_sqr = 0.0; // Square of the speed considered "safe" at the end of the segment + // i.e., at or below the exit speed of the segment that the planner + // would calculate if it knew the as-yet-unbuffered path + #endif + + PlannerHints(const_float_t mm=0.0f) : millimeters(mm) {} +}; + class Planner { public: @@ -752,14 +778,14 @@ class Planner { * target - target position in steps units * fr_mm_s - (target) speed of the move * extruder - target extruder - * millimeters - the length of the movement, if known + * hints - parameters to aid planner calculations * * Returns true if movement was buffered, false otherwise */ static bool _buffer_steps(const xyze_long_t &target OPTARG(HAS_POSITION_FLOAT, const xyze_pos_t &target_float) OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm) - , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0 + , feedRate_t fr_mm_s, const uint8_t extruder, const PlannerHints &hints ); /** @@ -774,15 +800,14 @@ class Planner { * @param cart_dist_mm The pre-calculated move lengths for all axes, in mm * @param fr_mm_s (target) speed of the move * @param extruder target extruder - * @param millimeters A pre-calculated linear distance for the move, in mm, - * or 0.0 to have the distance calculated here. + * @param hints parameters to aid planner calculations * * @return true if movement is acceptable, false otherwise */ static bool _populate_block(block_t * const block, const xyze_long_t &target OPTARG(HAS_POSITION_FLOAT, const xyze_pos_t &target_float) OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm) - , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0 + , feedRate_t fr_mm_s, const uint8_t extruder, const PlannerHints &hints ); /** @@ -809,12 +834,14 @@ class Planner { * * a,b,c,e - target positions in mm and/or degrees * fr_mm_s - (target) speed of the move - * extruder - target extruder - * millimeters - the length of the movement, if known + * extruder - optional target extruder (otherwise active_extruder) + * hints - optional parameters to aid planner calculations */ static bool buffer_segment(const abce_pos_t &abce OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm) - , const_feedRate_t fr_mm_s, const uint8_t extruder=active_extruder, const_float_t millimeters=0.0 + , const_feedRate_t fr_mm_s + , const uint8_t extruder=active_extruder + , const PlannerHints &hints=PlannerHints() ); public: @@ -826,12 +853,12 @@ class Planner { * * cart - target position in mm or degrees * fr_mm_s - (target) speed of the move (mm/s) - * extruder - target extruder - * millimeters - the length of the movement, if known - * inv_duration - the reciprocal if the duration of the movement, if known (kinematic only if feeedrate scaling is enabled) + * extruder - optional target extruder (otherwise active_extruder) + * hints - optional parameters to aid planner calculations */ - static bool buffer_line(const xyze_pos_t &cart, const_feedRate_t fr_mm_s, const uint8_t extruder=active_extruder, const float millimeters=0.0 - OPTARG(SCARA_FEEDRATE_SCALING, const_float_t inv_duration=0.0) + static bool buffer_line(const xyze_pos_t &cart, const_feedRate_t fr_mm_s + , const uint8_t extruder=active_extruder + , const PlannerHints &hints=PlannerHints() ); #if ENABLED(DIRECT_STEPPING) @@ -1024,15 +1051,15 @@ class Planner { static void calculate_trapezoid_for_block(block_t * const block, const_float_t entry_factor, const_float_t exit_factor); - static void reverse_pass_kernel(block_t * const current, const block_t * const next); + static void reverse_pass_kernel(block_t * const current, const block_t * const next OPTARG(ARC_SUPPORT, const_float_t safe_exit_speed_sqr)); static void forward_pass_kernel(const block_t * const previous, block_t * const current, uint8_t block_index); - static void reverse_pass(); + static void reverse_pass(TERN_(ARC_SUPPORT, const_float_t safe_exit_speed_sqr)); static void forward_pass(); - static void recalculate_trapezoids(); + static void recalculate_trapezoids(TERN_(ARC_SUPPORT, const_float_t safe_exit_speed_sqr)); - static void recalculate(); + static void recalculate(TERN_(ARC_SUPPORT, const_float_t safe_exit_speed_sqr)); #if HAS_JUNCTION_DEVIATION diff --git a/Marlin/src/module/planner_bezier.cpp b/Marlin/src/module/planner_bezier.cpp index 93b118f33054..a3f98435d04a 100644 --- a/Marlin/src/module/planner_bezier.cpp +++ b/Marlin/src/module/planner_bezier.cpp @@ -121,6 +121,9 @@ void cubic_b_spline( millis_t next_idle_ms = millis() + 200UL; + // Hints to help optimize the move + PlannerHints hints; + for (float t = 0; t < 1;) { thermalManager.task(); @@ -177,7 +180,7 @@ void cubic_b_spline( } */ - step = new_t - t; + hints.millimeters = new_t - t; t = new_t; // Compute and send new position @@ -203,7 +206,7 @@ void cubic_b_spline( const xyze_pos_t &pos = bez_target; #endif - if (!planner.buffer_line(pos, scaled_fr_mm_s, active_extruder, step)) + if (!planner.buffer_line(pos, scaled_fr_mm_s, active_extruder, hints)) break; } } diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 4832220abd75..2bacc556060b 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -2002,14 +2002,15 @@ uint32_t Stepper::block_phase_isr() { else if (LA_steps) nextAdvanceISR = 0; #endif - /* + /** * Adjust Laser Power - Accelerating - * isPowered - True when a move is powered. - * isEnabled - laser power is active. - * Laser power variables are calulated and stored in this block by the planner code. * - * trap_ramp_active_pwr - the active power in this block across accel or decel trap steps. - * trap_ramp_entry_incr - holds the precalculated value to increase the current power per accel step. + * isPowered - True when a move is powered. + * isEnabled - laser power is active. + * + * Laser power variables are calulated and stored in this block by the planner code. + * trap_ramp_active_pwr - the active power in this block across accel or decel trap steps. + * trap_ramp_entry_incr - holds the precalculated value to increase the current power per accel step. * * Apply the starting active power and then increase power per step by the trap_ramp_entry_incr value if positive. */ @@ -2032,6 +2033,7 @@ uint32_t Stepper::block_phase_isr() { uint32_t step_rate; #if ENABLED(S_CURVE_ACCELERATION) + // If this is the 1st time we process the 2nd half of the trapezoid... if (!bezier_2nd_half) { // Initialize the Bézier speed curve @@ -2046,6 +2048,7 @@ uint32_t Stepper::block_phase_isr() { ? _eval_bezier_curve(deceleration_time) : current_block->final_rate; } + #else // Using the old trapezoidal control step_rate = STEP_MULTIPLY(deceleration_time, current_block->acceleration_rate); @@ -2055,9 +2058,8 @@ uint32_t Stepper::block_phase_isr() { } else step_rate = current_block->final_rate; - #endif - // step_rate is in steps/second + #endif // step_rate to timer interval and steps per stepper isr interval = calc_timer_interval(step_rate, &steps_per_isr); @@ -2109,10 +2111,10 @@ uint32_t Stepper::block_phase_isr() { interval = ticks_nominal; } - /* Adjust Laser Power - Cruise + /** + * Adjust Laser Power - Cruise * power - direct or floor adjusted active laser power. */ - #if ENABLED(LASER_POWER_TRAP) if (cutter.cutter_mode == CUTTER_MODE_CONTINUOUS) { if (step_events_completed + 1 == accelerate_until) { @@ -2130,7 +2132,7 @@ uint32_t Stepper::block_phase_isr() { } #if ENABLED(LASER_FEATURE) - /* + /** * CUTTER_MODE_DYNAMIC is experimental and developing. * Super-fast method to dynamically adjust the laser power OCR value based on the input feedrate in mm-per-minute. * TODO: Set up Min/Max OCR offsets to allow tuning and scaling of various lasers. @@ -2147,9 +2149,8 @@ uint32_t Stepper::block_phase_isr() { } else { // !current_block #if ENABLED(LASER_FEATURE) - if (cutter.cutter_mode == CUTTER_MODE_DYNAMIC) { + if (cutter.cutter_mode == CUTTER_MODE_DYNAMIC) cutter.apply_power(0); // No movement in dynamic mode so turn Laser off - } #endif } From 24c211307d5a1d009d12c4d25d3828c05534f3e7 Mon Sep 17 00:00:00 2001 From: Mike La Spina Date: Fri, 8 Jul 2022 15:02:12 -0500 Subject: [PATCH 18/32] =?UTF-8?q?=F0=9F=90=9B=20Fix=20laser/fan=20sync=20(?= =?UTF-8?q?#24460)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Followup to #22690, 307dfb15 --- Marlin/src/lcd/menu/menu_item.h | 2 +- buildroot/tests/mega2560 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Marlin/src/lcd/menu/menu_item.h b/Marlin/src/lcd/menu/menu_item.h index 3e1733ee1c90..c009567ef27a 100644 --- a/Marlin/src/lcd/menu/menu_item.h +++ b/Marlin/src/lcd/menu/menu_item.h @@ -542,7 +542,7 @@ class MenuItem_bool : public MenuEditItemBase { inline void on_fan_update() { thermalManager.set_fan_speed(MenuItemBase::itemIndex, editable.uint8); - TERN_(LASER_SYNCHRONOUS_M106_M107, planner.buffer_sync_block(BLOCK_FLAG_SYNC_FANS)); + TERN_(LASER_SYNCHRONOUS_M106_M107, planner.buffer_sync_block(BLOCK_BIT_SYNC_FANS)); } #if ENABLED(EXTRA_FAN_SPEED) diff --git a/buildroot/tests/mega2560 b/buildroot/tests/mega2560 index aa425564fcad..89f9e046ce97 100755 --- a/buildroot/tests/mega2560 +++ b/buildroot/tests/mega2560 @@ -188,8 +188,8 @@ opt_set MOTHERBOARD BOARD_RAMPS_14_EFB EXTRUDERS 0 LCD_LANGUAGE en TEMP_SENSOR_C MANUAL_FEEDRATE '{ 50*60, 50*60, 4*60 }' \ AXIS_RELATIVE_MODES '{ false, false, false }' opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER SDSUPPORT EEPROM_SETTINGS EEPROM_BOOT_SILENT EEPROM_AUTO_INIT MEATPACK_ON_SERIAL_PORT_1 \ - LASER_FEATURE LASER_SAFETY_TIMEOUT_MS LASER_COOLANT_FLOW_METER AIR_EVACUATION AIR_EVACUATION_PIN AIR_ASSIST AIR_ASSIST_PIN -exec_test $1 $2 "MEGA2560 RAMPS | Laser Feature | Air Evacuation | Air Assist | Cooler | Flowmeter | 12864 LCD | meatpack | Laser Safety Timeout | M3 Power Sync | Trap Power Smoothing | SERIAL_PORT_2 " "$3" + LASER_FEATURE LASER_SAFETY_TIMEOUT_MS LASER_COOLANT_FLOW_METER AIR_EVACUATION AIR_EVACUATION_PIN AIR_ASSIST AIR_ASSIST_PIN LASER_SYNCHRONOUS_M106_M107 +exec_test $1 $2 "MEGA2560 RAMPS | Laser Options | 12864 | Meatpack | Fan Sync | SERIAL_PORT_2 " "$3" # # Test Laser features with 44780 LCD From 678474d55cd92d14bde24d00dbc9322919cfc1e1 Mon Sep 17 00:00:00 2001 From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Date: Fri, 8 Jul 2022 13:30:03 -0700 Subject: [PATCH 19/32] =?UTF-8?q?=F0=9F=94=A7=20Assert=20Probe=20Temp=20Co?= =?UTF-8?q?mp=20requirements=20(#24468)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/Conditionals_adv.h | 10 ----- Marlin/src/inc/SanityCheck.h | 62 ++++++++++++++++++------------- 2 files changed, 37 insertions(+), 35 deletions(-) diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 0cc1556a837e..49a1d7ef9c09 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -560,16 +560,6 @@ #endif #endif -// Probe Temperature Compensation -#if !TEMP_SENSOR_PROBE - #undef PTC_PROBE -#endif -#if !TEMP_SENSOR_BED - #undef PTC_BED -#endif -#if !HAS_EXTRUDERS - #undef PTC_HOTEND -#endif #if ANY(PTC_PROBE, PTC_BED, PTC_HOTEND) #define HAS_PTC 1 #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 4412fbb41e5e..3df020e3f051 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -666,34 +666,46 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L #endif #endif - #ifdef PTC_PROBE_START - constexpr auto _ptc_sample_start = PTC_PROBE_START; - constexpr decltype(_ptc_sample_start) _test_ptc_sample_start = 12.3f; - static_assert(_test_ptc_sample_start != 12.3f, "PTC_PROBE_START must be a whole number."); - #endif - #ifdef PTC_PROBE_RES - constexpr auto _ptc_sample_res = PTC_PROBE_RES; - constexpr decltype(_ptc_sample_res) _test_ptc_sample_res = 12.3f; - static_assert(_test_ptc_sample_res != 12.3f, "PTC_PROBE_RES must be a whole number."); - #endif - #ifdef PTC_BED_START - constexpr auto _btc_sample_start = PTC_BED_START; - constexpr decltype(_btc_sample_start) _test_btc_sample_start = 12.3f; - static_assert(_test_btc_sample_start != 12.3f, "PTC_BED_START must be a whole number."); - #endif - #ifdef PTC_BED_RES - constexpr auto _btc_sample_res = PTC_BED_RES; - constexpr decltype(_btc_sample_res) _test_btc_sample_res = 12.3f; - static_assert(_test_btc_sample_res != 12.3f, "PTC_BED_RES must be a whole number."); - #endif - #ifdef PTC_PROBE_TEMP - constexpr auto _btc_probe_temp = PTC_PROBE_TEMP; - constexpr decltype(_btc_probe_temp) _test_btc_probe_temp = 12.3f; - static_assert(_test_btc_probe_temp != 12.3f, "PTC_PROBE_TEMP must be a whole number."); + #if ENABLED(PTC_PROBE) + #if !TEMP_SENSOR_PROBE + #error "PTC_PROBE requires a probe with a thermistor." + #endif + #ifdef PTC_PROBE_START + constexpr auto _ptc_sample_start = PTC_PROBE_START; + constexpr decltype(_ptc_sample_start) _test_ptc_sample_start = 12.3f; + static_assert(_test_ptc_sample_start != 12.3f, "PTC_PROBE_START must be a whole number."); + #endif + #ifdef PTC_PROBE_RES + constexpr auto _ptc_sample_res = PTC_PROBE_RES; + constexpr decltype(_ptc_sample_res) _test_ptc_sample_res = 12.3f; + static_assert(_test_ptc_sample_res != 12.3f, "PTC_PROBE_RES must be a whole number."); + #endif + #if ENABLED(PTC_BED) && defined(PTC_PROBE_TEMP) + constexpr auto _btc_probe_temp = PTC_PROBE_TEMP; + constexpr decltype(_btc_probe_temp) _test_btc_probe_temp = 12.3f; + static_assert(_test_btc_probe_temp != 12.3f, "PTC_PROBE_TEMP must be a whole number."); + #endif + #endif + + #if ENABLED(PTC_BED) + #if !TEMP_SENSOR_BED + #error "PTC_BED requires a bed with a thermistor." + #endif + #ifdef PTC_BED_START + constexpr auto _btc_sample_start = PTC_BED_START; + constexpr decltype(_btc_sample_start) _test_btc_sample_start = 12.3f; + static_assert(_test_btc_sample_start != 12.3f, "PTC_BED_START must be a whole number."); + #endif + #ifdef PTC_BED_RES + constexpr auto _btc_sample_res = PTC_BED_RES; + constexpr decltype(_btc_sample_res) _test_btc_sample_res = 12.3f; + static_assert(_test_btc_sample_res != 12.3f, "PTC_BED_RES must be a whole number."); + #endif #endif + #if ENABLED(PTC_HOTEND) #if EXTRUDERS != 1 - #error "PTC_HOTEND only works with a single extruder." + #error "PTC_HOTEND requires a single extruder." #endif #ifdef PTC_HOTEND_START constexpr auto _etc_sample_start = PTC_HOTEND_START; From 7207a324341c3aaa8de8f103391576b274830c2d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 10 Jul 2022 22:00:10 -0500 Subject: [PATCH 20/32] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Add?= =?UTF-8?q?=20Sim=20debug=20with=20lldb?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildroot/share/PlatformIO/debugging/launch.json | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/buildroot/share/PlatformIO/debugging/launch.json b/buildroot/share/PlatformIO/debugging/launch.json index 583d860eb36c..f2219a44b88f 100644 --- a/buildroot/share/PlatformIO/debugging/launch.json +++ b/buildroot/share/PlatformIO/debugging/launch.json @@ -25,15 +25,26 @@ "svdFile": "${env:HOME}/.platformio/platforms/ststm32@12.1.1/misc/svd/STM32F40x.svd", }, { - "name": "Debug Sim", + "name": "Launch Sim (ggdb)", "request": "launch", "type": "cppdbg", "cwd": "${workspaceRoot}", + "program": ".pio/build/simulator_macos_debug/debug/MarlinSimulator", //"program": ".pio/build/simulator_linux_debug/MarlinSimulator", //"program": ".pio/build/simulator_windows/MarlinSimulator", - "program": ".pio/build/simulator_macos_debug/MarlinSimulator", "miDebuggerPath": "/opt/local/bin/ggdb", "MIMode": "gdb" + }, + { + "name": "Launch Sim (lldb)", + "request": "launch", + "type": "cppdbg", + "cwd": "${workspaceRoot}", + "program": ".pio/build/simulator_macos_debug/debug/MarlinSimulator", + //"program": ".pio/build/simulator_linux_debug/MarlinSimulator", + //"program": ".pio/build/simulator_windows/MarlinSimulator", + //"targetArchitecture": "arm64", + "MIMode": "lldb" } ] } From 6a86c5bad32da03b71c5f0223904b44e129185f0 Mon Sep 17 00:00:00 2001 From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Date: Mon, 11 Jul 2022 11:33:42 -0700 Subject: [PATCH 21/32] =?UTF-8?q?=E2=9C=A8=20MKS=20Monster8=20V2=20(#24483?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/core/boards.h | 23 +++--- Marlin/src/pins/pins.h | 10 ++- .../src/pins/stm32f4/pins_MKS_MONSTER8_V1.h | 51 ++++++++++++ .../src/pins/stm32f4/pins_MKS_MONSTER8_V2.h | 57 ++++++++++++++ ..._MONSTER8.h => pins_MKS_MONSTER8_common.h} | 78 +++++++------------ ini/stm32f4.ini | 6 +- 6 files changed, 159 insertions(+), 66 deletions(-) create mode 100644 Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V1.h create mode 100644 Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V2.h rename Marlin/src/pins/stm32f4/{pins_MKS_MONSTER8.h => pins_MKS_MONSTER8_common.h} (88%) diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index 72c7e22541f5..2882f5a1eea3 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -408,17 +408,18 @@ #define BOARD_MKS_ROBIN_PRO_V2 4227 // MKS Robin Pro V2 (STM32F407VE) #define BOARD_MKS_ROBIN_NANO_V3 4228 // MKS Robin Nano V3 (STM32F407VG) #define BOARD_MKS_ROBIN_NANO_V3_1 4229 // MKS Robin Nano V3.1 (STM32F407VE) -#define BOARD_MKS_MONSTER8 4230 // MKS Monster8 (STM32F407VG) -#define BOARD_ANET_ET4 4231 // ANET ET4 V1.x (STM32F407VG) -#define BOARD_ANET_ET4P 4232 // ANET ET4P V1.x (STM32F407VG) -#define BOARD_FYSETC_CHEETAH_V20 4233 // FYSETC Cheetah V2.0 -#define BOARD_TH3D_EZBOARD_V2 4234 // TH3D EZBoard v2.0 -#define BOARD_OPULO_LUMEN_REV3 4235 // Opulo Lumen PnP Controller REV3 (STM32F407VE/VG) -#define BOARD_MKS_ROBIN_NANO_V1_3_F4 4236 // MKS Robin Nano V1.3 and MKS Robin Nano-S V1.3 (STM32F407VE) -#define BOARD_MKS_EAGLE 4237 // MKS Eagle (STM32F407VE) -#define BOARD_ARTILLERY_RUBY 4238 // Artillery Ruby (STM32F401RC) -#define BOARD_FYSETC_SPIDER_V2_2 4239 // FYSETC Spider V2.2 (STM32F446VE) -#define BOARD_CREALITY_V24S1_301F4 4240 // Creality v2.4.S1_301F4 (STM32F401RC) as found in the Ender-3 S1 F4 +#define BOARD_MKS_MONSTER8_V1 4230 // MKS Monster8 V1 (STM32F407VG) +#define BOARD_MKS_MONSTER8_V2 4231 // MKS Monster8 V2 (STM32F407VG) +#define BOARD_ANET_ET4 4232 // ANET ET4 V1.x (STM32F407VG) +#define BOARD_ANET_ET4P 4233 // ANET ET4P V1.x (STM32F407VG) +#define BOARD_FYSETC_CHEETAH_V20 4234 // FYSETC Cheetah V2.0 +#define BOARD_TH3D_EZBOARD_V2 4235 // TH3D EZBoard v2.0 +#define BOARD_OPULO_LUMEN_REV3 4236 // Opulo Lumen PnP Controller REV3 (STM32F407VE/VG) +#define BOARD_MKS_ROBIN_NANO_V1_3_F4 4237 // MKS Robin Nano V1.3 and MKS Robin Nano-S V1.3 (STM32F407VE) +#define BOARD_MKS_EAGLE 4238 // MKS Eagle (STM32F407VE) +#define BOARD_ARTILLERY_RUBY 4239 // Artillery Ruby (STM32F401RC) +#define BOARD_FYSETC_SPIDER_V2_2 4240 // FYSETC Spider V2.2 (STM32F446VE) +#define BOARD_CREALITY_V24S1_301F4 4241 // Creality v2.4.S1_301F4 (STM32F401RC) as found in the Ender-3 S1 F4 // // ARM Cortex M7 diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 2a29c66d8acc..ee4f43cceff3 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -683,8 +683,10 @@ #include "stm32f4/pins_ANET_ET4P.h" // STM32F4 env:Anet_ET4_no_bootloader env:Anet_ET4_OpenBLT #elif MB(FYSETC_CHEETAH_V20) #include "stm32f4/pins_FYSETC_CHEETAH_V20.h" // STM32F4 env:FYSETC_CHEETAH_V20 -#elif MB(MKS_MONSTER8) - #include "stm32f4/pins_MKS_MONSTER8.h" // STM32F4 env:mks_monster8 env:mks_monster8_usb_flash_drive env:mks_monster8_usb_flash_drive_msc +#elif MB(MKS_MONSTER8_V1) + #include "stm32f4/pins_MKS_MONSTER8_V1.h" // STM32F4 env:mks_monster8 env:mks_monster8_usb_flash_drive env:mks_monster8_usb_flash_drive_msc +#elif MB(MKS_MONSTER8_V2) + #include "stm32f4/pins_MKS_MONSTER8_V2.h" // STM32F4 env:mks_monster8 env:mks_monster8_usb_flash_drive env:mks_monster8_usb_flash_drive_msc #elif MB(TH3D_EZBOARD_V2) #include "stm32f4/pins_TH3D_EZBOARD_V2.h" // STM32F4 env:TH3D_EZBoard_V2_no_bootloader env:TH3D_EZBoard_V2_OpenBLT #elif MB(OPULO_LUMEN_REV3) @@ -800,6 +802,7 @@ #define BOARD_BTT_SKR_V2_0 99922 #define BOARD_TH3D_EZBOARD_LITE_V2 99923 #define BOARD_BTT_SKR_SE_BX 99924 + #define BOARD_MKS_MONSTER8 99925 #if MB(MKS_13) #error "BOARD_MKS_13 has been renamed BOARD_MKS_GEN_13. Please update your configuration." @@ -853,6 +856,8 @@ #error "BOARD_TH3D_EZBOARD_LITE_V2 is now BOARD_TH3D_EZBOARD_V2. Please update your configuration." #elif MB(BTT_SKR_SE_BX) #error "BOARD_BTT_SKR_SE_BX is now BOARD_BTT_SKR_SE_BX_V2 or BOARD_BTT_SKR_SE_BX_V3. Please update your configuration." + #elif MB(MKS_MONSTER8) + #error "BOARD_MKS_MONSTER8 is now BOARD_MKS_MONSTER8_V1 or BOARD_MKS_MONSTER8_V2. Please update your configuration." #elif defined(MOTHERBOARD) #error "Unknown MOTHERBOARD value set in Configuration.h." #else @@ -884,6 +889,7 @@ #undef BOARD_BTT_SKR_V2_0 #undef BOARD_TH3D_EZBOARD_LITE_V2 #undef BOARD_BTT_SKR_SE_BX + #undef BOARD_MKS_MONSTER8 #endif diff --git a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V1.h b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V1.h new file mode 100644 index 000000000000..7163625e4042 --- /dev/null +++ b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V1.h @@ -0,0 +1,51 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#define BOARD_INFO_NAME "MKS Monster8 V1" + +// +// Limit Switches +// +#define X_MAX_PIN PA13 +#define Y_MAX_PIN PC5 + +// +// Steppers +// +#define E4_ENABLE_PIN PD14 // Driver7 + +// +// Misc. Functions +// +#define PW_DET PC5 // Y+ +#define PW_OFF PB12 // Z+ +#define MT_DET_1_PIN PW_DET +#define MT_DET_2_PIN PW_OFF +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN MT_DET_1_PIN +#endif +#ifndef FIL_RUNOUT2_PIN + #define FIL_RUNOUT2_PIN MT_DET_2_PIN +#endif + +#include "pins_MKS_MONSTER8_common.h" diff --git a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V2.h b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V2.h new file mode 100644 index 000000000000..9c012999b375 --- /dev/null +++ b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V2.h @@ -0,0 +1,57 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#define BOARD_INFO_NAME "MKS Monster8 V2" + +// +// Steppers +// +#define E4_ENABLE_PIN PB6 // Driver7 + +// +// Misc. Functions +// +#define PW_DET PA13 // MT_DET +#define PW_OFF PB12 // Z+ +#define MT_DET_1_PIN PW_DET +#define MT_DET_2_PIN PW_OFF +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN MT_DET_1_PIN +#endif +#ifndef FIL_RUNOUT2_PIN + #define FIL_RUNOUT2_PIN MT_DET_2_PIN +#endif + +// +// MKS WIFI MODULE +// +//#define WIFI_SERIAL 1// USART1 +#if ENABLED(MKS_WIFI_MODULE) + #define WIFI_IO0_PIN PB14 // MKS ESP WIFI IO0 PIN + #define WIFI_IO1_PIN PB15 // MKS ESP WIFI IO1 PIN + #define WIFI_RESET_PIN PD14 // MKS ESP WIFI RESET PIN +#endif + +#define NEOPIXEL_PIN PC5 + +#include "pins_MKS_MONSTER8_common.h" diff --git a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8.h b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_common.h similarity index 88% rename from Marlin/src/pins/stm32f4/pins_MKS_MONSTER8.h rename to Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_common.h index e55f3170d03e..2af6a872db13 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_common.h @@ -30,8 +30,6 @@ #error "MKS Monster doesn't support FSMC-based TFT displays." #endif -#define BOARD_INFO_NAME "MKS Monster8 V1.x" - #define HAS_OTG_USB_HOST_SUPPORT // USB Flash Drive support #define USES_DIAG_JUMPERS @@ -54,82 +52,76 @@ #define SERVO0_PIN PA8 // Enable BLTOUCH // -// Limit Switches for diag signal +// Limit Switches for diag signals // -#define X_DIAG_PIN PA14 // Driver0 diag signal is connect to X- -#define Y_DIAG_PIN PA15 // Driver1 diag signal is connect to Y- -#define Z_DIAG_PIN PB13 // Driver2 diag signal is connect to Z- -#define E0_DIAG_PIN PA13 // Driver3 diag signal is connect to X+ -#define E1_DIAG_PIN PC5 // Driver4 diag signal is connect to Y+ -#define E2_DIAG_PIN PB12 // Driver5 diag signal is connect to Z+ -#define E3_DIAG_PIN -1 // Driver6 diag signal is not connect -#define E4_DIAG_PIN -1 // Driver7 diag signal is not connect - -// Limit Switches for endstop +#define X_DIAG_PIN PA14 // Driver0 diag signal is connected to X- +#define Y_DIAG_PIN PA15 // Driver1 diag signal is connected to Y- +#define Z_DIAG_PIN PB13 // Driver2 diag signal is connected to Z- +#define E0_DIAG_PIN PA13 // Driver3 diag signal is connected to X+ +#define E1_DIAG_PIN PC5 // Driver4 diag signal is connected to Y+ +#define E2_DIAG_PIN PB12 // Driver5 diag signal is connected to Z+ +#define E3_DIAG_PIN -1 // Driver6 diag signal is not connected +#define E4_DIAG_PIN -1 // Driver7 diag signal is not connected + +// Limit Switches for endstops #define X_MIN_PIN PA14 -#define X_MAX_PIN PA13 #define Y_MIN_PIN PA15 -#define Y_MAX_PIN PC5 #define Z_MIN_PIN PB13 #define Z_MAX_PIN PB12 // // Steppers -// Driver 0 1 2 3 4 5 6 7 -// For X Y Z E0 E1 E2 E3 E4(default pin settings) // -//Driver0 -#define X_ENABLE_PIN PC15 +#define X_ENABLE_PIN PC15 // Driver0 #define X_STEP_PIN PC14 #define X_DIR_PIN PC13 #ifndef X_CS_PIN #define X_CS_PIN PE6 #endif -//Driver1 -#define Y_ENABLE_PIN PC15 + +#define Y_ENABLE_PIN PC15 // Driver1 #define Y_STEP_PIN PE5 #define Y_DIR_PIN PE4 #ifndef Y_CS_PIN #define Y_CS_PIN PE3 #endif -//Driver2 -#define Z_ENABLE_PIN PE2 + +#define Z_ENABLE_PIN PE2 // Driver2 #define Z_STEP_PIN PE1 #define Z_DIR_PIN PE0 #ifndef Z_CS_PIN #define Z_CS_PIN PB7 #endif -//Driver3 -#define E0_ENABLE_PIN PB6 + +#define E0_ENABLE_PIN PB6 // Driver3 #define E0_STEP_PIN PB5 #define E0_DIR_PIN PB4 #ifndef E0_CS_PIN #define E0_CS_PIN PB3 #endif -//Driver4 -#define E1_ENABLE_PIN PD7 + +#define E1_ENABLE_PIN PD7 // Driver4 #define E1_STEP_PIN PD6 #define E1_DIR_PIN PD5 #ifndef E1_CS_PIN #define E1_CS_PIN PD4 #endif -//Driver5 -#define E2_ENABLE_PIN PD3 + +#define E2_ENABLE_PIN PD3 // Driver5 #define E2_STEP_PIN PD2 #define E2_DIR_PIN PD1 #ifndef E2_CS_PIN #define E2_CS_PIN PD0 #endif -//Driver6 -#define E3_ENABLE_PIN PC8 + +#define E3_ENABLE_PIN PC8 // Driver6 #define E3_STEP_PIN PC7 #define E3_DIR_PIN PC6 #ifndef E3_CS_PIN #define E3_CS_PIN PD15 #endif -//Driver7 -#define E4_ENABLE_PIN PD14 -#define E4_STEP_PIN PD13 + +#define E4_STEP_PIN PD13 // Driver7 #define E4_DIR_PIN PD12 #ifndef E4_CS_PIN #define E4_CS_PIN PD11 @@ -207,20 +199,6 @@ #define FAN1_PIN PA1 // FAN1 #define FAN2_PIN PA0 // FAN2 -// -// Misc. Functions -// -#define PW_DET PC5 // Y+ -#define PW_OFF PB12 // Z+ -#define MT_DET_1_PIN PW_DET -#define MT_DET_2_PIN PW_OFF -#ifndef FIL_RUNOUT_PIN - #define FIL_RUNOUT_PIN MT_DET_1_PIN -#endif -#ifndef FIL_RUNOUT2_PIN - #define FIL_RUNOUT2_PIN MT_DET_2_PIN -#endif - // // Power Supply Control // @@ -347,8 +325,8 @@ #define DOGLCD_CS EXP1_05_PIN #define DOGLCD_SCK EXP2_09_PIN #define DOGLCD_MOSI EXP2_05_PIN - //#define LCD_BACKLIGHT_PIN -1 - //#define LCD_RESET_PIN -1 + //#define LCD_BACKLIGHT_PIN -1 + //#define LCD_RESET_PIN -1 #elif ENABLED(FYSETC_MINI_12864_2_1) diff --git a/ini/stm32f4.ini b/ini/stm32f4.ini index ddb944e80f61..a663d31483fc 100644 --- a/ini/stm32f4.ini +++ b/ini/stm32f4.ini @@ -515,7 +515,7 @@ build_unflags = -DUSBD_USE_CDC build_flags = -DPIN_WIRE_SCL=PB8 -DPIN_WIRE_SDA=PB9 # -# MKS Monster8 +# MKS Monster8 V1 / V2 (STM32F407VET6 ARM Cortex-M4) # [env:mks_monster8] extends = stm32_variant @@ -531,7 +531,7 @@ debug_tool = jlink upload_protocol = jlink # -# MKS Monster8 with USB Flash Drive Support +# MKS Monster8 V1 / V2 (STM32F407VET6 ARM Cortex-M4) with USB Flash Drive Support # Currently, using a STM32duino fork, until USB Host get merged # [env:mks_monster8_usb_flash_drive] @@ -544,7 +544,7 @@ build_flags = ${stm_flash_drive.build_flags} ${stm32f4_I2C1_CAN.build_flag -DUSE_USB_HS_IN_FS # -# MKS Monster8 with USB Flash Drive Support and Shared Media +# MKS Monster8 V1 / V2 (STM32F407VET6 ARM Cortex-M4) with USB Flash Drive Support and Shared Media # Currently, using a STM32duino fork, until USB Host and USB Device MSC get merged # [env:mks_monster8_usb_flash_drive_msc] From f543b3cb84e26c7594b9be2da1bcfc3c7c2b5a60 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 12 Jul 2022 13:02:54 -0500 Subject: [PATCH 22/32] =?UTF-8?q?=F0=9F=93=8C=20Ask=20for=20PlatformIO=206?= =?UTF-8?q?.1.1=20or=20newer=20(#24435)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildroot/share/PlatformIO/scripts/pioutil.py | 9 +++++++-- .../share/PlatformIO/scripts/preflight-checks.py | 5 +++++ ini/esp32.ini | 13 +++++++------ platformio.ini | 13 +++---------- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/buildroot/share/PlatformIO/scripts/pioutil.py b/buildroot/share/PlatformIO/scripts/pioutil.py index b8c1e9cfca6c..32096dab3f25 100644 --- a/buildroot/share/PlatformIO/scripts/pioutil.py +++ b/buildroot/share/PlatformIO/scripts/pioutil.py @@ -4,5 +4,10 @@ # Make sure 'vscode init' is not the current command def is_pio_build(): - from SCons.Script import COMMAND_LINE_TARGETS - return "idedata" not in COMMAND_LINE_TARGETS and "_idedata" not in COMMAND_LINE_TARGETS + from SCons.Script import DefaultEnvironment + env = DefaultEnvironment() + return not env.IsIntegrationDump() + +def get_pio_version(): + from platformio import util + return util.pioversion_to_intstr() diff --git a/buildroot/share/PlatformIO/scripts/preflight-checks.py b/buildroot/share/PlatformIO/scripts/preflight-checks.py index d0f1c138c94a..bbcf40e885a2 100644 --- a/buildroot/share/PlatformIO/scripts/preflight-checks.py +++ b/buildroot/share/PlatformIO/scripts/preflight-checks.py @@ -52,6 +52,11 @@ def sanity_check_target(): if 'PIOENV' not in env: raise SystemExit("Error: PIOENV is not defined. This script is intended to be used with PlatformIO") + # Require PlatformIO 6.1.1 or later + vers = pioutil.get_pio_version() + if vers < [6, 1, 1]: + raise SystemExit("Error: Marlin requires PlatformIO >= 6.1.1. Use 'pio upgrade' to get a newer version.") + if 'MARLIN_FEATURES' not in env: raise SystemExit("Error: this script should be used after common Marlin scripts") diff --git a/ini/esp32.ini b/ini/esp32.ini index 05b045f16e83..f12ef99759cd 100644 --- a/ini/esp32.ini +++ b/ini/esp32.ini @@ -20,6 +20,7 @@ build_src_filter = ${common.default_src_filter} + lib_ignore = NativeEthernet upload_speed = 500000 monitor_speed = 250000 +monitor_filters = colorize, time, send_on_enter, log2file, esp32_exception_decoder #upload_port = marlinesp.local #board_build.flash_mode = qio @@ -28,13 +29,13 @@ extends = env:esp32 board_build.partitions = default_16MB.csv [env:PANDA] -extends = env:esp32 -build_flags = ${env:esp32.build_flags} -DUSE_ESP32_EXIO -DUSE_ESP32_TASK_WDT -lib_deps = ${common.lib_deps} - SoftwareSerialEsp32 +extends = env:esp32 +build_flags = ${env:esp32.build_flags} -DUSE_ESP32_EXIO -DUSE_ESP32_TASK_WDT +lib_deps = ${common.lib_deps} + SoftwareSerialEsp32 board_build.partitions = Marlin/src/HAL/ESP32/esp32.csv -upload_speed = 115200 -monitor_speed = 115200 +upload_speed = 115200 +monitor_speed = 115200 [env:mks_tinybee] extends = env:esp32 diff --git a/platformio.ini b/platformio.ini index 3820e7019389..06ab12096653 100644 --- a/platformio.ini +++ b/platformio.ini @@ -267,17 +267,10 @@ framework = arduino extra_scripts = ${common.extra_scripts} build_flags = ${common.build_flags} lib_deps = ${common.lib_deps} -platform_packages = platformio/tool-dfuutil@^1.11.0 monitor_speed = 250000 -monitor_flags = - --quiet - --echo - --eol - LF - --filter - colorize - --filter - time +monitor_eol = LF +monitor_echo = yes +monitor_filters = colorize, time, send_on_enter, log2file # # Just print the dependency tree From efe04e10168a21f361a325a8c93840c2562042e0 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 12 Jul 2022 13:25:36 -0500 Subject: [PATCH 23/32] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Updat?= =?UTF-8?q?e=20Mac=20Sim=20directions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../share/PlatformIO/debugging/launch.json | 12 +++---- ini/native.ini | 34 ++++++++++++++----- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/buildroot/share/PlatformIO/debugging/launch.json b/buildroot/share/PlatformIO/debugging/launch.json index f2219a44b88f..f9936ebcedf9 100644 --- a/buildroot/share/PlatformIO/debugging/launch.json +++ b/buildroot/share/PlatformIO/debugging/launch.json @@ -29,9 +29,9 @@ "request": "launch", "type": "cppdbg", "cwd": "${workspaceRoot}", - "program": ".pio/build/simulator_macos_debug/debug/MarlinSimulator", - //"program": ".pio/build/simulator_linux_debug/MarlinSimulator", - //"program": ".pio/build/simulator_windows/MarlinSimulator", + "program": "${workspaceRoot}/.pio/build/simulator_macos_debug/debug/MarlinSimulator", + //"program": "${workspaceRoot}/.pio/build/simulator_linux_debug/MarlinSimulator", + //"program": "${workspaceRoot}/.pio/build/simulator_windows/MarlinSimulator", "miDebuggerPath": "/opt/local/bin/ggdb", "MIMode": "gdb" }, @@ -40,9 +40,9 @@ "request": "launch", "type": "cppdbg", "cwd": "${workspaceRoot}", - "program": ".pio/build/simulator_macos_debug/debug/MarlinSimulator", - //"program": ".pio/build/simulator_linux_debug/MarlinSimulator", - //"program": ".pio/build/simulator_windows/MarlinSimulator", + "program": "${workspaceRoot}/.pio/build/simulator_macos_debug/debug/MarlinSimulator", + //"program": "${workspaceRoot}/.pio/build/simulator_linux_debug/MarlinSimulator", + //"program": "${workspaceRoot}/.pio/build/simulator_windows/MarlinSimulator", //"targetArchitecture": "arm64", "MIMode": "lldb" } diff --git a/ini/native.ini b/ini/native.ini index 693a985d4e92..1905559fd060 100644 --- a/ini/native.ini +++ b/ini/native.ini @@ -63,20 +63,36 @@ build_flags = ${simulator_linux.build_flags} ${simulator_linux.release_flags} # # Simulator for macOS (MacPorts) # -# sudo port install gcc11 gdb glm libsdl2 libsdl2_net freetype -# sudo port install ld64 @3_3 +ld64_xcode + +# +# MacPorts: +# sudo port install gcc11 glm libsdl2 libsdl2_net # # cd /opt/local/bin # sudo rm -f gcc g++ cc # sudo ln -s gcc-mp-11 gcc ; sudo ln -s g++-mp-11 g++ ; sudo ln -s g++ cc -# This step may be obsolete: -# sudo port uninstall ld64 ld64-latest -# -# cd - +# cd - +# rehash # # Use 'sudo port install mesa' to get a if no Xcode is installed. # If Xcode is installed be sure to run `xcode-select --install` first. # +#================================================================================== +# +# Homebrew: +# /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" +# +# brew install gcc@12 glm sdl2 sdl2_net +# +# cd /opt/homebrew/bin +# sudo rm -f gcc g++ cc +# sudo ln -s gcc-12 gcc ; sudo ln -s g++-12 g++ ; sudo ln -s g++ cc +# cd - +# +# Use 'brew install mesa' to get a if no Xcode is installed. +# If Xcode is installed be sure to run `xcode-select --install` first. +# + [simulator_macos] build_unflags = -lGL -fstack-protector-strong build_flags = @@ -110,7 +126,7 @@ custom_gcc = g++ # pacman -S --needed base-devel mingw-w64-x86_64-toolchain mingw64/mingw-w64-x86_64-glm mingw64/mingw-w64-x86_64-SDL2 mingw64/mingw-w64-x86_64-SDL2_net mingw-w64-x86_64-dlfcn # [env:simulator_windows] -extends = simulator_common +extends = simulator_common build_src_flags = ${simulator_common.build_src_flags} -fpermissive -build_flags = ${simulator_common.build_flags} ${simulator_common.debug_build_flags} -IC:\\msys64\\mingw64\\include\\SDL2 -fno-stack-protector -Wl,-subsystem,windows -ldl -lmingw32 -lSDL2main -lSDL2 -lSDL2_net -lopengl32 -lssp -build_type = debug +build_flags = ${simulator_common.build_flags} ${simulator_common.debug_build_flags} -IC:\\msys64\\mingw64\\include\\SDL2 -fno-stack-protector -Wl,-subsystem,windows -ldl -lmingw32 -lSDL2main -lSDL2 -lSDL2_net -lopengl32 -lssp +build_type = debug From e840015cad0bbbf882e0b90cb8d722725c6e1dd2 Mon Sep 17 00:00:00 2001 From: GHGiampy <83699429+GHGiampy@users.noreply.github.com> Date: Thu, 14 Jul 2022 03:25:35 +0200 Subject: [PATCH 24/32] =?UTF-8?q?=F0=9F=94=A8=20Abort=20firmware=20update?= =?UTF-8?q?=20on=20transfer=20error=20(#24472,=20#24499)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../share/scripts/MarlinBinaryProtocol.py | 23 ++- buildroot/share/scripts/upload.py | 132 +++++++++++++----- 2 files changed, 112 insertions(+), 43 deletions(-) diff --git a/buildroot/share/scripts/MarlinBinaryProtocol.py b/buildroot/share/scripts/MarlinBinaryProtocol.py index 4887ad991978..ecf9df35e2f5 100644 --- a/buildroot/share/scripts/MarlinBinaryProtocol.py +++ b/buildroot/share/scripts/MarlinBinaryProtocol.py @@ -376,11 +376,13 @@ def close(self): token, data = self.await_response(1000) if token == 'PFT:success': print("File closed") - return + return True elif token == 'PFT:ioerror': print("Client storage device IO error") + return False elif token == 'PFT:invalid': print("No open file") + return False def abort(self): self.protocol.send(FileTransferProtocol.protocol_id, FileTransferProtocol.Packet.ABORT); @@ -417,12 +419,23 @@ def copy(self, filename, dest_filename, compression, dummy): self.write(data[start:end]) kibs = (( (i+1) * block_size) / 1024) / (millis() + 1 - start_time) * 1000 if (i / blocks) >= dump_pctg: - print("\r{0:2.2f}% {1:4.2f}KiB/s {2} Errors: {3}".format((i / blocks) * 100, kibs, "[{0:4.2f}KiB/s]".format(kibs * cratio) if compression_support else "", self.protocol.errors), end='') + print("\r{0:2.0f}% {1:4.2f}KiB/s {2} Errors: {3}".format((i / blocks) * 100, kibs, "[{0:4.2f}KiB/s]".format(kibs * cratio) if compression_support else "", self.protocol.errors), end='') dump_pctg += 0.1 - print("\r{0:2.2f}% {1:4.2f}KiB/s {2} Errors: {3}".format(100, kibs, "[{0:4.2f}KiB/s]".format(kibs * cratio) if compression_support else "", self.protocol.errors)) # no one likes transfers finishing at 99.8% - - self.close() + if self.protocol.errors > 0: + # Dump last status (errors may not be visible) + print("\r{0:2.0f}% {1:4.2f}KiB/s {2} Errors: {3} - Aborting...".format((i / blocks) * 100, kibs, "[{0:4.2f}KiB/s]".format(kibs * cratio) if compression_support else "", self.protocol.errors), end='') + print("") # New line to break the transfer speed line + self.close() + print("Transfer aborted due to protocol errors") + #raise Exception("Transfer aborted due to protocol errors") + return False; + print("\r{0:2.0f}% {1:4.2f}KiB/s {2} Errors: {3}".format(100, kibs, "[{0:4.2f}KiB/s]".format(kibs * cratio) if compression_support else "", self.protocol.errors)) # no one likes transfers finishing at 99.8% + + if not self.close(): + print("Transfer failed") + return False print("Transfer complete") + return True class EchoProtocol(object): diff --git a/buildroot/share/scripts/upload.py b/buildroot/share/scripts/upload.py index c7730d8f299d..52fa1abc549b 100644 --- a/buildroot/share/scripts/upload.py +++ b/buildroot/share/scripts/upload.py @@ -20,14 +20,18 @@ import MarlinBinaryProtocol -# Internal debug flag -Debug = False - #-----------------# # Upload Callback # #-----------------# def Upload(source, target, env): + #-------# + # Debug # + #-------# + Debug = False # Set to True to enable script debug + def debugPrint(data): + if Debug: print(f"[Debug]: {data}") + #------------------# # Marlin functions # #------------------# @@ -39,19 +43,35 @@ def _GetMarlinEnv(marlinEnv, feature): # Port functions # #----------------# def _GetUploadPort(env): - if Debug: print('Autodetecting upload port...') + debugPrint('Autodetecting upload port...') env.AutodetectUploadPort(env) - port = env.subst('$UPLOAD_PORT') - if not port: + portName = env.subst('$UPLOAD_PORT') + if not portName: raise Exception('Error detecting the upload port.') - if Debug: print('OK') - return port + debugPrint('OK') + return portName #-------------------------# # Simple serial functions # #-------------------------# + def _OpenPort(): + # Open serial port + if port.is_open: return + debugPrint('Opening upload port...') + port.open() + port.reset_input_buffer() + debugPrint('OK') + + def _ClosePort(): + # Open serial port + if port is None: return + if not port.is_open: return + debugPrint('Closing upload port...') + port.close() + debugPrint('OK') + def _Send(data): - if Debug: print(f'>> {data}') + debugPrint(f'>> {data}') strdata = bytearray(data, 'utf8') + b'\n' port.write(strdata) time.sleep(0.010) @@ -60,37 +80,37 @@ def _Recv(): clean_responses = [] responses = port.readlines() for Resp in responses: - # Test: suppress invaid chars (coming from debug info) + # Suppress invalid chars (coming from debug info) try: clean_response = Resp.decode('utf8').rstrip().lstrip() clean_responses.append(clean_response) + debugPrint(f'<< {clean_response}') except: pass - if Debug: print(f'<< {clean_response}') return clean_responses #------------------# # SDCard functions # #------------------# def _CheckSDCard(): - if Debug: print('Checking SD card...') + debugPrint('Checking SD card...') _Send('M21') Responses = _Recv() if len(Responses) < 1 or not any('SD card ok' in r for r in Responses): raise Exception('Error accessing SD card') - if Debug: print('SD Card OK') + debugPrint('SD Card OK') return True #----------------# # File functions # #----------------# def _GetFirmwareFiles(UseLongFilenames): - if Debug: print('Get firmware files...') + debugPrint('Get firmware files...') _Send(f"M20 F{'L' if UseLongFilenames else ''}") Responses = _Recv() if len(Responses) < 3 or not any('file list' in r for r in Responses): raise Exception('Error getting firmware files') - if Debug: print('OK') + debugPrint('OK') return Responses def _FilterFirmwareFiles(FirmwareList, UseLongFilenames): @@ -114,6 +134,17 @@ def _RemoveFirmwareFile(FirmwareFile): raise Exception(f"Firmware file '{FirmwareFile}' not removed") return Removed + def _RollbackUpload(FirmwareFile): + if not rollback: return + print(f"Rollback: trying to delete firmware '{FirmwareFile}'...") + _OpenPort() + # Wait for SD card release + time.sleep(1) + # Remount SD card + _CheckSDCard() + print(' OK' if _RemoveFirmwareFile(FirmwareFile) else ' Error!') + _ClosePort() + #---------------------# # Callback Entrypoint # @@ -121,6 +152,7 @@ def _RemoveFirmwareFile(FirmwareFile): port = None protocol = None filetransfer = None + rollback = False # Get Marlin evironment vars MarlinEnv = env['MARLIN_FEATURES'] @@ -204,9 +236,9 @@ def _RemoveFirmwareFile(FirmwareFile): if not marlin_custom_firmware_upload: raise Exception(f"CUSTOM_FIRMWARE_UPLOAD must be enabled in 'Configuration_adv.h' for '{marlin_motherboard}'") - # Init serial port + # Init & Open serial port port = serial.Serial(upload_port, baudrate = upload_speed, write_timeout = 0, timeout = 0.1) - port.reset_input_buffer() + _OpenPort() # Check SD card status _CheckSDCard() @@ -228,24 +260,26 @@ def _RemoveFirmwareFile(FirmwareFile): print(' OK' if _RemoveFirmwareFile(OldFirmwareFile) else ' Error!') # Close serial - port.close() + _ClosePort() # Cleanup completed - if Debug: print('Cleanup completed') + debugPrint('Cleanup completed') # WARNING! The serial port must be closed here because the serial transfer that follow needs it! # Upload firmware file - if Debug: print(f"Copy '{upload_firmware_source_name}' --> '{upload_firmware_target_name}'") + debugPrint(f"Copy '{upload_firmware_source_name}' --> '{upload_firmware_target_name}'") protocol = MarlinBinaryProtocol.Protocol(upload_port, upload_speed, upload_blocksize, float(upload_error_ratio), int(upload_timeout)) #echologger = MarlinBinaryProtocol.EchoProtocol(protocol) protocol.connect() + # Mark the rollback (delete broken transfer) from this point on + rollback = True filetransfer = MarlinBinaryProtocol.FileTransferProtocol(protocol) - filetransfer.copy(upload_firmware_source_name, upload_firmware_target_name, upload_compression, upload_test) + transferOK = filetransfer.copy(upload_firmware_source_name, upload_firmware_target_name, upload_compression, upload_test) protocol.disconnect() # Notify upload completed - protocol.send_ascii('M117 Firmware uploaded') + protocol.send_ascii('M117 Firmware uploaded' if transferOK else 'M117 Firmware upload failed') # Remount SD card print('Wait for SD card release...') @@ -253,34 +287,56 @@ def _RemoveFirmwareFile(FirmwareFile): print('Remount SD card') protocol.send_ascii('M21') - # Trigger firmware update - if upload_reset: - print('Trigger firmware update...') - protocol.send_ascii('M997', True) + # Transfer failed? + if not transferOK: + protocol.shutdown() + _RollbackUpload(upload_firmware_target_name) + else: + # Trigger firmware update + if upload_reset: + print('Trigger firmware update...') + protocol.send_ascii('M997', True) + protocol.shutdown() - protocol.shutdown() - print('Firmware update completed') + print('Firmware update completed' if transferOK else 'Firmware update failed') + return 0 if transferOK else -1 except KeyboardInterrupt: - if port: port.close() + print('Aborted by user') if filetransfer: filetransfer.abort() - if protocol: protocol.shutdown() + if protocol: + protocol.disconnect() + protocol.shutdown() + _RollbackUpload(upload_firmware_target_name) + _ClosePort() raise except serial.SerialException as se: - if port: port.close() - print(f'Serial excepion: {se}') + # This exception is raised only for send_ascii data (not for binary transfer) + print(f'Serial excepion: {se}, transfer aborted') + if protocol: + protocol.disconnect() + protocol.shutdown() + _RollbackUpload(upload_firmware_target_name) + _ClosePort() raise Exception(se) except MarlinBinaryProtocol.FatalError: - if port: port.close() - if protocol: protocol.shutdown() - print('Too many retries, Abort') + print('Too many retries, transfer aborted') + if protocol: + protocol.disconnect() + protocol.shutdown() + _RollbackUpload(upload_firmware_target_name) + _ClosePort() raise - except: - if port: port.close() - if protocol: protocol.shutdown() + except Exception as ex: + print(f"\nException: {ex}, transfer aborted") + if protocol: + protocol.disconnect() + protocol.shutdown() + _RollbackUpload(upload_firmware_target_name) + _ClosePort() print('Firmware not updated') raise From 9283859b1ef82d7aa82bcb64a70d1b25b8e6d22c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 13 Jul 2022 21:22:53 -0500 Subject: [PATCH 25/32] =?UTF-8?q?=F0=9F=8E=A8=20ANY=20=3D>=20EITHER?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/Conditionals_LCD.h | 4 ++-- Marlin/src/inc/Conditionals_post.h | 2 +- Marlin/src/lcd/e3v2/marlinui/ui_common.cpp | 2 +- .../ftdi_eve_lib/basic/commands.cpp | 2 +- .../lcd/extui/ftdi_eve_touch_ui/theme/colors.h | 16 ++++++++-------- Marlin/src/libs/nozzle.cpp | 2 +- Marlin/src/module/probe.cpp | 2 +- Marlin/src/module/temperature.cpp | 10 +++++----- Marlin/src/pins/linux/pins_RAMPS_LINUX.h | 2 +- Marlin/src/pins/lpc1768/pins_MKS_SBASE.h | 2 +- Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h | 2 +- Marlin/src/pins/lpc1769/pins_AZTEEG_X5_GT.h | 2 +- Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h | 2 +- Marlin/src/pins/lpc1769/pins_SMOOTHIEBOARD.h | 2 +- Marlin/src/pins/rambo/pins_RAMBO.h | 2 +- Marlin/src/pins/rambo/pins_SCOOVO_X9H.h | 2 +- Marlin/src/pins/ramps/pins_AZTEEG_X3.h | 2 +- Marlin/src/pins/ramps/pins_AZTEEG_X3_PRO.h | 4 ++-- Marlin/src/pins/ramps/pins_MKS_GEN_13.h | 2 +- Marlin/src/pins/ramps/pins_RAMPS.h | 2 +- Marlin/src/pins/ramps/pins_TRIGORILLA_14.h | 2 +- Marlin/src/pins/ramps/pins_ULTIMAKER_OLD.h | 2 +- Marlin/src/pins/sam/pins_RAMPS_FD_V1.h | 2 +- Marlin/src/pins/samd/pins_BRICOLEMON_LITE_V1_0.h | 2 +- Marlin/src/pins/samd/pins_BRICOLEMON_V1_0.h | 2 +- Marlin/src/pins/samd/pins_RAMPS_144.h | 2 +- Marlin/src/pins/stm32f1/pins_BEAST.h | 2 +- Marlin/src/pins/stm32f1/pins_CHITU3D.h | 2 +- Marlin/src/pins/stm32f1/pins_STM32F1R.h | 2 +- Marlin/src/pins/stm32f1/pins_STM3R_MINI.h | 2 +- .../src/pins/stm32f4/pins_MKS_MONSTER8_common.h | 2 +- Marlin/src/pins/teensy2/pins_PRINTRBOARD.h | 2 +- Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h | 2 +- 33 files changed, 46 insertions(+), 46 deletions(-) diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 12314e649285..1d3ad1c2d5a9 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -464,7 +464,7 @@ #define HAS_DGUS_LCD_CLASSIC 1 #endif -#if ANY(HAS_DGUS_LCD_CLASSIC, DGUS_LCD_UI_RELOADED) +#if EITHER(HAS_DGUS_LCD_CLASSIC, DGUS_LCD_UI_RELOADED) #define HAS_DGUS_LCD 1 #endif @@ -1431,7 +1431,7 @@ #define TFT_DEFAULT_ORIENTATION 0 #define TFT_RES_480x272 #define TFT_INTERFACE_FSMC -#elif ANY(MKS_ROBIN_TFT_V1_1R, LONGER_LK_TFT28) // ILI9328 or R61505 +#elif EITHER(MKS_ROBIN_TFT_V1_1R, LONGER_LK_TFT28) // ILI9328 or R61505 #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_X | TFT_INVERT_Y) #define TFT_RES_320x240 #define TFT_INTERFACE_FSMC diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index dfccd9b8f5c5..3a5470b03e7d 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -48,7 +48,7 @@ // Set additional flags to let HALs choose in their Conditionals_post.h #if ANY(FLASH_EEPROM_EMULATION, SRAM_EEPROM_EMULATION, SDCARD_EEPROM_EMULATION, QSPI_EEPROM) #define USE_EMULATED_EEPROM 1 - #elif ANY(I2C_EEPROM, SPI_EEPROM) + #elif EITHER(I2C_EEPROM, SPI_EEPROM) #define USE_WIRED_EEPROM 1 #elif ENABLED(IIC_BL24CXX_EEPROM) // nothing diff --git a/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp b/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp index 455fce272a1c..ab21c7be4a9c 100644 --- a/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp @@ -565,7 +565,7 @@ void MarlinUI::draw_status_message(const bool blink) { #endif // AUTO_BED_LEVELING_UBL - #if ANY(BABYSTEP_ZPROBE_GFX_OVERLAY, MESH_EDIT_GFX_OVERLAY) + #if EITHER(BABYSTEP_ZPROBE_GFX_OVERLAY, MESH_EDIT_GFX_OVERLAY) void MarlinUI::zoffset_overlay(const int8_t dir) { const int rot_up = TERN(OVERLAY_GFX_REVERSE, ICON_RotateCCW, ICON_RotateCW), diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.cpp index a796c8edcf5f..662753a1547c 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.cpp @@ -1208,7 +1208,7 @@ void CLCD::default_display_orientation() { + ENABLED(TOUCH_UI_INVERTED) * 1 ); cmd.execute(); - #elif ANY(TOUCH_UI_PORTRAIT, TOUCH_UI_MIRRORED) + #elif EITHER(TOUCH_UI_PORTRAIT, TOUCH_UI_MIRRORED) #error "PORTRAIT or MIRRORED orientation not supported on the FT800." #elif ENABLED(TOUCH_UI_INVERTED) mem_write_32(REG::ROTATE, 1); diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/colors.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/colors.h index 995379fcdab7..70c2be4ec23f 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/colors.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/colors.h @@ -37,14 +37,14 @@ namespace Theme { #else // Use linear accent colors - #if ANY(TOUCH_UI_ROYAL_THEME, TOUCH_UI_FROZEN_THEME) - // Dark blue accent colors - constexpr int accent_hue = 216; - constexpr float accent_sat = 0.7; + #if EITHER(TOUCH_UI_ROYAL_THEME, TOUCH_UI_FROZEN_THEME) + // Dark blue accent colors + constexpr int accent_hue = 216; + constexpr float accent_sat = 0.7; #else - // Green accent colors - constexpr int accent_hue = 68; - constexpr float accent_sat = 0.68; + // Green accent colors + constexpr int accent_hue = 68; + constexpr float accent_sat = 0.68; #endif // Shades of accent color @@ -88,7 +88,7 @@ namespace Theme { constexpr uint32_t bed_mesh_lines_rgb = 0xFFFFFF; constexpr uint32_t bed_mesh_shadow_rgb = 0x444444; - #elif ANY(TOUCH_UI_COCOA_THEME, TOUCH_UI_FROZEN_THEME) + #elif EITHER(TOUCH_UI_COCOA_THEME, TOUCH_UI_FROZEN_THEME) constexpr uint32_t theme_darkest = accent_color_1; constexpr uint32_t theme_dark = accent_color_4; diff --git a/Marlin/src/libs/nozzle.cpp b/Marlin/src/libs/nozzle.cpp index 4ca8fa2cae1e..575e74a81472 100644 --- a/Marlin/src/libs/nozzle.cpp +++ b/Marlin/src/libs/nozzle.cpp @@ -161,7 +161,7 @@ Nozzle nozzle; void Nozzle::clean(const uint8_t &pattern, const uint8_t &strokes, const_float_t radius, const uint8_t &objects, const uint8_t cleans) { xyz_pos_t start[HOTENDS] = NOZZLE_CLEAN_START_POINT, end[HOTENDS] = NOZZLE_CLEAN_END_POINT, middle[HOTENDS] = NOZZLE_CLEAN_CIRCLE_MIDDLE; - const uint8_t arrPos = ANY(SINGLENOZZLE, MIXING_EXTRUDER) ? 0 : active_extruder; + const uint8_t arrPos = EITHER(SINGLENOZZLE, MIXING_EXTRUDER) ? 0 : active_extruder; #if NOZZLE_CLEAN_MIN_TEMP > 20 if (thermalManager.degTargetHotend(arrPos) < NOZZLE_CLEAN_MIN_TEMP) { diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index afe5ba7a7416..cc6b521fe1a8 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -53,7 +53,7 @@ float largest_sensorless_adj = 0; #endif -#if ANY(HAS_QUIET_PROBING, USE_SENSORLESS) +#if EITHER(HAS_QUIET_PROBING, USE_SENSORLESS) #include "stepper/indirection.h" #if BOTH(HAS_QUIET_PROBING, PROBING_ESTEPPERS_OFF) #include "stepper.h" diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 65b79d8bc464..97d248864e4f 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -904,7 +904,7 @@ volatile bool Temperature::raw_temps_ready = false; temp_hotend[active_extruder].target = 0.0f; temp_hotend[active_extruder].soft_pwm_amount = 0; #if HAS_FAN - set_fan_speed(ANY(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) ? 0 : active_extruder, 0); + set_fan_speed(EITHER(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) ? 0 : active_extruder, 0); planner.sync_fan_speeds(fan_speed); #endif @@ -922,7 +922,7 @@ volatile bool Temperature::raw_temps_ready = false; disable_all_heaters(); #if HAS_FAN zero_fan_speeds(); - set_fan_speed(ANY(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) ? 0 : active_extruder, 255); + set_fan_speed(EITHER(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) ? 0 : active_extruder, 255); planner.sync_fan_speeds(fan_speed); #endif const xyz_pos_t tuningpos = MPC_TUNING_POS; @@ -949,7 +949,7 @@ volatile bool Temperature::raw_temps_ready = false; } #if HAS_FAN - set_fan_speed(ANY(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) ? 0 : active_extruder, 0); + set_fan_speed(EITHER(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) ? 0 : active_extruder, 0); planner.sync_fan_speeds(fan_speed); #endif @@ -1031,7 +1031,7 @@ volatile bool Temperature::raw_temps_ready = false; total_energy_fan0 += constants.heater_power * hotend.soft_pwm_amount / 127 * MPC_dT + (last_temp - current_temp) * constants.block_heat_capacity; #if HAS_FAN else if (ELAPSED(ms, test_end_ms) && !fan0_done) { - set_fan_speed(ANY(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) ? 0 : active_extruder, 255); + set_fan_speed(EITHER(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) ? 0 : active_extruder, 255); planner.sync_fan_speeds(fan_speed); settle_end_ms = ms + settle_time; test_end_ms = settle_end_ms + test_duration; @@ -1430,7 +1430,7 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { float ambient_xfer_coeff = constants.ambient_xfer_coeff_fan0; #if ENABLED(MPC_INCLUDE_FAN) - const uint8_t fan_index = ANY(MPC_FAN_0_ACTIVE_HOTEND, MPC_FAN_0_ALL_HOTENDS) ? 0 : ee; + const uint8_t fan_index = EITHER(MPC_FAN_0_ACTIVE_HOTEND, MPC_FAN_0_ALL_HOTENDS) ? 0 : ee; const float fan_fraction = TERN_(MPC_FAN_0_ACTIVE_HOTEND, !this_hotend ? 0.0f : ) fan_speed[fan_index] * RECIPROCAL(255); ambient_xfer_coeff += fan_fraction * constants.fan255_adjustment; #endif diff --git a/Marlin/src/pins/linux/pins_RAMPS_LINUX.h b/Marlin/src/pins/linux/pins_RAMPS_LINUX.h index 7953f678fa48..9e2eedd68e80 100644 --- a/Marlin/src/pins/linux/pins_RAMPS_LINUX.h +++ b/Marlin/src/pins/linux/pins_RAMPS_LINUX.h @@ -582,7 +582,7 @@ #define LCD_SDSS SDSS #define SD_DETECT_PIN 49 - #elif ANY(VIKI2, miniVIKI) + #elif EITHER(VIKI2, miniVIKI) #define DOGLCD_CS 45 #define DOGLCD_A0 44 diff --git a/Marlin/src/pins/lpc1768/pins_MKS_SBASE.h b/Marlin/src/pins/lpc1768/pins_MKS_SBASE.h index 7f9e530f3c72..cf12a98aef28 100644 --- a/Marlin/src/pins/lpc1768/pins_MKS_SBASE.h +++ b/Marlin/src/pins/lpc1768/pins_MKS_SBASE.h @@ -238,7 +238,7 @@ #define LCD_SDSS P0_28 // EXP2.4 #define LCD_PINS_ENABLE P0_18 // EXP1.3 #define LCD_PINS_D4 P0_15 // EXP1.5 - #if ANY(VIKI2, miniVIKI) + #if EITHER(VIKI2, miniVIKI) #define DOGLCD_SCK SD_SCK_PIN #define DOGLCD_MOSI SD_MOSI_PIN #endif diff --git a/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h b/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h index 56d75a748cbc..fe424c800a5a 100644 --- a/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h +++ b/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h @@ -351,7 +351,7 @@ //#define SHIFT_EN_PIN P1_22 // (41) J5-4 & AUX-4 #endif - #if ANY(VIKI2, miniVIKI) + #if EITHER(VIKI2, miniVIKI) #define DOGLCD_CS P0_16 // (16) #define DOGLCD_A0 P2_06 // (59) J3-8 & AUX-2 #define DOGLCD_SCK SD_SCK_PIN diff --git a/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_GT.h b/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_GT.h index 7ce78ad2832d..bc7cada8da05 100644 --- a/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_GT.h +++ b/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_GT.h @@ -107,7 +107,7 @@ // Display // -#if ANY(VIKI2, miniVIKI) +#if EITHER(VIKI2, miniVIKI) #define BEEPER_PIN P1_31 #define DOGLCD_A0 P2_06 #define DOGLCD_CS P0_16 diff --git a/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h b/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h index 4fbc19eed843..c33fe6e28f45 100644 --- a/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h +++ b/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h @@ -154,7 +154,7 @@ //#define SHIFT_EN_PIN P1_22 // (41) J5-4 & AUX-4 #endif - #if ANY(VIKI2, miniVIKI) + #if EITHER(VIKI2, miniVIKI) #define BEEPER_PIN P1_30 // (37) may change if cable changes #define DOGLCD_CS P0_26 // (63) J5-3 & AUX-2 #define DOGLCD_SCK SD_SCK_PIN diff --git a/Marlin/src/pins/lpc1769/pins_SMOOTHIEBOARD.h b/Marlin/src/pins/lpc1769/pins_SMOOTHIEBOARD.h index e80116efd036..cfaca164f89e 100644 --- a/Marlin/src/pins/lpc1769/pins_SMOOTHIEBOARD.h +++ b/Marlin/src/pins/lpc1769/pins_SMOOTHIEBOARD.h @@ -91,7 +91,7 @@ // // LCD / Controller // -#if ANY(VIKI2, miniVIKI) +#if EITHER(VIKI2, miniVIKI) #define BEEPER_PIN P1_31 #define DOGLCD_A0 P2_11 diff --git a/Marlin/src/pins/rambo/pins_RAMBO.h b/Marlin/src/pins/rambo/pins_RAMBO.h index 5484b193b93b..cb7a05913414 100644 --- a/Marlin/src/pins/rambo/pins_RAMBO.h +++ b/Marlin/src/pins/rambo/pins_RAMBO.h @@ -208,7 +208,7 @@ #define LCD_PINS_D6 74 #define LCD_PINS_D7 75 - #if ANY(VIKI2, miniVIKI) + #if EITHER(VIKI2, miniVIKI) #define BEEPER_PIN 44 // NB: Panucatt's Viki 2.0 wiring diagram (v1.2) indicates that the // beeper/buzzer is connected to pin 33; however, the pin used in the diff --git a/Marlin/src/pins/rambo/pins_SCOOVO_X9H.h b/Marlin/src/pins/rambo/pins_SCOOVO_X9H.h index 4c2645e64b2a..533284a4bf5e 100644 --- a/Marlin/src/pins/rambo/pins_SCOOVO_X9H.h +++ b/Marlin/src/pins/rambo/pins_SCOOVO_X9H.h @@ -143,7 +143,7 @@ #define HOME_PIN BTN_HOME -#if ANY(VIKI2, miniVIKI) +#if EITHER(VIKI2, miniVIKI) #define BEEPER_PIN 44 // Pins for DOGM SPI LCD Support #define DOGLCD_A0 70 diff --git a/Marlin/src/pins/ramps/pins_AZTEEG_X3.h b/Marlin/src/pins/ramps/pins_AZTEEG_X3.h index 44d8341c11d6..31adea42709d 100644 --- a/Marlin/src/pins/ramps/pins_AZTEEG_X3.h +++ b/Marlin/src/pins/ramps/pins_AZTEEG_X3.h @@ -51,7 +51,7 @@ #undef STAT_LED_RED_PIN #undef STAT_LED_BLUE_PIN -#if ANY(VIKI2, miniVIKI) +#if EITHER(VIKI2, miniVIKI) #undef DOGLCD_A0 #undef DOGLCD_CS diff --git a/Marlin/src/pins/ramps/pins_AZTEEG_X3_PRO.h b/Marlin/src/pins/ramps/pins_AZTEEG_X3_PRO.h index 5dc191cd2016..24266bb9d289 100644 --- a/Marlin/src/pins/ramps/pins_AZTEEG_X3_PRO.h +++ b/Marlin/src/pins/ramps/pins_AZTEEG_X3_PRO.h @@ -142,7 +142,7 @@ #undef BEEPER_PIN #define BEEPER_PIN 33 -#if ANY(VIKI2, miniVIKI) +#if EITHER(VIKI2, miniVIKI) #undef SD_DETECT_PIN #define SD_DETECT_PIN 49 // For easy adapter board #undef BEEPER_PIN @@ -169,7 +169,7 @@ #undef SPINDLE_DIR_PIN #if HAS_CUTTER // EXP2 header - #if ANY(VIKI2, miniVIKI) + #if EITHER(VIKI2, miniVIKI) #define BTN_EN2 31 // Pin 7 needed for Spindle PWM #endif #define SPINDLE_LASER_PWM_PIN 7 // Hardware PWM diff --git a/Marlin/src/pins/ramps/pins_MKS_GEN_13.h b/Marlin/src/pins/ramps/pins_MKS_GEN_13.h index bb7b55893ec1..1ba58629c15f 100644 --- a/Marlin/src/pins/ramps/pins_MKS_GEN_13.h +++ b/Marlin/src/pins/ramps/pins_MKS_GEN_13.h @@ -60,7 +60,7 @@ // // LCD / Controller // -#if ANY(VIKI2, miniVIKI) +#if EITHER(VIKI2, miniVIKI) /** * VIKI2 Has two groups of wires with... * diff --git a/Marlin/src/pins/ramps/pins_RAMPS.h b/Marlin/src/pins/ramps/pins_RAMPS.h index d779372b1b84..5672915b7cbb 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS.h +++ b/Marlin/src/pins/ramps/pins_RAMPS.h @@ -728,7 +728,7 @@ #define LCD_SDSS SDSS #define SD_DETECT_PIN EXP2_04_PIN - #elif ANY(VIKI2, miniVIKI) + #elif EITHER(VIKI2, miniVIKI) #define DOGLCD_CS AUX4_05_PIN #define DOGLCD_A0 AUX2_07_PIN diff --git a/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h b/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h index 994a54297f7c..b685ff0094d0 100644 --- a/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h +++ b/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h @@ -128,7 +128,7 @@ // LCD Display input pins #if IS_NEWPANEL - #if ANY(VIKI2, miniVIKI) + #if EITHER(VIKI2, miniVIKI) #undef DOGLCD_A0 #define DOGLCD_A0 23 #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) diff --git a/Marlin/src/pins/ramps/pins_ULTIMAKER_OLD.h b/Marlin/src/pins/ramps/pins_ULTIMAKER_OLD.h index 37060ab94541..146c519ff962 100644 --- a/Marlin/src/pins/ramps/pins_ULTIMAKER_OLD.h +++ b/Marlin/src/pins/ramps/pins_ULTIMAKER_OLD.h @@ -163,7 +163,7 @@ // // LCD / Controller // -#if ANY(BOARD_REV_1_0, BOARD_REV_1_1_TO_1_3) +#if EITHER(BOARD_REV_1_0, BOARD_REV_1_1_TO_1_3) #define LCD_PINS_RS 24 #define LCD_PINS_ENABLE 22 diff --git a/Marlin/src/pins/sam/pins_RAMPS_FD_V1.h b/Marlin/src/pins/sam/pins_RAMPS_FD_V1.h index 980a957a505a..4cb0f60328ca 100644 --- a/Marlin/src/pins/sam/pins_RAMPS_FD_V1.h +++ b/Marlin/src/pins/sam/pins_RAMPS_FD_V1.h @@ -217,7 +217,7 @@ #endif - #if ANY(VIKI2, miniVIKI) + #if EITHER(VIKI2, miniVIKI) #define DOGLCD_A0 EXP1_04_PIN #define KILL_PIN 51 #define STAT_LED_BLUE_PIN EXP1_08_PIN diff --git a/Marlin/src/pins/samd/pins_BRICOLEMON_LITE_V1_0.h b/Marlin/src/pins/samd/pins_BRICOLEMON_LITE_V1_0.h index 382c607d239b..264b2e80c6bc 100644 --- a/Marlin/src/pins/samd/pins_BRICOLEMON_LITE_V1_0.h +++ b/Marlin/src/pins/samd/pins_BRICOLEMON_LITE_V1_0.h @@ -373,7 +373,7 @@ //#define LCD_SDSS SDSS //#define SD_DETECT_PIN EXP2_01_PIN - #elif ANY(VIKI2, miniVIKI) + #elif EITHER(VIKI2, miniVIKI) // TO TEST //#define DOGLCD_CS 45 diff --git a/Marlin/src/pins/samd/pins_BRICOLEMON_V1_0.h b/Marlin/src/pins/samd/pins_BRICOLEMON_V1_0.h index 0f4bb1d0b591..e90be4eda1ec 100644 --- a/Marlin/src/pins/samd/pins_BRICOLEMON_V1_0.h +++ b/Marlin/src/pins/samd/pins_BRICOLEMON_V1_0.h @@ -424,7 +424,7 @@ //#define LCD_SDSS SDSS //#define SD_DETECT_PIN EXP2_01_PIN - #elif ANY(VIKI2, miniVIKI) + #elif EITHER(VIKI2, miniVIKI) // TO TEST //#define DOGLCD_CS 45 diff --git a/Marlin/src/pins/samd/pins_RAMPS_144.h b/Marlin/src/pins/samd/pins_RAMPS_144.h index 406162c0896e..2c42506a5f4d 100644 --- a/Marlin/src/pins/samd/pins_RAMPS_144.h +++ b/Marlin/src/pins/samd/pins_RAMPS_144.h @@ -408,7 +408,7 @@ //#define LCD_SDSS SDSS //#define SD_DETECT_PIN 49 - #elif ANY(VIKI2, miniVIKI) + #elif EITHER(VIKI2, miniVIKI) // TO TEST //#define DOGLCD_CS 45 diff --git a/Marlin/src/pins/stm32f1/pins_BEAST.h b/Marlin/src/pins/stm32f1/pins_BEAST.h index d494b29c1448..4dafe2f27365 100644 --- a/Marlin/src/pins/stm32f1/pins_BEAST.h +++ b/Marlin/src/pins/stm32f1/pins_BEAST.h @@ -131,7 +131,7 @@ #error "LCD_I2C_PANELOLU2 is not supported." #elif ENABLED(LCD_I2C_VIKI) #error "LCD_I2C_VIKI is not supported." - #elif ANY(VIKI2, miniVIKI) + #elif EITHER(VIKI2, miniVIKI) #error "VIKI2 / miniVIKI is not supported." #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) #error "ELB_FULL_GRAPHIC_CONTROLLER is not supported." diff --git a/Marlin/src/pins/stm32f1/pins_CHITU3D.h b/Marlin/src/pins/stm32f1/pins_CHITU3D.h index 1f56e59a23c5..3b66096a270d 100644 --- a/Marlin/src/pins/stm32f1/pins_CHITU3D.h +++ b/Marlin/src/pins/stm32f1/pins_CHITU3D.h @@ -171,7 +171,7 @@ #define LCD_SDSS PD5 // 53 #define SD_DETECT_PIN PD1 // 49 - #elif ANY(VIKI2, miniVIKI) + #elif EITHER(VIKI2, miniVIKI) #define BEEPER_PIN PC1 // 33 diff --git a/Marlin/src/pins/stm32f1/pins_STM32F1R.h b/Marlin/src/pins/stm32f1/pins_STM32F1R.h index c08b707d7e99..634cadc1aa8e 100644 --- a/Marlin/src/pins/stm32f1/pins_STM32F1R.h +++ b/Marlin/src/pins/stm32f1/pins_STM32F1R.h @@ -120,7 +120,7 @@ #error "LCD_I2C_PANELOLU2 is not supported." #elif ENABLED(LCD_I2C_VIKI) #error "LCD_I2C_VIKI is not supported." - #elif ANY(VIKI2, miniVIKI) + #elif EITHER(VIKI2, miniVIKI) #error "VIKI2 / miniVIKI is not supported." #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) #error "ELB_FULL_GRAPHIC_CONTROLLER is not supported." diff --git a/Marlin/src/pins/stm32f1/pins_STM3R_MINI.h b/Marlin/src/pins/stm32f1/pins_STM3R_MINI.h index e189fc3f97b9..eee7dbf31669 100644 --- a/Marlin/src/pins/stm32f1/pins_STM3R_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_STM3R_MINI.h @@ -144,7 +144,7 @@ #error "LCD_I2C_PANELOLU2 is not supported." #elif ENABLED(LCD_I2C_VIKI) #error "LCD_I2C_VIKI is not supported." - #elif ANY(VIKI2, miniVIKI) + #elif EITHER(VIKI2, miniVIKI) #error "VIKI2 / miniVIKI is not supported." #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) #error "ELB_FULL_GRAPHIC_CONTROLLER is not supported." diff --git a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_common.h b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_common.h index 2af6a872db13..cc02ac3097eb 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_common.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_common.h @@ -261,7 +261,7 @@ #endif #endif -#if ANY(TFT_COLOR_UI, TFT_CLASSIC_UI) +#if EITHER(TFT_COLOR_UI, TFT_CLASSIC_UI) #define TFT_CS_PIN EXP1_04_PIN #define TFT_SCK_PIN EXP2_09_PIN #define TFT_MISO_PIN EXP2_10_PIN diff --git a/Marlin/src/pins/teensy2/pins_PRINTRBOARD.h b/Marlin/src/pins/teensy2/pins_PRINTRBOARD.h index 82d9cec8949b..ddf0d53ea60a 100644 --- a/Marlin/src/pins/teensy2/pins_PRINTRBOARD.h +++ b/Marlin/src/pins/teensy2/pins_PRINTRBOARD.h @@ -130,7 +130,7 @@ #define LCD_PINS_D6 5 // D5 JP11-6 #define LCD_PINS_D7 4 // D4 JP11-5 - #if ANY(VIKI2, miniVIKI) + #if EITHER(VIKI2, miniVIKI) #define BEEPER_PIN 8 // E0 JP11-10 #define DOGLCD_A0 40 // F2 JP2-2 diff --git a/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h b/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h index 1ac953c89f8b..18673980870f 100644 --- a/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h +++ b/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h @@ -207,7 +207,7 @@ #define LCD_PINS_D6 5 // D5 JP11-6 #define LCD_PINS_D7 4 // D4 JP11-5 - #if ANY(VIKI2, miniVIKI) + #if EITHER(VIKI2, miniVIKI) #define BEEPER_PIN 8 // E0 JP11-10 #define DOGLCD_A0 40 // F2 JP2-2 From 6b19a58f035862292a3ec52b4efc388b746d69ad Mon Sep 17 00:00:00 2001 From: Bob Kuhn Date: Wed, 13 Jul 2022 22:16:22 -0500 Subject: [PATCH 26/32] =?UTF-8?q?=F0=9F=94=A5=20Drop=20STM=20L64**=20drive?= =?UTF-8?q?rs,=20STEVAL=5F3DP001V1=20(#24427)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration.h | 5 +- Marlin/Configuration_adv.h | 247 ----- Marlin/src/HAL/shared/HAL_spi_L6470.cpp | 139 --- Marlin/src/MarlinCore.cpp | 13 +- Marlin/src/core/boards.h | 1 - Marlin/src/core/drivers.h | 17 - Marlin/src/gcode/calibrate/G28.cpp | 20 - Marlin/src/gcode/feature/L6470/M122.cpp | 151 --- Marlin/src/gcode/feature/L6470/M906.cpp | 417 -------- Marlin/src/gcode/feature/L6470/M916-M918.cpp | 650 ------------ Marlin/src/gcode/gcode.cpp | 8 - Marlin/src/gcode/gcode.h | 15 +- Marlin/src/gcode/host/M114.cpp | 89 -- Marlin/src/inc/Conditionals_post.h | 42 +- Marlin/src/inc/SanityCheck.h | 34 +- Marlin/src/libs/L64XX/L64XX_Marlin.cpp | 998 ------------------ Marlin/src/libs/L64XX/L64XX_Marlin.h | 141 --- Marlin/src/libs/L64XX/README.md | 98 -- Marlin/src/module/stepper.cpp | 31 +- Marlin/src/module/stepper/L64xx.cpp | 264 ----- Marlin/src/module/stepper/L64xx.h | 490 --------- Marlin/src/module/stepper/indirection.cpp | 1 - Marlin/src/module/stepper/indirection.h | 4 - Marlin/src/pins/pins.h | 8 +- Marlin/src/pins/pinsDebug_list.h | 15 - .../src/pins/stm32f4/pins_STEVAL_3DP001V1.h | 325 ------ .../boards/marlin_STEVAL_STM32F401VE.json | 64 -- .../MARLIN_STEVAL_F401VE/PeripheralPins.c | 260 ----- .../MARLIN_STEVAL_F401VE/PinNamesVar.h | 33 - .../MARLIN_STEVAL_F401VE/hal_conf_custom.h | 495 --------- .../variants/MARLIN_STEVAL_F401VE/ldscript.ld | 187 ---- .../variants/MARLIN_STEVAL_F401VE/variant.cpp | 310 ------ .../variants/MARLIN_STEVAL_F401VE/variant.h | 327 ------ buildroot/tests/FYSETC_F6 | 8 +- buildroot/tests/STM32F401VE_STEVAL | 15 - ini/features.ini | 2 - ini/stm32f4.ini | 11 - 37 files changed, 55 insertions(+), 5880 deletions(-) delete mode 100644 Marlin/src/HAL/shared/HAL_spi_L6470.cpp delete mode 100644 Marlin/src/gcode/feature/L6470/M122.cpp delete mode 100644 Marlin/src/gcode/feature/L6470/M906.cpp delete mode 100644 Marlin/src/gcode/feature/L6470/M916-M918.cpp delete mode 100644 Marlin/src/libs/L64XX/L64XX_Marlin.cpp delete mode 100644 Marlin/src/libs/L64XX/L64XX_Marlin.h delete mode 100644 Marlin/src/libs/L64XX/README.md delete mode 100644 Marlin/src/module/stepper/L64xx.cpp delete mode 100644 Marlin/src/module/stepper/L64xx.h delete mode 100644 Marlin/src/pins/stm32f4/pins_STEVAL_3DP001V1.h delete mode 100644 buildroot/share/PlatformIO/boards/marlin_STEVAL_STM32F401VE.json delete mode 100644 buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/PeripheralPins.c delete mode 100644 buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/PinNamesVar.h delete mode 100644 buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/hal_conf_custom.h delete mode 100644 buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/ldscript.ld delete mode 100644 buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/variant.cpp delete mode 100644 buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/variant.h delete mode 100755 buildroot/tests/STM32F401VE_STEVAL diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index e05428ad08d8..4d9bf8871fe8 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -148,13 +148,12 @@ * * Use TMC2208/TMC2208_STANDALONE for TMC2225 drivers and TMC2209/TMC2209_STANDALONE for TMC2226 drivers. * - * Options: A4988, A5984, DRV8825, LV8729, L6470, L6474, POWERSTEP01, - * TB6560, TB6600, TMC2100, + * Options: A4988, A5984, DRV8825, LV8729, TB6560, TB6600, TMC2100, * TMC2130, TMC2130_STANDALONE, TMC2160, TMC2160_STANDALONE, * TMC2208, TMC2208_STANDALONE, TMC2209, TMC2209_STANDALONE, * TMC26X, TMC26X_STANDALONE, TMC2660, TMC2660_STANDALONE, * TMC5130, TMC5130_STANDALONE, TMC5160, TMC5160_STANDALONE - * :['A4988', 'A5984', 'DRV8825', 'LV8729', 'L6470', 'L6474', 'POWERSTEP01', 'TB6560', 'TB6600', 'TMC2100', 'TMC2130', 'TMC2130_STANDALONE', 'TMC2160', 'TMC2160_STANDALONE', 'TMC2208', 'TMC2208_STANDALONE', 'TMC2209', 'TMC2209_STANDALONE', 'TMC26X', 'TMC26X_STANDALONE', 'TMC2660', 'TMC2660_STANDALONE', 'TMC5130', 'TMC5130_STANDALONE', 'TMC5160', 'TMC5160_STANDALONE'] + * :['A4988', 'A5984', 'DRV8825', 'LV8729', 'TB6560', 'TB6600', 'TMC2100', 'TMC2130', 'TMC2130_STANDALONE', 'TMC2160', 'TMC2160_STANDALONE', 'TMC2208', 'TMC2208_STANDALONE', 'TMC2209', 'TMC2209_STANDALONE', 'TMC26X', 'TMC26X_STANDALONE', 'TMC2660', 'TMC2660_STANDALONE', 'TMC5130', 'TMC5130_STANDALONE', 'TMC5160', 'TMC5160_STANDALONE'] */ #define X_DRIVER_TYPE A4988 #define Y_DRIVER_TYPE A4988 diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 7f85b241a2ea..bf305741ddcd 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3239,253 +3239,6 @@ #endif // HAS_TRINAMIC_CONFIG -// @section L64XX - -/** - * L64XX Stepper Driver options - * - * Arduino-L6470 library (0.8.0 or higher) is required. - * https://github.com/ameyer/Arduino-L6470 - * - * Requires the following to be defined in your pins_YOUR_BOARD file - * L6470_CHAIN_SCK_PIN - * L6470_CHAIN_MISO_PIN - * L6470_CHAIN_MOSI_PIN - * L6470_CHAIN_SS_PIN - * ENABLE_RESET_L64XX_CHIPS(Q) where Q is 1 to enable and 0 to reset - */ - -#if HAS_L64XX - - //#define L6470_CHITCHAT // Display additional status info - - #if AXIS_IS_L64XX(X) - #define X_MICROSTEPS 128 // Number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128) - L6474 max is 16 - #define X_OVERCURRENT 2000 // (mA) Current where the driver detects an over current - // L6470 & L6474 - VALID: 375 x (1 - 16) - 6A max - rounds down - // POWERSTEP01: VALID: 1000 x (1 - 32) - 32A max - rounds down - #define X_STALLCURRENT 1500 // (mA) Current where the driver detects a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) - // L6470 & L6474 - VALID: 31.25 * (1-128) - 4A max - rounds down - // POWERSTEP01: VALID: 200 x (1 - 32) - 6.4A max - rounds down - // L6474 - STALLCURRENT setting is used to set the nominal (TVAL) current - #define X_MAX_VOLTAGE 127 // 0-255, Maximum effective voltage seen by stepper - not used by L6474 - #define X_CHAIN_POS -1 // Position in SPI chain, 0=Not in chain, 1=Nearest MOSI - #define X_SLEW_RATE 1 // 0-3, Slew 0 is slowest, 3 is fastest - #endif - - #if AXIS_IS_L64XX(X2) - #define X2_MICROSTEPS X_MICROSTEPS - #define X2_OVERCURRENT 2000 - #define X2_STALLCURRENT 1500 - #define X2_MAX_VOLTAGE 127 - #define X2_CHAIN_POS -1 - #define X2_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(Y) - #define Y_MICROSTEPS 128 - #define Y_OVERCURRENT 2000 - #define Y_STALLCURRENT 1500 - #define Y_MAX_VOLTAGE 127 - #define Y_CHAIN_POS -1 - #define Y_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(Y2) - #define Y2_MICROSTEPS Y_MICROSTEPS - #define Y2_OVERCURRENT 2000 - #define Y2_STALLCURRENT 1500 - #define Y2_MAX_VOLTAGE 127 - #define Y2_CHAIN_POS -1 - #define Y2_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(Z) - #define Z_MICROSTEPS 128 - #define Z_OVERCURRENT 2000 - #define Z_STALLCURRENT 1500 - #define Z_MAX_VOLTAGE 127 - #define Z_CHAIN_POS -1 - #define Z_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(Z2) - #define Z2_MICROSTEPS Z_MICROSTEPS - #define Z2_OVERCURRENT 2000 - #define Z2_STALLCURRENT 1500 - #define Z2_MAX_VOLTAGE 127 - #define Z2_CHAIN_POS -1 - #define Z2_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(Z3) - #define Z3_MICROSTEPS Z_MICROSTEPS - #define Z3_OVERCURRENT 2000 - #define Z3_STALLCURRENT 1500 - #define Z3_MAX_VOLTAGE 127 - #define Z3_CHAIN_POS -1 - #define Z3_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(Z4) - #define Z4_MICROSTEPS Z_MICROSTEPS - #define Z4_OVERCURRENT 2000 - #define Z4_STALLCURRENT 1500 - #define Z4_MAX_VOLTAGE 127 - #define Z4_CHAIN_POS -1 - #define Z4_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(I) - #define I_MICROSTEPS 128 - #define I_OVERCURRENT 2000 - #define I_STALLCURRENT 1500 - #define I_MAX_VOLTAGE 127 - #define I_CHAIN_POS -1 - #define I_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(J) - #define J_MICROSTEPS 128 - #define J_OVERCURRENT 2000 - #define J_STALLCURRENT 1500 - #define J_MAX_VOLTAGE 127 - #define J_CHAIN_POS -1 - #define J_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(K) - #define K_MICROSTEPS 128 - #define K_OVERCURRENT 2000 - #define K_STALLCURRENT 1500 - #define K_MAX_VOLTAGE 127 - #define K_CHAIN_POS -1 - #define K_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(U) - #define U_MICROSTEPS 128 - #define U_OVERCURRENT 2000 - #define U_STALLCURRENT 1500 - #define U_MAX_VOLTAGE 127 - #define U_CHAIN_POS -1 - #define U_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(V) - #define V_MICROSTEPS 128 - #define V_OVERCURRENT 2000 - #define V_STALLCURRENT 1500 - #define V_MAX_VOLTAGE 127 - #define V_CHAIN_POS -1 - #define V_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(W) - #define W_MICROSTEPS 128 - #define W_OVERCURRENT 2000 - #define W_STALLCURRENT 1500 - #define W_MAX_VOLTAGE 127 - #define W_CHAIN_POS -1 - #define W_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(E0) - #define E0_MICROSTEPS 128 - #define E0_OVERCURRENT 2000 - #define E0_STALLCURRENT 1500 - #define E0_MAX_VOLTAGE 127 - #define E0_CHAIN_POS -1 - #define E0_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(E1) - #define E1_MICROSTEPS E0_MICROSTEPS - #define E1_OVERCURRENT 2000 - #define E1_STALLCURRENT 1500 - #define E1_MAX_VOLTAGE 127 - #define E1_CHAIN_POS -1 - #define E1_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(E2) - #define E2_MICROSTEPS E0_MICROSTEPS - #define E2_OVERCURRENT 2000 - #define E2_STALLCURRENT 1500 - #define E2_MAX_VOLTAGE 127 - #define E2_CHAIN_POS -1 - #define E2_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(E3) - #define E3_MICROSTEPS E0_MICROSTEPS - #define E3_OVERCURRENT 2000 - #define E3_STALLCURRENT 1500 - #define E3_MAX_VOLTAGE 127 - #define E3_CHAIN_POS -1 - #define E3_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(E4) - #define E4_MICROSTEPS E0_MICROSTEPS - #define E4_OVERCURRENT 2000 - #define E4_STALLCURRENT 1500 - #define E4_MAX_VOLTAGE 127 - #define E4_CHAIN_POS -1 - #define E4_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(E5) - #define E5_MICROSTEPS E0_MICROSTEPS - #define E5_OVERCURRENT 2000 - #define E5_STALLCURRENT 1500 - #define E5_MAX_VOLTAGE 127 - #define E5_CHAIN_POS -1 - #define E5_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(E6) - #define E6_MICROSTEPS E0_MICROSTEPS - #define E6_OVERCURRENT 2000 - #define E6_STALLCURRENT 1500 - #define E6_MAX_VOLTAGE 127 - #define E6_CHAIN_POS -1 - #define E6_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(E7) - #define E7_MICROSTEPS E0_MICROSTEPS - #define E7_OVERCURRENT 2000 - #define E7_STALLCURRENT 1500 - #define E7_MAX_VOLTAGE 127 - #define E7_CHAIN_POS -1 - #define E7_SLEW_RATE 1 - #endif - - /** - * Monitor L6470 drivers for error conditions like over temperature and over current. - * In the case of over temperature Marlin can decrease the drive until the error condition clears. - * Other detected conditions can be used to stop the current print. - * Relevant G-codes: - * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. - * I not present or I0 or I1 - X, Y, Z or E0 - * I2 - X2, Y2, Z2 or E1 - * I3 - Z3 or E3 - * I4 - Z4 or E4 - * I5 - E5 - * M916 - Increase drive level until get thermal warning - * M917 - Find minimum current thresholds - * M918 - Increase speed until max or error - * M122 S0/1 - Report driver parameters - */ - //#define MONITOR_L6470_DRIVER_STATUS - - #if ENABLED(MONITOR_L6470_DRIVER_STATUS) - #define KVAL_HOLD_STEP_DOWN 1 - //#define L6470_STOP_ON_ERROR - #endif - -#endif // HAS_L64XX // @section i2cbus diff --git a/Marlin/src/HAL/shared/HAL_spi_L6470.cpp b/Marlin/src/HAL/shared/HAL_spi_L6470.cpp deleted file mode 100644 index 5d4ce89b2748..000000000000 --- a/Marlin/src/HAL/shared/HAL_spi_L6470.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -/** - * Software L6470 SPI functions originally from Arduino Sd2Card Library - * Copyright (c) 2009 by William Greiman - */ - -#include "../../inc/MarlinConfig.h" - -#if HAS_L64XX - -#include "Delay.h" - -#include "../../core/serial.h" -#include "../../libs/L64XX/L64XX_Marlin.h" - -// Make sure GCC optimizes this file. -// Note that this line triggers a bug in GCC which is fixed by casting. -// See the note below. -#pragma GCC optimize (3) - -// run at ~4Mhz -inline uint8_t L6470_SpiTransfer_Mode_0(uint8_t b) { // using Mode 0 - for (uint8_t bits = 8; bits--;) { - WRITE(L6470_CHAIN_MOSI_PIN, b & 0x80); - b <<= 1; // little setup time - - WRITE(L6470_CHAIN_SCK_PIN, HIGH); - DELAY_NS(125); // 10 cycles @ 84mhz - - b |= (READ(L6470_CHAIN_MISO_PIN) != 0); - - WRITE(L6470_CHAIN_SCK_PIN, LOW); - DELAY_NS(125); // 10 cycles @ 84mhz - } - return b; -} - -inline uint8_t L6470_SpiTransfer_Mode_3(uint8_t b) { // using Mode 3 - for (uint8_t bits = 8; bits--;) { - WRITE(L6470_CHAIN_SCK_PIN, LOW); - WRITE(L6470_CHAIN_MOSI_PIN, b & 0x80); - - DELAY_NS(125); // 10 cycles @ 84mhz - WRITE(L6470_CHAIN_SCK_PIN, HIGH); - DELAY_NS(125); // Need more delay for fast CPUs - - b <<= 1; // little setup time - b |= (READ(L6470_CHAIN_MISO_PIN) != 0); - } - DELAY_NS(125); // 10 cycles @ 84mhz - return b; -} - -/** - * L64XX methods for SPI init and transfer - */ -void L64XX_Marlin::spi_init() { - OUT_WRITE(L6470_CHAIN_SS_PIN, HIGH); - OUT_WRITE(L6470_CHAIN_SCK_PIN, HIGH); - OUT_WRITE(L6470_CHAIN_MOSI_PIN, HIGH); - SET_INPUT(L6470_CHAIN_MISO_PIN); - - #if PIN_EXISTS(L6470_BUSY) - SET_INPUT(L6470_BUSY_PIN); - #endif - - OUT_WRITE(L6470_CHAIN_MOSI_PIN, HIGH); -} - -uint8_t L64XX_Marlin::transfer_single(uint8_t data, int16_t ss_pin) { - // First device in chain has data sent last - extDigitalWrite(ss_pin, LOW); - - hal.isr_off(); // Disable interrupts during SPI transfer (can't allow partial command to chips) - const uint8_t data_out = L6470_SpiTransfer_Mode_3(data); - hal.isr_on(); // Enable interrupts - - extDigitalWrite(ss_pin, HIGH); - return data_out; -} - -uint8_t L64XX_Marlin::transfer_chain(uint8_t data, int16_t ss_pin, uint8_t chain_position) { - uint8_t data_out = 0; - - // first device in chain has data sent last - extDigitalWrite(ss_pin, LOW); - - for (uint8_t i = L64XX::chain[0]; !L64xxManager.spi_abort && i >= 1; i--) { // Send data unless aborted - hal.isr_off(); // Disable interrupts during SPI transfer (can't allow partial command to chips) - const uint8_t temp = L6470_SpiTransfer_Mode_3(uint8_t(i == chain_position ? data : dSPIN_NOP)); - hal.isr_on(); // Enable interrupts - if (i == chain_position) data_out = temp; - } - - extDigitalWrite(ss_pin, HIGH); - return data_out; -} - -/** - * Platform-supplied L6470 buffer transfer method - */ -void L64XX_Marlin::transfer(uint8_t L6470_buf[], const uint8_t length) { - // First device in chain has its data sent last - - if (spi_active) { // Interrupted SPI transfer so need to - WRITE(L6470_CHAIN_SS_PIN, HIGH); // guarantee min high of 650ns - DELAY_US(1); - } - - WRITE(L6470_CHAIN_SS_PIN, LOW); - for (uint8_t i = length; i >= 1; i--) - L6470_SpiTransfer_Mode_3(uint8_t(L6470_buf[i])); - WRITE(L6470_CHAIN_SS_PIN, HIGH); -} - -#pragma GCC reset_options - -#endif // HAS_L64XX diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 7a835da4979c..099289f35b9a 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -226,10 +226,6 @@ #include "feature/mmu/mmu2.h" #endif -#if HAS_L64XX - #include "libs/L64XX/L64XX_Marlin.h" -#endif - #if ENABLED(PASSWORD_FEATURE) #include "feature/password/password.h" #endif @@ -432,7 +428,7 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) { if (!has_blocks && !do_reset_timeout && gcode.stepper_inactive_timeout()) { if (!already_shutdown_steppers) { - already_shutdown_steppers = true; // L6470 SPI will consume 99% of free time without this + already_shutdown_steppers = true; // Individual axes will be disabled if configured TERN_(DISABLE_INACTIVE_X, stepper.disable_axis(X_AXIS)); @@ -731,8 +727,6 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) { TERN_(MONITOR_DRIVER_STATUS, monitor_tmc_drivers()); - TERN_(MONITOR_L6470_DRIVER_STATUS, L64xxManager.monitor_driver()); - // Limit check_axes_activity frequency to 10Hz static millis_t next_check_axes_ms = 0; if (ELAPSED(ms, next_check_axes_ms)) { @@ -1062,7 +1056,6 @@ inline void tmc_standby_setup() { * • TMC220x Stepper Drivers (Serial) * • PSU control * • Power-loss Recovery - * • L64XX Stepper Drivers (SPI) * • Stepper Driver Reset: DISABLE * • TMC Stepper Drivers (SPI) * • Run hal.init_board() for additional pins setup @@ -1251,10 +1244,6 @@ void setup() { SETUP_RUN(tmc_init_cs_pins()); #endif - #if HAS_L64XX - SETUP_RUN(L64xxManager.init()); // Set up SPI, init drivers - #endif - #if ENABLED(PSU_CONTROL) SETUP_LOG("PSU_CONTROL"); powerManager.init(); diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index 2882f5a1eea3..2e71c632de9d 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -385,7 +385,6 @@ #define BOARD_RUMBA32_BTT 4204 // RUMBA32 STM32F446VE based controller from BIGTREETECH #define BOARD_BLACK_STM32F407VE 4205 // BLACK_STM32F407VE #define BOARD_BLACK_STM32F407ZE 4206 // BLACK_STM32F407ZE -#define BOARD_STEVAL_3DP001V1 4207 // STEVAL-3DP001V1 3D PRINTER BOARD #define BOARD_BTT_SKR_PRO_V1_1 4208 // BigTreeTech SKR Pro v1.1 (STM32F407ZG) #define BOARD_BTT_SKR_PRO_V1_2 4209 // BigTreeTech SKR Pro v1.2 (STM32F407ZG) #define BOARD_BTT_BTT002_V1_0 4210 // BigTreeTech BTT002 v1.0 (STM32F407VG) diff --git a/Marlin/src/core/drivers.h b/Marlin/src/core/drivers.h index 7f9da909b248..8cf03d342a34 100644 --- a/Marlin/src/core/drivers.h +++ b/Marlin/src/core/drivers.h @@ -30,10 +30,6 @@ #define _A5984 0x5984 #define _DRV8825 0x8825 #define _LV8729 0x8729 -#define _L6470 0x6470 -#define _L6474 0x6474 -#define _L6480 0x6480 -#define _POWERSTEP01 0xF00D #define _TB6560 0x6560 #define _TB6600 0x6600 #define _TMC2100 0x2100 @@ -193,16 +189,3 @@ #if HAS_DRIVER(TMC26X) #define HAS_TMC26X 1 #endif - -// -// L64XX Stepper Drivers -// - -#if HAS_DRIVER(L6470) || HAS_DRIVER(L6474) || HAS_DRIVER(L6480) || HAS_DRIVER(POWERSTEP01) - #define HAS_L64XX 1 -#endif -#if HAS_L64XX && !HAS_DRIVER(L6474) - #define HAS_L64XX_NOT_L6474 1 -#endif - -#define AXIS_IS_L64XX(A) (AXIS_DRIVER_TYPE_##A(L6470) || AXIS_DRIVER_TYPE_##A(L6474) || AXIS_DRIVER_TYPE_##A(L6480) || AXIS_DRIVER_TYPE_##A(POWERSTEP01)) diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index 384fc7210c42..e312bf07b528 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -55,10 +55,6 @@ #include "../../lcd/e3v2/proui/dwin.h" #endif -#if HAS_L64XX // set L6470 absolute position registers to counts - #include "../../libs/L64XX/L64XX_Marlin.h" -#endif - #if ENABLED(LASER_FEATURE) #include "../../feature/spindle_laser.h" #endif @@ -601,20 +597,4 @@ void GcodeSuite::G28() { TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(old_grblstate)); - #if HAS_L64XX - // Set L6470 absolute position registers to counts - // constexpr *might* move this to PROGMEM. - // If not, this will need a PROGMEM directive and an accessor. - #define _EN_ITEM(N) , E_AXIS - static constexpr AxisEnum L64XX_axis_xref[MAX_L64XX] = { - NUM_AXIS_LIST(X_AXIS, Y_AXIS, Z_AXIS, I_AXIS, J_AXIS, K_AXIS, U_AXIS, V_AXIS, W_AXIS), - X_AXIS, Y_AXIS, Z_AXIS, Z_AXIS, Z_AXIS - REPEAT(E_STEPPERS, _EN_ITEM) - }; - #undef _EN_ITEM - for (uint8_t j = 1; j <= L64XX::chain[0]; j++) { - const uint8_t cv = L64XX::chain[j]; - L64xxManager.set_param((L64XX_axis_t)cv, L6470_ABS_POS, stepper.position(L64XX_axis_xref[cv])); - } - #endif } diff --git a/Marlin/src/gcode/feature/L6470/M122.cpp b/Marlin/src/gcode/feature/L6470/M122.cpp deleted file mode 100644 index 4a5629b04920..000000000000 --- a/Marlin/src/gcode/feature/L6470/M122.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include "../../../inc/MarlinConfig.h" - -#if HAS_L64XX - -#include "../../gcode.h" -#include "../../../libs/L64XX/L64XX_Marlin.h" -#include "../../../module/stepper/indirection.h" - -void echo_yes_no(const bool yes); - -inline void L6470_say_status(const L64XX_axis_t axis) { - if (L64xxManager.spi_abort) return; - const L64XX_Marlin::L64XX_shadow_t &sh = L64xxManager.shadow; - L64xxManager.get_status(axis); - L64xxManager.say_axis(axis); - #if ENABLED(L6470_CHITCHAT) - char temp_buf[20]; - sprintf_P(temp_buf, PSTR(" status: %4x "), sh.STATUS_AXIS_RAW); - SERIAL_ECHO(temp_buf); - print_bin(sh.STATUS_AXIS_RAW); - switch (sh.STATUS_AXIS_LAYOUT) { - case L6470_STATUS_LAYOUT: SERIAL_ECHOPGM(" L6470"); break; - case L6474_STATUS_LAYOUT: SERIAL_ECHOPGM(" L6474"); break; - case L6480_STATUS_LAYOUT: SERIAL_ECHOPGM(" L6480/powerSTEP01"); break; - } - #endif - SERIAL_ECHOPGM("\n...OUTPUT: "); - SERIAL_ECHOF(sh.STATUS_AXIS & STATUS_HIZ ? F("OFF") : F("ON ")); - SERIAL_ECHOPGM(" BUSY: "); echo_yes_no((sh.STATUS_AXIS & STATUS_BUSY) == 0); - SERIAL_ECHOPGM(" DIR: "); - SERIAL_ECHOF((((sh.STATUS_AXIS & STATUS_DIR) >> 4) ^ L64xxManager.index_to_dir[axis]) ? F("FORWARD") : F("REVERSE")); - if (sh.STATUS_AXIS_LAYOUT == L6480_STATUS_LAYOUT) { - SERIAL_ECHOPGM(" Last Command: "); - if (sh.STATUS_AXIS & sh.STATUS_AXIS_WRONG_CMD) SERIAL_ECHOPGM("VALID"); - else SERIAL_ECHOPGM("ERROR"); - SERIAL_ECHOPGM("\n...THERMAL: "); - switch ((sh.STATUS_AXIS & (sh.STATUS_AXIS_TH_SD | sh.STATUS_AXIS_TH_WRN)) >> 11) { - case 0: SERIAL_ECHOPGM("DEVICE SHUTDOWN"); break; - case 1: SERIAL_ECHOPGM("BRIDGE SHUTDOWN"); break; - case 2: SERIAL_ECHOPGM("WARNING "); break; - case 3: SERIAL_ECHOPGM("OK "); break; - } - } - else { - SERIAL_ECHOPGM(" Last Command: "); - if (!(sh.STATUS_AXIS & sh.STATUS_AXIS_WRONG_CMD)) SERIAL_ECHOPGM("IN"); - SERIAL_ECHOPGM("VALID "); - SERIAL_ECHOF(sh.STATUS_AXIS & sh.STATUS_AXIS_NOTPERF_CMD ? F("COMPLETED ") : F("Not PERFORMED")); - SERIAL_ECHOPGM("\n...THERMAL: ", !(sh.STATUS_AXIS & sh.STATUS_AXIS_TH_SD) ? "SHUTDOWN " : !(sh.STATUS_AXIS & sh.STATUS_AXIS_TH_WRN) ? "WARNING " : "OK "); - } - SERIAL_ECHOPGM(" OVERCURRENT:"); echo_yes_no((sh.STATUS_AXIS & sh.STATUS_AXIS_OCD) == 0); - if (sh.STATUS_AXIS_LAYOUT != L6474_STATUS_LAYOUT) { - SERIAL_ECHOPGM(" STALL:"); echo_yes_no((sh.STATUS_AXIS & sh.STATUS_AXIS_STEP_LOSS_A) == 0 || (sh.STATUS_AXIS & sh.STATUS_AXIS_STEP_LOSS_B) == 0); - SERIAL_ECHOPGM(" STEP-CLOCK MODE:"); echo_yes_no((sh.STATUS_AXIS & sh.STATUS_AXIS_SCK_MOD) != 0); - } - else { - SERIAL_ECHOPGM(" STALL: NA " - " STEP-CLOCK MODE: NA" - " UNDER VOLTAGE LOCKOUT: "); echo_yes_no((sh.STATUS_AXIS & sh.STATUS_AXIS_UVLO) == 0); - } - SERIAL_EOL(); -} - -/** - * M122: Debug L6470 drivers - */ -void GcodeSuite::M122() { - L64xxManager.pause_monitor(true); // Keep monitor_driver() from stealing status - L64xxManager.spi_active = true; // Tell set_directions() a series of SPI transfers is underway - - //if (parser.seen('S')) - // tmc_set_report_interval(parser.value_bool()); - //else - - #if AXIS_IS_L64XX(X) - L6470_say_status(X); - #endif - #if AXIS_IS_L64XX(X2) - L6470_say_status(X2); - #endif - #if AXIS_IS_L64XX(Y) - L6470_say_status(Y); - #endif - #if AXIS_IS_L64XX(Y2) - L6470_say_status(Y2); - #endif - #if AXIS_IS_L64XX(Z) - L6470_say_status(Z); - #endif - #if AXIS_IS_L64XX(Z2) - L6470_say_status(Z2); - #endif - #if AXIS_IS_L64XX(Z3) - L6470_say_status(Z3); - #endif - #if AXIS_IS_L64XX(Z4) - L6470_say_status(Z4); - #endif - #if AXIS_IS_L64XX(E0) - L6470_say_status(E0); - #endif - #if AXIS_IS_L64XX(E1) - L6470_say_status(E1); - #endif - #if AXIS_IS_L64XX(E2) - L6470_say_status(E2); - #endif - #if AXIS_IS_L64XX(E3) - L6470_say_status(E3); - #endif - #if AXIS_IS_L64XX(E4) - L6470_say_status(E4); - #endif - #if AXIS_IS_L64XX(E5) - L6470_say_status(E5); - #endif - #if AXIS_IS_L64XX(E6) - L6470_say_status(E6); - #endif - #if AXIS_IS_L64XX(E7) - L6470_say_status(E7); - #endif - - L64xxManager.spi_active = false; // done with all SPI transfers - clear handshake flags - L64xxManager.spi_abort = false; - L64xxManager.pause_monitor(false); -} - -#endif // HAS_L64XX diff --git a/Marlin/src/gcode/feature/L6470/M906.cpp b/Marlin/src/gcode/feature/L6470/M906.cpp deleted file mode 100644 index 26c637df279c..000000000000 --- a/Marlin/src/gcode/feature/L6470/M906.cpp +++ /dev/null @@ -1,417 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include "../../../inc/MarlinConfig.h" - -#if HAS_L64XX - -#if AXIS_COLLISION('I') - #error "M906 parameter 'I' collision with axis name." -#endif - -#include "../../gcode.h" -#include "../../../libs/L64XX/L64XX_Marlin.h" -#include "../../../module/stepper/indirection.h" -#include "../../../module/planner.h" - -#define DEBUG_OUT ENABLED(L6470_CHITCHAT) -#include "../../../core/debug_out.h" - -/** - * MACRO to fetch information on the items associated with current limiting - * and maximum voltage output. - * - * L6470 can be setup to shutdown if either current threshold is exceeded. - * - * L6470 output current can not be set directly. It is set indirectly by - * setting the maximum effective output voltage. - * - * Effective output voltage is set by PWM duty cycle. - * - * Maximum effective output voltage is affected by MANY variables. The main ones are: - * KVAL_HOLD - * KVAL_RUN - * KVAL_ACC - * KVAL_DEC - * Vs compensation (if enabled) - */ -void L64XX_report_current(L64XX &motor, const L64XX_axis_t axis) { - - if (L64xxManager.spi_abort) return; // don't do anything if set_directions() has occurred - - const L64XX_Marlin::L64XX_shadow_t &sh = L64xxManager.shadow; - const uint16_t status = L64xxManager.get_status(axis); //also populates shadow structure - const uint8_t OverCurrent_Threshold = uint8_t(motor.GetParam(L6470_OCD_TH)); - - auto say_axis_status = [](const L64XX_axis_t axis, const uint16_t status) { - L64xxManager.say_axis(axis); - #if ENABLED(L6470_CHITCHAT) - char tmp[10]; - sprintf_P(tmp, PSTR("%4x "), status); - DEBUG_ECHOPGM(" status: ", tmp); - print_bin(status); - #else - UNUSED(status); - #endif - SERIAL_EOL(); - }; - - char temp_buf[10]; - - switch (sh.STATUS_AXIS_LAYOUT) { - case L6470_STATUS_LAYOUT: // L6470 - case L6480_STATUS_LAYOUT: { // L6480 & powerstep01 - const uint16_t Stall_Threshold = (uint8_t)motor.GetParam(L6470_STALL_TH), - motor_status = (status & (STATUS_MOT_STATUS)) >> 5, - L6470_ADC_out = motor.GetParam(L6470_ADC_OUT), - L6470_ADC_out_limited = constrain(L6470_ADC_out, 8, 24); - const float comp_coef = 1600.0f / L6470_ADC_out_limited; - const uint16_t MicroSteps = _BV(motor.GetParam(L6470_STEP_MODE) & 0x07); - - say_axis_status(axis, sh.STATUS_AXIS_RAW); - - SERIAL_ECHOPGM("...OverCurrent Threshold: "); - sprintf_P(temp_buf, PSTR("%2d ("), OverCurrent_Threshold); - SERIAL_ECHO(temp_buf); - SERIAL_ECHO((OverCurrent_Threshold + 1) * motor.OCD_CURRENT_CONSTANT_INV); - SERIAL_ECHOPGM(" mA)"); - SERIAL_ECHOPGM(" Stall Threshold: "); - sprintf_P(temp_buf, PSTR("%2d ("), Stall_Threshold); - SERIAL_ECHO(temp_buf); - SERIAL_ECHO((Stall_Threshold + 1) * motor.STALL_CURRENT_CONSTANT_INV); - SERIAL_ECHOPGM(" mA)"); - SERIAL_ECHOPGM(" Motor Status: "); - switch (motor_status) { - case 0: SERIAL_ECHOPGM("stopped"); break; - case 1: SERIAL_ECHOPGM("accelerating"); break; - case 2: SERIAL_ECHOPGM("decelerating"); break; - case 3: SERIAL_ECHOPGM("at constant speed"); break; - } - SERIAL_EOL(); - - SERIAL_ECHOPGM("...MicroSteps: ", MicroSteps, - " ADC_OUT: ", L6470_ADC_out); - SERIAL_ECHOPGM(" Vs_compensation: "); - SERIAL_ECHOF((motor.GetParam(sh.L6470_AXIS_CONFIG) & CONFIG_EN_VSCOMP) ? F("ENABLED ") : F("DISABLED")); - SERIAL_ECHOLNPGM(" Compensation coefficient: ~", comp_coef * 0.01f); - - SERIAL_ECHOPGM("...KVAL_HOLD: ", motor.GetParam(L6470_KVAL_HOLD), - " KVAL_RUN : ", motor.GetParam(L6470_KVAL_RUN), - " KVAL_ACC: ", motor.GetParam(L6470_KVAL_ACC), - " KVAL_DEC: ", motor.GetParam(L6470_KVAL_DEC), - " V motor max = "); - switch (motor_status) { - case 0: SERIAL_ECHO(motor.GetParam(L6470_KVAL_HOLD) * 100 / 256); SERIAL_ECHOPGM("% (KVAL_HOLD)"); break; - case 1: SERIAL_ECHO(motor.GetParam(L6470_KVAL_RUN) * 100 / 256); SERIAL_ECHOPGM("% (KVAL_RUN)"); break; - case 2: SERIAL_ECHO(motor.GetParam(L6470_KVAL_ACC) * 100 / 256); SERIAL_ECHOPGM("% (KVAL_ACC)"); break; - case 3: SERIAL_ECHO(motor.GetParam(L6470_KVAL_DEC) * 100 / 256); SERIAL_ECHOPGM("% (KVAL_HOLD)"); break; - } - SERIAL_EOL(); - - #if ENABLED(L6470_CHITCHAT) - DEBUG_ECHOPGM("...SLEW RATE: "); - switch (sh.STATUS_AXIS_LAYOUT) { - case L6470_STATUS_LAYOUT: { - switch ((motor.GetParam(sh.L6470_AXIS_CONFIG) & CONFIG_POW_SR) >> CONFIG_POW_SR_BIT) { - case 0: { DEBUG_ECHOLNPGM("320V/uS") ; break; } - case 1: { DEBUG_ECHOLNPGM("75V/uS") ; break; } - case 2: { DEBUG_ECHOLNPGM("110V/uS") ; break; } - case 3: { DEBUG_ECHOLNPGM("260V/uS") ; break; } - } - break; - } - case L6480_STATUS_LAYOUT: { - switch (motor.GetParam(L6470_GATECFG1) & CONFIG1_SR ) { - case CONFIG1_SR_220V_us: { DEBUG_ECHOLNPGM("220V/uS") ; break; } - case CONFIG1_SR_400V_us: { DEBUG_ECHOLNPGM("400V/uS") ; break; } - case CONFIG1_SR_520V_us: { DEBUG_ECHOLNPGM("520V/uS") ; break; } - case CONFIG1_SR_980V_us: { DEBUG_ECHOLNPGM("980V/uS") ; break; } - default: { DEBUG_ECHOLNPGM("unknown") ; break; } - } - } - } - #endif - SERIAL_EOL(); - break; - } - - case L6474_STATUS_LAYOUT: { // L6474 - const uint16_t L6470_ADC_out = motor.GetParam(L6470_ADC_OUT) & 0x1F, - L6474_TVAL_val = motor.GetParam(L6474_TVAL) & 0x7F; - - say_axis_status(axis, sh.STATUS_AXIS_RAW); - - SERIAL_ECHOPGM("...OverCurrent Threshold: "); - sprintf_P(temp_buf, PSTR("%2d ("), OverCurrent_Threshold); - SERIAL_ECHO(temp_buf); - SERIAL_ECHO((OverCurrent_Threshold + 1) * motor.OCD_CURRENT_CONSTANT_INV); - SERIAL_ECHOPGM(" mA)"); - SERIAL_ECHOPGM(" TVAL: "); - sprintf_P(temp_buf, PSTR("%2d ("), L6474_TVAL_val); - SERIAL_ECHO(temp_buf); - SERIAL_ECHO((L6474_TVAL_val + 1) * motor.STALL_CURRENT_CONSTANT_INV); - SERIAL_ECHOLNPGM(" mA) Motor Status: NA"); - - const uint16_t MicroSteps = _BV(motor.GetParam(L6470_STEP_MODE) & 0x07); //NOMORE(MicroSteps, 16); - SERIAL_ECHOPGM("...MicroSteps: ", MicroSteps, - " ADC_OUT: ", L6470_ADC_out); - - SERIAL_ECHOLNPGM(" Vs_compensation: NA\n"); - SERIAL_ECHOLNPGM("...KVAL_HOLD: NA" - " KVAL_RUN : NA" - " KVAL_ACC: NA" - " KVAL_DEC: NA" - " V motor max = NA"); - - #if ENABLED(L6470_CHITCHAT) - DEBUG_ECHOPGM("...SLEW RATE: "); - switch ((motor.GetParam(sh.L6470_AXIS_CONFIG) & CONFIG_POW_SR) >> CONFIG_POW_SR_BIT) { - case 0: DEBUG_ECHOLNPGM("320V/uS") ; break; - case 1: DEBUG_ECHOLNPGM("75V/uS") ; break; - case 2: DEBUG_ECHOLNPGM("110V/uS") ; break; - case 3: DEBUG_ECHOLNPGM("260V/uS") ; break; - default: DEBUG_ECHOLNPGM("slew rate: ", (motor.GetParam(sh.L6470_AXIS_CONFIG) & CONFIG_POW_SR) >> CONFIG_POW_SR_BIT); break; - } - #endif - SERIAL_EOL(); - SERIAL_EOL(); - break; - } - } -} - -/** - * M906: report or set KVAL_HOLD which sets the maximum effective voltage provided by the - * PWMs to the steppers - * - * On L6474 this sets the TVAL register (same address). - * - * I - select which driver(s) to change on multi-driver axis - * (default) all drivers on the axis - * 0 - monitor only the first XYZ... driver - * 1 - monitor only X2, Y2, Z2 - * 2 - monitor only Z3 - * 3 - monitor only Z4 - * Xxxx, Yxxx, Zxxx, Axxx, Bxxx, Cxxx, Uxxx, Vxxx, Wxxx, Exxx - axis to change (optional) - * L6474 - current in mA (4A max) - * All others - 0-255 - * - * Sets KVAL_HOLD which affects the current being driven through the stepper. - * - * L6470 is used in the STEP-CLOCK mode. KVAL_HOLD is the only KVAL_xxx - * that affects the effective voltage seen by the stepper. - */ -void GcodeSuite::M906() { - - L64xxManager.pause_monitor(true); // Keep monitor_driver() from stealing status - - #define L6470_SET_KVAL_HOLD(Q) (AXIS_IS_L64XX(Q) ? stepper##Q.setTVALCurrent(value) : stepper##Q.SetParam(L6470_KVAL_HOLD, uint8_t(value))) - - DEBUG_ECHOLNPGM("M906"); - - uint8_t report_current = true; - - #if AXIS_IS_L64XX(X2) || AXIS_IS_L64XX(Y2) || AXIS_IS_L64XX(Z2) || AXIS_IS_L64XX(Z3) || AXIS_IS_L64XX(Z4) - const int8_t index = parser.byteval('I', -1); - #else - constexpr int8_t index = -1; - #endif - - LOOP_LOGICAL_AXES(i) if (uint16_t value = parser.intval(AXIS_CHAR(i))) { - - report_current = false; - - if (planner.has_blocks_queued() || planner.cleaning_buffer_counter) { - SERIAL_ECHOLNPGM("Test aborted. Can't set KVAL_HOLD while steppers are moving."); - return; - } - - switch (i) { - #if AXIS_IS_L64XX(X) || AXIS_IS_L64XX(X2) - case X_AXIS: - #if AXIS_IS_L64XX(X) - if (index < 0 || index == 0) L6470_SET_KVAL_HOLD(X); - #endif - #if AXIS_IS_L64XX(X2) - if (index < 0 || index == 1) L6470_SET_KVAL_HOLD(X2); - #endif - break; - #endif - - #if AXIS_IS_L64XX(Y) || AXIS_IS_L64XX(Y2) - case Y_AXIS: - #if AXIS_IS_L64XX(Y) - if (index < 0 || index == 0) L6470_SET_KVAL_HOLD(Y); - #endif - #if AXIS_IS_L64XX(Y2) - if (index < 0 || index == 1) L6470_SET_KVAL_HOLD(Y2); - #endif - break; - #endif - - #if AXIS_IS_L64XX(Z) || AXIS_IS_L64XX(Z2) || AXIS_IS_L64XX(Z3) || AXIS_IS_L64XX(Z4) - case Z_AXIS: - #if AXIS_IS_L64XX(Z) - if (index < 0 || index == 0) L6470_SET_KVAL_HOLD(Z); - #endif - #if AXIS_IS_L64XX(Z2) - if (index < 0 || index == 1) L6470_SET_KVAL_HOLD(Z2); - #endif - #if AXIS_IS_L64XX(Z3) - if (index < 0 || index == 2) L6470_SET_KVAL_HOLD(Z3); - #endif - #if AXIS_IS_L64XX(Z4) - if (index < 0 || index == 3) L6470_SET_KVAL_HOLD(Z4); - #endif - break; - #endif - - #if AXIS_IS_L64XX(I) - case I_AXIS: L6470_SET_KVAL_HOLD(I); break; - #endif - #if AXIS_IS_L64XX(J) - case J_AXIS: L6470_SET_KVAL_HOLD(J); break; - #endif - #if AXIS_IS_L64XX(K) - case K_AXIS: L6470_SET_KVAL_HOLD(K); break; - #endif - #if AXIS_IS_L64XX(U) - case U_AXIS: L6470_SET_KVAL_HOLD(U); break; - #endif - #if AXIS_IS_L64XX(V) - case V_AXIS: L6470_SET_KVAL_HOLD(V); break; - #endif - #if AXIS_IS_L64XX(W) - case W_AXIS: L6470_SET_KVAL_HOLD(W); break; - #endif - - #if AXIS_IS_L64XX(E0) || AXIS_IS_L64XX(E1) || AXIS_IS_L64XX(E2) || AXIS_IS_L64XX(E3) || AXIS_IS_L64XX(E4) || AXIS_IS_L64XX(E5) || AXIS_IS_L64XX(E6) || AXIS_IS_L64XX(E7) - case E_AXIS: { - const int8_t eindex = get_target_e_stepper_from_command(-2); - #if AXIS_IS_L64XX(E0) - if (eindex < 0 || eindex == 0) L6470_SET_KVAL_HOLD(E0); - #endif - #if AXIS_IS_L64XX(E1) - if (eindex < 0 || eindex == 1) L6470_SET_KVAL_HOLD(E1); - #endif - #if AXIS_IS_L64XX(E2) - if (eindex < 0 || eindex == 2) L6470_SET_KVAL_HOLD(E2); - #endif - #if AXIS_IS_L64XX(E3) - if (eindex < 0 || eindex == 3) L6470_SET_KVAL_HOLD(E3); - #endif - #if AXIS_IS_L64XX(E4) - if (eindex < 0 || eindex == 4) L6470_SET_KVAL_HOLD(E4); - #endif - #if AXIS_IS_L64XX(E5) - if (eindex < 0 || eindex == 5) L6470_SET_KVAL_HOLD(E5); - #endif - #if AXIS_IS_L64XX(E6) - if (eindex < 0 || eindex == 6) L6470_SET_KVAL_HOLD(E6); - #endif - #if AXIS_IS_L64XX(E7) - if (eindex < 0 || eindex == 7) L6470_SET_KVAL_HOLD(E7); - #endif - } break; - #endif - } - } - - if (report_current) { - #define L64XX_REPORT_CURRENT(Q) L64XX_report_current(stepper##Q, Q) - - L64xxManager.spi_active = true; // Tell set_directions() a series of SPI transfers is underway - - #if AXIS_IS_L64XX(X) - L64XX_REPORT_CURRENT(X); - #endif - #if AXIS_IS_L64XX(X2) - L64XX_REPORT_CURRENT(X2); - #endif - #if AXIS_IS_L64XX(Y) - L64XX_REPORT_CURRENT(Y); - #endif - #if AXIS_IS_L64XX(Y2) - L64XX_REPORT_CURRENT(Y2); - #endif - #if AXIS_IS_L64XX(Z) - L64XX_REPORT_CURRENT(Z); - #endif - #if AXIS_IS_L64XX(Z2) - L64XX_REPORT_CURRENT(Z2); - #endif - #if AXIS_IS_L64XX(Z3) - L64XX_REPORT_CURRENT(Z3); - #endif - #if AXIS_IS_L64XX(Z4) - L64XX_REPORT_CURRENT(Z4); - #endif - #if AXIS_IS_L64XX(I) - L64XX_REPORT_CURRENT(I); - #endif - #if AXIS_IS_L64XX(J) - L64XX_REPORT_CURRENT(J); - #endif - #if AXIS_IS_L64XX(K) - L64XX_REPORT_CURRENT(K); - #endif - #if AXIS_IS_L64XX(U) - L64XX_REPORT_CURRENT(U); - #endif - #if AXIS_IS_L64XX(V) - L64XX_REPORT_CURRENT(V); - #endif - #if AXIS_IS_L64XX(W) - L64XX_REPORT_CURRENT(W); - #endif - #if AXIS_IS_L64XX(E0) - L64XX_REPORT_CURRENT(E0); - #endif - #if AXIS_IS_L64XX(E1) - L64XX_REPORT_CURRENT(E1); - #endif - #if AXIS_IS_L64XX(E2) - L64XX_REPORT_CURRENT(E2); - #endif - #if AXIS_IS_L64XX(E3) - L64XX_REPORT_CURRENT(E3); - #endif - #if AXIS_IS_L64XX(E4) - L64XX_REPORT_CURRENT(E4); - #endif - #if AXIS_IS_L64XX(E5) - L64XX_REPORT_CURRENT(E5); - #endif - #if AXIS_IS_L64XX(E6) - L64XX_REPORT_CURRENT(E6); - #endif - #if AXIS_IS_L64XX(E7) - L64XX_REPORT_CURRENT(E7); - #endif - - L64xxManager.spi_active = false; // done with all SPI transfers - clear handshake flags - L64xxManager.spi_abort = false; - L64xxManager.pause_monitor(false); - } -} - -#endif // HAS_L64XX diff --git a/Marlin/src/gcode/feature/L6470/M916-M918.cpp b/Marlin/src/gcode/feature/L6470/M916-M918.cpp deleted file mode 100644 index 9e1f1b98da34..000000000000 --- a/Marlin/src/gcode/feature/L6470/M916-M918.cpp +++ /dev/null @@ -1,650 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -// -// NOTE: All tests assume each axis uses matching driver chips. -// - -#include "../../../inc/MarlinConfig.h" - -#if HAS_L64XX - -#include "../../gcode.h" -#include "../../../module/stepper/indirection.h" -#include "../../../module/planner.h" -#include "../../../libs/L64XX/L64XX_Marlin.h" - -#define DEBUG_OUT ENABLED(L6470_CHITCHAT) -#include "../../../core/debug_out.h" - -/** - * M916: increase KVAL_HOLD until get thermal warning - * NOTE - on L6474 it is TVAL that is used - * - * J - select which driver(s) to monitor on multi-driver axis - * 0 - (default) monitor all drivers on the axis or E0 - * 1 - monitor only X, Y, Z, E1 - * 2 - monitor only X2, Y2, Z2, E2 - * 3 - monitor only Z3, E3 - * 4 - monitor only Z4, E4 - * - * Xxxx, Yxxx, Zxxx, Exxx - axis to be monitored with displacement - * xxx (1-255) is distance moved on either side of current position - * - * F - feedrate - * optional - will use default max feedrate from configuration.h if not specified - * - * T - current (mA) setting for TVAL (0 - 4A in 31.25mA increments, rounds down) - L6474 only - * optional - will report current value from driver if not specified - * - * K - value for KVAL_HOLD (0 - 255) (ignored for L6474) - * optional - will report current value from driver if not specified - * - * D - time (in seconds) to run each setting of KVAL_HOLD/TVAL - * optional - defaults to zero (runs each setting once) - */ - -/** - * This routine is also useful for determining the approximate KVAL_HOLD - * where the stepper stops losing steps. The sound will get noticeably quieter - * as it stops losing steps. - */ - -void GcodeSuite::M916() { - - DEBUG_ECHOLNPGM("M916"); - - L64xxManager.pause_monitor(true); // Keep monitor_driver() from stealing status - - // Variables used by L64xxManager.get_user_input function - some may not be used - char axis_mon[3][3] = { {" "}, {" "}, {" "} }; // list of Axes to be monitored - L64XX_axis_t axis_index[3]; - uint16_t axis_status[3]; - uint8_t driver_count = 1; - float position_max; - float position_min; - float final_feedrate; - uint8_t kval_hold; - uint8_t OCD_TH_val = 0; - uint8_t STALL_TH_val = 0; - uint16_t over_current_threshold; - constexpr uint8_t over_current_flag = false; // M916 doesn't play with the overcurrent thresholds - - #define DRIVER_TYPE_L6474(Q) AXIS_DRIVER_TYPE_##Q(L6474) - - uint8_t j; // general purpose counter - - if (L64xxManager.get_user_input(driver_count, axis_index, axis_mon, position_max, position_min, final_feedrate, kval_hold, over_current_flag, OCD_TH_val, STALL_TH_val, over_current_threshold)) - return; // quit if invalid user input - - DEBUG_ECHOLNPGM("feedrate = ", final_feedrate); - - planner.synchronize(); // wait for all current movement commands to complete - - const L64XX_Marlin::L64XX_shadow_t &sh = L64xxManager.shadow; - for (j = 0; j < driver_count; j++) - L64xxManager.get_status(axis_index[j]); // clear out any pre-existing error flags - - char temp_axis_string[] = " "; - temp_axis_string[0] = axis_mon[0][0]; // need to have a string for use within sprintf format section - char gcode_string[80]; - uint16_t status_composite = 0; - - uint16_t M91x_counter = kval_hold; - uint16_t M91x_counter_max; - if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) { - M91x_counter_max = 128; // TVAL is 7 bits - LIMIT(M91x_counter, 0U, 127U); - } - else - M91x_counter_max = 256; // KVAL_HOLD is 8 bits - - uint8_t M91x_delay_s = parser.byteval('D'); // get delay in seconds - millis_t M91x_delay_ms = SEC_TO_MS(M91x_delay_s * 60); - millis_t M91x_delay_end; - - DEBUG_ECHOLNPGM(".\n."); - - do { - - if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) - DEBUG_ECHOLNPGM("TVAL current (mA) = ", (M91x_counter + 1) * sh.AXIS_STALL_CURRENT_CONSTANT_INV); // report TVAL current for this run - else - DEBUG_ECHOLNPGM("kval_hold = ", M91x_counter); // report KVAL_HOLD for this run - - for (j = 0; j < driver_count; j++) - L64xxManager.set_param(axis_index[j], L6470_KVAL_HOLD, M91x_counter); //set KVAL_HOLD or TVAL (same register address) - - M91x_delay_end = millis() + M91x_delay_ms; - do { - // turn the motor(s) both directions - sprintf_P(gcode_string, PSTR("G0 %s%03d F%03d"), temp_axis_string, uint16_t(position_min), uint16_t(final_feedrate)); - process_subcommands_now(gcode_string); - - sprintf_P(gcode_string, PSTR("G0 %s%03d F%03d"), temp_axis_string, uint16_t(position_max), uint16_t(final_feedrate)); - process_subcommands_now(gcode_string); - - // get the status after the motors have stopped - planner.synchronize(); - - status_composite = 0; // clear out the old bits - - for (j = 0; j < driver_count; j++) { - axis_status[j] = (~L64xxManager.get_status(axis_index[j])) & sh.L6470_ERROR_MASK; // bits of interest are all active low - status_composite |= axis_status[j] ; - } - - if (status_composite) break; - } while (millis() < M91x_delay_end); - - if (status_composite) break; - - M91x_counter++; - - } while (!(status_composite & (sh.STATUS_AXIS_TH_WRN | sh.STATUS_AXIS_TH_SD)) && (M91x_counter < M91x_counter_max)); - - DEBUG_ECHOLNPGM("."); - - #if ENABLED(L6470_CHITCHAT) - if (status_composite) { - L64xxManager.error_status_decode(status_composite, axis_index[0], - sh.STATUS_AXIS_TH_SD, sh.STATUS_AXIS_TH_WRN, - sh.STATUS_AXIS_STEP_LOSS_A, sh.STATUS_AXIS_STEP_LOSS_B, - sh.STATUS_AXIS_OCD, sh.STATUS_AXIS_LAYOUT); - DEBUG_ECHOLNPGM("."); - } - #endif - - if ((status_composite & (sh.STATUS_AXIS_TH_WRN | sh.STATUS_AXIS_TH_SD))) - DEBUG_ECHOLNPGM(".\n.\nTest completed normally - Thermal warning/shutdown has occurred"); - else if (status_composite) - DEBUG_ECHOLNPGM(".\n.\nTest completed abnormally - non-thermal error has occurred"); - else - DEBUG_ECHOLNPGM(".\n.\nTest completed normally - Unable to get to thermal warning/shutdown"); - - L64xxManager.pause_monitor(false); -} - -/** - * M917: Find minimum current thresholds - * - * Decrease OCD current until overcurrent error - * Increase OCD until overcurrent error goes away - * Decrease stall threshold until stall (not done on L6474) - * Increase stall until stall error goes away (not done on L6474) - * - * J - select which driver(s) to monitor on multi-driver axis - * 0 - (default) monitor all drivers on the axis or E0 - * 1 - monitor only X, Y, Z, E1 - * 2 - monitor only X2, Y2, Z2, E2 - * Xxxx, Yxxx, Zxxx, Exxx - axis to be monitored with displacement - * xxx (1-255) is distance moved on either side of current position - * - * F - feedrate - * optional - will use default max feedrate from Configuration.h if not specified - * - * I - starting over-current threshold - * optional - will report current value from driver if not specified - * if there are multiple drivers on the axis then all will be set the same - * - * T - current (mA) setting for TVAL (0 - 4A in 31.25mA increments, rounds down) - L6474 only - * optional - will report current value from driver if not specified - * - * K - value for KVAL_HOLD (0 - 255) (ignored for L6474) - * optional - will report current value from driver if not specified - */ -void GcodeSuite::M917() { - - DEBUG_ECHOLNPGM("M917"); - - L64xxManager.pause_monitor(true); // Keep monitor_driver() from stealing status - - char axis_mon[3][3] = { {" "}, {" "}, {" "} }; // list of Axes to be monitored - L64XX_axis_t axis_index[3]; - uint16_t axis_status[3]; - uint8_t driver_count = 1; - float position_max; - float position_min; - float final_feedrate; - uint8_t kval_hold; - uint8_t OCD_TH_val = 0; - uint8_t STALL_TH_val = 0; - uint16_t over_current_threshold; - constexpr uint8_t over_current_flag = true; - - uint8_t j; // general purpose counter - - if (L64xxManager.get_user_input(driver_count, axis_index, axis_mon, position_max, position_min, final_feedrate, kval_hold, over_current_flag, OCD_TH_val, STALL_TH_val, over_current_threshold)) - return; // quit if invalid user input - - DEBUG_ECHOLNPGM("feedrate = ", final_feedrate); - - planner.synchronize(); // wait for all current movement commands to complete - - const L64XX_Marlin::L64XX_shadow_t &sh = L64xxManager.shadow; - for (j = 0; j < driver_count; j++) - L64xxManager.get_status(axis_index[j]); // clear error flags - char temp_axis_string[] = " "; - temp_axis_string[0] = axis_mon[0][0]; // need a sprintf format string - char gcode_string[80]; - uint16_t status_composite = 0; - uint8_t test_phase = 0; // 0 - decreasing OCD - exit when OCD warning occurs (ignore STALL) - // 1 - increasing OCD - exit when OCD warning stops (ignore STALL) - // 2 - OCD finalized - decreasing STALL - exit when STALL warning happens - // 3 - OCD finalized - increasing STALL - exit when STALL warning stop - // 4 - all testing completed - DEBUG_ECHOPGM(".\n.\n.\nover_current threshold : ", (OCD_TH_val + 1) * 375); // first status display - DEBUG_ECHOPGM(" (OCD_TH: : ", OCD_TH_val); - if (sh.STATUS_AXIS_LAYOUT != L6474_STATUS_LAYOUT) { - DEBUG_ECHOPGM(") Stall threshold: ", (STALL_TH_val + 1) * 31.25); - DEBUG_ECHOPGM(" (STALL_TH: ", STALL_TH_val); - } - DEBUG_ECHOLNPGM(")"); - - do { - - if (sh.STATUS_AXIS_LAYOUT != L6474_STATUS_LAYOUT) DEBUG_ECHOPGM("STALL threshold : ", (STALL_TH_val + 1) * 31.25); - DEBUG_ECHOLNPGM(" OCD threshold : ", (OCD_TH_val + 1) * 375); - - sprintf_P(gcode_string, PSTR("G0 %s%03d F%03d"), temp_axis_string, uint16_t(position_min), uint16_t(final_feedrate)); - process_subcommands_now(gcode_string); - - sprintf_P(gcode_string, PSTR("G0 %s%03d F%03d"), temp_axis_string, uint16_t(position_max), uint16_t(final_feedrate)); - process_subcommands_now(gcode_string); - - planner.synchronize(); - - status_composite = 0; // clear out the old bits - - for (j = 0; j < driver_count; j++) { - axis_status[j] = (~L64xxManager.get_status(axis_index[j])) & sh.L6470_ERROR_MASK; // bits of interest are all active low - status_composite |= axis_status[j]; - } - - if (status_composite && (status_composite & sh.STATUS_AXIS_UVLO)) { - DEBUG_ECHOLNPGM("Test aborted (Undervoltage lockout active)"); - #if ENABLED(L6470_CHITCHAT) - for (j = 0; j < driver_count; j++) { - if (j) DEBUG_ECHOPGM("..."); - L64xxManager.error_status_decode(axis_status[j], axis_index[j], - sh.STATUS_AXIS_TH_SD, sh.STATUS_AXIS_TH_WRN, - sh.STATUS_AXIS_STEP_LOSS_A, sh.STATUS_AXIS_STEP_LOSS_B, - sh.STATUS_AXIS_OCD, sh.STATUS_AXIS_LAYOUT); - } - #endif - return; - } - - if (status_composite & (sh.STATUS_AXIS_TH_WRN | sh.STATUS_AXIS_TH_SD)) { - DEBUG_ECHOLNPGM("thermal problem - waiting for chip(s) to cool down "); - uint16_t status_composite_temp = 0; - uint8_t k = 0; - do { - k++; - if (!(k % 4)) { - kval_hold *= 0.95; - DEBUG_EOL(); - DEBUG_ECHOLNPGM("Lowering KVAL_HOLD by about 5% to ", kval_hold); - for (j = 0; j < driver_count; j++) - L64xxManager.set_param(axis_index[j], L6470_KVAL_HOLD, kval_hold); - } - DEBUG_ECHOLNPGM("."); - reset_stepper_timeout(); // keep steppers powered - safe_delay(5000); - status_composite_temp = 0; - for (j = 0; j < driver_count; j++) { - axis_status[j] = (~L64xxManager.get_status(axis_index[j])) & sh.L6470_ERROR_MASK; // bits of interest are all active low - status_composite_temp |= axis_status[j]; - } - } - while (status_composite_temp & (sh.STATUS_AXIS_TH_WRN | sh.STATUS_AXIS_TH_SD)); - DEBUG_EOL(); - } - if (status_composite & (sh.STATUS_AXIS_STEP_LOSS_A | sh.STATUS_AXIS_STEP_LOSS_B | sh.STATUS_AXIS_OCD)) { - switch (test_phase) { - - case 0: { - if (status_composite & sh.STATUS_AXIS_OCD) { - // phase 0 with OCD warning - time to go to next phase - if (OCD_TH_val >= sh.AXIS_OCD_TH_MAX) { - OCD_TH_val = sh.AXIS_OCD_TH_MAX; // limit to max - test_phase = 2; // at highest value so skip phase 1 - //DEBUG_ECHOLNPGM("LOGIC E0A OCD at highest - skip to 2"); - DEBUG_ECHOLNPGM("OCD at highest - OCD finalized"); - } - else { - OCD_TH_val++; // normal exit to next phase - test_phase = 1; // setup for first pass of phase 1 - //DEBUG_ECHOLNPGM("LOGIC E0B - inc OCD & go to 1"); - DEBUG_ECHOLNPGM("inc OCD"); - } - } - else { // phase 0 without OCD warning - keep on decrementing if can - if (OCD_TH_val) { - OCD_TH_val--; // try lower value - //DEBUG_ECHOLNPGM("LOGIC E0C - dec OCD"); - DEBUG_ECHOLNPGM("dec OCD"); - } - else { - test_phase = 2; // at lowest value without warning so skip phase 1 - //DEBUG_ECHOLNPGM("LOGIC E0D - OCD at latest - go to 2"); - DEBUG_ECHOLNPGM("OCD finalized"); - } - } - } break; - - case 1: { - if (status_composite & sh.STATUS_AXIS_OCD) { - // phase 1 with OCD warning - increment if can - if (OCD_TH_val >= sh.AXIS_OCD_TH_MAX) { - OCD_TH_val = sh.AXIS_OCD_TH_MAX; // limit to max - test_phase = 2; // at highest value so go to next phase - //DEBUG_ECHOLNPGM("LOGIC E1A - OCD at max - go to 2"); - DEBUG_ECHOLNPGM("OCD finalized"); - } - else { - OCD_TH_val++; // try a higher value - //DEBUG_ECHOLNPGM("LOGIC E1B - inc OCD"); - DEBUG_ECHOLNPGM("inc OCD"); - } - } - else { // phase 1 without OCD warning - normal exit to phase 2 - test_phase = 2; - //DEBUG_ECHOLNPGM("LOGIC E1C - no OCD warning - go to 1"); - DEBUG_ECHOLNPGM("OCD finalized"); - } - } break; - - case 2: { - if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) { // skip all STALL_TH steps if L6474 - test_phase = 4; - break; - } - if (status_composite & (sh.STATUS_AXIS_STEP_LOSS_A | sh.STATUS_AXIS_STEP_LOSS_B)) { - // phase 2 with stall warning - time to go to next phase - if (STALL_TH_val >= 127) { - STALL_TH_val = 127; // limit to max - //DEBUG_ECHOLNPGM("LOGIC E2A - STALL warning, STALL at max, quit"); - DEBUG_ECHOLNPGM("finished - STALL at maximum value but still have stall warning"); - test_phase = 4; - } - else { - test_phase = 3; // normal exit to next phase (found failing value of STALL) - STALL_TH_val++; // setup for first pass of phase 3 - //DEBUG_ECHOLNPGM("LOGIC E2B - INC - STALL warning, inc Stall, go to 3"); - DEBUG_ECHOLNPGM("inc Stall"); - } - } - else { // phase 2 without stall warning - decrement if can - if (STALL_TH_val) { - STALL_TH_val--; // try a lower value - //DEBUG_ECHOLNPGM("LOGIC E2C - no STALL, dec STALL"); - DEBUG_ECHOLNPGM("dec STALL"); - } - else { - DEBUG_ECHOLNPGM("finished - STALL at lowest value but still do NOT have stall warning"); - test_phase = 4; - //DEBUG_ECHOLNPGM("LOGIC E2D - no STALL, at lowest so quit"); - } - } - } break; - - case 3: { - if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) { // skip all STALL_TH steps if L6474 - test_phase = 4; - break; - } - if (status_composite & (sh.STATUS_AXIS_STEP_LOSS_A | sh.STATUS_AXIS_STEP_LOSS_B)) { - // phase 3 with stall warning - increment if can - if (STALL_TH_val >= 127) { - STALL_TH_val = 127; // limit to max - DEBUG_ECHOLNPGM("finished - STALL at maximum value but still have stall warning"); - test_phase = 4; - //DEBUG_ECHOLNPGM("LOGIC E3A - STALL, at max so quit"); - } - else { - STALL_TH_val++; // still looking for passing value - //DEBUG_ECHOLNPGM("LOGIC E3B - STALL, inc stall"); - DEBUG_ECHOLNPGM("inc stall"); - } - } - else { //phase 3 without stall warning but have OCD warning - DEBUG_ECHOLNPGM("Hardware problem - OCD warning without STALL warning"); - test_phase = 4; - //DEBUG_ECHOLNPGM("LOGIC E3C - not STALLED, hardware problem (quit)"); - } - } break; - - } - - } - else { - switch (test_phase) { - case 0: { // phase 0 without OCD warning - keep on decrementing if can - if (OCD_TH_val) { - OCD_TH_val--; // try lower value - //DEBUG_ECHOLNPGM("LOGIC N0A - DEC OCD"); - DEBUG_ECHOLNPGM("DEC OCD"); - } - else { - test_phase = 2; // at lowest value without warning so skip phase 1 - //DEBUG_ECHOLNPGM("LOGIC N0B - OCD at lowest (go to phase 2)"); - DEBUG_ECHOLNPGM("OCD finalized"); - } - } break; - - case 1: //DEBUG_ECHOLNPGM("LOGIC N1 (go directly to 2)"); // phase 1 without OCD warning - drop directly to phase 2 - DEBUG_ECHOLNPGM("OCD finalized"); - - case 2: { // phase 2 without stall warning - keep on decrementing if can - if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) { // skip all STALL_TH steps if L6474 - test_phase = 4; - break; - } - if (STALL_TH_val) { - STALL_TH_val--; // try a lower value (stay in phase 2) - //DEBUG_ECHOLNPGM("LOGIC N2B - dec STALL"); - DEBUG_ECHOLNPGM("dec STALL"); - } - else { - DEBUG_ECHOLNPGM("finished - STALL at lowest value but still no stall warning"); - test_phase = 4; - //DEBUG_ECHOLNPGM("LOGIC N2C - STALL at lowest (quit)"); - } - } break; - - case 3: { - if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) { // skip all STALL_TH steps if L6474 - test_phase = 4; - break; - } - test_phase = 4; - //DEBUG_ECHOLNPGM("LOGIC N3 - finished!"); - DEBUG_ECHOLNPGM("finished!"); - } break; // phase 3 without any warnings - desired exit - } // - } // end of status checks - - if (test_phase != 4) { - for (j = 0; j < driver_count; j++) { // update threshold(s) - L64xxManager.set_param(axis_index[j], L6470_OCD_TH, OCD_TH_val); - if (sh.STATUS_AXIS_LAYOUT != L6474_STATUS_LAYOUT) L64xxManager.set_param(axis_index[j], L6470_STALL_TH, STALL_TH_val); - if (L64xxManager.get_param(axis_index[j], L6470_OCD_TH) != OCD_TH_val) DEBUG_ECHOLNPGM("OCD mismatch"); - if ((L64xxManager.get_param(axis_index[j], L6470_STALL_TH) != STALL_TH_val) && (sh.STATUS_AXIS_LAYOUT != L6474_STATUS_LAYOUT)) DEBUG_ECHOLNPGM("STALL mismatch"); - } - } - - } while (test_phase != 4); - - DEBUG_ECHOLNPGM("."); - if (status_composite) { - #if ENABLED(L6470_CHITCHAT) - for (j = 0; j < driver_count; j++) { - if (j) DEBUG_ECHOPGM("..."); - L64xxManager.error_status_decode(axis_status[j], axis_index[j], - sh.STATUS_AXIS_TH_SD, sh.STATUS_AXIS_TH_WRN, - sh.STATUS_AXIS_STEP_LOSS_A, sh.STATUS_AXIS_STEP_LOSS_B, - sh.STATUS_AXIS_OCD, sh.STATUS_AXIS_LAYOUT); - } - DEBUG_ECHOLNPGM("."); - #endif - DEBUG_ECHOLNPGM("Completed with errors"); - } - else - DEBUG_ECHOLNPGM("Completed with no errors"); - DEBUG_ECHOLNPGM("."); - - L64xxManager.pause_monitor(false); -} - -/** - * M918: increase speed until error or max feedrate achieved (as shown in configuration.h)) - * - * J - select which driver(s) to monitor on multi-driver axis - * 0 - (default) monitor all drivers on the axis or E0 - * 1 - monitor only X, Y, Z, E1 - * 2 - monitor only X2, Y2, Z2, E2 - * Xxxx, Yxxx, Zxxx, Exxx - axis to be monitored with displacement - * xxx (1-255) is distance moved on either side of current position - * - * I - over current threshold - * optional - will report current value from driver if not specified - * - * T - current (mA) setting for TVAL (0 - 4A in 31.25mA increments, rounds down) - L6474 only - * optional - will report current value from driver if not specified - * - * K - value for KVAL_HOLD (0 - 255) (ignored for L6474) - * optional - will report current value from driver if not specified - * - * M - value for microsteps (1 - 128) (optional) - * optional - will report current value from driver if not specified - */ -void GcodeSuite::M918() { - - DEBUG_ECHOLNPGM("M918"); - - L64xxManager.pause_monitor(true); // Keep monitor_driver() from stealing status - - char axis_mon[3][3] = { {" "}, {" "}, {" "} }; // list of Axes to be monitored - L64XX_axis_t axis_index[3]; - uint16_t axis_status[3]; - uint8_t driver_count = 1; - float position_max, position_min; - float final_feedrate; - uint8_t kval_hold; - uint8_t OCD_TH_val = 0; - uint8_t STALL_TH_val = 0; - uint16_t over_current_threshold; - constexpr uint8_t over_current_flag = true; - - const L64XX_Marlin::L64XX_shadow_t &sh = L64xxManager.shadow; - - uint8_t j; // general purpose counter - - if (L64xxManager.get_user_input(driver_count, axis_index, axis_mon, position_max, position_min, final_feedrate, kval_hold, over_current_flag, OCD_TH_val, STALL_TH_val, over_current_threshold)) - return; // quit if invalid user input - - L64xxManager.get_status(axis_index[0]); // populate shadow array - - uint8_t m_steps = parser.byteval('M'); - - if (m_steps != 0) { - LIMIT(m_steps, 1, sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT ? 16 : 128); // L6474 - - uint8_t stepVal; - for (stepVal = 0; stepVal < 8; stepVal++) { // convert to L64xx register value - if (m_steps == 1) break; - m_steps >>= 1; - } - - if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) - stepVal |= 0x98; // NO SYNC - else - stepVal |= (!SYNC_EN) | SYNC_SEL_1 | stepVal; - - for (j = 0; j < driver_count; j++) { - L64xxManager.set_param(axis_index[j], dSPIN_HARD_HIZ, 0); // can't write STEP register if stepper being powered - // results in an extra NOOP being sent (data 00) - L64xxManager.set_param(axis_index[j], L6470_STEP_MODE, stepVal); // set microsteps - } - } - m_steps = L64xxManager.get_param(axis_index[0], L6470_STEP_MODE) & 0x07; // get microsteps - - DEBUG_ECHOLNPGM("Microsteps = ", _BV(m_steps)); - DEBUG_ECHOLNPGM("target (maximum) feedrate = ", final_feedrate); - - const float feedrate_inc = final_feedrate / 10, // Start at 1/10 of max & go up by 1/10 per step - fr_limit = final_feedrate * 0.99f; // Rounding-safe comparison value - float current_feedrate = 0; - - planner.synchronize(); // Wait for moves to complete - - for (j = 0; j < driver_count; j++) - L64xxManager.get_status(axis_index[j]); // Clear error flags - - char temp_axis_string[2] = " "; - temp_axis_string[0] = axis_mon[0][0]; // Need a sprintf format string - //temp_axis_string[1] = '\n'; - - char gcode_string[80]; - uint16_t status_composite = 0; - DEBUG_ECHOLNPGM(".\n.\n."); // Make feedrate outputs easier to read - - do { - current_feedrate += feedrate_inc; - DEBUG_ECHOLNPGM("...feedrate = ", current_feedrate); - - sprintf_P(gcode_string, PSTR("G0 %s%03d F%03d"), temp_axis_string, uint16_t(position_min), uint16_t(current_feedrate)); - process_subcommands_now(gcode_string); - - sprintf_P(gcode_string, PSTR("G0 %s%03d F%03d"), temp_axis_string, uint16_t(position_max), uint16_t(current_feedrate)); - process_subcommands_now(gcode_string); - - planner.synchronize(); - - for (j = 0; j < driver_count; j++) { - axis_status[j] = (~L64xxManager.get_status(axis_index[j])) & 0x0800; // Bits of interest are all active LOW - status_composite |= axis_status[j]; - } - if (status_composite) break; // Break on any error - } while (current_feedrate < fr_limit); - - DEBUG_ECHOPGM("Completed with "); - if (status_composite) { - DEBUG_ECHOLNPGM("errors"); - #if ENABLED(L6470_CHITCHAT) - for (j = 0; j < driver_count; j++) { - if (j) DEBUG_ECHOPGM("..."); - L64xxManager.error_status_decode(axis_status[j], axis_index[j], - sh.STATUS_AXIS_TH_SD, sh.STATUS_AXIS_TH_WRN, - sh.STATUS_AXIS_STEP_LOSS_A, sh.STATUS_AXIS_STEP_LOSS_B, - sh.STATUS_AXIS_OCD, sh.STATUS_AXIS_LAYOUT); - } - #endif - } - else - DEBUG_ECHOLNPGM("no errors"); - - L64xxManager.pause_monitor(false); -} - -#endif // HAS_L64XX diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index a13940afc326..d0242570eb9a 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -1005,14 +1005,6 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 919: M919(); break; // M919: Set stepper Chopper Times #endif - #if HAS_L64XX - case 122: M122(); break; // M122: Report status - case 906: M906(); break; // M906: Set or get motor drive level - case 916: M916(); break; // M916: L6470 tuning: Increase drive level until thermal warning - case 917: M917(); break; // M917: L6470 tuning: Find minimum current thresholds - case 918: M918(); break; // M918: L6470 tuning: Increase speed until max or error - #endif - #if HAS_MICROSTEPS case 350: M350(); break; // M350: Set microstepping mode. Warning: Steps per unit remains unchanged. S code sets stepping mode for all drivers. case 351: M351(); break; // M351: Toggle MS1 MS2 pins directly, S# determines MS1 or MS2, X# sets the pin high/low. diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index a6b530a2682a..e754b6dc3d82 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -155,7 +155,7 @@ * M120 - Enable endstops detection. * M121 - Disable endstops detection. * - * M122 - Debug stepper (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660 or L6470) + * M122 - Debug stepper (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660) * M123 - Report fan tachometers. (Requires En_FAN_TACHO_PIN) Optionally set auto-report interval. (Requires AUTO_REPORT_FANS) * M125 - Save current position and move to filament change position. (Requires PARK_HEAD_ON_PAUSE) * @@ -286,7 +286,7 @@ * M871 - Print/reset/clear first layer temperature offset values. (Requires PTC_PROBE, PTC_BED, or PTC_HOTEND) * M876 - Handle Prompt Response. (Requires HOST_PROMPT_SUPPORT and not EMERGENCY_PARSER) * M900 - Get or Set Linear Advance K-factor. (Requires LIN_ADVANCE) - * M906 - Set or get motor current in milliamps using axis codes XYZE, etc. Report values if no axis codes given. (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660 or L6470) + * M906 - Set or get motor current in milliamps using axis codes XYZE, etc. Report values if no axis codes given. (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660) * M907 - Set digital trimpot motor current using axis codes. (Requires a board with digital trimpots) * M908 - Control digital trimpot directly. (Requires HAS_MOTOR_CURRENT_DAC or DIGIPOTSS_PIN) * M909 - Print digipot/DAC current value. (Requires HAS_MOTOR_CURRENT_DAC) @@ -295,9 +295,6 @@ * M912 - Clear stepper driver overtemperature pre-warn condition flag. (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660) * M913 - Set HYBRID_THRESHOLD speed. (Requires HYBRID_THRESHOLD) * M914 - Set StallGuard sensitivity. (Requires SENSORLESS_HOMING or SENSORLESS_PROBING) - * M916 - L6470 tuning: Increase KVAL_HOLD until thermal warning. (Requires at least one _DRIVER_TYPE L6470) - * M917 - L6470 tuning: Find minimum current thresholds. (Requires at least one _DRIVER_TYPE L6470) - * M918 - L6470 tuning: Increase speed until max or error. (Requires at least one _DRIVER_TYPE L6470) * M919 - Get or Set motor Chopper Times (time_off, hysteresis_end, hysteresis_start) using axis codes XYZE, etc. If no parameters are given, report. (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660) * M951 - Set Magnetic Parking Extruder parameters. (Requires MAGNETIC_PARKING_EXTRUDER) * M3426 - Read MCP3426 ADC over I2C. (Requires HAS_MCP3426_ADC) @@ -1163,14 +1160,6 @@ class GcodeSuite { static void M919(); #endif - #if HAS_L64XX - static void M122(); - static void M906(); - static void M916(); - static void M917(); - static void M918(); - #endif - #if HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_PWM || HAS_MOTOR_CURRENT_I2C || HAS_MOTOR_CURRENT_DAC static void M907(); #if HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_PWM diff --git a/Marlin/src/gcode/host/M114.cpp b/Marlin/src/gcode/host/M114.cpp index 8ea300b5e053..60359eeecfae 100644 --- a/Marlin/src/gcode/host/M114.cpp +++ b/Marlin/src/gcode/host/M114.cpp @@ -28,12 +28,6 @@ #if ENABLED(M114_DETAIL) - #if HAS_L64XX - #include "../../libs/L64XX/L64XX_Marlin.h" - #define DEBUG_OUT ENABLED(L6470_CHITCHAT) - #include "../../core/debug_out.h" - #endif - void report_all_axis_pos(const xyze_pos_t &pos, const uint8_t n=LOGICAL_AXES, const uint8_t precision=3) { char str[12]; LOOP_L_N(a, n) { @@ -84,89 +78,6 @@ planner.synchronize(); - #if HAS_L64XX - char temp_buf[80]; - int32_t temp; - //#define ABS_POS_SIGN_MASK 0b1111 1111 1110 0000 0000 0000 0000 0000 - #define ABS_POS_SIGN_MASK 0b11111111111000000000000000000000 - #define REPORT_ABSOLUTE_POS(Q) do{ \ - L64xxManager.say_axis(Q, false); \ - temp = L6470_GETPARAM(L6470_ABS_POS,Q); \ - if (temp & ABS_POS_SIGN_MASK) temp |= ABS_POS_SIGN_MASK; \ - sprintf_P(temp_buf, PSTR(":%8ld "), temp); \ - DEBUG_ECHO(temp_buf); \ - }while(0) - - DEBUG_ECHOPGM("\nL6470:"); - #if AXIS_IS_L64XX(X) - REPORT_ABSOLUTE_POS(X); - #endif - #if AXIS_IS_L64XX(X2) - REPORT_ABSOLUTE_POS(X2); - #endif - #if AXIS_IS_L64XX(Y) - REPORT_ABSOLUTE_POS(Y); - #endif - #if AXIS_IS_L64XX(Y2) - REPORT_ABSOLUTE_POS(Y2); - #endif - #if AXIS_IS_L64XX(Z) - REPORT_ABSOLUTE_POS(Z); - #endif - #if AXIS_IS_L64XX(Z2) - REPORT_ABSOLUTE_POS(Z2); - #endif - #if AXIS_IS_L64XX(Z3) - REPORT_ABSOLUTE_POS(Z3); - #endif - #if AXIS_IS_L64XX(Z4) - REPORT_ABSOLUTE_POS(Z4); - #endif - #if AXIS_IS_L64XX(I) - REPORT_ABSOLUTE_POS(I); - #endif - #if AXIS_IS_L64XX(J) - REPORT_ABSOLUTE_POS(J); - #endif - #if AXIS_IS_L64XX(K) - REPORT_ABSOLUTE_POS(K); - #endif - #if AXIS_IS_L64XX(U) - REPORT_ABSOLUTE_POS(U); - #endif - #if AXIS_IS_L64XX(V) - REPORT_ABSOLUTE_POS(V); - #endif - #if AXIS_IS_L64XX(W) - REPORT_ABSOLUTE_POS(W); - #endif - #if AXIS_IS_L64XX(E0) - REPORT_ABSOLUTE_POS(E0); - #endif - #if AXIS_IS_L64XX(E1) - REPORT_ABSOLUTE_POS(E1); - #endif - #if AXIS_IS_L64XX(E2) - REPORT_ABSOLUTE_POS(E2); - #endif - #if AXIS_IS_L64XX(E3) - REPORT_ABSOLUTE_POS(E3); - #endif - #if AXIS_IS_L64XX(E4) - REPORT_ABSOLUTE_POS(E4); - #endif - #if AXIS_IS_L64XX(E5) - REPORT_ABSOLUTE_POS(E5); - #endif - #if AXIS_IS_L64XX(E6) - REPORT_ABSOLUTE_POS(E6); - #endif - #if AXIS_IS_L64XX(E7) - REPORT_ABSOLUTE_POS(E7); - #endif - SERIAL_EOL(); - #endif // HAS_L64XX - SERIAL_ECHOPGM("Stepper:"); LOOP_LOGICAL_AXES(i) { SERIAL_ECHOPGM_P((PGM_P)pgm_read_ptr(&SP_AXIS_LBL[i]), stepper.position((AxisEnum)i)); diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 3a5470b03e7d..5f9ab3dc7df3 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -1610,7 +1610,7 @@ #define HAS_X_MS_PINS 1 #endif -#if PIN_EXISTS(X2_ENABLE) || AXIS_IS_L64XX(X2) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(X2)) +#if PIN_EXISTS(X2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(X2)) #define HAS_X2_ENABLE 1 #endif #if PIN_EXISTS(X2_DIR) @@ -1631,7 +1631,7 @@ #endif #if HAS_Y_AXIS - #if PIN_EXISTS(Y_ENABLE) || AXIS_IS_L64XX(Y) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Y)) + #if PIN_EXISTS(Y_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Y)) #define HAS_Y_ENABLE 1 #endif #if PIN_EXISTS(Y_DIR) @@ -1644,7 +1644,7 @@ #define HAS_Y_MS_PINS 1 #endif - #if PIN_EXISTS(Y2_ENABLE) || AXIS_IS_L64XX(Y2) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Y2)) + #if PIN_EXISTS(Y2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Y2)) #define HAS_Y2_ENABLE 1 #endif #if PIN_EXISTS(Y2_DIR) @@ -1664,7 +1664,7 @@ #endif #if HAS_Z_AXIS - #if PIN_EXISTS(Z_ENABLE) || AXIS_IS_L64XX(Z) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z)) + #if PIN_EXISTS(Z_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z)) #define HAS_Z_ENABLE 1 #endif #if PIN_EXISTS(Z_DIR) @@ -1684,7 +1684,7 @@ #endif #if NUM_Z_STEPPERS >= 2 - #if PIN_EXISTS(Z2_ENABLE) || AXIS_IS_L64XX(Z2) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z2)) + #if PIN_EXISTS(Z2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z2)) #define HAS_Z2_ENABLE 1 #endif #if PIN_EXISTS(Z2_DIR) @@ -1699,7 +1699,7 @@ #endif #if NUM_Z_STEPPERS >= 3 - #if PIN_EXISTS(Z3_ENABLE) || AXIS_IS_L64XX(Z3) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z3)) + #if PIN_EXISTS(Z3_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z3)) #define HAS_Z3_ENABLE 1 #endif #if PIN_EXISTS(Z3_DIR) @@ -1714,7 +1714,7 @@ #endif #if NUM_Z_STEPPERS >= 4 - #if PIN_EXISTS(Z4_ENABLE) || AXIS_IS_L64XX(Z4) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z4)) + #if PIN_EXISTS(Z4_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z4)) #define HAS_Z4_ENABLE 1 #endif #if PIN_EXISTS(Z4_DIR) @@ -1729,7 +1729,7 @@ #endif #if HAS_I_AXIS - #if PIN_EXISTS(I_ENABLE) || AXIS_IS_L64XX(I) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(I)) + #if PIN_EXISTS(I_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(I)) #define HAS_I_ENABLE 1 #endif #if PIN_EXISTS(I_DIR) @@ -1749,7 +1749,7 @@ #endif #if HAS_J_AXIS - #if PIN_EXISTS(J_ENABLE) || AXIS_IS_L64XX(J) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(J)) + #if PIN_EXISTS(J_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(J)) #define HAS_J_ENABLE 1 #endif #if PIN_EXISTS(J_DIR) @@ -1769,7 +1769,7 @@ #endif #if HAS_K_AXIS - #if PIN_EXISTS(K_ENABLE) || AXIS_IS_L64XX(K) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(K)) + #if PIN_EXISTS(K_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(K)) #define HAS_K_ENABLE 1 #endif #if PIN_EXISTS(K_DIR) @@ -1789,7 +1789,7 @@ #endif #if HAS_U_AXIS - #if PIN_EXISTS(U_ENABLE) || AXIS_IS_L64XX(U) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(U)) + #if PIN_EXISTS(U_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(U)) #define HAS_U_ENABLE 1 #endif #if PIN_EXISTS(U_DIR) @@ -1809,7 +1809,7 @@ #endif #if HAS_V_AXIS - #if PIN_EXISTS(V_ENABLE) || AXIS_IS_L64XX(V) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(V)) + #if PIN_EXISTS(V_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(V)) #define HAS_V_ENABLE 1 #endif #if PIN_EXISTS(V_DIR) @@ -1829,7 +1829,7 @@ #endif #if HAS_W_AXIS - #if PIN_EXISTS(W_ENABLE) || AXIS_IS_L64XX(W) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(W)) + #if PIN_EXISTS(W_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(W)) #define HAS_W_ENABLE 1 #endif #if PIN_EXISTS(W_DIR) @@ -1851,7 +1851,7 @@ // Extruder steppers and solenoids #if HAS_EXTRUDERS - #if PIN_EXISTS(E0_ENABLE) || AXIS_IS_L64XX(E0) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E0)) + #if PIN_EXISTS(E0_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E0)) #define HAS_E0_ENABLE 1 #endif #if PIN_EXISTS(E0_DIR) @@ -1865,7 +1865,7 @@ #endif #if E_STEPPERS > 1 || ENABLED(E_DUAL_STEPPER_DRIVERS) - #if PIN_EXISTS(E1_ENABLE) || AXIS_IS_L64XX(E1) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E1)) + #if PIN_EXISTS(E1_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E1)) #define HAS_E1_ENABLE 1 #endif #if PIN_EXISTS(E1_DIR) @@ -1880,7 +1880,7 @@ #endif #if E_STEPPERS > 2 - #if PIN_EXISTS(E2_ENABLE) || AXIS_IS_L64XX(E2) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E2)) + #if PIN_EXISTS(E2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E2)) #define HAS_E2_ENABLE 1 #endif #if PIN_EXISTS(E2_DIR) @@ -1895,7 +1895,7 @@ #endif #if E_STEPPERS > 3 - #if PIN_EXISTS(E3_ENABLE) || AXIS_IS_L64XX(E3) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E3)) + #if PIN_EXISTS(E3_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E3)) #define HAS_E3_ENABLE 1 #endif #if PIN_EXISTS(E3_DIR) @@ -1910,7 +1910,7 @@ #endif #if E_STEPPERS > 4 - #if PIN_EXISTS(E4_ENABLE) || AXIS_IS_L64XX(E4) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E4)) + #if PIN_EXISTS(E4_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E4)) #define HAS_E4_ENABLE 1 #endif #if PIN_EXISTS(E4_DIR) @@ -1925,7 +1925,7 @@ #endif #if E_STEPPERS > 5 - #if PIN_EXISTS(E5_ENABLE) || AXIS_IS_L64XX(E5) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E5)) + #if PIN_EXISTS(E5_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E5)) #define HAS_E5_ENABLE 1 #endif #if PIN_EXISTS(E5_DIR) @@ -1940,7 +1940,7 @@ #endif #if E_STEPPERS > 6 - #if PIN_EXISTS(E6_ENABLE) || AXIS_IS_L64XX(E6) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E6)) + #if PIN_EXISTS(E6_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E6)) #define HAS_E6_ENABLE 1 #endif #if PIN_EXISTS(E6_DIR) @@ -1955,7 +1955,7 @@ #endif #if E_STEPPERS > 7 - #if PIN_EXISTS(E7_ENABLE) || AXIS_IS_L64XX(E7) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E7)) + #if PIN_EXISTS(E7_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E7)) #define HAS_E7_ENABLE 1 #endif #if PIN_EXISTS(E7_DIR) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 3df020e3f051..dff7fb88a884 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -350,7 +350,7 @@ #elif defined(HAVE_TMC2208) #error "HAVE_TMC2208 is now [AXIS]_DRIVER_TYPE TMC2208." #elif defined(HAVE_L6470DRIVER) - #error "HAVE_L6470DRIVER is now [AXIS]_DRIVER_TYPE L6470." + #error "HAVE_L6470DRIVER is obsolete. L64xx stepper drivers are no longer supported in Marlin." #elif defined(X_IS_TMC) || defined(X2_IS_TMC) || defined(Y_IS_TMC) || defined(Y2_IS_TMC) || defined(Z_IS_TMC) || defined(Z2_IS_TMC) || defined(Z3_IS_TMC) \ || defined(E0_IS_TMC) || defined(E1_IS_TMC) || defined(E2_IS_TMC) || defined(E3_IS_TMC) || defined(E4_IS_TMC) || defined(E5_IS_TMC) || defined(E6_IS_TMC) || defined(E7_IS_TMC) #error "[AXIS]_IS_TMC is now [AXIS]_DRIVER_TYPE TMC26X." @@ -363,9 +363,6 @@ #elif defined(X_IS_TMC2208) || defined(X2_IS_TMC2208) || defined(Y_IS_TMC2208) || defined(Y2_IS_TMC2208) || defined(Z_IS_TMC2208) || defined(Z2_IS_TMC2208) || defined(Z3_IS_TMC2208) \ || defined(E0_IS_TMC2208) || defined(E1_IS_TMC2208) || defined(E2_IS_TMC2208) || defined(E3_IS_TMC2208) || defined(E4_IS_TMC2208) || defined(E5_IS_TMC2208) || defined(E6_IS_TMC2208) || defined(E7_IS_TMC2208) #error "[AXIS]_IS_TMC2208 is now [AXIS]_DRIVER_TYPE TMC2208." -#elif defined(X_IS_L6470) || defined(X2_IS_L6470) || defined(Y_IS_L6470) || defined(Y2_IS_L6470) || defined(Z_IS_L6470) || defined(Z2_IS_L6470) || defined(Z3_IS_L6470) \ - || defined(E0_IS_L6470) || defined(E1_IS_L6470) || defined(E2_IS_L6470) || defined(E3_IS_L6470) || defined(E4_IS_L6470) || defined(E5_IS_L6470) || defined(E6_IS_L6470) || defined(E7_IS_L6470) - #error "[AXIS]_IS_L6470 is now [AXIS]_DRIVER_TYPE L6470." #elif defined(AUTOMATIC_CURRENT_CONTROL) #error "AUTOMATIC_CURRENT_CONTROL is now MONITOR_DRIVER_STATUS." #elif defined(FILAMENT_CHANGE_LOAD_LENGTH) @@ -647,6 +644,26 @@ #error "LEVEL_CENTER_TOO is now BED_TRAMMING_INCLUDE_CENTER." #endif +// L64xx stepper drivers have been removed +#define _L6470 0x6470 +#define _L6474 0x6474 +#define _L6480 0x6480 +#define _POWERSTEP01 0xF00D +#if HAS_DRIVER(L6470) + #error "L6470 stepper drivers are no longer supported in Marlin." +#elif HAS_DRIVER(L6474) + #error "L6474 stepper drivers are no longer supported in Marlin." +#elif HAS_DRIVER(L6480) + #error "L6480 stepper drivers are no longer supported in Marlin." +#elif HAS_DRIVER(POWERSTEP01) + #error "POWERSTEP01 stepper drivers are no longer supported in Marlin." +#endif +#undef _L6470 +#undef _L6474 +#undef _L6480 +#undef _POWERSTEP01 + +// Check AXIS_RELATIVE_MODES constexpr float arm[] = AXIS_RELATIVE_MODES; static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _LOGICAL_AXES_STR "elements."); @@ -3533,7 +3550,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS /** * TMC SPI Chaining */ -#define IN_CHAIN(A) ((A##_CHAIN_POS > 0) && !HAS_L64XX) +#define IN_CHAIN(A) A##_CHAIN_POS > 0 #if IN_CHAIN(X ) || IN_CHAIN(Y ) || IN_CHAIN(Z ) || IN_CHAIN(X2) || IN_CHAIN(Y2) || IN_CHAIN(Z2) || IN_CHAIN(Z3) || IN_CHAIN(Z4) \ || IN_CHAIN(E0) || IN_CHAIN(E1) || IN_CHAIN(E2) || IN_CHAIN(E3) || IN_CHAIN(E4) || IN_CHAIN(E5) || IN_CHAIN(E6) || IN_CHAIN(E7) #define BAD_CHAIN(A) (IN_CHAIN(A) && !PIN_EXISTS(A##_CS)) @@ -3598,13 +3615,6 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #undef IN_CHAIN -/** - * L64XX requirement - */ -#if HAS_L64XX && NUM_AXES > 3 - #error "L64XX requires NUM_AXES <= 3. Homing with L64XX is not yet implemented for NUM_AXES > 3." -#endif - /** * Digipot requirement */ diff --git a/Marlin/src/libs/L64XX/L64XX_Marlin.cpp b/Marlin/src/libs/L64XX/L64XX_Marlin.cpp deleted file mode 100644 index 1d6943406722..000000000000 --- a/Marlin/src/libs/L64XX/L64XX_Marlin.cpp +++ /dev/null @@ -1,998 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -/** - * The monitor_driver routines are a close copy of the TMC code - */ - -#include "../../inc/MarlinConfig.h" - -#if HAS_L64XX - -#include "L64XX_Marlin.h" - -L64XX_Marlin L64xxManager; - -#include "../../module/stepper/indirection.h" -#include "../../gcode/gcode.h" -#include "../../module/planner.h" -#include "../../HAL/shared/Delay.h" - -static const char NUM_AXIS_LIST( - str_X[] PROGMEM = "X ", str_Y[] PROGMEM = "Y ", str_Z[] PROGMEM = "Z ", - str_I[] PROGMEM = STR_I " ", str_J[] PROGMEM = STR_J " ", str_K[] PROGMEM = STR_K " " - ), - str_X2[] PROGMEM = "X2", str_Y2[] PROGMEM = "Y2", - str_Z2[] PROGMEM = "Z2", str_Z3[] PROGMEM = "Z3", str_Z4[] PROGMEM = "Z4", - LIST_N(EXTRUDERS, - str_E0[] PROGMEM = "E0", str_E1[] PROGMEM = "E1", - str_E2[] PROGMEM = "E2", str_E3[] PROGMEM = "E3", - str_E4[] PROGMEM = "E4", str_E5[] PROGMEM = "E5", - str_E6[] PROGMEM = "E6", str_E7[] PROGMEM = "E7" - ) - ; - -#define _EN_ITEM(N) , str_E##N -PGM_P const L64XX_Marlin::index_to_axis[] PROGMEM = { - NUM_AXIS_LIST(str_X, str_Y, str_Z, str_I, str_J, str_K), - str_X2, str_Y2, str_Z2, str_Z3, str_Z4 - REPEAT(E_STEPPERS, _EN_ITEM) -}; -#undef _EN_ITEM - -#define DEBUG_OUT ENABLED(L6470_CHITCHAT) -#include "../../core/debug_out.h" - -void echo_yes_no(const bool yes) { DEBUG_ECHOPGM_P(yes ? PSTR(" YES") : PSTR(" NO ")); UNUSED(yes); } - -uint8_t L64XX_Marlin::dir_commands[MAX_L64XX]; // array to hold direction command for each driver - -#define _EN_ITEM(N) , ENABLED(INVERT_E##N##_DIR) -const uint8_t L64XX_Marlin::index_to_dir[MAX_L64XX] = { - NUM_AXIS_LIST(ENABLED(INVERT_X_DIR), ENABLED(INVERT_Y_DIR), ENABLED(INVERT_Z_DIR), ENABLED(INVERT_I_DIR), ENABLED(INVERT_J_DIR), ENABLED(INVERT_K_DIR), ENABLED(INVERT_U_DIR), ENABLED(INVERT_V_DIR), ENABLED(INVERT_W_DIR)) - , ENABLED(INVERT_X_DIR) ^ BOTH(HAS_DUAL_X_STEPPERS, INVERT_X2_VS_X_DIR) // X2 - , ENABLED(INVERT_Y_DIR) ^ BOTH(HAS_DUAL_Y_STEPPERS, INVERT_Y2_VS_Y_DIR) // Y2 - , ENABLED(INVERT_Z_DIR) ^ ENABLED(INVERT_Z2_VS_Z_DIR) // Z2 - , ENABLED(INVERT_Z_DIR) ^ ENABLED(INVERT_Z3_VS_Z_DIR) // Z3 - , ENABLED(INVERT_Z_DIR) ^ ENABLED(INVERT_Z4_VS_Z_DIR) // Z4 - REPEAT(E_STEPPERS, _EN_ITEM) -}; -#undef _EN_ITEM - -volatile uint8_t L64XX_Marlin::spi_abort = false; -uint8_t L64XX_Marlin::spi_active = false; - -L64XX_Marlin::L64XX_shadow_t L64XX_Marlin::shadow; - -//uint32_t UVLO_ADC = 0x0400; // ADC undervoltage event - -void L6470_populate_chain_array() { - - #define _L6470_INIT_SPI(Q) do{ stepper##Q.set_chain_info(Q, Q##_CHAIN_POS); }while(0) - - #if AXIS_IS_L64XX(X) - _L6470_INIT_SPI(X); - #endif - #if AXIS_IS_L64XX(X2) - _L6470_INIT_SPI(X2); - #endif - #if AXIS_IS_L64XX(Y) - _L6470_INIT_SPI(Y); - #endif - #if AXIS_IS_L64XX(Y2) - _L6470_INIT_SPI(Y2); - #endif - #if AXIS_IS_L64XX(Z) - _L6470_INIT_SPI(Z); - #endif - #if AXIS_IS_L64XX(Z2) - _L6470_INIT_SPI(Z2); - #endif - #if AXIS_IS_L64XX(Z3) - _L6470_INIT_SPI(Z3); - #endif - #if AXIS_IS_L64XX(Z4) - _L6470_INIT_SPI(Z4); - #endif - #if AXIS_IS_L64XX(E0) - _L6470_INIT_SPI(E0); - #endif - #if AXIS_IS_L64XX(E1) - _L6470_INIT_SPI(E1); - #endif - #if AXIS_IS_L64XX(E2) - _L6470_INIT_SPI(E2); - #endif - #if AXIS_IS_L64XX(E3) - _L6470_INIT_SPI(E3); - #endif - #if AXIS_IS_L64XX(E4) - _L6470_INIT_SPI(E4); - #endif - #if AXIS_IS_L64XX(E5) - _L6470_INIT_SPI(E5); - #endif - #if AXIS_IS_L64XX(E6) - _L6470_INIT_SPI(E6); - #endif - #if AXIS_IS_L64XX(E7) - _L6470_INIT_SPI(E7); - #endif -} - - -/** - * Some status bit positions & definitions differ per driver. - * Copy info to known locations to simplfy check/display logic. - * 1. Copy stepper status - * 2. Copy status bit definitions - * 3. Copy status layout - * 4. Make all error bits active low (as needed) - */ -uint16_t L64XX_Marlin::get_stepper_status(L64XX &st) { - shadow.STATUS_AXIS_RAW = st.getStatus(); - shadow.STATUS_AXIS = shadow.STATUS_AXIS_RAW; - shadow.STATUS_AXIS_LAYOUT = st.L6470_status_layout; - shadow.AXIS_OCD_TH_MAX = st.OCD_TH_MAX; - shadow.AXIS_STALL_TH_MAX = st.STALL_TH_MAX; - shadow.AXIS_OCD_CURRENT_CONSTANT_INV = st.OCD_CURRENT_CONSTANT_INV; - shadow.AXIS_STALL_CURRENT_CONSTANT_INV = st.STALL_CURRENT_CONSTANT_INV; - shadow.L6470_AXIS_CONFIG = st.L64XX_CONFIG; - shadow.L6470_AXIS_STATUS = st.L64XX_STATUS; - shadow.STATUS_AXIS_OCD = st.STATUS_OCD; - shadow.STATUS_AXIS_SCK_MOD = st.STATUS_SCK_MOD; - shadow.STATUS_AXIS_STEP_LOSS_A = st.STATUS_STEP_LOSS_A; - shadow.STATUS_AXIS_STEP_LOSS_B = st.STATUS_STEP_LOSS_B; - shadow.STATUS_AXIS_TH_SD = st.STATUS_TH_SD; - shadow.STATUS_AXIS_TH_WRN = st.STATUS_TH_WRN; - shadow.STATUS_AXIS_UVLO = st.STATUS_UVLO; - shadow.STATUS_AXIS_WRONG_CMD = st.STATUS_WRONG_CMD; - shadow.STATUS_AXIS_CMD_ERR = st.STATUS_CMD_ERR; - shadow.STATUS_AXIS_NOTPERF_CMD = st.STATUS_NOTPERF_CMD; - - switch (shadow.STATUS_AXIS_LAYOUT) { - case L6470_STATUS_LAYOUT: { // L6470 - shadow.L6470_ERROR_MASK = shadow.STATUS_AXIS_UVLO | shadow.STATUS_AXIS_TH_WRN | shadow.STATUS_AXIS_TH_SD | shadow.STATUS_AXIS_OCD | shadow.STATUS_AXIS_STEP_LOSS_A | shadow.STATUS_AXIS_STEP_LOSS_B; - shadow.STATUS_AXIS ^= (shadow.STATUS_AXIS_WRONG_CMD | shadow.STATUS_AXIS_NOTPERF_CMD); // invert just error bits that are active high - break; - } - case L6474_STATUS_LAYOUT: { // L6474 - shadow.L6470_ERROR_MASK = shadow.STATUS_AXIS_UVLO | shadow.STATUS_AXIS_TH_WRN | shadow.STATUS_AXIS_TH_SD | shadow.STATUS_AXIS_OCD ; - shadow.STATUS_AXIS ^= (shadow.STATUS_AXIS_WRONG_CMD | shadow.STATUS_AXIS_NOTPERF_CMD); // invert just error bits that are active high - break; - } - case L6480_STATUS_LAYOUT: { // L6480 & powerSTEP01 - shadow.L6470_ERROR_MASK = shadow.STATUS_AXIS_UVLO | shadow.STATUS_AXIS_TH_WRN | shadow.STATUS_AXIS_TH_SD | shadow.STATUS_AXIS_OCD | shadow.STATUS_AXIS_STEP_LOSS_A | shadow.STATUS_AXIS_STEP_LOSS_B; - shadow.STATUS_AXIS ^= (shadow.STATUS_AXIS_CMD_ERR | shadow.STATUS_AXIS_TH_WRN | shadow.STATUS_AXIS_TH_SD); // invert just error bits that are active high - break; - } - } - return shadow.STATUS_AXIS; -} - - -void L64XX_Marlin::init() { // Set up SPI and then init chips - ENABLE_RESET_L64XX_CHIPS(LOW); // hardware reset of drivers - DELAY_US(100); - ENABLE_RESET_L64XX_CHIPS(HIGH); - DELAY_US(1000); // need about 650µs for the chip(s) to fully start up - L6470_populate_chain_array(); // Set up array to control where in the SPI transfer sequence a particular stepper's data goes - - spi_init(); // Since L64XX SPI pins are unset we must init SPI here - - init_to_defaults(); // init the chips -} - -uint16_t L64XX_Marlin::get_status(const L64XX_axis_t axis) { - - #define STATUS_L6470(Q) get_stepper_status(stepper##Q) - - switch (axis) { - default: break; - #if AXIS_IS_L64XX(X) - case X : return STATUS_L6470(X); - #endif - #if AXIS_IS_L64XX(Y) - case Y : return STATUS_L6470(Y); - #endif - #if AXIS_IS_L64XX(Z) - case Z : return STATUS_L6470(Z); - #endif - #if AXIS_IS_L64XX(X2) - case X2: return STATUS_L6470(X2); - #endif - #if AXIS_IS_L64XX(Y2) - case Y2: return STATUS_L6470(Y2); - #endif - #if AXIS_IS_L64XX(Z2) - case Z2: return STATUS_L6470(Z2); - #endif - #if AXIS_IS_L64XX(Z3) - case Z3: return STATUS_L6470(Z3); - #endif - #if AXIS_IS_L64XX(Z4) - case Z4: return STATUS_L6470(Z4); - #endif - #if AXIS_IS_L64XX(E0) - case E0: return STATUS_L6470(E0); - #endif - #if AXIS_IS_L64XX(E1) - case E1: return STATUS_L6470(E1); - #endif - #if AXIS_IS_L64XX(E2) - case E2: return STATUS_L6470(E2); - #endif - #if AXIS_IS_L64XX(E3) - case E3: return STATUS_L6470(E3); - #endif - #if AXIS_IS_L64XX(E4) - case E4: return STATUS_L6470(E4); - #endif - #if AXIS_IS_L64XX(E5) - case E5: return STATUS_L6470(E5); - #endif - #if AXIS_IS_L64XX(E6) - case E6: return STATUS_L6470(E6); - #endif - #if AXIS_IS_L64XX(E7) - case E7: return STATUS_L6470(E7); - #endif - } - - return 0; // Not needed but kills a compiler warning -} - -uint32_t L64XX_Marlin::get_param(const L64XX_axis_t axis, const uint8_t param) { - - #define GET_L6470_PARAM(Q) L6470_GETPARAM(param, Q) - - switch (axis) { - default: break; - #if AXIS_IS_L64XX(X) - case X : return GET_L6470_PARAM(X); - #endif - #if AXIS_IS_L64XX(Y) - case Y : return GET_L6470_PARAM(Y); - #endif - #if AXIS_IS_L64XX(Z) - case Z : return GET_L6470_PARAM(Z); - #endif - #if AXIS_IS_L64XX(X2) - case X2: return GET_L6470_PARAM(X2); - #endif - #if AXIS_IS_L64XX(Y2) - case Y2: return GET_L6470_PARAM(Y2); - #endif - #if AXIS_IS_L64XX(Z2) - case Z2: return GET_L6470_PARAM(Z2); - #endif - #if AXIS_IS_L64XX(Z3) - case Z3: return GET_L6470_PARAM(Z3); - #endif - #if AXIS_IS_L64XX(Z4) - case Z4: return GET_L6470_PARAM(Z4); - #endif - #if AXIS_IS_L64XX(E0) - case E0: return GET_L6470_PARAM(E0); - #endif - #if AXIS_IS_L64XX(E1) - case E1: return GET_L6470_PARAM(E1); - #endif - #if AXIS_IS_L64XX(E2) - case E2: return GET_L6470_PARAM(E2); - #endif - #if AXIS_IS_L64XX(E3) - case E3: return GET_L6470_PARAM(E3); - #endif - #if AXIS_IS_L64XX(E4) - case E4: return GET_L6470_PARAM(E4); - #endif - #if AXIS_IS_L64XX(E5) - case E5: return GET_L6470_PARAM(E5); - #endif - #if AXIS_IS_L64XX(E6) - case E6: return GET_L6470_PARAM(E6); - #endif - #if AXIS_IS_L64XX(E7) - case E7: return GET_L6470_PARAM(E7); - #endif - } - - return 0; // not needed but kills a compiler warning -} - -void L64XX_Marlin::set_param(const L64XX_axis_t axis, const uint8_t param, const uint32_t value) { - - #define SET_L6470_PARAM(Q) stepper##Q.SetParam(param, value) - - switch (axis) { - default: break; - #if AXIS_IS_L64XX(X) - case X : SET_L6470_PARAM(X); break; - #endif - #if AXIS_IS_L64XX(Y) - case Y : SET_L6470_PARAM(Y); break; - #endif - #if AXIS_IS_L64XX(Z) - case Z : SET_L6470_PARAM(Z); break; - #endif - #if AXIS_IS_L64XX(I) - case I : SET_L6470_PARAM(I); break; - #endif - #if AXIS_IS_L64XX(J) - case J : SET_L6470_PARAM(J); break; - #endif - #if AXIS_IS_L64XX(K) - case K : SET_L6470_PARAM(K); break; - #endif - #if AXIS_IS_L64XX(X2) - case X2: SET_L6470_PARAM(X2); break; - #endif - #if AXIS_IS_L64XX(Y2) - case Y2: SET_L6470_PARAM(Y2); break; - #endif - #if AXIS_IS_L64XX(Z2) - case Z2: SET_L6470_PARAM(Z2); break; - #endif - #if AXIS_IS_L64XX(Z3) - case Z3: SET_L6470_PARAM(Z3); break; - #endif - #if AXIS_IS_L64XX(Z4) - case Z4: SET_L6470_PARAM(Z4); break; - #endif - #if AXIS_IS_L64XX(E0) - case E0: SET_L6470_PARAM(E0); break; - #endif - #if AXIS_IS_L64XX(E1) - case E1: SET_L6470_PARAM(E1); break; - #endif - #if AXIS_IS_L64XX(E2) - case E2: SET_L6470_PARAM(E2); break; - #endif - #if AXIS_IS_L64XX(E3) - case E3: SET_L6470_PARAM(E3); break; - #endif - #if AXIS_IS_L64XX(E4) - case E4: SET_L6470_PARAM(E4); break; - #endif - #if AXIS_IS_L64XX(E5) - case E5: SET_L6470_PARAM(E5); break; - #endif - #if AXIS_IS_L64XX(E6) - case E6: SET_L6470_PARAM(E6); break; - #endif - #if AXIS_IS_L64XX(E7) - case E7: SET_L6470_PARAM(E7); break; - #endif - } -} - -inline void echo_min_max(const char a, const_float_t min, const_float_t max) { - DEBUG_CHAR(' '); DEBUG_CHAR(a); - DEBUG_ECHOLNPGM(" min = ", min, " max = ", max); -} -inline void echo_oct_used(const_float_t oct, const uint8_t stall) { - DEBUG_ECHOPGM("over_current_threshold used : ", oct); - DEBUG_ECHOPGM_P(stall ? PSTR(" (Stall") : PSTR(" (OCD")); - DEBUG_ECHOLNPGM(" threshold)"); -} -inline void err_out_of_bounds() { DEBUG_ECHOLNPGM("Test aborted - motion out of bounds"); } - -uint8_t L64XX_Marlin::get_user_input(uint8_t &driver_count, L64XX_axis_t axis_index[3], char axis_mon[3][3], - float &position_max, float &position_min, float &final_feedrate, uint8_t &kval_hold, - uint8_t over_current_flag, uint8_t &OCD_TH_val, uint8_t &STALL_TH_val, uint16_t &over_current_threshold -) { - // Return TRUE if the calling routine needs to abort/kill - - uint16_t displacement = 0; // " = 0" to eliminate compiler warning - uint8_t j; // general purpose counter - - if (!all_axes_homed()) { - DEBUG_ECHOLNPGM("Test aborted - home all before running this command"); - return true; - } - - uint8_t found_displacement = false; - LOOP_LOGICAL_AXES(i) if (uint16_t _displacement = parser.intval(AXIS_CHAR(i))) { - found_displacement = true; - displacement = _displacement; - const uint8_t axis_offset = parser.byteval('J'); - axis_mon[0][0] = AXIS_CHAR(i); // Axis first character, one of XYZ...E - const bool single_or_e = axis_offset >= 2 || axis_mon[0][0] == 'E', - one_or_more = !single_or_e && axis_offset == 0; - uint8_t driver_count_local = 0; // Can't use "driver_count" directly as a subscript because it's passed by reference - if (single_or_e) // Single axis, E0, or E1 - axis_mon[0][1] = axis_offset + '0'; // Index given by 'J' parameter - - if (single_or_e || one_or_more) { - for (j = 0; j < MAX_L64XX; j++) { // Count up the drivers on this axis - PGM_P str = (PGM_P)pgm_read_ptr(&index_to_axis[j]); // Get a PGM_P from progmem - const char c = pgm_read_byte(str); // Get a char from progmem - if (axis_mon[0][0] == c) { // For each stepper on this axis... - char *mon = axis_mon[driver_count_local]; - *mon++ = c; // Copy the 3 letter axis name - *mon++ = pgm_read_byte(&str[1]); // to the axis_mon array - *mon = pgm_read_byte(&str[2]); - axis_index[driver_count_local] = (L64XX_axis_t)j; // And store the L64XX axis index - driver_count_local++; - } - } - if (one_or_more) driver_count = driver_count_local; - } - break; // only take first axis found - } - - if (!found_displacement) { - DEBUG_ECHOLNPGM("Test aborted - AXIS with displacement is required"); - return true; - } - - // - // Position calcs & checks - // - - const float LOGICAL_AXIS_LIST( - E_center = current_position.e, - X_center = LOGICAL_X_POSITION(current_position.x), - Y_center = LOGICAL_Y_POSITION(current_position.y), - Z_center = LOGICAL_Z_POSITION(current_position.z), - I_center = LOGICAL_I_POSITION(current_position.i), - J_center = LOGICAL_J_POSITION(current_position.j), - K_center = LOGICAL_K_POSITION(current_position.k) - ); - - switch (axis_mon[0][0]) { - default: position_max = position_min = 0; break; - - case 'X': { - position_min = X_center - displacement; - position_max = X_center + displacement; - echo_min_max('X', position_min, position_max); - if (TERN0(HAS_ENDSTOPS, position_min < (X_MIN_POS) || position_max > (X_MAX_POS))) { - err_out_of_bounds(); - return true; - } - } break; - - #if HAS_Y_AXIS - case 'Y': { - position_min = Y_center - displacement; - position_max = Y_center + displacement; - echo_min_max('Y', position_min, position_max); - if (TERN0(HAS_ENDSTOPS, position_min < (Y_MIN_POS) || position_max > (Y_MAX_POS))) { - err_out_of_bounds(); - return true; - } - } break; - #endif - - #if HAS_Z_AXIS - case 'Z': { - position_min = Z_center - displacement; - position_max = Z_center + displacement; - echo_min_max('Z', position_min, position_max); - if (TERN0(HAS_ENDSTOPS, position_min < (Z_MIN_POS) || position_max > (Z_MAX_POS))) { - err_out_of_bounds(); - return true; - } - } break; - #endif - - #if HAS_I_AXIS - case AXIS4_NAME: { - position_min = I_center - displacement; - position_max = I_center + displacement; - echo_min_max(AXIS4_NAME, position_min, position_max); - if (TERN0(HAS_ENDSTOPS, position_min < (I_MIN_POS) || position_max > (I_MAX_POS))) { - err_out_of_bounds(); - return true; - } - } break; - #endif - - #if HAS_J_AXIS - case AXIS5_NAME: { - position_min = J_center - displacement; - position_max = J_center + displacement; - echo_min_max(AXIS5_NAME, position_min, position_max); - if (TERN1(HAS_ENDSTOPS, position_min < (J_MIN_POS) || position_max > (J_MAX_POS))) { - err_out_of_bounds(); - return true; - } - } break; - #endif - - #if HAS_K_AXIS - case AXIS6_NAME: { - position_min = K_center - displacement; - position_max = K_center + displacement; - echo_min_max(AXIS6_NAME, position_min, position_max); - if (TERN2(HAS_ENDSTOPS, position_min < (K_MIN_POS) || position_max > (K_MAX_POS))) { - err_out_of_bounds(); - return true; - } - } break; - #endif - - #if HAS_EXTRUDERS - case 'E': { - position_min = E_center - displacement; - position_max = E_center + displacement; - echo_min_max('E', position_min, position_max); - } break; - #endif - } - - // - // Work on the drivers - // - - LOOP_L_N(k, driver_count) { - uint8_t not_found = true; - for (j = 1; j <= L64XX::chain[0]; j++) { - PGM_P const str = (PGM_P)pgm_read_ptr(&index_to_axis[L64XX::chain[j]]); - if (pgm_read_byte(&str[0]) == axis_mon[k][0] && pgm_read_byte(&str[1]) == axis_mon[k][1]) { // See if a L6470 driver - not_found = false; - break; - } - } - if (not_found) { - driver_count = k; - axis_mon[k][0] = ' '; // mark this entry invalid - break; - } - } - - if (driver_count == 0) { - DEBUG_ECHOLNPGM("Test aborted - not a L6470 axis"); - return true; - } - - DEBUG_ECHOPGM("Monitoring:"); - for (j = 0; j < driver_count; j++) DEBUG_ECHOPGM(" ", axis_mon[j]); - DEBUG_EOL(); - - // now have a list of driver(s) to monitor - - // - // TVAL & kVAL_HOLD checks & settings - // - const L64XX_shadow_t &sh = shadow; - get_status(axis_index[0]); // populate shadow array - - if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) { // L6474 - use TVAL - uint16_t TVAL_current = parser.ushortval('T'); - if (TVAL_current) { - uint8_t TVAL_count = (TVAL_current / sh.AXIS_STALL_CURRENT_CONSTANT_INV) - 1; - LIMIT(TVAL_count, 0, sh.AXIS_STALL_TH_MAX); - for (j = 0; j < driver_count; j++) - set_param(axis_index[j], L6474_TVAL, TVAL_count); - } - // only print the tval from one of the drivers - kval_hold = get_param(axis_index[0], L6474_TVAL); - DEBUG_ECHOLNPGM("TVAL current (mA) = ", (kval_hold + 1) * sh.AXIS_STALL_CURRENT_CONSTANT_INV); - } - else { - kval_hold = parser.byteval('K'); - if (kval_hold) { - DEBUG_ECHOLNPGM("kval_hold = ", kval_hold); - for (j = 0; j < driver_count; j++) - set_param(axis_index[j], L6470_KVAL_HOLD, kval_hold); - } - else { - // only print the KVAL_HOLD from one of the drivers - kval_hold = get_param(axis_index[0], L6470_KVAL_HOLD); - DEBUG_ECHOLNPGM("KVAL_HOLD = ", kval_hold); - } - } - - // - // Overcurrent checks & settings - // - - if (over_current_flag) { - - uint8_t OCD_TH_val_local = 0, // compiler thinks OCD_TH_val is unused if use it directly - STALL_TH_val_local = 0; // just in case ... - - over_current_threshold = parser.intval('I'); - - if (over_current_threshold) { - - OCD_TH_val_local = over_current_threshold/375; - LIMIT(OCD_TH_val_local, 0, 15); - STALL_TH_val_local = over_current_threshold/31.25; - LIMIT(STALL_TH_val_local, 0, 127); - uint16_t OCD_TH_actual = (OCD_TH_val_local + 1) * 375, - STALL_TH_actual = (STALL_TH_val_local + 1) * 31.25; - if (OCD_TH_actual < STALL_TH_actual) { - OCD_TH_val_local++; - OCD_TH_actual = (OCD_TH_val_local + 1) * 375; - } - - DEBUG_ECHOLNPGM("over_current_threshold specified: ", over_current_threshold); - if (!(sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT)) echo_oct_used((STALL_TH_val_local + 1) * 31.25, true); - echo_oct_used((OCD_TH_val_local + 1) * 375, false); - - #define SET_OVER_CURRENT(Q) do { stepper##Q.SetParam(L6470_STALL_TH, STALL_TH_val_local); stepper##Q.SetParam(L6470_OCD_TH, OCD_TH_val_local);} while (0) - - for (j = 0; j < driver_count; j++) { - set_param(axis_index[j], L6470_STALL_TH, STALL_TH_val_local); - set_param(axis_index[j], L6470_OCD_TH, OCD_TH_val_local); - } - } - else { - // only get & print the OVER_CURRENT values from one of the drivers - STALL_TH_val_local = get_param(axis_index[0], L6470_STALL_TH); - OCD_TH_val_local = get_param(axis_index[0], L6470_OCD_TH); - - if (!(sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT)) echo_oct_used((STALL_TH_val_local + 1) * 31.25, true); - echo_oct_used((OCD_TH_val_local + 1) * 375, false); - } // over_current_threshold - - for (j = 0; j < driver_count; j++) { // set all drivers on axis the same - set_param(axis_index[j], L6470_STALL_TH, STALL_TH_val_local); - set_param(axis_index[j], L6470_OCD_TH, OCD_TH_val_local); - } - - OCD_TH_val = OCD_TH_val_local; // force compiler to update the main routine's copy - STALL_TH_val = STALL_TH_val_local; // force compiler to update the main routine's copy - } // end of overcurrent - - // - // Feedrate - // - - final_feedrate = parser.floatval('F'); - if (final_feedrate == 0) { - static constexpr float default_max_feedrate[] = DEFAULT_MAX_FEEDRATE; - const uint8_t num_feedrates = COUNT(default_max_feedrate); - for (j = 0; j < num_feedrates; j++) { - if (AXIS_CHAR(j) == axis_mon[0][0]) { - final_feedrate = default_max_feedrate[j]; - break; - } - } - if (j == 3 && num_feedrates > 4) { // have more than one extruder feedrate - uint8_t extruder_num = axis_mon[0][1] - '0'; - if (j <= num_feedrates - extruder_num) // have a feedrate specifically for this extruder - final_feedrate = default_max_feedrate[j + extruder_num]; - else - final_feedrate = default_max_feedrate[3]; // use E0 feedrate for this extruder - } - final_feedrate *= 60; // convert to mm/minute - } // end of feedrate - - return false; // FALSE indicates no user input problems -} - -void L64XX_Marlin::say_axis(const L64XX_axis_t axis, const uint8_t label/*=true*/) { - if (label) SERIAL_ECHOPGM("AXIS:"); - const char * const str = L64xxManager.index_to_axis[axis]; - SERIAL_CHAR(' ', str[0], str[1], ' '); -} - -#if ENABLED(L6470_CHITCHAT) - - // Assumes status bits have been inverted - void L64XX_Marlin::error_status_decode(const uint16_t status, const L64XX_axis_t axis, - const uint16_t _status_axis_th_sd, const uint16_t _status_axis_th_wrn, - const uint16_t _status_axis_step_loss_a, const uint16_t _status_axis_step_loss_b, - const uint16_t _status_axis_ocd, const uint8_t _status_axis_layout - ) { - say_axis(axis); - DEBUG_ECHOPGM(" THERMAL: "); - DEBUG_ECHOPGM_P((status & _status_axis_th_sd) ? PSTR("SHUTDOWN") : (status & _status_axis_th_wrn) ? PSTR("WARNING ") : PSTR("OK ")); - DEBUG_ECHOPGM(" OVERCURRENT: "); - echo_yes_no((status & _status_axis_ocd) != 0); - if (!(_status_axis_layout == L6474_STATUS_LAYOUT)) { // L6474 doesn't have these bits - DEBUG_ECHOPGM(" STALL: "); - echo_yes_no((status & (_status_axis_step_loss_a | _status_axis_step_loss_b)) != 0); - } - DEBUG_EOL(); - } - -#endif - -////////////////////////////////////////////////////////////////////////////////////////////////// -//// -//// MONITOR_L6470_DRIVER_STATUS routines -//// -////////////////////////////////////////////////////////////////////////////////////////////////// - -#if ENABLED(MONITOR_L6470_DRIVER_STATUS) - - bool L64XX_Marlin::monitor_paused = false; // Flag to skip monitor during M122, M906, M916, M917, M918, etc. - - struct L6470_driver_data { - L64XX_axis_t driver_index; - uint32_t driver_status; - uint8_t is_otw; - uint8_t otw_counter; - uint8_t is_ot; - uint8_t is_hi_Z; - uint8_t com_counter; - }; - - L6470_driver_data driver_L6470_data[] = { - #if AXIS_IS_L64XX(X) - { X, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(Y) - { Y, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(Z) - { Z, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(I) - { I, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(J) - { J, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(K) - { K, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(X2) - { X2, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(Y2) - { Y2, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(Z2) - { Z2, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(Z3) - { Z3, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(Z4) - { Z4, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(E0) - { E0, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(E1) - { E1, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(E2) - { E2, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(E3) - { E3, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(E4) - { E4, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(E5) - { E5, 0, 0, 0, 0, 0, 0 } - #endif - #if AXIS_IS_L64XX(E6) - { E6, 0, 0, 0, 0, 0, 0 } - #endif - #if AXIS_IS_L64XX(E7) - { E7, 0, 0, 0, 0, 0, 0 } - #endif - }; - - void L64XX_Marlin::append_stepper_err(char* &p, const uint8_t stepper_index, const char * const err/*=nullptr*/) { - PGM_P const str = (PGM_P)pgm_read_ptr(&index_to_axis[stepper_index]); - p += sprintf_P(p, PSTR("Stepper %c%c "), pgm_read_byte(&str[0]), pgm_read_byte(&str[1])); - if (err) p += sprintf_P(p, err); - } - - void L64XX_Marlin::monitor_update(L64XX_axis_t stepper_index) { - if (spi_abort) return; // don't do anything if set_directions() has occurred - const L64XX_shadow_t &sh = shadow; - get_status(stepper_index); // get stepper status and details - uint16_t status = sh.STATUS_AXIS; - uint8_t kval_hold, tval; - char temp_buf[120], *p = temp_buf; - uint8_t j; - for (j = 0; j < L64XX::chain[0]; j++) // find the table for this stepper - if (driver_L6470_data[j].driver_index == stepper_index) break; - - driver_L6470_data[j].driver_status = status; - uint16_t _status = ~status; // all error bits are active low - - if (status == 0 || status == 0xFFFF) { // com problem - if (driver_L6470_data[j].com_counter == 0) { // warn user when it first happens - driver_L6470_data[j].com_counter++; - append_stepper_err(p, stepper_index, PSTR(" - communications lost\n")); - DEBUG_ECHO(temp_buf); - } - else { - driver_L6470_data[j].com_counter++; - if (driver_L6470_data[j].com_counter > 240) { // remind of com problem about every 2 minutes - driver_L6470_data[j].com_counter = 1; - append_stepper_err(p, stepper_index, PSTR(" - still no communications\n")); - DEBUG_ECHO(temp_buf); - } - } - } - else { - if (driver_L6470_data[j].com_counter) { // comms re-established - driver_L6470_data[j].com_counter = 0; - append_stepper_err(p, stepper_index, PSTR(" - communications re-established\n.. setting all drivers to default values\n")); - DEBUG_ECHO(temp_buf); - init_to_defaults(); - } - else { - // no com problems - do the usual checks - if (_status & sh.L6470_ERROR_MASK) { - append_stepper_err(p, stepper_index); - - if (status & STATUS_HIZ) { // The driver has shut down. HiZ is active high - driver_L6470_data[j].is_hi_Z = true; - p += sprintf_P(p, PSTR("%cIS SHUT DOWN"), ' '); - //if (_status & sh.STATUS_AXIS_TH_SD) { // strange - TH_SD never seems to go active, must be implied by the HiZ and TH_WRN - if (_status & sh.STATUS_AXIS_TH_WRN) { // over current shutdown - p += sprintf_P(p, PSTR("%cdue to over temperature"), ' '); - driver_L6470_data[j].is_ot = true; - if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) { // L6474 - tval = get_param(stepper_index, L6474_TVAL) - 2 * KVAL_HOLD_STEP_DOWN; - set_param(stepper_index, L6474_TVAL, tval); // reduce TVAL - p += sprintf_P(p, PSTR(" - TVAL reduced by %d to %d mA"), uint16_t (2 * KVAL_HOLD_STEP_DOWN * sh.AXIS_STALL_CURRENT_CONSTANT_INV), uint16_t ((tval + 1) * sh.AXIS_STALL_CURRENT_CONSTANT_INV)); // let user know - } - else { - kval_hold = get_param(stepper_index, L6470_KVAL_HOLD) - 2 * KVAL_HOLD_STEP_DOWN; - set_param(stepper_index, L6470_KVAL_HOLD, kval_hold); // reduce KVAL_HOLD - p += sprintf_P(p, PSTR(" - KVAL_HOLD reduced by %d to %d"), 2 * KVAL_HOLD_STEP_DOWN, kval_hold); // let user know - } - } - else - driver_L6470_data[j].is_ot = false; - } - else { - driver_L6470_data[j].is_hi_Z = false; - - if (_status & sh.STATUS_AXIS_TH_WRN) { // have an over temperature warning - driver_L6470_data[j].is_otw = true; - driver_L6470_data[j].otw_counter++; - kval_hold = get_param(stepper_index, L6470_KVAL_HOLD); - if (driver_L6470_data[j].otw_counter > 4) { // otw present for 2 - 2.5 seconds, reduce KVAL_HOLD - driver_L6470_data[j].otw_counter = 0; - driver_L6470_data[j].is_otw = true; - if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) { // L6474 - tval = get_param(stepper_index, L6474_TVAL) - KVAL_HOLD_STEP_DOWN; - set_param(stepper_index, L6474_TVAL, tval); // reduce TVAL - p += sprintf_P(p, PSTR(" - TVAL reduced by %d to %d mA"), uint16_t (KVAL_HOLD_STEP_DOWN * sh.AXIS_STALL_CURRENT_CONSTANT_INV), uint16_t ((tval + 1) * sh.AXIS_STALL_CURRENT_CONSTANT_INV)); // let user know - } - else { - kval_hold = get_param(stepper_index, L6470_KVAL_HOLD) - KVAL_HOLD_STEP_DOWN; - set_param(stepper_index, L6470_KVAL_HOLD, kval_hold); // reduce KVAL_HOLD - p += sprintf_P(p, PSTR(" - KVAL_HOLD reduced by %d to %d"), KVAL_HOLD_STEP_DOWN, kval_hold); // let user know - } - } - else if (driver_L6470_data[j].otw_counter) - p += sprintf_P(p, PSTR("%c- thermal warning"), ' '); // warn user - } - } - - #if ENABLED(L6470_STOP_ON_ERROR) - if (_status & (sh.STATUS_AXIS_UVLO | sh.STATUS_AXIS_TH_WRN | sh.STATUS_AXIS_TH_SD)) - kill(temp_buf); - #endif - - #if ENABLED(L6470_CHITCHAT) - if (_status & sh.STATUS_AXIS_OCD) - p += sprintf_P(p, PSTR("%c over current"), ' '); - - if (_status & (sh.STATUS_AXIS_STEP_LOSS_A | sh.STATUS_AXIS_STEP_LOSS_B)) - p += sprintf_P(p, PSTR("%c stall"), ' '); - - if (_status & sh.STATUS_AXIS_UVLO) - p += sprintf_P(p, PSTR("%c under voltage lock out"), ' '); - - p += sprintf_P(p, PSTR("%c\n"), ' '); - #endif - - DEBUG_ECHOLN(temp_buf); // print the error message - } - else { - driver_L6470_data[j].is_ot = false; - driver_L6470_data[j].otw_counter = 0; //clear out warning indicators - driver_L6470_data[j].is_otw = false; - } // end usual checks - - } // comms established but have errors - } // comms re-established - } // end monitor_update() - - - void L64XX_Marlin::monitor_driver() { - static millis_t next_cOT = 0; - if (ELAPSED(millis(), next_cOT)) { - next_cOT = millis() + 500; - - if (!monitor_paused) { // Skip during M122, M906, M916, M917 or M918 (could steal status result from test) - - spi_active = true; // Tell set_directions() a series of SPI transfers is underway - - #if AXIS_IS_L64XX(X) - monitor_update(X); - #endif - #if AXIS_IS_L64XX(Y) - monitor_update(Y); - #endif - #if AXIS_IS_L64XX(Z) - monitor_update(Z); - #endif - #if AXIS_IS_L64XX(I) - monitor_update(I); - #endif - #if AXIS_IS_L64XX(J) - monitor_update(J); - #endif - #if AXIS_IS_L64XX(K) - monitor_update(K); - #endif - #if AXIS_IS_L64XX(X2) - monitor_update(X2); - #endif - #if AXIS_IS_L64XX(Y2) - monitor_update(Y2); - #endif - #if AXIS_IS_L64XX(Z2) - monitor_update(Z2); - #endif - #if AXIS_IS_L64XX(Z3) - monitor_update(Z3); - #endif - #if AXIS_IS_L64XX(Z4) - monitor_update(Z4); - #endif - #if AXIS_IS_L64XX(E0) - monitor_update(E0); - #endif - #if AXIS_IS_L64XX(E1) - monitor_update(E1); - #endif - #if AXIS_IS_L64XX(E2) - monitor_update(E2); - #endif - #if AXIS_IS_L64XX(E3) - monitor_update(E3); - #endif - #if AXIS_IS_L64XX(E4) - monitor_update(E4); - #endif - #if AXIS_IS_L64XX(E5) - monitor_update(E5); - #endif - #if AXIS_IS_L64XX(E6) - monitor_update(E6); - #endif - #if AXIS_IS_L64XX(E7) - monitor_update(E7); - #endif - - if (TERN0(L6470_DEBUG, report_L6470_status)) DEBUG_EOL(); - - spi_active = false; // done with all SPI transfers - clear handshake flags - spi_abort = false; - } - } - } - -#endif // MONITOR_L6470_DRIVER_STATUS - -#endif // HAS_L64XX diff --git a/Marlin/src/libs/L64XX/L64XX_Marlin.h b/Marlin/src/libs/L64XX/L64XX_Marlin.h deleted file mode 100644 index e8d8498ac7a6..000000000000 --- a/Marlin/src/libs/L64XX/L64XX_Marlin.h +++ /dev/null @@ -1,141 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ -#pragma once - -#include "../../inc/MarlinConfig.h" - -#include -#if !(L6470_LIBRARY_VERSION >= 0x000800) - #error 'L6470_LIBRARY_VERSION 0x000800 or later required' -#endif - -#define L6470_GETPARAM(P,Q) stepper##Q.GetParam(P) - -#define dSPIN_STEP_CLOCK 0x58 -#define dSPIN_STEP_CLOCK_FWD dSPIN_STEP_CLOCK -#define dSPIN_STEP_CLOCK_REV dSPIN_STEP_CLOCK+1 -#define HAS_L64XX_EXTRUDER (AXIS_IS_L64XX(E0) || AXIS_IS_L64XX(E1) || AXIS_IS_L64XX(E2) || AXIS_IS_L64XX(E3) || AXIS_IS_L64XX(E4) || AXIS_IS_L64XX(E5) || AXIS_IS_L64XX(E6) || AXIS_IS_L64XX(E7)) - -#define _EN_ITEM(N) , E##N -enum L64XX_axis_t : uint8_t { MAIN_AXIS_NAMES, X2, Y2, Z2, Z3, Z4 REPEAT(E_STEPPERS, _EN_ITEM), MAX_L64XX }; -#undef _EN_ITEM - -class L64XX_Marlin : public L64XXHelper { -public: - static PGM_P const index_to_axis[MAX_L64XX]; - - static const uint8_t index_to_dir[MAX_L64XX]; - - static uint8_t dir_commands[MAX_L64XX]; - - // Flags to guarantee graceful switch if stepper interrupts L6470 SPI transfer - static volatile uint8_t spi_abort; - static uint8_t spi_active; - - L64XX_Marlin() {} - - static void init(); - static void init_to_defaults(); - - static uint16_t get_stepper_status(L64XX &st); - - static uint16_t get_status(const L64XX_axis_t axis); - - static uint32_t get_param(const L64XX_axis_t axis, const uint8_t param); - - static void set_param(const L64XX_axis_t axis, const uint8_t param, const uint32_t value); - - //static void send_command(const L64XX_axis_t axis, uint8_t command); - - static uint8_t get_user_input(uint8_t &driver_count, L64XX_axis_t axis_index[3], char axis_mon[3][3], - float &position_max, float &position_min, float &final_feedrate, uint8_t &kval_hold, - uint8_t over_current_flag, uint8_t &OCD_TH_val, uint8_t &STALL_TH_val, uint16_t &over_current_threshold); - - static void transfer(uint8_t L6470_buf[], const uint8_t length); - - static void say_axis(const L64XX_axis_t axis, const uint8_t label=true); - #if ENABLED(L6470_CHITCHAT) - static void error_status_decode( - const uint16_t status, const L64XX_axis_t axis, - const uint16_t _status_axis_th_sd, const uint16_t _status_axis_th_wrn, - const uint16_t _status_axis_step_loss_a, const uint16_t _status_axis_step_loss_b, - const uint16_t _status_axis_ocd, const uint8_t _status_axis_layout - ); - #else - FORCE_INLINE static void error_status_decode( - const uint16_t, const L64XX_axis_t, - const uint16_t, const uint16_t, - const uint16_t, const uint16_t, - const uint16_t, const uint8_t - ){} - #endif - - // ~40 bytes SRAM to simplify status decode routines - typedef struct { - uint8_t STATUS_AXIS_LAYOUT; // Copy of L6470_status_layout - uint8_t AXIS_OCD_TH_MAX; // Size of OCD_TH field - uint8_t AXIS_STALL_TH_MAX; // Size of STALL_TH field - float AXIS_OCD_CURRENT_CONSTANT_INV; // mA per count - float AXIS_STALL_CURRENT_CONSTANT_INV; // mA per count - uint8_t L6470_AXIS_CONFIG, // Address of the CONFIG register - L6470_AXIS_STATUS; // Address of the STATUS register - uint16_t L6470_ERROR_MASK, // STATUS_UVLO | STATUS_TH_WRN | STATUS_TH_SD | STATUS_OCD | STATUS_STEP_LOSS_A | STATUS_STEP_LOSS_B - L6474_ERROR_MASK, // STATUS_UVLO | STATUS_TH_WRN | STATUS_TH_SD | STATUS_OCD - STATUS_AXIS_RAW, // Copy of status register contents - STATUS_AXIS, // Copy of status register contents but with all error bits active low - STATUS_AXIS_OCD, // Overcurrent detected bit position - STATUS_AXIS_SCK_MOD, // Step clock mode is active bit position - STATUS_AXIS_STEP_LOSS_A, // Stall detected on A bridge bit position - STATUS_AXIS_STEP_LOSS_B, // Stall detected on B bridge bit position - STATUS_AXIS_TH_SD, // Thermal shutdown bit position - STATUS_AXIS_TH_WRN, // Thermal warning bit position - STATUS_AXIS_UVLO, // Undervoltage lockout is active bit position - STATUS_AXIS_WRONG_CMD, // Last command not valid bit position - STATUS_AXIS_CMD_ERR, // Command error bit position - STATUS_AXIS_NOTPERF_CMD; // Last command not performed bit position - } L64XX_shadow_t; - - static L64XX_shadow_t shadow; - - #if ENABLED(MONITOR_L6470_DRIVER_STATUS) - static bool monitor_paused; - static void pause_monitor(const bool p) { monitor_paused = p; } - static void monitor_update(L64XX_axis_t stepper_index); - static void monitor_driver(); - #else - static void pause_monitor(const bool) {} - #endif - -//protected: - // L64XXHelper methods - static void spi_init(); - static uint8_t transfer_single(uint8_t data, int16_t ss_pin); - static uint8_t transfer_chain(uint8_t data, int16_t ss_pin, uint8_t chain_position); - -private: - static void append_stepper_err(char* &p, const uint8_t stepper_index, const char * const err=nullptr); - -}; - -void echo_yes_no(const bool yes); - -extern L64XX_Marlin L64xxManager; diff --git a/Marlin/src/libs/L64XX/README.md b/Marlin/src/libs/L64XX/README.md deleted file mode 100644 index d28bec5e67f5..000000000000 --- a/Marlin/src/libs/L64XX/README.md +++ /dev/null @@ -1,98 +0,0 @@ -### L64XX Stepper Driver - -*Arduino-L6470* library revision 0.8.0 or above is required. - -This software can be used with the L6470, L6474, L6480 and the powerSTEP01 (collectively referred to as "L64xx" from now on). Different drivers can be mixed within a system. - -These devices use voltage PWMs to drive the stepper phases. On the L6474 the phase current is controlled by the `TVAL` register. On all the other drivers the phase current is indirectly controlled via the `KVAL_HOLD` register which scales the PWM duty cycle. - -This software assumes that all drivers are in one SPI daisy chain. - -### Hardware Setup - -- MOSI from controller tied to SDI on the first device - -- SDO of the first device is tied to SDI of the next device - -- SDO of the last device is tied to MISO of the controller - -- All devices share the same `SCK_PIN` and `SS_PIN` pins. The user must supply a macro to control the `RESET_PIN`(s). - -- Each L6470 passes the data it saw on its SDI to its neighbor on the **NEXT** SPI cycle (8 bit delay). - -- Each L6470 acts on the **last** SPI data it saw when the `SS_PIN` **goes high**. - -The L6474 uses the standard STEP DIR interface. Phase currents are changed in response to step pulses. The direction is set by the DIR pin. Instead of an ENA pin, stepper power is controlled with SPI commands. - -The other drivers operate in `STEP_CLOCK` mode. In this mode the Direction / Enable functions are done with SPI commands and the phase currents are changed in response to STEP pulses. - -### Hardware / Software Interaction - -Except for the L6474, powering up a stepper and setting the direction are done by the same command. You can't do one without the other. - -**All** directions are set **every time** a new block is popped off the queue by the stepper ISR. - -When setting direction, SPI transfers are minimized by using arrays and a specialized SPI method. *Arduino-L6470* library calls are not used. For N L64xx drivers, this results in N bytes transferred. If library calls were used then N2 bytes would be sent. - -### Power-up (Reset) Sequence - -- Stepper objects are instantiated before the `setup()` entry point is reached. - -- In `setup()` (before stepper drivers are initialized) the `L6470_init()` method is called to do the following: - - - If present, pulse the hardware reset pin. - - - Populate the `L6470_chain` array, which maps positions in the SPI stream to commands/data for L64XX stepper drivers. - - - Initialize the L64XX Software SPI pin states. - - - Initialize L64XX drivers. They may be reset later by a call to `L6470_init_to_defaults()`. - -The steppers are **NOT** powered up (enabled) during this sequence. - -### `L6470_chain` array - -This array is used by all routines that transmit SPI data. For a chain with N devices, the array contains: - -Index|Value ------|----- -0|Number of drivers in chain -1|Axis index of the first device in the chain (closest to MOSI) -...| -N|Axis index of the last device chain (closest to MISO) - -### Set Direction and Enable - -The `DIR_WRITE` macros for the L64xx drivers are written so that the standard X, Y, Z and extruder logic used by the `set_directions()` routine is not altered. These macros write the correct forward/reverse command to the corresponding location in the array `L6470_dir_commands`. On the L6474 the array the command used just enables the stepper because direction is set by the DIR pin. - -At the end of the `set_directions()` routine, the array `L6470_chain` is used to grab the corresponding direction/enable commands out of the array `L6470_dir_commands` and put them in the correct sequence in the array `L6470_buf`. Array `L6470_buf` is then passed to the **`void`** `L6470_Transfer` function which actually sends the data to the devices. - -### Utilities, etc. - -The **absolute position** registers should accurately reflect Marlin’s stepper position counts. They are set to zero during initialization. `G28` sets them to the Marlin counts for the corresponding axis after homing. NOTE: These registers are often the negative of the Marlin counts. This is because the Marlin counts reflect the logical direction while the registers reflect the stepper direction. The register contents are displayed via the `M114 D` command. - -The `L6470_monitor` feature reads the status of each device every half second. It will report if there are any error conditions present or if communications has been lost/restored. The `KVAL_HOLD` value is reduced every 2 – 2.5 seconds if the thermal warning or thermal shutdown conditions are present. - -**M122** displays the settings of most of the bits in the status register plus a couple of other items. - -**M906** can be used to set the `KVAL_HOLD` register (`TVAL` on L6474) one driver at a time. If a setting is not included with the command then the contents of the registers that affect the phase current/voltage are displayed. - -**M916, M917 & M918** - -These utilities are used to tune the system. They can get you in the ballpark for acceptable jerk, acceleration, top speed and `KVAL_HOLD` settings (`TVAL` on L6474). In general they seem to provide an overly optimistic `KVAL_HOLD` (`TVAL`) setting because of the lag between setting `KVAL_HOLD` (`TVAL`) and the driver reaching final temperature. Enabling the `L6470_monitor` feature during prints will provide the **final useful setting**. - -The amount of power needed to move the stepper without skipping steps increases as jerk, acceleration, top speed, and micro-steps increase. The power dissipated by the driver increases as the power to the stepper increases. The net result is a balancing act between jerk, acceleration, top speed, micro-steps, and power dissipated by the driver. - -**M916** - Increases `KVAL_HOLD` (`TVAL`) while moving one axis until a thermal warning is generated. This routine is also useful for determining the approximate `KVAL_HOLD` (`TVAL`) where the stepper stops losing steps. The sound will get noticeably quieter as it stops losing steps. - -**M917** - Find minimum current thresholds. This is accomplished by doing the following steps while moving an axis: - -1. Decrease OCD current until overcurrent error. - -2. Increase OCD until overcurrent error goes away. - -3. Decrease stall threshold until stall error (not available on the L6474). - -4. Increase stall until stall error goes away (not available on the L6474). - -**M918** - Increase speed until error or max feedrate achieved. diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 2bacc556060b..593c8f7c6f7e 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -117,12 +117,6 @@ Stepper stepper; // Singleton #include "../feature/runout.h" #endif -#if HAS_L64XX - #include "../libs/L64XX/L64XX_Marlin.h" - uint8_t L6470_buf[MAX_L64XX + 1]; // chip command sequence - element 0 not used - bool L64XX_OK_to_power_up = false; // flag to keep L64xx steppers powered down after a reset or power up -#endif - #if ENABLED(AUTO_POWER_CONTROL) #include "../feature/power.h" #endif @@ -618,27 +612,6 @@ void Stepper::set_directions() { #endif #endif // !LIN_ADVANCE - #if HAS_L64XX - if (L64XX_OK_to_power_up) { // OK to send the direction commands (which powers up the L64XX steppers) - if (L64xxManager.spi_active) { - L64xxManager.spi_abort = true; // Interrupted SPI transfer needs to shut down gracefully - for (uint8_t j = 1; j <= L64XX::chain[0]; j++) - L6470_buf[j] = dSPIN_NOP; // Fill buffer with NOOPs - L64xxManager.transfer(L6470_buf, L64XX::chain[0]); // Send enough NOOPs to complete any command - L64xxManager.transfer(L6470_buf, L64XX::chain[0]); - L64xxManager.transfer(L6470_buf, L64XX::chain[0]); - } - - // L64xxManager.dir_commands[] is an array that holds direction command for each stepper - - // Scan command array, copy matches into L64xxManager.transfer - for (uint8_t j = 1; j <= L64XX::chain[0]; j++) - L6470_buf[j] = L64xxManager.dir_commands[L64XX::chain[j]]; - - L64xxManager.transfer(L6470_buf, L64XX::chain[0]); // send the command stream to the drivers - } - #endif - DIR_WAIT_AFTER(); } @@ -2351,13 +2324,11 @@ uint32_t Stepper::block_phase_isr() { else LA_isr_rate = LA_ADV_NEVER; #endif - if ( ENABLED(HAS_L64XX) // Always set direction for L64xx (Also enables the chips) - || ENABLED(DUAL_X_CARRIAGE) // TODO: Find out why this fixes "jittery" small circles + if ( ENABLED(DUAL_X_CARRIAGE) // TODO: Find out why this fixes "jittery" small circles || current_block->direction_bits != last_direction_bits || TERN(MIXING_EXTRUDER, false, stepper_extruder != last_moved_extruder) ) { E_TERN_(last_moved_extruder = stepper_extruder); - TERN_(HAS_L64XX, L64XX_OK_to_power_up = true); set_directions(current_block->direction_bits); } diff --git a/Marlin/src/module/stepper/L64xx.cpp b/Marlin/src/module/stepper/L64xx.cpp deleted file mode 100644 index 5b607463969f..000000000000 --- a/Marlin/src/module/stepper/L64xx.cpp +++ /dev/null @@ -1,264 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -/** - * stepper/L64xx.cpp - * Stepper driver indirection for L64XX drivers - */ - -#include "../../inc/MarlinConfig.h" - -#if HAS_L64XX - -#include "L64xx.h" - -#if AXIS_IS_L64XX(X) - L64XX_CLASS(X) stepperX(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(X2) - L64XX_CLASS(X2) stepperX2(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(Y) - L64XX_CLASS(Y) stepperY(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(Y2) - L64XX_CLASS(Y2) stepperY2(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(Z) - L64XX_CLASS(Z) stepperZ(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(Z2) - L64XX_CLASS(Z2) stepperZ2(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(Z3) - L64XX_CLASS(Z3) stepperZ3(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(Z4) - L64XX_CLASS(Z4) stepperZ4(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(I) - L64XX_CLASS(I) stepperI(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(J) - L64XX_CLASS(J) stepperJ(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(K) - L64XX_CLASS(K) stepperK(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(U) - L64XX_CLASS(u) stepperU(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(V) - L64XX_CLASS(v) stepperV(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(W) - L64XX_CLASS(w) stepperW(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(E0) - L64XX_CLASS(E0) stepperE0(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(E1) - L64XX_CLASS(E1) stepperE1(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(E2) - L64XX_CLASS(E2) stepperE2(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(E3) - L64XX_CLASS(E3) stepperE3(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(E4) - L64XX_CLASS(E4) stepperE4(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(E5) - L64XX_CLASS(E5) stepperE5(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(E6) - L64XX_CLASS(E6) stepperE6(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(E7) - L64XX_CLASS(E7) stepperE7(L6470_CHAIN_SS_PIN); -#endif - -// Not using L64XX class init method because it -// briefly sends power to the steppers - -inline void L6470_init_chip(L64XX &st, const int ms, const int oc, const int sc, const int mv, const int slew_rate) { - st.set_handlers(L64xxManager.spi_init, L64xxManager.transfer_single, L64xxManager.transfer_chain); // specify which external SPI routines to use - switch (st.L6470_status_layout) { - case L6470_STATUS_LAYOUT: { - st.resetDev(); - st.softFree(); - st.SetParam(st.L64XX_CONFIG, CONFIG_PWM_DIV_1 | CONFIG_PWM_MUL_2 | CONFIG_OC_SD_DISABLE | CONFIG_VS_COMP_DISABLE | CONFIG_SW_HARD_STOP | CONFIG_INT_16MHZ); - st.SetParam(L6470_KVAL_RUN, 0xFF); - st.SetParam(L6470_KVAL_ACC, 0xFF); - st.SetParam(L6470_KVAL_DEC, 0xFF); - st.setMicroSteps(ms); - st.setOverCurrent(oc); - st.setStallCurrent(sc); - st.SetParam(L6470_KVAL_HOLD, mv); - st.SetParam(L6470_ABS_POS, 0); - uint32_t config_temp = st.GetParam(st.L64XX_CONFIG); - config_temp &= ~CONFIG_POW_SR; - switch (slew_rate) { - case 0: st.SetParam(st.L64XX_CONFIG, config_temp | CONFIG_SR_75V_us); break; - default: - case 1: st.SetParam(st.L64XX_CONFIG, config_temp | CONFIG_SR_110V_us); break; - case 3: - case 2: st.SetParam(st.L64XX_CONFIG, config_temp | CONFIG_SR_260V_us); break; - } - st.getStatus(); - st.getStatus(); - break; - } - - case L6474_STATUS_LAYOUT: { - st.free(); - //st.SetParam(st.L64XX_CONFIG, CONFIG_PWM_DIV_1 | CONFIG_PWM_MUL_2 | CONFIG_OC_SD_DISABLE | CONFIG_VS_COMP_DISABLE | CONFIG_SW_HARD_STOP | CONFIG_INT_16MHZ); - //st.SetParam(L6474_TVAL, 0xFF); - st.setMicroSteps(ms); - st.setOverCurrent(oc); - st.setTVALCurrent(sc); - st.SetParam(L6470_ABS_POS, 0); - uint32_t config_temp = st.GetParam(st.L64XX_CONFIG); - config_temp &= ~CONFIG_POW_SR & ~CONFIG_EN_TQREG; // clear out slew rate and set current to be controlled by TVAL register - switch (slew_rate) { - case 0: st.SetParam(st.L64XX_CONFIG, config_temp | CONFIG_SR_75V_us); break; - default: - case 1: st.SetParam(st.L64XX_CONFIG, config_temp | CONFIG_SR_110V_us); break; - case 3: - case 2: st.SetParam(st.L64XX_CONFIG, config_temp | CONFIG_SR_260V_us); break; - //case 0: st.SetParam(st.L64XX_CONFIG, 0x2E88 | CONFIG_EN_TQREG | CONFIG_SR_75V_us); break; - //default: - //case 1: st.SetParam(st.L64XX_CONFIG, 0x2E88 | CONFIG_EN_TQREG | CONFIG_SR_110V_us); break; - //case 3: - //case 2: st.SetParam(st.L64XX_CONFIG, 0x2E88 | CONFIG_EN_TQREG | CONFIG_SR_260V_us); break; - - //case 0: st.SetParam(st.L64XX_CONFIG, 0x2E88 ); break; - //default: - //case 1: st.SetParam(st.L64XX_CONFIG, 0x2E88 ); break; - //case 3: - //case 2: st.SetParam(st.L64XX_CONFIG, 0x2E88 ); break; - } - st.getStatus(); - st.getStatus(); - break; - } - - case L6480_STATUS_LAYOUT: { - st.resetDev(); - st.softFree(); - st.SetParam(st.L64XX_CONFIG, CONFIG_PWM_DIV_1 | CONFIG_PWM_MUL_2 | CONFIG_OC_SD_DISABLE | CONFIG_VS_COMP_DISABLE | CONFIG_SW_HARD_STOP | CONFIG_INT_16MHZ); - st.SetParam(L6470_KVAL_RUN, 0xFF); - st.SetParam(L6470_KVAL_ACC, 0xFF); - st.SetParam(L6470_KVAL_DEC, 0xFF); - st.setMicroSteps(ms); - st.setOverCurrent(oc); - st.setStallCurrent(sc); - st.SetParam(+-L6470_KVAL_HOLD, mv); - st.SetParam(L6470_ABS_POS, 0); - st.SetParam(st.L64XX_CONFIG,(st.GetParam(st.L64XX_CONFIG) | PWR_VCC_7_5V)); - st.getStatus(); // must clear out status bits before can set slew rate - st.getStatus(); - switch (slew_rate) { - case 0: st.SetParam(L6470_GATECFG1, CONFIG1_SR_220V_us); st.SetParam(L6470_GATECFG2, CONFIG2_SR_220V_us); break; - default: - case 1: st.SetParam(L6470_GATECFG1, CONFIG1_SR_400V_us); st.SetParam(L6470_GATECFG2, CONFIG2_SR_400V_us); break; - case 2: st.SetParam(L6470_GATECFG1, CONFIG1_SR_520V_us); st.SetParam(L6470_GATECFG2, CONFIG2_SR_520V_us); break; - case 3: st.SetParam(L6470_GATECFG1, CONFIG1_SR_980V_us); st.SetParam(L6470_GATECFG2, CONFIG2_SR_980V_us); break; - } - break; - } - } -} - -#define L6470_INIT_CHIP(Q) L6470_init_chip(stepper##Q, Q##_MICROSTEPS, Q##_OVERCURRENT, Q##_STALLCURRENT, Q##_MAX_VOLTAGE, Q##_SLEW_RATE) - -void L64XX_Marlin::init_to_defaults() { - #if AXIS_IS_L64XX(X) - L6470_INIT_CHIP(X); - #endif - #if AXIS_IS_L64XX(X2) - L6470_INIT_CHIP(X2); - #endif - #if AXIS_IS_L64XX(Y) - L6470_INIT_CHIP(Y); - #endif - #if AXIS_IS_L64XX(Y2) - L6470_INIT_CHIP(Y2); - #endif - #if AXIS_IS_L64XX(Z) - L6470_INIT_CHIP(Z); - #endif - #if AXIS_IS_L64XX(Z2) - L6470_INIT_CHIP(Z2); - #endif - #if AXIS_IS_L64XX(Z3) - L6470_INIT_CHIP(Z3); - #endif - #if AXIS_IS_L64XX(Z4) - L6470_INIT_CHIP(Z4); - #endif - #if AXIS_IS_L64XX(I) - L6470_INIT_CHIP(I); - #endif - #if AXIS_IS_L64XX(J) - L6470_INIT_CHIP(J); - #endif - #if AXIS_IS_L64XX(K) - L6470_INIT_CHIP(K); - #endif - #if AXIS_IS_L64XX(U) - L6470_INIT_CHIP(U); - #endif - #if AXIS_IS_L64XX(V) - L6470_INIT_CHIP(V); - #endif - #if AXIS_IS_L64XX(W) - L6470_INIT_CHIP(W); - #endif - #if AXIS_IS_L64XX(E0) - L6470_INIT_CHIP(E0); - #endif - #if AXIS_IS_L64XX(E1) - L6470_INIT_CHIP(E1); - #endif - #if AXIS_IS_L64XX(E2) - L6470_INIT_CHIP(E2); - #endif - #if AXIS_IS_L64XX(E3) - L6470_INIT_CHIP(E3); - #endif - #if AXIS_IS_L64XX(E4) - L6470_INIT_CHIP(E4); - #endif - #if AXIS_IS_L64XX(E5) - L6470_INIT_CHIP(E5); - #endif - #if AXIS_IS_L64XX(E6) - L6470_INIT_CHIP(E6); - #endif - #if AXIS_IS_L64XX(E7) - L6470_INIT_CHIP(E7); - #endif -} - -#endif // HAS_L64XX diff --git a/Marlin/src/module/stepper/L64xx.h b/Marlin/src/module/stepper/L64xx.h deleted file mode 100644 index 870b0414f8eb..000000000000 --- a/Marlin/src/module/stepper/L64xx.h +++ /dev/null @@ -1,490 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ -#pragma once - -/** - * stepper/L64xx.h - * Stepper driver indirection for L64XX drivers - */ - -#include "../../inc/MarlinConfig.h" -#include "../../libs/L64XX/L64XX_Marlin.h" - -// Convert option names to L64XX classes -#define CLASS_L6470 L6470 -#define CLASS_L6474 L6474 -#define CLASS_POWERSTEP01 powerSTEP01 - -#define __L64XX_CLASS(TYPE) CLASS_##TYPE -#define _L64XX_CLASS(TYPE) __L64XX_CLASS(TYPE) -#define L64XX_CLASS(ST) _L64XX_CLASS(ST##_DRIVER_TYPE) - -#define L6474_DIR_WRITE(A,STATE) do{ L64xxManager.dir_commands[A] = dSPIN_L6474_ENABLE; WRITE(A##_DIR_PIN, STATE); }while(0) -#define L64XX_DIR_WRITE(A,STATE) do{ L64xxManager.dir_commands[A] = (STATE) ? dSPIN_STEP_CLOCK_REV : dSPIN_STEP_CLOCK_FWD; }while(0) - -// X Stepper -#if AXIS_IS_L64XX(X) - extern L64XX_CLASS(X) stepperX; - #define X_ENABLE_INIT() NOOP - #define X_ENABLE_WRITE(STATE) (STATE ? stepperX.hardStop() : stepperX.free()) - #define X_ENABLE_READ() (stepperX.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_X(L6474) - #define X_DIR_INIT() SET_OUTPUT(X_DIR_PIN) - #define X_DIR_WRITE(STATE) L6474_DIR_WRITE(X, STATE) - #define X_DIR_READ() READ(X_DIR_PIN) - #else - #define X_DIR_INIT() NOOP - #define X_DIR_WRITE(STATE) L64XX_DIR_WRITE(X, STATE) - #define X_DIR_READ() (stepper##X.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_X(L6470) - #define DISABLE_STEPPER_X() stepperX.free() - #endif - #endif -#endif - -// Y Stepper -#if AXIS_IS_L64XX(Y) - extern L64XX_CLASS(Y) stepperY; - #define Y_ENABLE_INIT() NOOP - #define Y_ENABLE_WRITE(STATE) (STATE ? stepperY.hardStop() : stepperY.free()) - #define Y_ENABLE_READ() (stepperY.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_Y(L6474) - #define Y_DIR_INIT() SET_OUTPUT(Y_DIR_PIN) - #define Y_DIR_WRITE(STATE) L6474_DIR_WRITE(Y, STATE) - #define Y_DIR_READ() READ(Y_DIR_PIN) - #else - #define Y_DIR_INIT() NOOP - #define Y_DIR_WRITE(STATE) L64XX_DIR_WRITE(Y, STATE) - #define Y_DIR_READ() (stepper##Y.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_Y(L6470) - #define DISABLE_STEPPER_Y() stepperY.free() - #endif - #endif -#endif - -// Z Stepper -#if AXIS_IS_L64XX(Z) - extern L64XX_CLASS(Z) stepperZ; - #define Z_ENABLE_INIT() NOOP - #define Z_ENABLE_WRITE(STATE) (STATE ? stepperZ.hardStop() : stepperZ.free()) - #define Z_ENABLE_READ() (stepperZ.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_Z(L6474) - #define Z_DIR_INIT() SET_OUTPUT(Z_DIR_PIN) - #define Z_DIR_WRITE(STATE) L6474_DIR_WRITE(Z, STATE) - #define Z_DIR_READ() READ(Z_DIR_PIN) - #else - #define Z_DIR_INIT() NOOP - #define Z_DIR_WRITE(STATE) L64XX_DIR_WRITE(Z, STATE) - #define Z_DIR_READ() (stepper##Z.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_Z(L6470) - #define DISABLE_STEPPER_Z() stepperZ.free() - #endif - #endif -#endif - -// X2 Stepper -#if HAS_X2_ENABLE && AXIS_IS_L64XX(X2) - extern L64XX_CLASS(X2) stepperX2; - #define X2_ENABLE_INIT() NOOP - #define X2_ENABLE_WRITE(STATE) (STATE ? stepperX2.hardStop() : stepperX2.free()) - #define X2_ENABLE_READ() (stepperX2.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_X2(L6474) - #define X2_DIR_INIT() SET_OUTPUT(X2_DIR_PIN) - #define X2_DIR_WRITE(STATE) L6474_DIR_WRITE(X2, STATE) - #define X2_DIR_READ() READ(X2_DIR_PIN) - #else - #define X2_DIR_INIT() NOOP - #define X2_DIR_WRITE(STATE) L64XX_DIR_WRITE(X2, STATE) - #define X2_DIR_READ() (stepper##X2.getStatus() & STATUS_DIR); - #endif -#endif - -#if AXIS_DRIVER_TYPE_X2(L6470) - #define DISABLE_STEPPER_X2() stepperX2.free() -#endif - -// Y2 Stepper -#if HAS_Y2_ENABLE && AXIS_IS_L64XX(Y2) - extern L64XX_CLASS(Y2) stepperY2; - #define Y2_ENABLE_INIT() NOOP - #define Y2_ENABLE_WRITE(STATE) (STATE ? stepperY2.hardStop() : stepperY2.free()) - #define Y2_ENABLE_READ() (stepperY2.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_Y2(L6474) - #define Y2_DIR_INIT() SET_OUTPUT(Y2_DIR_PIN) - #define Y2_DIR_WRITE(STATE) L6474_DIR_WRITE(Y2, STATE) - #define Y2_DIR_READ() READ(Y2_DIR_PIN) - #else - #define Y2_DIR_INIT() NOOP - #define Y2_DIR_WRITE(STATE) L64XX_DIR_WRITE(Y2, STATE) - #define Y2_DIR_READ() (stepper##Y2.getStatus() & STATUS_DIR); - #endif -#endif - -#if AXIS_DRIVER_TYPE_Y2(L6470) - #define DISABLE_STEPPER_Y2() stepperY2.free() -#endif - -// Z2 Stepper -#if HAS_Z2_ENABLE && AXIS_IS_L64XX(Z2) - extern L64XX_CLASS(Z2) stepperZ2; - #define Z2_ENABLE_INIT() NOOP - #define Z2_ENABLE_WRITE(STATE) (STATE ? stepperZ2.hardStop() : stepperZ2.free()) - #define Z2_ENABLE_READ() (stepperZ2.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_Z2(L6474) - #define Z2_DIR_INIT() SET_OUTPUT(Z2_DIR_PIN) - #define Z2_DIR_WRITE(STATE) L6474_DIR_WRITE(Z2, STATE) - #define Z2_DIR_READ() READ(Z2_DIR_PIN) - #else - #define Z2_DIR_INIT() NOOP - #define Z2_DIR_WRITE(STATE) L64XX_DIR_WRITE(Z2, STATE) - #define Z2_DIR_READ() (stepper##Z2.getStatus() & STATUS_DIR); - #endif -#endif - -#if AXIS_DRIVER_TYPE_Z2(L6470) - #define DISABLE_STEPPER_Z2() stepperZ2.free() -#endif - -// Z3 Stepper -#if HAS_Z3_ENABLE && AXIS_IS_L64XX(Z3) - extern L64XX_CLASS(Z3) stepperZ3; - #define Z3_ENABLE_INIT() NOOP - #define Z3_ENABLE_WRITE(STATE) (STATE ? stepperZ3.hardStop() : stepperZ3.free()) - #define Z3_ENABLE_READ() (stepperZ3.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_Z3(L6474) - #define Z3_DIR_INIT() SET_OUTPUT(Z3_DIR_PIN) - #define Z3_DIR_WRITE(STATE) L6474_DIR_WRITE(Z3, STATE) - #define Z3_DIR_READ() READ(Z3_DIR_PIN) - #else - #define Z3_DIR_INIT() NOOP - #define Z3_DIR_WRITE(STATE) L64XX_DIR_WRITE(Z3, STATE) - #define Z3_DIR_READ() (stepper##Z3.getStatus() & STATUS_DIR); - #endif -#endif - -#if AXIS_DRIVER_TYPE_Z3(L6470) - #define DISABLE_STEPPER_Z3() stepperZ3.free() -#endif - -// Z4 Stepper -#if HAS_Z4_ENABLE && AXIS_IS_L64XX(Z4) - extern L64XX_CLASS(Z4) stepperZ4; - #define Z4_ENABLE_INIT() NOOP - #define Z4_ENABLE_WRITE(STATE) (STATE ? stepperZ4.hardStop() : stepperZ4.free()) - #define Z4_ENABLE_READ() (stepperZ4.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_Z4(L6474) - #define Z4_DIR_INIT() SET_OUTPUT(Z4_DIR_PIN) - #define Z4_DIR_WRITE(STATE) L6474_DIR_WRITE(Z4, STATE) - #define Z4_DIR_READ() READ(Z4_DIR_PIN) - #else - #define Z4_DIR_INIT() NOOP - #define Z4_DIR_WRITE(STATE) L64XX_DIR_WRITE(Z4, STATE) - #define Z4_DIR_READ() (stepper##Z4.getStatus() & STATUS_DIR); - #endif -#endif - -#if AXIS_DRIVER_TYPE_Z4(L6470) - #define DISABLE_STEPPER_Z4() stepperZ4.free() -#endif - -// I Stepper -#if AXIS_IS_L64XX(I) - extern L64XX_CLASS(I) stepperI; - #define I_ENABLE_INIT() NOOP - #define I_ENABLE_WRITE(STATE) (STATE ? stepperI.hardStop() : stepperI.free()) - #define I_ENABLE_READ() (stepperI.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_I(L6474) - #define I_DIR_INIT() SET_OUTPUT(I_DIR_PIN) - #define I_DIR_WRITE(STATE) L6474_DIR_WRITE(I, STATE) - #define I_DIR_READ() READ(I_DIR_PIN) - #else - #define I_DIR_INIT() NOOP - #define I_DIR_WRITE(STATE) L64XX_DIR_WRITE(I, STATE) - #define I_DIR_READ() (stepper##I.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_I(L6470) - #define DISABLE_STEPPER_I() stepperI.free() - #endif - #endif -#endif - -// J Stepper -#if AXIS_IS_L64XX(J) - extern L64XX_CLASS(J) stepperJ; - #define J_ENABLE_INIT() NOOP - #define J_ENABLE_WRITE(STATE) (STATE ? stepperJ.hardStop() : stepperJ.free()) - #define J_ENABLE_READ() (stepperJ.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_J(L6474) - #define J_DIR_INIT() SET_OUTPUT(J_DIR_PIN) - #define J_DIR_WRITE(STATE) L6474_DIR_WRITE(J, STATE) - #define J_DIR_READ() READ(J_DIR_PIN) - #else - #define J_DIR_INIT() NOOP - #define J_DIR_WRITE(STATE) L64XX_DIR_WRITE(J, STATE) - #define J_DIR_READ() (stepper##J.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_J(L6470) - #define DISABLE_STEPPER_J() stepperJ.free() - #endif - #endif -#endif - -// K Stepper -#if AXIS_IS_L64XX(K) - extern L64XX_CLASS(K) stepperK; - #define K_ENABLE_INIT() NOOP - #define K_ENABLE_WRITE(STATE) (STATE ? stepperK.hardStop() : stepperK.free()) - #define K_ENABLE_READ() (stepperK.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_K(L6474) - #define K_DIR_INIT() SET_OUTPUT(K_DIR_PIN) - #define K_DIR_WRITE(STATE) L6474_DIR_WRITE(K, STATE) - #define K_DIR_READ() READ(K_DIR_PIN) - #else - #define K_DIR_INIT() NOOP - #define K_DIR_WRITE(STATE) L64XX_DIR_WRITE(K, STATE) - #define K_DIR_READ() (stepper##K.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_K(L6470) - #define DISABLE_STEPPER_K() stepperK.free() - #endif - #endif -#endif - -// U Stepper -#if HAS_U_AXIS - #if AXIS_IS_L64XX(U) - extern L64XX_CLASS(U) stepperU; - #define U_ENABLE_INIT() NOOP - #define U_ENABLE_WRITE(STATE) (STATE ? stepperU.hardStop() : stepperU.free()) - #define U_ENABLE_READ() (stepperU.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_U(L6474) - #define U_DIR_INIT() SET_OUTPUT(U_DIR_PIN) - #define U_DIR_WRITE(STATE) L6474_DIR_WRITE(U, STATE) - #define U_DIR_READ() READ(U_DIR_PIN) - #else - #define U_DIR_INIT() NOOP - #define U_DIR_WRITE(STATE) L64XX_DIR_WRITE(U, STATE) - #define U_DIR_READ() (stepper##U.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_U(L6470) - #define DISABLE_STEPPER_U() stepperU.free() - #endif - #endif - #endif -#endif - -// V Stepper -#if HAS_V_AXIS - #if AXIS_IS_L64XX(V) - extern L64XX_CLASS(V) stepperV; - #define V_ENABLE_INIT() NOOP - #define V_ENABLE_WRITE(STATE) (STATE ? stepperV.hardStop() : stepperV.free()) - #define V_ENABLE_READ() (stepperV.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_V(L6474) - #define V_DIR_INIT() SET_OUTPUT(V_DIR_PIN) - #define V_DIR_WRITE(STATE) L6474_DIR_WRITE(V, STATE) - #define V_DIR_READ() READ(V_DIR_PIN) - #else - #define V_DIR_INIT() NOOP - #define V_DIR_WRITE(STATE) L64XX_DIR_WRITE(V, STATE) - #define V_DIR_READ() (stepper##V.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_V(L6470) - #define DISABLE_STEPPER_V() stepperV.free() - #endif - #endif - #endif -#endif - -// W Stepper -#if HAS_W_AXIS - #if AXIS_IS_L64XX(W) - extern L64XX_CLASS(w) stepperW; - #define W_ENABLE_INIT() NOOP - #define W_ENABLE_WRITE(STATE) (STATE ? stepperW.hardStop() : stepperW.free()) - #define W_ENABLE_READ() (stepperW.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_W(L6474) - #define W_DIR_INIT() SET_OUTPUT(W_DIR_PIN) - #define W_DIR_WRITE(STATE) L6474_DIR_WRITE(W, STATE) - #define W_DIR_READ() READ(W_DIR_PIN) - #else - #define W_DIR_INIT() NOOP - #define W_DIR_WRITE(STATE) L64XX_DIR_WRITE(W, STATE) - #define W_DIR_READ() (stepper##W.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_W(L6470) - #define DISABLE_STEPPER_W() stepperW.free() - #endif - #endif - #endif -#endif - -// E0 Stepper -#if AXIS_IS_L64XX(E0) - extern L64XX_CLASS(E0) stepperE0; - #define E0_ENABLE_INIT() NOOP - #define E0_ENABLE_WRITE(STATE) (STATE ? stepperE0.hardStop() : stepperE0.free()) - #define E0_ENABLE_READ() (stepperE0.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_E0(L6474) - #define E0_DIR_INIT() SET_OUTPUT(E0_DIR_PIN) - #define E0_DIR_WRITE(STATE) L6474_DIR_WRITE(E0, STATE) - #define E0_DIR_READ() READ(E0_DIR_PIN) - #else - #define E0_DIR_INIT() NOOP - #define E0_DIR_WRITE(STATE) L64XX_DIR_WRITE(E0, STATE) - #define E0_DIR_READ() (stepper##E0.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_E0(L6470) - #define DISABLE_STEPPER_E0() do{ stepperE0.free(); }while(0) - #endif - #endif -#endif - -// E1 Stepper -#if AXIS_IS_L64XX(E1) - extern L64XX_CLASS(E1) stepperE1; - #define E1_ENABLE_INIT() NOOP - #define E1_ENABLE_WRITE(STATE) (STATE ? stepperE1.hardStop() : stepperE1.free()) - #define E1_ENABLE_READ() (stepperE1.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_E1(L6474) - #define E1_DIR_INIT() SET_OUTPUT(E1_DIR_PIN) - #define E1_DIR_WRITE(STATE) L6474_DIR_WRITE(E1, STATE) - #define E1_DIR_READ() READ(E1_DIR_PIN) - #else - #define E1_DIR_INIT() NOOP - #define E1_DIR_WRITE(STATE) L64XX_DIR_WRITE(E1, STATE) - #define E1_DIR_READ() (stepper##E1.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_E1(L6470) - #define DISABLE_STEPPER_E1() do{ stepperE1.free(); }while(0) - #endif - #endif -#endif - -// E2 Stepper -#if AXIS_IS_L64XX(E2) - extern L64XX_CLASS(E2) stepperE2; - #define E2_ENABLE_INIT() NOOP - #define E2_ENABLE_WRITE(STATE) (STATE ? stepperE2.hardStop() : stepperE2.free()) - #define E2_ENABLE_READ() (stepperE2.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_E2(L6474) - #define E2_DIR_INIT() SET_OUTPUT(E2_DIR_PIN) - #define E2_DIR_WRITE(STATE) L6474_DIR_WRITE(E2, STATE) - #define E2_DIR_READ() READ(E2_DIR_PIN) - #else - #define E2_DIR_INIT() NOOP - #define E2_DIR_WRITE(STATE) L64XX_DIR_WRITE(E2, STATE) - #define E2_DIR_READ() (stepper##E2.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_E2(L6470) - #define DISABLE_STEPPER_E2() do{ stepperE2.free(); }while(0) - #endif - #endif -#endif - -// E3 Stepper -#if AXIS_IS_L64XX(E3) - extern L64XX_CLASS(E3) stepperE3; - #define E3_ENABLE_INIT() NOOP - #define E3_ENABLE_WRITE(STATE) (STATE ? stepperE3.hardStop() : stepperE3.free()) - #define E3_ENABLE_READ() (stepperE3.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_E3(L6474) - #define E3_DIR_INIT() SET_OUTPUT(E3_DIR_PIN) - #define E3_DIR_WRITE(STATE) L6474_DIR_WRITE(E3, STATE) - #define E3_DIR_READ() READ(E3_DIR_PIN) - #else - #define E3_DIR_INIT() NOOP - #define E3_DIR_WRITE(STATE) L64XX_DIR_WRITE(E3, STATE) - #define E3_DIR_READ() (stepper##E3.getStatus() & STATUS_DIR); - #endif -#endif - -// E4 Stepper -#if AXIS_IS_L64XX(E4) - extern L64XX_CLASS(E4) stepperE4; - #define E4_ENABLE_INIT() NOOP - #define E4_ENABLE_WRITE(STATE) (STATE ? stepperE4.hardStop() : stepperE4.free()) - #define E4_ENABLE_READ() (stepperE4.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_E4(L6474) - #define E4_DIR_INIT() SET_OUTPUT(E4_DIR_PIN) - #define E4_DIR_WRITE(STATE) L6474_DIR_WRITE(E4, STATE) - #define E4_DIR_READ() READ(E4_DIR_PIN) - #else - #define E4_DIR_INIT() NOOP - #define E4_DIR_WRITE(STATE) L64XX_DIR_WRITE(E4, STATE) - #define E4_DIR_READ() (stepper##E4.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_E4(L6470) - #define DISABLE_STEPPER_E4() do{ stepperE4.free(); }while(0) - #endif - #endif -#endif - -// E5 Stepper -#if AXIS_IS_L64XX(E5) - extern L64XX_CLASS(E5) stepperE5; - #define E5_ENABLE_INIT() NOOP - #define E5_ENABLE_WRITE(STATE) (STATE ? stepperE5.hardStop() : stepperE5.free()) - #define E5_ENABLE_READ() (stepperE5.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_E5(L6474) - #define E5_DIR_INIT() SET_OUTPUT(E5_DIR_PIN) - #define E5_DIR_WRITE(STATE) L6474_DIR_WRITE(E5, STATE) - #define E5_DIR_READ() READ(E5_DIR_PIN) - #else - #define E5_DIR_INIT() NOOP - #define E5_DIR_WRITE(STATE) L64XX_DIR_WRITE(E5, STATE) - #define E5_DIR_READ() (stepper##E5.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_E5(L6470) - #define DISABLE_STEPPER_E5() do{ stepperE5.free(); }while(0) - #endif - #endif -#endif - -// E6 Stepper -#if AXIS_IS_L64XX(E6) - extern L64XX_CLASS(E6) stepperE6; - #define E6_ENABLE_INIT() NOOP - #define E6_ENABLE_WRITE(STATE) (STATE ? stepperE6.hardStop() : stepperE6.free()) - #define E6_ENABLE_READ() (stepperE6.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_E6(L6474) - #define E6_DIR_INIT() SET_OUTPUT(E6_DIR_PIN) - #define E6_DIR_WRITE(STATE) L6474_DIR_WRITE(E6, STATE) - #define E6_DIR_READ() READ(E6_DIR_PIN) - #else - #define E6_DIR_INIT() NOOP - #define E6_DIR_WRITE(STATE) L64XX_DIR_WRITE(E6, STATE) - #define E6_DIR_READ() (stepper##E6.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_E6(L6470) - #define DISABLE_STEPPER_E6() do{ stepperE6.free(); }while(0) - #endif - #endif -#endif - -// E7 Stepper -#if AXIS_IS_L64XX(E7) - extern L64XX_CLASS(E7) stepperE7; - #define E7_ENABLE_INIT() NOOP - #define E7_ENABLE_WRITE(STATE) (STATE ? stepperE7.hardStop() : stepperE7.free()) - #define E7_ENABLE_READ() (stepperE7.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_E7(L6474) - #define E7_DIR_INIT() SET_OUTPUT(E7_DIR_PIN) - #define E7_DIR_WRITE(STATE) L6474_DIR_WRITE(E7, STATE) - #define E7_DIR_READ() READ(E7_DIR_PIN) - #else - #define E7_DIR_INIT() NOOP - #define E7_DIR_WRITE(STATE) L64XX_DIR_WRITE(E7, STATE) - #define E7_DIR_READ() (stepper##E7.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_E7(L6470) - #define DISABLE_STEPPER_E7() do{ stepperE7.free(); }while(0) - #endif - #endif -#endif diff --git a/Marlin/src/module/stepper/indirection.cpp b/Marlin/src/module/stepper/indirection.cpp index e44496d0224c..427fd71cbe7d 100644 --- a/Marlin/src/module/stepper/indirection.cpp +++ b/Marlin/src/module/stepper/indirection.cpp @@ -38,7 +38,6 @@ void restore_stepper_drivers() { void reset_stepper_drivers() { TERN_(HAS_TMC26X, tmc26x_init_to_defaults()); - TERN_(HAS_L64XX, L64xxManager.init_to_defaults()); TERN_(HAS_TRINAMIC_CONFIG, reset_trinamic_drivers()); } diff --git a/Marlin/src/module/stepper/indirection.h b/Marlin/src/module/stepper/indirection.h index 687a0f289628..3f21530af7ff 100644 --- a/Marlin/src/module/stepper/indirection.h +++ b/Marlin/src/module/stepper/indirection.h @@ -32,10 +32,6 @@ #include "../../inc/MarlinConfig.h" -#if HAS_L64XX - #include "L64xx.h" -#endif - #if HAS_TMC26X #include "TMC26X.h" #endif diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index ee4f43cceff3..8457cdc4ff1d 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -629,8 +629,6 @@ #include "stm32f4/pins_RUMBA32_BTT.h" // STM32F4 env:rumba32 #elif MB(BLACK_STM32F407VE) #include "stm32f4/pins_BLACK_STM32F407VE.h" // STM32F4 env:STM32F407VE_black -#elif MB(STEVAL_3DP001V1) - #include "stm32f4/pins_STEVAL_3DP001V1.h" // STM32F4 env:STM32F401VE_STEVAL #elif MB(BTT_SKR_PRO_V1_1) #include "stm32f4/pins_BTT_SKR_PRO_V1_1.h" // STM32F4 env:BIGTREE_SKR_PRO env:BIGTREE_SKR_PRO_usb_flash_drive #elif MB(BTT_SKR_PRO_V1_2) @@ -786,6 +784,7 @@ #define BOARD_STM32F103R 99906 #define BOARD_ESP32 99907 #define BOARD_STEVAL 99908 + #define BOARD_STEVAL_3DP001V1 99908 #define BOARD_BIGTREE_SKR_V1_1 99909 #define BOARD_BIGTREE_SKR_V1_3 99910 #define BOARD_BIGTREE_SKR_V1_4 99911 @@ -841,7 +840,7 @@ #elif MOTHERBOARD == BOARD_ESP32 #error "BOARD_ESP32 has been renamed BOARD_ESPRESSIF_ESP32. Please update your configuration." #elif MB(STEVAL) - #error "BOARD_STEVAL has been renamed BOARD_STEVAL_3DP001V1. Please update your configuration." + #error "BOARD_STEVAL_3DP001V1 (BOARD_STEVAL) is no longer supported in Marlin." #elif MB(RUMBA32) #error "BOARD_RUMBA32 is now BOARD_RUMBA32_MKS or BOARD_RUMBA32_V1_0. Please update your configuration." #elif MB(RUMBA32_AUS3D) @@ -873,7 +872,7 @@ #undef BOARD_STM32F103R #undef BOARD_ESP32 #undef BOARD_STEVAL - #undef BOARD_BIGTREE_SKR_MINI_E3 + #undef BOARD_STEVAL_3DP001V1 #undef BOARD_BIGTREE_SKR_V1_1 #undef BOARD_BIGTREE_SKR_V1_3 #undef BOARD_BIGTREE_SKR_V1_4 @@ -881,6 +880,7 @@ #undef BOARD_BIGTREE_BTT002_V1_0 #undef BOARD_BIGTREE_SKR_PRO_V1_1 #undef BOARD_BIGTREE_SKR_MINI_V1_1 + #undef BOARD_BIGTREE_SKR_MINI_E3 #undef BOARD_BIGTREE_SKR_E3_DIP #undef BOARD_RUMBA32 #undef BOARD_RUMBA32_AUS3D diff --git a/Marlin/src/pins/pinsDebug_list.h b/Marlin/src/pins/pinsDebug_list.h index 8969997e9a54..034e4adf1b66 100644 --- a/Marlin/src/pins/pinsDebug_list.h +++ b/Marlin/src/pins/pinsDebug_list.h @@ -1826,21 +1826,6 @@ #if PIN_EXISTS(K_SERIAL_RX) REPORT_NAME_DIGITAL(__LINE__, K_SERIAL_RX_PIN) #endif -#if PIN_EXISTS(L6470_CHAIN_SCK) - REPORT_NAME_DIGITAL(__LINE__, L6470_CHAIN_SCK_PIN) -#endif -#if PIN_EXISTS(L6470_CHAIN_MISO) - REPORT_NAME_DIGITAL(__LINE__, L6470_CHAIN_MISO_PIN) -#endif -#if PIN_EXISTS(L6470_CHAIN_MOSI) - REPORT_NAME_DIGITAL(__LINE__, L6470_CHAIN_MOSI_PIN) -#endif -#if PIN_EXISTS(L6470_CHAIN_SS) - REPORT_NAME_DIGITAL(__LINE__, L6470_CHAIN_SS_PIN) -#endif -#if PIN_EXISTS(L6470_RESET_CHAIN) - REPORT_NAME_DIGITAL(__LINE__, L6470_RESET_CHAIN_PIN) -#endif #if PIN_EXISTS(FET_SAFETY) REPORT_NAME_DIGITAL(__LINE__, FET_SAFETY_PIN) #endif diff --git a/Marlin/src/pins/stm32f4/pins_STEVAL_3DP001V1.h b/Marlin/src/pins/stm32f4/pins_STEVAL_3DP001V1.h deleted file mode 100644 index 0b527a6fdb78..000000000000 --- a/Marlin/src/pins/stm32f4/pins_STEVAL_3DP001V1.h +++ /dev/null @@ -1,325 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ -#pragma once - -// Source: https://github.com/stm32duino/Arduino_Core_STM32/blob/master/variants/ST3DP001_EVAL/variant.cpp - -/** - * HOW TO COMPILE - * - * PlatformIO - Use the STM32F401VE_STEVAL environment (or the "Auto Build Marlin" extension). - * - * Arduino - Tested with 1.8.10 - * Install library per https://github.com/stm32duino/Arduino_Core_STM32 - * Make the following selections under the TOOL menu in the Arduino IDE - * Board: "3D printer boards" - * Board part number: "STEVAL-3DP001V1" - * U(S)ART support: "Enabled (generic "Serial")" - * USB support (if available): "CDC (no generic "Serial")" - * Optimize: "Smallest (-Os default)" - * C Runtime Library: "newlib Nano (default)" - */ - -#include "env_validate.h" - -#ifndef MACHINE_NAME - #define MACHINE_NAME "STEVAL-3DP001V1" -#endif - -// -// Limit Switches -// -#define X_MIN_PIN PD8 // X_STOP -#define Y_MIN_PIN PD9 // Y_STOP -#define Z_MIN_PIN PD10 // Z_STOP - -#define X_MAX_PIN PD0 // W_STOP -#define Y_MAX_PIN PA8 // V_STOP -#define Z_MAX_PIN PD11 // U_STOP - -// -// Z Probe (when not Z_MIN_PIN) -// -//#ifndef Z_MIN_PROBE_PIN -// #define Z_MIN_PROBE_PIN PA4 // SPI1_CS -//#endif - -// -// Filament runout -// -//#define FIL_RUNOUT_PIN PA3 // BED_THERMISTOR_3 - -// -// Steppers -// - -#define X_STEP_PIN PE14 // X_PWM -#define X_DIR_PIN PE15 // X_DIR -#define X_ENABLE_PIN PE13 // X_RESET -#define X_CS_PIN PA4 // SPI1_CS - -#define Y_STEP_PIN PB10 // Y_PWM -#define Y_DIR_PIN PE9 // Y_DIR -#define Y_ENABLE_PIN PE10 // Y_RESET -#define Y_CS_PIN PA4 // SPI1_CS - -#define Z_STEP_PIN PC6 // Z_PWM -#define Z_DIR_PIN PC0 // Z_DIR -#define Z_ENABLE_PIN PC15 // Z_RESET -#define Z_CS_PIN PA4 // SPI1_CS - -#define E0_STEP_PIN PD12 // E1_PW -#define E0_DIR_PIN PC13 // E1_DIR -#define E0_ENABLE_PIN PC14 // E1_RESET -#define E0_CS_PIN PA4 // SPI1_CS - -#define E1_STEP_PIN PE5 // E2_PWM -#define E1_DIR_PIN PE6 // E2_DIR -#define E1_ENABLE_PIN PE4 // E2_RESET -#define E1_CS_PIN PA4 // SPI1_CS - -#define E2_STEP_PIN PB8 // E3_PWM -#define E2_DIR_PIN PE2 // E3_DIR -#define E2_ENABLE_PIN PE3 // E3_RESET -#define E2_CS_PIN PA4 // SPI1_CS - -// needed to pass a sanity check -#define X2_CS_PIN PA4 // SPI1_CS -#define Y2_CS_PIN PA4 // SPI1_CS -#define Z2_CS_PIN PA4 // SPI1_CS -#define Z3_CS_PIN PA4 // SPI1_CS -#define E3_CS_PIN PA4 // SPI1_CS -#define E4_CS_PIN PA4 // SPI1_CS -#define E5_CS_PIN PA4 // SPI1_CS - -#if HAS_L64XX - #define L6470_CHAIN_SCK_PIN PA5 // SPI1_SCK - #define L6470_CHAIN_MISO_PIN PA6 // SPI1_MISO - #define L6470_CHAIN_MOSI_PIN PA7 // SPI1_MOSI - #define L6470_CHAIN_SS_PIN PA4 // SPI1_CS - - //#define SD_SCK_PIN L6470_CHAIN_SCK_PIN - //#define SD_MISO_PIN L6470_CHAIN_MISO_PIN - //#define SD_MOSI_PIN L6470_CHAIN_MOSI_PIN -#else - //#define SD_SCK_PIN PB13 // SPI2_SCK - //#define SD_MISO_PIN PB14 // SPI2_MISO - //#define SD_MOSI_PIN PB15 // SPI2_MOSI -#endif - -/** - * Macro to reset/enable L6474 stepper drivers - * - * IMPORTANT - To disable (bypass) L6474s, install the corresponding - * resistors (R11 - R17) and change the "V" to "0" for the - * corresponding pins here: - */ -#define ENABLE_RESET_L64XX_CHIPS(V) do{ OUT_WRITE(X_ENABLE_PIN, V); \ - OUT_WRITE(Y_ENABLE_PIN, V); \ - OUT_WRITE(Z_ENABLE_PIN, V); \ - OUT_WRITE(E0_ENABLE_PIN,V); \ - OUT_WRITE(E1_ENABLE_PIN,V); \ - OUT_WRITE(E2_ENABLE_PIN,V); \ - }while(0) - -// -// Temperature Sensors -// -#define TEMP_0_PIN PA0 // Analog Input 3 -#define TEMP_1_PIN PA1 // Analog Input 4 -#define TEMP_2_PIN PA2 // Analog Input 5 -#define TEMP_BED_PIN PC2 // Analog Input 0 -#define TEMP_BED_1_PIN PC3 // Analog Input 1 -#define TEMP_BED_2_PIN PA3 // Analog Input 2 - -// -// Heaters / Fans -// -#define HEATER_0_PIN PC7 // E1_HEAT_PWM -#define HEATER_1_PIN PB0 // E2_HEAT_PWM -#define HEATER_2_PIN PB1 // E3_HEAT_PWM -#define HEATER_BED_PIN PD14 // BED_HEAT_1 FET -#define HEATER_BED_1_PIN PD13 // BED_HEAT_2 FET -#define HEATER_BED_2_PIN PD15 // BED_HEAT_3 FET - -#define FAN_PIN PC4 // E1_FAN PWM pin, Part cooling fan FET -#define FAN1_PIN PC5 // E2_FAN PWM pin, Extruder fan FET -#define FAN2_PIN PE8 // E3_FAN PWM pin, Controller fan FET - -#ifndef E0_AUTO_FAN_PIN - #define E0_AUTO_FAN_PIN PC5 // FAN1_PIN -#endif - -// -// Misc functions -// -#define LED_PIN -1 // PE1 Green LED Heartbeat -#define PS_ON_PIN -1 -#define KILL_PIN -1 -#define POWER_LOSS_PIN -1 // PWR_LOSS / nAC_FAULT - -// -// LCD / Controller -// -//#define SD_DETECT_PIN PA15 // SD_CARD_DETECT -//#define BEEPER_PIN PC9 // SDIO_D1 -//#define LCD_PINS_RS PE9 // Y_DIR -//#define LCD_PINS_ENABLE PE8 // E3_FAN -//#define LCD_PINS_D4 PB12 // SPI2_CS -//#define LCD_PINS_D5 PB13 // SPI2_SCK -//#define LCD_PINS_D6 PB14 // SPI2_MISO -//#define LCD_PINS_D7 PB15 // SPI2_MOSI -//#define BTN_EN1 PC4 // E1_FAN -//#define BTN_EN2 PC5 // E2_FAN -//#define BTN_ENC PC3 // BED_THERMISTOR_2 - -// -// Extension pins -// -//#define EXT0_PIN PB0 // E2_HEAT -//#define EXT1_PIN PB1 // E3_HEAT -//#define EXT2_PIN PB2 // not used (tied to ground) -//#define EXT3_PIN PD8 // X_STOP -//#define EXT4_PIN PD9 // Y_STOP -//#define EXT5_PIN PD10 // Z_STOP -//#define EXT6_PIN PD11 // U_STOP -//#define EXT7_PIN PD12 // E1_PWM -//#define EXT8_PIN PB10 // Y_PWM - -// WIFI -// PD3 CTS -// PD4 RTS -// PD5 TX -// PD6 RX -// PB5 WIFI_WAKEUP -// PE11 WIFI_RESET -// PE12 WIFI_BOOT - -// I2C USER -// PB7 SDA -// PB6 SCL - -// JTAG -// PA13 JTAG_TMS/SWDIO -// PA14 JTAG_TCK/SWCLK -// PB3 JTAG_TDO/SWO - -// -// Onboard SD support -// -#ifndef SDCARD_CONNECTION - #define SDCARD_CONNECTION ONBOARD -#endif - -#if SD_CONNECTION_IS(ONBOARD) - - #define SDIO_SUPPORT // Use SDIO for onboard SD - #if DISABLED(SDIO_SUPPORT) - #define SOFTWARE_SPI // Use soft SPI for onboard SD - #define SDSS PC11 - #define SD_SCK_PIN PC12 - #define SD_MISO_PIN PC8 - #define SD_MOSI_PIN PD2 - #endif - - //#define SD_DETECT_PIN PA15 - -#endif - -#ifndef SDSS - #define SDSS PA4 // SPI1_CS -#endif - -// OTG -// PA11 OTG_DM -// PA12 OTG_DP - -// USER_PINS -// PD7 USER3 -// PB9 USER1 -// PE0 USER2 -// PB4 USER4 - -// USERKET -// PE7 USER_BUTTON - -// PA9 TX -// PA10 RX - -// IR/PROBE -// PD1 IR_OUT -// PC1 IR_ON - -/** - * Logical pin vs. port/pin cross reference - * - * PA0 E1_THERMISTOR PD0 W_STOP - * PA1 E2_THERMISTOR PD1 IR_OUT - * PA2 E3_THERMISTOR PD2 SDIO_CMD - * PA3 BED_THERMISTOR_3 PD3 CTS - * PA4 SPI1_CS PD4 RTS - * PA5 SPI1_SCK PD5 TX - * PA6 SPI1_MISO PD6 RX - * PA7 SPI1_MOSI PD7 USER3 - * PA8 V_STOP PD8 X_STOP - * PA9 TX PD9 Y_STOP - * PA10 RX PD10 Z_STOP - * PA11 OTG_DM PD11 U_STOP - * PA12 OTG_DP PD12 E1_PWM - * PA13 JTAG_TMS/SWDIO PD13 BED_HEAT_2 - * PA14 JTAG_TCK/SWCLK PD14 BED_HEAT_1 - * PA15 SD_CARD_DETECT PD15 BED_HEAT_3 - * - * PB0 E2_HEAT_PWM PE0 USER2 - * PB1 E3_HEAT_PWM PE1 STATUS_LED - * PB2 --- PE2 E3_DIR - * PB3 JTAG_TDO/SWO PE3 E3_RESET - * PB4 USER4 PE4 E2_RESET - * PB5 WIFI_WAKEUP PE5 E2_PWM - * PB6 SCL PE6 E2_DIR - * PB7 SDA PE7 USER_BUTTON - * PB8 E3_PWM PE8 E3_FAN - * PB9 USER1 PE9 Y_DIR - * PB10 Y_PWM PE10 Y_RESET - * PB11 --- PE11 WIFI_RESET - * PB12 SPI2_CS PE12 WIFI_BOOT - * PB13 SPI2_SCK PE13 X_RESET - * PB14 SPI2_MISO PE14 X_PWM - * PB15 SPI2_MOSI PE15 X_DIR - * - * PC0 Z_DIR - * PC1 IR_ON - * PC2 BED_THERMISTOR_1 - * PC3 BED_THERMISTOR_2 - * PC4 E1_FAN - * PC5 E2_FAN - * PC6 Z_PWM - * PC7 E1_HEAT_PWM - * PC8 SDIO_D0 - * PC9 SDIO_D1 - * PC10 SDIO_D2 - * PC11 SDIO_D3 - * PC12 SDIO_CK - * PC13 E1_DIR - * PC14 E1_RESET - * PC15 Z_RESET - */ diff --git a/buildroot/share/PlatformIO/boards/marlin_STEVAL_STM32F401VE.json b/buildroot/share/PlatformIO/boards/marlin_STEVAL_STM32F401VE.json deleted file mode 100644 index e260950f25d5..000000000000 --- a/buildroot/share/PlatformIO/boards/marlin_STEVAL_STM32F401VE.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "build": { - "core": "stm32", - "cpu": "cortex-m4", - "extra_flags": "-DSTM32F401xx -DARDUINO_STEVAL", - "f_cpu": "84000000L", - "hwids": [ - [ - "0x1EAF", - "0x0003" - ], - [ - "0x0483", - "0x3748" - ] - ], - "mcu": "stm32f401vet6", - "variant": "MARLIN_STEVAL_F401VE" - }, - "debug": { - "jlink_device": "STM32F401VE", - "openocd_target": "stm32f4x", - "svd_path": "STM32F40x.svd", - "tools": { - "stlink": { - "server": { - "arguments": [ - "-f", - "scripts/interface/stlink.cfg", - "-c", - "transport select hla_swd", - "-f", - "scripts/target/stm32f4x.cfg", - "-c", - "reset_config none" - ], - "executable": "bin/openocd", - "package": "tool-openocd" - } - } - } - }, - "frameworks": [ - "arduino", - "stm32cube" - ], - "name": "STM32F401VE (96k RAM. 512k Flash)", - "upload": { - "disable_flushing": false, - "maximum_ram_size": 98304, - "maximum_size": 514288, - "protocol": "stlink", - "protocols": [ - "stlink", - "dfu", - "jlink" - ], - "require_upload_port": true, - "use_1200bps_touch": false, - "wait_for_upload_port": false - }, - "url": "https://www.st.com/en/evaluation-tools/steval-3dp001v1.html", - "vendor": "Generic" -} diff --git a/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/PeripheralPins.c deleted file mode 100644 index d3d754b689ee..000000000000 --- a/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/PeripheralPins.c +++ /dev/null @@ -1,260 +0,0 @@ - -/* - ******************************************************************************* - * Copyright (c) 2019, STMicroelectronics - * All rights reserved. - * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ******************************************************************************* - * Automatically generated from STM32F401V(D-E)Tx.xml - */ -#include "Arduino.h" -#include "PeripheralPins.h" - -/* ===== - * Note: Commented lines are alternative possibilities which are not used per default. - * If you change them, you will have to know what you do - * ===== - */ - -//*** ADC *** - -#ifdef HAL_ADC_MODULE_ENABLED -WEAK const PinMap PinMap_ADC[] = { - {PA_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC1_IN0 - {PA_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1 - {PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2 - {PA_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3 - //{PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 - //{PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 - //{PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 - //{PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 - //{PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 - //{PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 - //{PC_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 - //{PC_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 - {PC_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12 - {PC_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13 - //{PC_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14 - //{PC_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 - {NC, NP, 0} -}; -#endif - -//*** No DAC *** - -//*** I2C *** - -#ifdef HAL_I2C_MODULE_ENABLED -WEAK const PinMap PinMap_I2C_SDA[] = { - //{PB_3, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF9_I2C2)}, - //{PB_4, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF9_I2C3)}, - {PB_7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, - //{PB_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, - //{PC_9, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, - {NC, NP, 0} -}; - -WEAK const PinMap PinMap_I2C_SCL[] = { - //{PA_8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, - {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, - //{PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, - //{PB_10, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, - {NC, NP, 0} -}; -#endif - -//*** PWM *** - -#ifdef HAL_TIM_MODULE_ENABLED -WEAK const PinMap PinMap_PWM[] = { - //{PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 - //{PA_0, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 - //{PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 - //{PA_1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 - //{PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 - //{PA_2, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3 - //{PA_2, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 - //{PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 - //{PA_3, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 - //{PA_3, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 - //{PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 - //{PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 - //{PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N - //{PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 - //{PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 - //{PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 - //{PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 - //{PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 - //{PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 - //{PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N - {PB_0, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 - //{PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N - {PB_1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 - //{PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 - //{PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 - //{PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 - //{PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 - //{PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 - //{PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 - //{PB_8, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 - //{PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 - //{PB_9, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 - {PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 - //{PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N - //{PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N - //{PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N - {PC_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 - {PC_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 - //{PC_8, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 - //{PC_9, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 - {PD_12, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 - {PD_13, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 - {PD_14, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 - {PD_15, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 - {PE_5, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 - //{PE_6, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 - //{PE_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N - //{PE_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 - //{PE_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N - //{PE_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 - //{PE_12, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N - //{PE_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 - {PE_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 - {NC, NP, 0} -}; -#endif - -//*** SERIAL *** - -#ifdef HAL_UART_MODULE_ENABLED -WEAK const PinMap PinMap_UART_TX[] = { - //{PA_2, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, - {PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, - //{PA_11, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, - //{PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, - //{PC_6, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, - {PD_5, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, - {NC, NP, 0} -}; - -WEAK const PinMap PinMap_UART_RX[] = { - //{PA_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, - {PA_10, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, - //{PA_12, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, - //{PB_7, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, - //{PC_7, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, - {PD_6, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, - {NC, NP, 0} -}; - -WEAK const PinMap PinMap_UART_RTS[] = { - //{PA_1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, - //{PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, - {PD_4, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, - {NC, NP, 0} -}; - -WEAK const PinMap PinMap_UART_CTS[] = { - //{PA_0, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, - //{PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, - {PD_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, - {NC, NP, 0} -}; -#endif - -//*** SPI *** - -#ifdef HAL_SPI_MODULE_ENABLED -WEAK const PinMap PinMap_SPI_MOSI[] = { - {PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - //{PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - //{PB_5, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - {PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - //{PC_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - //{PC_12, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - //{PD_6, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - //{PE_6, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - //{PE_14, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - {NC, NP, 0} -}; - -WEAK const PinMap PinMap_SPI_MISO[] = { - {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - //{PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - //{PB_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - {PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - //{PC_2, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - //{PC_11, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - //{PE_5, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - //{PE_13, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - {NC, NP, 0} -}; - -WEAK const PinMap PinMap_SPI_SCLK[] = { - {PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - //{PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - //{PB_3, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - //{PB_10, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - {PB_13, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - //{PC_10, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - //{PD_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - //{PE_2, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - //{PE_12, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - {NC, NP, 0} -}; - -WEAK const PinMap PinMap_SPI_SSEL[] = { - {PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - //{PA_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - //{PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - //{PA_15, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - //{PB_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - {PB_12, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - //{PE_4, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - //{PE_11, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - {NC, NP, 0} -}; -#endif - -//*** No CAN *** - -//*** No ETHERNET *** - -//*** No QUADSPI *** - -//*** USB *** - -#ifdef HAL_PCD_MODULE_ENABLED -WEAK const PinMap PinMap_USB_OTG_FS[] = { - //{PA_8, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_SOF - //{PA_9, USB_OTG_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_FS_VBUS - //{PA_10, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_ID - {PA_11, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DM - {PA_12, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DP - {NC, NP, 0} -}; -#endif - -//*** No USB_OTG_HS *** -//*** SD *** - -#ifdef HAL_SD_MODULE_ENABLED -WEAK const PinMap PinMap_SD[] = { - //{PB_8, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D4 - //{PB_9, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D5 - //{PC_6, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D6 - //{PC_7, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D7 - {PC_8, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D0 - {PC_9, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D1 - {PC_10, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D2 - {PC_11, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D3 - {PC_12, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDIO)}, // SDIO_CK - {PD_2, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDIO)}, // SDIO_CMD - {NC, NP, 0} -}; -#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/PinNamesVar.h b/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/PinNamesVar.h deleted file mode 100644 index 6a1eb9b887f4..000000000000 --- a/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/PinNamesVar.h +++ /dev/null @@ -1,33 +0,0 @@ -/* SYS_WKUP */ -#ifdef PWR_WAKEUP_PIN1 - SYS_WKUP1 = PA_0, -#endif -#ifdef PWR_WAKEUP_PIN2 - SYS_WKUP2 = NC, -#endif -#ifdef PWR_WAKEUP_PIN3 - SYS_WKUP3 = NC, -#endif -#ifdef PWR_WAKEUP_PIN4 - SYS_WKUP4 = NC, -#endif -#ifdef PWR_WAKEUP_PIN5 - SYS_WKUP5 = NC, -#endif -#ifdef PWR_WAKEUP_PIN6 - SYS_WKUP6 = NC, -#endif -#ifdef PWR_WAKEUP_PIN7 - SYS_WKUP7 = NC, -#endif -#ifdef PWR_WAKEUP_PIN8 - SYS_WKUP8 = NC, -#endif -/* USB */ -#ifdef USBCON - USB_OTG_FS_SOF = PA_8, - USB_OTG_FS_VBUS = PA_9, - USB_OTG_FS_ID = PA_10, - USB_OTG_FS_DM = PA_11, - USB_OTG_FS_DP = PA_12, -#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/hal_conf_custom.h b/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/hal_conf_custom.h deleted file mode 100644 index 7d013d2b27f4..000000000000 --- a/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/hal_conf_custom.h +++ /dev/null @@ -1,495 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f4xx_hal_conf.h - * @brief HAL configuration file. - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2017 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F4xx_HAL_CONF_CUSTOM -#define __STM32F4xx_HAL_CONF_CUSTOM - -#ifdef __cplusplus -extern "C" { -#endif - -/* Exported types ------------------------------------------------------------*/ -/* Exported constants --------------------------------------------------------*/ - -/* ########################## Module Selection ############################## */ - /** - * @brief This is the list of modules to be used in the HAL driver - */ -#define HAL_MODULE_ENABLED -#define HAL_ADC_MODULE_ENABLED -#define HAL_CRC_MODULE_ENABLED -#define HAL_DMA_MODULE_ENABLED -#define HAL_EXTI_MODULE_ENABLED // Needed for Endstop (and other external) Interrupts -#define HAL_FLASH_MODULE_ENABLED -#define HAL_GPIO_MODULE_ENABLED -#define HAL_I2C_MODULE_ENABLED -#define HAL_IWDG_MODULE_ENABLED -#define HAL_PWR_MODULE_ENABLED -#define HAL_RCC_MODULE_ENABLED -#define HAL_RTC_MODULE_ENABLED -#define HAL_SD_MODULE_ENABLED -#define HAL_SPI_MODULE_ENABLED -#define HAL_TIM_MODULE_ENABLED -#define HAL_CORTEX_MODULE_ENABLED -//#define HAL_PCD_MODULE_ENABLED // Automatically added if any type of USB is enabled, as in Arduino IDE. (STM32 v3.10700.191028) - -//#define HAL_CAN_MODULE_ENABLED -//#define HAL_CAN_LEGACY_MODULE_ENABLED -//#define HAL_CEC_MODULE_ENABLED -//#define HAL_CRYP_MODULE_ENABLED -//#define HAL_DAC_MODULE_ENABLED -//#define HAL_DCMI_MODULE_ENABLED -//#define HAL_DMA2D_MODULE_ENABLED -//#define HAL_ETH_MODULE_ENABLED -//#define HAL_NAND_MODULE_ENABLED -//#define HAL_NOR_MODULE_ENABLED -//#define HAL_PCCARD_MODULE_ENABLED -//#define HAL_SRAM_MODULE_ENABLED -//#define HAL_SDRAM_MODULE_ENABLED -//#define HAL_HASH_MODULE_ENABLED -//#define HAL_SMBUS_MODULE_ENABLED -//#define HAL_I2S_MODULE_ENABLED -//#define HAL_LTDC_MODULE_ENABLED -//#define HAL_DSI_MODULE_ENABLED -//#define HAL_QSPI_MODULE_ENABLED -//#define HAL_RNG_MODULE_ENABLED -//#define HAL_SAI_MODULE_ENABLED -//#define HAL_UART_MODULE_ENABLED // by default -//#define HAL_USART_MODULE_ENABLED -//#define HAL_IRDA_MODULE_ENABLED -//#define HAL_SMARTCARD_MODULE_ENABLED -//#define HAL_WWDG_MODULE_ENABLED -//#define HAL_HCD_MODULE_ENABLED -//#define HAL_FMPI2C_MODULE_ENABLED -//#define HAL_SPDIFRX_MODULE_ENABLED -//#define HAL_DFSDM_MODULE_ENABLED -//#define HAL_LPTIM_MODULE_ENABLED -//#define HAL_MMC_MODULE_ENABLED - -/* ########################## HSE/HSI Values adaptation ##################### */ -/** - * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. - * This value is used by the RCC HAL module to compute the system frequency - * (when HSE is used as system clock source, directly or through the PLL). - */ -#ifndef HSE_VALUE -#define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ -#endif /* HSE_VALUE */ - -#ifndef HSE_STARTUP_TIMEOUT -#define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ -#endif /* HSE_STARTUP_TIMEOUT */ - -/** - * @brief Internal High Speed oscillator (HSI) value. - * This value is used by the RCC HAL module to compute the system frequency - * (when HSI is used as system clock source, directly or through the PLL). - */ -#ifndef HSI_VALUE -#define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz */ -#endif /* HSI_VALUE */ - -/** - * @brief Internal Low Speed oscillator (LSI) value. - */ -#ifndef LSI_VALUE -#define LSI_VALUE 32000U /*!< LSI Typical Value in Hz */ -#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz -The real value may vary depending on the variations -in voltage and temperature. */ -/** - * @brief External Low Speed oscillator (LSE) value. - */ -#ifndef LSE_VALUE -#define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */ -#endif /* LSE_VALUE */ - -#ifndef LSE_STARTUP_TIMEOUT -#define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ -#endif /* LSE_STARTUP_TIMEOUT */ - -/** - * @brief External clock source for I2S peripheral - * This value is used by the I2S HAL module to compute the I2S clock source - * frequency, this source is inserted directly through I2S_CKIN pad. - */ -#ifndef EXTERNAL_CLOCK_VALUE -#define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External oscillator in Hz*/ -#endif /* EXTERNAL_CLOCK_VALUE */ - -/* Tip: To avoid modifying this file each time you need to use different HSE, - === you can define the HSE value in your toolchain compiler preprocessor. */ - -/* ########################### System Configuration ######################### */ -/** - * @brief This is the HAL system configuration section - */ -#if !defined (VDD_VALUE) -#define VDD_VALUE 3300U /*!< Value of VDD in mv */ -#endif -#if !defined (TICK_INT_PRIORITY) -#define TICK_INT_PRIORITY 0x00U /*!< tick interrupt priority */ -#endif -#if !defined (USE_RTOS) -#define USE_RTOS 0U -#endif -#if !defined (PREFETCH_ENABLE) -#define PREFETCH_ENABLE 1U -#endif -#if !defined (INSTRUCTION_CACHE_ENABLE) -#define INSTRUCTION_CACHE_ENABLE 1U -#endif -#if !defined (DATA_CACHE_ENABLE) -#define DATA_CACHE_ENABLE 1U -#endif - -#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ -#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ -#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ -#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */ -#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ -#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */ -#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */ -#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */ -#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */ -#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ -#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */ -#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ -#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ -#define USE_HAL_FMPI2C_REGISTER_CALLBACKS 0U /* FMPI2C register callback disabled */ -#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ -#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ -#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */ -#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */ -#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ -#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ -#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ -#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */ -#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ -#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */ -#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */ -#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ -#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */ -#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ -#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ -#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */ -#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ -#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */ -#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */ -#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ -#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ -#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ -#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ -#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ - -/* ########################## Assert Selection ############################## */ -/** - * @brief Uncomment the line below to expanse the "assert_param" macro in the - * HAL drivers code - */ -/* #define USE_FULL_ASSERT 1U */ - -/* ################## Ethernet peripheral configuration ##################### */ - -/* Section 1 : Ethernet peripheral configuration */ - -/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ -#define MAC_ADDR0 2U -#define MAC_ADDR1 0U -#define MAC_ADDR2 0U -#define MAC_ADDR3 0U -#define MAC_ADDR4 0U -#define MAC_ADDR5 0U - -/* Definition of the Ethernet driver buffers size and count */ -#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ -#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ -#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ -#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ - -/* Section 2: PHY configuration section */ - -/* DP83848_PHY_ADDRESS Address*/ -#define DP83848_PHY_ADDRESS 0x01U -/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ -#define PHY_RESET_DELAY 0x000000FFU -/* PHY Configuration delay */ -#define PHY_CONFIG_DELAY 0x00000FFFU - -#define PHY_READ_TO 0x0000FFFFU -#define PHY_WRITE_TO 0x0000FFFFU - -/* Section 3: Common PHY Registers */ - -#define PHY_BCR ((uint16_t)0x0000) /*!< Transceiver Basic Control Register */ -#define PHY_BSR ((uint16_t)0x0001) /*!< Transceiver Basic Status Register */ - -#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */ -#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */ -#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */ -#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */ -#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */ -#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */ -#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */ -#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */ -#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */ -#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */ - -#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */ -#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */ -#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */ - -/* Section 4: Extended PHY Registers */ -#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */ - -#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */ -#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */ - -/* ################## SPI peripheral configuration ########################## */ - -/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver - * Activated: CRC code is present inside driver - * Deactivated: CRC code cleaned from driver - */ -#ifndef USE_SPI_CRC -#define USE_SPI_CRC 0U -#endif - -/* Includes ------------------------------------------------------------------*/ -/** - * @brief Include module's header file - */ - -#ifdef HAL_RCC_MODULE_ENABLED -#include "stm32f4xx_hal_rcc.h" -#endif /* HAL_RCC_MODULE_ENABLED */ - -#ifdef HAL_GPIO_MODULE_ENABLED -#include "stm32f4xx_hal_gpio.h" -#endif /* HAL_GPIO_MODULE_ENABLED */ - -#ifdef HAL_EXTI_MODULE_ENABLED -#include "stm32f4xx_hal_exti.h" -#endif /* HAL_EXTI_MODULE_ENABLED */ - -#ifdef HAL_DMA_MODULE_ENABLED -#include "stm32f4xx_hal_dma.h" -#endif /* HAL_DMA_MODULE_ENABLED */ - -#ifdef HAL_CORTEX_MODULE_ENABLED -#include "stm32f4xx_hal_cortex.h" -#endif /* HAL_CORTEX_MODULE_ENABLED */ - -#ifdef HAL_ADC_MODULE_ENABLED -#include "stm32f4xx_hal_adc.h" -#endif /* HAL_ADC_MODULE_ENABLED */ - -#ifdef HAL_CAN_MODULE_ENABLED -#include "stm32f4xx_hal_can.h" -#endif /* HAL_CAN_MODULE_ENABLED */ - -#ifdef HAL_CAN_LEGACY_MODULE_ENABLED -#include "stm32f4xx_hal_can_legacy.h" -#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ - -#ifdef HAL_CRC_MODULE_ENABLED -#include "stm32f4xx_hal_crc.h" -#endif /* HAL_CRC_MODULE_ENABLED */ - -#ifdef HAL_CRYP_MODULE_ENABLED -#include "stm32f4xx_hal_cryp.h" -#endif /* HAL_CRYP_MODULE_ENABLED */ - -#ifdef HAL_DMA2D_MODULE_ENABLED -#include "stm32f4xx_hal_dma2d.h" -#endif /* HAL_DMA2D_MODULE_ENABLED */ - -#ifdef HAL_DAC_MODULE_ENABLED -#include "stm32f4xx_hal_dac.h" -#endif /* HAL_DAC_MODULE_ENABLED */ - -#ifdef HAL_DCMI_MODULE_ENABLED -#include "stm32f4xx_hal_dcmi.h" -#endif /* HAL_DCMI_MODULE_ENABLED */ - -#ifdef HAL_ETH_MODULE_ENABLED -#include "stm32f4xx_hal_eth.h" -#endif /* HAL_ETH_MODULE_ENABLED */ - -#ifdef HAL_FLASH_MODULE_ENABLED -#include "stm32f4xx_hal_flash.h" -#endif /* HAL_FLASH_MODULE_ENABLED */ - -#ifdef HAL_SRAM_MODULE_ENABLED -#include "stm32f4xx_hal_sram.h" -#endif /* HAL_SRAM_MODULE_ENABLED */ - -#ifdef HAL_NOR_MODULE_ENABLED -#include "stm32f4xx_hal_nor.h" -#endif /* HAL_NOR_MODULE_ENABLED */ - -#ifdef HAL_NAND_MODULE_ENABLED -#include "stm32f4xx_hal_nand.h" -#endif /* HAL_NAND_MODULE_ENABLED */ - -#ifdef HAL_PCCARD_MODULE_ENABLED -#include "stm32f4xx_hal_pccard.h" -#endif /* HAL_PCCARD_MODULE_ENABLED */ - -#ifdef HAL_SDRAM_MODULE_ENABLED -#include "stm32f4xx_hal_sdram.h" -#endif /* HAL_SDRAM_MODULE_ENABLED */ - -#ifdef HAL_HASH_MODULE_ENABLED -#include "stm32f4xx_hal_hash.h" -#endif /* HAL_HASH_MODULE_ENABLED */ - -#ifdef HAL_I2C_MODULE_ENABLED -#include "stm32f4xx_hal_i2c.h" -#endif /* HAL_I2C_MODULE_ENABLED */ - -#ifdef HAL_SMBUS_MODULE_ENABLED -#include "stm32f4xx_hal_smbus.h" -#endif /* HAL_SMBUS_MODULE_ENABLED */ - -#ifdef HAL_I2S_MODULE_ENABLED -#include "stm32f4xx_hal_i2s.h" -#endif /* HAL_I2S_MODULE_ENABLED */ - -#ifdef HAL_IWDG_MODULE_ENABLED -#include "stm32f4xx_hal_iwdg.h" -#endif /* HAL_IWDG_MODULE_ENABLED */ - -#ifdef HAL_LTDC_MODULE_ENABLED -#include "stm32f4xx_hal_ltdc.h" -#endif /* HAL_LTDC_MODULE_ENABLED */ - -#ifdef HAL_PWR_MODULE_ENABLED -#include "stm32f4xx_hal_pwr.h" -#endif /* HAL_PWR_MODULE_ENABLED */ - -#ifdef HAL_RNG_MODULE_ENABLED -#include "stm32f4xx_hal_rng.h" -#endif /* HAL_RNG_MODULE_ENABLED */ - -#ifdef HAL_RTC_MODULE_ENABLED -#include "stm32f4xx_hal_rtc.h" -#endif /* HAL_RTC_MODULE_ENABLED */ - -#ifdef HAL_SAI_MODULE_ENABLED -#include "stm32f4xx_hal_sai.h" -#endif /* HAL_SAI_MODULE_ENABLED */ - -#ifdef HAL_SD_MODULE_ENABLED -#include "stm32f4xx_hal_sd.h" -#endif /* HAL_SD_MODULE_ENABLED */ - -#ifdef HAL_SPI_MODULE_ENABLED -#include "stm32f4xx_hal_spi.h" -#endif /* HAL_SPI_MODULE_ENABLED */ - -#ifdef HAL_TIM_MODULE_ENABLED -#include "stm32f4xx_hal_tim.h" -#endif /* HAL_TIM_MODULE_ENABLED */ - -#ifdef HAL_UART_MODULE_ENABLED -#include "stm32f4xx_hal_uart.h" -#endif /* HAL_UART_MODULE_ENABLED */ - -#ifdef HAL_USART_MODULE_ENABLED -#include "stm32f4xx_hal_usart.h" -#endif /* HAL_USART_MODULE_ENABLED */ - -#ifdef HAL_IRDA_MODULE_ENABLED -#include "stm32f4xx_hal_irda.h" -#endif /* HAL_IRDA_MODULE_ENABLED */ - -#ifdef HAL_SMARTCARD_MODULE_ENABLED -#include "stm32f4xx_hal_smartcard.h" -#endif /* HAL_SMARTCARD_MODULE_ENABLED */ - -#ifdef HAL_WWDG_MODULE_ENABLED -#include "stm32f4xx_hal_wwdg.h" -#endif /* HAL_WWDG_MODULE_ENABLED */ - -#ifdef HAL_PCD_MODULE_ENABLED -#include "stm32f4xx_hal_pcd.h" -#endif /* HAL_PCD_MODULE_ENABLED */ - -#ifdef HAL_HCD_MODULE_ENABLED -#include "stm32f4xx_hal_hcd.h" -#endif /* HAL_HCD_MODULE_ENABLED */ - -#ifdef HAL_DSI_MODULE_ENABLED -#include "stm32f4xx_hal_dsi.h" -#endif /* HAL_DSI_MODULE_ENABLED */ - -#ifdef HAL_QSPI_MODULE_ENABLED -#include "stm32f4xx_hal_qspi.h" -#endif /* HAL_QSPI_MODULE_ENABLED */ - -#ifdef HAL_CEC_MODULE_ENABLED -#include "stm32f4xx_hal_cec.h" -#endif /* HAL_CEC_MODULE_ENABLED */ - -#ifdef HAL_FMPI2C_MODULE_ENABLED -#include "stm32f4xx_hal_fmpi2c.h" -#endif /* HAL_FMPI2C_MODULE_ENABLED */ - -#ifdef HAL_SPDIFRX_MODULE_ENABLED -#include "stm32f4xx_hal_spdifrx.h" -#endif /* HAL_SPDIFRX_MODULE_ENABLED */ - -#ifdef HAL_DFSDM_MODULE_ENABLED -#include "stm32f4xx_hal_dfsdm.h" -#endif /* HAL_DFSDM_MODULE_ENABLED */ - -#ifdef HAL_LPTIM_MODULE_ENABLED -#include "stm32f4xx_hal_lptim.h" -#endif /* HAL_LPTIM_MODULE_ENABLED */ - -#ifdef HAL_MMC_MODULE_ENABLED -#include "stm32f4xx_hal_mmc.h" -#endif /* HAL_MMC_MODULE_ENABLED */ - -/* Exported macro ------------------------------------------------------------*/ -#ifdef USE_FULL_ASSERT -/** - * @brief The assert_param macro is used for function's parameters check. - * @param expr If expr is false, it calls assert_failed function - * which reports the name of the source file and the source - * line number of the call that failed. - * If expr is true, it returns no value. - * @retval None - */ -#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) -/* Exported functions ------------------------------------------------------- */ -void assert_failed(uint8_t *file, uint32_t line); -#else -#define assert_param(expr) ((void)0U) -#endif /* USE_FULL_ASSERT */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32F4xx_HAL_CONF_CUSTOM_H */ - - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/ldscript.ld deleted file mode 100644 index c5788dbebe6c..000000000000 --- a/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/ldscript.ld +++ /dev/null @@ -1,187 +0,0 @@ -/* -***************************************************************************** -** -** File : ldscript.ld -** -** Abstract : Linker script for STM32F401RETx Device with -** 512KByte FLASH, 96KByte RAM -** -** Set heap size, stack size and stack location according -** to application requirements. -** -** Set memory bank area and size if external memory is used. -** -** Target : STMicroelectronics STM32 -** -** -** Distribution: The file is distributed as is, without any warranty -** of any kind. -** -***************************************************************************** -** @attention -** -**

© COPYRIGHT(c) 2014 Ac6

-** -** Redistribution and use in source and binary forms, with or without modification, -** are permitted provided that the following conditions are met: -** 1. Redistributions of source code must retain the above copyright notice, -** this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright notice, -** this list of conditions and the following disclaimer in the documentation -** and/or other materials provided with the distribution. -** 3. Neither the name of Ac6 nor the names of its contributors -** may be used to endorse or promote products derived from this software -** without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -** -***************************************************************************** -*/ - -/* Entry Point */ -ENTRY(Reset_Handler) - -/* Highest address of the user mode stack */ -_estack = 0x20018000; /* end of RAM */ -/* Generate a link error if heap and stack don't fit into RAM */ -_Min_Heap_Size = 0x200; /* required amount of heap */ -_Min_Stack_Size = 0x400; /* required amount of stack */ - -/* Specify the memory areas */ -MEMORY -{ -FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K -RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 96K -} - -/* Define output sections */ -SECTIONS -{ - /* The startup code goes first into FLASH */ - .isr_vector : - { - . = ALIGN(4); - KEEP(*(.isr_vector)) /* Startup code */ - . = ALIGN(4); - } >FLASH - - /* The program code and other data goes into FLASH */ - .text : - { - . = ALIGN(4); - *(.text) /* .text sections (code) */ - *(.text*) /* .text* sections (code) */ - *(.glue_7) /* glue arm to thumb code */ - *(.glue_7t) /* glue thumb to arm code */ - *(.eh_frame) - - KEEP (*(.init)) - KEEP (*(.fini)) - - . = ALIGN(4); - _etext = .; /* define a global symbols at end of code */ - } >FLASH - - /* Constant data goes into FLASH */ - .rodata : - { - . = ALIGN(4); - *(.rodata) /* .rodata sections (constants, strings, etc.) */ - *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ - . = ALIGN(4); - } >FLASH - - .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH - .ARM : { - __exidx_start = .; - *(.ARM.exidx*) - __exidx_end = .; - } >FLASH - - .preinit_array : - { - PROVIDE_HIDDEN (__preinit_array_start = .); - KEEP (*(.preinit_array*)) - PROVIDE_HIDDEN (__preinit_array_end = .); - } >FLASH - .init_array : - { - PROVIDE_HIDDEN (__init_array_start = .); - KEEP (*(SORT(.init_array.*))) - KEEP (*(.init_array*)) - PROVIDE_HIDDEN (__init_array_end = .); - } >FLASH - .fini_array : - { - PROVIDE_HIDDEN (__fini_array_start = .); - KEEP (*(SORT(.fini_array.*))) - KEEP (*(.fini_array*)) - PROVIDE_HIDDEN (__fini_array_end = .); - } >FLASH - - /* used by the startup to initialize data */ - _sidata = LOADADDR(.data); - - /* Initialized data sections goes into RAM, load LMA copy after code */ - .data : - { - . = ALIGN(4); - _sdata = .; /* create a global symbol at data start */ - *(.data) /* .data sections */ - *(.data*) /* .data* sections */ - - . = ALIGN(4); - _edata = .; /* define a global symbol at data end */ - } >RAM AT> FLASH - - - /* Uninitialized data section */ - . = ALIGN(4); - .bss : - { - /* This is used by the startup in order to initialize the .bss section */ - _sbss = .; /* define a global symbol at bss start */ - __bss_start__ = _sbss; - *(.bss) - *(.bss*) - *(COMMON) - - . = ALIGN(4); - _ebss = .; /* define a global symbol at bss end */ - __bss_end__ = _ebss; - } >RAM - - /* User_heap_stack section, used to check that there is enough RAM left */ - ._user_heap_stack : - { - . = ALIGN(4); - PROVIDE ( end = . ); - PROVIDE ( _end = . ); - . = . + _Min_Heap_Size; - . = . + _Min_Stack_Size; - . = ALIGN(4); - } >RAM - - - - /* Remove information from the standard libraries */ - /DISCARD/ : - { - libc.a ( * ) - libm.a ( * ) - libgcc.a ( * ) - } - - .ARM.attributes 0 : { *(.ARM.attributes) } -} - - diff --git a/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/variant.cpp b/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/variant.cpp deleted file mode 100644 index 4ecbff0ecc5c..000000000000 --- a/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/variant.cpp +++ /dev/null @@ -1,310 +0,0 @@ -/* - ******************************************************************************* - * Copyright (c) 2017, STMicroelectronics - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************* - */ - -#include "pins_arduino.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef ARDUINO_STEVAL -// Pin number -// This array allows to wrap Arduino pin number(Dx or x) -// to STM32 PinName (PX_n) -const PinName digitalPin[] = { - PA_9, // TX - PA_10, // RX - - // WIFI - PD_3, // CTS - PD_4, // RTS - PD_5, // TX - PD_6, // RX - PB_5, // WIFI_WAKEUP - PE_11, // WIFI_RESET - PE_12, // WIFI_BOOT - - // STATUS_LED - PE_1, //STATUS_LED - - // SPI USER - PB_12, // SPI_CS - PB_15, // SPI_MOSI - PB_14, // SPI_MISO - PB_13, // SPI_SCK - - // I2C USER - PB_7, // SDA - PB_6, // SCL - - // SPI - PA_4, // SPI_CS - PA_5, // SPI_SCK - PA_6, // SPI_MISO - PA_7, // SPI_MOSI - - // JTAG - PA_13, // JTAG_TMS/SWDIO - PA_14, // JTAG_TCK/SWCLK - PB_3, // JTAG_TDO/SWO - - // SDCARD - PC_8, // SDIO_D0 - PC_9, // SDIO_D1 - PA_15, // SD_CARD_DETECT - PC_10, // SDIO_D2 - PC_11, // SDIO_D3 - PC_12, // SDIO_CK - PD_2, // SDIO_CMD - - // OTG - PA_11, // OTG_DM - PA_12, // OTG_DP - - // IR/PROBE - PD_1, // IR_OUT - PC_1, // IR_ON - - // USER_PINS - PD_7, // USER3 - PB_9, // USER1 - PE_0, // USER2 - PB_4, // USER4 - - // USERKET - PE_7, // USER_BUTTON - - // ENDSTOPS - PD_8, // X_STOP - PD_9, // Y_STOP - PD_10, // Z_STOP - PD_11, // U_STOP - PA_8, // V_STOP - PD_0, // W_STOP - - // HEATERS - PD_13, // BED_HEAT_2 - PD_14, // BED_HEAT_1 - PD_15, // BED_HEAT_3 - PC_7, // E1_HEAT_PWM - PB_0, // E2_HEAT_PWM - PB_1, // E3_HEAT_PWM - - // THERMISTOR - PC_2, // BED_THERMISTOR_1 - PC_3, // BED_THERMISTOR_2 - PA_3, // BED_THERMISTOR_3 - PA_0, // E1_THERMISTOR - PA_1, // E2_THERMISTOR - PA_2, // E3_THERMISTOR - - // FANS - PC_4, // E1_FAN - PC_5, // E2_FAN - PE_8, // E3_FAN - - // X_MOTOR - PE_13, // X_RESET - PE_14, // X_PWM - PE_15, // X_DIR - - // Y_MOTOR - PE_10, // Y_RESET - PB_10, // Y_PWM - PE_9, // Y_DIR - - // Z_MOTOR - PC_15, // Z_RESET - PC_6, // Z_PWM - PC_0, // Z_DIR - - // E1_MOTOR - PC_14, // E1_RESET - PC_13, // E1_DIR - PD_12, // E1_PWM - - // E2_MOTOR - PE_4, // E2_RESET - PE_5, // E2_PWM - PE_6, // E2_DIR - - // E3_MOTOR - PE_3, // E3_RESET - PE_2, // E3_DIR - PB_8 // E3_PWM -}; -#endif - -#ifdef __cplusplus -} -#endif - -// ---------------------------------------------------------------------------- - -#ifdef __cplusplus -extern "C" { -#endif -/** - * @brief System Clock Configuration - * The system Clock is configured as follow : - * System Clock source = PLL (HSI) - * SYSCLK(Hz) = 84000000 - * HCLK(Hz) = 84000000 - * AHB Prescaler = 1 - * APB1 Prescaler = 2 - * APB2 Prescaler = 1 - * HSI Frequency(Hz) = 16000000 - * PLL_M = 16 - * PLL_N = 336 - * PLL_P = 4 - * PLL_Q = 7 - * VDD(V) = 3.3 - * Main regulator output voltage = Scale2 mode - * Flash Latency(WS) = 2 - * @param None - * @retval None - */ -WEAK void SystemClock_Config(void) -{ - RCC_OscInitTypeDef RCC_OscInitStruct = {}; - RCC_ClkInitTypeDef RCC_ClkInitStruct = {}; - - /* Configure the main internal regulator output voltage */ - __HAL_RCC_PWR_CLK_ENABLE(); - __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2); - - /* Initializes the CPU, AHB and APB busses clocks */ - RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; - RCC_OscInitStruct.HSEState = RCC_HSE_ON; - RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; - RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; - RCC_OscInitStruct.PLL.PLLM = 15; - RCC_OscInitStruct.PLL.PLLN = 144; - RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; - RCC_OscInitStruct.PLL.PLLQ = 5; - if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { - Error_Handler(); - } - /* Initializes the CPU, AHB and APB busses clocks */ - RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK - | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2; - RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; - RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; - RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; - RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; - - if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) { - Error_Handler(); - } -} - -#ifdef __cplusplus -} -#endif - - -// PA_0 54 // E1_THERMISTOR -// PA_1 55 // E2_THERMISTOR -// PA_2 56 // E3_THERMISTOR -// PA_3 53 // BED_THERMISTOR_3 -// PA_4 16 // SPI_CS -// PA_5 17 // SPI_SCK -// PA_6 18 // SPI_MISO -// PA_7 19 // SPI_MOSI -// PA_8 43 // V_STOP -// PA_9 0 //TX -// PA_10 1 //RX -// PA_11 30 //OTG_DM -// PA_12 31 //OTG_DP -// PA_13 20 // JTAG_TMS/SWDIO -// PA_14 21 // JTAG_TCK/SWCLK -// PA_15 25 // SD_CARD_DETECT -// PB_0 49 // E2_HEAT_PWM -// PB_1 50 // E3_HEAT_PWM -// PB_3 22 // JTAG_TDO/SWO -// PB_4 37 // USER4 -// PB_5 6 // WIFI_WAKEUP -// PB_6 15 // SCL -// PB_7 14 // SDA -// PB_8 77 // E3_PWM -// PB_9 35 // USER1 -// PB_10 64 // Y_PWM -// PB_12 10 // SPI_CS -// PB_13 13 // SPI_SCK -// PB_14 12 // SPI_MISO -// PB_15 11 // SPI_MOSI -// PC_0 68 // Z_DIR -// PC_1 33 //IR_ON -// PC_2 51 // BED_THERMISTOR_1 -// PC_3 52 // BED_THERMISTOR_2 -// PC_4 57 // E1_FAN -// PC_5 58 // E2_FAN -// PC_6 67 // Z_PWM -// PC_7 48 // E1_HEAT_PWM -// PC_8 23 // SDIO_D0 -// PC_9 24 // SDIO_D1 -// PC_10 26 // SDIO_D2 -// PC_11 27 // SDIO_D3 -// PC_12 28 // SDIO_CK -// PC_13 70 // E1_DIR -// PC_14 69 // E1_RESET -// PC_15 66 // Z_RESET -// PD_0 44 // W_STOP -// PD_1 32 //IR_OUT -// PD_2 29 // SDIO_CMD -// PD_3 2 // CTS -// PD_4 3 // RTS -// PD_5 4 // TX -// PD_6 5 // RX -// PD_7 34 // USER3 -// PD_8 39 // X_STOP -// PD_9 40 // Y_STOP -// PD_10 41 // Z_STOP -// PD_11 42 // U_STOP -// PD_12 71 // E1_PWM -// PD_13 45 // BED_HEAT_2 -// PD_14 46 // BED_HEAT_1 -// PD_15 47 // BED_HEAT_3 -// PE_0 36 // USER2 -// PE_1 9 // STATUS_LED -// PE_2 76 // E3_DIR -// PE_3 75 // E3_RESET -// PE_4 72 // E2_RESET -// PE_5 73 // E2_PWM -// PE_6 74 // E2_DIR -// PE_7 38 // USER_BUTTON -// PE_8 59 // E3_FAN -// PE_9 65 // Y_DIR -// PE_10 63 // Y_RESET -// PE_11 7 // WIFI_RESET -// PE_12 8 // WIFI_BOOT -// PE_13 60 // X_RESET -// PE_14 61 // X_PWM -// PE_15 62 // X_DIR diff --git a/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/variant.h deleted file mode 100644 index df7295ab17e8..000000000000 --- a/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/variant.h +++ /dev/null @@ -1,327 +0,0 @@ -/* - ******************************************************************************* - * Copyright (c) 2017, STMicroelectronics - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************* - */ - -#ifndef _VARIANT_ARDUINO_STM32_ -#define _VARIANT_ARDUINO_STM32_ -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ - -#ifdef __cplusplus -extern "C" { -#endif // __cplusplus - -/*---------------------------------------------------------------------------- - * Pins - *----------------------------------------------------------------------------*/ -#ifdef ARDUINO_STEVAL - - -/*---------------------------------------------------------------------------- - * Pins - *----------------------------------------------------------------------------*/ -// USART1_MAIN -#define PA9 0 //TX -#define PA10 1 //RX - -// WIFI (USART2) -#define PD3 2 // CTS -#define PD4 3 // RTS -#define PD5 4 // TX -#define PD6 5 // RX -#define PB5 6 // WIFI_WAKEUP -#define PE11 7 // WIFI_RESET -#define PE12 8 // WIFI_BOOT - -// STATUS_LED -#define PE1 9 // STATUS_LED - -// SPI USER -#define PB12 10 // SPI_CS -#define PB15 11 // SPI_MOSI -#define PB14 12 // SPI_MISO -#define PB13 13 // SPI_SCK - -// I2C USER -#define PB7 14 // SDA -#define PB6 15 // SCL - -// SPI -#define PA4 16 // SPI_CS -#define PA5 17 // SPI_SCK -#define PA6 18 // SPI_MISO -#define PA7 19 // SPI_MOSI - -// JTAG -#define PA13 20 // JTAG_TMS/SWDIO -#define PA14 21 // JTAG_TCK/SWCLK -#define PB3 22 // JTAG_TDO/SWO - -// SDCARD -#define PC8 23 // SDIO_D0 -#define PC9 24 // SDIO_D1 -#define PA15 25 // SD_CARD_DETECT -#define PC10 26 // SDIO_D2 -#define PC11 27 // SDIO_D3 -#define PC12 28 // SDIO_CK -#define PD2 29 // SDIO_CMD - -// OTG -#define PA11 30 //OTG_DM -#define PA12 31 //OTG_DP - -// IR/PROBE -#define PD1 32 //IR_OUT -#define PC1 33 //IR_ON - -// USER_PINS -#define PD7 34 // USER3 -#define PB9 35 // USER1 -#define PE0 36 // USER2 -#define PB4 37 // USER4 - -// USERKET -#define PE7 38 // USER_BUTTON - -// ENDSTOPS -#define PD8 39 // X_STOP -#define PD9 40 // Y_STOP -#define PD10 41 // Z_STOP -#define PD11 42 // U_STOP -#define PA8 43 // V_STOP -#define PD0 44 // W_STOP - -// HEATERS -#define PD13 45 // BED_HEAT_2 -#define PD14 46 // BED_HEAT_1 -#define PD15 47 // BED_HEAT_3 -#define PC7 48 // E1_HEAT_PWM -#define PB0 49 // E2_HEAT_PWM -#define PB1 50 // E3_HEAT_PWM - -// THERMISTOR -#define PC2 51 // BED_THERMISTOR_1 -#define PC3 52 // BED_THERMISTOR_2 -#define PA3 53 // BED_THERMISTOR_3 -#define PA0 54 // E1_THERMISTOR -#define PA1 55 // E2_THERMISTOR -#define PA2 56 // E3_THERMISTOR - -// FANS -#define PC4 57 // E1_FAN -#define PC5 58 // E2_FAN -#define PE8 59 // E3_FAN - -// X_MOTOR -#define PE13 60 // X_RESET -#define PE14 61 // X_PWM -#define PE15 62 // X_DIR - -// Y_MOTOR -#define PE10 63 // Y_RESET -#define PB10 64 // Y_PWM -#define PE9 65 // Y_DIR - -// Z_MOTOR -#define PC15 66 // Z_RESET -#define PC6 67 // Z_PWM -#define PC0 68 // Z_DIR - -// E1_MOTOR -#define PC14 69 // E1_RESET -#define PC13 70 // E1_DIR -#define PD12 71 // E1_PWM - -// E2_MOTOR -#define PE4 72 // E2_RESET -#define PE5 73 // E2_PWM -#define PE6 74 // E2_DIR - -// E3_MOTOR -#define PE3 75 // E3_RESET -#define PE2 76 // E3_DIR -#define PB8 77 // E3_PWM - -// This must be a literal -#define NUM_DIGITAL_PINS 78 -// This must be a literal with a value less than or equal to to MAX_ANALOG_INPUTS -#define NUM_ANALOG_INPUTS 6 -#define NUM_ANALOG_FIRST 51 - -// On-board LED pin number -#define LED_BUILTIN PE1 -#define LED_GREEN LED_BUILTIN - -// On-board user button -#define USER_BTN PE7 - -// UART Definitions -#define SERIAL_UART_INSTANCE 1 // Connected to ST-Link -//#define SERIAL_UART_INSTANCE 2 // Connected to WIFI - -// Default pin used for 'Serial' instance (ex: ST-Link) -// Mandatory for Firmata -#if SERIAL_UART_INSTANCE == 1 // ST-Link & J23 - #define PIN_SERIAL_RX PA10 - #define PIN_SERIAL_TX PA9 -#elif SERIAL_UART_INSTANCE == 2 // WIFI interface - #define PIN_SERIAL2_RX PD6 - #define PIN_SERIAL2_TX PD5 -#else - #error "Invalid setting for SERIAL_UART_INSTANCE." -#endif - -// Timer Definitions -#define TIMER_SERVO TIM4 // TIMER_SERVO must be defined in this file -#define TIMER_TONE TIM5 // TIMER_TONE must be defined in this file - -/* SD detect signal */ -/* - * By default, R67 is not provided, so SD card detect is not used. - * Note: SD CD (pin 16 of expansion connector J23) can be connected - * to GND in order to be able to use SD_DETECT_PIN - */ -/*#define SD_DETECT_PIN PA15*/ - -/* HAL configuration */ -#define HSE_VALUE 25000000U - -/* Extra HAL modules */ -#define HAL_SD_MODULE_ENABLED - -#endif - -#ifdef __cplusplus -} // extern "C" -#endif -/*---------------------------------------------------------------------------- - * Arduino objects - C++ only - *----------------------------------------------------------------------------*/ - -#ifdef __cplusplus -// These serial port names are intended to allow libraries and architecture-neutral -// sketches to automatically default to the correct port name for a particular type -// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, -// the first hardware serial port whose RX/TX pins are not dedicated to another use. -// -// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor -// -// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial -// -// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library -// -// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. -// -// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX -// pins are NOT connected to anything by default. -#define SERIAL_PORT_MONITOR Serial -#define SERIAL_PORT_HARDWARE Serial1 -#endif - -#endif // _VARIANT_ARDUINO_STM32_ - -// PA0 54 // E1_THERMISTOR -// PA1 55 // E2_THERMISTOR -// PA2 56 // E3_THERMISTOR -// PA3 53 // BED_THERMISTOR_3 -// PA4 16 // SPI_CS -// PA5 17 // SPI_SCK -// PA6 18 // SPI_MISO -// PA7 19 // SPI_MOSI -// PA8 43 // V_STOP -// PA9 0 //TX -// PA10 1 //RX -// PA11 30 //OTG_DM -// PA12 31 //OTG_DP -// PA13 20 // JTAG_TMS/SWDIO -// PA14 21 // JTAG_TCK/SWCLK -// PA15 25 // SD_CARD_DETECT -// PB0 49 // E2_HEAT_PWM -// PB1 50 // E3_HEAT_PWM -// PB3 22 // JTAG_TDO/SWO -// PB4 37 // USER4 -// PB5 6 // WIFI_WAKEUP -// PB6 15 // SCL -// PB7 14 // SDA -// PB8 77 // E3_PWM -// PB9 35 // USER1 -// PB10 64 // Y_PWM -// PB12 10 // SPI_CS -// PB13 13 // SPI_SCK -// PB14 12 // SPI_MISO -// PB15 11 // SPI_MOSI -// PC0 68 // Z_DIR -// PC1 33 //IR_ON -// PC2 51 // BED_THERMISTOR_1 -// PC3 52 // BED_THERMISTOR_2 -// PC4 57 // E1_FAN -// PC5 58 // E2_FAN -// PC6 67 // Z_PWM -// PC7 48 // E1_HEAT_PWM -// PC8 23 // SDIO_D0 -// PC9 24 // SDIO_D1 -// PC10 26 // SDIO_D2 -// PC11 27 // SDIO_D3 -// PC12 28 // SDIO_CK -// PC13 70 // E1_DIR -// PC14 69 // E1_RESET -// PC15 66 // Z_RESET -// PD0 44 // W_STOP -// PD1 32 //IR_OUT -// PD2 29 // SDIO_CMD -// PD3 2 // CTS -// PD4 3 // RTS -// PD5 4 // TX -// PD6 5 // RX -// PD7 34 // USER3 -// PD8 39 // X_STOP -// PD9 40 // Y_STOP -// PD10 41 // Z_STOP -// PD11 42 // U_STOP -// PD12 71 // E1_PWM -// PD13 45 // BED_HEAT_2 -// PD14 46 // BED_HEAT_1 -// PD15 47 // BED_HEAT_3 -// PE0 36 // USER2 -// PE1 9 // STATUS_LED -// PE2 76 // E3_DIR -// PE3 75 // E3_RESET -// PE4 72 // E2_RESET -// PE5 73 // E2_PWM -// PE6 74 // E2_DIR -// PE7 38 // USER_BUTTON -// PE8 59 // E3_FAN -// PE9 65 // Y_DIR -// PE10 63 // Y_RESET -// PE11 7 // WIFI_RESET -// PE12 8 // WIFI_BOOT -// PE13 60 // X_RESET -// PE14 61 // X_PWM -// PE15 62 // X_DIR diff --git a/buildroot/tests/FYSETC_F6 b/buildroot/tests/FYSETC_F6 index 17f8eb42b1e2..91b1f899ffea 100755 --- a/buildroot/tests/FYSETC_F6 +++ b/buildroot/tests/FYSETC_F6 @@ -18,15 +18,11 @@ exec_test $1 $2 "FYSETC F6 1.3 with DGUS" "$3" # Delta Config (generic) + UBL + ALLEN_KEY + EEPROM_SETTINGS + OLED_PANEL_TINYBOY2 # use_example_configs delta/generic -opt_set MOTHERBOARD BOARD_FYSETC_F6_13 \ - LCD_LANGUAGE ko_KR \ - X_DRIVER_TYPE L6470 Y_DRIVER_TYPE L6470 Z_DRIVER_TYPE L6470 \ - L6470_CHAIN_SCK_PIN 53 L6470_CHAIN_MISO_PIN 49 L6470_CHAIN_MOSI_PIN 40 L6470_CHAIN_SS_PIN 42 \ - 'ENABLE_RESET_L64XX_CHIPS(V)' NOOP +opt_set MOTHERBOARD BOARD_FYSETC_F6_13 LCD_LANGUAGE ko_KR opt_enable RESTORE_LEVELING_AFTER_G28 EEPROM_SETTINGS EEPROM_CHITCHAT \ Z_PROBE_ALLEN_KEY AUTO_BED_LEVELING_UBL UBL_MESH_WIZARD \ OLED_PANEL_TINYBOY2 MESH_EDIT_GFX_OVERLAY DELTA_CALIBRATION_MENU -exec_test $1 $2 "DELTA, RAMPS, L6470, UBL, Allen Key, EEPROM, OLED_PANEL_TINYBOY2..." "$3" +exec_test $1 $2 "DELTA, FYSETC F6 1.3, UBL, Allen Key, EEPROM, OLED_PANEL_TINYBOY2..." "$3" # # Test mixed TMC config diff --git a/buildroot/tests/STM32F401VE_STEVAL b/buildroot/tests/STM32F401VE_STEVAL deleted file mode 100755 index 1704f3d2f004..000000000000 --- a/buildroot/tests/STM32F401VE_STEVAL +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash -# -# Build tests for STM32F401VE_STEVAL -# - -# exit on first failure -set -e - -# Build examples -restore_configs -opt_set MOTHERBOARD BOARD_STEVAL_3DP001V1 SERIAL_PORT -1 -exec_test $1 $2 "STM32F401VE_STEVAL Default Config" "$3" - -# cleanup -restore_configs diff --git a/ini/features.ini b/ini/features.ini index 6fd8a7950bae..3e34e01d5c87 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -26,8 +26,6 @@ HAS_MOTOR_CURRENT_I2C = SlowSoftI2CMaster src_filter=+ HAS_TMC26X = TMC26XStepper=https://github.com/MarlinFirmware/TMC26XStepper/archive/master.zip src_filter=+ -HAS_L64XX = Arduino-L6470@0.8.0 - src_filter=+ + + + LIB_INTERNAL_MAX31865 = src_filter=+ NEOPIXEL_LED = adafruit/Adafruit NeoPixel@~1.8.0 src_filter=+ diff --git a/ini/stm32f4.ini b/ini/stm32f4.ini index a663d31483fc..5e0d4a13ecb4 100644 --- a/ini/stm32f4.ini +++ b/ini/stm32f4.ini @@ -28,17 +28,6 @@ board = armed_v1 build_flags = ${common_stm32.build_flags} -O2 -ffreestanding -fsigned-char -fno-move-loop-invariants -fno-strict-aliasing -# -# STM32F401VE -# 'STEVAL-3DP001V1' STM32F401VE board - https://www.st.com/en/evaluation-tools/steval-3dp001v1.html -# -[env:STM32F401VE_STEVAL] -extends = stm32_variant -board = marlin_STEVAL_STM32F401VE -build_flags = ${stm32_variant.build_flags} - -DSTM32F401xE -DDISABLE_GENERIC_SERIALUSB - -DUSBD_USE_CDC_COMPOSITE -DUSE_USB_FS - # # STM32F401RC # From 3a19d34c7515598180abbc3e24d8991f8e8a098a Mon Sep 17 00:00:00 2001 From: toomuchwonder <43323256+toomuchwonder@users.noreply.github.com> Date: Thu, 14 Jul 2022 04:17:53 +0100 Subject: [PATCH 27/32] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20MKS=20UI=20extruder?= =?UTF-8?q?=20speed=20(#24476)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/extui/mks_ui/draw_ui.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/lcd/extui/mks_ui/draw_ui.h b/Marlin/src/lcd/extui/mks_ui/draw_ui.h index 798e662220ef..9bc583d3ad32 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_ui.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_ui.h @@ -236,9 +236,9 @@ typedef struct UI_Config_Struct { eStepMax = 10; // Extruder speed (mm/s) uint8_t extruSpeed; - static constexpr uint8_t eSpeedH = 1, + static constexpr uint8_t eSpeedH = 20, eSpeedN = 10, - eSpeedL = 20; + eSpeedL = 1; uint8_t print_state; uint8_t stepPrintSpeed; uint8_t waitEndMoves; From 3c9789fda810cb6cebfb835379780b27e1dbe6f5 Mon Sep 17 00:00:00 2001 From: Miguel Risco-Castillo Date: Thu, 14 Jul 2022 00:00:33 -0500 Subject: [PATCH 28/32] =?UTF-8?q?=F0=9F=9A=B8=20Fix=20and=20update=20ProUI?= =?UTF-8?q?=20(#24477)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/e3v2/common/dwin_font.h | 2 + .../{ubl_tools.cpp => bedlevel_tools.cpp} | 82 ++++--- .../proui/{ubl_tools.h => bedlevel_tools.h} | 46 ++-- Marlin/src/lcd/e3v2/proui/dwin.cpp | 223 +++++++++--------- Marlin/src/lcd/e3v2/proui/dwin.h | 11 +- Marlin/src/lcd/e3v2/proui/dwin_defines.h | 15 +- Marlin/src/lcd/e3v2/proui/dwinui.cpp | 60 +++-- Marlin/src/lcd/e3v2/proui/dwinui.h | 157 ++++++------ Marlin/src/lcd/e3v2/proui/lockscreen.cpp | 8 +- Marlin/src/lcd/e3v2/proui/menus.cpp | 26 +- Marlin/src/lcd/e3v2/proui/menus.h | 6 +- Marlin/src/lcd/e3v2/proui/meshviewer.cpp | 15 +- Marlin/src/lcd/e3v2/proui/meshviewer.h | 3 - Marlin/src/lcd/e3v2/proui/plot.cpp | 9 +- Marlin/src/lcd/language/language_en.h | 1 + Marlin/src/module/planner.h | 2 +- Marlin/src/module/settings.cpp | 13 +- 17 files changed, 376 insertions(+), 303 deletions(-) rename Marlin/src/lcd/e3v2/proui/{ubl_tools.cpp => bedlevel_tools.cpp} (78%) rename Marlin/src/lcd/e3v2/proui/{ubl_tools.h => bedlevel_tools.h} (64%) diff --git a/Marlin/src/lcd/e3v2/common/dwin_font.h b/Marlin/src/lcd/e3v2/common/dwin_font.h index 5a4b1a61cf24..10bb104d27bc 100644 --- a/Marlin/src/lcd/e3v2/common/dwin_font.h +++ b/Marlin/src/lcd/e3v2/common/dwin_font.h @@ -21,6 +21,8 @@ */ #pragma once +typedef uint8_t fontid_t; + /** * 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 diff --git a/Marlin/src/lcd/e3v2/proui/ubl_tools.cpp b/Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp similarity index 78% rename from Marlin/src/lcd/e3v2/proui/ubl_tools.cpp rename to Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp index 87909d2dd2a2..e967c26198be 100644 --- a/Marlin/src/lcd/e3v2/proui/ubl_tools.cpp +++ b/Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp @@ -21,19 +21,20 @@ */ /** - * UBL Tools and Mesh Viewer for Pro UI - * Version: 1.0.0 - * Date: 2022/04/13 + * Bed Level Tools for Pro UI + * Extended by: Miguel A. Risco-Castillo (MRISCOC) + * Version: 2.0.0 + * Date: 2022/05/23 * - * Original Author: Henri-J-Norden - * Original Source: https://github.com/Jyers/Marlin/pull/126 + * Based on the original work of: Henri-J-Norden + * https://github.com/Jyers/Marlin/pull/126 */ #include "../../../inc/MarlinConfigPre.h" +#include "bedlevel_tools.h" -#if BOTH(DWIN_LCD_PROUI, AUTO_BED_LEVELING_UBL) +#if BOTH(DWIN_LCD_PROUI, HAS_LEVELING) -#include "ubl_tools.h" #include "../../marlinui.h" #include "../../../core/types.h" #include "dwin.h" @@ -47,27 +48,29 @@ #include "../../../libs/least_squares_fit.h" #include "../../../libs/vector_3.h" -UBLMeshToolsClass ubl_tools; +BedLevelToolsClass BedLevelTools; -#if ENABLED(USE_UBL_VIEWER) - bool UBLMeshToolsClass::viewer_asymmetric_range = false; - bool UBLMeshToolsClass::viewer_print_value = false; +#if USE_UBL_VIEWER + bool BedLevelToolsClass::viewer_asymmetric_range = false; + bool BedLevelToolsClass::viewer_print_value = false; #endif -bool UBLMeshToolsClass::goto_mesh_value = false; -uint8_t UBLMeshToolsClass::tilt_grid = 1; +bool BedLevelToolsClass::goto_mesh_value = false; +uint8_t BedLevelToolsClass::mesh_x = 0; +uint8_t BedLevelToolsClass::mesh_y = 0; +uint8_t BedLevelToolsClass::tilt_grid = 1; bool drawing_mesh = false; char cmd[MAX_CMD_SIZE+16], str_1[16], str_2[16], str_3[16]; #if ENABLED(AUTO_BED_LEVELING_UBL) - void UBLMeshToolsClass::manual_value_update(const uint8_t mesh_x, const uint8_t mesh_y, bool undefined/*=false*/) { + void BedLevelToolsClass::manual_value_update(const uint8_t mesh_x, const uint8_t mesh_y, bool undefined/*=false*/) { sprintf_P(cmd, PSTR("M421 I%i J%i Z%s %s"), mesh_x, mesh_y, dtostrf(current_position.z, 1, 3, str_1), undefined ? "N" : ""); gcode.process_subcommands_now(cmd); planner.synchronize(); } - bool UBLMeshToolsClass::create_plane_from_mesh() { + bool BedLevelToolsClass::create_plane_from_mesh() { struct linear_fit_data lsf_results; incremental_LSF_reset(&lsf_results); GRID_LOOP(x, y) { @@ -119,7 +122,7 @@ char cmd[MAX_CMD_SIZE+16], str_1[16], str_2[16], str_3[16]; #else - void UBLMeshToolsClass::manual_value_update(const uint8_t mesh_x, const uint8_t mesh_y) { + void BedLevelToolsClass::manual_value_update(const uint8_t mesh_x, const uint8_t mesh_y) { sprintf_P(cmd, PSTR("G29 I%i J%i Z%s"), mesh_x, mesh_y, dtostrf(current_position.z, 1, 3, str_1)); gcode.process_subcommands_now(cmd); planner.synchronize(); @@ -127,7 +130,8 @@ char cmd[MAX_CMD_SIZE+16], str_1[16], str_2[16], str_3[16]; #endif -void UBLMeshToolsClass::manual_move(const uint8_t mesh_x, const uint8_t mesh_y, bool zmove/*=false*/) { +void BedLevelToolsClass::manual_move(const uint8_t mesh_x, const uint8_t mesh_y, bool zmove/*=false*/) { + gcode.process_subcommands_now(F("G28O")); if (zmove) { planner.synchronize(); current_position.z = goto_mesh_value ? bedlevel.z_values[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES; @@ -149,8 +153,28 @@ void UBLMeshToolsClass::manual_move(const uint8_t mesh_x, const uint8_t mesh_y, } } -float UBLMeshToolsClass::get_max_value() { - float max = __FLT_MIN__; +void BedLevelToolsClass::MoveToXYZ() { + BedLevelTools.goto_mesh_value = true; + BedLevelTools.manual_move(BedLevelTools.mesh_x, BedLevelTools.mesh_y, false); +} +void BedLevelToolsClass::MoveToXY() { + BedLevelTools.goto_mesh_value = false; + BedLevelTools.manual_move(BedLevelTools.mesh_x, BedLevelTools.mesh_y, false); +} +void BedLevelToolsClass::MoveToZ() { + BedLevelTools.goto_mesh_value = true; + BedLevelTools.manual_move(BedLevelTools.mesh_x, BedLevelTools.mesh_y, true); +} +void BedLevelToolsClass::ProbeXY() { + sprintf_P(cmd, PSTR("G30X%sY%s"), + dtostrf(bedlevel.get_mesh_x(BedLevelTools.mesh_x), 1, 2, str_1), + dtostrf(bedlevel.get_mesh_y(BedLevelTools.mesh_y), 1, 2, str_2) + ); + gcode.process_subcommands_now(cmd); +} + +float BedLevelToolsClass::get_max_value() { + float max = __FLT_MAX__ * -1; GRID_LOOP(x, y) { if (!isnan(bedlevel.z_values[x][y]) && bedlevel.z_values[x][y] > max) max = bedlevel.z_values[x][y]; @@ -158,7 +182,7 @@ float UBLMeshToolsClass::get_max_value() { return max; } -float UBLMeshToolsClass::get_min_value() { +float BedLevelToolsClass::get_min_value() { float min = __FLT_MAX__; GRID_LOOP(x, y) { if (!isnan(bedlevel.z_values[x][y]) && bedlevel.z_values[x][y] < min) @@ -167,19 +191,20 @@ float UBLMeshToolsClass::get_min_value() { return min; } -bool UBLMeshToolsClass::validate() { - float min = __FLT_MAX__, max = __FLT_MIN__; +bool BedLevelToolsClass::meshvalidate() { + float min = __FLT_MAX__, max = __FLT_MAX__ * -1; GRID_LOOP(x, y) { if (isnan(bedlevel.z_values[x][y])) return false; if (bedlevel.z_values[x][y] < min) min = bedlevel.z_values[x][y]; if (bedlevel.z_values[x][y] > max) max = bedlevel.z_values[x][y]; } - return max <= UBL_Z_OFFSET_MAX && min >= UBL_Z_OFFSET_MIN; + return WITHIN(max, MESH_Z_OFFSET_MIN, MESH_Z_OFFSET_MAX); } -#if ENABLED(USE_UBL_VIEWER) - void UBLMeshToolsClass::Draw_Bed_Mesh(int16_t selected /*= -1*/, uint8_t gridline_width /*= 1*/, uint16_t padding_x /*= 8*/, uint16_t padding_y_top /*= 40 + 53 - 7*/) { +#if USE_UBL_VIEWER + + void BedLevelToolsClass::Draw_Bed_Mesh(int16_t selected /*= -1*/, uint8_t gridline_width /*= 1*/, uint16_t padding_x /*= 8*/, uint16_t padding_y_top /*= 40 + 53 - 7*/) { drawing_mesh = true; const uint16_t total_width_px = DWIN_WIDTH - padding_x - padding_x; const uint16_t cell_width_px = total_width_px / (GRID_MAX_POINTS_X); @@ -237,7 +262,7 @@ bool UBLMeshToolsClass::validate() { } } - void UBLMeshToolsClass::Set_Mesh_Viewer_Status() { // TODO: draw gradient with values as a legend instead + void BedLevelToolsClass::Set_Mesh_Viewer_Status() { // TODO: draw gradient with values as a legend instead float v_max = abs(get_max_value()), v_min = abs(get_min_value()), range = _MAX(v_min, v_max); if (v_min > 3e+10F) v_min = 0.0000001; if (v_max > 3e+10F) v_max = 0.0000001; @@ -255,6 +280,7 @@ bool UBLMeshToolsClass::validate() { ui.set_status(msg); drawing_mesh = false; } -#endif -#endif // DWIN_LCD_PROUI && AUTO_BED_LEVELING_UBL +#endif // USE_UBL_VIEWER + +#endif // DWIN_LCD_PROUI && HAS_LEVELING diff --git a/Marlin/src/lcd/e3v2/proui/ubl_tools.h b/Marlin/src/lcd/e3v2/proui/bedlevel_tools.h similarity index 64% rename from Marlin/src/lcd/e3v2/proui/ubl_tools.h rename to Marlin/src/lcd/e3v2/proui/bedlevel_tools.h index 563794a46385..9373d593f969 100644 --- a/Marlin/src/lcd/e3v2/proui/ubl_tools.h +++ b/Marlin/src/lcd/e3v2/proui/bedlevel_tools.h @@ -1,10 +1,9 @@ -/** - * UBL Tools and Mesh Viewer for Pro UI - * Version: 1.0.0 - * Date: 2022/04/13 +/* + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] * - * Original Author: Henri-J-Norden (https://github.com/Henri-J-Norden) - * Original Source: https://github.com/Jyers/Marlin/pull/135 + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,22 +19,37 @@ * along with this program. If not, see . * */ + +/** + * Bed Level Tools for Pro UI + * Extended by: Miguel A. Risco-Castillo (MRISCOC) + * Version: 2.0.0 + * Date: 2022/05/23 + * + * Based on the original work of: Henri-J-Norden + * https://github.com/Jyers/Marlin/pull/126 + */ + #pragma once #include "../../../inc/MarlinConfigPre.h" -//#define USE_UBL_VIEWER 1 +#if ENABLED(AUTO_BED_LEVELING_UBL) + //#define USE_UBL_VIEWER 1 +#endif -#define UBL_Z_OFFSET_MIN -3.0 -#define UBL_Z_OFFSET_MAX 3.0 +#define MESH_Z_OFFSET_MIN -3.0 +#define MESH_Z_OFFSET_MAX 3.0 -class UBLMeshToolsClass { +class BedLevelToolsClass { public: - #if ENABLED(USE_UBL_VIEWER) + #if USE_UBL_VIEWER static bool viewer_asymmetric_range; static bool viewer_print_value; #endif static bool goto_mesh_value; + static uint8_t mesh_x; + static uint8_t mesh_y; static uint8_t tilt_grid; #if ENABLED(AUTO_BED_LEVELING_UBL) @@ -45,15 +59,19 @@ class UBLMeshToolsClass { static void manual_value_update(const uint8_t mesh_x, const uint8_t mesh_y); #endif static void manual_move(const uint8_t mesh_x, const uint8_t mesh_y, bool zmove=false); + static void MoveToXYZ(); + static void MoveToXY(); + static void MoveToZ(); + static void ProbeXY(); static float get_max_value(); static float get_min_value(); - static bool validate(); - #if ENABLED(USE_UBL_VIEWER) + static bool meshvalidate(); + #if USE_UBL_VIEWER static void Draw_Bed_Mesh(int16_t selected = -1, uint8_t gridline_width = 1, uint16_t padding_x = 8, uint16_t padding_y_top = 40 + 53 - 7); static void Set_Mesh_Viewer_Status(); #endif }; -extern UBLMeshToolsClass ubl_tools; +extern BedLevelToolsClass BedLevelTools; void Goto_MeshViewer(); diff --git a/Marlin/src/lcd/e3v2/proui/dwin.cpp b/Marlin/src/lcd/e3v2/proui/dwin.cpp index 07b134471b58..27e1003ab6eb 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin.cpp @@ -101,17 +101,18 @@ #if HAS_MESH || HAS_ONESTEP_LEVELING #include "../../../feature/bedlevel/bedlevel.h" + #include "bedlevel_tools.h" #endif #if HAS_BED_PROBE #include "../../../module/probe.h" #endif -#ifdef BLTOUCH_HS_MODE +#if ENABLED(BLTOUCH) #include "../../../feature/bltouch.h" #endif -#if ANY(BABYSTEPPING, HAS_BED_PROBE, HAS_WORKSPACE_OFFSET) +#if EITHER(BABYSTEPPING, HAS_BED_PROBE) #define HAS_ZOFFSET_ITEM 1 #if ENABLED(BABYSTEPPING) #include "../../../feature/babystep.h" @@ -141,10 +142,6 @@ #include "meshviewer.h" #endif -#if ENABLED(AUTO_BED_LEVELING_UBL) - #include "ubl_tools.h" -#endif - #if ENABLED(PRINTCOUNTER) #include "printstats.h" #endif @@ -157,16 +154,14 @@ #include "../../../feature/leds/leds.h" #endif -#include -#include -#include +#if HAS_LOCKSCREEN + #include "lockscreen.h" +#endif #ifndef MACHINE_SIZE #define MACHINE_SIZE STRINGIFY(X_BED_SIZE) "x" STRINGIFY(Y_BED_SIZE) "x" STRINGIFY(Z_MAX_POS) #endif -#include "lockscreen.h" - #define PAUSE_HEAT #define MENU_CHAR_LIMIT 24 @@ -251,6 +246,7 @@ constexpr float max_feedrate_edit_values[] = { 1000, 1000, 10, 50 } #endif ; + constexpr float max_acceleration_edit_values[] = #ifdef MAX_ACCEL_EDIT_VALUES MAX_ACCEL_EDIT_VALUES @@ -258,6 +254,7 @@ constexpr float max_acceleration_edit_values[] = { 1000, 1000, 200, 2000 } #endif ; + #if HAS_CLASSIC_JERK constexpr float max_jerk_edit_values[] = #ifdef MAX_JERK_EDIT_VALUES @@ -305,7 +302,9 @@ MenuClass *FilamentMenu = nullptr; MenuClass *TemperatureMenu = nullptr; MenuClass *MaxSpeedMenu = nullptr; MenuClass *MaxAccelMenu = nullptr; -MenuClass *MaxJerkMenu = nullptr; +#if HAS_CLASSIC_JERK + MenuClass *MaxJerkMenu = nullptr; +#endif MenuClass *StepsMenu = nullptr; MenuClass *HotendPIDMenu = nullptr; MenuClass *BedPIDMenu = nullptr; @@ -552,14 +551,9 @@ void Popup_window_PauseOrStop() { #endif // Draw status line -void DWIN_DrawStatusLine(const char *text) { - DWIN_Draw_Rectangle(1, HMI_data.StatusBg_Color, 0, STATUS_Y, DWIN_WIDTH, STATUS_Y + 20); - if (text) DWINUI::Draw_CenteredString(HMI_data.StatusTxt_Color, STATUS_Y + 2, text); -} - -void DWIN_DrawStatusLine(FSTR_P fstr) { +void DWIN_DrawStatusLine() { DWIN_Draw_Rectangle(1, HMI_data.StatusBg_Color, 0, STATUS_Y, DWIN_WIDTH, STATUS_Y + 20); - if (fstr) DWINUI::Draw_CenteredString(HMI_data.StatusTxt_Color, STATUS_Y + 2, fstr); + DWINUI::Draw_CenteredString(HMI_data.StatusTxt_Color, STATUS_Y + 2, ui.status_message); } // Clear & reset status line @@ -588,7 +582,7 @@ void DWIN_DrawStatusMessage() { // If the string fits the status line do not scroll it if (slen <= LCD_WIDTH) { if (hash_changed) { - DWIN_DrawStatusLine(ui.status_message); + DWIN_DrawStatusLine(); hash_changed = false; } } @@ -620,7 +614,7 @@ void DWIN_DrawStatusMessage() { if (hash_changed) { ui.status_message[LCD_WIDTH] = 0; - DWIN_DrawStatusLine(ui.status_message); + DWIN_DrawStatusLine(); hash_changed = false; } @@ -663,7 +657,7 @@ void ICON_ResumeOrPause() { } // Update filename on print -void DWIN_Print_Header(const char *text = nullptr) { +void DWIN_Print_Header(const char *text=nullptr) { static char headertxt[31] = ""; // Print header text if (text) { const int8_t size = _MIN(30U, strlen_P(text)); @@ -1099,7 +1093,7 @@ void DWIN_Draw_Dashboard() { DWINUI::Draw_Int(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 3, 195 + 2 * STAT_CHR_W, 384, thermalManager.fan_speed[0]); #endif - #if BOTH(BABYSTEPPING, HAS_BED_PROBE) + #if HAS_ZOFFSET_ITEM DWINUI::Draw_Icon(planner.leveling_active ? ICON_SetZOffset : ICON_Zoffset, 187, 416); #endif @@ -1370,13 +1364,15 @@ void Draw_Main_Area() { case ESDiagProcess: Draw_EndStopDiag(); break; #endif case Popup: popupDraw(); break; - case Locked: lockScreen.draw(); break; + #if HAS_LOCKSCREEN + case Locked: lockScreen.draw(); break; + #endif case Menu: case SetInt: case SetPInt: case SetIntNoDraw: case SetFloat: - case SetPFloat: ReDrawMenu(); break; + case SetPFloat: ReDrawMenu(true); break; default: break; } } @@ -1567,7 +1563,9 @@ void DWIN_HandleScreen() { case PrintProcess: HMI_Printing(); break; case Popup: HMI_Popup(); break; case Leveling: break; - case Locked: HMI_LockScreen(); break; + #if HAS_LOCKSCREEN + case Locked: HMI_LockScreen(); break; + #endif case PrintDone: TERN_(HAS_ESDIAG, case ESDiagProcess:) case WaitResponse: HMI_WaitForUser(); break; @@ -1769,7 +1767,7 @@ void DWIN_Print_Aborted() { Goto_PrintDone(); } -// Progress Bar update +// Progress and remaining time update void DWIN_M73() { if (parser.seenval('P')) { _percent_done = parser.value_byte(); @@ -1843,11 +1841,6 @@ void DWIN_CopySettingsFrom(const char * const buff) { TERN_(PREVENT_COLD_EXTRUSION, ApplyExtMinT()); feedrate_percentage = 100; TERN_(BAUD_RATE_GCODE, HMI_SetBaudRate()); - #if BOTH(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS) - // Apply Case light brightness - caselight.brightness = HMI_data.CaseLight_Brightness; - caselight.update_brightness(); - #endif #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS) leds.set_color( (HMI_data.LED_Color >> 16) & 0xFF, @@ -1880,7 +1873,7 @@ void DWIN_InitScreen() { index_file = MROWS; hash_changed = true; last_E = 0; - DWIN_DrawStatusLine(FSTR_P(nullptr)); + DWIN_DrawStatusLine(); DWIN_Draw_Dashboard(); Goto_Main_Menu(); } @@ -1935,7 +1928,7 @@ void DWIN_RedrawScreen() { case PAUSE_MESSAGE_PARKING: DWIN_Popup_Pause(GET_TEXT_F(MSG_PAUSE_PRINT_PARKING)); break; // M125 case PAUSE_MESSAGE_CHANGING: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_INIT)); break; // pause_print (M125, M600) case PAUSE_MESSAGE_WAITING: DWIN_Popup_Pause(GET_TEXT_F(MSG_ADVANCED_PAUSE_WAITING), BTN_Continue); break; - case PAUSE_MESSAGE_INSERT: DWIN_Popup_Continue(ICON_BLTouch, GET_TEXT_F(MSG_ADVANCED_PAUSE), GET_TEXT_F(MSG_FILAMENT_CHANGE_INSERT)); break; + case PAUSE_MESSAGE_INSERT: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_INSERT), BTN_Continue); break; case PAUSE_MESSAGE_LOAD: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_LOAD)); break; case PAUSE_MESSAGE_UNLOAD: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_UNLOAD)); break; // Unload of pause and Unload of M702 case PAUSE_MESSAGE_PURGE: @@ -1988,28 +1981,32 @@ void DWIN_RedrawScreen() { } #endif // HAS_MESH -void DWIN_LockScreen() { - if (checkkey != Locked) { - lockScreen.rprocess = checkkey; - checkkey = Locked; - lockScreen.init(); + +#if HAS_LOCKSCREEN + + void DWIN_LockScreen() { + if (checkkey != Locked) { + lockScreen.rprocess = checkkey; + checkkey = Locked; + lockScreen.init(); + } } -} -void DWIN_UnLockScreen() { - if (checkkey == Locked) { - checkkey = lockScreen.rprocess; - Draw_Main_Area(); + void DWIN_UnLockScreen() { + if (checkkey == Locked) { + checkkey = lockScreen.rprocess; + Draw_Main_Area(); + } } -} -void HMI_LockScreen() { - EncoderState encoder_diffState = get_encoder_state(); - if (encoder_diffState == ENCODER_DIFF_NO) return; - lockScreen.onEncoder(encoder_diffState); - if (lockScreen.isUnlocked()) DWIN_UnLockScreen(); -} + void HMI_LockScreen() { + EncoderState encoder_diffState = get_encoder_state(); + if (encoder_diffState == ENCODER_DIFF_NO) return; + lockScreen.onEncoder(encoder_diffState); + if (lockScreen.isUnlocked()) DWIN_UnLockScreen(); + } +#endif // HAS_LOCKSCREEN #if HAS_GCODE_PREVIEW @@ -2051,7 +2048,8 @@ void HMI_LockScreen() { #if ENABLED(EEPROM_SETTINGS) void WriteEeprom() { - DWIN_DrawStatusLine(GET_TEXT_F(MSG_STORE_EEPROM)); + ui.set_status(GET_TEXT_F(MSG_STORE_EEPROM)); + DWIN_DrawStatusLine(); DWIN_UpdateLCD(); DONE_BUZZ(settings.save()); } @@ -2106,11 +2104,13 @@ void HomeX() { queue.inject(F("G28X")); } void HomeY() { queue.inject(F("G28Y")); } void HomeZ() { queue.inject(F("G28Z")); } -void SetHome() { +#if HAS_HOME_OFFSET // Apply workspace offset, making the current position 0,0,0 + void SetHome() { queue.inject(F("G92X0Y0Z0")); DONE_BUZZ(true); -} + } +#endif #if HAS_ZOFFSET_ITEM @@ -2132,22 +2132,25 @@ void SetHome() { void SetMoveZto0() { #if ENABLED(Z_SAFE_HOMING) char cmd[54], str_1[5], str_2[5]; - sprintf_P(cmd, PSTR("G28XYO\nG28Z\nG0X%sY%sF5000\nM420S0\nG0Z0F300\nM400"), + sprintf_P(cmd, PSTR("G28XYO\nG28Z\nG0X%sY%sF5000\nG0Z0F300\nM400"), dtostrf(Z_SAFE_HOMING_X_POINT, 1, 1, str_1), dtostrf(Z_SAFE_HOMING_Y_POINT, 1, 1, str_2) ); gcode.process_subcommands_now(cmd); #else - gcode.process_subcommands_now(F("G28O\nM420S0\nG0Z0F300\nM400")); + set_bed_leveling_enabled(false); + gcode.process_subcommands_now(F("G28O\nG0Z0F300\nM400")); #endif ui.reset_status(); DONE_BUZZ(true); } - void HomeZandDisable() { - SetMoveZto0(); - DisableMotors(); - } + #if !HAS_BED_PROBE + void HomeZandDisable() { + SetMoveZto0(); + DisableMotors(); + } + #endif #endif // HAS_ZOFFSET_ITEM @@ -2840,9 +2843,6 @@ void onDrawGetColorItem(MenuItemClass* menuitem, int8_t line) { DWIN_Draw_HLine(HMI_data.SplitLine_Color, 16, MYPOS(line + 1), 240); } -#if HAS_FILAMENT_SENSOR - void onDrawRunoutEnable(MenuItemClass* menuitem, int8_t line) { onDrawChkbMenu(menuitem, line, runout.enabled); } -#endif void onDrawPIDi(MenuItemClass* menuitem, int8_t line) { onDrawFloatMenu(menuitem, line, 2, unscalePID_i(*(float*)static_cast(menuitem)->value)); } void onDrawPIDd(MenuItemClass* menuitem, int8_t line) { onDrawFloatMenu(menuitem, line, 2, unscalePID_d(*(float*)static_cast(menuitem)->value)); } @@ -3249,7 +3249,9 @@ void Draw_AdvancedSettings_Menu() { MENU_ITEM_F(ICON_PrintStats, MSG_INFO_STATS_MENU, onDrawSubMenu, Goto_PrintStats); MENU_ITEM_F(ICON_PrintStatsReset, MSG_INFO_PRINT_COUNT_RESET, onDrawSubMenu, PrintStats.Reset); #endif - MENU_ITEM_F(ICON_Lock, MSG_LOCKSCREEN, onDrawMenuItem, DWIN_LockScreen); + #if HAS_LOCKSCREEN + MENU_ITEM_F(ICON_Lock, MSG_LOCKSCREEN, onDrawMenuItem, DWIN_LockScreen); + #endif } ui.reset_status(true); UpdateMenu(AdvancedSettings); @@ -3295,12 +3297,15 @@ void Draw_Move_Menu() { EDIT_ITEM_F(ICON_ProbeOffsetX, MSG_ZPROBE_XOFFSET, onDrawPFloatMenu, SetProbeOffsetX, &probe.offset.x); EDIT_ITEM_F(ICON_ProbeOffsetY, MSG_ZPROBE_YOFFSET, onDrawPFloatMenu, SetProbeOffsetY, &probe.offset.y); EDIT_ITEM_F(ICON_ProbeOffsetZ, MSG_ZPROBE_ZOFFSET, onDrawPFloat2Menu, SetProbeOffsetZ, &probe.offset.z); - #ifdef BLTOUCH_HS_MODE - EDIT_ITEM_F(ICON_HSMode, MSG_ENABLE_HS_MODE, onDrawChkbMenu, SetHSMode, &bltouch.high_speed_mode); + #if ENABLED(BLTOUCH) + MENU_ITEM_F(ICON_ProbeStow, MSG_MANUAL_STOW, onDrawMenuItem, ProbeStow); + MENU_ITEM_F(ICON_ProbeDeploy, MSG_MANUAL_DEPLOY, onDrawMenuItem, ProbeDeploy); + MENU_ITEM_F(ICON_BltouchReset, MSG_BLTOUCH_RESET, onDrawMenuItem, bltouch._reset); + #ifdef BLTOUCH_HS_MODE + EDIT_ITEM_F(ICON_HSMode, MSG_ENABLE_HS_MODE, onDrawChkbMenu, SetHSMode, &bltouch.high_speed_mode); + #endif #endif MENU_ITEM_F(ICON_ProbeTest, MSG_M48_TEST, onDrawMenuItem, ProbeTest); - MENU_ITEM_F(ICON_ProbeStow, MSG_MANUAL_STOW, onDrawMenuItem, ProbeStow); - MENU_ITEM_F(ICON_ProbeDeploy, MSG_MANUAL_DEPLOY, onDrawMenuItem, ProbeDeploy); } UpdateMenu(ProbeSetMenu); } @@ -3384,14 +3389,24 @@ void Draw_GetColor_Menu() { #endif #if ENABLED(LED_CONTROL_MENU) - void Draw_LedControl_Menu() { - checkkey = Menu; - if (SetMenu(LedControlMenu, GET_TEXT_F(MSG_LED_CONTROL), 6)) { - BACK_ITEM(Draw_Control_Menu); - #if !BOTH(CASE_LIGHT_MENU, CASE_LIGHT_USE_NEOPIXEL) - EDIT_ITEM_F(ICON_LedControl, MSG_LEDS, onDrawChkbMenu, SetLedStatus, &leds.lights_on); - #endif - #if HAS_COLOR_LEDS + void Draw_LedControl_Menu() { + checkkey = Menu; + if (SetMenu(LedControlMenu, GET_TEXT_F(MSG_LED_CONTROL), 6)) { + BACK_ITEM(Draw_Control_Menu); + #if !BOTH(CASE_LIGHT_MENU, CASE_LIGHT_USE_NEOPIXEL) + EDIT_ITEM_F(ICON_LedControl, MSG_LEDS, onDrawChkbMenu, SetLedStatus, &leds.lights_on); + #endif + #if HAS_COLOR_LEDS + #if ENABLED(LED_COLOR_PRESETS) + MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_WHITE, onDrawMenuItem, leds.set_white); + MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_RED, onDrawMenuItem, leds.set_red); + MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_ORANGE, onDrawMenuItem, leds.set_orange); + MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_YELLOW, onDrawMenuItem, leds.set_yellow); + MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_GREEN, onDrawMenuItem, leds.set_green); + MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_BLUE, onDrawMenuItem, leds.set_blue); + MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_INDIGO, onDrawMenuItem, leds.set_indigo); + MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_VIOLET, onDrawMenuItem, leds.set_violet); + #else EDIT_ITEM_F(ICON_LedControl, MSG_COLORS_RED, onDrawPInt8Menu, SetLEDColorR, &leds.color.r); EDIT_ITEM_F(ICON_LedControl, MSG_COLORS_GREEN, onDrawPInt8Menu, SetLEDColorG, &leds.color.g); EDIT_ITEM_F(ICON_LedControl, MSG_COLORS_BLUE, onDrawPInt8Menu, SetLEDColorB, &leds.color.b); @@ -3399,9 +3414,10 @@ void Draw_GetColor_Menu() { EDIT_ITEM_F(ICON_LedControl, MSG_COLORS_WHITE, onDrawPInt8Menu, SetLedColorW, &leds.color.w); #endif #endif - } - UpdateMenu(LedControlMenu); + #endif } + UpdateMenu(LedControlMenu); + } #endif void Draw_Tune_Menu() { @@ -3432,7 +3448,9 @@ void Draw_Tune_Menu() { #if ENABLED(FWRETRACT) MENU_ITEM_F(ICON_FWRetract, MSG_FWRETRACT, onDrawSubMenu, Draw_FWRetract_Menu); #endif - MENU_ITEM_F(ICON_Lock, MSG_LOCKSCREEN, onDrawMenuItem, DWIN_LockScreen); + #if HAS_LOCKSCREEN + MENU_ITEM_F(ICON_Lock, MSG_LOCKSCREEN, onDrawMenuItem, DWIN_LockScreen); + #endif #if HAS_LCD_BRIGHTNESS EDIT_ITEM_F(ICON_Brightness, MSG_BRIGHTNESS, onDrawPInt8Menu, SetBrightness, &ui.brightness); MENU_ITEM_F(ICON_Brightness, MSG_BRIGHTNESS_OFF, onDrawMenuItem, TurnOffBacklight); @@ -3750,15 +3768,14 @@ void Draw_Steps_Menu() { #endif #if ENABLED(MESH_EDIT_MENU) - uint8_t mesh_x = 0, mesh_y = 0; #define Z_OFFSET_MIN -3 #define Z_OFFSET_MAX 3 - void LiveEditMesh() { ((MenuItemPtrClass*)EditZValueItem)->value = &bedlevel.z_values[HMI_value.Select ? mesh_x : MenuData.Value][HMI_value.Select ? MenuData.Value : mesh_y]; EditZValueItem->redraw(); } - void ApplyEditMeshX() { mesh_x = MenuData.Value; } - void SetEditMeshX() { HMI_value.Select = 0; SetIntOnClick(0, GRID_MAX_POINTS_X - 1, mesh_x, ApplyEditMeshX, LiveEditMesh); } - void ApplyEditMeshY() { mesh_y = MenuData.Value; } - void SetEditMeshY() { HMI_value.Select = 1; SetIntOnClick(0, GRID_MAX_POINTS_Y - 1, mesh_y, ApplyEditMeshY, LiveEditMesh); } + void LiveEditMesh() { ((MenuItemPtrClass*)EditZValueItem)->value = &bedlevel.z_values[HMI_value.Select ? BedLevelTools.mesh_x : MenuData.Value][HMI_value.Select ? MenuData.Value : BedLevelTools.mesh_y]; EditZValueItem->redraw(); } + void ApplyEditMeshX() { BedLevelTools.mesh_x = MenuData.Value; } + void SetEditMeshX() { HMI_value.Select = 0; SetIntOnClick(0, GRID_MAX_POINTS_X - 1, BedLevelTools.mesh_x, ApplyEditMeshX, LiveEditMesh); } + void ApplyEditMeshY() { BedLevelTools.mesh_y = MenuData.Value; } + void SetEditMeshY() { HMI_value.Select = 1; SetIntOnClick(0, GRID_MAX_POINTS_Y - 1, BedLevelTools.mesh_y, ApplyEditMeshY, LiveEditMesh); } void SetEditZValue() { SetPFloatOnClick(Z_OFFSET_MIN, Z_OFFSET_MAX, 3); } #endif #endif @@ -3772,14 +3789,14 @@ void Draw_Steps_Menu() { onDrawIntMenu(menuitem, line, bedlevel.storage_slot); } - void ApplyUBLTiltGrid() { ubl_tools.tilt_grid = MenuData.Value; } - void SetUBLTiltGrid() { SetIntOnClick(1, 3, ubl_tools.tilt_grid, ApplyUBLTiltGrid); } + void ApplyUBLTiltGrid() { BedLevelTools.tilt_grid = MenuData.Value; } + void SetUBLTiltGrid() { SetIntOnClick(1, 3, BedLevelTools.tilt_grid, ApplyUBLTiltGrid); } void UBLTiltMesh() { if (bedlevel.storage_slot < 0) bedlevel.storage_slot = 0; char buf[15]; - if (ubl_tools.tilt_grid > 1) { - sprintf_P(buf, PSTR("G28O\nG29 J%i"), ubl_tools.tilt_grid); + if (BedLevelTools.tilt_grid > 1) { + sprintf_P(buf, PSTR("G28O\nG29 J%i"), BedLevelTools.tilt_grid); gcode.process_subcommands_now(buf); } else @@ -3788,16 +3805,10 @@ void Draw_Steps_Menu() { } void UBLSmartFillMesh() { - bedlevel.smart_fill_mesh(); + LOOP_L_N(x, GRID_MAX_POINTS_Y) bedlevel.smart_fill_mesh(); LCD_MESSAGE(MSG_UBL_MESH_FILLED); } - bool UBLValidMesh() { - const bool valid = ubl_tools.validate(); - if (!valid) bedlevel.invalidate(); - return valid; - } - void UBLSaveMesh() { if (bedlevel.storage_slot < 0) bedlevel.storage_slot = 0; settings.store_mesh(bedlevel.storage_slot); @@ -3808,14 +3819,6 @@ void Draw_Steps_Menu() { void UBLLoadMesh() { if (bedlevel.storage_slot < 0) bedlevel.storage_slot = 0; settings.load_mesh(bedlevel.storage_slot); - if (UBLValidMesh()) { - ui.status_printf(0, GET_TEXT_F(MSG_MESH_LOADED), bedlevel.storage_slot); - DONE_BUZZ(true); - } - else { - LCD_MESSAGE_F("Invalid Mesh Loaded"); - DONE_BUZZ(false); - } } #endif // AUTO_BED_LEVELING_UBL @@ -3837,7 +3840,7 @@ void Draw_Steps_Menu() { EDIT_ITEM_F(ICON_UBLActive, MSG_UBL_STORAGE_SLOT, onDrawUBLSlot, SetUBLSlot, &bedlevel.storage_slot); MENU_ITEM_F(ICON_UBLActive, MSG_UBL_SAVE_MESH, onDrawMenuItem, UBLSaveMesh); MENU_ITEM_F(ICON_UBLActive, MSG_UBL_LOAD_MESH, onDrawMenuItem, UBLLoadMesh); - EDIT_ITEM_F(ICON_UBLActive, MSG_UBL_TILTING_GRID, onDrawPInt8Menu, SetUBLTiltGrid, &ubl_tools.tilt_grid); + EDIT_ITEM_F(ICON_UBLActive, MSG_UBL_TILTING_GRID, onDrawPInt8Menu, SetUBLTiltGrid, &BedLevelTools.tilt_grid); MENU_ITEM_F(ICON_UBLActive, MSG_UBL_TILT_MESH, onDrawMenuItem, UBLTiltMesh); MENU_ITEM_F(ICON_UBLActive, MSG_UBL_SMART_FILLIN, onDrawMenuItem, UBLSmartFillMesh); #endif @@ -3851,13 +3854,15 @@ void Draw_Steps_Menu() { #if ENABLED(MESH_EDIT_MENU) void Draw_EditMesh_Menu() { + if (!leveling_is_valid()) { LCD_MESSAGE(MSG_UBL_MESH_INVALID); return; } + set_bed_leveling_enabled(false); checkkey = Menu; if (SetMenu(EditMeshMenu, GET_TEXT_F(MSG_EDIT_MESH), 4)) { - mesh_x = mesh_y = 0; + BedLevelTools.mesh_x = BedLevelTools.mesh_y = 0; BACK_ITEM(Draw_MeshSet_Menu); - EDIT_ITEM_F(ICON_UBLActive, MSG_MESH_X, onDrawPInt8Menu, SetEditMeshX, &mesh_x); - EDIT_ITEM_F(ICON_UBLActive, MSG_MESH_Y, onDrawPInt8Menu, SetEditMeshY, &mesh_y); - EditZValueItem = EDIT_ITEM_F(ICON_UBLActive, MSG_MESH_EDIT_Z, onDrawPFloat3Menu, SetEditZValue, &bedlevel.z_values[mesh_x][mesh_y]); + EDIT_ITEM_F(ICON_UBLActive, MSG_MESH_X, onDrawPInt8Menu, SetEditMeshX,&BedLevelTools.mesh_x); + EDIT_ITEM_F(ICON_UBLActive, MSG_MESH_Y, onDrawPInt8Menu, SetEditMeshY,&BedLevelTools.mesh_y); + EditZValueItem = EDIT_ITEM_F(ICON_UBLActive, MSG_MESH_EDIT_Z, onDrawPFloat3Menu, SetEditZValue, &bedlevel.z_values[BedLevelTools.mesh_x][BedLevelTools.mesh_y]); } UpdateMenu(EditMeshMenu); } diff --git a/Marlin/src/lcd/e3v2/proui/dwin.h b/Marlin/src/lcd/e3v2/proui/dwin.h index 4f992b3a7895..6d36cca92af7 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.h +++ b/Marlin/src/lcd/e3v2/proui/dwin.h @@ -160,8 +160,7 @@ void Goto_PowerLossRecovery(); void Goto_ConfirmToPrint(); void DWIN_Draw_Dashboard(const bool with_update); // Status Area void Draw_Main_Area(); // Redraw main area -void DWIN_DrawStatusLine(const char *text); // Draw simple status text -void DWIN_DrawStatusLine(FSTR_P fstr); +void DWIN_DrawStatusLine(); // Draw simple status text void DWIN_RedrawDash(); // Redraw Dash and Status line void DWIN_RedrawScreen(); // Redraw all screen elements void HMI_MainMenu(); // Main process screen @@ -210,9 +209,11 @@ void DWIN_RebootScreen(); #endif // Utility and extensions -void DWIN_LockScreen(); -void DWIN_UnLockScreen(); -void HMI_LockScreen(); +#if HAS_LOCKSCREEN + void DWIN_LockScreen(); + void DWIN_UnLockScreen(); + void HMI_LockScreen(); +#endif #if HAS_MESH void DWIN_MeshViewer(); #endif diff --git a/Marlin/src/lcd/e3v2/proui/dwin_defines.h b/Marlin/src/lcd/e3v2/proui/dwin_defines.h index 1517acd238d0..0c4e0104f432 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin_defines.h +++ b/Marlin/src/lcd/e3v2/proui/dwin_defines.h @@ -28,23 +28,21 @@ * Date: 2022/02/28 */ +#define HAS_GCODE_PREVIEW 1 +#define HAS_PIDPLOT 1 +#define HAS_ESDIAG 1 +#define HAS_LOCKSCREEN 1 //#define DEBUG_DWIN 1 //#define NEED_HEX_PRINT 1 #include "../../../inc/MarlinConfigPre.h" +#include "../common/dwin_color.h" #include -#define HAS_ESDIAG 1 -#define HAS_PIDPLOT 1 -#define HAS_GCODE_PREVIEW 1 #if defined(__STM32F1__) || defined(STM32F1) #define DASH_REDRAW 1 #endif -#include "../common/dwin_color.h" -#if ENABLED(LED_CONTROL_MENU) - #include "../../../feature/leds/leds.h" -#endif #define Def_Background_Color RGB( 1, 12, 8) #define Def_Cursor_color RGB(20, 49, 31) @@ -65,9 +63,6 @@ #define Def_Indicator_Color Color_White #define Def_Coordinate_Color Color_White #define Def_Button_Color RGB( 0, 23, 16) - -#define HAS_ESDIAG 1 - #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS) #define Def_Leds_Color 0xFFFFFFFF #endif diff --git a/Marlin/src/lcd/e3v2/proui/dwinui.cpp b/Marlin/src/lcd/e3v2/proui/dwinui.cpp index ecb4754a0f35..5ed36e7dacf0 100644 --- a/Marlin/src/lcd/e3v2/proui/dwinui.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwinui.cpp @@ -23,8 +23,8 @@ /** * DWIN Enhanced implementation for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 3.17.1 - * Date: 2022/04/12 + * Version: 3.18.1 + * Date: 2022/07/05 */ #include "../../../inc/MarlinConfigPre.h" @@ -44,7 +44,7 @@ uint16_t DWINUI::pencolor = Color_White; uint16_t DWINUI::textcolor = Def_Text_Color; uint16_t DWINUI::backcolor = Def_Background_Color; uint16_t DWINUI::buttoncolor = Def_Button_Color; -uint8_t DWINUI::font = font8x16; +uint8_t DWINUI::fontid = font8x16; FSTR_P const DWINUI::Author = F(STRING_CONFIG_H_AUTHOR); void (*DWINUI::onTitleDraw)(TitleClass* title) = nullptr; @@ -62,17 +62,15 @@ void DWINUI::init() { textcolor = Def_Text_Color; backcolor = Def_Background_Color; buttoncolor = Def_Button_Color; - font = font8x16; + fontid = font8x16; } // Set text/number font -void DWINUI::setFont(uint8_t cfont) { - font = cfont; -} +void DWINUI::setFont(fontid_t fid) { fontid = fid; } // Get font character width -uint8_t DWINUI::fontWidth(uint8_t cfont) { - switch (cfont) { +uint8_t DWINUI::fontWidth(fontid_t fid) { + switch (fid) { case font6x12 : return 6; case font8x16 : return 8; case font10x20: return 10; @@ -88,8 +86,8 @@ uint8_t DWINUI::fontWidth(uint8_t cfont) { } // Get font character height -uint8_t DWINUI::fontHeight(uint8_t cfont) { - switch (cfont) { +uint8_t DWINUI::fontHeight(fontid_t fid) { + switch (fid) { case font6x12 : return 12; case font8x16 : return 16; case font10x20: return 20; @@ -105,14 +103,10 @@ uint8_t DWINUI::fontHeight(uint8_t cfont) { } // Get screen x coordinates from text column -uint16_t DWINUI::ColToX(uint8_t col) { - return col * fontWidth(font); -} +uint16_t DWINUI::ColToX(uint8_t col) { return col * fontWidth(fontid); } // Get screen y coordinates from text row -uint16_t DWINUI::RowToY(uint8_t row) { - return row * fontHeight(font); -} +uint16_t DWINUI::RowToY(uint8_t row) { return row * fontHeight(fontid); } // Set text/number color void DWINUI::SetColors(uint16_t fgcolor, uint16_t bgcolor, uint16_t alcolor) { @@ -152,9 +146,9 @@ void DWINUI::MoveBy(xy_int_t point) { } // Draw a Centered string using arbitrary x1 and x2 margins -void DWINUI::Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x1, uint16_t x2, uint16_t y, const char * const string) { - const uint16_t x = _MAX(0U, x2 + x1 - strlen_P(string) * fontWidth(size)) / 2 - 1; - DWIN_Draw_String(bShow, size, color, bColor, x, y, string); +void DWINUI::Draw_CenteredString(bool bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint16_t x1, uint16_t x2, uint16_t y, const char * const string) { + const uint16_t x = _MAX(0U, x2 + x1 - strlen_P(string) * fontWidth(fid)) / 2 - 1; + DWIN_Draw_String(bShow, fid, color, bColor, x, y, string); } // Draw a char @@ -164,13 +158,13 @@ void DWINUI::Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint1 // c: ASCII code of char void DWINUI::Draw_Char(uint16_t color, uint16_t x, uint16_t y, const char c) { const char string[2] = { c, 0}; - DWIN_Draw_String(false, font, color, backcolor, x, y, string, 1); + DWIN_Draw_String(false, fontid, color, backcolor, x, y, string, 1); } // Draw a char at cursor position and increment cursor void DWINUI::Draw_Char(uint16_t color, const char c) { Draw_Char(color, cursor.x, cursor.y, c); - MoveBy(fontWidth(font), 0); + MoveBy(fontWidth(fontid), 0); } // Draw a string at cursor position @@ -178,49 +172,49 @@ void DWINUI::Draw_Char(uint16_t color, const char c) { // *string: The string // rlimit: For draw less chars than string length use rlimit void DWINUI::Draw_String(const char * const string, uint16_t rlimit) { - DWIN_Draw_String(false, font, textcolor, backcolor, cursor.x, cursor.y, string, rlimit); - MoveBy(strlen(string) * fontWidth(font), 0); + DWIN_Draw_String(false, fontid, textcolor, backcolor, cursor.x, cursor.y, string, rlimit); + MoveBy(strlen(string) * fontWidth(fontid), 0); } void DWINUI::Draw_String(uint16_t color, const char * const string, uint16_t rlimit) { - DWIN_Draw_String(false, font, color, backcolor, cursor.x, cursor.y, string, rlimit); - MoveBy(strlen(string) * fontWidth(font), 0); + DWIN_Draw_String(false, fontid, color, backcolor, cursor.x, cursor.y, string, rlimit); + MoveBy(strlen(string) * fontWidth(fontid), 0); } // Draw a numeric integer value // bShow: true=display background color; false=don't display background color // signedMode: 1=signed; 0=unsigned -// size: Font size +// fid: Font ID // color: Character color // bColor: Background color // iNum: Number of digits // x/y: Upper-left coordinate // value: Integer value -void DWINUI::Draw_Int(uint8_t bShow, bool signedMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, int32_t value) { +void DWINUI::Draw_Int(uint8_t bShow, bool signedMode, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, int32_t value) { char nstr[10]; sprintf_P(nstr, PSTR("%*li"), (signedMode ? iNum + 1 : iNum), value); - DWIN_Draw_String(bShow, size, color, bColor, x, y, nstr); + DWIN_Draw_String(bShow, fid, color, bColor, x, y, nstr); } // Draw a numeric float value // bShow: true=display background color; false=don't display background color // signedMode: 1=signed; 0=unsigned -// size: Font size +// fid: Font ID // color: Character color // bColor: Background color // iNum: Number of digits // fNum: Number of decimal digits // x/y: Upper-left coordinate // value: float value -void DWINUI::Draw_Float(uint8_t bShow, bool signedMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { +void DWINUI::Draw_Float(uint8_t bShow, bool signedMode, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { char nstr[10]; - DWIN_Draw_String(bShow, size, color, bColor, x, y, dtostrf(value, iNum + (signedMode ? 2:1) + fNum, fNum, nstr)); + DWIN_Draw_String(bShow, fid, color, bColor, x, y, dtostrf(value, iNum + (signedMode ? 2:1) + fNum, fNum, nstr)); } // ------------------------- Buttons ------------------------------// void DWINUI::Draw_Button(uint16_t color, uint16_t bcolor, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, const char * const caption) { DWIN_Draw_Rectangle(1, bcolor, x1, y1, x2, y2); - Draw_CenteredString(0, font, color, bcolor, x1, x2, (y2 + y1 - fontHeight())/2, caption); + Draw_CenteredString(0, fontid, color, bcolor, x1, x2, (y2 + y1 - fontHeight())/2, caption); } void DWINUI::Draw_Button(uint8_t id, uint16_t x, uint16_t y) { diff --git a/Marlin/src/lcd/e3v2/proui/dwinui.h b/Marlin/src/lcd/e3v2/proui/dwinui.h index f8ff0917694d..a5444718312c 100644 --- a/Marlin/src/lcd/e3v2/proui/dwinui.h +++ b/Marlin/src/lcd/e3v2/proui/dwinui.h @@ -24,8 +24,8 @@ /** * DWIN Enhanced implementation for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 3.17.1 - * Date: 2022/04/12 + * Version: 3.18.1 + * Date: 2022/07/05 */ #include "dwin_lcd.h" @@ -39,6 +39,7 @@ #define ICON_BedSizeY ICON_PrintSize #define ICON_BedTramming ICON_SetHome #define ICON_Binary ICON_Contact +#define ICON_BltouchReset ICON_StockConfiguration #define ICON_Brightness ICON_Motion #define ICON_Cancel ICON_StockConfiguration #define ICON_CustomPreheat ICON_SetEndTemp @@ -145,7 +146,7 @@ #define DWIN_FONT_HEAD font10x20 #define DWIN_FONT_ALERT font10x20 #define STATUS_Y 354 -#define LCD_WIDTH (DWIN_WIDTH / 8) // only if the default font is font8x16 +#define LCD_WIDTH (DWIN_WIDTH / 8) // only if the default fontid is font8x16 // Minimum unit (0.1) : multiple (10) #define UNITFDIGITS 1 @@ -156,7 +157,7 @@ constexpr uint8_t TITLE_HEIGHT = 30, // Title bar heig TROWS = (STATUS_Y - TITLE_HEIGHT) / MLINE, // Total rows MROWS = TROWS - 1, // Other-than-Back ICOX = 26, // Menu item icon X position - LBLX = 60, // Menu item label X position + LBLX = 55, // Menu item label X position VALX = 210, // Menu item value X position MENU_CHR_W = 8, MENU_CHR_H = 16, // Menu font 8x16 STAT_CHR_W = 10; @@ -196,7 +197,7 @@ namespace DWINUI { extern uint16_t textcolor; extern uint16_t backcolor; extern uint16_t buttoncolor; - extern uint8_t font; + extern fontid_t fontid; extern FSTR_P const Author; extern void (*onTitleDraw)(TitleClass* title); @@ -205,15 +206,15 @@ namespace DWINUI { void init(); // Set text/number font - void setFont(uint8_t cfont); + void setFont(fontid_t cfont); // Get font character width - uint8_t fontWidth(uint8_t cfont); - inline uint8_t fontWidth() { return fontWidth(font); }; + uint8_t fontWidth(fontid_t cfont); + inline uint8_t fontWidth() { return fontWidth(fontid); }; // Get font character height - uint8_t fontHeight(uint8_t cfont); - inline uint8_t fontHeight() { return fontHeight(font); }; + uint8_t fontHeight(fontid_t cfont); + inline uint8_t fontHeight() { return fontHeight(fontid); }; // Get screen x coordinates from text column uint16_t ColToX(uint8_t col); @@ -278,108 +279,108 @@ namespace DWINUI { // Draw a numeric integer value // bShow: true=display background color; false=don't display background color // signedMode: 1=signed; 0=unsigned - // size: Font size + // fid: Font ID // color: Character color // bColor: Background color // iNum: Number of digits // x/y: Upper-left coordinate // value: Integer value - void Draw_Int(uint8_t bShow, bool signedMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, int32_t value); + void Draw_Int(uint8_t bShow, bool signedMode, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, int32_t value); // Draw a positive integer - inline void Draw_Int(uint8_t bShow, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(bShow, 0, size, color, bColor, iNum, x, y, value); + inline void Draw_Int(uint8_t bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { + Draw_Int(bShow, 0, fid, color, bColor, iNum, x, y, value); } inline void Draw_Int(uint8_t iNum, long value) { - Draw_Int(false, 0, font, textcolor, backcolor, iNum, cursor.x, cursor.y, value); - MoveBy(iNum * fontWidth(font), 0); + Draw_Int(false, 0, fontid, textcolor, backcolor, iNum, cursor.x, cursor.y, value); + MoveBy(iNum * fontWidth(fontid), 0); } inline void Draw_Int(uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(false, 0, font, textcolor, backcolor, iNum, x, y, value); + Draw_Int(false, 0, fontid, textcolor, backcolor, iNum, x, y, value); } inline void Draw_Int(uint16_t color, uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(false, 0, font, color, backcolor, iNum, x, y, value); + Draw_Int(false, 0, fontid, color, backcolor, iNum, x, y, value); } inline void Draw_Int(uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(true, 0, font, color, bColor, iNum, x, y, value); + Draw_Int(true, 0, fontid, color, bColor, iNum, x, y, value); } - inline void Draw_Int(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(true, 0, size, color, bColor, iNum, x, y, value); + inline void Draw_Int(fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { + Draw_Int(true, 0, fid, color, bColor, iNum, x, y, value); } // Draw a signed integer - inline void Draw_Signed_Int(uint8_t bShow, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(bShow, 1, size, color, bColor, iNum, x, y, value); + inline void Draw_Signed_Int(uint8_t bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { + Draw_Int(bShow, 1, fid, color, bColor, iNum, x, y, value); } inline void Draw_Signed_Int(uint8_t iNum, long value) { - Draw_Int(false, 1, font, textcolor, backcolor, iNum, cursor.x, cursor.y, value); - MoveBy(iNum * fontWidth(font), 0); + Draw_Int(false, 1, fontid, textcolor, backcolor, iNum, cursor.x, cursor.y, value); + MoveBy(iNum * fontWidth(fontid), 0); } inline void Draw_Signed_Int(uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(false, 1, font, textcolor, backcolor, iNum, x, y, value); + Draw_Int(false, 1, fontid, textcolor, backcolor, iNum, x, y, value); } inline void Draw_Signed_Int(uint16_t color, uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(false, 1, font, color, backcolor, iNum, x, y, value); + Draw_Int(false, 1, fontid, color, backcolor, iNum, x, y, value); } inline void Draw_Signed_Int(uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(true, 1, font, color, bColor, iNum, x, y, value); + Draw_Int(true, 1, fontid, color, bColor, iNum, x, y, value); } - inline void Draw_Signed_Int(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(true, 1, size, color, bColor, iNum, x, y, value); + inline void Draw_Signed_Int(fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { + Draw_Int(true, 1, fid, color, bColor, iNum, x, y, value); } // Draw a numeric float value // bShow: true=display background color; false=don't display background color // signedMode: 1=signed; 0=unsigned - // size: Font size + // fid: Font ID // color: Character color // bColor: Background color // iNum: Number of digits // fNum: Number of decimal digits // x/y: Upper-left coordinate // value: float value - void Draw_Float(uint8_t bShow, bool signedMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value); + void Draw_Float(uint8_t bShow, bool signedMode, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value); // Draw a positive floating point number - inline void Draw_Float(uint8_t bShow, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(bShow, 0, size, color, bColor, iNum, fNum, x, y, value); + inline void Draw_Float(uint8_t bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(bShow, 0, fid, color, bColor, iNum, fNum, x, y, value); } inline void Draw_Float(uint8_t iNum, uint8_t fNum, float value) { - Draw_Float(false, 0, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value); - MoveBy((iNum + fNum + 1) * fontWidth(font), 0); + Draw_Float(false, 0, fontid, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value); + MoveBy((iNum + fNum + 1) * fontWidth(fontid), 0); } inline void Draw_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(false, 0, font, textcolor, backcolor, iNum, fNum, x, y, value); + Draw_Float(false, 0, fontid, textcolor, backcolor, iNum, fNum, x, y, value); } - inline void Draw_Float(uint8_t size, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(false, 0, size, textcolor, backcolor, iNum, fNum, x, y, value); + inline void Draw_Float(fontid_t fid, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(false, 0, fid, textcolor, backcolor, iNum, fNum, x, y, value); } inline void Draw_Float(uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(true, 0, font, color, bColor, iNum, fNum, x, y, value); + Draw_Float(true, 0, fontid, color, bColor, iNum, fNum, x, y, value); } - inline void Draw_Float(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(true, 0, size, color, bColor, iNum, fNum, x, y, value); + inline void Draw_Float(fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(true, 0, fid, color, bColor, iNum, fNum, x, y, value); } // Draw a signed floating point number - inline void Draw_Signed_Float(uint8_t bShow, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(bShow, 1, size, color, bColor, iNum, fNum, x, y, value); + inline void Draw_Signed_Float(uint8_t bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(bShow, 1, fid, color, bColor, iNum, fNum, x, y, value); } inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, float value) { - Draw_Float(false, 1, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value); - MoveBy((iNum + fNum + 1) * fontWidth(font), 0); + Draw_Float(false, 1, fontid, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value); + MoveBy((iNum + fNum + 1) * fontWidth(fontid), 0); } inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(false, 1, font, textcolor, backcolor, iNum, fNum, x, y, value); + Draw_Float(false, 1, fontid, textcolor, backcolor, iNum, fNum, x, y, value); } - inline void Draw_Signed_Float(uint8_t size, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(false, 1, size, textcolor, backcolor, iNum, fNum, x, y, value); + inline void Draw_Signed_Float(fontid_t fid, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(false, 1, fid, textcolor, backcolor, iNum, fNum, x, y, value); } inline void Draw_Signed_Float(uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(true, 1, font, color, bColor, iNum, fNum, x, y, value); + Draw_Float(true, 1, fontid, color, bColor, iNum, fNum, x, y, value); } - inline void Draw_Signed_Float(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(true, 1, size, color, bColor, iNum, fNum, x, y, value); + inline void Draw_Signed_Float(fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(true, 1, fid, color, bColor, iNum, fNum, x, y, value); } // Draw a char @@ -407,70 +408,70 @@ namespace DWINUI { } // Draw a string - // size: Font size + // fid: Font ID // color: Character color // bColor: Background color // x/y: Upper-left coordinate of the string // *string: The string inline void Draw_String(uint16_t x, uint16_t y, const char * const string) { - DWIN_Draw_String(false, font, textcolor, backcolor, x, y, string); + DWIN_Draw_String(false, fontid, textcolor, backcolor, x, y, string); } inline void Draw_String(uint16_t x, uint16_t y, FSTR_P title) { - DWIN_Draw_String(false, font, textcolor, backcolor, x, y, FTOP(title)); + DWIN_Draw_String(false, fontid, textcolor, backcolor, x, y, FTOP(title)); } inline void Draw_String(uint16_t color, uint16_t x, uint16_t y, const char * const string) { - DWIN_Draw_String(false, font, color, backcolor, x, y, string); + DWIN_Draw_String(false, fontid, color, backcolor, x, y, string); } inline void Draw_String(uint16_t color, uint16_t x, uint16_t y, FSTR_P title) { - DWIN_Draw_String(false, font, color, backcolor, x, y, title); + DWIN_Draw_String(false, fontid, color, backcolor, x, y, title); } inline void Draw_String(uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, const char * const string) { - DWIN_Draw_String(true, font, color, bgcolor, x, y, string); + DWIN_Draw_String(true, fontid, color, bgcolor, x, y, string); } inline void Draw_String(uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, FSTR_P title) { - DWIN_Draw_String(true, font, color, bgcolor, x, y, title); + DWIN_Draw_String(true, fontid, color, bgcolor, x, y, title); } - inline void Draw_String(uint8_t size, uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, const char * const string) { - DWIN_Draw_String(true, size, color, bgcolor, x, y, string); + inline void Draw_String(fontid_t fid, uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, const char * const string) { + DWIN_Draw_String(true, fid, color, bgcolor, x, y, string); } - inline void Draw_String(uint8_t size, uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, FSTR_P title) { - DWIN_Draw_String(true, size, color, bgcolor, x, y, title); + inline void Draw_String(fontid_t fid, uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, FSTR_P title) { + DWIN_Draw_String(true, fid, color, bgcolor, x, y, title); } // Draw a centered string using DWIN_WIDTH // bShow: true=display background color; false=don't display background color - // size: Font size + // fid: Font ID // color: Character color // bColor: Background color // y: Upper coordinate of the string // *string: The string - void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x1, uint16_t x2, uint16_t y, const char * const string); - inline void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, const char * const string) { - Draw_CenteredString(bShow, size, color, bColor, 0, DWIN_WIDTH, y, string); + void Draw_CenteredString(bool bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint16_t x1, uint16_t x2, uint16_t y, const char * const string); + inline void Draw_CenteredString(bool bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint16_t y, const char * const string) { + Draw_CenteredString(bShow, fid, color, bColor, 0, DWIN_WIDTH, y, string); } - inline void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, FSTR_P string) { - Draw_CenteredString(bShow, size, color, bColor, y, FTOP(string)); + inline void Draw_CenteredString(bool bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint16_t y, FSTR_P string) { + Draw_CenteredString(bShow, fid, color, bColor, y, FTOP(string)); } inline void Draw_CenteredString(uint16_t color, uint16_t bcolor, uint16_t y, const char * const string) { - Draw_CenteredString(true, font, color, bcolor, y, string); + Draw_CenteredString(true, fontid, color, bcolor, y, string); } - inline void Draw_CenteredString(uint8_t size, uint16_t color, uint16_t y, const char * const string) { - Draw_CenteredString(false, size, color, backcolor, y, string); + inline void Draw_CenteredString(fontid_t fid, uint16_t color, uint16_t y, const char * const string) { + Draw_CenteredString(false, fid, color, backcolor, y, string); } - inline void Draw_CenteredString(uint8_t size, uint16_t color, uint16_t y, FSTR_P title) { - Draw_CenteredString(false, size, color, backcolor, y, title); + inline void Draw_CenteredString(fontid_t fid, uint16_t color, uint16_t y, FSTR_P title) { + Draw_CenteredString(false, fid, color, backcolor, y, title); } inline void Draw_CenteredString(uint16_t color, uint16_t y, const char * const string) { - Draw_CenteredString(false, font, color, backcolor, y, string); + Draw_CenteredString(false, fontid, color, backcolor, y, string); } inline void Draw_CenteredString(uint16_t color, uint16_t y, FSTR_P title) { - Draw_CenteredString(false, font, color, backcolor, y, title); + Draw_CenteredString(false, fontid, color, backcolor, y, title); } inline void Draw_CenteredString(uint16_t y, const char * const string) { - Draw_CenteredString(false, font, textcolor, backcolor, y, string); + Draw_CenteredString(false, fontid, textcolor, backcolor, y, string); } inline void Draw_CenteredString(uint16_t y, FSTR_P title) { - Draw_CenteredString(false, font, textcolor, backcolor, y, title); + Draw_CenteredString(false, fontid, textcolor, backcolor, y, title); } // Draw a box diff --git a/Marlin/src/lcd/e3v2/proui/lockscreen.cpp b/Marlin/src/lcd/e3v2/proui/lockscreen.cpp index 44b595096a88..86c2095294b4 100644 --- a/Marlin/src/lcd/e3v2/proui/lockscreen.cpp +++ b/Marlin/src/lcd/e3v2/proui/lockscreen.cpp @@ -31,8 +31,10 @@ #if ENABLED(DWIN_LCD_PROUI) -#include "../../../core/types.h" -#include "dwin_lcd.h" +#include "dwin_defines.h" + +#if HAS_LOCKSCREEN + #include "dwinui.h" #include "dwin.h" #include "lockscreen.h" @@ -73,4 +75,6 @@ void LockScreenClass::onEncoder(EncoderState encoder_diffState) { DWIN_UpdateLCD(); } +#endif // HAS_LOCKSCREEN + #endif // DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/proui/menus.cpp b/Marlin/src/lcd/e3v2/proui/menus.cpp index 6438545cb251..85594fecdbab 100644 --- a/Marlin/src/lcd/e3v2/proui/menus.cpp +++ b/Marlin/src/lcd/e3v2/proui/menus.cpp @@ -23,8 +23,8 @@ /** * Menu functions for ProUI * Author: Miguel A. Risco-Castillo - * Version: 1.4.1 - * Date: 2022/04/14 + * Version: 1.5.1 + * Date: 2022/05/23 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -166,6 +166,17 @@ void onDrawChkbMenu(MenuItemClass* menuitem, int8_t line) { onDrawChkbMenu(menuitem, line, val); } +void DrawItemEdit() { + switch (checkkey) { + case SetIntNoDraw: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break; + case SetInt: + case SetPInt: DWINUI::Draw_Signed_Int(HMI_data.Text_Color, HMI_data.Selected_Color, 4 , VALX, MBASE(CurrentMenu->line()) - 1, MenuData.Value); break; + case SetFloat: + case SetPFloat: DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Selected_Color, 3, MenuData.dp, VALX - MenuData.dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), MenuData.Value / POW(10, MenuData.dp)); break; + default: break; + } +} + //----------------------------------------------------------------------------- // On click functions //----------------------------------------------------------------------------- @@ -307,7 +318,7 @@ int8_t HMI_GetInt(const int32_t lo, const int32_t hi) { return 2; } LIMIT(MenuData.Value, lo, hi); - DWINUI::Draw_Signed_Int(HMI_data.Text_Color, HMI_data.Selected_Color, 4 , VALX, MBASE(CurrentMenu->line()) - 1, MenuData.Value); + DrawItemEdit(); return 1; } return 0; @@ -361,7 +372,7 @@ int8_t HMI_GetFloat(uint8_t dp, int32_t lo, int32_t hi) { return 2; } LIMIT(MenuData.Value, lo, hi); - DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Selected_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), MenuData.Value / POW(10, dp)); + DrawItemEdit(); return 1; } return 0; @@ -469,7 +480,7 @@ void MenuItemClass::SetFrame(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, } void MenuItemClass::draw(int8_t line) { - if (line < 0 || line >= TROWS) return; + if (!WITHIN(line, 0, TROWS - 1)) return; if (onDraw != nullptr) (*onDraw)(this, line); }; @@ -547,6 +558,9 @@ void UpdateMenu(MenuClass* &menu) { menu->draw(); } -void ReDrawMenu() { if (CurrentMenu && checkkey==Menu) CurrentMenu->draw(); } +void ReDrawMenu(const bool force/*=false*/) { + if (CurrentMenu && (force || checkkey == Menu)) CurrentMenu->draw(); + if (force) DrawItemEdit(); +} #endif // DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/proui/menus.h b/Marlin/src/lcd/e3v2/proui/menus.h index d4514d173237..6a5f8786ca5f 100644 --- a/Marlin/src/lcd/e3v2/proui/menus.h +++ b/Marlin/src/lcd/e3v2/proui/menus.h @@ -23,8 +23,8 @@ /** * Menu functions for ProUI * Author: Miguel A. Risco-Castillo - * Version: 1.4.1 - * Date: 2022/04/14 + * Version: 1.5.1 + * Date: 2022/05/23 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -168,7 +168,7 @@ bool SetMenu(MenuClass* &menu, FSTR_P title, int8_t totalitems); void UpdateMenu(MenuClass* &menu); //Redraw the current Menu if it is valid -void ReDrawMenu(); +void ReDrawMenu(const bool force=false); // Clear MenuItems array and free MenuItems elements void MenuItemsClear(); diff --git a/Marlin/src/lcd/e3v2/proui/meshviewer.cpp b/Marlin/src/lcd/e3v2/proui/meshviewer.cpp index c2d01a07eb76..2511d33ff124 100644 --- a/Marlin/src/lcd/e3v2/proui/meshviewer.cpp +++ b/Marlin/src/lcd/e3v2/proui/meshviewer.cpp @@ -31,8 +31,6 @@ #if BOTH(DWIN_LCD_PROUI, HAS_MESH) -#include "meshviewer.h" - #include "../../../core/types.h" #include "../../marlinui.h" #include "dwin_lcd.h" @@ -40,9 +38,10 @@ #include "dwin.h" #include "dwin_popup.h" #include "../../../feature/bedlevel/bedlevel.h" +#include "meshviewer.h" #if ENABLED(AUTO_BED_LEVELING_UBL) - #include "ubl_tools.h" + #include "bedlevel_tools.h" #endif MeshViewerClass MeshViewer; @@ -112,10 +111,10 @@ void MeshViewerClass::DrawMesh(bed_mesh_t zval, const uint8_t sizex, const uint8 void MeshViewerClass::Draw(bool withsave /*= false*/) { Title.ShowCaption(GET_TEXT_F(MSG_MESH_VIEWER)); - #if ENABLED(USE_UBL_VIEWER) + #if USE_UBL_VIEWER DWINUI::ClearMainArea(); - ubl_tools.viewer_print_value = true; - ubl_tools.Draw_Bed_Mesh(-1, 1, 8, 10 + TITLE_HEIGHT); + BedLevelTools.viewer_print_value = true; + BedLevelTools.Draw_Bed_Mesh(-1, 1, 8, 10 + TITLE_HEIGHT); #else DrawMesh(bedlevel.z_values, GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y); #endif @@ -127,8 +126,8 @@ void MeshViewerClass::Draw(bool withsave /*= false*/) { else DWINUI::Draw_Button(BTN_Continue, 86, 305); - #if ENABLED(USE_UBL_VIEWER) - ubl_tools.Set_Mesh_Viewer_Status(); + #if USE_UBL_VIEWER + BedLevelTools.Set_Mesh_Viewer_Status(); #else char str_1[6], str_2[6] = ""; ui.status_printf(0, F("Mesh minZ: %s, maxZ: %s"), diff --git a/Marlin/src/lcd/e3v2/proui/meshviewer.h b/Marlin/src/lcd/e3v2/proui/meshviewer.h index 1e78ff2657b8..3aafe16984aa 100644 --- a/Marlin/src/lcd/e3v2/proui/meshviewer.h +++ b/Marlin/src/lcd/e3v2/proui/meshviewer.h @@ -21,9 +21,6 @@ */ #pragma once -#include "../../../core/types.h" -#include "../../../feature/bedlevel/bedlevel.h" - /** * Mesh Viewer for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) diff --git a/Marlin/src/lcd/e3v2/proui/plot.cpp b/Marlin/src/lcd/e3v2/proui/plot.cpp index ebc685fa2453..cb1f6c2dda0f 100644 --- a/Marlin/src/lcd/e3v2/proui/plot.cpp +++ b/Marlin/src/lcd/e3v2/proui/plot.cpp @@ -46,13 +46,16 @@ #ifdef DWIN_LCD_PROUI +#include "dwin_defines.h" + +#if HAS_PIDPLOT + #include "plot.h" #include "../../../core/types.h" #include "../../marlinui.h" #include "dwin_lcd.h" #include "dwinui.h" -#include "dwin_popup.h" #include "dwin.h" #define Plot_Bg_Color RGB( 1, 12, 8) @@ -71,7 +74,7 @@ void PlotClass::Draw(const frame_rect_t frame, const float max, const float ref) y2 = frame.y + frame.h - 1; r = round((y2) - ref * scale); DWINUI::Draw_Box(1, Plot_Bg_Color, frame); - for (uint8_t i = 1; i < 4; i++) if (i*50 < frame.w) DWIN_Draw_VLine(Line_Color, i*50 + frame.x, frame.y, frame.h); + for (uint8_t i = 1; i < 4; i++) if (i * 50 < frame.w) DWIN_Draw_VLine(Line_Color, i * 50 + frame.x, frame.y, frame.h); DWINUI::Draw_Box(0, Color_White, DWINUI::ExtendFrame(frame, 1)); DWIN_Draw_HLine(Color_Red, frame.x, r, frame.w); } @@ -91,4 +94,6 @@ void PlotClass::Update(const float value) { grphpoints++; } +#endif // HAS_PIDPLOT + #endif // DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index f2a9cb0c0868..57cae3d32858 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -254,6 +254,7 @@ namespace Language_en { LSTR MSG_UBL_SMART_FILLIN = _UxGT("Smart Fill-in"); LSTR MSG_UBL_FILLIN_MESH = _UxGT("Fill-in Mesh"); LSTR MSG_UBL_MESH_FILLED = _UxGT("Missing Points Filled"); + LSTR MSG_UBL_MESH_INVALID = _UxGT("Invalid Mesh"); LSTR MSG_UBL_INVALIDATE_ALL = _UxGT("Invalidate All"); LSTR MSG_UBL_INVALIDATE_CLOSEST = _UxGT("Invalidate Closest"); LSTR MSG_UBL_FINE_TUNE_ALL = _UxGT("Fine Tune All"); diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index 5a0de47bf2f0..389ae6d4bf64 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -188,7 +188,7 @@ typedef struct { * The "nominal" values are as-specified by G-code, and * may never actually be reached due to acceleration limits. */ -typedef struct block_t { +typedef struct PlannerBlock { volatile block_flags_t flag; // Block flags diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index d21dc92c67c4..a37dfc025716 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -76,6 +76,7 @@ #include "../lcd/extui/ui_api.h" #elif ENABLED(DWIN_LCD_PROUI) #include "../lcd/e3v2/proui/dwin.h" + #include "../lcd/e3v2/proui/bedlevel_tools.h" #endif #if ENABLED(HOST_PROMPT_SUPPORT) @@ -2756,7 +2757,7 @@ void MarlinSettings::postprocess() { #endif persistentStore.access_start(); - const uint16_t status = persistentStore.read_data(pos, dest, MESH_STORE_SIZE, &crc); + uint16_t status = persistentStore.read_data(pos, dest, MESH_STORE_SIZE, &crc); persistentStore.access_finish(); #if ENABLED(OPTIMIZED_MESH_STORAGE) @@ -2769,6 +2770,16 @@ void MarlinSettings::postprocess() { bedlevel.set_mesh_from_store(z_mesh_store, bedlevel.z_values); #endif + #if ENABLED(DWIN_LCD_PROUI) + status = !BedLevelTools.meshvalidate(); + if (status) { + bedlevel.invalidate(); + LCD_MESSAGE(MSG_UBL_MESH_INVALID); + } + else + ui.status_printf(0, GET_TEXT_F(MSG_MESH_LOADED), bedlevel.storage_slot); + #endif + if (status) SERIAL_ECHOLNPGM("?Unable to load mesh data."); else DEBUG_ECHOLNPGM("Mesh loaded from slot ", slot); From 4a6ad1c98bde764255511c5bce58740b6e5cfb13 Mon Sep 17 00:00:00 2001 From: GHGiampy <83699429+GHGiampy@users.noreply.github.com> Date: Thu, 14 Jul 2022 07:03:27 +0200 Subject: [PATCH 29/32] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20ProUI=20LED=20compil?= =?UTF-8?q?e=20(#24473)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/e3v2/proui/dwin.cpp | 14 +++++++++----- Marlin/src/lcd/e3v2/proui/dwin_defines.h | 9 +++------ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Marlin/src/lcd/e3v2/proui/dwin.cpp b/Marlin/src/lcd/e3v2/proui/dwin.cpp index 27e1003ab6eb..762a4fb627ab 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin.cpp @@ -1843,10 +1843,10 @@ void DWIN_CopySettingsFrom(const char * const buff) { TERN_(BAUD_RATE_GCODE, HMI_SetBaudRate()); #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS) leds.set_color( - (HMI_data.LED_Color >> 16) & 0xFF, - (HMI_data.LED_Color >> 8) & 0xFF, - (HMI_data.LED_Color >> 0) & 0xFF - OPTARG(HAS_WHITE_LED, (HMI_data.LED_Color >> 24) & 0xFF) + HMI_data.Led_Color.r, + HMI_data.Led_Color.g, + HMI_data.Led_Color.b + OPTARG(HAS_WHITE_LED, HMI_data.Led_Color.w) ); leds.update(); #endif @@ -2267,7 +2267,11 @@ void SetPID(celsius_t t, heater_id_t h) { } #endif #if HAS_COLOR_LEDS - void ApplyLEDColor() { HMI_data.LED_Color = TERN0(HAS_WHITE_LED, (leds.color.w << 24)) | (leds.color.r << 16) | (leds.color.g << 8) | leds.color.b; } + void ApplyLEDColor() { + HMI_data.Led_Color = LEDColor( + TERN(HAS_WHITE_LED, { 0, 0, 0, leds.color.w }, { leds.color.r, leds.color.g, leds.color.b }) + ); + } void LiveLEDColor(uint8_t *color) { *color = MenuData.Value; leds.update(); } void LiveLEDColorR() { LiveLEDColor(&leds.color.r); } void LiveLEDColorG() { LiveLEDColor(&leds.color.g); } diff --git a/Marlin/src/lcd/e3v2/proui/dwin_defines.h b/Marlin/src/lcd/e3v2/proui/dwin_defines.h index 0c4e0104f432..98aadb8e73aa 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin_defines.h +++ b/Marlin/src/lcd/e3v2/proui/dwin_defines.h @@ -64,10 +64,7 @@ #define Def_Coordinate_Color Color_White #define Def_Button_Color RGB( 0, 23, 16) #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS) - #define Def_Leds_Color 0xFFFFFFFF -#endif -#if ENABLED(CASELIGHT_USES_BRIGHTNESS) - #define Def_CaseLight_Brightness 255 + #define Def_Leds_Color LEDColorWhite() #endif typedef struct { @@ -110,12 +107,12 @@ typedef struct { bool Baud115K = false; #endif bool FullManualTramming = false; - // Led #if ENABLED(MESH_BED_LEVELING) float ManualZOffset = 0; #endif + // Led #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS) - uint32_t LED_Color = Def_Leds_Color; + LEDColor Led_Color = Def_Leds_Color; #endif } HMI_data_t; From 3315f6faa4fed3fde158013c8575d6bc6b813f3d Mon Sep 17 00:00:00 2001 From: Victor Oliveira Date: Thu, 14 Jul 2022 03:30:00 -0300 Subject: [PATCH 30/32] =?UTF-8?q?=E2=9C=A8=20Creality3D=20v4.2.5=20/=20CR2?= =?UTF-8?q?00B=20(#24491)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/core/boards.h | 47 ++++---- Marlin/src/pins/pins.h | 2 + Marlin/src/pins/stm32f1/pins_CREALITY_V4.h | 108 +++++++++++++------ Marlin/src/pins/stm32f1/pins_CREALITY_V425.h | 77 +++++++++++++ 4 files changed, 176 insertions(+), 58 deletions(-) create mode 100644 Marlin/src/pins/stm32f1/pins_CREALITY_V425.h diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index 2e71c632de9d..fa11c97380e4 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -343,29 +343,30 @@ #define BOARD_CREALITY_V4 4040 // Creality v4.x (STM32F103RC / STM32F103RE) #define BOARD_CREALITY_V422 4041 // Creality v4.2.2 (STM32F103RC / STM32F103RE) #define BOARD_CREALITY_V423 4042 // Creality v4.2.3 (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V427 4043 // Creality v4.2.7 (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V4210 4044 // Creality v4.2.10 (STM32F103RC / STM32F103RE) as found in the CR-30 -#define BOARD_CREALITY_V431 4045 // Creality v4.3.1 (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V431_A 4046 // Creality v4.3.1a (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V431_B 4047 // Creality v4.3.1b (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V431_C 4048 // Creality v4.3.1c (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V431_D 4049 // Creality v4.3.1d (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V452 4050 // Creality v4.5.2 (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V453 4051 // Creality v4.5.3 (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V24S1 4052 // Creality v2.4.S1 (STM32F103RC / STM32F103RE) v101 as found in the Ender-7 -#define BOARD_CREALITY_V24S1_301 4053 // Creality v2.4.S1_301 (STM32F103RC / STM32F103RE) v301 as found in the Ender-3 S1 -#define BOARD_CREALITY_V25S1 4054 // Creality v2.5.S1 (STM32F103RE) as found in the CR-10 Smart Pro -#define BOARD_TRIGORILLA_PRO 4055 // Trigorilla Pro (STM32F103ZE) -#define BOARD_FLY_MINI 4056 // FLYmaker FLY MINI (STM32F103RC) -#define BOARD_FLSUN_HISPEED 4057 // FLSUN HiSpeedV1 (STM32F103VE) -#define BOARD_BEAST 4058 // STM32F103RE Libmaple-based controller -#define BOARD_MINGDA_MPX_ARM_MINI 4059 // STM32F103ZE Mingda MD-16 -#define BOARD_GTM32_PRO_VD 4060 // STM32F103VE controller -#define BOARD_ZONESTAR_ZM3E2 4061 // Zonestar ZM3E2 (STM32F103RC) -#define BOARD_ZONESTAR_ZM3E4 4062 // Zonestar ZM3E4 V1 (STM32F103VC) -#define BOARD_ZONESTAR_ZM3E4V2 4063 // Zonestar ZM3E4 V2 (STM32F103VC) -#define BOARD_ERYONE_ERY32_MINI 4064 // Eryone Ery32 mini (STM32F103VE) -#define BOARD_PANDA_PI_V29 4065 // Panda Pi V2.9 - Standalone (STM32F103RC) +#define BOARD_CREALITY_V425 4043 // Creality v4.2.5 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V427 4044 // Creality v4.2.7 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V4210 4045 // Creality v4.2.10 (STM32F103RC / STM32F103RE) as found in the CR-30 +#define BOARD_CREALITY_V431 4046 // Creality v4.3.1 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V431_A 4047 // Creality v4.3.1a (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V431_B 4048 // Creality v4.3.1b (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V431_C 4049 // Creality v4.3.1c (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V431_D 4050 // Creality v4.3.1d (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V452 4051 // Creality v4.5.2 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V453 4052 // Creality v4.5.3 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V24S1 4053 // Creality v2.4.S1 (STM32F103RC / STM32F103RE) v101 as found in the Ender-7 +#define BOARD_CREALITY_V24S1_301 4054 // Creality v2.4.S1_301 (STM32F103RC / STM32F103RE) v301 as found in the Ender-3 S1 +#define BOARD_CREALITY_V25S1 4055 // Creality v2.5.S1 (STM32F103RE) as found in the CR-10 Smart Pro +#define BOARD_TRIGORILLA_PRO 4056 // Trigorilla Pro (STM32F103ZE) +#define BOARD_FLY_MINI 4057 // FLYmaker FLY MINI (STM32F103RC) +#define BOARD_FLSUN_HISPEED 4058 // FLSUN HiSpeedV1 (STM32F103VE) +#define BOARD_BEAST 4059 // STM32F103RE Libmaple-based controller +#define BOARD_MINGDA_MPX_ARM_MINI 4060 // STM32F103ZE Mingda MD-16 +#define BOARD_GTM32_PRO_VD 4061 // STM32F103VE controller +#define BOARD_ZONESTAR_ZM3E2 4062 // Zonestar ZM3E2 (STM32F103RC) +#define BOARD_ZONESTAR_ZM3E4 4063 // Zonestar ZM3E4 V1 (STM32F103VC) +#define BOARD_ZONESTAR_ZM3E4V2 4064 // Zonestar ZM3E4 V2 (STM32F103VC) +#define BOARD_ERYONE_ERY32_MINI 4065 // Eryone Ery32 mini (STM32F103VE) +#define BOARD_PANDA_PI_V29 4066 // Panda Pi V2.9 - Standalone (STM32F103RC) // // ARM Cortex-M4F diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 8457cdc4ff1d..8925993c363f 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -567,6 +567,8 @@ #include "stm32f1/pins_CREALITY_V4.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple #elif MB(CREALITY_V4210) #include "stm32f1/pins_CREALITY_V4210.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple +#elif MB(CREALITY_V425) + #include "stm32f1/pins_CREALITY_V425.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple #elif MB(CREALITY_V422) #include "stm32f1/pins_CREALITY_V422.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple #elif MB(CREALITY_V423) diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h index cb11c3e53b5b..7e3979b87e79 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h @@ -77,8 +77,12 @@ // // Limit Switches // -#define X_STOP_PIN PA5 -#define Y_STOP_PIN PA6 +#ifndef X_STOP_PIN + #define X_STOP_PIN PA5 +#endif +#ifndef Y_STOP_PIN + #define Y_STOP_PIN PA6 +#endif #ifndef Z_STOP_PIN #define Z_STOP_PIN PA7 #endif @@ -153,7 +157,7 @@ // SD Card // #define SD_DETECT_PIN PC7 -#define SDCARD_CONNECTION ONBOARD +#define SDCARD_CONNECTION ONBOARD #define SDIO_SUPPORT #define NO_SD_HOST_DRIVE // This board's SD is only seen by the printer @@ -161,53 +165,87 @@ #if ENABLED(RET6_12864_LCD) - // RET6 12864 LCD - #define LCD_PINS_RS PB12 - #define LCD_PINS_ENABLE PB15 - #define LCD_PINS_D4 PB13 - - #define BTN_ENC PB2 - #define BTN_EN1 PB10 - #define BTN_EN2 PB14 + /** + * RET6 12864 LCD + * ------ + * PC6 |10 9 | PB2 + * PB10 | 8 7 | PE8 + * PB14 6 5 | PB13 + * PB12 | 4 3 | PB15 + * GND | 2 1 | 5V + * ------ + * EXP1 + */ + #define EXP1_03_PIN PB15 + #define EXP1_04_PIN PB12 + #define EXP1_05_PIN PB13 + #define EXP1_06_PIN PB14 + #define EXP1_07_PIN PE8 + #define EXP1_08_PIN PB10 + #define EXP1_09_PIN PB2 + #define EXP1_10_PIN PC6 #ifndef HAS_PIN_27_BOARD - #define BEEPER_PIN PC6 + #define BEEPER_PIN EXP1_10_PIN #endif #elif ENABLED(VET6_12864_LCD) - // VET6 12864 LCD - #define LCD_PINS_RS PA4 - #define LCD_PINS_ENABLE PA7 - #define LCD_PINS_D4 PA5 - - #define BTN_ENC PC5 - #define BTN_EN1 PB10 - #define BTN_EN2 PA6 + /** + * VET6 12864 LCD + * ------ + * ? |10 9 | PC5 + * PB10 | 8 7 | ? + * PA6 6 5 | PA5 + * PA4 | 4 3 | PA7 + * GND | 2 1 | 5V + * ------ + * EXP1 + */ + #define EXP1_03_PIN PA7 + #define EXP1_04_PIN PA4 + #define EXP1_05_PIN PA5 + #define EXP1_06_PIN PA6 + #define EXP1_07_PIN -1 + #define EXP1_08_PIN PB10 + #define EXP1_09_PIN PC5 + #define EXP1_10_PIN -1 #else #error "Define RET6_12864_LCD or VET6_12864_LCD to select pins for CR10_STOCKDISPLAY with the Creality V4 controller." #endif -#elif HAS_DWIN_E3V2 || IS_DWIN_MARLINUI + #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN - // RET6 DWIN ENCODER LCD - #define BTN_ENC PB14 - #define BTN_EN1 PB15 - #define BTN_EN2 PB12 + #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP1_08_PIN + #define BTN_EN2 EXP1_06_PIN - //#define LCD_LED_PIN PB2 - #ifndef BEEPER_PIN - #define BEEPER_PIN PB13 - #endif +#elif ANY(HAS_DWIN_E3V2, IS_DWIN_MARLINUI, DWIN_VET6_CREALITY_LCD) -#elif ENABLED(DWIN_VET6_CREALITY_LCD) + #if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI + // RET6 DWIN ENCODER LCD + #define EXP1_03_PIN PB15 + #define EXP1_04_PIN PB12 + #define EXP1_05_PIN PB13 + #define EXP1_06_PIN PB14 + //#define LCD_LED_PIN PB2 + #else + // VET6 DWIN ENCODER LCD + #define EXP1_03_PIN PA7 + #define EXP1_04_PIN PA4 + #define EXP1_05_PIN PA5 + #define EXP1_06_PIN PA6 + #endif - // VET6 DWIN ENCODER LCD - #define BTN_ENC PA6 - #define BTN_EN1 PA7 - #define BTN_EN2 PA4 + #define BTN_ENC EXP1_06_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_04_PIN - #define BEEPER_PIN PA5 + #ifndef BEEPER_PIN + #define BEEPER_PIN EXP1_05_PIN + #endif #endif diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V425.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V425.h new file mode 100644 index 000000000000..46f437ecafb2 --- /dev/null +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V425.h @@ -0,0 +1,77 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (C) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * CREALITY 4.2.5 (STM32F103RE / STM32F103RC) board pin assignments + */ + +#include "env_validate.h" + +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 + #error "Creality v4.2.5 only supports 1 hotend / E stepper." +#endif + +#define BOARD_INFO_NAME "Creality V4.2.5" +#define DEFAULT_MACHINE_NAME "CR200B" + +// +// EEPROM +// +#if NO_EEPROM_SELECTED + #define IIC_BL24CXX_EEPROM // EEPROM on I2C-0 + #undef NO_EEPROM_SELECTED +#elif DISABLED(IIC_BL24CXX_EEPROM) + #define SDCARD_EEPROM_EMULATION // SD EEPROM until all EEPROM is BL24CXX +#endif + +// +// Servos +// +#define SERVO0_PIN PB1 // BLTouch OUT + +// +// Limit Switches +// +#define X_STOP_PIN PA3 +#define Y_STOP_PIN PA4 +#define Z_STOP_PIN PA5 + +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PB0 // BLTouch IN +#endif + +// +// Filament Runout Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PA6 // "Pulled-high" +#endif + +// +// Heaters / Fans +// +#define HEATER_0_PIN PA0 // HEATER1 +#define HEATER_BED_PIN PA1 // HOT BED +#define FAN_PIN PA2 // FAN + +#include "pins_CREALITY_V4.h" From e5e4cf920d406c45a66d00cd379fee08f4da0985 Mon Sep 17 00:00:00 2001 From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Date: Wed, 13 Jul 2022 23:31:47 -0700 Subject: [PATCH 31/32] =?UTF-8?q?=F0=9F=93=8C=20Pin=20ESP32SSDP=20to=201.1?= =?UTF-8?q?.1=20(#24489)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ini/features.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ini/features.ini b/ini/features.ini index 3e34e01d5c87..6eebbe8fd22f 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -236,5 +236,5 @@ HAS_MICROSTEPS = src_filter=+ Date: Thu, 14 Jul 2022 02:56:55 -0500 Subject: [PATCH 32/32] =?UTF-8?q?=F0=9F=94=A8=20Fix=20and=20update=20Makef?= =?UTF-8?q?ile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Followup to 89fe5f6d --- Marlin/Makefile | 121 ++---------------------------------------------- 1 file changed, 4 insertions(+), 117 deletions(-) diff --git a/Marlin/Makefile b/Marlin/Makefile index 563354fdbe1f..c72c1d589607 100644 --- a/Marlin/Makefile +++ b/Marlin/Makefile @@ -317,123 +317,10 @@ else ifeq ($(HARDWARE_MOTHERBOARD),1159) else ifeq ($(HARDWARE_MOTHERBOARD),1160) # Longer LKx PRO / Alfawise Uxx Pro (PRO version) else ifeq ($(HARDWARE_MOTHERBOARD),1161) - - -# 3Drag Controller -else ifeq ($(HARDWARE_MOTHERBOARD),1100) -# Velleman K8200 Controller (derived from 3Drag Controller) -else ifeq ($(HARDWARE_MOTHERBOARD),1101) -# Velleman K8400 Controller (derived from 3Drag Controller) -else ifeq ($(HARDWARE_MOTHERBOARD),1102) -# Velleman K8600 Controller (Vertex Nano) -else ifeq ($(HARDWARE_MOTHERBOARD),1103) -# Velleman K8800 Controller (Vertex Delta) -else ifeq ($(HARDWARE_MOTHERBOARD),1104) -# 2PrintBeta BAM&DICE with STK drivers -else ifeq ($(HARDWARE_MOTHERBOARD),1105) -# 2PrintBeta BAM&DICE Due with STK drivers -else ifeq ($(HARDWARE_MOTHERBOARD),1106) -# MKS BASE v1.0 -else ifeq ($(HARDWARE_MOTHERBOARD),1107) -# MKS v1.4 with A4982 stepper drivers -else ifeq ($(HARDWARE_MOTHERBOARD),1108) -# MKS v1.5 with Allegro A4982 stepper drivers -else ifeq ($(HARDWARE_MOTHERBOARD),1109) -# MKS v1.6 with Allegro A4982 stepper drivers -else ifeq ($(HARDWARE_MOTHERBOARD),1110) -# MKS BASE 1.0 with Heroic HR4982 stepper drivers -else ifeq ($(HARDWARE_MOTHERBOARD),1111) -# MKS GEN v1.3 or 1.4 -else ifeq ($(HARDWARE_MOTHERBOARD),1112) -# MKS GEN L -else ifeq ($(HARDWARE_MOTHERBOARD),1113) -# zrib V2.0 control board (Chinese RAMPS replica) -else ifeq ($(HARDWARE_MOTHERBOARD),1114) -# BigTreeTech or BIQU KFB2.0 -else ifeq ($(HARDWARE_MOTHERBOARD),1115) -# Felix 2.0+ Electronics Board (RAMPS like) -else ifeq ($(HARDWARE_MOTHERBOARD),1116) -# Invent-A-Part RigidBoard -else ifeq ($(HARDWARE_MOTHERBOARD),1117) -# Invent-A-Part RigidBoard V2 -else ifeq ($(HARDWARE_MOTHERBOARD),1118) -# Sainsmart 2-in-1 board -else ifeq ($(HARDWARE_MOTHERBOARD),1119) -# Ultimaker -else ifeq ($(HARDWARE_MOTHERBOARD),1120) -# Ultimaker (Older electronics. Pre 1.5.4. This is rare) -else ifeq ($(HARDWARE_MOTHERBOARD),1121) - MCU ?= atmega1280 - PROG_MCU ?= m1280 - -# Azteeg X3 -else ifeq ($(HARDWARE_MOTHERBOARD),1122) -# Azteeg X3 Pro -else ifeq ($(HARDWARE_MOTHERBOARD),1123) -# Ultimainboard 2.x (Uses TEMP_SENSOR 20) -else ifeq ($(HARDWARE_MOTHERBOARD),1124) -# Rumba -else ifeq ($(HARDWARE_MOTHERBOARD),1125) -# Raise3D Rumba -else ifeq ($(HARDWARE_MOTHERBOARD),1126) -# Rapide Lite RL200 Rumba -else ifeq ($(HARDWARE_MOTHERBOARD),1127) -# Formbot T-Rex 2 Plus -else ifeq ($(HARDWARE_MOTHERBOARD),1128) -# Formbot T-Rex 3 -else ifeq ($(HARDWARE_MOTHERBOARD),1129) -# Formbot Raptor -else ifeq ($(HARDWARE_MOTHERBOARD),1130) -# Formbot Raptor 2 -else ifeq ($(HARDWARE_MOTHERBOARD),1131) -# bq ZUM Mega 3D -else ifeq ($(HARDWARE_MOTHERBOARD),1132) -# MakeBoard Mini v2.1.2 is a control board sold by MicroMake -else ifeq ($(HARDWARE_MOTHERBOARD),1133) -# TriGorilla Anycubic version 1.3 based on RAMPS EFB -else ifeq ($(HARDWARE_MOTHERBOARD),1134) -# TriGorilla Anycubic version 1.4 based on RAMPS EFB -else ifeq ($(HARDWARE_MOTHERBOARD),1135) -# TriGorilla Anycubic version 1.4 Rev 1.1 -else ifeq ($(HARDWARE_MOTHERBOARD),1136) -# Creality: Ender-4, CR-8 -else ifeq ($(HARDWARE_MOTHERBOARD),1137) -# Creality: CR10S, CR20, CR-X -else ifeq ($(HARDWARE_MOTHERBOARD),1138) -# Dagoma F5 -else ifeq ($(HARDWARE_MOTHERBOARD),1139) -# FYSETC F6 1.3 -else ifeq ($(HARDWARE_MOTHERBOARD),1140) -# FYSETC F6 1.5 -else ifeq ($(HARDWARE_MOTHERBOARD),1141) -# Duplicator i3 Plus -else ifeq ($(HARDWARE_MOTHERBOARD),1142) -# VORON -else ifeq ($(HARDWARE_MOTHERBOARD),1143) -# TRONXY V3 1.0 -else ifeq ($(HARDWARE_MOTHERBOARD),1144) -# Z-Bolt X Series -else ifeq ($(HARDWARE_MOTHERBOARD),1145) -# TT OSCAR -else ifeq ($(HARDWARE_MOTHERBOARD),1146) -# Overlord/Overlord Pro -else ifeq ($(HARDWARE_MOTHERBOARD),1147) -# ADIMLab Gantry v1 -else ifeq ($(HARDWARE_MOTHERBOARD),1148) -# ADIMLab Gantry v2 -else ifeq ($(HARDWARE_MOTHERBOARD),1149) -# BIQU Tango V1 -else ifeq ($(HARDWARE_MOTHERBOARD),1150) -# MKS GEN L V2 -else ifeq ($(HARDWARE_MOTHERBOARD),1151) -# MKS GEN L V2.1 -else ifeq ($(HARDWARE_MOTHERBOARD),1152) -# Copymaster 3D -else ifeq ($(HARDWARE_MOTHERBOARD),1153) -# Ortur 4 -else ifeq ($(HARDWARE_MOTHERBOARD),1154) -# Tenlog D3 Hero -else ifeq ($(HARDWARE_MOTHERBOARD),1155) +# Zonestar zrib V5.3 (Chinese RAMPS replica) +else ifeq ($(HARDWARE_MOTHERBOARD),1162) +# Pxmalion Core I3 +else ifeq ($(HARDWARE_MOTHERBOARD),1163) # # RAMBo and derivatives