aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/extras/load_cell.py
diff options
context:
space:
mode:
authorGareth Farrington <gareth@waves.ky>2024-06-02 22:31:28 -0700
committerKevin O'Connor <kevin@koconnor.net>2024-07-31 21:22:06 -0400
commitc0095812ff18687ed25ce0f1ed468ebed8f81cfe (patch)
treecb57572e351128f439789306f2b9b99bb7ccba65 /klippy/extras/load_cell.py
parent0844388d70f225f6458382c1c5d4e7eb37767758 (diff)
downloadkutter-c0095812ff18687ed25ce0f1ed468ebed8f81cfe.tar.gz
kutter-c0095812ff18687ed25ce0f1ed468ebed8f81cfe.tar.xz
kutter-c0095812ff18687ed25ce0f1ed468ebed8f81cfe.zip
hx71x: Load Cell Skeleton and HX71x bulk ADC
* Create the load_cell host module skeleton to create the sensors and start taking samples. * Add support for the HX717 and HX711 ADC sensors. Signed-off-by: Gareth Farrington <gareth@waves.ky>
Diffstat (limited to 'klippy/extras/load_cell.py')
-rw-r--r--klippy/extras/load_cell.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/klippy/extras/load_cell.py b/klippy/extras/load_cell.py
new file mode 100644
index 00000000..7210f230
--- /dev/null
+++ b/klippy/extras/load_cell.py
@@ -0,0 +1,36 @@
+# Load Cell Implementation
+#
+# Copyright (C) 2024 Gareth Farrington <gareth@waves.ky>
+#
+# This file may be distributed under the terms of the GNU GPLv3 license.
+from . import hx71x
+
+# Printer class that controls a load cell
+class LoadCell:
+ def __init__(self, config, sensor):
+ self.printer = printer = config.get_printer()
+ self.sensor = sensor # must implement BulkAdcSensor
+ # startup, when klippy is ready, start capturing data
+ printer.register_event_handler("klippy:ready", self._handle_ready)
+
+ def _handle_ready(self):
+ self.sensor.add_client(self._on_sample)
+
+ def _on_sample(self, msg):
+ return True
+
+ def get_sensor(self):
+ return self.sensor
+
+ def get_status(self, eventtime):
+ return {}
+
+def load_config(config):
+ # Sensor types
+ sensors = {}
+ sensors.update(hx71x.HX71X_SENSOR_TYPES)
+ sensor_class = config.getchoice('sensor_type', sensors)
+ return LoadCell(config, sensor_class(config))
+
+def load_config_prefix(config):
+ return load_config(config)