class Lock: def __init__(self, name): self.name = name self.motor = MyPiStepperMotor(MyPiStepperMotor.DEFAULT) self.logger = MyLogger('Lock') #def reset(self): # TODO Should reset to known orientation def lock(self): self.logger.info("Locking " + self.name) self.motor.rotate(90) def unlock(self): # FIXME should rotate anticlockwise self.logger.info("Unlocking " + self.name) self.motor.rotate(-90)
import RPi.GPIO as GPIO import time from stepper_motor import MyPiStepperMotor try: print("Starting FullStep Motor") stepper_motor = MyPiStepperMotor(MyPiStepperMotor.DEFAULT, MyPiStepperMotor.FULLSTEP) stepper_motor.rotate(90) time.sleep(5) print("Starting HalfStep Motor") stepper_motor2 = MyPiStepperMotor(MyPiStepperMotor.DEFAULT, MyPiStepperMotor.HALFSTEP) stepper_motor2.rotate(90) except KeyboardInterrupt: print("Quit!") finally: GPIO.cleanup()
import RPi.GPIO as GPIO from stepper_motor import MyPiStepperMotor stepper = MyPiStepperMotor(MyPiStepperMotor.DEFAULT) stepper.rotate(-90) stepper.rotate(90)
def __init__(self, name): self.name = name self.motor = MyPiStepperMotor(MyPiStepperMotor.DEFAULT) self.logger = MyLogger('Lock')