소스 검색

Sync and report changed position

Scott Lahteine 7 년 전
부모
커밋
03ba79f144

+ 12
- 1
Marlin/src/feature/bedlevel/bedlevel.cpp 파일 보기

128
         // so compensation will give the right stepper counts.
128
         // so compensation will give the right stepper counts.
129
         planner.unapply_leveling(current_position);
129
         planner.unapply_leveling(current_position);
130
 
130
 
131
+      SYNC_PLAN_POSITION_KINEMATIC();
132
+
131
     #endif // OLDSCHOOL_ABL
133
     #endif // OLDSCHOOL_ABL
132
   }
134
   }
133
 }
135
 }
134
 
136
 
135
 #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
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
     const bool level_active = planner.leveling_active;
143
     const bool level_active = planner.leveling_active;
140
 
144
 
145
     planner.set_z_fade_height(zfh);
149
     planner.set_z_fade_height(zfh);
146
 
150
 
147
     if (level_active) {
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
       #if ENABLED(AUTO_BED_LEVELING_UBL)
156
       #if ENABLED(AUTO_BED_LEVELING_UBL)
149
         set_bed_leveling_enabled(true);  // turn back on after changing fade height
157
         set_bed_leveling_enabled(true);  // turn back on after changing fade height
150
       #else
158
       #else
155
             Z_AXIS
163
             Z_AXIS
156
           #endif
164
           #endif
157
         );
165
         );
166
+        SYNC_PLAN_POSITION_KINEMATIC();
158
       #endif
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 파일 보기

47
 void reset_bed_level();
47
 void reset_bed_level();
48
 
48
 
49
 #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
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
 #endif
51
 #endif
52
 
52
 
53
 #if ENABLED(AUTO_BED_LEVELING_BILINEAR) || ENABLED(MESH_BED_LEVELING)
53
 #if ENABLED(AUTO_BED_LEVELING_BILINEAR) || ENABLED(MESH_BED_LEVELING)

+ 3
- 1
Marlin/src/feature/bedlevel/ubl/ubl.cpp 파일 보기

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

+ 1
- 1
Marlin/src/gcode/bedlevel/M420.cpp 파일 보기

108
   if (parser.seen('S')) set_bed_leveling_enabled(to_enable);
108
   if (parser.seen('S')) set_bed_leveling_enabled(to_enable);
109
 
109
 
110
   #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
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
   #endif
112
   #endif
113
 
113
 
114
   const bool new_status = planner.leveling_active;
114
   const bool new_status = planner.leveling_active;

+ 1
- 0
Marlin/src/gcode/bedlevel/abl/G29.cpp 파일 보기

285
             bed_level_virt_interpolate();
285
             bed_level_virt_interpolate();
286
           #endif
286
           #endif
287
           set_bed_leveling_enabled(abl_should_enable);
287
           set_bed_leveling_enabled(abl_should_enable);
288
+          if (abl_should_enable) report_current_position();
288
         }
289
         }
289
         return;
290
         return;
290
       } // parser.seen('W')
291
       } // parser.seen('W')

+ 6
- 0
Marlin/src/module/motion.cpp 파일 보기

211
  * Set the current_position for an axis based on
211
  * Set the current_position for an axis based on
212
  * the stepper positions, removing any leveling that
212
  * the stepper positions, removing any leveling that
213
  * may have been applied.
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
 void set_current_from_steppers_for_axis(const AxisEnum axis) {
221
 void set_current_from_steppers_for_axis(const AxisEnum axis) {
216
   get_cartesian_from_steppers();
222
   get_cartesian_from_steppers();

Loading…
취소
저장