| @@ -85,6 +85,7 @@ INSERT OR IGNORE INTO config VALUES ('sensor_cols', 4, 'select', 'Adjust the wid | |||||
| INSERT OR IGNORE INTO config VALUES ('unit', 'C', 'select', 'Temperature Unit', '["C","F"]'); | INSERT OR IGNORE INTO config VALUES ('unit', 'C', 'select', 'Temperature Unit', '["C","F"]'); | ||||
| INSERT OR IGNORE INTO config VALUES ('brewery_name', 'My Home Brewery', 'text', 'Your brewery name', NULL ); | INSERT OR IGNORE INTO config VALUES ('brewery_name', 'My Home Brewery', 'text', 'Your brewery name', NULL ); | ||||
| INSERT OR IGNORE INTO config VALUES ('buzzer', 16, 'select', 'Buzzer GPIO', '[16,17,18,19,20]'); | INSERT OR IGNORE INTO config VALUES ('buzzer', 16, 'select', 'Buzzer GPIO', '[16,17,18,19,20]'); | ||||
| INSERT OR IGNORE INTO config VALUES ('buzzer_beep_level', 'HIGH', 'select', 'Buzzer Logic Beep Level', '["HIGH", "LOW"]'); | |||||
| INSERT OR IGNORE INTO config VALUES ('setup', 'YES', 'select', 'Show the Setup dialog', '["YES","NO"]'); | INSERT OR IGNORE INTO config VALUES ('setup', 'YES', 'select', 'Show the Setup dialog', '["YES","NO"]'); | ||||
| INSERT OR IGNORE INTO config VALUES ('brew_name', '', 'text', 'Brew Name', NULL); | INSERT OR IGNORE INTO config VALUES ('brew_name', '', 'text', 'Brew Name', NULL); | ||||
| INSERT OR IGNORE INTO config VALUES ('donation_notification', 'YES', 'select', 'Disable Donation Notification', '["YES","NO"]'); | INSERT OR IGNORE INTO config VALUES ('donation_notification', 'YES', 'select', 'Disable Donation Notification', '["YES","NO"]'); | ||||
| @@ -10,10 +10,11 @@ except Exception as e: | |||||
| class Buzzer(object): | class Buzzer(object): | ||||
| sound = ["H", 0.1, "L", 0.1, "H", 0.1, "L", 0.1, "H", 0.1, "L"] | sound = ["H", 0.1, "L", 0.1, "H", 0.1, "L", 0.1, "H", 0.1, "L"] | ||||
| def __init__(self, gpio): | |||||
| def __init__(self, gpio, beep_level): | |||||
| try: | try: | ||||
| cbpi.app.logger.info("INIT BUZZER NOW GPIO%s" % gpio) | cbpi.app.logger.info("INIT BUZZER NOW GPIO%s" % gpio) | ||||
| self.gpio = int(gpio) | self.gpio = int(gpio) | ||||
| self.beep_level = beep_level | |||||
| GPIO.setmode(GPIO.BCM) | GPIO.setmode(GPIO.BCM) | ||||
| GPIO.setup(self.gpio, GPIO.OUT) | GPIO.setup(self.gpio, GPIO.OUT) | ||||
| self.state = True | self.state = True | ||||
| @@ -31,10 +32,14 @@ class Buzzer(object): | |||||
| try: | try: | ||||
| for i in sound: | for i in sound: | ||||
| if (isinstance(i, str)): | if (isinstance(i, str)): | ||||
| if i == "H": | |||||
| if i == "H" and self.beep_level == "HIGH": | |||||
| GPIO.output(int(self.gpio), GPIO.HIGH) | GPIO.output(int(self.gpio), GPIO.HIGH) | ||||
| else: | |||||
| 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) | GPIO.output(int(self.gpio), GPIO.LOW) | ||||
| else: | |||||
| GPIO.output(int(self.gpio), GPIO.HIGH) | |||||
| else: | else: | ||||
| time.sleep(i) | time.sleep(i) | ||||
| except Exception as e: | except Exception as e: | ||||
| @@ -45,6 +50,8 @@ class Buzzer(object): | |||||
| @cbpi.initalizer(order=1) | @cbpi.initalizer(order=1) | ||||
| def init(cbpi): | def init(cbpi): | ||||
| gpio = cbpi.get_config_parameter("buzzer", 16) | gpio = cbpi.get_config_parameter("buzzer", 16) | ||||
| cbpi.buzzer = Buzzer(gpio) | |||||
| beep_level = cbpi.get_config_parameter("buzzer_beep_level", "HIGH") | |||||
| cbpi.buzzer = Buzzer(gpio, beep_level) | |||||
| cbpi.beep() | cbpi.beep() | ||||
| cbpi.app.logger.info("INIT OK") | cbpi.app.logger.info("INIT OK") | ||||