diff --git a/docs/Command_Templates.md b/docs/Command_Templates.md index afa390af..9e19422d 100644 --- a/docs/Command_Templates.md +++ b/docs/Command_Templates.md @@ -129,6 +129,10 @@ The following are common printer attributes: This is also available on "heater_fan", "fan_generic", and "controller_fan" config sections (eg, `printer["fan_generic my_fan"].speed`). +- `printer.fan.rpm`: The measured fan speed in rotations per minute if + the fan has a tachometer_pin defined. This is also available on + "heater_fan", "fan_generic", and "controller_fan" config sections + (eg, `printer["fan_generic my_fan"].rpm`). - `printer.gcode_move.gcode_position`: The current position of the toolhead relative to the current G-Code origin. That is, positions that one might directly send to a `G1` command. It is possible to diff --git a/klippy/extras/fan.py b/klippy/extras/fan.py index 13d9bcd7..83df80fe 100644 --- a/klippy/extras/fan.py +++ b/klippy/extras/fan.py @@ -12,7 +12,6 @@ class Fan: self.printer = config.get_printer() self.last_fan_value = 0. self.last_fan_time = 0. - self.rpm = None # Read config self.max_power = config.getfloat('max_power', 1., above=0., maxval=1.) self.kick_start_time = config.getfloat('kick_start_time', 0.1, @@ -84,8 +83,8 @@ class FanTachometer: printer, pin, sample_time, poll_time) def get_status(self, eventtime): - if self._freq_counter: - rpm = self._freq_counter.frequency * 30. / self.ppr + if self._freq_counter is not None: + rpm = self._freq_counter.get_frequency() * 30. / self.ppr else: rpm = None return {'rpm': rpm} diff --git a/klippy/extras/pulse_counter.py b/klippy/extras/pulse_counter.py index 00038f01..a952b7f8 100644 --- a/klippy/extras/pulse_counter.py +++ b/klippy/extras/pulse_counter.py @@ -74,6 +74,5 @@ class FrequencyCounter: self._callback(time, self._freq) self._last_count = count - @property - def frequency(self): + def get_frequency(self): return self._freq