def tone(pin, frequency, duration=None): p = GPIO.PWM(pin, frequency) p.start(50) if duration is not None and duration > 0: threading.Timer(duration, lambda *args, **kwargs: p.stop()).start()
def noTone(pin): GPIO.PWM(pin).stop()
def digitalWrite(pin, value): try: GPIO.output(pin, value) except NameError: raise NameError(('Pin {} is not setup yet, please run' '`pinMode({}, state)` first!').format(pin, pin))
def digitalRead(pin): try: return GPIO.input(pin) except NameError: raise NameError(('Pin {} is not setup yet, please run' '`pinMode({}, state)` first!').format(pin, pin))
def noInterrupts(): GPIO.disable_interrupts()
def interrupts(): GPIO.enable_interrupts()
def detachInterrupt(pin): GPIO.remove_event_detect(pin)
def pinMode(pin, state): GPIO.setup(pin, state)
def attachInterrupt(pin, ISR, mode): GPIO.add_event_detect(pin, edge=mode, callback=[ISR])