Skip to content

Commit 0569351

Browse files
committed
tests: Add Ode to Joy melody test for buzzer qualification.
1 parent 7223472 commit 0569351

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

tests/scenarios/board_buzzer.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,39 @@ tests:
4545
prompt: "Avez-vous entendu un balayage de fréquence (grave vers aigu) ?"
4646
expect_true: true
4747
mode: [hardware]
48+
49+
- name: "Buzzer Ode to Joy"
50+
action: hardware_script
51+
script: |
52+
import pyb
53+
from time import sleep_ms
54+
timer = pyb.Timer(1, freq=440)
55+
ch = timer.channel(4, pyb.Timer.PWM, pin=pyb.Pin("SPEAKER"))
56+
# Ode to Joy (Beethoven) - first phrase
57+
# (frequency Hz, duration ms)
58+
melody = [
59+
(330, 300), (330, 300), (349, 300), (392, 300),
60+
(392, 300), (349, 300), (330, 300), (294, 300),
61+
(262, 300), (262, 300), (294, 300), (330, 300),
62+
(330, 450), (294, 150), (294, 600),
63+
(330, 300), (330, 300), (349, 300), (392, 300),
64+
(392, 300), (349, 300), (330, 300), (294, 300),
65+
(262, 300), (262, 300), (294, 300), (330, 300),
66+
(294, 450), (262, 150), (262, 600),
67+
]
68+
for freq, dur in melody:
69+
timer.freq(freq)
70+
ch.pulse_width_percent(50)
71+
sleep_ms(dur)
72+
ch.pulse_width_percent(0)
73+
sleep_ms(30)
74+
timer.deinit()
75+
result = True
76+
expect_true: true
77+
mode: [hardware]
78+
79+
- name: "Buzzer Ode to Joy audible"
80+
action: manual
81+
prompt: "Avez-vous reconnu l'Hymne à la joie (Beethoven) ?"
82+
expect_true: true
83+
mode: [hardware]

0 commit comments

Comments
 (0)