Browse Source

Minor planner.cpp style changes

Scott Lahteine 7 years ago
parent
commit
a0fc5f7b52
1 changed files with 9 additions and 8 deletions
  1. 9
    8
      Marlin/planner.cpp

+ 9
- 8
Marlin/planner.cpp View File

1071
     if (WITHIN(moves_queued, 2, (BLOCK_BUFFER_SIZE) / 2 - 1)) {
1071
     if (WITHIN(moves_queued, 2, (BLOCK_BUFFER_SIZE) / 2 - 1)) {
1072
       if (segment_time_us < min_segment_time_us) {
1072
       if (segment_time_us < min_segment_time_us) {
1073
         // buffer is draining, add extra time.  The amount of time added increases if the buffer is still emptied more.
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
         #if defined(XY_FREQUENCY_LIMIT) || ENABLED(ULTRA_LCD)
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
         #endif
1078
         #endif
1078
       }
1079
       }
1079
     }
1080
     }
1101
       filwidth_delay_dist += delta_mm[E_AXIS];
1102
       filwidth_delay_dist += delta_mm[E_AXIS];
1102
 
1103
 
1103
       // Only get new measurements on forward E movement
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
         // Loop the delay distance counter (modulus by the mm length)
1107
         // Loop the delay distance counter (modulus by the mm length)
1107
         while (filwidth_delay_dist >= MMD_MM) filwidth_delay_dist -= MMD_MM;
1108
         while (filwidth_delay_dist >= MMD_MM) filwidth_delay_dist -= MMD_MM;
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
     // Estimate a maximum velocity allowed at a joint of two successive segments.
1309
     // Estimate a maximum velocity allowed at a joint of two successive segments.
1309
     // If this maximum velocity allowed is lower than the minimum of the entry / exit safe velocities,
1310
     // If this maximum velocity allowed is lower than the minimum of the entry / exit safe velocities,
1310
     // then the machine is not coasting anymore and the safe entry / exit velocities shall be used.
1311
     // then the machine is not coasting anymore and the safe entry / exit velocities shall be used.
1311
 
1312
 
1312
     // The junction velocity will be shared between successive segments. Limit the junction velocity to their minimum.
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
     float smaller_speed_factor = prev_speed_larger ? (block->nominal_speed / previous_nominal_speed) : (previous_nominal_speed / block->nominal_speed);
1315
     float smaller_speed_factor = prev_speed_larger ? (block->nominal_speed / previous_nominal_speed) : (previous_nominal_speed / block->nominal_speed);
1315
     // Pick the smaller of the nominal speeds. Higher speed shall not be achieved at the junction during coasting.
1316
     // Pick the smaller of the nominal speeds. Higher speed shall not be achieved at the junction during coasting.
1316
     vmax_junction = prev_speed_larger ? block->nominal_speed : previous_nominal_speed;
1317
     vmax_junction = prev_speed_larger ? block->nominal_speed : previous_nominal_speed;
1317
     // Factor to multiply the previous / current nominal velocities to get componentwise limited velocities.
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
     limited = 0;
1320
     limited = 0;
1320
     // Now limit the jerk in all axes.
1321
     // Now limit the jerk in all axes.
1321
     LOOP_XYZE(axis) {
1322
     LOOP_XYZE(axis) {
1330
       // Calculate jerk depending on whether the axis is coasting in the same direction or reversing.
1331
       // Calculate jerk depending on whether the axis is coasting in the same direction or reversing.
1331
       const float jerk = (v_exit > v_entry)
1332
       const float jerk = (v_exit > v_entry)
1332
           ? //                                  coasting             axis reversal
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
           : // v_exit <= v_entry                coasting             axis reversal
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
       if (jerk > max_jerk[axis]) {
1338
       if (jerk > max_jerk[axis]) {
1338
         v_factor *= max_jerk[axis] / jerk;
1339
         v_factor *= max_jerk[axis] / jerk;

Loading…
Cancel
Save