Skip to content

add direction to moster settings #138

Merged
beniroquai merged 2 commits into
masterfrom
mergemaster
May 29, 2026
Merged

add direction to moster settings #138
beniroquai merged 2 commits into
masterfrom
mergemaster

Conversation

@beniroquai
Copy link
Copy Markdown
Contributor

No description provided.

Introduce a per-axis `direction` sign array to hide wiring polarity from callers and keep a consistent user coordinate frame. stepSize is stored as a positive magnitude while the hardware direction (+1/-1) is tracked separately and applied at the firmware boundary. setup_motor() now accepts an optional `direction` and also consumes a negative stepSize as a direction flip. Updated conversions in position parsing, move preparation, currentPosition updates, and motor status parsing to apply the direction sign when converting between hardware steps and physical (user-frame) units.
Copilot AI review requested due to automatic review settings May 29, 2026 13:46
@beniroquai beniroquai merged commit fb4ef8b into master May 29, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a per-axis hardware-direction sign to Motor so that wiring polarity can be inverted without flipping the user-facing coordinate frame. setup_motor() now stores abs(stepSize) plus a direction (derived from a negative stepSize or passed explicitly), and that sign is applied at the firmware boundary in three places.

Changes:

  • Introduce Motor.direction (int8 array, [A, X, Y, Z], default +1).
  • Extend setup_motor() with a direction kwarg and split sign from magnitude when storing stepSize.
  • Apply direction in _callback_motor_status(), move_stepper() (including currentPosition updates), and get_position().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread uc2rest/motor.py
Comment on lines +296 to +306
# Split sign from magnitude. An explicit `direction` always wins;
# otherwise the sign of stepSize is consumed and stepSize becomes
# a positive scale factor.
if direction is None:
sign = -1 if stepSize < 0 else 1
else:
sign = -1 if direction < 0 else 1
stepSize = abs(stepSize)

axisIdx = self.xyztTo1230(axis)
self.direction[axisIdx] = sign
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