Skip to content

Commit 583f836

Browse files
committed
Add additional documentation
1 parent ae5afeb commit 583f836

File tree

4 files changed

+112
-3
lines changed

4 files changed

+112
-3
lines changed

src/modulino/buttons.py

+73-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ def set_led_status(self, a, b, c):
3131
3232
Parameters:
3333
a (bool): The status of the LED A.
34-
b (bool): The status of the LED B.
35-
c (bool): The status of the LED C.
34+
b (bool): The status of the LED B.
35+
c (bool): The status of the LED C.
3636
"""
3737
data = bytearray(3)
3838
data[0] = 1 if a else 0
@@ -42,82 +42,144 @@ def set_led_status(self, a, b, c):
4242

4343
@property
4444
def long_press_duration(self):
45+
"""
46+
Returns the duration in milliseconds that the button must
47+
be pressed to trigger the long press event
48+
"""
4549
return self._long_press_duration
4650

4751
@long_press_duration.setter
4852
def long_press_duration(self, value):
53+
"""
54+
Sets the duration in milliseconds that the button must
55+
be pressed to trigger the long press event
56+
"""
4957
self._long_press_duration = value
5058

5159
@property
5260
def on_button_a_press(self):
61+
"""
62+
Returns the callback for the press event of button A.
63+
"""
5364
return self._on_button_a_press
5465

5566
@on_button_a_press.setter
5667
def on_button_a_press(self, value):
68+
"""
69+
Sets the callback for the press event of button A.
70+
"""
5771
self._on_button_a_press = value
5872

5973
@property
6074
def on_button_a_release(self):
75+
"""
76+
Returns the callback for the release event of button A.
77+
"""
6178
return self._on_button_a_release
6279

6380
@on_button_a_release.setter
6481
def on_button_a_release(self, value):
82+
"""
83+
Sets the callback for the release event of button A.
84+
"""
6585
self._on_button_a_release = value
6686

6787
@property
6888
def on_button_a_long_press(self):
89+
"""
90+
Returns the callback for the long press event of button A.
91+
"""
6992
return self._on_button_a_long_press
7093

7194
@on_button_a_long_press.setter
7295
def on_button_a_long_press(self, value):
96+
"""
97+
Sets the callback for the long press event of button A.
98+
"""
7399
self._on_button_a_long_press = value
74100

75101
@property
76102
def on_button_b_press(self):
103+
"""
104+
Returns the callback for the press event of button B.
105+
"""
77106
return self._on_button_b_press
78107

79108
@on_button_b_press.setter
80109
def on_button_b_press(self, value):
110+
"""
111+
Sets the callback for the press event of button B.
112+
"""
81113
self._on_button_b_press = value
82114

83115
@property
84116
def on_button_b_release(self):
117+
"""
118+
Returns the callback for the release event of button B.
119+
"""
85120
return self._on_button_b_release
86121

87122
@on_button_b_release.setter
88123
def on_button_b_release(self, value):
124+
"""
125+
Sets the callback for the release event of button B.
126+
"""
89127
self._on_button_b_release = value
90128

91129
@property
92130
def on_button_b_long_press(self):
131+
"""
132+
Returns the callback for the long press event of button B.
133+
"""
93134
return self._on_button_b_long_press
94135

95136
@on_button_b_long_press.setter
96137
def on_button_b_long_press(self, value):
138+
"""
139+
Sets the callback for the long press event of button B.
140+
"""
97141
self._on_button_b_long_press = value
98142

99143
@property
100144
def on_button_c_press(self):
145+
"""
146+
Returns the callback for the press event of button C.
147+
"""
101148
return self._on_button_c_press
102149

103150
@on_button_c_press.setter
104151
def on_button_c_press(self, value):
152+
"""
153+
Sets the callback for the press event of button C.
154+
"""
105155
self._on_button_c_press = value
106156

107157
@property
108158
def on_button_c_release(self):
159+
"""
160+
Returns the callback for the release event of button C.
161+
"""
109162
return self._on_button_c_release
110163

111164
@on_button_c_release.setter
112165
def on_button_c_release(self, value):
166+
"""
167+
Sets the callback for the release event of button C.
168+
"""
113169
self._on_button_c_release = value
114170

115171
@property
116172
def on_button_c_long_press(self):
173+
"""
174+
Returns the callback for the long press event of button C.
175+
"""
117176
return self._on_button_c_long_press
118177

119178
@on_button_c_long_press.setter
120179
def on_button_c_long_press(self, value):
180+
"""
181+
Sets the callback for the long press event of button C.
182+
"""
121183
self._on_button_c_long_press = value
122184

123185
def update(self):
@@ -189,12 +251,21 @@ def is_pressed(self, index):
189251

190252
@property
191253
def button_a_pressed(self):
254+
"""
255+
Returns True if button A is currently pressed.
256+
"""
192257
return self.is_pressed(0)
193258

194259
@property
195260
def button_b_pressed(self):
261+
"""
262+
Returns True if button B is currently pressed.
263+
"""
196264
return self.is_pressed(1)
197265

198266
@property
199267
def button_c_pressed(self):
268+
"""
269+
Returns True if button C is currently pressed.
270+
"""
200271
return self.is_pressed(2)

src/modulino/buzzer.py

+17-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
22
from time import sleep_ms
33

44
class ModulinoBuzzer(Modulino):
5+
"""
6+
Class to play tones on the buzzer of the Modulino.
7+
The supported notes are defined as follows:
8+
- B0
9+
- C1, CS1, D1, DS1, E1, F1, FS1, G1, GS1, A1, AS1, B1
10+
- C2, CS2, D2, DS2, E2, F2, FS2, G2, GS2, A2, AS2, B2
11+
- C3, CS3, D3, DS3, E3, F3, FS3, G3, GS3, A3, AS3, B3
12+
- C4, CS4, D4, DS4, E4, F4, FS4, G4, GS4, A4, AS4, B4
13+
- C5, CS5, D5, DS5, E5, F5, FS5, G5, GS5, A5, AS5, B5
14+
- C6, CS6, D6, DS6, E6, F6, FS6, G6, GS6, A6, AS6, B6
15+
- C7, CS7, D7, DS7, E7, F7, FS7, G7, GS7, A7, AS7, B7
16+
- C8, CS8, D8, DS8
17+
- REST (Silence)
18+
19+
Those notes are accessible through ModulinoBuzzer.NOTES e.g. ModulinoBuzzer.NOTES["C4"]
20+
"""
521
NOTES = {
622
"B0": 31,
723
"C1": 33,
@@ -109,7 +125,7 @@ def tone(self, frequency, lenght_ms=0xFFFF, blocking=False):
109125
110126
Parameters:
111127
frequency: The frequency of the tone in Hz
112-
lenght_ms: The duration of the tone in milliseconds
128+
lenght_ms: The duration of the tone in milliseconds. If omitted, the tone will play indefinitely
113129
blocking: If set to True, the function will wait until the tone is finished
114130
"""
115131
self.data[0:4]=frequency.to_bytes(4,'little')

