aboutsummaryrefslogtreecommitdiffstats
path: root/klippy
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2017-04-04 19:37:54 -0400
committerKevin O'Connor <kevin@koconnor.net>2017-04-07 13:26:39 -0400
commit47f12f107d613ce0ccd11b69aee126df24fcb8e7 (patch)
tree79ed2e6ab48ef9a8becca0bb6b152c60e5a9a94a /klippy
parentbfad970e4dcf9f7aca4f8442477ca9e886871c9e (diff)
downloadkutter-47f12f107d613ce0ccd11b69aee126df24fcb8e7.tar.gz
kutter-47f12f107d613ce0ccd11b69aee126df24fcb8e7.tar.xz
kutter-47f12f107d613ce0ccd11b69aee126df24fcb8e7.zip
stepcompress: Move stepcompress_push_* functions to their own section
This is only code movement; no code changes. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy')
-rw-r--r--klippy/chelper.py7
-rw-r--r--klippy/stepcompress.c111
2 files changed, 62 insertions, 56 deletions
diff --git a/klippy/chelper.py b/klippy/chelper.py
index ed494456..b35089a1 100644
--- a/klippy/chelper.py
+++ b/klippy/chelper.py
@@ -16,6 +16,10 @@ defs_stepcompress = """
, uint32_t queue_step_msgid, uint32_t set_next_step_dir_msgid
, uint32_t invert_sdir, uint32_t oid);
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);
+ int stepcompress_queue_msg(struct stepcompress *sc, uint32_t *data, int len);
+
int stepcompress_push(struct stepcompress *sc, double step_clock
, int32_t sdir);
int32_t stepcompress_push_factor(struct stepcompress *sc
@@ -32,9 +36,6 @@ defs_stepcompress = """
, double clock_offset, double dist, double start_pos
, double accel_multiplier, double step_dist, double height
, double closestxy_d, double closest_height2, double movez_r);
- int stepcompress_reset(struct stepcompress *sc, uint64_t last_step_clock);
- int stepcompress_set_homing(struct stepcompress *sc, uint64_t homing_clock);
- int stepcompress_queue_msg(struct stepcompress *sc, uint32_t *data, int len);
struct steppersync *steppersync_alloc(struct serialqueue *sq
, struct stepcompress **sc_list, int sc_num, int move_num);
diff --git a/klippy/stepcompress.c b/klippy/stepcompress.c
index a139a1f1..41e7f515 100644
--- a/klippy/stepcompress.c
+++ b/klippy/stepcompress.c
@@ -275,22 +275,6 @@ check_line(struct stepcompress *sc, struct step_move move)
* Step compress interface
****************************************************************/
-#define likely(x) __builtin_expect(!!(x), 1)
-
-// Wrapper around sqrt() to handle small negative numbers
-static double
-_safe_sqrt(double v)
-{
- // Due to floating point truncation, it's possible to get a small
- // negative number - treat it as zero.
- if (v < -0.001)
- errorf("safe_sqrt of %.9f", v);
- return 0.;
-}
-static inline double safe_sqrt(double v) {
- return likely(v >= 0.) ? sqrt(v) : _safe_sqrt(v);
-}
-
// Allocate a new 'stepcompress' object
struct stepcompress *
stepcompress_alloc(uint32_t max_error, uint32_t queue_step_msgid
@@ -378,6 +362,8 @@ set_next_step_dir(struct stepcompress *sc, int sdir)
return 0;
}
+#define likely(x) __builtin_expect(!!(x), 1)
+
// Check if the internal queue needs to be expanded, and expand if so
static int
_check_expand(struct stepcompress *sc, uint64_t *qn)
@@ -405,6 +391,62 @@ check_expand(struct stepcompress *sc, uint64_t **pqn, uint64_t **pqend)
return 0;
}
+// Reset the internal state of the stepcompress object
+int
+stepcompress_reset(struct stepcompress *sc, uint64_t last_step_clock)
+{
+ int ret = stepcompress_flush(sc, UINT64_MAX);
+ if (ret)
+ return ret;
+ sc->last_step_clock = last_step_clock;
+ sc->sdir = -1;
+ return 0;
+}
+
+// Indicate the stepper is in homing mode (or done homing if zero)
+int
+stepcompress_set_homing(struct stepcompress *sc, uint64_t homing_clock)
+{
+ int ret = stepcompress_flush(sc, UINT64_MAX);
+ if (ret)
+ return ret;
+ sc->homing_clock = homing_clock;
+ return 0;
+}
+
+// Queue an mcu command to go out in order with stepper commands
+int
+stepcompress_queue_msg(struct stepcompress *sc, uint32_t *data, int len)
+{
+ int ret = stepcompress_flush(sc, UINT64_MAX);
+ if (ret)
+ return ret;
+
+ struct queue_message *qm = message_alloc_and_encode(data, len);
+ qm->req_clock = sc->homing_clock ?: sc->last_step_clock;
+ list_add_tail(&qm->node, &sc->msg_queue);
+ return 0;
+}
+
+
+/****************************************************************
+ * Motion to step conversions
+ ****************************************************************/
+
+// Wrapper around sqrt() to handle small negative numbers
+static double
+_safe_sqrt(double v)
+{
+ // Due to floating point truncation, it's possible to get a small
+ // negative number - treat it as zero.
+ if (v < -0.001)
+ errorf("safe_sqrt of %.9f", v);
+ return 0.;
+}
+static inline double safe_sqrt(double v) {
+ return likely(v >= 0.) ? sqrt(v) : _safe_sqrt(v);
+}
+
// Schedule a step event at the specified step_clock time
int
stepcompress_push(struct stepcompress *sc, double step_clock, int32_t sdir)
@@ -625,43 +667,6 @@ stepcompress_push_delta_accel(
return res;
}
-// Reset the internal state of the stepcompress object
-int
-stepcompress_reset(struct stepcompress *sc, uint64_t last_step_clock)
-{
- int ret = stepcompress_flush(sc, UINT64_MAX);
- if (ret)
- return ret;
- sc->last_step_clock = last_step_clock;
- sc->sdir = -1;
- return 0;
-}
-
-// Indicate the stepper is in homing mode (or done homing if zero)
-int
-stepcompress_set_homing(struct stepcompress *sc, uint64_t homing_clock)
-{
- int ret = stepcompress_flush(sc, UINT64_MAX);
- if (ret)
- return ret;
- sc->homing_clock = homing_clock;
- return 0;
-}
-
-// Queue an mcu command to go out in order with stepper commands
-int
-stepcompress_queue_msg(struct stepcompress *sc, uint32_t *data, int len)
-{
- int ret = stepcompress_flush(sc, UINT64_MAX);
- if (ret)
- return ret;
-
- struct queue_message *qm = message_alloc_and_encode(data, len);
- qm->req_clock = sc->homing_clock ?: sc->last_step_clock;
- list_add_tail(&qm->node, &sc->msg_queue);
- return 0;
-}
-
/****************************************************************
* Step compress synchronization