Skip to content

feat: add dock_dir for rear-mounted tool docks - #7

Merged
ogland merged 2 commits into
BondtechAB:mainfrom
charliemayall:feat/dock-dir
Aug 18, 2026
Merged

feat: add dock_dir for rear-mounted tool docks#7
ogland merged 2 commits into
BondtechAB:mainfrom
charliemayall:feat/dock-dir

Conversation

@charliemayall

@charliemayall charliemayall commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

feat: add dock_dir for rear-mounted tool docks

Summary

Dock geometry assumed the tools sit at the front of the machine (min Y). trigger_y, unlock-dance depths, and peel-off moves all used that sign. On a rear-mounted dock (max Y), park/pickup approached from the wrong side and could drive past the seat into the dock.

Adds variable_dock_dir (-1 front, +1 rear, default -1) for trigger-line derivation, unlock dance, and peel moves. Default -1 leaves existing front-dock configs alone.

Alternative

To avoid another variable, derive dock_dir from clearance_y and a tool's dock_y: the sign of Y that moves from clearance_y toward dock_y (i.e. sign(dock_y - clearance_y)).

Changes

File What
macros/indx.cfg Add variable_dock_dir: -1; update trigger-line comments
macros/indx-tc-macros.cfg Derive trigger_y, unlock dance, and peel from dock_dir
macros/indx-cal.cfg Peel direction in dock calibration uses dock_dir
README.md Document variable_dock_dir and rear-dock clearance_y placement

Test plan

  • Front dock (dock_dir: -1, default): PARK_TOOL / T0 matches current behaviour
  • Rear dock (dock_dir: 1): same behaiour but in reverse direction.
  • Rear dock: peel-off after park moves away from the dock (toward clearance_y on the bed side)

{-(expr)} is parsed as whitespace-strip, so front-dock peel
became Y-10 into the dock and tripped position_min.
@ogland

ogland commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Merged. I checked the maths both ways before taking it: front comes out at trigger_y -21 with the dance stepping -21.5 / -22 / -23 and peel +10, which is bit identical to what main did before, so the default really is a no-op for existing setups. Rear puts the trigger line on the bed side and marches the dance deeper, which is right.

Two follow ups.

The variable adds exactly one new way to hurt yourself: set dock_dir -1 on a rear dock and the head drives away from the trigger line into the dock. Your own alternative in the description is the fix for that, not as a replacement but as a guard. sign(dock_y - clearance_y) gives the right answer in both configurations, and those two values are already calibrated so they can't disagree with reality. Worth erroring out if dock_dir contradicts them. Happy to take that as a small follow up PR if you fancy it.

The other thing is INDX_DOCK_MEASURE. It's documented as homing Y then X from the dock and deriving the position from raw stepper counts, but on a rear dock homing Y moves away from the dock. That's plugin side rather than anything dock_dir can fix, so it needs @dalegaard rather than either of us, but anyone running a rear dock should know dock calibration may not work the same way.

Also worth knowing this unblocks part of #26: your homing.cfg uses tp.dock_dir for the clearance check and carries its own copy of variable_dock_dir, which is some of why that PR is showing as conflicting. With this on main that overlap goes away and the rebase should be a bit less painful.

@ogland
ogland merged commit ac3b44a into BondtechAB:main Aug 18, 2026
ogland added a commit that referenced this pull request Aug 18, 2026
The comment added in #7 warning about the bare-minus form contained
that form literally. Klipper hands the whole macro body to Jinja,
comments included, so the warning parsed as an expression and every
config using these two macros failed to load.

Rephrased so it says the same thing without writing the sequence out.
@ogland

ogland commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Heads up, I had to push a follow up on this one. The comment above the peel move broke config loading:

# Use 0- not {- : Jinja treats {- as whitespace strip, so {-(x)} drops the unary minus

Klipper hands the whole macro body to Jinja, comments included, since the # is only stripped later at gcode execution. So the sequence you were warning about gets parsed rather than read, the next token is a colon, and _LINEAR_EXIT and _CAL_PARK_ACTIVE both fail to compile. Klipper refuses to start with that on main. The comment fell into the exact trap it was documenting, which I did enjoy slightly.

Fixed in 266f53e, same warning phrased so it doesn't write the sequence out.

The code either side of it is fine and your front and rear numbers check out, so I assume the comment went in after you'd tested, because a config with that in it won't load at all.

No harm done, it was on main for about four minutes. Worth knowing for anything else you write though: you can't put those delimiters inside a Klipper macro comment, the template engine sees them regardless.

ogland added a commit that referenced this pull request Aug 18, 2026
A macro that fails to compile stops Klipper from starting, so it is a
dead printer at boot rather than a runtime warning. #7 shipped one
briefly and only a manual check caught it.

Uses the same delimiters as Klipper's gcode_macro, including the part
that caught us out: # comments are not stripped before compilation, so
a Jinja delimiter written inside a comment is still parsed.
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