heater: Handle case where min adc value is less than max adc value
When using a sensor that isn't a thermisistor, the maximum and minimum adc values may be swapped - handle that case. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
d21b9280f0
commit
4388a294a4
|
@ -52,10 +52,9 @@ class PrinterHeater:
|
||||||
self.mcu_pwm = printer.mcu.create_pwm(
|
self.mcu_pwm = printer.mcu.create_pwm(
|
||||||
heater_pin, PWM_CYCLE_TIME, 0, MAX_HEAT_TIME)
|
heater_pin, PWM_CYCLE_TIME, 0, MAX_HEAT_TIME)
|
||||||
self.mcu_adc = printer.mcu.create_adc(thermistor_pin)
|
self.mcu_adc = printer.mcu.create_adc(thermistor_pin)
|
||||||
min_adc = self.calc_adc(self.max_temp)
|
adc_range = [self.calc_adc(self.min_temp), self.calc_adc(self.max_temp)]
|
||||||
max_adc = self.calc_adc(self.min_temp)
|
self.mcu_adc.set_minmax(SAMPLE_TIME, SAMPLE_COUNT,
|
||||||
self.mcu_adc.set_minmax(
|
minval=min(adc_range), maxval=max(adc_range))
|
||||||
SAMPLE_TIME, SAMPLE_COUNT, minval=min_adc, maxval=max_adc)
|
|
||||||
self.mcu_adc.set_adc_callback(REPORT_TIME, self.adc_callback)
|
self.mcu_adc.set_adc_callback(REPORT_TIME, self.adc_callback)
|
||||||
self.control = algo(self, config)
|
self.control = algo(self, config)
|
||||||
# pwm caching
|
# pwm caching
|
||||||
|
|
Loading…
Reference in New Issue