Refactor 2

This commit is contained in:
2025-03-31 03:59:45 +03:00
parent 70f1e677d8
commit f14caffb3d
6 changed files with 98 additions and 0 deletions

57
Scripts/fan_monitor.cfg Normal file
View File

@@ -0,0 +1,57 @@
# Author: alch3my#9819
# Requires a 3-wire fan with tachometer_pin defined. https://www.klipper3d.org/Config_Reference.html#heater_fan
# The tach wire can be connected to a spare endstop pin.
# Don't forget a pullup (^) on the tach pin (example: tachometer_pin: ^P1.29)
##test
# Monitoring loop. Begins at Klipper start.
[delayed_gcode CHECK_ALL_FANS]
initial_duration: 1
gcode:
HOTEND_FAN_CHECK
UPDATE_DELAYED_GCODE ID=CHECK_ALL_FANS DURATION=3
# Change min_rpm and max_consecutive_stops to your desired values.
[gcode_macro HOTEND_FAN_CHECK]
variable_he_stop_count: 0
gcode:
{% set min_rpm = 2500|float %}
{% set max_consecutive_stops = 3 %}
{% set rpm = printer['heater_fan toolhead_cooling_fan'].rpm|float %}
{% set he_target = printer[printer.toolhead.extruder].target|float %}
{% set he_temp = printer[printer.toolhead.extruder].temperature|float %}
{% set fan_on_temp = printer.configfile.settings['heater_fan toolhead_cooling_fan'].heater_temp|float %}
{% set he_stop_count = printer["gcode_macro HOTEND_FAN_CHECK"].he_stop_count|int %}
{% if (he_target >= fan_on_temp) and (rpm < min_rpm) and (he_temp >= fan_on_temp) %}
SET_GCODE_VARIABLE MACRO=HOTEND_FAN_CHECK VARIABLE=he_stop_count VALUE={he_stop_count + 1}
M118 WARNING: Fan stoppage detected ({he_stop_count+1}/{max_consecutive_stops}).
{% if printer["gcode_macro RatOS"].tgbot_enabled|lower == 'true' %}
RESPOND PREFIX=tgnotify MSG="Чот вентилятор термобарьера медленный"
{% endif %}
M400
{% if printer["gcode_macro HOTEND_FAN_CHECK"].he_stop_count|int >= max_consecutive_stops-1 %}
FAN_STOPPAGE_ROUTINE
{% endif %}
{% else %}
SET_GCODE_VARIABLE MACRO=HOTEND_FAN_CHECK VARIABLE=he_stop_count VALUE=0
{% endif %}
# Insert the gcode that you want to run when a fan stoppage is detected.
# This runs every ~3 seconds until the stop conditions are cleared.
[gcode_macro FAN_STOPPAGE_ROUTINE]
gcode:
# If not already paused
{% if printer['pause_resume'].is_paused|int == 0 %}
M117 !!FAN STOPPAGE!!
{% if printer["gcode_macro RatOS"].tgbot_enabled|lower == 'true' %}
RESPOND PREFIX=tgnotify MSG="Вентилятор термобарьера сдох. PAUSING..."
{% endif %}
M118 FAN STOPPAGE DETECTED. PAUSING...
#PAUSE
# Turn off the hotend.
# !! Don't forget to turn your hotend back on before resume. !!
# -- If using this guide's pause/resume macros (in useful_macros.html), the hotend will automatically reheat on resume
# -- (as long as the hotend is not turned off BEFORE pause is called)
#SET_HEATER_TEMPERATURE HEATER=extruder TARGET=0
{% endif %}