Skip to content

Commit

Permalink
fan changes for UI compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
fbeauKmi committed Nov 9, 2024
1 parent 568ae9f commit ef52588
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
6 changes: 6 additions & 0 deletions docs/Config_Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ All dates in this document are approximate.

## Changes

yyyymmdd: The `off_below` parameter in fans config section is
deprecated. It will be removed in the near future. Use
[`min_power`](./Config_Reference.md#fans)
instead. The `printer[fan object].speed` status will be replaced by
`printer[fan object].value` and `printer[fan object].power`.

20240430: The `adc_ignore_limits` parameter in the `[danger_options]`
config section has been renamed to `temp_ignore_limits` and it now
covers all possible temperature sensors.
Expand Down
3 changes: 3 additions & 0 deletions docs/Config_Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -3318,6 +3318,9 @@ pin:
# input. In such a case, the PWM pin can be used normally, and e.g. a
# ground-switched FET(standard fan pin) can be used to control power to
# the fan.
#off_below:
# These option is deprecated and should no longer be specified.
# Use `min_power` instead.
```

### [heated_fan]
Expand Down
5 changes: 4 additions & 1 deletion docs/Status_Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,12 @@ The following information is available in
[heater_fan some_name](Config_Reference.md#heater_fan) and
[controller_fan some_name](Config_Reference.md#controller_fan)
objects:
- `speed`: The fan speed as a float between 0.0 and 1.0.
- `value`: The fan speed value as a float between 0.0 and 1.0.
- `power`: The fan power as a float between 0|`min_power` and 1.0|`max_power`.
- `rpm`: The measured fan speed in rotations per minute if the fan has
a tachometer_pin defined.
deprecated objects (for UI compatibility only):
- `speed`: The fan speed as a float between 0.0 and `max_power`.

## filament_switch_sensor

Expand Down
9 changes: 8 additions & 1 deletion klippy/extras/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def __init__(self, config, default_shutdown_speed=0.0):
self.printer = config.get_printer()
self.last_fan_value = 0.0
self.last_fan_time = 0.0
self.last_pwm_value = 0.0
# Read config
self.kick_start_time = config.getfloat(
"kick_start_time", 0.1, minval=0.0
Expand All @@ -23,6 +24,9 @@ def __init__(self, config, default_shutdown_speed=0.0):
self.off_below = config.getfloat(
"off_below", default=None, minval=0.0, maxval=1.0
)
if self.off_below is not None:
config.deprecate("off_below")


# handles switchover of variable
# if new var is not set, and old var is, set new var to old var
Expand Down Expand Up @@ -111,6 +115,7 @@ def set_speed(self, print_time, value):
self.mcu_fan.set_pwm(print_time, self.max_power)
print_time += self.kick_start_time
self.mcu_fan.set_pwm(print_time, pwm_value)
self.last_pwm_value = pwm_value
self.last_fan_time = print_time
self.last_fan_value = value

Expand All @@ -126,7 +131,9 @@ def _handle_request_restart(self, print_time):
def get_status(self, eventtime):
tachometer_status = self.tachometer.get_status(eventtime)
return {
"speed": self.last_fan_value,
"power": self.last_pwm_value,
"value": self.last_fan_value,
"speed": self.last_fan_value * self.max_power,
"rpm": tachometer_status["rpm"],
}

Expand Down

0 comments on commit ef52588

Please sign in to comment.