diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2017-01-10 18:36:43 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2017-01-10 18:36:43 -0500 |
commit | 4ea091339ed98ccf4df2341abef41c67460a40c6 (patch) | |
tree | 3d466d5bd42cb1e0e83af3889cb0a754b07ab008 | |
parent | 8378b7345bf976d6597b297064e151ecf644141d (diff) | |
download | kutter-4ea091339ed98ccf4df2341abef41c67460a40c6.tar.gz kutter-4ea091339ed98ccf4df2341abef41c67460a40c6.tar.xz kutter-4ea091339ed98ccf4df2341abef41c67460a40c6.zip |
heater: Only create a soft PWM object for PID heaters
The "watermark" style heater only needs a digital_out pin - not a
software PWM pin.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r-- | klippy/heater.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/klippy/heater.py b/klippy/heater.py index 0249b75b..5addfaca 100644 --- a/klippy/heater.py +++ b/klippy/heater.py @@ -39,17 +39,23 @@ class PrinterHeater: self.next_pwm_time = 0. self.last_pwm_value = 0 def build_config(self): + algos = {'watermark': ControlBangBang, 'pid': ControlPID} + algo = self.config.getchoice('control', algos) heater_pin = self.config.get('heater_pin') thermistor_pin = self.config.get('thermistor_pin') - self.mcu_pwm = self.printer.mcu.create_pwm(heater_pin, 0, MAX_HEAT_TIME) + if algo is ControlBangBang: + self.mcu_pwm = self.printer.mcu.create_digital_out( + heater_pin, MAX_HEAT_TIME) + else: + self.mcu_pwm = self.printer.mcu.create_pwm( + heater_pin, 0, MAX_HEAT_TIME) self.mcu_adc = self.printer.mcu.create_adc(thermistor_pin) min_adc = self.calc_adc(self.config.getfloat('max_temp')) max_adc = self.calc_adc(self.config.getfloat('min_temp')) 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) - algos = {'watermark': ControlBangBang, 'pid': ControlPID} - self.control = self.config.getchoice('control', algos)(self, self.config) + self.control = algo(self, self.config) if self.printer.mcu.is_fileoutput(): self.can_extrude = True def set_pwm(self, read_time, value): |