mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-08-08 22:35:17 -06:00
toolhead: Keep stepcompress move history relative to current time (#6439)
Expire history relative to current time rather than last move in history queue Signed-off-by: Francois Chagnon <fc@francoischagnon.net>
This commit is contained in:
parent
b502558052
commit
d7f6348ae6
10 changed files with 54 additions and 27 deletions
|
@ -163,11 +163,10 @@ trapq_append(struct trapq *tq, double print_time
|
|||
}
|
||||
}
|
||||
|
||||
#define HISTORY_EXPIRE (30.0)
|
||||
|
||||
// Expire any moves older than `print_time` from the trapezoid velocity queue
|
||||
void __visible
|
||||
trapq_finalize_moves(struct trapq *tq, double print_time)
|
||||
trapq_finalize_moves(struct trapq *tq, double print_time
|
||||
, double clear_history_time)
|
||||
{
|
||||
struct move *head_sentinel = list_first_entry(&tq->moves, struct move,node);
|
||||
struct move *tail_sentinel = list_last_entry(&tq->moves, struct move, node);
|
||||
|
@ -190,10 +189,9 @@ trapq_finalize_moves(struct trapq *tq, double print_time)
|
|||
if (list_empty(&tq->history))
|
||||
return;
|
||||
struct move *latest = list_first_entry(&tq->history, struct move, node);
|
||||
double expire_time = latest->print_time + latest->move_t - HISTORY_EXPIRE;
|
||||
for (;;) {
|
||||
struct move *m = list_last_entry(&tq->history, struct move, node);
|
||||
if (m == latest || m->print_time + m->move_t > expire_time)
|
||||
if (m == latest || m->print_time + m->move_t > clear_history_time)
|
||||
break;
|
||||
list_del(&m->node);
|
||||
free(m);
|
||||
|
@ -206,7 +204,7 @@ trapq_set_position(struct trapq *tq, double print_time
|
|||
, double pos_x, double pos_y, double pos_z)
|
||||
{
|
||||
// Flush all moves from trapq
|
||||
trapq_finalize_moves(tq, NEVER_TIME);
|
||||
trapq_finalize_moves(tq, NEVER_TIME, 0);
|
||||
|
||||
// Prune any moves in the trapq history that were interrupted
|
||||
while (!list_empty(&tq->history)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue