mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2024-11-24 04:29:34 +00:00
Merge pull request #9971 from thinkyhead/bf2_lin_advance_duplication
[2.0.x] Support duplication mode in LIN_ADVANCE
This commit is contained in:
commit
d7aed2fe4f
@ -122,8 +122,13 @@ volatile uint32_t Stepper::step_events_completed = 0; // The number of step even
|
|||||||
Stepper::final_adv_steps,
|
Stepper::final_adv_steps,
|
||||||
Stepper::max_adv_steps;
|
Stepper::max_adv_steps;
|
||||||
|
|
||||||
int8_t Stepper::e_steps = 0,
|
int8_t Stepper::e_steps = 0;
|
||||||
Stepper::LA_active_extruder; // Copy from current executed block. Needed because current_block is set to NULL "too early".
|
|
||||||
|
#if E_STEPPERS > 1
|
||||||
|
int8_t Stepper::LA_active_extruder; // Copy from current executed block. Needed because current_block is set to NULL "too early".
|
||||||
|
#else
|
||||||
|
constexpr int8_t Stepper::LA_active_extruder;
|
||||||
|
#endif
|
||||||
|
|
||||||
bool Stepper::use_advance_lead;
|
bool Stepper::use_advance_lead;
|
||||||
|
|
||||||
@ -755,23 +760,21 @@ void Stepper::isr() {
|
|||||||
|
|
||||||
void Stepper::advance_isr() {
|
void Stepper::advance_isr() {
|
||||||
|
|
||||||
#if ENABLED(MK2_MULTIPLEXER)
|
#if ENABLED(MK2_MULTIPLEXER) // For SNMM even-numbered steppers are reversed
|
||||||
// Even-numbered steppers are reversed
|
#define SET_E_STEP_DIR(INDEX) do{ if (e_steps) E## INDEX ##_DIR_WRITE(e_steps < 0 ? !INVERT_E## INDEX ##_DIR ^ TEST(INDEX, 0) : INVERT_E## INDEX ##_DIR ^ TEST(INDEX, 0)); }while(0)
|
||||||
#define SET_E_STEP_DIR(INDEX) \
|
#elif ENABLED(DUAL_X_CARRIAGE) || ENABLED(DUAL_NOZZLE_DUPLICATION_MODE)
|
||||||
if (e_steps) E## INDEX ##_DIR_WRITE(e_steps < 0 ? !INVERT_E## INDEX ##_DIR ^ TEST(INDEX, 0) : INVERT_E## INDEX ##_DIR ^ TEST(INDEX, 0))
|
#define SET_E_STEP_DIR(INDEX) do{ if (e_steps) { e_steps < 0 ? REV_E_DIR() : NORM_E_DIR(); } }while(0)
|
||||||
#else
|
#else
|
||||||
#define SET_E_STEP_DIR(INDEX) \
|
#define SET_E_STEP_DIR(INDEX) do{ if (e_steps) E## INDEX ##_DIR_WRITE(e_steps < 0 ? INVERT_E## INDEX ##_DIR : !INVERT_E## INDEX ##_DIR); }while(0)
|
||||||
if (e_steps) E## INDEX ##_DIR_WRITE(e_steps < 0 ? INVERT_E## INDEX ##_DIR : !INVERT_E## INDEX ##_DIR)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define START_E_PULSE(INDEX) \
|
#if ENABLED(DUAL_X_CARRIAGE) || ENABLED(DUAL_NOZZLE_DUPLICATION_MODE)
|
||||||
if (e_steps) E## INDEX ##_STEP_WRITE(!INVERT_E_STEP_PIN)
|
#define START_E_PULSE(INDEX) do{ if (e_steps) E_STEP_WRITE(!INVERT_E_STEP_PIN); }while(0)
|
||||||
|
#define STOP_E_PULSE(INDEX) do{ if (e_steps) { E_STEP_WRITE(INVERT_E_STEP_PIN); e_steps < 0 ? ++e_steps : --e_steps; } }while(0)
|
||||||
#define STOP_E_PULSE(INDEX) \
|
#else
|
||||||
if (e_steps) { \
|
#define START_E_PULSE(INDEX) do{ if (e_steps) E## INDEX ##_STEP_WRITE(!INVERT_E_STEP_PIN); }while(0)
|
||||||
e_steps < 0 ? ++e_steps : --e_steps; \
|
#define STOP_E_PULSE(INDEX) do { if (e_steps) { E## INDEX ##_STEP_WRITE(INVERT_E_STEP_PIN); e_steps < 0 ? ++e_steps : --e_steps; } }while(0)
|
||||||
E## INDEX ##_STEP_WRITE(INVERT_E_STEP_PIN); \
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
if (current_block->use_advance_lead) {
|
if (current_block->use_advance_lead) {
|
||||||
if (step_events_completed > LA_decelerate_after && current_adv_steps > final_adv_steps) {
|
if (step_events_completed > LA_decelerate_after && current_adv_steps > final_adv_steps) {
|
||||||
|
@ -104,8 +104,12 @@ class Stepper {
|
|||||||
static uint16_t current_adv_steps, final_adv_steps, max_adv_steps; // Copy from current executed block. Needed because current_block is set to NULL "too early".
|
static uint16_t current_adv_steps, final_adv_steps, max_adv_steps; // Copy from current executed block. Needed because current_block is set to NULL "too early".
|
||||||
#define _NEXT_ISR(T) nextMainISR = T
|
#define _NEXT_ISR(T) nextMainISR = T
|
||||||
static int8_t e_steps;
|
static int8_t e_steps;
|
||||||
static int8_t LA_active_extruder; // Copy from current executed block. Needed because current_block is set to NULL "too early".
|
|
||||||
static bool use_advance_lead;
|
static bool use_advance_lead;
|
||||||
|
#if E_STEPPERS > 1
|
||||||
|
static int8_t LA_active_extruder; // Copy from current executed block. Needed because current_block is set to NULL "too early".
|
||||||
|
#else
|
||||||
|
constexpr int8_t LA_active_extruder = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
#else // !LIN_ADVANCE
|
#else // !LIN_ADVANCE
|
||||||
|
|
||||||
@ -352,19 +356,18 @@ class Stepper {
|
|||||||
static int8_t last_extruder = -1;
|
static int8_t last_extruder = -1;
|
||||||
|
|
||||||
#if ENABLED(LIN_ADVANCE)
|
#if ENABLED(LIN_ADVANCE)
|
||||||
|
#if E_STEPPERS > 1
|
||||||
if (current_block->active_extruder != last_extruder) {
|
if (current_block->active_extruder != last_extruder) {
|
||||||
current_adv_steps = 0; // If the now active extruder wasn't in use during the last move, its pressure is most likely gone.
|
current_adv_steps = 0; // If the now active extruder wasn't in use during the last move, its pressure is most likely gone.
|
||||||
LA_active_extruder = current_block->active_extruder;
|
LA_active_extruder = current_block->active_extruder;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (current_block->use_advance_lead) {
|
if ((use_advance_lead = current_block->use_advance_lead)) {
|
||||||
LA_decelerate_after = current_block->decelerate_after;
|
LA_decelerate_after = current_block->decelerate_after;
|
||||||
final_adv_steps = current_block->final_adv_steps;
|
final_adv_steps = current_block->final_adv_steps;
|
||||||
max_adv_steps = current_block->max_adv_steps;
|
max_adv_steps = current_block->max_adv_steps;
|
||||||
use_advance_lead = true;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
use_advance_lead = false;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (current_block->direction_bits != last_direction_bits || current_block->active_extruder != last_extruder) {
|
if (current_block->direction_bits != last_direction_bits || current_block->active_extruder != last_extruder) {
|
||||||
|
Loading…
Reference in New Issue
Block a user