Skip to content

Commit

Permalink
cleanup of some callback macros and doc
Browse files Browse the repository at this point in the history
  • Loading branch information
moggieuk committed Jul 23, 2023
1 parent 97e1f44 commit df24aa9
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 66 deletions.
72 changes: 41 additions & 31 deletions config/mmu_software.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ gcode:


########################################################################
# Standalone Tip Forming (for rapid tuning of Slicer values)
# Standalone Tip Forming (also helps with rapid tuning of Slicer values)
########################################################################
[gcode_macro _MMU_FORM_TIP_STANDALONE]
description: Standalone macro that mimics SuperSlicer process
Expand Down Expand Up @@ -252,58 +252,68 @@ gcode:
# Note that EndlessSpool is an unsupervised filament change
###########################################################################


###########################################################################
# This occurs prior to MMU forming tip and ejecting the remains of the old filament
#
# Typically you would move toolhead to your park position so oozing is not a problem
#
# This is probably similar to what you do in your PAUSE macro and you could simply call that here...
# (this call works with reference PAUSE macro supplied in client_macros.cfg)
#
[gcode_macro _MMU_ENDLESS_SPOOL_PRE_UNLOAD]
description: Pre unload routine for EndlessSpool changes
gcode:
# This occurs prior to MMU forming tip and ejecting the remains of the old filament
#
# Typically you would move toolhead to your park position so oozing is not a problem
#
# This is probably similar to what you do in your PAUSE macro and you could simply call that here...
# (this call works with reference PAUSE macro supplied in client_macros.cfg)

PAUSE


###########################################################################
# This occurs after MMU has loaded the new filament from the next spool in rotation
# MMU will have loaded the new filament to the nozzle the same way as a normal filament
# swap. Previously configured Pressure Advance will be retained.
#
# This would be a place to purge additional filament if necessary (it really shouldn't be)
# and clean nozzle if your printer is suitably equipped.
#
# This is probably similar to what you do in your RESUME macro and you could simply call that here...
# (this call works with reference RESUME macro supplied in client_macros.cfg)
#
[gcode_macro _MMU_ENDLESS_SPOOL_POST_LOAD]
description: Optional post load routine for EndlessSpool changes
gcode:
# This occurs after MMU has loaded the new filament from the next spool in rotation
# MMU will have loaded the new filament to the nozzle the same way as a normal filament
# swap. Previously configured Pressure Advance will be retained.
#
# This would be a place to purge additional filament if necessary (it really shouldn't be)
# and clean nozzle if your printer is suitably equipped.
#
# This is probably similar to what you do in your RESUME macro and you could simply call that here...
# (this call works with reference RESUME macro supplied in client_macros.cfg)

RESUME


###########################################################################
# This occurs when the MMU action status changes. The `ACTION` parameters will contain
# the current action string (also available in `printer.mmu.action` printer variable).
# Also the previous action is available in `OLD_ACTION`. See Happy Hare README for
# full list of action strings.
#
# This could be a place to set LED status or similar. The logic here
# demonstrates the three major action states
#
[gcode_macro _MMU_ACTION_CHANGED]
description: Called when an action has changed.
gcode:
# This occurs when the MMU action status changes. `printer.mmu.action` will contain
# the current action string. See Happy Hare README for full list
#
# This could be a place to set LED status or similar. The logic here
# demonstrates the three major action states
{% set ACTION = printer.mmu.action|string %}
{% set ACTION = params.ACTION|string %}
{% set OLD_ACTION = params.OLD_ACTION|string %}

{% if ACTION|string == "Idle" %}
# Add your logic here
# _STATUS_STANDBY
{% endif %}

{% if ACTION|string == "Loading" %}
# Add your logic here
# Add your logic here, e.g. loading LED
# _STATUS_LOADING
{% endif %}

{% if ACTION|string == "Unloading" %}
# Add your logic here
# Add your logic here, e.g. unloading LED
# _STATUS_UNLOADING
{% endif %}

{% if ACTION|string == "Idle" %}
# Add your logic here, e.g. LED off
# _STATUS_STANDBY
{% endif %}


###########################################################################
# ADVANCED: User modifable loading and unloading sequences
Expand Down
71 changes: 37 additions & 34 deletions doc/gcode_customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,35 @@ Possible action strings are:
Here is the reference/example macro packaged in `mmu_software.cfg`:

