Bladeren bron

Define ADV_NEVER, ADV_RATE

Scott Lahteine 8 jaren geleden
bovenliggende
commit
92dbeebf40
1 gewijzigde bestanden met toevoegingen van 11 en 6 verwijderingen
  1. 11
    6
      Marlin/stepper.cpp

+ 11
- 6
Marlin/stepper.cpp Bestand weergeven

91
 
91
 
92
 #if ENABLED(ADVANCE) || ENABLED(LIN_ADVANCE)
92
 #if ENABLED(ADVANCE) || ENABLED(LIN_ADVANCE)
93
 
93
 
94
+  constexpr uint16_t ADV_NEVER = 65535;
95
+
94
   uint16_t Stepper::nextMainISR = 0,
96
   uint16_t Stepper::nextMainISR = 0,
95
-           Stepper::nextAdvanceISR = 65535,
96
-           Stepper::eISR_Rate = 65535;
97
+           Stepper::nextAdvanceISR = ADV_NEVER,
98
+           Stepper::eISR_Rate = ADV_NEVER;
97
 
99
 
98
   #if ENABLED(LIN_ADVANCE)
100
   #if ENABLED(LIN_ADVANCE)
99
     volatile int Stepper::e_steps[E_STEPPERS];
101
     volatile int Stepper::e_steps[E_STEPPERS];
107
          Stepper::advance_rate,
109
          Stepper::advance_rate,
108
          Stepper::advance;
110
          Stepper::advance;
109
   #endif
111
   #endif
112
+
113
+  #define ADV_RATE(T, L) (e_steps[TOOL_E_INDEX] ? (T) * (L) / abs(e_steps[TOOL_E_INDEX]) : ADV_NEVER)
114
+
110
 #endif
115
 #endif
111
 
116
 
112
 long Stepper::acceleration_time, Stepper::deceleration_time;
117
 long Stepper::acceleration_time, Stepper::deceleration_time;
632
     #endif // ADVANCE or LIN_ADVANCE
637
     #endif // ADVANCE or LIN_ADVANCE
633
 
638
 
634
     #if ENABLED(ADVANCE) || ENABLED(LIN_ADVANCE)
639
     #if ENABLED(ADVANCE) || ENABLED(LIN_ADVANCE)
635
-      eISR_Rate = !e_steps[TOOL_E_INDEX] ? 65535 : timer * step_loops / abs(e_steps[TOOL_E_INDEX]);
640
+      eISR_Rate = ADV_RATE(timer, step_loops);
636
     #endif
641
     #endif
637
   }
642
   }
638
   else if (step_events_completed > (uint32_t)current_block->decelerate_after) {
643
   else if (step_events_completed > (uint32_t)current_block->decelerate_after) {
683
     #endif // ADVANCE or LIN_ADVANCE
688
     #endif // ADVANCE or LIN_ADVANCE
684
 
689
 
685
     #if ENABLED(ADVANCE) || ENABLED(LIN_ADVANCE)
690
     #if ENABLED(ADVANCE) || ENABLED(LIN_ADVANCE)
686
-      eISR_Rate = !e_steps[TOOL_E_INDEX] ? 65535 : timer * step_loops / abs(e_steps[TOOL_E_INDEX]);
691
+      eISR_Rate = ADV_RATE(timer, step_loops);
687
     #endif
692
     #endif
688
   }
693
   }
689
   else {
694
   else {
693
       if (current_block->use_advance_lead)
698
       if (current_block->use_advance_lead)
694
         current_estep_rate[TOOL_E_INDEX] = final_estep_rate;
699
         current_estep_rate[TOOL_E_INDEX] = final_estep_rate;
695
 
700
 
696
-      eISR_Rate = !e_steps[TOOL_E_INDEX] ? 65535 : OCR1A_nominal * step_loops_nominal / abs(e_steps[TOOL_E_INDEX]);
701
+      eISR_Rate = ADV_RATE(OCR1A_nominal, step_loops_nominal);
697
 
702
 
698
     #endif
703
     #endif
699
 
704
 
812
       // The next main ISR comes first
817
       // The next main ISR comes first
813
       OCR1A = nextMainISR;
818
       OCR1A = nextMainISR;
814
       // New interval for the next advance ISR, if any
819
       // New interval for the next advance ISR, if any
815
-      if (nextAdvanceISR && nextAdvanceISR != 65535)
820
+      if (nextAdvanceISR && nextAdvanceISR != ADV_NEVER)
816
         nextAdvanceISR -= nextMainISR;
821
         nextAdvanceISR -= nextMainISR;
817
       // Will call Stepper::isr on the next interrupt
822
       // Will call Stepper::isr on the next interrupt
818
       nextMainISR = 0;
823
       nextMainISR = 0;

Laden…
Annuleren
Opslaan