Skip to content

Commit

Permalink
Bugfix subsequent stepper speeds being lost on overlapping moves
Browse files Browse the repository at this point in the history
  • Loading branch information
avanwinkle committed Oct 13, 2024
1 parent f563b63 commit 352d3b6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions mpf/devices/stepper.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,22 +135,23 @@ async def _run(self):
delta, target_position, self._current_position)
# move stepper
self.hw_stepper.move_rel_pos(delta, self._target_speed)
# Clear the speed override here, in case a subsequent move wants
# to set one before this one finishes.
self._target_speed = None
# wait for the move to complete
await self.hw_stepper.wait_for_move_completed()
else:
self.info_log("Got command to move (relative) to %s, but already there. Not moving.",
self._target_position)
# set current position
self._current_position = target_position
# Clear the speed override
self._target_speed = None
# post ready event
self._post_ready_event()

def _move_to_absolute_position(self, position, speed=None):
"""Move stepper to position."""
self.info_log("%s: Moving to absolute position %s. Current position: %s",
self.hw_stepper, position, self._current_position)
self.info_log("Moving to absolute position %s. Current position: %s",
position, self._current_position)
if self.config['pos_min'] <= position <= self.config['pos_max']:
self._target_position = position
self._target_speed = speed
Expand Down
2 changes: 1 addition & 1 deletion mpf/platforms/fast/fast_stepper.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def move_rel_pos(self, position, speed=None):

base_command = "MF" if position > 0 else "MR"
hex_position = Util.int_to_hex_string(position, True)
self.log.debug("Moving stepper index %s: %s steps with speed %s", self.stepper_index, position, speed)
self.log.info("Moving stepper index %s: %s steps with speed %s", self.stepper_index, position, speed)

if speed:
if speed < MIN_SPEED or speed > MAX_SPEED:
Expand Down

0 comments on commit 352d3b6

Please sign in to comment.