Optimize coordinate transformation

Pre-compute the combined position shift and home offset to save a
single float fetch-and-add per conversion. Great for delta/scara and
bed leveling.
This commit is contained in:
Scott Lahteine
2017-03-04 19:18:11 -06:00
parent 5f7e85398b
commit e141f3a03f
2 changed files with 10 additions and 6 deletions

View File

@ -278,10 +278,11 @@ extern float current_position[NUM_AXIS];
// Workspace offsets
#if DISABLED(NO_WORKSPACE_OFFSETS)
extern float position_shift[XYZ];
extern float home_offset[XYZ];
#define LOGICAL_POSITION(POS, AXIS) ((POS) + home_offset[AXIS] + position_shift[AXIS])
#define RAW_POSITION(POS, AXIS) ((POS) - home_offset[AXIS] - position_shift[AXIS])
extern float position_shift[XYZ],
home_offset[XYZ],
workspace_offset[XYZ];
#define LOGICAL_POSITION(POS, AXIS) ((POS) + workspace_offset[AXIS])
#define RAW_POSITION(POS, AXIS) ((POS) - workspace_offset[AXIS])
#else
#define LOGICAL_POSITION(POS, AXIS) (POS)
#define RAW_POSITION(POS, AXIS) (POS)