src/modulino/knob.py

+15
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ def update(self):
118118

119119
@property
120120
def range(self):
121+
"""
122+
Returns the range of the encoder value.
123+
"""
121124
return self._value_range
122125

123126
@range.setter
@@ -144,6 +147,9 @@ def range(self, value):
144147

145148
@property
146149
def on_rotate_clockwise(self):
150+
"""
151+
Returns the callback for the rotate clockwise event.
152+
"""
147153
return self._on_rotate_clockwise
148154

149155
@on_rotate_clockwise.setter
@@ -158,6 +164,9 @@ def on_rotate_clockwise(self, value):
158164

159165
@property
160166
def on_rotate_counter_clockwise(self):
167+
"""
168+
Returns the callback for the rotate counter clockwise event.
169+
"""
161170
return self._on_rotate_counter_clockwise
162171

163172
@on_rotate_counter_clockwise.setter
@@ -172,6 +181,9 @@ def on_rotate_counter_clockwise(self, value):
172181

173182
@property
174183
def on_press(self):
184+
"""
185+
Returns the callback for the press event.
186+
"""
175187
return self._on_press
176188

177189
@on_press.setter
@@ -186,6 +198,9 @@ def on_press(self, value):
186198

187199
@property
188200
def on_release(self):
201+
"""
202+
Returns the callback for the release event.
203+
"""
189204
return self._on_release
190205

191206
@on_release.setter

src/modulino/pixels.py

+7
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,13 @@ def clear(self, idx):
129129
self.set_color(idx, ModulinoColor(0, 0, 0), 0)
130130

131131
def clear_range(self, start, end):
132+
"""
133+
Turns off the LEDs in the given range.
134+
135+
Parameters:
136+
start (int): The starting index of the range.
137+
end (int): The ending index (inclusive) of the range.
138+
"""
132139
for i in range(start, end):
133140
self.clear(i)
134141

0 commit comments

Comments
 (0)