heater: Resend PWM values even if last value was zero
Continue to resend the pwm value even if the last value was zero - this extends the debugging info. Also, add the target temperature to the pwm debugging. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
4ea091339e
commit
f335045273
|
@ -65,14 +65,15 @@ class PrinterHeater:
|
||||||
if (read_time < self.next_pwm_time
|
if (read_time < self.next_pwm_time
|
||||||
and abs(value - self.last_pwm_value) < 15):
|
and abs(value - self.last_pwm_value) < 15):
|
||||||
return
|
return
|
||||||
elif not self.last_pwm_value:
|
elif not self.last_pwm_value and (
|
||||||
|
self.target_temp <= 0. or read_time < self.next_pwm_time):
|
||||||
return
|
return
|
||||||
pwm_time = read_time + REPORT_TIME + SAMPLE_TIME*SAMPLE_COUNT
|
pwm_time = read_time + REPORT_TIME + SAMPLE_TIME*SAMPLE_COUNT
|
||||||
self.next_pwm_time = pwm_time + 0.75 * MAX_HEAT_TIME
|
self.next_pwm_time = pwm_time + 0.75 * MAX_HEAT_TIME
|
||||||
self.last_pwm_value = value
|
self.last_pwm_value = value
|
||||||
logging.debug("%s: pwm=%d@%.3f (from %.3f@%.3f)" % (
|
logging.debug("%s: pwm=%d@%.3f (from %.3f@%.3f [%.3f])" % (
|
||||||
self.config.section, value, pwm_time,
|
self.config.section, value, pwm_time,
|
||||||
self.last_temp, self.last_temp_time))
|
self.last_temp, self.last_temp_time, self.target_temp))
|
||||||
self.mcu_pwm.set_pwm(pwm_time, value)
|
self.mcu_pwm.set_pwm(pwm_time, value)
|
||||||
# Temperature calculation
|
# Temperature calculation
|
||||||
def calc_temp(self, adc):
|
def calc_temp(self, adc):
|
||||||
|
|
Loading…
Reference in New Issue