aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/chelper
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2019-10-29 12:44:39 -0400
committerKevin O'Connor <kevin@koconnor.net>2019-11-06 15:51:51 -0500
commit1acaaa98c21af0a2a2cff725365dfda0ff4b7204 (patch)
tree601ce8a29fb24f7b4b83368c120c386563d2ff1b /klippy/chelper
parent797dcfcb1218194077d37dd53575c19c4af710c5 (diff)
downloadkutter-1acaaa98c21af0a2a2cff725365dfda0ff4b7204.tar.gz
kutter-1acaaa98c21af0a2a2cff725365dfda0ff4b7204.tar.xz
kutter-1acaaa98c21af0a2a2cff725365dfda0ff4b7204.zip
trapq: Remove move_fill()
Now that all callers use the trapq system to queue moves, it is no longer necessary to individually allocate and fill a 'struct move'. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/chelper')
-rw-r--r--klippy/chelper/__init__.py6
-rw-r--r--klippy/chelper/itersolve.c4
-rw-r--r--klippy/chelper/kin_extruder.c14
-rw-r--r--klippy/chelper/trapq.c24
-rw-r--r--klippy/chelper/trapq.h17
5 files changed, 35 insertions, 30 deletions
diff --git a/klippy/chelper/__init__.py b/klippy/chelper/__init__.py
index 2c8f78f3..e26e31ba 100644
--- a/klippy/chelper/__init__.py
+++ b/klippy/chelper/__init__.py
@@ -58,15 +58,13 @@ defs_itersolve = """
"""
defs_trapq = """
- struct move *move_alloc(void);
- void move_fill(struct move *m, double print_time
+ void trapq_append(struct trapq *tq, double print_time
, double accel_t, double cruise_t, double decel_t
, double start_pos_x, double start_pos_y, double start_pos_z
, double axes_d_x, double axes_d_y, double axes_d_z
, double start_v, double cruise_v, double accel);
struct trapq *trapq_alloc(void);
void trapq_free(struct trapq *tq);
- void trapq_add_move(struct trapq *tq, struct move *m);
void trapq_free_moves(struct trapq *tq, double print_time);
"""
@@ -94,7 +92,7 @@ defs_kin_winch = """
defs_kin_extruder = """
struct stepper_kinematics *extruder_stepper_alloc(void);
- void extruder_move_fill(struct move *m, double print_time
+ void extruder_add_move(struct trapq *tq, double print_time
, double accel_t, double cruise_t, double decel_t, double start_pos
, double start_v, double cruise_v, double accel
, double extra_accel_v, double extra_decel_v);
diff --git a/klippy/chelper/itersolve.c b/klippy/chelper/itersolve.c
index eeb107ab..c86b35e3 100644
--- a/klippy/chelper/itersolve.c
+++ b/klippy/chelper/itersolve.c
@@ -215,7 +215,9 @@ itersolve_calc_position_from_coord(struct stepper_kinematics *sk
{
struct move m;
memset(&m, 0, sizeof(m));
- move_fill(&m, 0., 0., 1., 0., x, y, z, 0., 1., 0., 0., 1., 0.);
+ m.start_pos.x = x;
+ m.start_pos.y = y;
+ m.start_pos.z = z;
return sk->calc_position_cb(sk, &m, 0.);
}
diff --git a/klippy/chelper/kin_extruder.c b/klippy/chelper/kin_extruder.c
index 26513092..37c00c8b 100644
--- a/klippy/chelper/kin_extruder.c
+++ b/klippy/chelper/kin_extruder.c
@@ -30,12 +30,14 @@ extruder_stepper_alloc(void)
// Populate a 'struct move' with an extruder velocity trapezoid
void __visible
-extruder_move_fill(struct move *m, double print_time
- , double accel_t, double cruise_t, double decel_t
- , double start_pos
- , double start_v, double cruise_v, double accel
- , double extra_accel_v, double extra_decel_v)
+extruder_add_move(struct trapq *tq, double print_time
+ , double accel_t, double cruise_t, double decel_t
+ , double start_pos
+ , double start_v, double cruise_v, double accel
+ , double extra_accel_v, double extra_decel_v)
{
+ struct move *m = move_alloc();
+
// Setup velocity trapezoid
m->print_time = print_time;
m->move_t = accel_t + cruise_t + decel_t;
@@ -54,4 +56,6 @@ extruder_move_fill(struct move *m, double print_time
// Setup start distance
m->start_pos.x = start_pos;
m->axes_r.x = 1.;
+
+ trapq_add_move(tq, m);
}
diff --git a/klippy/chelper/trapq.c b/klippy/chelper/trapq.c
index 828d48cf..966c8a45 100644
--- a/klippy/chelper/trapq.c
+++ b/klippy/chelper/trapq.c
@@ -12,7 +12,7 @@
#include "trapq.h" // move_get_coord
// Allocate a new 'move' object
-struct move * __visible
+struct move *
move_alloc(void)
{
struct move *m = malloc(sizeof(*m));
@@ -20,14 +20,16 @@ move_alloc(void)
return m;
}
-// Populate a 'struct move' with a velocity trapezoid
+// Fill and add a move to the trapezoid velocity queue
void __visible
-move_fill(struct move *m, double print_time
- , double accel_t, double cruise_t, double decel_t
- , double start_pos_x, double start_pos_y, double start_pos_z
- , double axes_d_x, double axes_d_y, double axes_d_z
- , double start_v, double cruise_v, double accel)
+trapq_append(struct trapq *tq, double print_time
+ , double accel_t, double cruise_t, double decel_t
+ , double start_pos_x, double start_pos_y, double start_pos_z
+ , double axes_d_x, double axes_d_y, double axes_d_z
+ , double start_v, double cruise_v, double accel)
{
+ struct move *m = move_alloc();
+
// Setup velocity trapezoid
m->print_time = print_time;
m->move_t = accel_t + cruise_t + decel_t;
@@ -52,6 +54,8 @@ move_fill(struct move *m, double print_time
m->axes_r.x = axes_d_x * inv_move_d;
m->axes_r.y = axes_d_y * inv_move_d;
m->axes_r.z = axes_d_z * inv_move_d;
+
+ trapq_add_move(tq, m);
}
// Find the distance travel during acceleration/deceleration
@@ -111,12 +115,10 @@ trapq_free(struct trapq *tq)
}
// Add a move to the trapezoid velocity queue
-void __visible
+void
trapq_add_move(struct trapq *tq, struct move *m)
{
- struct move *nm = move_alloc();
- memcpy(nm, m, sizeof(*nm));
- list_add_tail(&nm->node, &tq->moves);
+ list_add_tail(&m->node, &tq->moves);
}
// Free any moves older than `print_time` from the trapezoid velocity queue
diff --git a/klippy/chelper/trapq.h b/klippy/chelper/trapq.h
index e568a1ab..0c81b330 100644
--- a/klippy/chelper/trapq.h
+++ b/klippy/chelper/trapq.h
@@ -22,19 +22,18 @@ struct move {
struct list_node node;
};
-struct move *move_alloc(void);
-void move_fill(struct move *m, double print_time
- , double accel_t, double cruise_t, double decel_t
- , double start_pos_x, double start_pos_y, double start_pos_z
- , double axes_d_x, double axes_d_y, double axes_d_z
- , double start_v, double cruise_v, double accel);
-double move_get_distance(struct move *m, double move_time);
-struct coord move_get_coord(struct move *m, double move_time);
-
struct trapq {
struct list_head moves;
};
+struct move *move_alloc(void);
+void trapq_append(struct trapq *tq, double print_time
+ , double accel_t, double cruise_t, double decel_t
+ , double start_pos_x, double start_pos_y, double start_pos_z
+ , double axes_d_x, double axes_d_y, double axes_d_z
+ , double start_v, double cruise_v, double accel);
+double move_get_distance(struct move *m, double move_time);
+struct coord move_get_coord(struct move *m, double move_time);
struct trapq *trapq_alloc(void);
void trapq_free(struct trapq *tq);
void trapq_add_move(struct trapq *tq, struct move *m);