aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/chelper
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2021-08-06 10:06:03 -0400
committerKevin O'Connor <kevin@koconnor.net>2021-08-06 12:22:07 -0400
commitafada5e79edd935a82150c8838393f096997c8c4 (patch)
tree8421f1b3409aba71dc96d07592aaf7b6d2e1ed49 /klippy/chelper
parentb17ec3d2e9d0afb96351a6ed26fba958584899ac (diff)
downloadkutter-afada5e79edd935a82150c8838393f096997c8c4.tar.gz
kutter-afada5e79edd935a82150c8838393f096997c8c4.tar.xz
kutter-afada5e79edd935a82150c8838393f096997c8c4.zip
trapq: Prune interrupted moves from history on trapq_set_position()
It is possible for a homing move to not fully complete. Fixup the trapq history to make processing of the history easier for callers. Similarly, do not add artificial "null" moves to the trapq history. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/chelper')
-rw-r--r--klippy/chelper/trapq.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/klippy/chelper/trapq.c b/klippy/chelper/trapq.c
index 2d4c2093..dbb72865 100644
--- a/klippy/chelper/trapq.c
+++ b/klippy/chelper/trapq.c
@@ -181,7 +181,10 @@ trapq_finalize_moves(struct trapq *tq, double print_time)
if (m->print_time + m->move_t > print_time)
break;
list_del(&m->node);
- list_add_head(&m->node, &tq->history);
+ if (m->start_v || m->half_accel)
+ list_add_head(&m->node, &tq->history);
+ else
+ free(m);
}
// Free old moves from history list
if (list_empty(&tq->history))
@@ -205,6 +208,18 @@ trapq_set_position(struct trapq *tq, double print_time
// Flush all moves from trapq
trapq_finalize_moves(tq, NEVER_TIME);
+ // Prune any moves in the trapq history that were interrupted
+ while (!list_empty(&tq->history)) {
+ struct move *m = list_first_entry(&tq->history, struct move, node);
+ if (m->print_time < print_time) {
+ if (m->print_time + m->move_t > print_time)
+ m->move_t = print_time - m->print_time;
+ break;
+ }
+ list_del(&m->node);
+ free(m);
+ }
+
// Add a marker to the trapq history
struct move *m = move_alloc();
m->print_time = print_time;