Skip to content

Commit 4ea4388

Browse files
committed
Switch to sphinx documentation as requested
1 parent 26b9c8d commit 4ea4388

File tree

1 file changed

+25
-29
lines changed

1 file changed

+25
-29
lines changed

adafruit_mpr121.py

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,8 @@ class MPR121_Channel:
100100
def __init__(self, mpr121: MPR121, channel: int) -> None:
101101
"""Creates a new ``MPR121_Channel`` instance.
102102
103-
Args:
104-
mpr121: An instance of the touch sensor driver.
105-
channel: The channel this instance represents (0-11).
103+
:param mpr121: An instance of the touch sensor driver.
104+
:param channel: The channel this instance represents (0-11).
106105
"""
107106
self._mpr121 = mpr121
108107
self._channel = channel
@@ -156,9 +155,10 @@ class MPR121:
156155
def __init__(self, i2c: busio.I2C, address: int = MPR121_I2CADDR_DEFAULT) -> None:
157156
"""Creates a new ``MPR121`` instance.
158157
159-
Args:
160-
i2c: An I2C driver.
161-
address: The address of the touch sensor (0x5A - 0x5D).
158+
:param i2c: An I2C driver.
159+
:type i2c: class:`busio.I2C`
160+
:param address: The address of the touch sensor (0x5A - 0x5D).
161+
:type address: int
162162
"""
163163
self._i2c = i2c_device.I2CDevice(i2c, address)
164164
self._buffer = bytearray(2)
@@ -167,7 +167,7 @@ def __init__(self, i2c: busio.I2C, address: int = MPR121_I2CADDR_DEFAULT) -> Non
167167

168168
def __getitem__(self, key: int) -> MPR121_Channel:
169169
if key < 0 or key > 11:
170-
raise IndexError("pin must be a value 0-11.")
170+
raise IndexError("pin must be a value 0-11")
171171
if self._channels[key] is None:
172172
self._channels[key] = MPR121_Channel(self, key)
173173
return self._channels[key]
@@ -207,8 +207,7 @@ def reset(self) -> None:
207207
208208
All configurations and states previously set are lost.
209209
210-
Raises:
211-
RuntimeError: The sensor is in an invalid config state.
210+
:raises RuntimeError: The sensor is in an invalid config state.
212211
"""
213212
# Write to the reset register.
214213
self._write_register_byte(MPR121_SOFTRESET, 0x63)
@@ -255,14 +254,13 @@ def reset(self) -> None:
255254
def filtered_data(self, pin: int) -> int:
256255
"""Get the filtered data register value.
257256
258-
Args:
259-
pin: The pin to read (0 - 11).
257+
:param pin: The pin to read (0 - 11).
258+
:type pin: int
260259
261-
Returns:
262-
The filtered data value stored in the register.
260+
:raises ValueError: Argument ``pin`` is invalid.
263261
264-
Raises:
265-
ValueError: Argument ``pin`` is invalid.
262+
:return: The filtered data value stored in the register.
263+
:rtype: int
266264
"""
267265
if pin < 0 or pin > 11:
268266
raise ValueError("Pin must be a value 0-11.")
@@ -272,14 +270,13 @@ def filtered_data(self, pin: int) -> int:
272270
def baseline_data(self, pin: int) -> int:
273271
"""Get the baseline data register value.
274272
275-
Args:
276-
pin: The pin to read (0 - 11).
273+
:param pin: The pin to read (0 - 11).
274+
:type pin: int
277275
278-
Returns:
279-
The baseline data value stored in the register.
276+
:raises ValueError: Argument ``pin`` is invalid.
280277
281-
Raises:
282-
ValueError: Argument ``pin`` is invalid.
278+
:return: The baseline data value stored in the register.
279+
:rtype: int
283280
"""
284281
if pin < 0 or pin > 11:
285282
raise ValueError("Pin must be a value 0-11.")
@@ -289,22 +286,21 @@ def baseline_data(self, pin: int) -> int:
289286
def touched(self) -> int:
290287
"""Get the touch state of all pins as a 12-bit value.
291288
292-
Returns:
293-
A 12-bit value representing the touch state of each pin.
294-
Each state in the value is represented by either a 1 or 0;
295-
touched or not.
289+
:return: A 12-bit value representing the touch state of each
290+
pin. Each state in the value is represented by either a 1 or
291+
0; touched or not.
292+
:rtype: int
296293
"""
297294
self._read_register_bytes(MPR121_TOUCHSTATUS_L, self._buffer)
298295
return ((self._buffer[1] << 8) | (self._buffer[0])) & 0xFFFF
299296

300297
def is_touched(self, pin: int) -> bool:
301298
"""Get if ``pin`` is being touched.
302299
303-
Returns:
304-
True if ``pin`` is being touched; otherwise False.
300+
:raises ValueError: Argument ``pin`` is invalid.
305301
306-
Raises:
307-
ValueError: Argument ``pin`` is invalid.
302+
:return: True if ``pin`` is being touched; otherwise False.
303+
:rtype: bool
308304
"""
309305
if pin < 0 or pin > 11:
310306
raise ValueError("Pin must be a value 0-11.")

0 commit comments

Comments
 (0)