Skip to content

Commit

Permalink
Linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
avanwinkle committed Nov 16, 2024
1 parent a11c9ea commit 27ff968
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion mpf/devices/stepper.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def validate_and_parse_config(self, config, is_mode_config, debug_prefix: str =
if cfg in config:
for pos, value in config[cfg].items():
if isinstance(value, str):
config[cfg][pos] = { 'event': value }
config[cfg][pos] = {'event': value}
config = super().validate_and_parse_config(config, is_mode_config, debug_prefix)
platform = self.machine.get_platform_sections(
'stepper_controllers', getattr(config, "platform", None))
Expand Down
3 changes: 2 additions & 1 deletion mpf/platforms/fast/communicators/exp.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,10 @@ def set_led_fade_rate(self, board_address: str, rate: int) -> None:
self.send_and_forget(f'RF@{board_address}:{Util.int_to_hex_string(rate, True)}')

def register_processor(self, message_prefix, board_address, device_id, callback):
"""Register an exp board processor to handle messages."""
if message_prefix not in self.message_processors:
self.message_processors[message_prefix] = partial(self._process_device_msg, message_prefix)
self._device_processors[message_prefix]= dict()
self._device_processors[message_prefix] = dict()
if board_address not in self._device_processors[message_prefix]:
self._device_processors[message_prefix][board_address] = dict()
self._device_processors[message_prefix][board_address][device_id] = callback
Expand Down
9 changes: 7 additions & 2 deletions mpf/platforms/fast/fast_stepper.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
MIN_SPEED = 350
MAX_SPEED = 1650


class FastStepper(StepperPlatformInterface):

"""A stepper in the FAST platform connected to a FAST Expansion Board."""
Expand All @@ -31,6 +32,7 @@ def __init__(self, breakout_board, port, config):
self._default_speed = Util.int_to_hex_string(self.config['default_speed'], True)

def home(self, direction):
"""Return the stepper to its home position."""
if direction != 'counterclockwise':
raise ConfigFileError("FAST Stepper only supports home in counter-clockwise direction. "
"Please rewire your motor and set homing_direction: counterclockwise "
Expand All @@ -39,6 +41,7 @@ def home(self, direction):
self._send_command("MH")

async def wait_for_move_completed(self):
"""Wait for the stepper to stop moving."""
# If not moving, return immediately
if not self._is_moving:
return
Expand Down Expand Up @@ -73,7 +76,8 @@ def move_rel_pos(self, position, speed=None):
def move_vel_mode(self, velocity):
"""Move the motor indefinitely in either direction.
FAST does not support this, so instead send the longest possible move time."""
FAST does not support this, so instead send the longest possible move time.
"""
base_command = "MR" if velocity < 0 else "MF"
# The only place in MPF code that uses move_vel_mode is the software-based
# homing, which sends 1/-1 as values. Interpret that as slowest possible
Expand All @@ -88,9 +92,10 @@ def stop(self):
self._send_command("MC")

def set_home_position(self):
"""Not used."""
pass

def _send_command(self, base_command, payload=[]):
def _send_command(self, base_command, payload=set()):
self.exp_connection.send_and_forget(','.join([
f'{base_command}@{self.base_address}:{self.stepper_index}', *payload]))

Expand Down
2 changes: 1 addition & 1 deletion mpf/platforms/p_roc_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ def move_vel_mode(self, velocity):
else:
self.move_rel_pos(-16384)

def move_rel_pos(self, position):
def move_rel_pos(self, position, speed=None):
"""Move stepper by x steps."""
if abs(position) > 16384:
raise ValueError("Cannot move more than 16384 steps but tried {}".format(position))
Expand Down
2 changes: 1 addition & 1 deletion mpf/platforms/pololu/pololu_tic.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def move_abs_pos(self, position):
self._move_complete.clear()
self.tic.rotate_to_position(self._position)

def move_rel_pos(self, position):
def move_rel_pos(self, position, speed=None):
"""Move axis to a relative position."""
self._position += position
self._move_complete.clear()
Expand Down
4 changes: 2 additions & 2 deletions mpf/platforms/spike/spike.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,10 +420,10 @@ async def is_move_complete(self) -> bool:
return False
return info['position'] == self._position

def move_rel_pos(self, position):
def move_rel_pos(self, position, speed=None):
"""Move relative to current position."""
self._position += int(position)
self._move_to_absolute_position(self._position, self.config['speed'])
self._move_to_absolute_position(self._position, speed or self.config['speed'])

def move_vel_mode(self, velocity):
"""Move stepper in a direction."""
Expand Down
2 changes: 1 addition & 1 deletion mpf/platforms/step_stick.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def start_stepper(self, **kwargs):
if self.enable_output:
self.enable_output.enable()

def move_rel_pos(self, position):
def move_rel_pos(self, position, speed=None):
"""Move a number of steps in one direction."""
if self._move_task and not self._move_task.done():
raise AssertionError("Last move has not been completed. Calls stop first.")
Expand Down
2 changes: 1 addition & 1 deletion mpf/platforms/trinamics_steprocker.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def move_abs_pos(self, position):
microstep_pos = self._uu_to_microsteps(position)
self.tmcl.mvp(self._mn, "ABS", microstep_pos)

def move_rel_pos(self, position):
def move_rel_pos(self, position, speed=None):
"""Move axis to a relative position."""
microstep_rel = self._uu_to_microsteps(position)
self.tmcl.mvp(self._mn, "REL", microstep_rel)
Expand Down
2 changes: 1 addition & 1 deletion mpf/platforms/virtual.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ async def wait_for_move_completed(self):
"""Wait until move completed."""
await asyncio.sleep(0.1)

def move_rel_pos(self, position):
def move_rel_pos(self, position, speed=None):
"""Move axis to a relative position."""
self._current_position += position

Expand Down

0 comments on commit 27ff968

Please sign in to comment.