sensor_hx71x: Update Sensors to report to load_cell_probe

Signed-off-by: Gareth Farrington <gareth@waves.ky>
This commit is contained in:
Gareth Farrington
2024-06-15 19:10:08 -07:00
committed by Kevin O'Connor
parent 42c9031c81
commit 69507a0354
4 changed files with 45 additions and 0 deletions

View File

@@ -53,6 +53,7 @@ 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))
@@ -64,10 +65,13 @@ class HX71xBase:
def _build_config(self):
self.query_hx71x_cmd = self.mcu.lookup_command(
"query_hx71x oid=%c rest_ticks=%u")
self.attach_probe_cmd = self.mcu.lookup_command(
"hx71x_attach_load_cell_probe oid=%c load_cell_probe_oid=%c")
self.ffreader.setup_query_command("query_hx71x_status oid=%c",
oid=self.oid,
cq=self.mcu.alloc_command_queue())
def get_mcu(self):
return self.mcu
@@ -83,6 +87,9 @@ class HX71xBase:
def add_client(self, callback):
self.batch_bulk.add_client(callback)
def attach_load_cell_probe(self, load_cell_probe_oid):
self.attach_probe_cmd.send([self.oid, load_cell_probe_oid])
# Measurement decoding
def _convert_samples(self, samples):
adc_factor = 1. / (1 << 23)