@@ -8,37 +8,6 @@ class ModulinoBuzzer(Modulino):
8
8
"""
9
9
10
10
NOTES : dict [str , int ] = {
11
- "B0" : 31 ,
12
- "C1" : 33 ,
13
- "CS1" : 35 ,
14
- "D1" : 37 ,
15
- "DS1" : 39 ,
16
- "E1" : 41 ,
17
- "F1" : 44 ,
18
- "FS1" : 46 ,
19
- "G1" : 49 ,
20
- "GS1" : 52 ,
21
- "A1" : 55 ,
22
- "AS1" : 58 ,
23
- "B1" : 62 ,
24
- "C2" : 65 ,
25
- "CS2" : 69 ,
26
- "D2" : 73 ,
27
- "DS2" : 78 ,
28
- "E2" : 82 ,
29
- "F2" : 87 ,
30
- "FS2" : 93 ,
31
- "G2" : 98 ,
32
- "GS2" : 104 ,
33
- "A2" : 110 ,
34
- "AS2" : 117 ,
35
- "B2" : 123 ,
36
- "C3" : 131 ,
37
- "CS3" : 139 ,
38
- "D3" : 147 ,
39
- "DS3" : 156 ,
40
- "E3" : 165 ,
41
- "F3" : 175 ,
42
11
"FS3" : 185 ,
43
12
"G3" : 196 ,
44
13
"GS3" : 208 ,
@@ -102,10 +71,7 @@ class ModulinoBuzzer(Modulino):
102
71
"""
103
72
Dictionary with the notes and their corresponding frequencies.
104
73
The supported notes are defined as follows:
105
- - B0
106
- - C1, CS1, D1, DS1, E1, F1, FS1, G1, GS1, A1, AS1, B1
107
- - C2, CS2, D2, DS2, E2, F2, FS2, G2, GS2, A2, AS2, B2
108
- - C3, CS3, D3, DS3, E3, F3, FS3, G3, GS3, A3, AS3, B3
74
+ - FS3, G3, GS3, A3, AS3, B3
109
75
- C4, CS4, D4, DS4, E4, F4, FS4, G4, GS4, A4, AS4, B4
110
76
- C5, CS5, D5, DS5, E5, F5, FS5, G5, GS5, A5, AS5, B5
111
77
- C6, CS6, D6, DS6, E6, F6, FS6, G6, GS6, A6, AS6, B6
@@ -134,10 +100,13 @@ def tone(self, frequency: int, lenght_ms: int = 0xFFFF, blocking: bool = False)
134
100
If blocking is set to True, the function will wait until the tone is finished.
135
101
136
102
Parameters:
137
- frequency: The frequency of the tone in Hz
103
+ frequency: The frequency of the tone in Hz (freuqencies below 180 Hz are not supported)
138
104
lenght_ms: The duration of the tone in milliseconds. If omitted, the tone will play indefinitely
139
105
blocking: If set to True, the function will wait until the tone is finished
140
106
"""
107
+ if frequency < 180 and frequency != 0 :
108
+ raise ValueError ("Frequency must be greater than 180 Hz" )
109
+
141
110
self .data [0 :4 ] = frequency .to_bytes (4 , 'little' )
142
111
self .data [4 :8 ] = lenght_ms .to_bytes (4 , 'little' )
143
112
self .write (self .data )
0 commit comments