fan: Clarify hardware_pwm and allow cycle_time to be set on software pwm

Specify hardware pwm cycle times using the same method as software pwm
(in seconds, not clock ticks).  Allow the fan code to be configured
with an explicit cycle time even when using software pwm.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2018-01-29 12:54:06 -05:00
parent b7b216af7f
commit 21df21b7af
9 changed files with 46 additions and 51 deletions

View file

@ -25,12 +25,9 @@ class PrinterPin:
self.is_pwm = 'pwm' in config.get_name().split()[0]
if self.is_pwm:
self.mcu_pin = pins.setup_pin(printer, 'pwm', config.get('pin'))
hard_pwm = config.getint('hard_pwm', None, minval=1)
if hard_pwm is None:
self.mcu_pin.setup_cycle_time(config.getfloat(
'cycle_time', 0.100, above=0.))
else:
self.mcu_pin.setup_hard_pwm(hard_pwm)
cycle_time = config.getfloat('cycle_time', 0.100, above=0.)
hardware_pwm = config.getboolean('hardware_pwm', False)
self.mcu_pin.setup_cycle_time(cycle_time, hardware_pwm)
self.scale = config.getfloat('scale', 1., above=0.)
else:
self.mcu_pin = pins.setup_pin(