diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2022-01-29 19:13:31 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2022-02-10 13:24:21 -0500 |
commit | 9ec97424844c76bbc0c5604e15aa195282b6c955 (patch) | |
tree | ff05667b33edfff52b86768ed962e5c0f4e597df /klippy/chelper/stepcompress.c | |
parent | 189188e3ca3e40d8272fb4ad48316e329f8ec453 (diff) | |
download | kutter-9ec97424844c76bbc0c5604e15aa195282b6c955.tar.gz kutter-9ec97424844c76bbc0c5604e15aa195282b6c955.tar.xz kutter-9ec97424844c76bbc0c5604e15aa195282b6c955.zip |
extruder: Add support for reversing the direction of extruder stepper movement
Extend SET_EXTRUDER_ROTATION_DISTANCE to support reversing the
direction of extruder movement.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/chelper/stepcompress.c')
-rw-r--r-- | klippy/chelper/stepcompress.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/klippy/chelper/stepcompress.c b/klippy/chelper/stepcompress.c index b38b72ad..e261f1d3 100644 --- a/klippy/chelper/stepcompress.c +++ b/klippy/chelper/stepcompress.c @@ -259,15 +259,25 @@ stepcompress_alloc(uint32_t oid) // Fill message id information void __visible stepcompress_fill(struct stepcompress *sc, uint32_t max_error - , uint32_t invert_sdir, int32_t queue_step_msgtag - , int32_t set_next_step_dir_msgtag) + , int32_t queue_step_msgtag, int32_t set_next_step_dir_msgtag) { sc->max_error = max_error; - sc->invert_sdir = !!invert_sdir; sc->queue_step_msgtag = queue_step_msgtag; sc->set_next_step_dir_msgtag = set_next_step_dir_msgtag; } +// Set the inverted stepper direction flag +void __visible +stepcompress_set_invert_sdir(struct stepcompress *sc, uint32_t invert_sdir) +{ + invert_sdir = !!invert_sdir; + if (invert_sdir != sc->invert_sdir) { + sc->invert_sdir = invert_sdir; + if (sc->sdir >= 0) + sc->sdir ^= 1; + } +} + // Helper to free items from the history_list static void free_history(struct stepcompress *sc, uint64_t end_clock) |