diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index dbbbb35c2c..5cc22a7bbe 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1541,13 +1541,16 @@ #endif /** - * NanoDLP Synch support + * NanoDLP Sync support * * Add support for Synchronized Z moves when using with NanoDLP. G0/G1 axis moves will output "Z_move_comp" * string to enable synchronization with DLP projector exposure. This change will allow to use * [[WaitForDoneMessage]] instead of populating your gcode with M400 commands - * */ - //#define NANODLP_Z_SYNC +//#define NANODLP_Z_SYNC +#if ENABLED(NANODLP_Z_SYNC) + //#define NANODLP_ALL_AXIS // Enables "Z_move_comp" output on any axis move. + // Default behaviour is limited to Z axis only. +#endif #endif // CONFIGURATION_ADV_H diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index d641a08d22..7368314942 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -325,6 +325,15 @@ void GcodeSuite::G28(const bool always_home_all) { lcd_refresh(); report_current_position(); + #if ENABLED(NANODLP_Z_SYNC) + #if ENABLED(NANODLP_ALL_AXIS) + #define _HOME_SYNC true // For any axis, output sync text. + #else + #define _HOME_SYNC (home_all || homeZ) // Only for Z-axis + #endif + if (_HOME_SYNC) + SERIAL_ECHOLNPGM(MSG_Z_MOVE_COMP); + #endif #if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< G28"); diff --git a/Marlin/src/gcode/motion/G0_G1.cpp b/Marlin/src/gcode/motion/G0_G1.cpp index 8d485e3744..98f297f13c 100644 --- a/Marlin/src/gcode/motion/G0_G1.cpp +++ b/Marlin/src/gcode/motion/G0_G1.cpp @@ -78,8 +78,12 @@ void GcodeSuite::G0_G1( #endif #if ENABLED(NANODLP_Z_SYNC) - // If G0/G1 command include Z-axis, wait for move and output sync text. - if (parser.seenval('Z')) { + #if ENABLED(NANODLP_ALL_AXIS) + #define _MOVE_SYNC true // For any move wait and output sync message + #else + #define _MOVE_SYNC parser.seenval('Z') // Only for Z move + #endif + if (_MOVE_SYNC) { stepper.synchronize(); SERIAL_ECHOLNPGM(MSG_Z_MOVE_COMP); } diff --git a/Marlin/src/gcode/motion/G4.cpp b/Marlin/src/gcode/motion/G4.cpp index 1630cf0b44..ff17cb6aa2 100644 --- a/Marlin/src/gcode/motion/G4.cpp +++ b/Marlin/src/gcode/motion/G4.cpp @@ -34,6 +34,9 @@ void GcodeSuite::G4() { if (parser.seenval('S')) dwell_ms = parser.value_millis_from_seconds(); // seconds to wait stepper.synchronize(); + #if ENABLED(NANODLP_Z_SYNC) + SERIAL_ECHOLNPGM(MSG_Z_MOVE_COMP); + #endif if (!lcd_hasstatus()) LCD_MESSAGEPGM(MSG_DWELL);