|
25 | 25 | Use this class if you are using a PCA9555 or compatible expander. This class is also used |
26 | 26 | as the base class for the PCAL9555 expander. |
27 | 27 |
|
28 | | -There are likely other devices that use this same command set and can be used with this class. |
29 | | -Where I find them, I will probably make a separate class name to make it obvious what devices are |
30 | | -supported. A list of other devices that should be compatible is below. |
| 28 | +Required library files (.py or their .mpy equivalent): |
| 29 | +
|
| 30 | +* PCA9555.py |
| 31 | +* i2c_expander.py |
| 32 | +* digital_inout.py |
| 33 | +* helpers.py |
31 | 34 |
|
32 | 35 | Compatible Devices |
33 | 36 |
|
34 | 37 | * PCA9555 |
35 | | -* TODO |
| 38 | +
|
| 39 | +These are devices I have specifically tested and know work. There appear to be a lot more devices |
| 40 | +with similar naming schemes that use the same register map. These should also be compatible, but |
| 41 | +make sure you check the i2c address and default register state. |
36 | 42 |
|
37 | 43 | Heavily based on the code written by Tony DiCola for the MCP230xx library. |
38 | 44 |
|
39 | 45 | * Author(s): Pat Satyshur |
40 | 46 | """ |
41 | 47 |
|
42 | | -# DriveMode: PUSH_PULL vs OPEN_DRAIN |
43 | | -# Pull: Pull.Up vs Pull.DOWN vs None |
44 | | -# TODO: Handle interrupts in here somewhere |
| 48 | +from micropython import const |
45 | 49 |
|
46 | | -from micropython import ( |
47 | | - const, |
48 | | -) # TODO: What does const get me in this situation? Can I remove it? |
49 | 50 | from i2c_expanders.i2c_expander import I2c_Expander |
50 | 51 | from i2c_expanders.helpers import _enable_bit, Capability |
51 | 52 |
|
52 | | -# from i2c_expanders.digital_inout import _enable_bit |
53 | | - |
54 | 53 | __version__ = "0.0.0+auto.0" |
55 | 54 | __repo__ = "https://github.com/ilikecake/CircuitPython_I2C_Expanders.git" |
56 | 55 |
|
57 | | -# TODO: this will probably change based on the device used. |
58 | | -# Not sure how to deal with this. Maybe remove the default and |
59 | | -# force the user to specify the address? |
| 56 | +# This is the default address for the PCA9555 with all addr pins grounded. |
| 57 | +_PCA9555_DEFAULT_ADDRESS = const(0x20) |
60 | 58 |
|
61 | | -_PCA9555_ADDRESS = const(0x20) |
62 | 59 | _PCA9555_INPUT0 = const(0x00) # Input register 0 |
63 | 60 | _PCA9555_INPUT1 = const(0x01) # Input register 1 |
64 | 61 | _PCA9555_OUTPUT0 = const(0x02) # Output register 0 |
|
70 | 67 |
|
71 | 68 |
|
72 | 69 | class PCA9555(I2c_Expander): |
73 | | - """Supports PCA9555 instance on specified I2C bus and optionally |
74 | | - at the specified I2C address. |
| 70 | + """The class for the PCA9555 expander. Instantiate one of these for each expander on the bus. |
| 71 | + Make sure you get the address right. |
75 | 72 | """ |
76 | 73 |
|
77 | | - def __init__(self, i2c, address=_PCA9555_ADDRESS, reset=True): |
| 74 | + def __init__(self, i2c, address=_PCA9555_DEFAULT_ADDRESS, reset=True): |
78 | 75 | super().__init__(i2c, address) |
79 | 76 | self._maxpins = 15 |
80 | 77 | self._capability = _enable_bit(0x00, Capability.INVERT_POL) |
|
0 commit comments