Ver código fonte

LIN_ADVANCE single stepper optimization

Scott Lahteine 6 anos atrás
pai
commit
ca0def766e
2 arquivos alterados com 19 adições e 11 exclusões
  1. 7
    2
      Marlin/src/module/stepper.cpp
  2. 12
    9
      Marlin/src/module/stepper.h

+ 7
- 2
Marlin/src/module/stepper.cpp Ver arquivo

@@ -122,8 +122,13 @@ volatile uint32_t Stepper::step_events_completed = 0; // The number of step even
122 122
            Stepper::final_adv_steps,
123 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 133
   bool Stepper::use_advance_lead;
129 134
 

+ 12
- 9
Marlin/src/module/stepper.h Ver arquivo

@@ -104,8 +104,12 @@ class Stepper {
104 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 105
       #define _NEXT_ISR(T) nextMainISR = T
106 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 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 114
     #else // !LIN_ADVANCE
111 115
 
@@ -352,19 +356,18 @@ class Stepper {
352 356
       static int8_t last_extruder = -1;
353 357
 
354 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 367
           LA_decelerate_after = current_block->decelerate_after;
362 368
           final_adv_steps = current_block->final_adv_steps;
363 369
           max_adv_steps = current_block->max_adv_steps;
364
-          use_advance_lead = true;
365 370
         }
366
-        else
367
-          use_advance_lead = false;
368 371
       #endif
369 372
 
370 373
       if (current_block->direction_bits != last_direction_bits || current_block->active_extruder != last_extruder) {

Carregando…
Cancelar
Salvar