__init__.py 文件源码

python
阅读 65 收藏 0 点赞 0 评论 0

项目:craftbeerpi3 作者: Manuel83 项目源码 文件源码
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,))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号