mirror of https://github.com/Desuuuu/klipper.git
mcu: Internally store _print_start_time instead of _print_start_clock
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
e52113a319
commit
7276c7085a
|
@ -260,7 +260,7 @@ class MCU:
|
||||||
self._steppers = []
|
self._steppers = []
|
||||||
self._steppersync = None
|
self._steppersync = None
|
||||||
# Print time to clock epoch calculations
|
# Print time to clock epoch calculations
|
||||||
self._print_start_clock = 0
|
self._print_start_time = 0.
|
||||||
self._clock_freq = 0.
|
self._clock_freq = 0.
|
||||||
# Stats
|
# Stats
|
||||||
self._mcu_tick_avg = 0.
|
self._mcu_tick_avg = 0.
|
||||||
|
@ -421,12 +421,14 @@ class MCU:
|
||||||
return MCU_adc(self, pin)
|
return MCU_adc(self, pin)
|
||||||
# Clock syncing
|
# Clock syncing
|
||||||
def set_print_start_time(self, eventtime):
|
def set_print_start_time(self, eventtime):
|
||||||
self._print_start_clock = self.serial.get_clock(eventtime)
|
est_mcu_time = self.serial.get_clock(eventtime) / self._clock_freq
|
||||||
def get_print_buffer_time(self, eventtime, last_move_end):
|
self._print_start_time = est_mcu_time
|
||||||
clock_diff = self.serial.get_clock(eventtime) - self._print_start_clock
|
def get_print_buffer_time(self, eventtime, print_time):
|
||||||
return last_move_end - (float(clock_diff) / self._clock_freq)
|
mcu_time = print_time + self._print_start_time
|
||||||
|
est_mcu_time = self.serial.get_clock(eventtime) / self._clock_freq
|
||||||
|
return mcu_time - est_mcu_time
|
||||||
def print_to_mcu_time(self, print_time):
|
def print_to_mcu_time(self, print_time):
|
||||||
return print_time + self._print_start_clock / self._clock_freq
|
return print_time + self._print_start_time
|
||||||
def get_mcu_freq(self):
|
def get_mcu_freq(self):
|
||||||
return self._clock_freq
|
return self._clock_freq
|
||||||
def get_last_clock(self):
|
def get_last_clock(self):
|
||||||
|
@ -435,7 +437,8 @@ class MCU:
|
||||||
def send(self, cmd, minclock=0, reqclock=0, cq=None):
|
def send(self, cmd, minclock=0, reqclock=0, cq=None):
|
||||||
self.serial.send(cmd, minclock, reqclock, cq=cq)
|
self.serial.send(cmd, minclock, reqclock, cq=cq)
|
||||||
def flush_moves(self, print_time):
|
def flush_moves(self, print_time):
|
||||||
clock = int(print_time * self._clock_freq) + self._print_start_clock
|
mcu_time = print_time + self._print_start_time
|
||||||
|
clock = int(mcu_time * self._clock_freq)
|
||||||
self.ffi_lib.steppersync_flush(self._steppersync, clock)
|
self.ffi_lib.steppersync_flush(self._steppersync, clock)
|
||||||
|
|
||||||
|
|
||||||
|
@ -490,7 +493,7 @@ class DummyMCU:
|
||||||
def __init__(self, outfile):
|
def __init__(self, outfile):
|
||||||
self.outfile = outfile
|
self.outfile = outfile
|
||||||
self._stepid = -1
|
self._stepid = -1
|
||||||
self._print_start_clock = 0
|
self._print_start_time = 0.
|
||||||
self._clock_freq = 16000000.
|
self._clock_freq = 16000000.
|
||||||
logging.debug('Translated by klippy')
|
logging.debug('Translated by klippy')
|
||||||
def connect(self):
|
def connect(self):
|
||||||
|
@ -517,7 +520,7 @@ class DummyMCU:
|
||||||
def get_print_buffer_time(self, eventtime, last_move_end):
|
def get_print_buffer_time(self, eventtime, last_move_end):
|
||||||
return 0.250
|
return 0.250
|
||||||
def print_to_mcu_time(self, print_time):
|
def print_to_mcu_time(self, print_time):
|
||||||
return print_time + self._print_start_clock / self._clock_freq
|
return print_time + self._print_start_time
|
||||||
def get_mcu_freq(self):
|
def get_mcu_freq(self):
|
||||||
return self._clock_freq
|
return self._clock_freq
|
||||||
def flush_moves(self, print_time):
|
def flush_moves(self, print_time):
|
||||||
|
|
Loading…
Reference in New Issue