Skip to content

Commit 4287f7a

Browse files
committed
Add additional API documentation
1 parent a874813 commit 4287f7a

File tree

9 files changed

+66
-2
lines changed

9 files changed

+66
-2
lines changed

src/modulino/buttons.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,15 @@ class ModulinoButtons(Modulino):
1010
default_addresses = [0x7C]
1111
_default_long_press_duration = const(1000) # 1 second
1212

13-
def __init__(self, i2c_bus=None, address=None):
13+
def __init__(self, i2c_bus = None, address = None):
14+
"""
15+
Initializes the Modulino Buttons.
16+
17+
Parameters:
18+
i2c_bus (I2C): The I2C bus to use. If not provided, the default I2C bus will be used.
19+
address (int): The I2C address of the module. If not provided, the default address will be used.
20+
"""
21+
1422
super().__init__(i2c_bus, address, "BUTTONS")
1523
self.long_press_duration = self._default_long_press_duration
1624

src/modulino/buzzer.py

+7
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ class ModulinoBuzzer(Modulino):
117117
default_addresses = [0x3C]
118118

119119
def __init__(self, i2c_bus=None, address=None):
120+
"""
121+
Initializes the Modulino Buzzer.
122+
123+
Parameters:
124+
i2c_bus (I2C): The I2C bus to use. If not provided, the default I2C bus will be used.
125+
address (int): The I2C address of the module. If not provided, the default address will be used.
126+
"""
120127
super().__init__(i2c_bus, address, "BUZZER")
121128
self.data = bytearray(8)
122129
self.no_tone()

src/modulino/distance.py

+8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ class ModulinoDistance(Modulino):
1010
convert_default_addresses = False
1111

1212
def __init__(self, i2c_bus = None, address: int | None = None) -> None:
13+
"""
14+
Initializes the Modulino Distance.
15+
16+
Parameters:
17+
i2c_bus (I2C): The I2C bus to use. If not provided, the default I2C bus will be used.
18+
address (int): The I2C address of the module. If not provided, the default address will be used.
19+
"""
20+
1321
super().__init__(i2c_bus, address, "DISTANCE")
1422
self.sensor = VL53L4CD(self.i2c_bus, self.address)
1523
self.sensor.timing_budget = 20

src/modulino/knob.py

+8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ class ModulinoKnob(Modulino):
1010
default_addresses = [0x74, 0x76]
1111

1212
def __init__(self, i2c_bus = None, address = None):
13+
"""
14+
Initializes the Modulino Knob.
15+
16+
Parameters:
17+
i2c_bus (I2C): The I2C bus to use. If not provided, the default I2C bus will be used.
18+
address (int): The I2C address of the module. If not provided, the default address will be used.
19+
"""
20+
1321
super().__init__(i2c_bus, address, "ENCODER")
1422
self._pressed: bool = None
1523
self._encoder_value: int = None

src/modulino/modulino.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ def __init__(self, i2c_bus: I2C = None, address: int = None, name: str = None):
130130
If the address is provided, the device will check if it is connected to the bus.
131131
If the address is 8-bit, it will be converted to 7-bit.
132132
If no bus is provided, the default bus will be used if available.
133+
134+
Parameters:
135+
i2c_bus (I2C): The I2C bus to use. If not provided, the default I2C bus will be used.
136+
address (int): The address of the device. If not provided, the device will try to auto discover it.
137+
name (str): The name of the device.
133138
"""
134139

135140
if i2c_bus is None:
@@ -159,7 +164,7 @@ def __init__(self, i2c_bus: I2C = None, address: int = None, name: str = None):
159164
def discover(self, default_addresses: list[int]) -> int | None:
160165
"""
161166
Tries to find the given modulino device in the device chain
162-
based on the pre-defined default addresses.
167+
based on the pre-defined default addresses. The first address found will be returned.
163168
If the address has been changed to a custom one it won't be found with this function.
164169
165170
Returns:

src/modulino/movement.py

+7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ class ModulinoMovement(Modulino):
1212
convert_default_addresses = False
1313

1414
def __init__(self, i2c_bus = None, address: int | None = None) -> None:
15+
"""
16+
Initializes the Modulino Movement.
17+
18+
Parameters:
19+
i2c_bus (I2C): The I2C bus to use. If not provided, the default I2C bus will be used.
20+
address (int): The I2C address of the module. If not provided, the default address will be used.
21+
"""
1522
super().__init__(i2c_bus, address, "MOVEMENT")
1623
self.sensor = LSM6DSOX(self.i2c_bus, address=self.address)
1724

src/modulino/pixels.py

+7
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ class ModulinoPixels(Modulino):
5858
default_addresses = [0x6C]
5959

6060
def __init__(self, i2c_bus = None, address=None):
61+
"""
62+
Initializes the Modulino Pixels.
63+
64+
Parameters:
65+
i2c_bus (I2C): The I2C bus to use. If not provided, the default I2C bus will be used.
66+
address (int): The I2C address of the module. If not provided, the default address will be used.
67+
"""
6168
super().__init__(i2c_bus, address, "LEDS")
6269
self.clear_all()
6370

src/modulino/pressure.py

+7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ class ModulinoPressure(Modulino):
1212
convert_default_addresses = False
1313

1414
def __init__(self, i2c_bus: I2C = None, address: int = None) -> None:
15+
"""
16+
Initializes the Modulino Pressure.
17+
18+
Parameters:
19+
i2c_bus (I2C): The I2C bus to use. If not provided, the default I2C bus will be used.
20+
address (int): The I2C address of the module. If not provided, the default address will be used.
21+
"""
1522
super().__init__(i2c_bus, address, "PRESSURE")
1623
self.sensor = LPS22H(self.i2c_bus, self.address)
1724

src/modulino/thermo.py

+7
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ class ModulinoThermo(Modulino):
1818
DEFAULT_ADDRESS = const(0x44)
1919

2020
def __init__(self, i2c_bus: I2C = None, address: int = DEFAULT_ADDRESS) -> None:
21+
"""
22+
Initializes the Modulino Thermo.
23+
24+
Parameters:
25+
i2c_bus (I2C): The I2C bus to use. If not provided, the default I2C bus will be used.
26+
address (int): The I2C address of the module. If not provided, the default address will be used.
27+
"""
2128
super().__init__(i2c_bus, address, "THERMO")
2229
self.sensor: hs3003.HS3003 = hs3003.HS3003(self.i2c_bus)
2330

0 commit comments

Comments
 (0)