22# SPDX-FileCopyrightText: Copyright (c) 2022 Gabriele Pongelli
33#
44# SPDX-License-Identifier: MIT
5+
56"""
6- `gpio_expander`
7+
8+ `gpio_expander`.
9+
710================================================================================
811
912CircuitPython helper library for gpio expanders (Texas Instrument PCA95xx and TCA95xx chips).
3538
3639# imports
3740try :
38- import typing # pylint: disable=unused-import
3941 from busio import I2C
4042except ImportError :
4143 pass
4244
4345__version__ = "0.0.0"
4446__repo__ = "https://github.com/gpongelli/CircuitPython_gpio_expander.git"
4547
46- from micropython import const
4748import adafruit_bus_device .i2c_device as i2cdevice
48-
4949from adafruit_register .i2c_bit import ROBit , RWBit
5050from adafruit_register .i2c_bits import ROBits , RWBits
51-
52- try :
53- from typing import Optional , Type , NoReturn
54- from circuitpython_typing .device_drivers import I2CDeviceDriver
55- except ImportError :
56- pass
51+ from micropython import const
5752
5853# For the PCA 953X and 955X series, the chips with 8 GPIO's have these port numbers
5954# The chips with 16 GPIO's have the first port for each type at double these numbers
@@ -80,7 +75,7 @@ def _get_registry_params(value, x):
8075 return _name , _reg_address_multiplier , _adder , _idx
8176
8277
83- class MetaGPIOExpander (type ):
78+ class _MetaGPIOExpander (type ):
8479 def __new__ (mcs , clsname , bases , dct , * args , ** kwargs ):
8580 result_dct = {}
8681
@@ -122,11 +117,11 @@ def __new__(mcs, clsname, bases, dct, *args, **kwargs):
122117 prop_name = f"C{ _name } { _idx } "
123118 result_dct [prop_name ] = _cfg_reg
124119
125- inst = super (MetaGPIOExpander , mcs ).__new__ (mcs , clsname , bases , result_dct )
120+ inst = super (_MetaGPIOExpander , mcs ).__new__ (mcs , clsname , bases , result_dct )
126121 return inst
127122
128123
129- class BaseGPIOExpander (metaclass = MetaGPIOExpander ):
124+ class _BaseGPIOExpander (metaclass = _MetaGPIOExpander ):
130125 def __init__ (self , i2c_bus : I2C , address : int , ** kwargs ) -> None :
131126 self .i2c_device = i2cdevice .I2CDevice (i2c_bus , address )
132127
@@ -135,26 +130,38 @@ def max_gpios(self):
135130
136131
137132# PCA series
138- class PCA9534 (BaseGPIOExpander ):
133+ class PCA9534 (_BaseGPIOExpander ):
134+ """PCA9534 8-Bit I2C I/O Expander."""
135+
139136 _NUM_GPIO = 8
140137
141138
142- class PCA9535 (BaseGPIOExpander ):
139+ class PCA9535 (_BaseGPIOExpander ):
140+ """PCA9535 16-Bit I2C I/O Expander."""
141+
143142 _NUM_GPIO = 16
144143
145144
146- class PCA9555 (BaseGPIOExpander ):
145+ class PCA9555 (_BaseGPIOExpander ):
146+ """PCA9555 16-Bit I2C I/O Expander."""
147+
147148 _NUM_GPIO = 16
148149
149150
150151# TCA series
151- class TCA9534 (BaseGPIOExpander ):
152+ class TCA9534 (_BaseGPIOExpander ):
153+ """TCA9534 Low-Voltage 8-Bit I2C I/O Expander."""
154+
152155 _NUM_GPIO = 8
153156
154157
155- class TCA9535 (BaseGPIOExpander ):
158+ class TCA9535 (_BaseGPIOExpander ):
159+ """TCA9535 Low-Voltage 16-Bit I2C I/O Expander."""
160+
156161 _NUM_GPIO = 16
157162
158163
159- class TCA9555 (BaseGPIOExpander ):
164+ class TCA9555 (_BaseGPIOExpander ):
165+ """TCA9555 Low-Voltage 16-Bit I2C I/O Expander."""
166+
160167 _NUM_GPIO = 16
0 commit comments