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

adc out of range: expose heater thermistor out of min/max #182

Merged
merged 1 commit into from
Mar 30, 2024
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -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
Loading