Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disable heaters if a specified mcu is connected #425

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ See the [Danger Features document](https://dangerklipper.io/Danger_Features.html

- [danger_options: configurable homing constants](https://github.com/DangerKlippers/danger-klipper/pull/378)

- [adxl: disable heaters when connected](https://github.com/DangerKlippers/danger-klipper/pull/425)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the message needs improving


If you're feeling adventurous, take a peek at the extra features in the bleeding-edge-v2 branch [feature documentation](docs/Bleeding_Edge.md)
and [feature configuration reference](docs/Config_Reference_Bleeding_Edge.md):

Expand Down
6 changes: 5 additions & 1 deletion docs/Config_Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,9 @@ per_move_pressure_advance: False
# If true, uses pressure advance constant from trapq when processing moves
# This causes changes to pressure advance be taken into account immediately,
# for all moves in the current queue, rather than ~250ms later once the queue gets flushed
#disable_if_connected:
# List of mcus that should disable the heater if connected, usefull for nozzle adxls
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo in useful

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops

# as to not accidentally fry them due to heating the hotend.
```

### [heater_bed]
Expand All @@ -1107,6 +1109,7 @@ sensor_pin:
control:
min_temp:
max_temp:
disable_if_connected:
# See the "extruder" section for a description of the above parameters.
```

Expand Down Expand Up @@ -2920,6 +2923,7 @@ target temperature.
#pwm_cycle_time:
#min_temp:
#max_temp:
#disable_if_connected:
# See the "extruder" section for the definition of the above
# parameters.
```
Expand Down
21 changes: 21 additions & 0 deletions klippy/extras/heaters.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ def __init__(self, config, sensor):
self.printer.get_start_args().get("debugoutput") is not None
)
self.can_extrude = self.min_extrude_temp <= 0.0 or is_fileoutput
self.disable_if_connected = []
if hasattr(config, "getlist"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the hasattr()?

Copy link
Contributor Author

@Zeanon Zeanon Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cause some dummy configs don't have that attribute and I ran into issues without it in the older version
Probably not needed anymore since we are now checking in heaters and not adxl

self.disable_if_connected = config.getlist(
"disable_if_connected", self.disable_if_connected
)
self.max_power = config.getfloat(
"max_power", 1.0, above=0.0, maxval=1.0
)
Expand Down Expand Up @@ -130,6 +135,12 @@ def __init__(self, config, sensor):
"klippy:shutdown", self._handle_shutdown
)

def notify_disabled(self, mcu_name):
raise self.printer.command_error(
"Heater [%s] is disabled due to [%s] being connected."
% (self.short_name, mcu_name)
)

def lookup_control(self, profile, load_clean=False):
algos = collections.OrderedDict(
{
Expand Down Expand Up @@ -1102,6 +1113,16 @@ def check(eventtime):
self.printer.wait_while(check)

def set_temperature(self, heater, temp, wait=False):
for mcu_name in heater.disable_if_connected:
if not mcu_name.startswith("mcu"):
mcu_name = "mcu " + mcu_name
mcu_object = self.printer.lookup_object(mcu_name, None)
if (
mcu_object is not None
and not mcu_object.non_critical_disconnected
):
heater.notify_disabled(mcu_name)
return
toolhead = self.printer.lookup_object("toolhead")
toolhead.register_lookahead_callback((lambda pt: None))
heater.set_temp(temp)
Expand Down
1 change: 1 addition & 0 deletions test/klippy/input_shaper.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pid_Ki: 1.08
pid_Kd: 114
min_temp: 0
max_temp: 210
disable_if_connected: mcu

[heater_bed]
heater_pin: PH5
Expand Down
Loading