Browse Source

Cleanup position_float

Hopefully fixes Marlin #5481
Sebastianv650 8 years ago
parent
commit
1b59766fcb
1 changed files with 32 additions and 4 deletions
  1. 32
    4
      Marlin/planner.cpp

+ 32
- 4
Marlin/planner.cpp View File

673
 
673
 
674
   #if ENABLED(LIN_ADVANCE)
674
   #if ENABLED(LIN_ADVANCE)
675
     const float target_float[XYZE] = { a, b, c, e },
675
     const float target_float[XYZE] = { a, b, c, e },
676
-                de_float = target_float[E_AXIS] - position_float[E_AXIS],
677
                 mm_D_float = sqrt(sq(target_float[X_AXIS] - position_float[X_AXIS]) + sq(target_float[Y_AXIS] - position_float[Y_AXIS]));
676
                 mm_D_float = sqrt(sq(target_float[X_AXIS] - position_float[X_AXIS]) + sq(target_float[Y_AXIS] - position_float[Y_AXIS]));
678
-
679
-    memcpy(position_float, target_float, sizeof(position_float));
680
   #endif
677
   #endif
681
 
678
 
682
   const long da = target[X_AXIS] - position[X_AXIS],
679
   const long da = target[X_AXIS] - position[X_AXIS],
707
   //*/
704
   //*/
708
 
705
 
709
   // DRYRUN ignores all temperature constraints and assures that the extruder is instantly satisfied
706
   // DRYRUN ignores all temperature constraints and assures that the extruder is instantly satisfied
710
-  if (DEBUGGING(DRYRUN)) position[E_AXIS] = target[E_AXIS];
707
+  if (DEBUGGING(DRYRUN)) {
708
+    position[E_AXIS] = target[E_AXIS];
709
+    #if ENABLED(LIN_ADVANCE)
710
+      position_float[E_AXIS] = target_float[E_AXIS];
711
+    #endif
712
+  }
711
 
713
 
712
   long de = target[E_AXIS] - position[E_AXIS];
714
   long de = target[E_AXIS] - position[E_AXIS];
715
+  #if ENABLED(LIN_ADVANCE)
716
+    float de_float = target_float[E_AXIS] - position_float[E_AXIS];
717
+  #endif
713
 
718
 
714
   #if ENABLED(PREVENT_COLD_EXTRUSION)
719
   #if ENABLED(PREVENT_COLD_EXTRUSION)
715
     if (de) {
720
     if (de) {
716
       if (thermalManager.tooColdToExtrude(extruder)) {
721
       if (thermalManager.tooColdToExtrude(extruder)) {
717
         position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
722
         position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
718
         de = 0; // no difference
723
         de = 0; // no difference
724
+        #if ENABLED(LIN_ADVANCE)
725
+          position_float[E_AXIS] = target_float[E_AXIS];
726
+          de_float = 0;
727
+        #endif
719
         SERIAL_ECHO_START;
728
         SERIAL_ECHO_START;
720
         SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP);
729
         SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP);
721
       }
730
       }
723
         if (labs(de) > (int32_t)axis_steps_per_mm[E_AXIS_N] * (EXTRUDE_MAXLENGTH)) { // It's not important to get max. extrusion length in a precision < 1mm, so save some cycles and cast to int
732
         if (labs(de) > (int32_t)axis_steps_per_mm[E_AXIS_N] * (EXTRUDE_MAXLENGTH)) { // It's not important to get max. extrusion length in a precision < 1mm, so save some cycles and cast to int
724
           position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
733
           position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
725
           de = 0; // no difference
734
           de = 0; // no difference
735
+          #if ENABLED(LIN_ADVANCE)
736
+            position_float[E_AXIS] = target_float[E_AXIS];
737
+            de_float = 0;
738
+          #endif
726
           SERIAL_ECHO_START;
739
           SERIAL_ECHO_START;
727
           SERIAL_ECHOLNPGM(MSG_ERR_LONG_EXTRUDE_STOP);
740
           SERIAL_ECHOLNPGM(MSG_ERR_LONG_EXTRUDE_STOP);
728
         }
741
         }
1342
 
1355
 
1343
   // Update the position (only when a move was queued)
1356
   // Update the position (only when a move was queued)
1344
   memcpy(position, target, sizeof(position));
1357
   memcpy(position, target, sizeof(position));
1358
+  #if ENABLED(LIN_ADVANCE)
1359
+    memcpy(position_float, target_float, sizeof(position_float));
1360
+  #endif
1345
 
1361
 
1346
   recalculate();
1362
   recalculate();
1347
 
1363
 
1367
        nb = position[Y_AXIS] = lround(b * axis_steps_per_mm[Y_AXIS]),
1383
        nb = position[Y_AXIS] = lround(b * axis_steps_per_mm[Y_AXIS]),
1368
        nc = position[Z_AXIS] = lround(c * axis_steps_per_mm[Z_AXIS]),
1384
        nc = position[Z_AXIS] = lround(c * axis_steps_per_mm[Z_AXIS]),
1369
        ne = position[E_AXIS] = lround(e * axis_steps_per_mm[_EINDEX]);
1385
        ne = position[E_AXIS] = lround(e * axis_steps_per_mm[_EINDEX]);
1386
+  #if ENABLED(LIN_ADVANCE)
1387
+    position_float[X_AXIS] = a;
1388
+    position_float[Y_AXIS] = b;
1389
+    position_float[Z_AXIS] = c;
1390
+    position_float[E_AXIS] = e;
1391
+  #endif
1370
   stepper.set_position(na, nb, nc, ne);
1392
   stepper.set_position(na, nb, nc, ne);
1371
   previous_nominal_speed = 0.0; // Resets planner junction speeds. Assumes start from rest.
1393
   previous_nominal_speed = 0.0; // Resets planner junction speeds. Assumes start from rest.
1372
   ZERO(previous_speed);
1394
   ZERO(previous_speed);
1392
  */
1414
  */
1393
 void Planner::sync_from_steppers() {
1415
 void Planner::sync_from_steppers() {
1394
   LOOP_XYZE(i) position[i] = stepper.position((AxisEnum)i);
1416
   LOOP_XYZE(i) position[i] = stepper.position((AxisEnum)i);
1417
+  #if ENABLED(LIN_ADVANCE)
1418
+    LOOP_XYZE(i) position_float[i] = stepper.position((AxisEnum)i) * steps_to_mm[i];
1419
+  #endif
1395
 }
1420
 }
1396
 
1421
 
1397
 /**
1422
 /**
1405
     const uint8_t axis_index = axis;
1430
     const uint8_t axis_index = axis;
1406
   #endif
1431
   #endif
1407
   position[axis] = lround(v * axis_steps_per_mm[axis_index]);
1432
   position[axis] = lround(v * axis_steps_per_mm[axis_index]);
1433
+  #if ENABLED(LIN_ADVANCE)
1434
+    position_float[axis] = v;
1435
+  #endif
1408
   stepper.set_position(axis, v);
1436
   stepper.set_position(axis, v);
1409
   previous_speed[axis] = 0.0;
1437
   previous_speed[axis] = 0.0;
1410
 }
1438
 }

Loading…
Cancel
Save