From fbfa31a3c3bc948ac26494244d74dee21fe11b12 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 19 Jul 2021 14:40:50 -0400 Subject: [PATCH] stepcompress: Rename 'struct history_move' to 'struct history_steps' Signed-off-by: Kevin O'Connor --- klippy/chelper/stepcompress.c | 50 +++++++++++++++++------------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/klippy/chelper/stepcompress.c b/klippy/chelper/stepcompress.c index 09fedf7a..50a4d7c4 100644 --- a/klippy/chelper/stepcompress.c +++ b/klippy/chelper/stepcompress.c @@ -56,7 +56,7 @@ struct step_move { #define HISTORY_EXPIRE (30.0) -struct history_move { +struct history_steps { struct list_node node; uint64_t first_clock, last_clock; int64_t start_position; @@ -274,12 +274,12 @@ static void free_history(struct stepcompress *sc, uint64_t end_clock) { while (!list_empty(&sc->history_list)) { - struct history_move *hm = list_last_entry( - &sc->history_list, struct history_move, node); - if (hm->last_clock > end_clock) + struct history_steps *hs = list_last_entry( + &sc->history_list, struct history_steps, node); + if (hs->last_clock > end_clock) break; - list_del(&hm->node); - free(hm); + list_del(&hs->node); + free(hs); } } @@ -351,14 +351,14 @@ add_move(struct stepcompress *sc, uint64_t first_clock, struct step_move *move) sc->last_step_clock = last_clock; // Create and store move in history tracking - struct history_move *hm = malloc(sizeof(*hm)); - hm->first_clock = first_clock; - hm->last_clock = last_clock; - hm->start_position = sc->last_position; - hm->step_count = sc->sdir ? move->count : -move->count; - sc->last_position += hm->step_count; - memcpy(&hm->sm, move, sizeof(hm->sm)); - list_add_head(&hm->node, &sc->history_list); + struct history_steps *hs = malloc(sizeof(*hs)); + hs->first_clock = first_clock; + hs->last_clock = last_clock; + hs->start_position = sc->last_position; + hs->step_count = sc->sdir ? move->count : -move->count; + sc->last_position += hs->step_count; + memcpy(&hs->sm, move, sizeof(hs->sm)); + list_add_head(&hs->node, &sc->history_list); } // Convert previously scheduled steps into commands for the mcu @@ -567,16 +567,16 @@ int64_t __visible stepcompress_find_past_position(struct stepcompress *sc, uint64_t clock) { int64_t last_position = sc->last_position; - struct history_move *hm; - list_for_each_entry(hm, &sc->history_list, node) { - if (clock < hm->first_clock) { - last_position = hm->start_position; + struct history_steps *hs; + list_for_each_entry(hs, &sc->history_list, node) { + if (clock < hs->first_clock) { + last_position = hs->start_position; continue; } - if (clock >= hm->last_clock) - return hm->start_position + hm->step_count; - int32_t interval = hm->sm.interval, add = hm->sm.add; - int32_t ticks = (int32_t)(clock - hm->first_clock) + interval, offset; + if (clock >= hs->last_clock) + return hs->start_position + hs->step_count; + int32_t interval = hs->sm.interval, add = hs->sm.add; + int32_t ticks = (int32_t)(clock - hs->first_clock) + interval, offset; if (!add) { offset = ticks / interval; } else { @@ -584,9 +584,9 @@ stepcompress_find_past_position(struct stepcompress *sc, uint64_t clock) double a = .5 * add, b = interval - .5 * add, c = -ticks; offset = (sqrt(b*b - 4*a*c) - b) / (2. * a); } - if (hm->step_count < 0) - return hm->start_position - offset; - return hm->start_position + offset; + if (hs->step_count < 0) + return hs->start_position - offset; + return hs->start_position + offset; } return last_position; }