diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h
index 355c782e8..7f242dce7 100644
--- a/Marlin/Configuration.h
+++ b/Marlin/Configuration.h
@@ -915,6 +915,13 @@
#define Z_PROBE_RETRACT_X X_MAX_POS
#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 sensivity.
+//#define DUET_SMART_EFFECTOR
+#if ENABLED(DUET_SMART_EFFECTOR)
+ #define SMART_EFFECTOR_MOD_PIN -1 // Connect a GPIO pin to the Smart Effector MOD pin
+#endif
+
//
// For Z_PROBE_ALLEN_KEY see the Delta example configurations.
//
diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp
index a6bb262f8..7ec6ffb48 100644
--- a/Marlin/src/MarlinCore.cpp
+++ b/Marlin/src/MarlinCore.cpp
@@ -827,6 +827,10 @@ void setup() {
L64xxManager.init(); // Set up SPI, init drivers
#endif
+ #if ENABLED(SMART_EFFECTOR) && PIN_EXISTS(SMART_EFFECTOR_MOD)
+ OUT_WRITE(SMART_EFFECTOR_MOD_PIN, LOW); // Put Smart Effector into NORMAL mode
+ #endif
+
#if ENABLED(MAX7219_DEBUG)
max7219.init();
#endif
diff --git a/Marlin/src/gcode/config/M672.cpp b/Marlin/src/gcode/config/M672.cpp
new file mode 100644
index 000000000..ca4b028dc
--- /dev/null
+++ b/Marlin/src/gcode/config/M672.cpp
@@ -0,0 +1,99 @@
+/**
+ * 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 ENABLED(SMART_EFFECTOR) && PIN_EXISTS(SMART_EFFECTOR_MOD)
+
+#include "../gcode.h"
+#include "../../HAL/shared/Delay.h"
+#include "../parser.h"
+
+/**
+ * M672 - Set/reset Duet Smart Effector sensitivity
+ *
+ * One of these is required:
+ * S - 0-255
+ * R - Flag to reset sensitivity to default
+ */
+
+/**
+ * The Marlin format for the M672 command is different than shown in the Duet Smart Effector
+ * documentation https://duet3d.dozuki.com/Wiki/Smart_effector_and_carriage_adapters_for_delta_printer
+ *
+ * To set custom sensitivity:
+ * Duet: M672 S105:aaa:bbb
+ * Marlin: M672 Saaa
+ *
+ * (where aaa is the desired sensitivity and bbb is 255 - aaa).
+ *
+ * Revert sensitivity to factory settings:
+ * Duet: M672 S105:131:131
+ * Marlin: M672 R
+ */
+
+#define M672_PROGBYTE 105 // magic byte to start programming custom sensitivity
+#define M672_ERASEBYTE 131 // magic byte to clear custom sensitivity
+
+//
+// Smart Effector byte send protocol:
+//
+// 0 0 1 0 ... always 0010
+// b7 b6 b5 b4 ~b4 ... hi bits, NOT last bit
+// b3 b2 b1 b0 ~b0 ... lo bits, NOT last bit
+//
+void M672_send(uint8_t b) { // bit rate requirement: 1KHz +/- 30%
+ for (uint8_t bits = 0; bits < 14; bits++) {
+ switch (bits) {
+ default: { OUT_WRITE(SMART_EFFECTOR_MOD_PIN, !!(b & 0x80)); b <<= 1; break; } // send bit, shift next into place
+ case 7:
+ case 12: { OUT_WRITE(SMART_EFFECTOR_MOD_PIN, !!(b & 0x80)); break; } // send bit. no shift
+ case 8:
+ case 13: { OUT_WRITE(SMART_EFFECTOR_MOD_PIN, !(b & 0x80)); b <<= 1; break; } // send inverted previous bit
+ case 0: case 1: // 00
+ case 3: { OUT_WRITE(SMART_EFFECTOR_MOD_PIN, LOW); break; } // 0010
+ case 2: { OUT_WRITE(SMART_EFFECTOR_MOD_PIN, HIGH); break; } // 001
+ }
+ DELAY_US(1000);
+ }
+}
+
+void GcodeSuite::M672() {
+ if (parser.seen('R')) {
+ M672_send(M672_ERASEBYTE);
+ M672_send(M672_ERASEBYTE);
+ }
+ else if (parser.seenval('S')) {
+ const int8_t M672_sensitivity = parser.value_byte();
+ M672_send(M672_PROGBYTE);
+ M672_send(M672_sensitivity);
+ M672_send(255 - M672_sensitivity);
+ }
+ else {
+ SERIAL_ECHO_MSG("!'S' or 'R' parameter required.");
+ return;
+ }
+
+ OUT_WRITE(SMART_EFFECTOR_MOD_PIN, LOW); // Keep Smart Effector in NORMAL mode
+}
+
+#endif // SMART_EFFECTOR && SMART_EFFECTOR_MOD_PIN
diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp
index 8260db20a..7ff86f314 100644
--- a/Marlin/src/gcode/gcode.cpp
+++ b/Marlin/src/gcode/gcode.cpp
@@ -562,14 +562,6 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
case 206: M206(); break; // M206: Set home offsets
#endif
- #if ENABLED(DELTA)
- case 665: M665(); break; // M665: Set delta configurations
- #endif
-
- #if ENABLED(DELTA) || HAS_EXTRA_ENDSTOPS
- case 666: M666(); break; // M666: Set delta or multiple endstop adjustment
- #endif
-
#if ENABLED(FWRETRACT)
case 207: M207(); break; // M207: Set Retract Length, Feedrate, and Z lift
case 208: M208(); break; // M208: Set Recover (unretract) Additional Length and Feedrate
@@ -714,7 +706,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
#endif
#if ENABLED(SDSUPPORT)
- case 524: M524(); break; // M524: Abort the current SD print job
+ case 524: M524(); break; // M524: Abort the current SD print job
#endif
#if ENABLED(SD_ABORT_ON_ENDSTOP_HIT)
@@ -725,14 +717,6 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
case 575: M575(); break; // M575: Set serial baudrate
#endif
- #if HAS_BED_PROBE
- case 851: M851(); break; // M851: Set Z Probe Z Offset
- #endif
-
- #if ENABLED(SKEW_CORRECTION_GCODE)
- case 852: M852(); break; // M852: Set Skew factors
- #endif
-
#if ENABLED(ADVANCED_PAUSE_FEATURE)
case 600: M600(); break; // M600: Pause for Filament Change
case 603: M603(); break; // M603: Configure Filament Change
@@ -742,21 +726,37 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
case 605: M605(); break; // M605: Set Dual X Carriage movement mode
#endif
+ #if ENABLED(DELTA)
+ case 665: M665(); break; // M665: Set delta configurations
+ #endif
+
+ #if ENABLED(DELTA) || HAS_EXTRA_ENDSTOPS
+ case 666: M666(); break; // M666: Set delta or multiple endstop adjustment
+ #endif
+
+ #if ENABLED(SMART_EFFECTOR) && PIN_EXISTS(SMART_EFFECTOR_MOD)
+ case 672: M672(); break; // M672: Set/clear Duet Smart Effector sensitivity
+ #endif
+
#if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
case 701: M701(); break; // M701: Load Filament
case 702: M702(); break; // M702: Unload Filament
#endif
- #if ENABLED(MAX7219_GCODE)
- case 7219: M7219(); break; // M7219: Set LEDs, columns, and rows
- #endif
-
#if ENABLED(GCODE_MACROS)
case 810: case 811: case 812: case 813: case 814:
case 815: case 816: case 817: case 818: case 819:
M810_819(); break; // M810-M819: Define/execute G-code macro
#endif
+ #if HAS_BED_PROBE
+ case 851: M851(); break; // M851: Set Z Probe Z Offset
+ #endif
+
+ #if ENABLED(SKEW_CORRECTION_GCODE)
+ case 852: M852(); break; // M852: Set Skew factors
+ #endif
+
#if ENABLED(PROBE_TEMP_COMPENSATION)
case 871: M871(); break; // M871: Print/reset/clear first layer temperature offset values
#endif
@@ -847,6 +847,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
case 1000: M1000(); break; // M1000: Resume from power-loss
#endif
+ #if ENABLED(MAX7219_GCODE)
+ case 7219: M7219(); break; // M7219: Set LEDs, columns, and rows
+ #endif
+
default: parser.unknown_command_error(); break;
}
break;
diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h
index 0fbfbfc40..f7111c6ee 100644
--- a/Marlin/src/gcode/gcode.h
+++ b/Marlin/src/gcode/gcode.h
@@ -228,7 +228,8 @@
* M603 - Configure filament change: "M603 T U L". (Requires ADVANCED_PAUSE_FEATURE)
* M605 - Set Dual X-Carriage movement mode: "M605 S [X] [R]". (Requires DUAL_X_CARRIAGE)
* M665 - Set delta configurations: "M665 H L R S B X Y Z (Requires DELTA)
- * M666 - Set/get offsets for delta (Requires DELTA) or dual endstops (Requires [XYZ]_DUAL_ENDSTOPS).
+ * M666 - Set/get offsets for delta (Requires DELTA) or dual endstops. (Requires [XYZ]_DUAL_ENDSTOPS)
+ * M672 - Set/Reset Duet Smart Effector's sensitivity. (Requires SMART_EFFECTOR and SMART_EFFECTOR_MOD_PIN)
* M701 - Load filament (Requires FILAMENT_LOAD_UNLOAD_GCODES)
* M702 - Unload filament (Requires FILAMENT_LOAD_UNLOAD_GCODES)
* M810-M819 - Define/execute a G-code macro (Requires GCODE_MACROS)
@@ -850,6 +851,10 @@ private:
static void M666();
#endif
+ #if ENABLED(SMART_EFFECTOR) && PIN_EXISTS(SMART_EFFECTOR_MOD)
+ static void M672();
+ #endif
+
#if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
static void M701();
static void M702();
diff --git a/Marlin/src/pins/pinsDebug_list.h b/Marlin/src/pins/pinsDebug_list.h
index 7de2bad35..771ca3da0 100644
--- a/Marlin/src/pins/pinsDebug_list.h
+++ b/Marlin/src/pins/pinsDebug_list.h
@@ -1488,3 +1488,6 @@
#if PIN_EXISTS(TOUCH_INT)
REPORT_NAME_DIGITAL(__LINE__, TOUCH_INT_PIN)
#endif
+#if PIN_EXISTS(SMART_EFFECTOR_MOD)
+ REPORT_NAME_DIGITAL(__LINE__, SMART_EFFECTOR_MOD_PIN)
+#endif