Преглед изворни кода

Clarify solenoid active / magnet-on state

Scott Lahteine пре 3 година
родитељ
комит
c0a3931595
2 измењених фајлова са 17 додато и 20 уклоњено
  1. 14
    17
      Marlin/src/module/tool_change.cpp
  2. 3
    3
      Marlin/src/module/tool_change.h

+ 14
- 17
Marlin/src/module/tool_change.cpp Прегледај датотеку

@@ -259,11 +259,10 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a
259 259
 #elif ENABLED(PARKING_EXTRUDER)
260 260
 
261 261
   void pe_solenoid_init() {
262
-    LOOP_LE_N(n, 1)
263
-      TERN(PARKING_EXTRUDER_SOLENOIDS_INVERT, pe_activate_solenoid, pe_deactivate_solenoid)(n);
262
+    LOOP_LE_N(n, 1) pe_solenoid_set_pin_state(n, !PARKING_EXTRUDER_SOLENOIDS_PINS_ACTIVE);
264 263
   }
265 264
 
266
-  void pe_set_solenoid(const uint8_t extruder_num, const uint8_t state) {
265
+  void pe_solenoid_set_pin_state(const uint8_t extruder_num, const uint8_t state) {
267 266
     switch (extruder_num) {
268 267
       case 1: OUT_WRITE(SOL1_PIN, state); break;
269 268
       default: OUT_WRITE(SOL0_PIN, state); break;
@@ -282,11 +281,11 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a
282 281
     if (!extruder_parked) return false; // nothing to do
283 282
 
284 283
     if (homed_towards_final_tool) {
285
-      pe_deactivate_solenoid(1 - final_tool);
284
+      pe_solenoid_magnet_off(1 - final_tool);
286 285
       DEBUG_ECHOLNPAIR("Disengage magnet", (int)(1 - final_tool));
287
-      pe_activate_solenoid(final_tool);
286
+      pe_solenoid_magnet_on(final_tool);
288 287
       DEBUG_ECHOLNPAIR("Engage magnet", (int)final_tool);
289
-      extruder_parked = false;
288
+      parking_extruder_set_parked(false);
290 289
       return false;
291 290
     }
292 291
 
@@ -335,7 +334,7 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a
335 334
 
336 335
         planner.synchronize();
337 336
         DEBUG_ECHOLNPGM("(2) Disengage magnet");
338
-        pe_deactivate_solenoid(active_extruder);
337
+        pe_solenoid_magnet_off(active_extruder);
339 338
 
340 339
         // STEP 3
341 340
 
@@ -353,8 +352,8 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a
353 352
       DEBUG_ECHOLNPGM("(4) Engage magnetic field");
354 353
 
355 354
       // Just save power for inverted magnets
356
-      TERN_(PARKING_EXTRUDER_SOLENOIDS_INVERT, pe_activate_solenoid(active_extruder));
357
-      pe_activate_solenoid(new_tool);
355
+      TERN_(PARKING_EXTRUDER_SOLENOIDS_INVERT, pe_solenoid_magnet_on(active_extruder));
356
+      pe_solenoid_magnet_on(new_tool);
358 357
 
359 358
       // STEP 5
360 359
 
@@ -382,10 +381,10 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a
382 381
       extruder_parked = false;
383 382
     }
384 383
     else if (do_solenoid_activation) { // && nomove == true
385
-      // Deactivate old extruder solenoid
386
-      TERN(PARKING_EXTRUDER_SOLENOIDS_INVERT, pe_activate_solenoid, pe_deactivate_solenoid)(active_extruder);
387
-      // Only engage magnetic field for new extruder
388
-      TERN(PARKING_EXTRUDER_SOLENOIDS_INVERT, pe_deactivate_solenoid, pe_activate_solenoid)(new_tool);
384
+      // Deactivate current extruder solenoid
385
+      pe_solenoid_set_pin_state(active_extruder, !PARKING_EXTRUDER_SOLENOIDS_PINS_ACTIVE);
386
+      // Engage new extruder magnetic field
387
+      pe_solenoid_set_pin_state(new_tool, PARKING_EXTRUDER_SOLENOIDS_PINS_ACTIVE);
389 388
     }
390 389
 
391 390
     do_solenoid_activation = true; // Activate solenoid for subsequent tool_change()
@@ -1149,10 +1148,8 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
1149 1148
             // Just move back down
1150 1149
             DEBUG_ECHOLNPGM("Move back Z only");
1151 1150
 
1152
-            #if ENABLED(TOOLCHANGE_PARK)
1153
-              if (toolchange_settings.enable_park)
1154
-            #endif
1155
-            do_blocking_move_to_z(destination.z, planner.settings.max_feedrate_mm_s[Z_AXIS]);
1151
+            if (TERN1(TOOLCHANGE_PARK, toolchange_settings.enable_park))
1152
+              do_blocking_move_to_z(destination.z, planner.settings.max_feedrate_mm_s[Z_AXIS]);
1156 1153
 
1157 1154
           #else
1158 1155
             // Move back to the original (or adjusted) position

+ 3
- 3
Marlin/src/module/tool_change.h Прегледај датотеку

@@ -86,10 +86,10 @@
86 86
     #define PE_MAGNET_ON_STATE PARKING_EXTRUDER_SOLENOIDS_PINS_ACTIVE
87 87
   #endif
88 88
 
89
-  void pe_set_solenoid(const uint8_t extruder_num, const uint8_t state);
89
+  void pe_solenoid_set_pin_state(const uint8_t extruder_num, const uint8_t state);
90 90
 
91
-  inline void pe_activate_solenoid(const uint8_t extruder_num) { pe_set_solenoid(extruder_num, PE_MAGNET_ON_STATE); }
92
-  inline void pe_deactivate_solenoid(const uint8_t extruder_num) { pe_set_solenoid(extruder_num, !PE_MAGNET_ON_STATE); }
91
+  inline void pe_solenoid_magnet_on(const uint8_t extruder_num)  { pe_solenoid_set_pin_state(extruder_num,  PE_MAGNET_ON_STATE); }
92
+  inline void pe_solenoid_magnet_off(const uint8_t extruder_num) { pe_solenoid_set_pin_state(extruder_num, !PE_MAGNET_ON_STATE); }
93 93
 
94 94
   void pe_solenoid_init();
95 95
 

Loading…
Откажи
Сачувај