def initialise(): GpioInterface.initialise() Peripherals.motion_sensor = MotionSensor(14) Peripherals.laser = Laser(4) Peripherals.laser.turnOff() Peripherals.gimbal = Gimbal(3, 2) Peripherals.audio = AudioInterface() Peripherals.button = Button(15)
def setAngle(self, angleDegrees: float) -> None: position = angleDegrees * ( Servo._maxPosition - Servo._minPosition) / 180 + Servo._minPosition position = min(position, Servo._maxPosition) position = max(position, Servo._minPosition) GpioInterface.setServoPosition(self.pin, position)
def turnOn(self) -> None: GpioInterface.writePin(self.pin, True)
def __init__(self, pin: int): self.pin = pin GpioInterface.setup(self.pin, GpioInterface.OUT)
def turnOff(self) -> None: GpioInterface.writePin(self.pin, False)
def isPressed(self) -> bool: return not GpioInterface.readPin(self.pin)
def destroy(): Peripherals.laser.turnOff() Peripherals.gimbal.destroy() GpioInterface.destroy()
def isMotionDetected(self) -> bool: return GpioInterface.readPin(self.pin)