|
|
@ -30,13 +30,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
#include "fwretract.h"
|
|
|
|
#include "fwretract.h"
|
|
|
|
|
|
|
|
|
|
|
|
FWRetract fwretract; // Single instance
|
|
|
|
FWRetract fwretract; // Single instance - this calls the constructor
|
|
|
|
|
|
|
|
|
|
|
|
#include "../module/motion.h"
|
|
|
|
#include "../module/motion.h"
|
|
|
|
#include "../module/planner.h"
|
|
|
|
#include "../module/planner.h"
|
|
|
|
|
|
|
|
#include "../module/stepper.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// private:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if EXTRUDERS > 1
|
|
|
|
|
|
|
|
bool FWRetract::retracted_swap[EXTRUDERS]; // Which extruders are swap-retracted
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// public:
|
|
|
|
|
|
|
|
|
|
|
|
bool FWRetract::autoretract_enabled, // M209 S - Autoretract switch
|
|
|
|
bool FWRetract::autoretract_enabled, // M209 S - Autoretract switch
|
|
|
|
FWRetract::retracted[EXTRUDERS] = { false }; // Which extruders are currently retracted
|
|
|
|
FWRetract::retracted[EXTRUDERS]; // Which extruders are currently retracted
|
|
|
|
float FWRetract::retract_length, // M207 S - G10 Retract length
|
|
|
|
float FWRetract::retract_length, // M207 S - G10 Retract length
|
|
|
|
FWRetract::retract_feedrate_mm_s, // M207 F - G10 Retract feedrate
|
|
|
|
FWRetract::retract_feedrate_mm_s, // M207 F - G10 Retract feedrate
|
|
|
|
FWRetract::retract_zlift, // M207 Z - G10 Retract hop size
|
|
|
|
FWRetract::retract_zlift, // M207 Z - G10 Retract hop size
|
|
|
@ -45,9 +54,6 @@ float FWRetract::retract_length, // M207 S - G10 Retract len
|
|
|
|
FWRetract::swap_retract_length, // M207 W - G10 Swap Retract length
|
|
|
|
FWRetract::swap_retract_length, // M207 W - G10 Swap Retract length
|
|
|
|
FWRetract::swap_retract_recover_length, // M208 W - G11 Swap Recover length
|
|
|
|
FWRetract::swap_retract_recover_length, // M208 W - G11 Swap Recover length
|
|
|
|
FWRetract::swap_retract_recover_feedrate_mm_s; // M208 R - G11 Swap Recover feedrate
|
|
|
|
FWRetract::swap_retract_recover_feedrate_mm_s; // M208 R - G11 Swap Recover feedrate
|
|
|
|
#if EXTRUDERS > 1
|
|
|
|
|
|
|
|
bool FWRetract::retracted_swap[EXTRUDERS] = { false }; // Which extruders are swap-retracted
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FWRetract::reset() {
|
|
|
|
void FWRetract::reset() {
|
|
|
|
autoretract_enabled = false;
|
|
|
|
autoretract_enabled = false;
|
|
|
@ -59,6 +65,13 @@ void FWRetract::reset() {
|
|
|
|
swap_retract_length = RETRACT_LENGTH_SWAP;
|
|
|
|
swap_retract_length = RETRACT_LENGTH_SWAP;
|
|
|
|
swap_retract_recover_length = RETRACT_RECOVER_LENGTH_SWAP;
|
|
|
|
swap_retract_recover_length = RETRACT_RECOVER_LENGTH_SWAP;
|
|
|
|
swap_retract_recover_feedrate_mm_s = RETRACT_RECOVER_FEEDRATE_SWAP;
|
|
|
|
swap_retract_recover_feedrate_mm_s = RETRACT_RECOVER_FEEDRATE_SWAP;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (uint8_t i = 0; i < EXTRUDERS; ++i) {
|
|
|
|
|
|
|
|
retracted[i] = false;
|
|
|
|
|
|
|
|
#if EXTRUDERS > 1
|
|
|
|
|
|
|
|
retracted_swap[i] = false;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -87,10 +100,11 @@ void FWRetract::retract(const bool retracting
|
|
|
|
// Simply never allow two retracts or recovers in a row
|
|
|
|
// Simply never allow two retracts or recovers in a row
|
|
|
|
if (retracted[active_extruder] == retracting) return;
|
|
|
|
if (retracted[active_extruder] == retracting) return;
|
|
|
|
|
|
|
|
|
|
|
|
#if EXTRUDERS < 2
|
|
|
|
#if EXTRUDERS > 1
|
|
|
|
bool swapping = false;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!retracting) swapping = retracted_swap[active_extruder];
|
|
|
|
if (!retracting) swapping = retracted_swap[active_extruder];
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
const bool swapping = false;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/* // debugging
|
|
|
|
/* // debugging
|
|
|
|
SERIAL_ECHOLNPAIR("retracting ", retracting);
|
|
|
|
SERIAL_ECHOLNPAIR("retracting ", retracting);
|
|
|
@ -117,6 +131,8 @@ void FWRetract::retract(const bool retracting
|
|
|
|
// The current position will be the destination for E and Z moves
|
|
|
|
// The current position will be the destination for E and Z moves
|
|
|
|
set_destination_to_current();
|
|
|
|
set_destination_to_current();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stepper.synchronize(); // Wait for buffered moves to complete
|
|
|
|
|
|
|
|
|
|
|
|
if (retracting) {
|
|
|
|
if (retracting) {
|
|
|
|
// Remember the Z height since G-code may include its own Z-hop
|
|
|
|
// Remember the Z height since G-code may include its own Z-hop
|
|
|
|
// For best results turn off Z hop if G-code already includes it
|
|
|
|
// For best results turn off Z hop if G-code already includes it
|
|
|
|