Bläddra i källkod

Sync and report changed position

Scott Lahteine 7 år sedan
förälder
incheckning
03ba79f144

+ 12
- 1
Marlin/src/feature/bedlevel/bedlevel.cpp Visa fil

@@ -128,13 +128,17 @@ void set_bed_leveling_enabled(const bool enable/*=true*/) {
128 128
         // so compensation will give the right stepper counts.
129 129
         planner.unapply_leveling(current_position);
130 130
 
131
+      SYNC_PLAN_POSITION_KINEMATIC();
132
+
131 133
     #endif // OLDSCHOOL_ABL
132 134
   }
133 135
 }
134 136
 
135 137
 #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
136 138
 
137
-  void set_z_fade_height(const float zfh) {
139
+  void set_z_fade_height(const float zfh, const bool do_report/*=true*/) {
140
+
141
+    if (planner.z_fade_height == zfh) return; // do nothing if no change
138 142
 
139 143
     const bool level_active = planner.leveling_active;
140 144
 
@@ -145,6 +149,10 @@ void set_bed_leveling_enabled(const bool enable/*=true*/) {
145 149
     planner.set_z_fade_height(zfh);
146 150
 
147 151
     if (level_active) {
152
+      const float oldpos[XYZE] = {
153
+        current_position[X_AXIS], current_position[Y_AXIS],
154
+        current_position[Z_AXIS], current_position[E_AXIS]
155
+      };
148 156
       #if ENABLED(AUTO_BED_LEVELING_UBL)
149 157
         set_bed_leveling_enabled(true);  // turn back on after changing fade height
150 158
       #else
@@ -155,7 +163,10 @@ void set_bed_leveling_enabled(const bool enable/*=true*/) {
155 163
             Z_AXIS
156 164
           #endif
157 165
         );
166
+        SYNC_PLAN_POSITION_KINEMATIC();
158 167
       #endif
168
+      if (do_report && memcmp(oldpos, current_position, sizeof(oldpos)))
169
+        report_current_position();
159 170
     }
160 171
   }
161 172
 

+ 1
- 1
Marlin/src/feature/bedlevel/bedlevel.h Visa fil

@@ -47,7 +47,7 @@ void set_bed_leveling_enabled(const bool enable=true);
47 47
 void reset_bed_level();
48 48
 
49 49
 #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
50
-  void set_z_fade_height(const float zfh);
50
+  void set_z_fade_height(const float zfh, const bool do_report=true);
51 51
 #endif
52 52
 
53 53
 #if ENABLED(AUTO_BED_LEVELING_BILINEAR) || ENABLED(MESH_BED_LEVELING)

+ 3
- 1
Marlin/src/feature/bedlevel/ubl/ubl.cpp Visa fil

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

+ 1
- 1
Marlin/src/gcode/bedlevel/M420.cpp Visa fil

@@ -108,7 +108,7 @@ void GcodeSuite::M420() {
108 108
   if (parser.seen('S')) set_bed_leveling_enabled(to_enable);
109 109
 
110 110
   #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
111
-    if (parser.seen('Z')) set_z_fade_height(parser.value_linear_units());
111
+    if (parser.seen('Z')) set_z_fade_height(parser.value_linear_units(), false);
112 112
   #endif
113 113
 
114 114
   const bool new_status = planner.leveling_active;

+ 1
- 0
Marlin/src/gcode/bedlevel/abl/G29.cpp Visa fil

@@ -285,6 +285,7 @@ void GcodeSuite::G29() {
285 285
             bed_level_virt_interpolate();
286 286
           #endif
287 287
           set_bed_leveling_enabled(abl_should_enable);
288
+          if (abl_should_enable) report_current_position();
288 289
         }
289 290
         return;
290 291
       } // parser.seen('W')

+ 6
- 0
Marlin/src/module/motion.cpp Visa fil

@@ -211,6 +211,12 @@ void get_cartesian_from_steppers() {
211 211
  * Set the current_position for an axis based on
212 212
  * the stepper positions, removing any leveling that
213 213
  * may have been applied.
214
+ *
215
+ * To prevent small shifts in axis position always call
216
+ * SYNC_PLAN_POSITION_KINEMATIC after updating axes with this.
217
+ *
218
+ * To keep hosts in sync, always call report_current_position
219
+ * after updating the current_position.
214 220
  */
215 221
 void set_current_from_steppers_for_axis(const AxisEnum axis) {
216 222
   get_cartesian_from_steppers();

Laddar…
Avbryt
Spara