Browse Source

Sync and report changed position

Scott Lahteine 7 years ago
parent
commit
684692091e
2 changed files with 20 additions and 3 deletions
  1. 17
    2
      Marlin/Marlin_main.cpp
  2. 3
    1
      Marlin/ubl.cpp

+ 17
- 2
Marlin/Marlin_main.cpp View File

@@ -2469,6 +2469,8 @@ static void clean_up_after_endstop_or_probe_move() {
2469 2469
           // so compensation will give the right stepper counts.
2470 2470
           planner.unapply_leveling(current_position);
2471 2471
 
2472
+        SYNC_PLAN_POSITION_KINEMATIC();
2473
+
2472 2474
       #endif // ABL
2473 2475
     }
2474 2476
   }
@@ -2488,6 +2490,10 @@ static void clean_up_after_endstop_or_probe_move() {
2488 2490
       planner.set_z_fade_height(zfh);
2489 2491
 
2490 2492
       if (level_active) {
2493
+        const float oldpos[XYZE] = {
2494
+          current_position[X_AXIS], current_position[Y_AXIS],
2495
+          current_position[Z_AXIS], current_position[E_AXIS]
2496
+        };
2491 2497
         #if ENABLED(AUTO_BED_LEVELING_UBL)
2492 2498
           set_bed_leveling_enabled(true);  // turn back on after changing fade height
2493 2499
         #else
@@ -2498,8 +2504,10 @@ static void clean_up_after_endstop_or_probe_move() {
2498 2504
               Z_AXIS
2499 2505
             #endif
2500 2506
           );
2507
+          SYNC_PLAN_POSITION_KINEMATIC();
2501 2508
         #endif
2502
-        if (do_report) report_current_position();
2509
+        if (do_report && memcmp(oldpos, current_position, sizeof(oldpos)))
2510
+          report_current_position();
2503 2511
       }
2504 2512
     }
2505 2513
 
@@ -4628,6 +4636,7 @@ void home_all_axes() { gcode_G28(true); }
4628 4636
               bed_level_virt_interpolate();
4629 4637
             #endif
4630 4638
             set_bed_leveling_enabled(abl_should_enable);
4639
+            report_current_position();
4631 4640
           }
4632 4641
           return;
4633 4642
         } // parser.seen('W')
@@ -9671,7 +9680,7 @@ void quickstop_stepper() {
9671 9680
       set_bed_leveling_enabled(to_enable);
9672 9681
 
9673 9682
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
9674
-      if (parser.seen('Z')) set_z_fade_height(parser.value_linear_units());
9683
+      if (parser.seen('Z')) set_z_fade_height(parser.value_linear_units(), false);
9675 9684
     #endif
9676 9685
 
9677 9686
     const bool new_status = planner.leveling_active;
@@ -12394,6 +12403,12 @@ void get_cartesian_from_steppers() {
12394 12403
  * Set the current_position for an axis based on
12395 12404
  * the stepper positions, removing any leveling that
12396 12405
  * may have been applied.
12406
+ *
12407
+ * To prevent small shifts in axis position always call
12408
+ * SYNC_PLAN_POSITION_KINEMATIC after updating axes with this.
12409
+ *
12410
+ * To keep hosts in sync, always call report_current_position
12411
+ * after updating the current_position.
12397 12412
  */
12398 12413
 void set_current_from_steppers_for_axis(const AxisEnum axis) {
12399 12414
   get_cartesian_from_steppers();

+ 3
- 1
Marlin/ubl.cpp View File

@@ -67,17 +67,19 @@
67 67
   volatile int unified_bed_leveling::encoder_diff;
68 68
 
69 69
   unified_bed_leveling::unified_bed_leveling() {
70
-    ubl_cnt++;  // Debug counter to insure we only have one UBL object present in memory.  We can eliminate this (and all references to ubl_cnt) very soon.
70
+    ubl_cnt++;  // Debug counter to ensure we only have one UBL object present in memory.  We can eliminate this (and all references to ubl_cnt) very soon.
71 71
     reset();
72 72
   }
73 73
 
74 74
   void unified_bed_leveling::reset() {
75
+    const bool was_enabled = planner.leveling_active;
75 76
     set_bed_leveling_enabled(false);
76 77
     storage_slot = -1;
77 78
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
78 79
       planner.set_z_fade_height(10.0);
79 80
     #endif
80 81
     ZERO(z_values);
82
+    if (was_enabled) report_current_position();
81 83
   }
82 84
 
83 85
   void unified_bed_leveling::invalidate() {

Loading…
Cancel
Save