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
           // so compensation will give the right stepper counts.
2469
           // so compensation will give the right stepper counts.
2470
           planner.unapply_leveling(current_position);
2470
           planner.unapply_leveling(current_position);
2471
 
2471
 
2472
+        SYNC_PLAN_POSITION_KINEMATIC();
2473
+
2472
       #endif // ABL
2474
       #endif // ABL
2473
     }
2475
     }
2474
   }
2476
   }
2488
       planner.set_z_fade_height(zfh);
2490
       planner.set_z_fade_height(zfh);
2489
 
2491
 
2490
       if (level_active) {
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
         #if ENABLED(AUTO_BED_LEVELING_UBL)
2497
         #if ENABLED(AUTO_BED_LEVELING_UBL)
2492
           set_bed_leveling_enabled(true);  // turn back on after changing fade height
2498
           set_bed_leveling_enabled(true);  // turn back on after changing fade height
2493
         #else
2499
         #else
2498
               Z_AXIS
2504
               Z_AXIS
2499
             #endif
2505
             #endif
2500
           );
2506
           );
2507
+          SYNC_PLAN_POSITION_KINEMATIC();
2501
         #endif
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
               bed_level_virt_interpolate();
4636
               bed_level_virt_interpolate();
4629
             #endif
4637
             #endif
4630
             set_bed_leveling_enabled(abl_should_enable);
4638
             set_bed_leveling_enabled(abl_should_enable);
4639
+            report_current_position();
4631
           }
4640
           }
4632
           return;
4641
           return;
4633
         } // parser.seen('W')
4642
         } // parser.seen('W')
9671
       set_bed_leveling_enabled(to_enable);
9680
       set_bed_leveling_enabled(to_enable);
9672
 
9681
 
9673
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
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
     #endif
9684
     #endif
9676
 
9685
 
9677
     const bool new_status = planner.leveling_active;
9686
     const bool new_status = planner.leveling_active;
12394
  * Set the current_position for an axis based on
12403
  * Set the current_position for an axis based on
12395
  * the stepper positions, removing any leveling that
12404
  * the stepper positions, removing any leveling that
12396
  * may have been applied.
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
 void set_current_from_steppers_for_axis(const AxisEnum axis) {
12413
 void set_current_from_steppers_for_axis(const AxisEnum axis) {
12399
   get_cartesian_from_steppers();
12414
   get_cartesian_from_steppers();

+ 3
- 1
Marlin/ubl.cpp View File

67
   volatile int unified_bed_leveling::encoder_diff;
67
   volatile int unified_bed_leveling::encoder_diff;
68
 
68
 
69
   unified_bed_leveling::unified_bed_leveling() {
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
     reset();
71
     reset();
72
   }
72
   }
73
 
73
 
74
   void unified_bed_leveling::reset() {
74
   void unified_bed_leveling::reset() {
75
+    const bool was_enabled = planner.leveling_active;
75
     set_bed_leveling_enabled(false);
76
     set_bed_leveling_enabled(false);
76
     storage_slot = -1;
77
     storage_slot = -1;
77
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
78
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
78
       planner.set_z_fade_height(10.0);
79
       planner.set_z_fade_height(10.0);
79
     #endif
80
     #endif
80
     ZERO(z_values);
81
     ZERO(z_values);
82
+    if (was_enabled) report_current_position();
81
   }
83
   }
82
 
84
 
83
   void unified_bed_leveling::invalidate() {
85
   void unified_bed_leveling::invalidate() {

Loading…
Cancel
Save