Skip to content
Snippets Groups Projects
Commit 6a6ed4cb authored by David Huss's avatar David Huss :speech_balloon:
Browse files

Read notes from config

parent dbfbd539
Branches
No related tags found
No related merge requests found
......@@ -78,6 +78,22 @@ success_on_time = "[0.05]"
[buzzer]
active = true
# Midi note numbers and lengths in seconds - played on startup
startup_notes = [69, 82, 72]
startup_note_lengths = [0.9, 0.25, 2.9]
startup_note_stop_lengths = [0.1, 0.25, 0.1]
# Midi note numbers and lengths in seconds - played on successful scan
success_notes = [69, 72, 69]
success_note_lengths = [0.9, 0.25, 0.9]
success_note_stop_lengths = [0.1, 0.25, 0.1]
# Midi note numbers and lengths in seconds - played on successful scan
failure_notes = [63, 61, 60, 59]
failure_note_lengths = [0.9, 0.25, 0.9, 1.0]
failure_note_stop_lengths = [0.1, 0.25, 0.1, 0.1]
[server]
address = "127.0.0.1"
......@@ -165,47 +181,32 @@ def dispatch_buzzer(state, config):
def set_buzzer(state, config):
global buzzer_pin
f = 8.175799
buzzer = GPIO.PWM(buzzer_pin, f) # Set frequency to 1 Khz
state = str(state).strip().lower()
if state in ["startup", "ready"]:
f = 1000
buzzer = GPIO.PWM(buzzer_pin, f) # Set frequency to 1 Khz
for i, note in enumerate(config["buzzer"]["startup_notes"]):
buzzer.ChangeFrequency((1+note)*0.083333333*f) # Set frequency to 1 Khz
buzzer.start(50) # Set dutycycle to 10
time.sleep(0.1)
time.sleep(repeat(config["buzzer"]["startup_note_lengths"], i))
buzzer.stop()
time.sleep(0.1)
for i in [1, 3, 1, 2, 3, 4, 5, 6, 1]:
buzzer.ChangeFrequency((1+i)*0.083333333*f) # Set frequency to 1 Khz
buzzer.start(50) # Set dutycycle to 10
time.sleep(0.1)
buzzer.stop()
time.sleep(0.1)
time.sleep(repeat(config["buzzer"]["startup_note_stop_lengths"], i))
elif state in ["success"]:
f = 1000
buzzer = GPIO.PWM(buzzer_pin, f) # Set frequency to 1 Khz
for i, note in enumerate(config["buzzer"]["success_notes"]):
buzzer.ChangeFrequency((1+note)*0.083333333*f) # Set frequency to 1 Khz
buzzer.start(50) # Set dutycycle to 10
time.sleep(0.1)
time.sleep(repeat(config["buzzer"]["success_note_lengths"], i))
buzzer.stop()
time.sleep(0.1)
for i in [12, 1]:
buzzer.ChangeFrequency((1+i)*0.083333333*f) # Set frequency to 1 Khz
buzzer.start(50) # Set dutycycle to 10
time.sleep(0.1)
buzzer.stop()
time.sleep(0.1)
time.sleep(repeat(config["buzzer"]["success_note_stop_lengths"], i))
elif state in ["failure"]:
f = 1000
buzzer = GPIO.PWM(buzzer_pin, f) # Set frequency to 1 Khz
for i, note in enumerate(config["buzzer"]["failure_notes"]):
buzzer.ChangeFrequency((1+note)*0.083333333*f) # Set frequency to 1 Khz
buzzer.start(50) # Set dutycycle to 10
time.sleep(0.1)
buzzer.stop()
time.sleep(0.1)
for i in [5,3,2]:
buzzer.ChangeFrequency((1+i)*0.083333333*f) # Set frequency to 1 Khz
buzzer.start(50) # Set dutycycle to 10
time.sleep(0.1)
time.sleep(repeat(config["buzzer"]["failure_note_lengths"], i))
buzzer.stop()
time.sleep(0.1)
time.sleep(repeat(config["buzzer"]["failure_note_stop_lengths"], i))
def process_request(output_queue, config=None, logger=None):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment