Browse Source

Merge pull request #4754 from thinkyhead/rc_mixing_regression

Unify counter_m and counter_M
Scott Lahteine 8 years ago
parent
commit
6f71bd7372
2 changed files with 12 additions and 12 deletions
  1. 11
    11
      Marlin/stepper.cpp
  2. 1
    1
      Marlin/stepper.h

+ 11
- 11
Marlin/stepper.cpp View File

115
 volatile signed char Stepper::count_direction[NUM_AXIS] = { 1, 1, 1, 1 };
115
 volatile signed char Stepper::count_direction[NUM_AXIS] = { 1, 1, 1, 1 };
116
 
116
 
117
 #if ENABLED(MIXING_EXTRUDER)
117
 #if ENABLED(MIXING_EXTRUDER)
118
-  long Stepper::counter_M[MIXING_STEPPERS];
118
+  long Stepper::counter_m[MIXING_STEPPERS];
119
 #endif
119
 #endif
120
 
120
 
121
 unsigned short Stepper::acc_step_rate; // needed for deceleration start point
121
 unsigned short Stepper::acc_step_rate; // needed for deceleration start point
340
 
340
 
341
       #if ENABLED(MIXING_EXTRUDER)
341
       #if ENABLED(MIXING_EXTRUDER)
342
         MIXING_STEPPERS_LOOP(i)
342
         MIXING_STEPPERS_LOOP(i)
343
-          counter_M[i] = -(current_block->mix_event_count[i] >> 1);
343
+          counter_m[i] = -(current_block->mix_event_count[i] >> 1);
344
       #endif
344
       #endif
345
 
345
 
346
       step_events_completed = 0;
346
       step_events_completed = 0;
392
 
392
 
393
         #if ENABLED(MIXING_EXTRUDER)
393
         #if ENABLED(MIXING_EXTRUDER)
394
           // Step mixing steppers proportionally
394
           // Step mixing steppers proportionally
395
-          long dir = motor_direction(E_AXIS) ? -1 : 1;
395
+          bool dir = motor_direction(E_AXIS);
396
           MIXING_STEPPERS_LOOP(j) {
396
           MIXING_STEPPERS_LOOP(j) {
397
             counter_m[j] += current_block->steps[E_AXIS];
397
             counter_m[j] += current_block->steps[E_AXIS];
398
             if (counter_m[j] > 0) {
398
             if (counter_m[j] > 0) {
399
               counter_m[j] -= current_block->mix_event_count[j];
399
               counter_m[j] -= current_block->mix_event_count[j];
400
-              e_steps[j] += dir;
400
+              dir ? --e_steps[j] : ++e_steps[j];
401
             }
401
             }
402
           }
402
           }
403
         #endif
403
         #endif
433
         #if ENABLED(MIXING_EXTRUDER)
433
         #if ENABLED(MIXING_EXTRUDER)
434
 
434
 
435
           // Step mixing steppers proportionally
435
           // Step mixing steppers proportionally
436
-          long dir = motor_direction(E_AXIS) ? -1 : 1;
436
+          bool dir = motor_direction(E_AXIS);
437
           MIXING_STEPPERS_LOOP(j) {
437
           MIXING_STEPPERS_LOOP(j) {
438
             counter_m[j] += current_block->steps[E_AXIS];
438
             counter_m[j] += current_block->steps[E_AXIS];
439
             if (counter_m[j] > 0) {
439
             if (counter_m[j] > 0) {
440
               counter_m[j] -= current_block->mix_event_count[j];
440
               counter_m[j] -= current_block->mix_event_count[j];
441
-              e_steps[j] += dir;
441
+              dir ? --e_steps[j] : ++e_steps[j];
442
             }
442
             }
443
           }
443
           }
444
 
444
 
487
           // Tick the counters used for this mix
487
           // Tick the counters used for this mix
488
           MIXING_STEPPERS_LOOP(j) {
488
           MIXING_STEPPERS_LOOP(j) {
489
             // Step mixing steppers (proportionally)
489
             // Step mixing steppers (proportionally)
490
-            counter_M[j] += current_block->steps[E_AXIS];
490
+            counter_m[j] += current_block->steps[E_AXIS];
491
             // Step when the counter goes over zero
491
             // Step when the counter goes over zero
492
-            if (counter_M[j] > 0) En_STEP_WRITE(j, !INVERT_E_STEP_PIN);
492
+            if (counter_m[j] > 0) En_STEP_WRITE(j, !INVERT_E_STEP_PIN);
493
           }
493
           }
494
         #else // !MIXING_EXTRUDER
494
         #else // !MIXING_EXTRUDER
495
           PULSE_START(E);
495
           PULSE_START(E);
520
             count_position[E_AXIS] += count_direction[E_AXIS];
520
             count_position[E_AXIS] += count_direction[E_AXIS];
521
           }
521
           }
522
           MIXING_STEPPERS_LOOP(j) {
522
           MIXING_STEPPERS_LOOP(j) {
523
-            if (counter_M[j] > 0) {
524
-              counter_M[j] -= current_block->mix_event_count[j];
523
+            if (counter_m[j] > 0) {
524
+              counter_m[j] -= current_block->mix_event_count[j];
525
               En_STEP_WRITE(j, INVERT_E_STEP_PIN);
525
               En_STEP_WRITE(j, INVERT_E_STEP_PIN);
526
             }
526
             }
527
           }
527
           }
691
 
691
 
692
     #define STOP_E_PULSE(INDEX) \
692
     #define STOP_E_PULSE(INDEX) \
693
       if (e_steps[INDEX]) { \
693
       if (e_steps[INDEX]) { \
694
-        e_steps[INDEX] < 0 ? ++e_steps[INDEX] : --e_steps[INDEX]; \
694
+        e_steps[INDEX] <= 0 ? ++e_steps[INDEX] : --e_steps[INDEX]; \
695
         E## INDEX ##_STEP_WRITE(!INVERT_E_STEP_PIN); \
695
         E## INDEX ##_STEP_WRITE(!INVERT_E_STEP_PIN); \
696
       }
696
       }
697
 
697
 

+ 1
- 1
Marlin/stepper.h View File

152
     // Mixing extruder mix counters
152
     // Mixing extruder mix counters
153
     //
153
     //
154
     #if ENABLED(MIXING_EXTRUDER)
154
     #if ENABLED(MIXING_EXTRUDER)
155
-      static long counter_M[MIXING_STEPPERS];
155
+      static long counter_m[MIXING_STEPPERS];
156
       #define MIXING_STEPPERS_LOOP(VAR) \
156
       #define MIXING_STEPPERS_LOOP(VAR) \
157
         for (uint8_t VAR = 0; VAR < MIXING_STEPPERS; VAR++) \
157
         for (uint8_t VAR = 0; VAR < MIXING_STEPPERS; VAR++) \
158
           if (current_block->mix_event_count[VAR])
158
           if (current_block->mix_event_count[VAR])

Loading…
Cancel
Save