Augment planner/stepper getters/setters

This commit is contained in:
Scott Lahteine 2016-09-28 14:01:29 -05:00
parent 2febd8ec82
commit ecf7cdde65
5 changed files with 21 additions and 11 deletions

View file

@ -23,6 +23,8 @@
#ifndef __ENUM_H__ #ifndef __ENUM_H__
#define __ENUM_H__ #define __ENUM_H__
#include "MarlinConfig.h"
/** /**
* Axis indices as enumerated constants * Axis indices as enumerated constants
* *

View file

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

View file

@ -33,6 +33,7 @@
#define PLANNER_H #define PLANNER_H
#include "types.h" #include "types.h"
#include "enum.h"
#include "MarlinConfig.h" #include "MarlinConfig.h"
#if HAS_ABL #if HAS_ABL
@ -242,17 +243,16 @@ class Planner {
* Clears previous speed values. * Clears previous speed values.
*/ */
static void set_position_mm(ARG_X, ARG_Y, ARG_Z, const float& e); static void set_position_mm(ARG_X, ARG_Y, ARG_Z, const float& e);
static void set_position_mm(const AxisEnum axis, const float& v);
static FORCE_INLINE void set_z_position_mm(const float& z) { set_position_mm(Z_AXIS, z); }
static FORCE_INLINE void set_e_position_mm(const float& e) { set_position_mm(E_AXIS, e); }
/** /**
* Sync from the stepper positions. (e.g., after an interrupted move) * Sync from the stepper positions. (e.g., after an interrupted move)
*/ */
static void sync_from_steppers(); static void sync_from_steppers();
/**
* Set the E position (mm) of the planner (and the E stepper)
*/
static void set_e_position_mm(const float& e);
/** /**
* Does the buffer have any blocks queued? * Does the buffer have any blocks queued?
*/ */

View file

@ -970,6 +970,12 @@ void Stepper::set_position(const long& x, const long& y, const long& z, const lo
CRITICAL_SECTION_END; CRITICAL_SECTION_END;
} }
void Stepper::set_position(const AxisEnum &axis, const long& v) {
CRITICAL_SECTION_START;
count_position[axis] = v;
CRITICAL_SECTION_END;
}
void Stepper::set_e_position(const long& e) { void Stepper::set_e_position(const long& e) {
CRITICAL_SECTION_START; CRITICAL_SECTION_START;
count_position[E_AXIS] = e; count_position[E_AXIS] = e;

View file

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