Kaynağa Gözat

Augment planner/stepper getters/setters

Scott Lahteine 8 yıl önce
ebeveyn
işleme
ecf7cdde65
5 değiştirilmiş dosya ile 21 ekleme ve 11 silme
  1. 2
    0
      Marlin/enum.h
  2. 7
    6
      Marlin/planner.cpp
  3. 5
    5
      Marlin/planner.h
  4. 6
    0
      Marlin/stepper.cpp
  5. 1
    0
      Marlin/stepper.h

+ 2
- 0
Marlin/enum.h Dosyayı Görüntüle

@@ -23,6 +23,8 @@
23 23
 #ifndef __ENUM_H__
24 24
 #define __ENUM_H__
25 25
 
26
+#include "MarlinConfig.h"
27
+
26 28
 /**
27 29
  * Axis indices as enumerated constants
28 30
  *

+ 7
- 6
Marlin/planner.cpp Dosyayı Görüntüle

@@ -1201,7 +1201,8 @@ void Planner::buffer_line(ARG_X, ARG_Y, ARG_Z, const float &e, float fr_mm_s, co
1201 1201
 } // buffer_line()
1202 1202
 
1203 1203
 /**
1204
- * Directly set the planner XYZ position (hence the stepper positions).
1204
+ * Directly set the planner XYZ position (and stepper positions)
1205
+ * converting mm (or angles for SCARA) into steps.
1205 1206
  *
1206 1207
  * On CORE machines stepper ABC will be translated from the given XYZ.
1207 1208
  */
@@ -1229,12 +1230,12 @@ void Planner::sync_from_steppers() {
1229 1230
 }
1230 1231
 
1231 1232
 /**
1232
- * Directly set the planner E position (hence the stepper E position).
1233
+ * Setters for planner position (also setting stepper position).
1233 1234
  */
1234
-void Planner::set_e_position_mm(const float& e) {
1235
-  position[E_AXIS] = lround(e * axis_steps_per_mm[E_AXIS]);
1236
-  stepper.set_e_position(position[E_AXIS]);
1237
-  previous_speed[E_AXIS] = 0.0;
1235
+void Planner::set_position_mm(const AxisEnum axis, const float& v) {
1236
+  position[axis] = lround(v * axis_steps_per_mm[axis]);
1237
+  stepper.set_position(axis, v);
1238
+  previous_speed[axis] = 0.0;
1238 1239
 }
1239 1240
 
1240 1241
 // Recalculate the steps/s^2 acceleration rates, based on the mm/s^2

+ 5
- 5
Marlin/planner.h Dosyayı Görüntüle

@@ -33,6 +33,7 @@
33 33
 #define PLANNER_H
34 34
 
35 35
 #include "types.h"
36
+#include "enum.h"
36 37
 #include "MarlinConfig.h"
37 38
 
38 39
 #if HAS_ABL
@@ -242,6 +243,10 @@ class Planner {
242 243
      * Clears previous speed values.
243 244
      */
244 245
     static void set_position_mm(ARG_X, ARG_Y, ARG_Z, const float& e);
246
+    static void set_position_mm(const AxisEnum axis, const float& v);
247
+
248
+    static FORCE_INLINE void set_z_position_mm(const float& z) { set_position_mm(Z_AXIS, z); }
249
+    static FORCE_INLINE void set_e_position_mm(const float& e) { set_position_mm(E_AXIS, e); }
245 250
 
246 251
     /**
247 252
      * Sync from the stepper positions. (e.g., after an interrupted move)
@@ -249,11 +254,6 @@ class Planner {
249 254
     static void sync_from_steppers();
250 255
 
251 256
     /**
252
-     * Set the E position (mm) of the planner (and the E stepper)
253
-     */
254
-    static void set_e_position_mm(const float& e);
255
-
256
-    /**
257 257
      * Does the buffer have any blocks queued?
258 258
      */
259 259
     static bool blocks_queued() { return (block_buffer_head != block_buffer_tail); }

+ 6
- 0
Marlin/stepper.cpp Dosyayı Görüntüle

@@ -970,6 +970,12 @@ void Stepper::set_position(const long& x, const long& y, const long& z, const lo
970 970
   CRITICAL_SECTION_END;
971 971
 }
972 972
 
973
+void Stepper::set_position(const AxisEnum &axis, const long& v) {
974
+  CRITICAL_SECTION_START;
975
+  count_position[axis] = v;
976
+  CRITICAL_SECTION_END;
977
+}
978
+
973 979
 void Stepper::set_e_position(const long& e) {
974 980
   CRITICAL_SECTION_START;
975 981
   count_position[E_AXIS] = e;

+ 1
- 0
Marlin/stepper.h Dosyayı Görüntüle

@@ -189,6 +189,7 @@ class Stepper {
189 189
     // Set the current position in steps
190 190
     //
191 191
     static void set_position(const long& x, const long& y, const long& z, const long& e);
192
+    static void set_position(const AxisEnum& a, const long& v);
192 193
     static void set_e_position(const long& e);
193 194
 
194 195
     //

Loading…
İptal
Kaydet