diff --git a/klippy/extras/ads1220.py b/klippy/extras/ads1220.py index fda584ac3..809c44435 100644 --- a/klippy/extras/ads1220.py +++ b/klippy/extras/ads1220.py @@ -96,7 +96,6 @@ class ADS1220: self.printer, self._process_batch, self._start_measurements, self._finish_measurements, UPDATE_INTERVAL) # Command Configuration - self.attach_probe_cmd = None mcu.add_config_cmd( "config_ads1220 oid=%d spi_oid=%d data_ready_pin=%s" % (self.oid, self.spi.get_oid(), self.data_ready_pin)) @@ -105,12 +104,15 @@ class ADS1220: mcu.register_config_callback(self._build_config) self.query_ads1220_cmd = None + def setup_trigger_analog(self, trigger_analog_oid): + self.mcu.add_config_cmd( + "ads1220_attach_trigger_analog oid=%d trigger_analog_oid=%d" + % (self.oid, trigger_analog_oid), is_init=True) + def _build_config(self): cmdqueue = self.spi.get_command_queue() self.query_ads1220_cmd = self.mcu.lookup_command( "query_ads1220 oid=%c rest_ticks=%u", cq=cmdqueue) - self.attach_probe_cmd = self.mcu.lookup_command( - "ads1220_attach_trigger_analog oid=%c trigger_analog_oid=%c") self.ffreader.setup_query_command("query_ads1220_status oid=%c", oid=self.oid, cq=cmdqueue) @@ -129,9 +131,6 @@ class ADS1220: def add_client(self, callback): self.batch_bulk.add_client(callback) - def attach_trigger_analog(self, trigger_analog_oid): - self.attach_probe_cmd.send([self.oid, trigger_analog_oid]) - # Measurement decoding def _convert_samples(self, samples): adc_factor = 1. / (1 << 23) diff --git a/klippy/extras/hx71x.py b/klippy/extras/hx71x.py index f0d904a89..e9d7bf605 100644 --- a/klippy/extras/hx71x.py +++ b/klippy/extras/hx71x.py @@ -53,7 +53,6 @@ class HX71xBase: self._finish_measurements, UPDATE_INTERVAL) # Command Configuration self.query_hx71x_cmd = None - self.attach_probe_cmd = None mcu.add_config_cmd( "config_hx71x oid=%d gain_channel=%d dout_pin=%s sclk_pin=%s" % (self.oid, self.gain_channel, self.dout_pin, self.sclk_pin)) @@ -62,13 +61,15 @@ class HX71xBase: mcu.register_config_callback(self._build_config) + def setup_trigger_analog(self, trigger_analog_oid): + self.mcu.add_config_cmd( + "hx71x_attach_trigger_analog oid=%d trigger_analog_oid=%d" + % (self.oid, trigger_analog_oid), is_init=True) + def _build_config(self): cmd_queue = self.mcu.alloc_command_queue() self.query_hx71x_cmd = self.mcu.lookup_command( "query_hx71x oid=%c rest_ticks=%u", cq=cmd_queue) - self.attach_probe_cmd = self.mcu.lookup_command( - "hx71x_attach_trigger_analog oid=%c trigger_analog_oid=%c", - cq=cmd_queue) self.ffreader.setup_query_command("query_hx71x_status oid=%c", oid=self.oid, cq=cmd_queue) @@ -88,9 +89,6 @@ class HX71xBase: def add_client(self, callback): self.batch_bulk.add_client(callback) - def attach_trigger_analog(self, trigger_analog_oid): - self.attach_probe_cmd.send([self.oid, trigger_analog_oid]) - # Measurement decoding def _convert_samples(self, samples): adc_factor = 1. / (1 << 23) diff --git a/klippy/extras/trigger_analog.py b/klippy/extras/trigger_analog.py index 78c4e7c70..4e149cdf0 100644 --- a/klippy/extras/trigger_analog.py +++ b/klippy/extras/trigger_analog.py @@ -238,12 +238,12 @@ class MCU_trigger_analog: self._last_trigger_time = 0. self._home_cmd = self._query_cmd = self._set_range_cmd = None self._mcu.register_config_callback(self._build_config) - self._printer.register_event_handler("klippy:connect", self._on_connect) def setup_sos_filter(self, sos_filter): self._sos_filter = sos_filter def _build_config(self): + self._sensor.setup_trigger_analog(self._oid) cmd_queue = self._dispatch.get_command_queue() if self._sos_filter is None: self.setup_sos_filter(MCU_SosFilter(self._mcu, cmd_queue, 0, 0)) @@ -263,10 +263,6 @@ class MCU_trigger_analog: " error_reason=%c clock=%u rest_ticks=%u timeout=%u", cq=cmd_queue) - # the sensor data stream is connected on the MCU at the ready event - def _on_connect(self): - self._sensor.attach_trigger_analog(self._oid) - def get_oid(self): return self._oid