Explorar el Código

Prettify LIN_ADVANCE code with the positive condition

Scott Lahteine hace 8 años
padre
commit
fc2fc828b3
Se han modificado 1 ficheros con 21 adiciones y 15 borrados
  1. 21
    15
      Marlin/planner.cpp

+ 21
- 15
Marlin/planner.cpp Ver fichero

@@ -1293,22 +1293,28 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
1293 1293
 
1294 1294
   #if ENABLED(LIN_ADVANCE)
1295 1295
 
1296
-    // Don't use LIN_ADVANCE for blocks if:
1297
-    // !block->steps[E_AXIS]: We don't have E steps todo (Travel move)
1298
-    // !block->steps[X_AXIS] && !block->steps[Y_AXIS]: We don't have a movement in XY direction (Retract / Prime moves)
1299
-    // extruder_advance_k == 0.0: There is no advance factor set
1300
-    // block->steps[E_AXIS] == block->step_event_count: A problem occurs when there's a very tiny move before a retract.
1301
-    // In this case, the retract and the move will be executed together.
1302
-    // This leads to an enormous number of advance steps due to a huge e_acceleration.
1303
-    // The math is correct, but you don't want a retract move done with advance!
1304
-    // de_float <= 0.0: Extruder is running in reverse direction (for example during "Wipe while retracting" (Slic3r) or "Combing" (Cura) movements)
1305
-    if (!esteps || (!block->steps[X_AXIS] && !block->steps[Y_AXIS]) || extruder_advance_k == 0.0 || (uint32_t)esteps == block->step_event_count || de_float <= 0.0) {
1306
-      block->use_advance_lead = false;
1307
-    }
1308
-    else {
1309
-      block->use_advance_lead = true;
1296
+    //
1297
+    // Use LIN_ADVANCE for blocks if all these are true:
1298
+    //
1299
+    // esteps                                          : We have E steps todo (a printing move)
1300
+    // 
1301
+    // block->steps[X_AXIS] || block->steps[Y_AXIS]    : We have a movement in XY direction (i.e., not retract / prime).
1302
+    // 
1303
+    // extruder_advance_k                              : There is an advance factor set.
1304
+    // 
1305
+    // block->steps[E_AXIS] != block->step_event_count : A problem occurs if the move before a retract is too small.
1306
+    //                                                   In that case, the retract and move will be executed together.
1307
+    //                                                   This leads to too many advance steps due to a huge e_acceleration.
1308
+    //                                                   The math is good, but we must avoid retract moves with advance!
1309
+    // de_float > 0.0                                  : Extruder is running forward (e.g., for "Wipe while retracting" (Slic3r) or "Combing" (Cura) moves)
1310
+    //
1311
+    block->use_advance_lead =  esteps
1312
+                            && (block->steps[X_AXIS] || block->steps[Y_AXIS])
1313
+                            && extruder_advance_k
1314
+                            && (uint32_t)esteps != block->step_event_count
1315
+                            && de_float > 0.0;
1316
+    if (block->use_advance_lead)
1310 1317
       block->abs_adv_steps_multiplier8 = lround(extruder_advance_k * (de_float / mm_D_float) * block->nominal_speed / (float)block->nominal_rate * axis_steps_per_mm[E_AXIS_N] * 256.0);
1311
-    }
1312 1318
 
1313 1319
   #elif ENABLED(ADVANCE)
1314 1320
 

Loading…
Cancelar
Guardar