```yml
###########################################################################
# This occurs when the MMU action status changes. The `ACTION` parameters will contain
# the current action string (also available in `printer.mmu.action` printer variable).
# Also the previous action is available in `OLD_ACTION`. See Happy Hare README for
# full list of action strings.
#
# This could be a place to set LED status or similar. The logic here
# demonstrates the three major action states
#
[gcode_macro _MMU_ACTION_CHANGED]
description: Called when an action has changed.
gcode:
# This occurs when the MMU action status changes. `printer.mmu.action` will contain
# the current action string. See Happy Hare README for full list
#
# This could be a place to set LED status or similar. The logic here
# demonstrates the three major action states
{% set ACTION = printer.mmu.action|string %}
{% set ACTION = params.ACTION|string %}
{% set OLD_ACTION = params.OLD_ACTION|string %}

{% if ACTION|string == "Idle" %}
# Add your logic here
# _STATUS_STANDBY
{% endif %}

{% if ACTION|string == "Loading" %}
# Add your logic here
# Add your logic here, e.g. loading LED
# _STATUS_LOADING
{% endif %}

{% if ACTION|string == "Unloading" %}
# Add your logic here
# Add your logic here, e.g. unloading LED
# _STATUS_UNLOADING
{% endif %}

{% if ACTION|string == "Idle" %}
# Add your logic here, e.g. LED off
# _STATUS_STANDBY
{% endif %}
```

<br>
Expand All @@ -62,35 +67,33 @@ Here are the default macros:

```yml
###########################################################################
# Callback macros for modifying Happy Hare behavour
# Note that EndlessSpool is an unsupervised filament change
###########################################################################

# This occurs prior to MMU forming tip and ejecting the remains of the old filament
#
# Typically you would move toolhead to your park position so oozing is not a problem
#
# This is probably similar to what you do in your PAUSE macro and you could simply call that here...
# (this call works with reference PAUSE macro supplied in client_macros.cfg)
#
[gcode_macro _MMU_ENDLESS_SPOOL_PRE_UNLOAD]
description: Pre unload routine for EndlessSpool changes
gcode:
# This occurs prior to MMU forming tip and ejecting the remains of the old filament
#
# Typically you would move toolhead to your park position so oozing is not a problem
#
# This is probably similar to what you do in your PAUSE macro and you could simply call that here...
# (this call works with reference PAUSE macro supplied in client_macros.cfg)

PAUSE


###########################################################################
# This occurs after MMU has loaded the new filament from the next spool in rotation
# MMU will have loaded the new filament to the nozzle the same way as a normal filament
# swap. Previously configured Pressure Advance will be retained.
#
# This would be a place to purge additional filament if necessary (it really shouldn't be)
# and clean nozzle if your printer is suitably equipped.
#
# This is probably similar to what you do in your RESUME macro and you could simply call that here...
# (this call works with reference RESUME macro supplied in client_macros.cfg)
#
[gcode_macro _MMU_ENDLESS_SPOOL_POST_LOAD]
description: Optional post load routine for EndlessSpool changes
gcode:
# This occurs after MMU has loaded the new filament from the next spool in rotation
# MMU will have loaded the new filament to the nozzle the same way as a normal filament
# swap. Previously configured Pressure Advance will be retained.
#
# This would be a place to purge additional filament if necessary (it really shouldn't be)
# and clean nozzle if your printer is suitably equipped.
#
# This is probably similar to what you do in your RESUME macro and you could simply call that here...
# (this call works with reference RESUME macro supplied in client_macros.cfg)

RESUME
```
Expand Down
2 changes: 1 addition & 1 deletion extras/mmu.py
Original file line number Diff line number Diff line change
Expand Up @@ -2053,7 +2053,7 @@ def _set_action(self, action):
self.action = action
try:
self.printer.lookup_object('gcode_macro _MMU_ACTION_CHANGED')
self.gcode.run_script_from_command("_MMU_ACTION_CHANGED")
self.gcode.run_script_from_command("_MMU_ACTION_CHANGED ACTION=%s OLD_ACTION=%s" % (self.action, old_action))
finally:
return old_action

Expand Down

0 comments on commit df24aa9

Please sign in to comment.