aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/chelper
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2018-06-08 17:02:20 -0400
committerKevin O'Connor <kevin@koconnor.net>2018-06-20 09:26:10 -0400
commitba3428822d61af7653f65f6a1b3b46813e104439 (patch)
tree5032ced1830f1a832a0ae5092a1506dbf30df7df /klippy/chelper
parent9a2eb4beddf1f6e551f4e85836cf1e0bd056ea03 (diff)
downloadkutter-ba3428822d61af7653f65f6a1b3b46813e104439.tar.gz
kutter-ba3428822d61af7653f65f6a1b3b46813e104439.tar.xz
kutter-ba3428822d61af7653f65f6a1b3b46813e104439.zip
stepcompress: Allow stepcompress_alloc() to be called early
Don't require an mcu connection to allocate the stepcompress object. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/chelper')
-rw-r--r--klippy/chelper/__init__.py7
-rw-r--r--klippy/chelper/stepcompress.c20
-rw-r--r--klippy/chelper/stepcompress.h7
3 files changed, 21 insertions, 13 deletions
diff --git a/klippy/chelper/__init__.py b/klippy/chelper/__init__.py
index 00fec80c..32b065d3 100644
--- a/klippy/chelper/__init__.py
+++ b/klippy/chelper/__init__.py
@@ -22,9 +22,10 @@ DEST_LIB = "c_helper.so"
OTHER_FILES = ['list.h', 'serialqueue.h', 'stepcompress.h', 'pyhelper.h']
defs_stepcompress = """
- struct stepcompress *stepcompress_alloc(uint32_t max_error
- , uint32_t queue_step_msgid, uint32_t set_next_step_dir_msgid
- , uint32_t invert_sdir, uint32_t oid);
+ struct stepcompress *stepcompress_alloc(uint32_t oid);
+ void stepcompress_fill(struct stepcompress *sc, uint32_t max_error
+ , uint32_t invert_sdir, uint32_t queue_step_msgid
+ , uint32_t set_next_step_dir_msgid);
void stepcompress_free(struct stepcompress *sc);
int stepcompress_reset(struct stepcompress *sc, uint64_t last_step_clock);
int stepcompress_set_homing(struct stepcompress *sc, uint64_t homing_clock);
diff --git a/klippy/chelper/stepcompress.c b/klippy/chelper/stepcompress.c
index e6b4da0b..ebab287a 100644
--- a/klippy/chelper/stepcompress.c
+++ b/klippy/chelper/stepcompress.c
@@ -228,22 +228,28 @@ check_line(struct stepcompress *sc, struct step_move move)
// Allocate a new 'stepcompress' object
struct stepcompress * __visible
-stepcompress_alloc(uint32_t max_error, uint32_t queue_step_msgid
- , uint32_t set_next_step_dir_msgid, uint32_t invert_sdir
- , uint32_t oid)
+stepcompress_alloc(uint32_t oid)
{
struct stepcompress *sc = malloc(sizeof(*sc));
memset(sc, 0, sizeof(*sc));
- sc->max_error = max_error;
list_init(&sc->msg_queue);
- sc->queue_step_msgid = queue_step_msgid;
- sc->set_next_step_dir_msgid = set_next_step_dir_msgid;
sc->oid = oid;
sc->sdir = -1;
- sc->invert_sdir = !!invert_sdir;
return sc;
}
+// Fill message id information
+void __visible
+stepcompress_fill(struct stepcompress *sc, uint32_t max_error
+ , uint32_t invert_sdir, uint32_t queue_step_msgid
+ , uint32_t set_next_step_dir_msgid)
+{
+ sc->max_error = max_error;
+ sc->invert_sdir = !!invert_sdir;
+ sc->queue_step_msgid = queue_step_msgid;
+ sc->set_next_step_dir_msgid = set_next_step_dir_msgid;
+}
+
// Free memory associated with a 'stepcompress' object
void __visible
stepcompress_free(struct stepcompress *sc)
diff --git a/klippy/chelper/stepcompress.h b/klippy/chelper/stepcompress.h
index 2a2fe725..a926409c 100644
--- a/klippy/chelper/stepcompress.h
+++ b/klippy/chelper/stepcompress.h
@@ -5,9 +5,10 @@
#define ERROR_RET -989898989
-struct stepcompress *stepcompress_alloc(
- uint32_t max_error, uint32_t queue_step_msgid
- , uint32_t set_next_step_dir_msgid, uint32_t invert_sdir, uint32_t oid);
+struct stepcompress *stepcompress_alloc(uint32_t oid);
+void stepcompress_fill(struct stepcompress *sc, uint32_t max_error
+ , uint32_t invert_sdir, uint32_t queue_step_msgid
+ , uint32_t set_next_step_dir_msgid);
void stepcompress_free(struct stepcompress *sc);
int set_next_step_dir(struct stepcompress *sc, int sdir);
int stepcompress_reset(struct stepcompress *sc, uint64_t last_step_clock);