Browse Source

Augment planner/stepper getters/setters

Scott Lahteine 8 years ago
parent
commit
ecf7cdde65
5 changed files with 21 additions and 11 deletions
  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 View File

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

+ 7
- 6
Marlin/planner.cpp View File

1201
 } // buffer_line()
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
  * On CORE machines stepper ABC will be translated from the given XYZ.
1207
  * On CORE machines stepper ABC will be translated from the given XYZ.
1207
  */
1208
  */
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
 // Recalculate the steps/s^2 acceleration rates, based on the mm/s^2
1241
 // Recalculate the steps/s^2 acceleration rates, based on the mm/s^2

+ 5
- 5
Marlin/planner.h View File

33
 #define PLANNER_H
33
 #define PLANNER_H
34
 
34
 
35
 #include "types.h"
35
 #include "types.h"
36
+#include "enum.h"
36
 #include "MarlinConfig.h"
37
 #include "MarlinConfig.h"
37
 
38
 
38
 #if HAS_ABL
39
 #if HAS_ABL
242
      * Clears previous speed values.
243
      * Clears previous speed values.
243
      */
244
      */
244
     static void set_position_mm(ARG_X, ARG_Y, ARG_Z, const float& e);
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
      * Sync from the stepper positions. (e.g., after an interrupted move)
252
      * Sync from the stepper positions. (e.g., after an interrupted move)
249
     static void sync_from_steppers();
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
      * Does the buffer have any blocks queued?
257
      * Does the buffer have any blocks queued?
258
      */
258
      */
259
     static bool blocks_queued() { return (block_buffer_head != block_buffer_tail); }
259
     static bool blocks_queued() { return (block_buffer_head != block_buffer_tail); }

+ 6
- 0
Marlin/stepper.cpp View File

970
   CRITICAL_SECTION_END;
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
 void Stepper::set_e_position(const long& e) {
979
 void Stepper::set_e_position(const long& e) {
974
   CRITICAL_SECTION_START;
980
   CRITICAL_SECTION_START;
975
   count_position[E_AXIS] = e;
981
   count_position[E_AXIS] = e;

+ 1
- 0
Marlin/stepper.h View File

189
     // Set the current position in steps
189
     // Set the current position in steps
190
     //
190
     //
191
     static void set_position(const long& x, const long& y, const long& z, const long& e);
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
     static void set_e_position(const long& e);
193
     static void set_e_position(const long& e);
193
 
194
 
194
     //
195
     //

Loading…
Cancel
Save