Skip to content

Conversation

@TheSin-
Copy link

@TheSin- TheSin- commented Jan 23, 2024

  • Add x to possible path values for future dock types
  • Change so default is always 0 for all paths, to simplify paths
  • Add DROPOFF/PICKUP START/END macros that can be used with rename to add user code to these calls for LEDS, Runout Sensors, Nozzle cleaning or other tasks

I haven't tested all this yet as I'm at work, but I'll test it once I'm home. I wanted to get this PR in incase I was going in the wrong direction you could tell me before I put more time in on it.

This would allow for macro overrides in a user area so we don't mess with toolchanger.cfg and can keep it in sync with git

Example of my vision

[tool T0]
...
before_change_gcode:
  MY_TOOL_BEFORE_CHANGE TN='T0'
after_change_gcode:
  MY_TOOL_AFTER_CHANGE TN='T0'
pickup_gcode:
  MY_TOOL_PICKUP TN='T0'
dropoff_gcode:
  MY_TOOL_DROPOFF TN='T0'

[tool T1]
...
before_change_gcode:
  MY_TOOL_BEFORE_CHANGE TN='T1'
after_change_gcode:
  MY_TOOL_AFTER_CHANGE TN='T1'
pickup_gcode:
  MY_TOOL_PICKUP TN='T1'
dropoff_gcode:
  MY_TOOL_DROPOFF TN='T1'

[gcode_macro MY_TOOL_BEFORE_CHANGE]
gcode:
  {% set tn = params.TN|string %}
  {% set tool = printer['tool ' + tn] %}
  RESPOND TYPE=echo MSG='Before change {tool.name}'
  STATUS_BUSY T={tool.tool_number}
  TOOL_BEFORE_CHANGE {rawparams}

[gcode_macro MY_TOOL_AFTER_CHANGE]
gcode:
  {% set tn = params.TN|string %}
  {% set tool = printer['tool ' + tn] %}
  RESPOND TYPE=echo MSG='After change {tool.name}'
  TOOL_AFTER_CHANGE {rawparams}

[gcode_macro MY_TOOL_DROPOFF]
gcode:
  {% set tn = params.TN|string %}
  {% set tool = printer['tool ' + tn] %}
  RESPOND TYPE=echo MSG='Dropping off {tool.name}'
  SET_FILAMENT_SENSOR SENSOR=filament_sensor_T{tool.tool_number} ENABLE=0
  TOOL_DROPOFF {rawparams}
  STATUS_READY T={tool.tool_number}

[gcode_macro MY_TOOL_PICKUP]
gcode:
  {% set tn = params.TN|string %}
  {% set tool = printer['tool ' + tn] %}
  RESPOND TYPE=echo MSG='Picking up {tool.name}'
  STATUS_HEATING T={tool.tool_number}
  SET_FILAMENT_SENSOR SENSOR=filament_sensor_T{tool.tool_number} ENABLE=1
  TOOL_PICKUP {rawparams}
  CLEAN_NOZZLE
  STATUS_PRINTING T={tool.tool_number}

Still want to make an other PR after this one to separate the path into 2 pieces, tool_path, dock_path and have the center marker for tool detection auto happen so that f isn't reused and can be used through out the path instead. it'll be really easy to do. I just didn't want to make this PR too large.

@TheSin- TheSin- changed the title Add some functionality Add some tool functionality to user space Jan 23, 2024
@TheSin-
Copy link
Author

TheSin- commented Jan 23, 2024

Updated the example for the new method

@TheSin- TheSin- force-pushed the main branch 5 times, most recently from fd6597f to 5399ec8 Compare January 24, 2024 16:15
@TheSin-
Copy link
Author

TheSin- commented Jan 24, 2024

this plan might be totally flawed, I didn't know Klipper would only let you rename system macros

configparser.Error: Existing command 'TOOL_BEFORE_CHANGE' not found in gcode_macro rename

so I need to make this macros system versions via the toolchanger.py I suspect which I was trying to avoid.

Just putting my notes here as I figure this out, since I'm still new to the Klipper ecosystem

@TheSin- TheSin- force-pushed the main branch 3 times, most recently from c224ab2 to cf47776 Compare January 24, 2024 20:15
@TheSin-
Copy link
Author

TheSin- commented Jan 24, 2024

this plan might be totally flawed, I didn't know Klipper would only let you rename system macros

configparser.Error: Existing command 'TOOL_BEFORE_CHANGE' not found in gcode_macro rename

so I need to make this macros system versions via the toolchanger.py I suspect which I was trying to avoid.

Just putting my notes here as I figure this out, since I'm still new to the Klipper ecosystem

This is fixed with the new example now. I'm going to make a PR on klipper-toolchanger to expose before_change_gcode and after_change_gcode as well to go with this one

viesturz/klipper-toolchanger#8

- Add x to possible path values for future dock types
- Change so default is always 0 for all paths, to simplify paths
- Add DROPOFF/PICKUP START/END macros that can be used with rename to add user code to these calls for LEDS, Runout Sensors, Nozzle cleaning or other tasks
@TheSin-
Copy link
Author

TheSin- commented Jan 24, 2024

Everything is tested and 100% working now. Exactly what I was hoping for, LEDs change properly, I can clean on change now, and once I finish wiring I can add runout sensors for each tool and only check the active tool. This does require the changes to klipper-toolchanger for the before/after_change

@viesturz
Copy link
Owner

viesturz commented Apr 1, 2024

Thanks for the PR, overall reasonable changes to merge.

Please fix a few nits:

  • please prefux the macros with _underscore to make them hidden from the UI.
  • tool.name|replace('tool ', '', 1) - just use tool.tool_number?
  • and then in the macros you are re-creating the tool name. Just pass tool.name in params and not the number?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants