mirror of
https://github.com/Klipper3d/klipper.git
synced 2026-02-07 16:50:54 -07:00
trigger_analog: Attach trigger_analog to sensor during initialization
Avoid setting up a "connect" callback - just register the association using mcu.add_config_cmd() . Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
5bd791d96e
commit
87c8b505a7
3 changed files with 11 additions and 18 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue