mcu: Avoid adding the same stepper multiple times to an endstop

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2018-08-26 11:06:20 -04:00
parent 96acfdc6d2
commit ad480bd470
1 changed files with 2 additions and 0 deletions

View File

@ -150,6 +150,8 @@ class MCU_endstop:
def add_stepper(self, stepper): def add_stepper(self, stepper):
if stepper.get_mcu() is not self._mcu: if stepper.get_mcu() is not self._mcu:
raise pins.error("Endstop and stepper must be on the same mcu") raise pins.error("Endstop and stepper must be on the same mcu")
if stepper in self._steppers:
return
self._steppers.append(stepper) self._steppers.append(stepper)
def get_steppers(self): def get_steppers(self):
return list(self._steppers) return list(self._steppers)