From 77add9567555f395eac7b12df96fb830fe08d46c Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Mon, 14 Dec 2020 02:08:16 +0100 Subject: [PATCH] heaters: add last pwm value to heater.get_status (#3621) Signed-off-by: Stefan Dej --- docs/Command_Templates.md | 2 ++ klippy/extras/heaters.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/Command_Templates.md b/docs/Command_Templates.md index 979c4b85..64fdacc9 100644 --- a/docs/Command_Templates.md +++ b/docs/Command_Templates.md @@ -166,6 +166,8 @@ The following are common printer attributes: `. - `printer..target`: The current target temperature (in Celsius as a float) for the given heater. +- `printer..power`: The last setting of the PWM pin (a value + between 0.0 and 1.0) associated with the heater. - `printer.idle_timeout.state`: The current state of the printer as tracked by the idle_timeout module. It is one of the following strings: "Idle", "Printing", "Ready". diff --git a/klippy/extras/heaters.py b/klippy/extras/heaters.py index 7dca5fd4..cd426f30 100644 --- a/klippy/extras/heaters.py +++ b/klippy/extras/heaters.py @@ -135,7 +135,9 @@ class Heater: with self.lock: target_temp = self.target_temp smoothed_temp = self.smoothed_temp - return {'temperature': smoothed_temp, 'target': target_temp} + last_pwm_value = self.last_pwm_value + return {'temperature': smoothed_temp, 'target': target_temp, + 'power': last_pwm_value} cmd_SET_HEATER_TEMPERATURE_help = "Sets a heater temperature" def cmd_SET_HEATER_TEMPERATURE(self, gcmd): temp = gcmd.get_float('TARGET', 0.)