Skip to content

Commit

Permalink
filament: Beep on load/unload completion
Browse files Browse the repository at this point in the history
  • Loading branch information
jschuh committed May 16, 2023
1 parent 9b85b4c commit f46c25e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
20 changes: 16 additions & 4 deletions filament.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ gcode:
{% set EXTRUDER = params.EXTRUDER|default(saved_extruder)|lower %}
{% set km = printer["gcode_macro _km_globals"] %}
# Use the global min as default if provided, else use per extruder min + 5.
{% set BEEPS = params.BEEPS|default(8)|int if "output_pin beeper" in printer
else 0 %}
{% set default_minimum = km.load_min_temp if km.load_min_temp else
(printer.configfile.settings[EXTRUDER].min_extrude_temp + 5) %}
{% if 'MINIMUM' in params %}
Expand Down Expand Up @@ -59,11 +61,18 @@ gcode:
{% endif %}
RESTORE_GCODE_STATE NAME=_KM_LOAD_UNLOAD

# Beep on completion
{% for i in range(BEEPS) %}
M300 P100
G4 P200
{% endfor %}

# TODO: Fix casing after front-ends get fixed
[gcode_macro LOAD_FILAMENT]
description: Loads filament to the extruder.
Usage: LOAD_FILAMENT [LENGTH=<distance>] [SPEED=<speed>]
[EXTRUDER=<extruder>] [MINIMUM=<temperature>]
[BEEPS=<beep count on completion>]
gcode:
_LOAD_UNLOAD LOAD=1{% for k in params
%}{' '~k~'="'~params[k]~'"'}{% endfor %}
Expand All @@ -75,13 +84,15 @@ gcode:
{% set dummy = params.SPEED|default(variable_load_speed)|float %}
{% set dummy = params.EXTRUDER|default(current extruder) %}
{% set dummy = params.MINIMUM|default(min_extrude_temp)|int %}
{% set dummy = params.BEEPS|default(10)|int %}
" %} # End argument block for Mainsail

# TODO: Fix casing after front-ends get fixed
[gcode_macro UNLOAD_FILAMENT]
description: Unloads filament from the extruder.
Usage: UNLOAD_FILAMENT [LENGTH=<distance>] [SPEED=<speed>]
[EXTRUDER=<extruder>] [MINIMUM=<temperature>]
[BEEPS=<beep count on completion>]
gcode:
_LOAD_UNLOAD LOAD=0{% for k in params
%}{' '~k~'="'~params[k]~'"'}{% endfor %}
Expand All @@ -93,6 +104,7 @@ gcode:
{% set dummy = params.SPEED|default(variable_load_speed)|float %}
{% set dummy = params.EXTRUDER|default(default extruder) %}
{% set dummy = params.MINIMUM|default(min_extrude_temp)|int %}
{% set dummy = params.BEEPS|default(10)|int %}
" %} # End argument block for Mainsail

[gcode_macro _pause_inner_m700]
Expand All @@ -106,9 +118,9 @@ gcode:
{% set z_param = (' Z="%f"' % params.Z) if 'Z' in params else "" %}

{% if printer.idle_timeout.state|string == "Printing" %}
PAUSE P=2{z_param}
PAUSE B="{0}" P=2{z_param}
{% elif not printer.pause_resume.is_paused%}
PARK P=2{z_param}
PARK B="{0}" P=2{z_param}
{% endif %}

[gcode_macro m701]
Expand All @@ -125,7 +137,7 @@ gcode:
{% endif %}

_PAUSE_INNER_M700 {% for k in params %}{' '~k~'="'~params[k]~'"'}{% endfor %}
LOAD_FILAMENT LENGTH={
LOAD_FILAMENT BEEPS="{10}" LENGTH={
params.L|default(printer["gcode_macro _km_globals"].load_length)|float}

[gcode_macro m702]
Expand All @@ -142,5 +154,5 @@ gcode:
{% endif %}

_PAUSE_INNER_M700 {% for k in params %}{' '~k~'="'~params[k]~'"'}{% endfor %}
UNLOAD_FILAMENT LENGTH={
UNLOAD_FILAMENT BEEPS="{10}" LENGTH={
params.U|default(printer["gcode_macro _km_globals"].load_length)|float}
18 changes: 9 additions & 9 deletions pause_resume_cancel.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ gcode:
# Retract length (negative)
{% set E = (params.E|default(5))|float %}
# Beeps
{% set B = (params.B|default(10))|float %}
{% set B = params.B|default(10)|int if "output_pin beeper" in printer else 0
%}

{% if printer.pause_resume.is_paused %}
{ action_respond_info("Print already paused") }
Expand All @@ -31,12 +32,10 @@ gcode:
{' '~k~'="'~params[k]~'"'}
{% endfor %}
# Beep on pause if there's an M300 macro.
{% if "output_pin beeper" in printer %}
{% for i in range(B|int) %}
M300 P100
G4 P200
{% endfor %}
{% endif %}
{% for i in range(B) %}
M300 P100
G4 P200
{% endfor %}
{% else %}
{ action_respond_info("Print not in progress") }
{% endif %}
Expand All @@ -46,9 +45,10 @@ description: Pauses the current print.
Usage: M600 [B<beeps>] [E<pos>] [L<pos>] [R<temp>] [U<pos>] [X<pos>] [Y<pos>]
[Z<pos>]
gcode:
PAUSE P=2{% for k in params|select("in", "BEXYZ") %}{
PAUSE B="{0}" P=2{% for k in params|select("in", "EXYZ") %}{
' '~k~'="'~params[k]~'"'}{% endfor %}
UNLOAD_FILAMENT{% if 'U' in params %} LENGTH={params.U}{% endif %}
UNLOAD_FILAMENT{% if 'U' in params %} LENGTH={params.U}{% endif
%} BEEPS="{params.B|default(10)|int}"
{% if 'R' in params %}M109 S{params.R}{% endif %}

[gcode_macro m601]
Expand Down

0 comments on commit f46c25e

Please sign in to comment.