Johannes 7 роки тому
джерело
коміт
32125d3e6b
3 змінених файлів з 25 додано та 5 видалено
  1. +1
    -0
      config/schema.sql
  2. +13
    -1
      install.sh
  3. +11
    -4
      modules/buzzer/__init__.py

+ 1
- 0
config/schema.sql Переглянути файл

@@ -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 ('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_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 ('brew_name', '', 'text', 'Brew Name', NULL);
INSERT OR IGNORE INTO config VALUES ('donation_notification', 'YES', 'select', 'Disable Donation Notification', '["YES","NO"]');


+ 13
- 1
install.sh Переглянути файл

@@ -19,7 +19,8 @@ show_menu () {
"7" "Software Update (git pull)" \
"8" "Reset File Changes (git reset --hard)" \
"9" "Clear all logs" \
"10" "Reboot Raspberry Pi" 3>&1 1>&2 2>&3)
"10" "Reboot Raspberry Pi" \
"11" "Stop CraftBeerPi, Clear logs, Start CraftBeerPi" 3>&1 1>&2 2>&3)

BUTTON=$?
# Exit if user pressed cancel or escape
@@ -143,6 +144,17 @@ show_menu () {
show_menu
fi
;;
11)
confirmAnswer "Are you sure you want to reboot CraftBeerPi and delete all log files?"
if [ $? = 0 ]; then
sudo /etc/init.d/craftbeerpiboot stop
sudo rm -rf logs/*.log
sudo /etc/init.d/craftbeerpiboot start
show_menu
else
show_menu
fi
;;
esac
fi
}


+ 11
- 4
modules/buzzer/__init__.py Переглянути файл

@@ -10,10 +10,11 @@ except Exception as e:
class Buzzer(object):

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:
cbpi.app.logger.info("INIT BUZZER NOW GPIO%s" % gpio)
self.gpio = int(gpio)
self.beep_level = beep_level
GPIO.setmode(GPIO.BCM)
GPIO.setup(self.gpio, GPIO.OUT)
self.state = True
@@ -31,10 +32,14 @@ class Buzzer(object):
try:
for i in sound:
if (isinstance(i, str)):
if i == "H":
if i == "H" and self.beep_level == "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)
else:
GPIO.output(int(self.gpio), GPIO.HIGH)
else:
time.sleep(i)
except Exception as e:
@@ -45,6 +50,8 @@ class Buzzer(object):
@cbpi.initalizer(order=1)
def init(cbpi):
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.app.logger.info("INIT OK")

Завантаження…
Відмінити
Зберегти