Skip to content

Commit

Permalink
Move code ouf of the klippy:ready handler into a deferred callback.
Browse files Browse the repository at this point in the history
This allows using tmc_mcu without breaking the rules of klippy:ready.
  • Loading branch information
rschaeuble committed Oct 2, 2024
1 parent 489a178 commit d521ac1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions autotune_tmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,13 @@ def handle_connect(self):
self.tuning_goal = TuningGoal.SILENT if self.auto_silent else TuningGoal.PERFORMANCE
self.motor_object = self.printer.lookup_object(self.motor_name)
#self.tune_driver()

def handle_ready(self):
# klippy:ready handlers are limited in what they may do. Communicating with a MCU
# will pause the reactor and is thus forbidden. That code has to run outside of the event handler.
self.printer.reactor.register_callback(self._handle_ready_deferred)

def _handle_ready_deferred(self, eventtime):
if self.tmc_init_registers is not None:
self.tmc_init_registers(print_time=print_time)
try:
Expand Down

0 comments on commit d521ac1

Please sign in to comment.