ソースを参照

Followup to stepper/planner refactor

Scott Lahteine 6年前
コミット
435ecb6b67

+ 3
- 3
Marlin/src/module/planner.cpp ファイルの表示

962
 }
962
 }
963
 
963
 
964
 // The kernel called by recalculate() when scanning the plan from first to last entry.
964
 // The kernel called by recalculate() when scanning the plan from first to last entry.
965
-void Planner::forward_pass_kernel(const block_t * const previous, block_t* const current, uint8_t block_index) {
965
+void Planner::forward_pass_kernel(const block_t* const previous, block_t* const current, const uint8_t block_index) {
966
   if (previous) {
966
   if (previous) {
967
     // If the previous block is an acceleration block, too short to complete the full speed
967
     // If the previous block is an acceleration block, too short to complete the full speed
968
     // change, adjust the entry speed accordingly. Entry speeds have already been reset,
968
     // change, adjust the entry speed accordingly. Entry speeds have already been reset,
1586
  * Returns true is movement is acceptable, false otherwise
1586
  * Returns true is movement is acceptable, false otherwise
1587
  */
1587
  */
1588
 bool Planner::_populate_block(block_t * const block, bool split_move,
1588
 bool Planner::_populate_block(block_t * const block, bool split_move,
1589
-    const int32_t (&target)[XYZE]
1589
+  const int32_t (&target)[XYZE]
1590
   #if HAS_POSITION_FLOAT
1590
   #if HAS_POSITION_FLOAT
1591
     , const float (&target_float)[XYZE]
1591
     , const float (&target_float)[XYZE]
1592
   #endif
1592
   #endif
2234
         if (block->millimeters < 1.0) {
2234
         if (block->millimeters < 1.0) {
2235
 
2235
 
2236
           // Fast acos approximation, minus the error bar to be safe
2236
           // Fast acos approximation, minus the error bar to be safe
2237
-          float junction_theta = (RADIANS(-40) * sq(junction_cos_theta) - RADIANS(50)) * junction_cos_theta + RADIANS(90) - 0.18;
2237
+          const float junction_theta = (RADIANS(-40) * sq(junction_cos_theta) - RADIANS(50)) * junction_cos_theta + RADIANS(90) - 0.18;
2238
 
2238
 
2239
           // If angle is greater than 135 degrees (octagon), find speed for approximate arc
2239
           // If angle is greater than 135 degrees (octagon), find speed for approximate arc
2240
           if (junction_theta > RADIANS(135)) {
2240
           if (junction_theta > RADIANS(135)) {

+ 1
- 1
Marlin/src/module/planner.h ファイルの表示

452
      * - Wait for the number of spaces to open up in the planner
452
      * - Wait for the number of spaces to open up in the planner
453
      * - Return the first head block
453
      * - Return the first head block
454
      */
454
      */
455
-    FORCE_INLINE static block_t* get_next_free_block(uint8_t &next_buffer_head, uint8_t count = 1) {
455
+    FORCE_INLINE static block_t* get_next_free_block(uint8_t &next_buffer_head, const uint8_t count=1) {
456
 
456
 
457
       // Wait until there are enough slots free
457
       // Wait until there are enough slots free
458
       while (moves_free() < count) { idle(); }
458
       while (moves_free() < count) { idle(); }

+ 11
- 11
Marlin/src/module/stepper.cpp ファイルの表示

181
   #define LOCKED_X2_MOTOR locked_x2_motor
181
   #define LOCKED_X2_MOTOR locked_x2_motor
182
   #define LOCKED_Y2_MOTOR locked_y2_motor
182
   #define LOCKED_Y2_MOTOR locked_y2_motor
183
   #define LOCKED_Z2_MOTOR locked_z2_motor
183
   #define LOCKED_Z2_MOTOR locked_z2_motor
184
-  #define DUAL_ENDSTOP_APPLY_STEP(A,V)                                                                                                           \
185
-    if (performing_homing) {                                                                                                                        \
186
-      if (A##_HOME_DIR < 0) {                                                                                                                    \
184
+  #define DUAL_ENDSTOP_APPLY_STEP(A,V)                                                                                                      \
185
+    if (performing_homing) {                                                                                                                \
186
+      if (A##_HOME_DIR < 0) {                                                                                                               \
187
         if (!(TEST(endstops.current_endstop_bits, A##_MIN) && count_direction[_AXIS(A)] < 0) && !LOCKED_##A##_MOTOR) A##_STEP_WRITE(V);     \
187
         if (!(TEST(endstops.current_endstop_bits, A##_MIN) && count_direction[_AXIS(A)] < 0) && !LOCKED_##A##_MOTOR) A##_STEP_WRITE(V);     \
188
         if (!(TEST(endstops.current_endstop_bits, A##2_MIN) && count_direction[_AXIS(A)] < 0) && !LOCKED_##A##2_MOTOR) A##2_STEP_WRITE(V);  \
188
         if (!(TEST(endstops.current_endstop_bits, A##2_MIN) && count_direction[_AXIS(A)] < 0) && !LOCKED_##A##2_MOTOR) A##2_STEP_WRITE(V);  \
189
-      }                                                                                                                                             \
190
-      else {                                                                                                                                        \
189
+      }                                                                                                                                     \
190
+      else {                                                                                                                                \
191
         if (!(TEST(endstops.current_endstop_bits, A##_MAX) && count_direction[_AXIS(A)] > 0) && !LOCKED_##A##_MOTOR) A##_STEP_WRITE(V);     \
191
         if (!(TEST(endstops.current_endstop_bits, A##_MAX) && count_direction[_AXIS(A)] > 0) && !LOCKED_##A##_MOTOR) A##_STEP_WRITE(V);     \
192
         if (!(TEST(endstops.current_endstop_bits, A##2_MAX) && count_direction[_AXIS(A)] > 0) && !LOCKED_##A##2_MOTOR) A##2_STEP_WRITE(V);  \
192
         if (!(TEST(endstops.current_endstop_bits, A##2_MAX) && count_direction[_AXIS(A)] > 0) && !LOCKED_##A##2_MOTOR) A##2_STEP_WRITE(V);  \
193
-      }                                                                                                                                             \
194
-    }                                                                                                                                               \
195
-    else {                                                                                                                                          \
196
-      A##_STEP_WRITE(V);                                                                                                                         \
197
-      A##2_STEP_WRITE(V);                                                                                                                        \
193
+      }                                                                                                                                     \
194
+    }                                                                                                                                       \
195
+    else {                                                                                                                                  \
196
+      A##_STEP_WRITE(V);                                                                                                                    \
197
+      A##2_STEP_WRITE(V);                                                                                                                   \
198
     }
198
     }
199
 #endif
199
 #endif
200
 
200
 
2035
     if (was_enabled) DISABLE_STEPPER_DRIVER_INTERRUPT();
2035
     if (was_enabled) DISABLE_STEPPER_DRIVER_INTERRUPT();
2036
   #endif
2036
   #endif
2037
 
2037
 
2038
-  int32_t v = count_position[axis];
2038
+  const int32_t v = count_position[axis];
2039
 
2039
 
2040
   #ifdef __AVR__
2040
   #ifdef __AVR__
2041
     // Reenable Stepper ISR
2041
     // Reenable Stepper ISR

+ 5
- 5
Marlin/src/module/stepper.h ファイルの表示

98
       static int32_t bezier_A,     // A coefficient in Bézier speed curve
98
       static int32_t bezier_A,     // A coefficient in Bézier speed curve
99
                      bezier_B,     // B coefficient in Bézier speed curve
99
                      bezier_B,     // B coefficient in Bézier speed curve
100
                      bezier_C;     // C coefficient in Bézier speed curve
100
                      bezier_C;     // C coefficient in Bézier speed curve
101
-      static uint32_t bezier_F;    // F coefficient in Bézier speed curve
102
-      static uint32_t bezier_AV;   // AV coefficient in Bézier speed curve
101
+      static uint32_t bezier_F,    // F coefficient in Bézier speed curve
102
+                      bezier_AV;   // AV coefficient in Bézier speed curve
103
       #ifdef __AVR__
103
       #ifdef __AVR__
104
         static bool A_negative;    // If A coefficient was negative
104
         static bool A_negative;    // If A coefficient was negative
105
       #endif
105
       #endif
297
         NOLESS(step_rate, uint32_t(F_CPU / 500000U));
297
         NOLESS(step_rate, uint32_t(F_CPU / 500000U));
298
         step_rate -= F_CPU / 500000; // Correct for minimal speed
298
         step_rate -= F_CPU / 500000; // Correct for minimal speed
299
         if (step_rate >= (8 * 256)) { // higher step rate
299
         if (step_rate >= (8 * 256)) { // higher step rate
300
-          uint8_t tmp_step_rate = (step_rate & 0x00FF);
301
-          uint16_t table_address = (uint16_t)&speed_lookuptable_fast[(uint8_t)(step_rate >> 8)][0],
302
-                   gain = (uint16_t)pgm_read_word_near(table_address + 2);
300
+          const uint8_t tmp_step_rate = (step_rate & 0x00FF);
301
+          const uint16_t table_address = (uint16_t)&speed_lookuptable_fast[(uint8_t)(step_rate >> 8)][0],
302
+                         gain = (uint16_t)pgm_read_word_near(table_address + 2);
303
           timer = MultiU16X8toH16(tmp_step_rate, gain);
303
           timer = MultiU16X8toH16(tmp_step_rate, gain);
304
           timer = (uint16_t)pgm_read_word_near(table_address) - timer;
304
           timer = (uint16_t)pgm_read_word_near(table_address) - timer;
305
         }
305
         }

読み込み中…
キャンセル
保存