aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/heater.py
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2016-11-30 15:50:28 -0500
committerKevin O'Connor <kevin@koconnor.net>2016-11-30 21:19:44 -0500
commit2f97b2d7c250d4612654824633122b63d917a937 (patch)
treec43f5cb774c3c0e27349161826b8da8ff08857e7 /klippy/heater.py
parent57244de37d6b4e2247c09803d06728daacfdaa48 (diff)
downloadkutter-2f97b2d7c250d4612654824633122b63d917a937.tar.gz
kutter-2f97b2d7c250d4612654824633122b63d917a937.tar.xz
kutter-2f97b2d7c250d4612654824633122b63d917a937.zip
klippy: Add ConfigWrapper.getchoice method
Add helper function that ensures a config option is one of several choices. This helps ensure that a proper error is raised if an invalid choice is made. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/heater.py')
-rw-r--r--klippy/heater.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/klippy/heater.py b/klippy/heater.py
index 827ba324..a7522368 100644
--- a/klippy/heater.py
+++ b/klippy/heater.py
@@ -26,7 +26,7 @@ class PrinterHeater:
self.printer = printer
self.config = config
self.mcu_pwm = self.mcu_adc = None
- self.thermistor_c = Thermistors.get(config.get('thermistor_type'))
+ self.thermistor_c = config.getchoice('thermistor_type', Thermistors)
self.pullup_r = config.getfloat('pullup_resistor', 4700.)
self.min_extrude_temp = config.getfloat('min_extrude_temp', 170.)
self.can_extrude = (self.min_extrude_temp <= 0.)
@@ -48,9 +48,8 @@ class PrinterHeater:
self.mcu_adc.set_minmax(
SAMPLE_TIME, SAMPLE_COUNT, minval=min_adc, maxval=max_adc)
self.mcu_adc.set_adc_callback(REPORT_TIME, self.adc_callback)
- control_algo = self.config.get('control', 'watermark')
algos = {'watermark': ControlBangBang, 'pid': ControlPID}
- self.control = algos[control_algo](self, self.config)
+ self.control = self.config.getchoice('control', algos)(self, self.config)
if self.printer.mcu.is_fileoutput():
self.can_extrude = True
def set_pwm(self, read_time, value):