Skip to content

Add runtime axis and homing direction control - #28493

Draft
ellensp wants to merge 5 commits into
MarlinFirmware:bugfix-2.1.xfrom
ellensp:add-runtime-homing-and-direction-changes
Draft

Add runtime axis and homing direction control#28493
ellensp wants to merge 5 commits into
MarlinFirmware:bugfix-2.1.xfrom
ellensp:add-runtime-homing-and-direction-changes

Conversation

@ellensp

@ellensp ellensp commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Description

This PR adds two optional runtime tuning features:

  • RUNTIME_AXIS_DIRECTION: Change motor direction at runtime with G-code (M670) instead of rebuilding firmware.
  • RUNTIME_HOMING_DIRECTION: Change homing direction at runtime with G-code (M671), including matching endstop behavior when both min/max pins exist.

Both settings are saved to EEPROM, so changes persist after restart. A reset (M502) restores defaults from configuration.

Requirements

  • Requires enabling RUNTIME_AXIS_DIRECTION and/or RUNTIME_HOMING_DIRECTION in Configuration_adv.h.
  • Runtime endstop pin swapping applies only on boards that define both MIN and MAX pins for an axis.

Benefits

  • Makes machine setup and troubleshooting much faster.
  • Reduces compile/flash cycles when reversing motors or testing homing direction.
  • Keeps behavior flexible while still preserving a safe default from config.

Configurations

  • Tested with mega2560 build.
  • Suggested validation:
    • Use M670 to flip an axis direction and confirm movement changes.
    • Use M671 to switch homing direction and confirm homing/endstop behavior.
    • Save/reload with M500 / M501, then verify reset behavior with M502.

Related Issues

Feature request: runtime control of axis direction and homing direction without reflashing.

@ellensp ellensp added Needs: Testing Testing is needed for this change PR: New Feature labels Jul 21, 2026
@ellensp

ellensp commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

This has not been tested on real hardware at all yet. Just wanted to make it public for constructive feedback.

The G-codes were picked at random. I have no problems if they get changed

@Nuck-TH

Nuck-TH commented Jul 21, 2026

Copy link
Copy Markdown

I'd suggest to use RRF gcodes, so incompatibility doesn't grow.

@ellensp

ellensp commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

M569 https://reprap.org/wiki/G-code#M569:_Stepper_driver_control is quite different and extensive...
I cant find a homing dirction gcode

@Nuck-TH

Nuck-TH commented Jul 21, 2026

Copy link
Copy Markdown

https://reprap.org/wiki/G-code#M574:_Set_endstop_configuration

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

Labels

Needs: Testing Testing is needed for this change PR: New Feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants