load_cell: Only launch a callback in the klippy:ready event handler

It is not valid to pause in the klippy:ready callback, so perform the
sensor startup process in a separate reactor task.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor
2025-10-06 21:48:44 -04:00
parent 0e7e908af4
commit e549cc4143

View File

@@ -383,7 +383,7 @@ class LoadCell:
# startup, when klippy is ready, start capturing data
printer.register_event_handler("klippy:ready", self._handle_ready)
def _handle_ready(self):
def _handle_do_ready(self, eventtime):
self.sensor.add_client(self._sensor_data_event)
self.add_client(self._track_force)
# announce calibration status on ready
@@ -391,6 +391,8 @@ class LoadCell:
self.printer.send_event("load_cell:calibrate", self)
if self.is_tared():
self.printer.send_event("load_cell:tare", self)
def _handle_ready(self):
self.printer.get_reactor().register_callback(self._handle_do_ready)
# convert raw counts to grams and broadcast to clients
def _sensor_data_event(self, msg):