@@ -100,9 +100,8 @@ class MPR121_Channel:
100
100
def __init__ (self , mpr121 : MPR121 , channel : int ) -> None :
101
101
"""Creates a new ``MPR121_Channel`` instance.
102
102
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).
106
105
"""
107
106
self ._mpr121 = mpr121
108
107
self ._channel = channel
@@ -156,9 +155,10 @@ class MPR121:
156
155
def __init__ (self , i2c : busio .I2C , address : int = MPR121_I2CADDR_DEFAULT ) -> None :
157
156
"""Creates a new ``MPR121`` instance.
158
157
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
162
162
"""
163
163
self ._i2c = i2c_device .I2CDevice (i2c , address )
164
164
self ._buffer = bytearray (2 )
@@ -167,7 +167,7 @@ def __init__(self, i2c: busio.I2C, address: int = MPR121_I2CADDR_DEFAULT) -> Non
167
167
168
168
def __getitem__ (self , key : int ) -> MPR121_Channel :
169
169
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" )
171
171
if self ._channels [key ] is None :
172
172
self ._channels [key ] = MPR121_Channel (self , key )
173
173
return self ._channels [key ]
@@ -207,8 +207,7 @@ def reset(self) -> None:
207
207
208
208
All configurations and states previously set are lost.
209
209
210
- Raises:
211
- RuntimeError: The sensor is in an invalid config state.
210
+ :raises RuntimeError: The sensor is in an invalid config state.
212
211
"""
213
212
# Write to the reset register.
214
213
self ._write_register_byte (MPR121_SOFTRESET , 0x63 )
@@ -255,14 +254,13 @@ def reset(self) -> None:
255
254
def filtered_data (self , pin : int ) -> int :
256
255
"""Get the filtered data register value.
257
256
258
- Args:
259
- pin: The pin to read (0 - 11).
257
+ :param pin: The pin to read (0 - 11).
258
+ :type pin: int
260
259
261
- Returns:
262
- The filtered data value stored in the register.
260
+ :raises ValueError: Argument ``pin`` is invalid.
263
261
264
- Raises:
265
- ValueError: Argument ``pin`` is invalid.
262
+ :return: The filtered data value stored in the register.
263
+ :rtype: int
266
264
"""
267
265
if pin < 0 or pin > 11 :
268
266
raise ValueError ("Pin must be a value 0-11." )
@@ -272,14 +270,13 @@ def filtered_data(self, pin: int) -> int:
272
270
def baseline_data (self , pin : int ) -> int :
273
271
"""Get the baseline data register value.
274
272
275
- Args:
276
- pin: The pin to read (0 - 11).
273
+ :param pin: The pin to read (0 - 11).
274
+ :type pin: int
277
275
278
- Returns:
279
- The baseline data value stored in the register.
276
+ :raises ValueError: Argument ``pin`` is invalid.
280
277
281
- Raises:
282
- ValueError: Argument ``pin`` is invalid.
278
+ :return: The baseline data value stored in the register.
279
+ :rtype: int
283
280
"""
284
281
if pin < 0 or pin > 11 :
285
282
raise ValueError ("Pin must be a value 0-11." )
@@ -289,22 +286,21 @@ def baseline_data(self, pin: int) -> int:
289
286
def touched (self ) -> int :
290
287
"""Get the touch state of all pins as a 12-bit value.
291
288
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
296
293
"""
297
294
self ._read_register_bytes (MPR121_TOUCHSTATUS_L , self ._buffer )
298
295
return ((self ._buffer [1 ] << 8 ) | (self ._buffer [0 ])) & 0xFFFF
299
296
300
297
def is_touched (self , pin : int ) -> bool :
301
298
"""Get if ``pin`` is being touched.
302
299
303
- Returns:
304
- True if ``pin`` is being touched; otherwise False.
300
+ :raises ValueError: Argument ``pin`` is invalid.
305
301
306
- Raises:
307
- ValueError: Argument ``pin`` is invalid.
302
+ :return: True if ``pin`` is being touched; otherwise False.
303
+ :rtype: bool
308
304
"""
309
305
if pin < 0 or pin > 11 :
310
306
raise ValueError ("Pin must be a value 0-11." )
0 commit comments