Skip to content

Commit 1706478

Browse files
committed
Add documentation to examples
1 parent 84acafd commit 1706478

10 files changed

+55
-1
lines changed

examples/distance.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
"""
2+
This example shows how to use the ModulinoDistance class to read the distance from the Time of Flight sensor of the Modulino.
3+
The sensor works by sending out short pulses of light and then measure the time it takes for some of the emitted light to come back
4+
when it hits an object. The time it takes for the light to come back is directly proportional to the distance between the sensor and the object.
5+
26
Initial author: Sebastian Romero ([email protected])
37
"""
48

examples/knob.py

+11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
"""
2+
This example shows how to use the ModulinoKnob class to read the value of a rotary encoder knob.
3+
The knob is used to increase or decrease a value. The knob is rotated clockwise to increase the value and counter-clockwise to decrease it.
4+
5+
You can register callbacks for the following events:
6+
- Press: The knob is pressed.
7+
- Release: The knob is released.
8+
- Rotate clockwise: The knob is rotated clockwise.
9+
- Rotate counter clockwise: The knob is rotated counter clockwise.
10+
11+
Use reset() to reset the knob value to 0.
12+
213
Initial author: Sebastian Romero ([email protected])
314
"""
415

examples/knob_buzzer.py

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
"""
2+
This example demonstrates how to use the ModulinoKnob and ModulinoBuzzer classes to play different notes using a buzzer.
3+
The knob is used to select the note to play. The knob is rotated clockwise to increase the frequency of the note and counter-clockwise to decrease it.
4+
Once the knob is pressed, the buzzer stops playing the note.
5+
Only the notes between 400 and 2000 Hz from the predefined list are played in this example.
6+
You can run print(ModulinoBuzzer.NOTES) to see the full list of available notes.
7+
28
Initial author: Sebastian Romero ([email protected])
39
"""
410

examples/knob_pixels.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
"""
2+
This example shows how to use the ModulinoKnob and ModulinoPixels classes to control a set of pixels with a knob.
3+
The knob is used to set the number of pixels to turn on.
4+
The range property of the knob is used to map the knob values to the number of pixels to turn on.
5+
26
Initial author: Sebastian Romero ([email protected])
37
"""
48

examples/movement.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
"""
2+
This example shows how to use the ModulinoMovement class to read the accelerometer
3+
and gyroscope values from the Modulino.
4+
25
Initial author: Sebastian Romero ([email protected])
36
"""
47

examples/pixels.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
"""
2+
This example shows how to use the ModulinoPixels class to control a set of pixels.
3+
The pixels are set to different colors and animations.
4+
You can use the ModulinoColor class to set predefined colors:
5+
- RED, GREEN, BLUE, YELLOW, CYAN, VIOLET, WHITE
6+
27
Initial author: Sebastian Romero ([email protected])
38
"""
49

examples/pixels_thermo.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
"""
2+
This example shows how to use the ModulinoPixels and ModulinoThermo classes to display the temperature on a pixel strip.
3+
A high temperature is represented by red color and a lower temperature with a yellow color.
4+
5+
The pixels will map to the temperature range so that the first pixel represents
6+
the lowest temperature and the last pixel the highest temperature of the predefined range.
7+
You can change the temperature range to accommodate the temperature range of your environment.
8+
29
Initial author: Sebastian Romero ([email protected])
310
"""
411

@@ -8,7 +15,7 @@
815
pixels = ModulinoPixels()
916
thermo_module = ModulinoThermo()
1017

11-
# Yellow to red scale with 8 steps in between
18+
# Yellow to red scale with 8 steps
1219
colors = [
1320
(255, 255, 0),
1421
(255, 204, 0),

examples/pressure.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
"""
2+
This example shows how to use the ModulinoPressure class to read the pressure,
3+
temperature and altitude from the Modulino.
4+
25
Initial author: Sebastian Romero ([email protected])
36
"""
47

examples/thermo.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
"""
2+
This example shows how to use the ModulinoThermo class to read
3+
the temperature and humidity from the Modulino.
4+
If those values are temporarily unavailable, they will be set to None.
5+
26
Initial author: Sebastian Romero ([email protected])
37
"""
48

examples/third_party_board.py

+7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
"""
2+
This example shows how to use the Modulino library with a third party board.
3+
When running on a non-Arduino board, the I2C bus must be initialized manually.
4+
Usually the available I2C buses are predefined and can be accessed by their number, e.g. I2C(0).
5+
If not, the pins for SDA and SCL must be specified.
6+
7+
Please note that the Modulinos are designed to work with a bus frequency of 100kHz.
8+
29
Initial author: Sebastian Romero ([email protected])
310
"""
411

0 commit comments

Comments
 (0)