Skip to content

Commit

Permalink
添加log,不修改调整频率
Browse files Browse the repository at this point in the history
  • Loading branch information
GuoGeTiertime committed Dec 15, 2023
1 parent cccaddf commit 7340413
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions klippy/clocksync.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ def stats(self, eventtime):
def calibrate_clock(self, print_time, eventtime):
# Calculate: est_print_time = main_sync.estimatated_print_time()
ser_time, ser_clock, ser_freq = self.main_sync.clock_est
estSerTime = ser_clock / ser_freq
main_mcu_freq = self.main_sync.mcu_freq
est_main_clock = (eventtime - ser_time) * ser_freq + ser_clock
est_print_time = est_main_clock / main_mcu_freq
Expand Down Expand Up @@ -231,10 +232,10 @@ def calibrate_clock(self, print_time, eventtime):
# adjusted_freq = limit(adjusted_freq, freq - maxFreqErr, freq + maxFreqErr)
maxFreq = freq + maxFreqErr
minFreq = freq - maxFreqErr
if adjusted_freq > maxFreq :
adjusted_freq = maxFreq
elif adjusted_freq < minFreq :
adjusted_freq = minFreq
# if adjusted_freq > maxFreq :
# adjusted_freq = maxFreq
# elif adjusted_freq < minFreq :
# adjusted_freq = minFreq

# adjusted_freq = sync2_clock / sync2_print_time
adjusted_offset = sync1_print_time - sync1_clock / adjusted_freq
Expand All @@ -250,8 +251,8 @@ def calibrate_clock(self, print_time, eventtime):
self.clock_adj = (adjusted_offset, adjusted_freq)
self.last_sync_time = sync2_print_time
logging.info(" *** Sync clock by Second clock sync. print time: %.3f @ event time: %.3f, adj off: %.3f, freq: %.3f", print_time, eventtime, adjusted_offset, adjusted_freq)
if abs(adjusted_offset) > 0.020 :
logging.info("ser_time:%.3f, ser_clock:%.3f, ser_freq:%.3f", ser_time, ser_clock, ser_freq )
if abs(adjusted_offset) > 0.010 :
logging.info("ser_time:%.3f, ser_clock:%.3f, ser_freq:%.3f, estSerTime:%.3f", ser_time, ser_clock, ser_freq, estSerTime )
logging.info("est_main_clock:%.3f, est_print_time:%.3f, sync1_print_time:%.3f, sync2_print_time:%.3f, timeDiff: %.3f", est_main_clock, est_print_time, sync1_print_time, sync2_print_time, printTimeDiff )
logging.info("sync2_main_clock:%.3f, sync2_sys_time:%.3f, sync1_clock:%.3f, sync2_clock:%.3f, syncClock_TimeDiff:%.3f", sync2_main_clock, sync2_sys_time, sync1_clock, sync2_clock, syncTimeDiff )
logging.info("child mcu - sample_time:%.3f, clock:%.3f, freq:%.3f", sample_time, clock, freq )
Expand Down

0 comments on commit 7340413

Please sign in to comment.