diff options
| author | Kevin O'Connor <kevin@koconnor.net> | 2016-08-25 11:24:18 -0400 |
|---|---|---|
| committer | Kevin O'Connor <kevin@koconnor.net> | 2017-03-03 20:00:16 -0500 |
| commit | f53897758da58ac0201dcfaecbedc8409d828da2 (patch) | |
| tree | 468fcbb0df87a82cd1dea2a026d612f81d46111a /klippy/mcu.py | |
| parent | 54002c43914ea7a88cb831fe16bbfb695c533f74 (diff) | |
| download | kutter-f53897758da58ac0201dcfaecbedc8409d828da2.tar.gz kutter-f53897758da58ac0201dcfaecbedc8409d828da2.tar.xz kutter-f53897758da58ac0201dcfaecbedc8409d828da2.zip | |
heater: Support max_power setting for heaters
Change the mcu PWM value from an integer (0-255) to a float (0. - 1.).
Add support for limiting the maximum power (as measured over a
sufficiently long duration) to a particular heater.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/mcu.py')
| -rw-r--r-- | klippy/mcu.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/klippy/mcu.py b/klippy/mcu.py index 83ff1fdb..129024ba 100644 --- a/klippy/mcu.py +++ b/klippy/mcu.py @@ -245,11 +245,12 @@ class MCU_digital_out: return self._last_value def set_pwm(self, mcu_time, value): dval = 0 - if value > 127: + if value >= 0.5: dval = 1 self.set_digital(mcu_time, dval) class MCU_pwm: + PWM_MAX = 255. def __init__(self, mcu, pin, cycle_ticks, max_duration, hard_pwm=True): self._mcu = mcu self._oid = mcu.create_oid() @@ -272,6 +273,7 @@ class MCU_pwm: self.print_to_mcu_time = mcu.print_to_mcu_time def set_pwm(self, mcu_time, value): clock = int(mcu_time * self._mcu_freq) + value = int(value * self.PWM_MAX + 0.5) msg = self._set_cmd.encode(self._oid, clock, value) self._mcu.send(msg, minclock=self._last_clock, reqclock=clock , cq=self._cmd_queue) |
