aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/chelper
diff options
context:
space:
mode:
Diffstat (limited to 'klippy/chelper')
-rw-r--r--klippy/chelper/__init__.py5
-rw-r--r--klippy/chelper/stepcompress.c16
-rw-r--r--klippy/chelper/stepcompress.h4
3 files changed, 19 insertions, 6 deletions
diff --git a/klippy/chelper/__init__.py b/klippy/chelper/__init__.py
index e04d431d..c7e2155c 100644
--- a/klippy/chelper/__init__.py
+++ b/klippy/chelper/__init__.py
@@ -38,8 +38,9 @@ defs_stepcompress = """
struct stepcompress *stepcompress_alloc(uint32_t oid);
void 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);
+ void stepcompress_set_invert_sdir(struct stepcompress *sc
+ , uint32_t invert_sdir);
void stepcompress_free(struct stepcompress *sc);
int stepcompress_reset(struct stepcompress *sc, uint64_t last_step_clock);
int stepcompress_set_last_position(struct stepcompress *sc
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)
diff --git a/klippy/chelper/stepcompress.h b/klippy/chelper/stepcompress.h
index 5bca39a5..b8a95057 100644
--- a/klippy/chelper/stepcompress.h
+++ b/klippy/chelper/stepcompress.h
@@ -13,8 +13,10 @@ struct pull_history_steps {
struct stepcompress *stepcompress_alloc(uint32_t oid);
void stepcompress_fill(struct stepcompress *sc, uint32_t max_error
- , uint32_t invert_sdir, int32_t queue_step_msgtag
+ , int32_t queue_step_msgtag
, int32_t set_next_step_dir_msgtag);
+void stepcompress_set_invert_sdir(struct stepcompress *sc
+ , uint32_t invert_sdir);
void stepcompress_free(struct stepcompress *sc);
uint32_t stepcompress_get_oid(struct stepcompress *sc);
int stepcompress_get_step_dir(struct stepcompress *sc);