Skip to content

Commit

Permalink
adc out of range: expose heater out of min/max (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerlz authored Mar 30, 2024
1 parent 5bce0b5 commit 3405a4c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ If I want my printer to light itself on fire, I should be able to make my printe

- [heater: PID-Profiles](https://github.com/DangerKlippers/danger-klipper/pull/162)

- [heater: expose heater thermistor out of min/max](https://github.com/DangerKlippers/danger-klipper/pull/182)

- [gcode: jinja2.ext.do extension](https://github.com/DangerKlippers/danger-klipper/pull/26) ([klipper#5149](https://github.com/Klipper3d/klipper/pull/5149))

- [gcode: gcode_shell_command](https://github.com/DangerKlippers/danger-klipper/pull/26) ([klipper#2173](https://github.com/Klipper3d/klipper/pull/2173) / [kiuah](https://github.com/dw-0/kiauh/blob/master/resources/gcode_shell_command.py) )
Expand Down
5 changes: 5 additions & 0 deletions klippy/extras/heaters.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ def get_status(self, eventtime):
"pid_profile": self.get_control().get_profile()["name"],
}

def is_adc_faulty(self):
if self.last_temp > self.max_temp or self.last_temp < self.min_temp:
return True
return False

cmd_SET_HEATER_TEMPERATURE_help = "Sets a heater temperature"

def cmd_SET_HEATER_TEMPERATURE(self, gcmd):
Expand Down
38 changes: 36 additions & 2 deletions klippy/mcu.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,30 @@ def _handle_shutdown(self, params):
prefix = "MCU '%s' shutdown: " % (self._name,)
if params["#name"] == "is_shutdown":
prefix = "Previous MCU '%s' shutdown: " % (self._name,)
self._printer.invoke_async_shutdown(prefix + msg + error_help(msg))

append_msgs = []
if (
msg.startswith("ADC out of range")
and not self.danger_options.adc_ignore_limits
):
pheaters = self._printer.lookup_object("heaters")
heaters = [
pheaters.lookup_heater(n) for n in pheaters.available_heaters
]
for heater in heaters:
if heater.is_adc_faulty():
append_msgs.append(
{
"heater": heater.name,
"last_temp": "{:.2f}".format(heater.last_temp),
"min_temp": heater.min_temp,
"max_temp": heater.max_temp,
}
)

self._printer.invoke_async_shutdown(
prefix + msg + error_help(msg=msg, append_msgs=append_msgs)
)

def _handle_starting(self, params):
if not self._is_shutdown:
Expand Down Expand Up @@ -1304,10 +1327,21 @@ def stats(self, eventtime):
}


def error_help(msg):
def error_help(msg, append_msgs=[]):
for prefixes, help_msg in Common_MCU_errors.items():
for prefix in prefixes:
if msg.startswith(prefix):
if append_msgs:
for append in append_msgs:
line = append
if isinstance(append, dict):
line = ", ".join(
[
f"{str(k)}: {str(v)}"
for k, v in append.items()
]
)
help_msg = "\n".join([help_msg, str(line)])
return help_msg
return ""

Expand Down

0 comments on commit 3405a4c

Please sign in to comment.