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

Also expose temperature_fan and temperature_sensor #201

Merged
merged 6 commits into from
Apr 10, 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
5 changes: 5 additions & 0 deletions klippy/extras/temperature_fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ def get_status(self, eventtime):
status["target"] = self.target_temp
return status

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_TEMPERATURE_FAN_TARGET_help = (
"Sets a temperature fan target and fan speed limits"
)
Expand Down
5 changes: 5 additions & 0 deletions klippy/extras/temperature_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ def get_status(self, eventtime):
"measured_max_temp": round(self.measured_max, 2),
}

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


def load_config_prefix(config):
return PrinterSensorGeneric(config)
24 changes: 22 additions & 2 deletions klippy/mcu.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,8 +813,8 @@ def _handle_shutdown(self, params):
append_msgs = []
if (
msg.startswith("ADC out of range")
and not get_danger_options.adc_ignore_limits
):
or msg.startswith("Thermocouple reader fault")
) and not get_danger_options.adc_ignore_limits:
pheaters = self._printer.lookup_object("heaters")
heaters = [
pheaters.lookup_heater(n) for n in pheaters.available_heaters
Expand All @@ -829,6 +829,25 @@ def _handle_shutdown(self, params):
"max_temp": heater.max_temp,
}
)
sensor_names = [
sensor
for sensor in self._printer.objects
if (
sensor.startswith("temperature_sensor")
or sensor.startswith("temperature_fan")
)
]
for sensor_name in sensor_names:
sensor = self._printer.lookup_object(sensor_name)
if sensor.is_adc_faulty():
append_msgs.append(
{
sensor_name.split(" ")[0]: sensor.name,
"last_temp": "{:.2f}".format(sensor.last_temp),
"min_temp": sensor.min_temp,
"max_temp": sensor.max_temp,
}
)

self._printer.invoke_async_shutdown(
prefix + msg + error_help(msg=msg, append_msgs=append_msgs)
Expand Down Expand Up @@ -1328,6 +1347,7 @@ def stats(self, eventtime):
communication failure between micro-controller and host.""",
(
"ADC out of range",
"Thermocouple reader fault",
): """
This generally occurs when a heater temperature exceeds
its configured min_temp or max_temp.""",
Expand Down
Loading