完善断电续打是否暂停状态和当前激活挤出机变量的保存
This commit is contained in:
parent
9e9faf726d
commit
9374daaa4e
@ -57,7 +57,7 @@ pin: ^!gpiochip4/gpio19
|
||||
debounce_period: .01
|
||||
minimum_event_time: 0
|
||||
on_press:
|
||||
{% set query_objs = {"print_stats": ["state"], "gcode_move": ["gcode_position"], "virtual_sdcard": ["file_path"]} %}
|
||||
{% set query_objs = {"print_stats": ["state"], "toolhead": ["extruder"], "gcode_move": ["gcode_position"], "virtual_sdcard": ["file_path"]} %}
|
||||
{% set status = call_method("printer.objects.query", objects=query_objs) %}
|
||||
{% do call_method("printer.emergency_stop") %}
|
||||
{% set data = status | tojson | fromjson %}
|
||||
@ -67,12 +67,20 @@ on_press:
|
||||
{% set x_position = data['status']['gcode_move']['gcode_position'][0] %}
|
||||
{% set y_position = data['status']['gcode_move']['gcode_position'][1] %}
|
||||
{% set z_position = data['status']['gcode_move']['gcode_position'][2] %}
|
||||
{% set hotend = data['status']['toolhead']['extruder'] %}
|
||||
{% set filepath = data['status']['virtual_sdcard']['file_path'] %}
|
||||
{% set filename = filepath.split('/')[-1] %}
|
||||
# save position
|
||||
{% do call_method("printer.gcode.script", script="SAVE_VARIABLE VARIABLE=power_resume_x VALUE=" + x_position | string) %}
|
||||
{% do call_method("printer.gcode.script", script="SAVE_VARIABLE VARIABLE=power_resume_y VALUE=" + y_position | string) %}
|
||||
{% do call_method("printer.gcode.script", script="SAVE_VARIABLE VARIABLE=power_resume_z VALUE=" + z_position | string) %}
|
||||
{% if print_state | string == 'printing' %}
|
||||
{% do call_method("printer.gcode.script", script="SAVE_VARIABLE VARIABLE=power_resume_x VALUE=" + x_position | string) %}
|
||||
{% do call_method("printer.gcode.script", script="SAVE_VARIABLE VARIABLE=power_resume_y VALUE=" + y_position | string) %}
|
||||
{% do call_method("printer.gcode.script", script="SAVE_VARIABLE VARIABLE=power_resume_z VALUE=" + z_position | string) %}
|
||||
{% do call_method("printer.gcode.script", script="SAVE_VARIABLE VARIABLE=power_loss_paused VALUE=False") %}
|
||||
{% elif print_state | string == 'paused' %}
|
||||
{% do call_method("printer.gcode.script", script="SAVE_VARIABLE VARIABLE=power_loss_paused VALUE=True") %}
|
||||
{% endif%}
|
||||
# save extruder
|
||||
{% do call_method("printer.gcode.script", script="SAVE_VARIABLE VARIABLE=power_resume_extruder VALUE=\"'" + hotend | string + "'\"") %}
|
||||
# save file
|
||||
{% do call_method("printer.gcode.script", script="SAVE_VARIABLE VARIABLE=filepath VALUE=\"'" + filepath | string + "'\"") %}
|
||||
{% do call_method("printer.gcode.script", script="SAVE_VARIABLE VARIABLE=last_file VALUE=\"'" + filename | string + "'\"") %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user