aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/extras
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2018-04-09 15:44:34 -0400
committerKevin O'Connor <kevin@koconnor.net>2018-04-09 15:44:34 -0400
commit6466af63131cda874fa0f2d6fa86363ca224d79d (patch)
tree38ec518ee2efa17a981c8f0559a5cf40928c9dac /klippy/extras
parentc463893a5ea1353dc3aa94169fa2398ecdd927df (diff)
downloadkutter-6466af63131cda874fa0f2d6fa86363ca224d79d.tar.gz
kutter-6466af63131cda874fa0f2d6fa86363ca224d79d.tar.xz
kutter-6466af63131cda874fa0f2d6fa86363ca224d79d.zip
adc_temperature: Support defining custom sensors in the config file
Allow the user to define a custom sensor with their own set of temperature/voltage measurements. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/extras')
-rw-r--r--klippy/extras/adc_temperature.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/klippy/extras/adc_temperature.py b/klippy/extras/adc_temperature.py
index 4072f18f..31c1ecce 100644
--- a/klippy/extras/adc_temperature.py
+++ b/klippy/extras/adc_temperature.py
@@ -72,6 +72,20 @@ class Linear:
gain, offset = self.slope_samples[pos]
return (temp - offset) / gain
+# Custom defined sensors from the config file
+class CustomLinear:
+ def __init__(self, config):
+ self.name = " ".join(config.get_name().split()[1:])
+ self.params = []
+ for i in range(1, 1000):
+ t = config.getfloat("temperature%d" % (i,), None)
+ if t is None:
+ break
+ v = config.getfloat("voltage%d" % (i,))
+ self.params.append((t, v))
+ def create(self, config):
+ return Linear(config, self.params)
+
AD595 = [
(0., .0027), (10., .101), (20., .200), (25., .250), (30., .300), (40., .401),
(50., .503), (60., .605), (80., .810), (100., 1.015), (120., 1.219),
@@ -99,3 +113,8 @@ def load_config(config):
for sensor_type, params in [("AD595", AD595), ("PT100 INA826", PT100)]:
func = (lambda config, params=params: Linear(config, params))
pheater.add_sensor(sensor_type, func)
+
+def load_config_prefix(config):
+ linear = CustomLinear(config)
+ pheater = config.get_printer().lookup_object("heater")
+ pheater.add_sensor(linear.name, linear.create)