From a1fd50ea9aaab1ae3a5d69446cf94ba6cc6117be Mon Sep 17 00:00:00 2001 From: bubnikv <bubnikv@gmail.com> Date: Sun, 14 Jan 2018 14:45:27 +0100 Subject: [PATCH] Simlified the extruder ticking code. --- Firmware/stepper.cpp | 30 ++++++++---------------------- Firmware/stepper.h | 14 -------------- 2 files changed, 8 insertions(+), 36 deletions(-) diff --git a/Firmware/stepper.cpp b/Firmware/stepper.cpp index 38ece7ea..5cf3d908 100644 --- a/Firmware/stepper.cpp +++ b/Firmware/stepper.cpp @@ -634,34 +634,20 @@ void isr() { if ((out_bits & (1 << E_AXIS)) != 0) { // -direction //AKU + WRITE(E0_DIR_PIN, #ifdef SNMM - if (snmm_extruder == 0 || snmm_extruder == 2) - { - NORM_E_DIR(); - } - else - { - REV_E_DIR(); - } -#else - REV_E_DIR(); + (snmm_extruder == 0 || snmm_extruder == 2) ? !INVERT_E0_DIR : #endif // SNMM + INVERT_E0_DIR); count_direction[E_AXIS] = -1; } else { // +direction + WRITE(E0_DIR_PIN, #ifdef SNMM - if (snmm_extruder == 0 || snmm_extruder == 2) - { - REV_E_DIR(); - } - else - { - NORM_E_DIR(); - } -#else - NORM_E_DIR(); + (snmm_extruder == 0 || snmm_extruder == 2) ? INVERT_E0_DIR : #endif // SNMM + !INVERT_E0_DIR); count_direction[E_AXIS] = 1; } @@ -738,10 +724,10 @@ void isr() { #ifndef LIN_ADVANCE counter_e += current_block->steps_e; if (counter_e > 0) { - WRITE_E_STEP(!INVERT_E_STEP_PIN); + WRITE(E0_STEP_PIN, !INVERT_E_STEP_PIN); counter_e -= current_block->step_event_count; count_position[E_AXIS]+=count_direction[E_AXIS]; - WRITE_E_STEP(INVERT_E_STEP_PIN); + WRITE(E0_STEP_PIN, INVERT_E_STEP_PIN); #ifdef PAT9125 fsensor_counter++; #endif //PAT9125 diff --git a/Firmware/stepper.h b/Firmware/stepper.h index 9915de90..5ca68a39 100644 --- a/Firmware/stepper.h +++ b/Firmware/stepper.h @@ -23,20 +23,6 @@ #include "planner.h" -#if EXTRUDERS > 2 - #define WRITE_E_STEP(v) { if(current_block->active_extruder == 2) { WRITE(E2_STEP_PIN, v); } else { if(current_block->active_extruder == 1) { WRITE(E1_STEP_PIN, v); } else { WRITE(E0_STEP_PIN, v); }}} - #define NORM_E_DIR() { if(current_block->active_extruder == 2) { WRITE(E2_DIR_PIN, !INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); }}} - #define REV_E_DIR() { if(current_block->active_extruder == 2) { WRITE(E2_DIR_PIN, INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, INVERT_E0_DIR); }}} -#elif EXTRUDERS > 1 - #define WRITE_E_STEP(v) { if(current_block->active_extruder == 1) { WRITE(E1_STEP_PIN, v); } else { WRITE(E0_STEP_PIN, v); }} - #define NORM_E_DIR() { if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); }} - #define REV_E_DIR() { if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, INVERT_E0_DIR); }} -#else - #define WRITE_E_STEP(v) WRITE(E0_STEP_PIN, v) - #define NORM_E_DIR() WRITE(E0_DIR_PIN, !INVERT_E0_DIR) - #define REV_E_DIR() WRITE(E0_DIR_PIN, INVERT_E0_DIR) -#endif - #ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED extern bool abort_on_endstop_hit; #endif