diff --git a/mpf/devices/stepper.py b/mpf/devices/stepper.py index f3a68c8cd..126f72b0b 100644 --- a/mpf/devices/stepper.py +++ b/mpf/devices/stepper.py @@ -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)) diff --git a/mpf/platforms/fast/communicators/exp.py b/mpf/platforms/fast/communicators/exp.py index 8c6528693..f4d0e98c7 100644 --- a/mpf/platforms/fast/communicators/exp.py +++ b/mpf/platforms/fast/communicators/exp.py @@ -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 diff --git a/mpf/platforms/fast/fast_stepper.py b/mpf/platforms/fast/fast_stepper.py index 5935030c6..a10a4131c 100644 --- a/mpf/platforms/fast/fast_stepper.py +++ b/mpf/platforms/fast/fast_stepper.py @@ -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.""" @@ -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 " @@ -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 @@ -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 @@ -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])) diff --git a/mpf/platforms/p_roc_devices.py b/mpf/platforms/p_roc_devices.py index f68462b09..71ec625d0 100644 --- a/mpf/platforms/p_roc_devices.py +++ b/mpf/platforms/p_roc_devices.py @@ -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)) diff --git a/mpf/platforms/pololu/pololu_tic.py b/mpf/platforms/pololu/pololu_tic.py index 16b355678..ade5e15fe 100644 --- a/mpf/platforms/pololu/pololu_tic.py +++ b/mpf/platforms/pololu/pololu_tic.py @@ -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() diff --git a/mpf/platforms/spike/spike.py b/mpf/platforms/spike/spike.py index 00cb52334..d655270a1 100644 --- a/mpf/platforms/spike/spike.py +++ b/mpf/platforms/spike/spike.py @@ -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.""" diff --git a/mpf/platforms/step_stick.py b/mpf/platforms/step_stick.py index 5e5ebee3c..b7d412259 100644 --- a/mpf/platforms/step_stick.py +++ b/mpf/platforms/step_stick.py @@ -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.") diff --git a/mpf/platforms/trinamics_steprocker.py b/mpf/platforms/trinamics_steprocker.py index a92c785c8..d7a5d312d 100644 --- a/mpf/platforms/trinamics_steprocker.py +++ b/mpf/platforms/trinamics_steprocker.py @@ -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) diff --git a/mpf/platforms/virtual.py b/mpf/platforms/virtual.py index 7d8164a69..19cb95bb5 100644 --- a/mpf/platforms/virtual.py +++ b/mpf/platforms/virtual.py @@ -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