class TetrisSpeaker: def __init__(self, ipcon): self.okay = False self.ipcon = ipcon if not config.UID_PIEZO_SPEAKER_BRICKLET: print("Not Configured: Piezo Speaker") return self.speaker = PiezoSpeaker(config.UID_PIEZO_SPEAKER_BRICKLET, self.ipcon) try: self.speaker.get_identity() print("Found: Piezo Speaker ({0})").format(config.UID_PIEZO_SPEAKER_BRICKLET) except: print("Not Found: Piezo Speaker ({0})").format(config.UID_PIEZO_SPEAKER_BRICKLET) return self.okay = True def sirene(self, freq): if not self.okay: return for j in range(2): for i in range(25): self.speaker.beep(10, freq + i*20) time.sleep(0.007) for i in range(25): self.speaker.beep(10, freq + 24*20 - i*20) time.sleep(0.007) def beep_input(self): if not self.okay: return self.speaker.beep(10, 500) def beep_delete_line(self, lines): if not self.okay: return Thread(target=self.sirene, args=(1000*lines,)).start()
def __init__(self, ipcon): self.okay = False self.ipcon = ipcon if not config.UID_PIEZO_SPEAKER_BRICKLET: print("Not Configured: Piezo Speaker") return self.speaker = PiezoSpeaker(config.UID_PIEZO_SPEAKER_BRICKLET, self.ipcon) try: self.speaker.get_identity() print("Found: Piezo Speaker ({0})").format(config.UID_PIEZO_SPEAKER_BRICKLET) except: print("Not Found: Piezo Speaker ({0})").format(config.UID_PIEZO_SPEAKER_BRICKLET) return self.okay = True