Browse Source

LIN_ADVANCE single stepper optimization

Scott Lahteine 6 years ago
parent
commit
ca0def766e
2 changed files with 19 additions and 11 deletions
  1. 7
    2
      Marlin/src/module/stepper.cpp
  2. 12
    9
      Marlin/src/module/stepper.h

+ 7
- 2
Marlin/src/module/stepper.cpp View File

122
            Stepper::final_adv_steps,
122
            Stepper::final_adv_steps,
123
            Stepper::max_adv_steps;
123
            Stepper::max_adv_steps;
124
 
124
 
125
-  int8_t Stepper::e_steps = 0,
126
-         Stepper::LA_active_extruder; // Copy from current executed block. Needed because current_block is set to NULL "too early".
125
+  int8_t Stepper::e_steps = 0;
126
+
127
+  #if E_STEPPERS > 1
128
+    int8_t Stepper::LA_active_extruder; // Copy from current executed block. Needed because current_block is set to NULL "too early".
129
+  #else
130
+    constexpr int8_t Stepper::LA_active_extruder;
131
+  #endif
127
 
132
 
128
   bool Stepper::use_advance_lead;
133
   bool Stepper::use_advance_lead;
129
 
134
 

+ 12
- 9
Marlin/src/module/stepper.h View File

104
       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".
104
       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".
105
       #define _NEXT_ISR(T) nextMainISR = T
105
       #define _NEXT_ISR(T) nextMainISR = T
106
       static int8_t e_steps;
106
       static int8_t e_steps;
107
-      static int8_t LA_active_extruder; // Copy from current executed block. Needed because current_block is set to NULL "too early".
108
       static bool use_advance_lead;
107
       static bool use_advance_lead;
108
+      #if E_STEPPERS > 1
109
+        static int8_t LA_active_extruder; // Copy from current executed block. Needed because current_block is set to NULL "too early".
110
+      #else
111
+        constexpr int8_t LA_active_extruder = 0;
112
+      #endif
109
 
113
 
110
     #else // !LIN_ADVANCE
114
     #else // !LIN_ADVANCE
111
 
115
 
352
       static int8_t last_extruder = -1;
356
       static int8_t last_extruder = -1;
353
 
357
 
354
       #if ENABLED(LIN_ADVANCE)
358
       #if ENABLED(LIN_ADVANCE)
355
-        if (current_block->active_extruder != last_extruder) {
356
-          current_adv_steps = 0; // If the now active extruder wasn't in use during the last move, its pressure is most likely gone.
357
-          LA_active_extruder = current_block->active_extruder;
358
-        }
359
+        #if E_STEPPERS > 1
360
+          if (current_block->active_extruder != last_extruder) {
361
+            current_adv_steps = 0; // If the now active extruder wasn't in use during the last move, its pressure is most likely gone.
362
+            LA_active_extruder = current_block->active_extruder;
363
+          }
364
+        #endif
359
 
365
 
360
-        if (current_block->use_advance_lead) {
366
+        if ((use_advance_lead = current_block->use_advance_lead)) {
361
           LA_decelerate_after = current_block->decelerate_after;
367
           LA_decelerate_after = current_block->decelerate_after;
362
           final_adv_steps = current_block->final_adv_steps;
368
           final_adv_steps = current_block->final_adv_steps;
363
           max_adv_steps = current_block->max_adv_steps;
369
           max_adv_steps = current_block->max_adv_steps;
364
-          use_advance_lead = true;
365
         }
370
         }
366
-        else
367
-          use_advance_lead = false;
368
       #endif
371
       #endif
369
 
372
 
370
       if (current_block->direction_bits != last_direction_bits || current_block->active_extruder != last_extruder) {
373
       if (current_block->direction_bits != last_direction_bits || current_block->active_extruder != last_extruder) {

Loading…
Cancel
Save