Browse Source

🩹 No PE_MAGNET_ON_STATE without PARKING_EXTRUDER

Scott Lahteine 2 years ago
parent
commit
d3e3e6a491

+ 6
- 12
Marlin/src/feature/solenoid.cpp View File

@@ -27,17 +27,11 @@
27 27
 #include "solenoid.h"
28 28
 
29 29
 #include "../module/motion.h" // for active_extruder
30
-
31
-// PARKING_EXTRUDER options alter the default behavior of solenoids, this ensures compliance of M380-381
32
-
33
-#if ENABLED(PARKING_EXTRUDER)
34
-  #include "../module/tool_change.h"
35
-#endif
30
+#include "../module/tool_change.h"
36 31
 
37 32
 // Used primarily with MANUAL_SOLENOID_CONTROL
38
-static void set_solenoid(const uint8_t num, const bool active) {
39
-  const uint8_t value = active ? PE_MAGNET_ON_STATE : !PE_MAGNET_ON_STATE;
40
-  #define _SOL_CASE(N) case N: TERN_(HAS_SOLENOID_##N, OUT_WRITE(SOL##N##_PIN, value)); break;
33
+static void set_solenoid(const uint8_t num, const uint8_t state) {
34
+  #define _SOL_CASE(N) case N: TERN_(HAS_SOLENOID_##N, OUT_WRITE(SOL##N##_PIN, state)); break;
41 35
   switch (num) {
42 36
     REPEAT(8, _SOL_CASE)
43 37
     default: SERIAL_ECHO_MSG(STR_INVALID_SOLENOID); break;
@@ -49,9 +43,9 @@ static void set_solenoid(const uint8_t num, const bool active) {
49 43
   #endif
50 44
 }
51 45
 
52
-void enable_solenoid(const uint8_t num) { set_solenoid(num, true); }
53
-void disable_solenoid(const uint8_t num) { set_solenoid(num, false); }
54
-void enable_solenoid_on_active_extruder() {  }
46
+// PARKING_EXTRUDER options alter the default behavior of solenoids to ensure compliance of M380-381
47
+void  enable_solenoid(const uint8_t num) { set_solenoid(num, TERN1(PARKING_EXTRUDER,  PE_MAGNET_ON_STATE)); }
48
+void disable_solenoid(const uint8_t num) { set_solenoid(num, TERN0(PARKING_EXTRUDER, !PE_MAGNET_ON_STATE)); }
55 49
 
56 50
 void disable_all_solenoids() {
57 51
   #define _SOL_DISABLE(N) TERN_(HAS_SOLENOID_##N, disable_solenoid(N));

+ 0
- 1
Marlin/src/feature/solenoid.h View File

@@ -21,7 +21,6 @@
21 21
  */
22 22
 #pragma once
23 23
 
24
-void enable_solenoid_on_active_extruder();
25 24
 void disable_all_solenoids();
26 25
 void enable_solenoid(const uint8_t num);
27 26
 void disable_solenoid(const uint8_t num);

+ 1
- 1
Marlin/src/gcode/control/M380_M381.cpp View File

@@ -37,7 +37,7 @@ void GcodeSuite::M380() {
37 37
   #if ENABLED(MANUAL_SOLENOID_CONTROL)
38 38
     enable_solenoid(parser.intval('S', active_extruder));
39 39
   #else
40
-    enable_solenoid_on_active_extruder();
40
+    enable_solenoid(active_extruder);
41 41
   #endif
42 42
 }
43 43
 

+ 2
- 2
Marlin/src/gcode/gcode.h View File

@@ -219,8 +219,8 @@
219 219
  * M350 - Set microstepping mode. (Requires digital microstepping pins.)
220 220
  * M351 - Toggle MS1 MS2 pins directly. (Requires digital microstepping pins.)
221 221
  * M355 - Set Case Light on/off and set brightness. (Requires CASE_LIGHT_PIN)
222
- * M380 - Activate solenoid on active extruder. (Requires EXT_SOLENOID)
223
- * M381 - Disable all solenoids. (Requires EXT_SOLENOID)
222
+ * M380 - Activate solenoid on active tool (Requires EXT_SOLENOID) or the tool specified by 'S' (Requires MANUAL_SOLENOID_CONTROL).
223
+ * M381 - Disable solenoids on all tools (Requires EXT_SOLENOID) or the tool specified by 'S' (Requires MANUAL_SOLENOID_CONTROL).
224 224
  * M400 - Finish all moves.
225 225
  * M401 - Deploy and activate Z probe. (Requires a probe)
226 226
  * M402 - Deactivate and stow Z probe. (Requires a probe)

+ 1
- 1
Marlin/src/module/tool_change.cpp View File

@@ -1292,7 +1292,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
1292 1292
 
1293 1293
     #if ENABLED(EXT_SOLENOID) && DISABLED(PARKING_EXTRUDER)
1294 1294
       disable_all_solenoids();
1295
-      enable_solenoid_on_active_extruder();
1295
+      enable_solenoid(active_extruder);
1296 1296
     #endif
1297 1297
 
1298 1298
     #if HAS_PRUSA_MMU1

Loading…
Cancel
Save