diff --git a/README.md b/README.md index 237f30234..923bbb6d3 100644 --- a/README.md +++ b/README.md @@ -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) ) diff --git a/klippy/extras/heaters.py b/klippy/extras/heaters.py index 71aa7249b..b23d1b7e6 100644 --- a/klippy/extras/heaters.py +++ b/klippy/extras/heaters.py @@ -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): diff --git a/klippy/mcu.py b/klippy/mcu.py index 16cc33061..3c96b24c4 100644 --- a/klippy/mcu.py +++ b/klippy/mcu.py @@ -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: @@ -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 ""