From 9d10d3e277f203d3d27271acc50f0753f2e2629e Mon Sep 17 00:00:00 2001 From: Reijii Date: Thu, 3 Jul 2025 22:33:32 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B5=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D0=BA=D0=B0=20idle,=20=D1=82=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20?= =?UTF-8?q?=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=B5=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/idle.cfg | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/Scripts/idle.cfg b/Scripts/idle.cfg index 669f67a..3d3f017 100644 --- a/Scripts/idle.cfg +++ b/Scripts/idle.cfg @@ -1,36 +1,41 @@ [idle_timeout] timeout: 120 gcode: - RESPOND MSG="Idle start" - UPDATE_DELAYED_GCODE ID=_FIRST_STAGE_IDLE DURATION={printer["gcode_macro RatOS"].idle_delay} + RESPOND MSG="Idle check" + {% if printer["gcode_macro _POWER_OFF_PRINTER"].first_stage_active|lower == 'false' %} + UPDATE_DELAYED_GCODE ID=_FIRST_STAGE_IDLE DURATION={printer["gcode_macro RatOS"].idle_delay} + RESPOND MSG="Idle start" + SET_GCODE_VARIABLE MACRO=_POWER_OFF_PRINTER VARIABLE=first_stage_active VALUE=True + {% endif %} [delayed_gcode set_idle_work] initial_duration: 1 gcode: - M119 + M119 [delayed_gcode _FIRST_STAGE_IDLE] -variable_first_stage_active: False gcode: {% if printer.idle_timeout.state == "Idle" or printer.idle_timeout.state == "Ready" %} {% if printer.heater_bed.temperature < 50.0 %} {% if printer.heater_bed.target == 0.0 %} UPDATE_DELAYED_GCODE ID=_FIRST_STAGE_IDLE DURATION=0 - {% if printer["gcode_macro _FIRST_STAGE_IDLE"].first_stage_active|lower == 'false' %} + #{% if printer["gcode_macro _FIRST_STAGE_IDLE"].first_stage_active|lower == 'false' %} {% if printer["gcode_macro RatOS"].tgbot_enabled|lower == 'true' %} RESPOND PREFIX=tgnotify MSG="Моторы погашены" {% endif %} M84 UPDATE_DELAYED_GCODE ID=_POWER_OFF_PRINTER_CHECK DURATION={printer["gcode_macro RatOS"].poweroff_delay} - SET_GCODE_VARIABLE MACRO=_FIRST_STAGE_IDLE VARIABLE=first_stage_active VALUE=True + SET_GCODE_VARIABLE MACRO=_POWER_OFF_PRINTER VARIABLE=first_stage_active VALUE=True + UPDATE_DELAYED_GCODE ID=_RESET_IDLE_VARIABLE DURATION={printer["gcode_macro RatOS"].poweroff_delay + 30} M104 S0 - {% endif %} + #{% endif %} {% else %} UPDATE_DELAYED_GCODE ID=_FIRST_STAGE_IDLE DURATION=2 {% endif %} {% else %} {% if printer.idle_timeout.state == "Printing" %} UPDATE_DELAYED_GCODE ID=_FIRST_STAGE_IDLE DURATION=0 + SET_GCODE_VARIABLE MACRO=_POWER_OFF_PRINTER VARIABLE=first_stage_active VALUE=False {% else %} {% if printer.extruder.target == 0.0 and printer.heater_bed.target == 0.0 %} UPDATE_DELAYED_GCODE ID=_FIRST_STAGE_IDLE DURATION=2 @@ -53,22 +58,31 @@ gcode: {% if printer.idle_timeout.state == "Idle" or printer.idle_timeout.state == "Ready" %} {% if printer.extruder.temperature < 50.0 and printer.heater_bed.temperature < 50.0 %} {% if printer.extruder.target == 0.0 and printer.heater_bed.target == 0.0 %} - UPDATE_DELAYED_GCODE ID=_POWER_OFF_PRINTER_CHECK DURATION=0 - {% if printer["gcode_macro RatOS"].tgbot_enabled|lower == 'true' %} - RESPOND PREFIX=tgnotify MSG="Питание принтера выключено" + {% if printer.toolhead.homed_axes|length > 0 %} + SET_GCODE_VARIABLE MACRO=_POWER_OFF_PRINTER VARIABLE=first_stage_active VALUE=False + UPDATE_DELAYED_GCODE ID=_POWER_OFF_PRINTER_CHECK DURATION=0 + M119 + {% else %} + UPDATE_DELAYED_GCODE ID=_POWER_OFF_PRINTER_CHECK DURATION=0 + {% if printer["gcode_macro RatOS"].tgbot_enabled|lower == 'true' %} + RESPOND PREFIX=tgnotify MSG="Питание принтера выключено" + {% endif %} + _POWER_OFF_PRINTER {% endif %} - _POWER_OFF_PRINTER {% else %} UPDATE_DELAYED_GCODE ID=_POWER_OFF_PRINTER_CHECK DURATION=2 {% endif %} {% else %} {% if printer.idle_timeout.state == "Printing" %} + SET_GCODE_VARIABLE MACRO=_POWER_OFF_PRINTER VARIABLE=first_stage_active VALUE=False UPDATE_DELAYED_GCODE ID=_POWER_OFF_PRINTER_CHECK DURATION=0 {% else %} {% if printer.extruder.target == 0.0 and printer.heater_bed.target == 0.0 %} UPDATE_DELAYED_GCODE ID=_POWER_OFF_PRINTER_CHECK DURATION=2 {% else %} UPDATE_DELAYED_GCODE ID=_POWER_OFF_PRINTER_CHECK DURATION=0 + SET_GCODE_VARIABLE MACRO=_POWER_OFF_PRINTER VARIABLE=first_stage_active VALUE=False + {% endif %} {% endif %} {% endif %} @@ -95,10 +109,15 @@ gcode: RESPOND PREFIX=tgnotify MSG="Вытяжка остановлена" {% endif %} +[delayed_gcode _RESET_IDLE_VARIABLE] +gcode: + SET_GCODE_VARIABLE MACRO=_POWER_OFF_PRINTER VARIABLE=first_stage_active VALUE=False + [gcode_macro _POWER_OFF_PRINTER] +variable_first_stage_active: False gcode: - SET_GCODE_VARIABLE MACRO=_FIRST_STAGE_IDLE VARIABLE=first_stage_active VALUE=False + SET_GCODE_VARIABLE MACRO=_POWER_OFF_PRINTER VARIABLE=first_stage_active VALUE=False {action_call_remote_method("set_device_power", device=printer["gcode_macro RatOS"].power_device, state="off")}