mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-07-14 18:28:00 -06:00
pins: Support registering arbitrary chips that supply configurable pins
Allow multiple chips to provide pin mappings (not just the main mcu chip). Move the pin parsing from the mcu.py code to pins.py and support mapping from pin descriptions to their corresponding chips and parameters. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
268834e4ae
commit
ec7990796a
6 changed files with 166 additions and 100 deletions
|
@ -3,8 +3,7 @@
|
|||
# Copyright (C) 2016,2017 Kevin O'Connor <kevin@koconnor.net>
|
||||
#
|
||||
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||
|
||||
import extruder
|
||||
import extruder, pins
|
||||
|
||||
FAN_MIN_TIME = 0.1
|
||||
PWM_CYCLE_TIME = 0.010
|
||||
|
@ -15,9 +14,10 @@ class PrinterFan:
|
|||
self.last_fan_time = 0.
|
||||
self.max_power = config.getfloat('max_power', 1., above=0., maxval=1.)
|
||||
self.kick_start_time = config.getfloat('kick_start_time', 0.1, minval=0.)
|
||||
pin = config.get('pin')
|
||||
hard_pwm = config.getint('hard_pwm', 0)
|
||||
self.mcu_fan = printer.mcu.create_pwm(pin, PWM_CYCLE_TIME, hard_pwm, 0.)
|
||||
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))
|
||||
def set_pwm(self, mcu_time, value):
|
||||
value = max(0., min(self.max_power, value))
|
||||
if value == self.last_fan_value:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue