mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-10-26 07:46:11 +01:00
msgblock: Add new clock_fill() function
Add a new function for filling the fields of 'struct clock_estimate'. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user