legacy/EDGE_CODE/buzzer.py

25 lines
585 B
Python
Raw Normal View History

2020-07-13 19:42:32 +02:00
import asyncio
import RPi.GPIO as GPIO
from time import sleep
class Buzzer:
def __init__(self):
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
self.buzzer=23
GPIO.setup(self.buzzer,GPIO.OUT)
def background(f):
def wrapped(*args,**kwargs):
return asyncio.get_event_loop().run_in_executor(None,f,*args,*kwargs)
return wrapped
@background
def beep(self):
i=0
while i < 3 :
GPIO.output(self.buzzer,GPIO.HIGH)
sleep(0.2)
GPIO.output(self.buzzer,GPIO.LOW)
sleep(0.8)
i+=1