Merge branch 'develop'
* develop: 实现断电续打功能的保存数据部分
This commit is contained in:
commit
f2e2dbb6cd
@ -51,14 +51,38 @@ on_press:
|
||||
on_release:
|
||||
{% do call_method("machine.device_power.post_device", device="Printer", action="toggle") %}
|
||||
|
||||
[button estop]
|
||||
[button power_outage]
|
||||
type: gpio
|
||||
pin: ^!gpiochip4/gpio19
|
||||
debounce_period: .01
|
||||
minimum_event_time: 0
|
||||
on_press:
|
||||
{% do call_method("printer.emergency_stop") %}
|
||||
{% do call_method("machine.shutdown") %}
|
||||
{% set query_objs = {"print_stats": ["state"], "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 %}
|
||||
{% set print_state = data['status']['print_stats']['state'] %}
|
||||
# Judging the printer status
|
||||
{% if print_state | string == 'printing' or print_state | string == 'paused' %}
|
||||
{% 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 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) %}
|
||||
# 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 + "'\"") %}
|
||||
# save interrupt
|
||||
{% do call_method("printer.gcode.script", script="SAVE_VARIABLE VARIABLE=was_interrupted VALUE=True") %}
|
||||
{% else %}
|
||||
{% do call_method("printer.gcode.script", script="SAVE_VARIABLE VARIABLE=was_interrupted VALUE=False") %}
|
||||
{% endif %}
|
||||
# shutdown
|
||||
{% do call_method("machine.shutdown") %}
|
||||
|
||||
[update_manager]
|
||||
channel: dev
|
||||
|
Loading…
x
Reference in New Issue
Block a user