diff --git a/klippy/chelper/msgblock.c b/klippy/chelper/msgblock.c index e6cb298b4..a7385c893 100644 --- a/klippy/chelper/msgblock.c +++ b/klippy/chelper/msgblock.c @@ -207,3 +207,14 @@ clock_from_time(struct clock_estimate *ce, double time) { return (int64_t)((time - ce->conv_time)*ce->est_freq + .5) + ce->conv_clock; } + +// Fill the fields of a 'struct clock_estimate' +void +clock_fill(struct clock_estimate *ce, double est_freq, double conv_time + , uint64_t conv_clock, uint64_t last_clock) +{ + ce->est_freq = est_freq; + ce->conv_time = conv_time; + ce->conv_clock = conv_clock; + ce->last_clock = last_clock; +} diff --git a/klippy/chelper/msgblock.h b/klippy/chelper/msgblock.h index 43ee95325..9bb066313 100644 --- a/klippy/chelper/msgblock.h +++ b/klippy/chelper/msgblock.h @@ -50,5 +50,7 @@ void message_queue_free(struct list_head *root); uint64_t clock_from_clock32(struct clock_estimate *ce, uint32_t clock32); double clock_to_time(struct clock_estimate *ce, uint64_t clock); uint64_t clock_from_time(struct clock_estimate *ce, double time); +void clock_fill(struct clock_estimate *ce, double est_freq, double conv_time + , uint64_t conv_clock, uint64_t last_clock); #endif // msgblock.h diff --git a/klippy/chelper/serialqueue.c b/klippy/chelper/serialqueue.c index ed1215df9..914d4c395 100644 --- a/klippy/chelper/serialqueue.c +++ b/klippy/chelper/serialqueue.c @@ -909,10 +909,7 @@ serialqueue_set_clock_est(struct serialqueue *sq, double est_freq , uint64_t last_clock) { pthread_mutex_lock(&sq->lock); - sq->ce.est_freq = est_freq; - sq->ce.conv_time = conv_time; - sq->ce.conv_clock = conv_clock; - sq->ce.last_clock = last_clock; + clock_fill(&sq->ce, est_freq, conv_time, conv_clock, last_clock); pthread_mutex_unlock(&sq->lock); }