def beep(self):
if self.state is False:
cbpi.app.logger.error("BUZZER not working")
return
def play(sound):
try:
for i in sound:
if (isinstance(i, str)):
if i == "H" and self.beep_level == "HIGH":
GPIO.output(int(self.gpio), GPIO.HIGH)
elif i == "H" and self.beep_level != "HIGH":
GPIO.output(int(self.gpio), GPIO.LOW)
elif i == "L" and self.beep_level == "HIGH":
GPIO.output(int(self.gpio), GPIO.LOW)
else:
GPIO.output(int(self.gpio), GPIO.HIGH)
else:
time.sleep(i)
except Exception as e:
pass
start_new_thread(play, (self.sound,))
评论列表
文章目录