aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/chelper/itersolve.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2019-11-01 18:32:06 -0400
committerKevin O'Connor <kevin@koconnor.net>2019-11-21 13:17:45 -0500
commit4dbe795ac2b9af24c3c45d4d25ac0eedf86f3d12 (patch)
tree81a867ec77541be7a6b4e43efc8e5072c50f92af /klippy/chelper/itersolve.c
parent2843c850198010b1948a578a1b1421ee81be36b7 (diff)
downloadkutter-4dbe795ac2b9af24c3c45d4d25ac0eedf86f3d12.tar.gz
kutter-4dbe795ac2b9af24c3c45d4d25ac0eedf86f3d12.tar.xz
kutter-4dbe795ac2b9af24c3c45d4d25ac0eedf86f3d12.zip
trapq: Implement sentinel nodes on the trapq list
Use sentinels to make list traversal code simpler. Also add in null moves so that there are no time gaps in the list. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/chelper/itersolve.c')
-rw-r--r--klippy/chelper/itersolve.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/klippy/chelper/itersolve.c b/klippy/chelper/itersolve.c
index 5eafd2a7..84fd5f71 100644
--- a/klippy/chelper/itersolve.c
+++ b/klippy/chelper/itersolve.c
@@ -144,14 +144,12 @@ itersolve_generate_steps(struct stepper_kinematics *sk, double flush_time)
{
double last_flush_time = sk->last_flush_time;
sk->last_flush_time = flush_time;
- if (!sk->tq || list_empty(&sk->tq->moves))
+ if (!sk->tq)
return 0;
+ trapq_check_sentinels(sk->tq);
struct move *m = list_first_entry(&sk->tq->moves, struct move, node);
- while (last_flush_time >= m->print_time + m->move_t) {
- if (list_is_last(&m->node, &sk->tq->moves))
- return 0;
+ while (last_flush_time >= m->print_time + m->move_t)
m = list_next_entry(m, node);
- }
for (;;) {
double start = m->print_time, end = start + m->move_t;
if (start < last_flush_time)
@@ -166,7 +164,7 @@ itersolve_generate_steps(struct stepper_kinematics *sk, double flush_time)
return ret;
}
last_flush_time = end;
- if (list_is_last(&m->node, &sk->tq->moves))
+ if (flush_time <= m->print_time + m->move_t)
return 0;
m = list_next_entry(m, node);
}
@@ -176,22 +174,19 @@ itersolve_generate_steps(struct stepper_kinematics *sk, double flush_time)
double __visible
itersolve_check_active(struct stepper_kinematics *sk, double flush_time)
{
- if (!sk->tq || list_empty(&sk->tq->moves))
+ if (!sk->tq)
return 0.;
+ trapq_check_sentinels(sk->tq);
struct move *m = list_first_entry(&sk->tq->moves, struct move, node);
- while (sk->last_flush_time >= m->print_time + m->move_t) {
- if (list_is_last(&m->node, &sk->tq->moves))
- return 0.;
+ while (sk->last_flush_time >= m->print_time + m->move_t)
m = list_next_entry(m, node);
- }
- while (m->print_time < flush_time) {
+ for (;;) {
if (check_active(sk, m))
return m->print_time;
- if (list_is_last(&m->node, &sk->tq->moves))
+ if (flush_time <= m->print_time + m->move_t)
return 0.;
m = list_next_entry(m, node);
}
- return 0.;
}
void __visible