浏览代码

Minor planner.cpp style changes

Scott Lahteine 7 年前
父节点
当前提交
a0fc5f7b52
共有 1 个文件被更改,包括 9 次插入8 次删除
  1. 9
    8
      Marlin/planner.cpp

+ 9
- 8
Marlin/planner.cpp 查看文件

@@ -1071,9 +1071,10 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
1071 1071
     if (WITHIN(moves_queued, 2, (BLOCK_BUFFER_SIZE) / 2 - 1)) {
1072 1072
       if (segment_time_us < min_segment_time_us) {
1073 1073
         // buffer is draining, add extra time.  The amount of time added increases if the buffer is still emptied more.
1074
-        inverse_mm_s = 1000000.0 / (segment_time_us + LROUND(2 * (min_segment_time_us - segment_time_us) / moves_queued));
1074
+        const uint32_t nst = segment_time_us + LROUND(2 * (min_segment_time_us - segment_time_us) / moves_queued);
1075
+        inverse_mm_s = 1000000.0 / nst;
1075 1076
         #if defined(XY_FREQUENCY_LIMIT) || ENABLED(ULTRA_LCD)
1076
-          segment_time_us = LROUND(1000000.0 / inverse_mm_s);
1077
+          segment_time_us = nst;
1077 1078
         #endif
1078 1079
       }
1079 1080
     }
@@ -1101,7 +1102,7 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
1101 1102
       filwidth_delay_dist += delta_mm[E_AXIS];
1102 1103
 
1103 1104
       // Only get new measurements on forward E movement
1104
-      if (filwidth_e_count > 0.0001) {
1105
+      if (!UNEAR_ZERO(filwidth_e_count)) {
1105 1106
 
1106 1107
         // Loop the delay distance counter (modulus by the mm length)
1107 1108
         while (filwidth_delay_dist >= MMD_MM) filwidth_delay_dist -= MMD_MM;
@@ -1304,18 +1305,18 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
1304 1305
     }
1305 1306
   }
1306 1307
 
1307
-  if (moves_queued > 1 && previous_nominal_speed > 0.0001) {
1308
+  if (moves_queued > 1 && !UNEAR_ZERO(previous_nominal_speed)) {
1308 1309
     // Estimate a maximum velocity allowed at a joint of two successive segments.
1309 1310
     // If this maximum velocity allowed is lower than the minimum of the entry / exit safe velocities,
1310 1311
     // then the machine is not coasting anymore and the safe entry / exit velocities shall be used.
1311 1312
 
1312 1313
     // The junction velocity will be shared between successive segments. Limit the junction velocity to their minimum.
1313
-    bool prev_speed_larger = previous_nominal_speed > block->nominal_speed;
1314
+    const bool prev_speed_larger = previous_nominal_speed > block->nominal_speed;
1314 1315
     float smaller_speed_factor = prev_speed_larger ? (block->nominal_speed / previous_nominal_speed) : (previous_nominal_speed / block->nominal_speed);
1315 1316
     // Pick the smaller of the nominal speeds. Higher speed shall not be achieved at the junction during coasting.
1316 1317
     vmax_junction = prev_speed_larger ? block->nominal_speed : previous_nominal_speed;
1317 1318
     // Factor to multiply the previous / current nominal velocities to get componentwise limited velocities.
1318
-    float v_factor = 1.f;
1319
+    float v_factor = 1;
1319 1320
     limited = 0;
1320 1321
     // Now limit the jerk in all axes.
1321 1322
     LOOP_XYZE(axis) {
@@ -1330,9 +1331,9 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
1330 1331
       // Calculate jerk depending on whether the axis is coasting in the same direction or reversing.
1331 1332
       const float jerk = (v_exit > v_entry)
1332 1333
           ? //                                  coasting             axis reversal
1333
-            ( (v_entry > 0.f || v_exit < 0.f) ? (v_exit - v_entry) : max(v_exit, -v_entry) )
1334
+            ( (v_entry > 0 || v_exit < 0) ? (v_exit - v_entry) : max(v_exit, -v_entry) )
1334 1335
           : // v_exit <= v_entry                coasting             axis reversal
1335
-            ( (v_entry < 0.f || v_exit > 0.f) ? (v_entry - v_exit) : max(-v_exit, v_entry) );
1336
+            ( (v_entry < 0 || v_exit > 0) ? (v_entry - v_exit) : max(-v_exit, v_entry) );
1336 1337
 
1337 1338
       if (jerk > max_jerk[axis]) {
1338 1339
         v_factor *= max_jerk[axis] / jerk;

正在加载...
取消
保存