Clarify solenoid active / magnet-on state
This commit is contained in:
parent
ed7698efaa
commit
cc1b8c2d0b
@ -259,11 +259,10 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a
|
||||
#elif ENABLED(PARKING_EXTRUDER)
|
||||
|
||||
void pe_solenoid_init() {
|
||||
LOOP_LE_N(n, 1)
|
||||
TERN(PARKING_EXTRUDER_SOLENOIDS_INVERT, pe_activate_solenoid, pe_deactivate_solenoid)(n);
|
||||
LOOP_LE_N(n, 1) pe_solenoid_set_pin_state(n, !PARKING_EXTRUDER_SOLENOIDS_PINS_ACTIVE);
|
||||
}
|
||||
|
||||
void pe_set_solenoid(const uint8_t extruder_num, const uint8_t state) {
|
||||
void pe_solenoid_set_pin_state(const uint8_t extruder_num, const uint8_t state) {
|
||||
switch (extruder_num) {
|
||||
case 1: OUT_WRITE(SOL1_PIN, state); break;
|
||||
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
|
||||
if (!extruder_parked) return false; // nothing to do
|
||||
|
||||
if (homed_towards_final_tool) {
|
||||
pe_deactivate_solenoid(1 - final_tool);
|
||||
pe_solenoid_magnet_off(1 - final_tool);
|
||||
DEBUG_ECHOLNPAIR("Disengage magnet", (int)(1 - final_tool));
|
||||
pe_activate_solenoid(final_tool);
|
||||
pe_solenoid_magnet_on(final_tool);
|
||||
DEBUG_ECHOLNPAIR("Engage magnet", (int)final_tool);
|
||||
extruder_parked = false;
|
||||
parking_extruder_set_parked(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -335,7 +334,7 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a
|
||||
|
||||
planner.synchronize();
|
||||
DEBUG_ECHOLNPGM("(2) Disengage magnet");
|
||||
pe_deactivate_solenoid(active_extruder);
|
||||
pe_solenoid_magnet_off(active_extruder);
|
||||
|
||||
// STEP 3
|
||||
|
||||
@ -353,8 +352,8 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a
|
||||
DEBUG_ECHOLNPGM("(4) Engage magnetic field");
|
||||
|
||||
// Just save power for inverted magnets
|
||||
TERN_(PARKING_EXTRUDER_SOLENOIDS_INVERT, pe_activate_solenoid(active_extruder));
|
||||
pe_activate_solenoid(new_tool);
|
||||
TERN_(PARKING_EXTRUDER_SOLENOIDS_INVERT, pe_solenoid_magnet_on(active_extruder));
|
||||
pe_solenoid_magnet_on(new_tool);
|
||||
|
||||
// STEP 5
|
||||
|
||||
@ -382,10 +381,10 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a
|
||||
extruder_parked = false;
|
||||
}
|
||||
else if (do_solenoid_activation) { // && nomove == true
|
||||
// Deactivate old extruder solenoid
|
||||
TERN(PARKING_EXTRUDER_SOLENOIDS_INVERT, pe_activate_solenoid, pe_deactivate_solenoid)(active_extruder);
|
||||
// Only engage magnetic field for new extruder
|
||||
TERN(PARKING_EXTRUDER_SOLENOIDS_INVERT, pe_deactivate_solenoid, pe_activate_solenoid)(new_tool);
|
||||
// Deactivate current extruder solenoid
|
||||
pe_solenoid_set_pin_state(active_extruder, !PARKING_EXTRUDER_SOLENOIDS_PINS_ACTIVE);
|
||||
// Engage new extruder magnetic field
|
||||
pe_solenoid_set_pin_state(new_tool, PARKING_EXTRUDER_SOLENOIDS_PINS_ACTIVE);
|
||||
}
|
||||
|
||||
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*/) {
|
||||
// Just move back down
|
||||
DEBUG_ECHOLNPGM("Move back Z only");
|
||||
|
||||
#if ENABLED(TOOLCHANGE_PARK)
|
||||
if (toolchange_settings.enable_park)
|
||||
#endif
|
||||
do_blocking_move_to_z(destination.z, planner.settings.max_feedrate_mm_s[Z_AXIS]);
|
||||
if (TERN1(TOOLCHANGE_PARK, toolchange_settings.enable_park))
|
||||
do_blocking_move_to_z(destination.z, planner.settings.max_feedrate_mm_s[Z_AXIS]);
|
||||
|
||||
#else
|
||||
// Move back to the original (or adjusted) position
|
||||
|
@ -86,10 +86,10 @@
|
||||
#define PE_MAGNET_ON_STATE PARKING_EXTRUDER_SOLENOIDS_PINS_ACTIVE
|
||||
#endif
|
||||
|
||||
void pe_set_solenoid(const uint8_t extruder_num, const uint8_t state);
|
||||
void pe_solenoid_set_pin_state(const uint8_t extruder_num, const uint8_t state);
|
||||
|
||||
inline void pe_activate_solenoid(const uint8_t extruder_num) { pe_set_solenoid(extruder_num, PE_MAGNET_ON_STATE); }
|
||||
inline void pe_deactivate_solenoid(const uint8_t extruder_num) { pe_set_solenoid(extruder_num, !PE_MAGNET_ON_STATE); }
|
||||
inline void pe_solenoid_magnet_on(const uint8_t extruder_num) { pe_solenoid_set_pin_state(extruder_num, PE_MAGNET_ON_STATE); }
|
||||
inline void pe_solenoid_magnet_off(const uint8_t extruder_num) { pe_solenoid_set_pin_state(extruder_num, !PE_MAGNET_ON_STATE); }
|
||||
|
||||
void pe_solenoid_init();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user