diff options
Diffstat (limited to 'klippy/extras')
-rw-r--r-- | klippy/extras/fan.py | 8 | ||||
-rw-r--r-- | klippy/extras/multi_pin.py | 7 | ||||
-rw-r--r-- | klippy/extras/replicape.py | 12 |
3 files changed, 13 insertions, 14 deletions
diff --git a/klippy/extras/fan.py b/klippy/extras/fan.py index c7434ca5..7bc4a26d 100644 --- a/klippy/extras/fan.py +++ b/klippy/extras/fan.py @@ -5,8 +5,7 @@ # This file may be distributed under the terms of the GNU GPLv3 license. import pins -FAN_MIN_TIME = 0.1 -PWM_CYCLE_TIME = 0.010 +FAN_MIN_TIME = 0.100 class PrinterFan: def __init__(self, config): @@ -17,8 +16,9 @@ class PrinterFan: printer = config.get_printer() self.mcu_fan = pins.setup_pin(printer, 'pwm', config.get('pin')) self.mcu_fan.setup_max_duration(0.) - self.mcu_fan.setup_cycle_time(PWM_CYCLE_TIME) - self.mcu_fan.setup_hard_pwm(config.getint('hard_pwm', 0)) + cycle_time = config.getfloat('cycle_time', 0.010, above=0.) + hardware_pwm = config.getboolean('hardware_pwm', False) + self.mcu_fan.setup_cycle_time(cycle_time, hardware_pwm) def set_speed(self, print_time, value): value = max(0., min(self.max_power, value)) if value == self.last_fan_value: diff --git a/klippy/extras/multi_pin.py b/klippy/extras/multi_pin.py index 3e033a86..5ffaed80 100644 --- a/klippy/extras/multi_pin.py +++ b/klippy/extras/multi_pin.py @@ -40,12 +40,9 @@ class PrinterMultiPin: def setup_start_value(self, start_value, shutdown_value): for mcu_pin in self.mcu_pins: mcu_pin.setup_start_value(start_value, shutdown_value) - def setup_cycle_time(self, cycle_time): + def setup_cycle_time(self, cycle_time, hardware_pwm=False): for mcu_pin in self.mcu_pins: - mcu_pin.setup_cycle_time(cycle_time) - def setup_hard_pwm(self, hard_cycle_ticks): - for mcu_pin in self.mcu_pins: - mcu_pin.setup_hard_pwm(hard_cycle_ticks) + mcu_pin.setup_cycle_time(cycle_time, hardware_pwm) def set_digital(self, print_time, value): for mcu_pin in self.mcu_pins: mcu_pin.set_digital(print_time, value) diff --git a/klippy/extras/replicape.py b/klippy/extras/replicape.py index 72ab45e9..742607c5 100644 --- a/klippy/extras/replicape.py +++ b/klippy/extras/replicape.py @@ -3,6 +3,7 @@ # Copyright (C) 2017,2018 Kevin O'Connor <kevin@koconnor.net> # # This file may be distributed under the terms of the GNU GPLv3 license. +import logging import pins, mcu REPLICAPE_MAX_CURRENT = 3.84 @@ -37,11 +38,12 @@ class pca9685_pwm: return self._mcu def setup_max_duration(self, max_duration): self._max_duration = max_duration - def setup_cycle_time(self, cycle_time): - pass - def setup_hard_pwm(self, hard_cycle_ticks): - if hard_cycle_ticks: - raise pins.error("pca9685 does not support hard_pwm parameter") + def setup_cycle_time(self, cycle_time, hardware_pwm=False): + if hardware_pwm: + raise pins.error("pca9685 does not support hardware_pwm parameter") + if cycle_time != self._cycle_time: + logging.info("Ignoring pca9685 cycle time of %.6f (using %.6f)", + cycle_time, self._cycle_time) def setup_start_value(self, start_value, shutdown_value, is_static=False): if is_static and start_value != shutdown_value: raise pins.error("Static pin can not have shutdown value") |