mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-11-02 03:16:02 +01:00
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:
@@ -383,7 +383,7 @@ class LoadCell:
|
|||||||
# startup, when klippy is ready, start capturing data
|
# startup, when klippy is ready, start capturing data
|
||||||
printer.register_event_handler("klippy:ready", self._handle_ready)
|
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.sensor.add_client(self._sensor_data_event)
|
||||||
self.add_client(self._track_force)
|
self.add_client(self._track_force)
|
||||||
# announce calibration status on ready
|
# announce calibration status on ready
|
||||||
@@ -391,6 +391,8 @@ class LoadCell:
|
|||||||
self.printer.send_event("load_cell:calibrate", self)
|
self.printer.send_event("load_cell:calibrate", self)
|
||||||
if self.is_tared():
|
if self.is_tared():
|
||||||
self.printer.send_event("load_cell:tare", self)
|
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
|
# convert raw counts to grams and broadcast to clients
|
||||||
def _sensor_data_event(self, msg):
|
def _sensor_data_event(self, msg):
|
||||||
|
|||||||
Reference in New Issue
Block a user