2929from adafruit_bus_device import i2c_device
3030from adafruit_register .i2c_struct import ROUnaryStruct , UnaryStruct
3131from adafruit_register .i2c_bit import RWBit
32+ from adafruit_register .i2c_bits import RWBits
3233from micropython import const
3334
3435__version__ = "0.0.0-auto.0"
4647
4748# pylint: disable=invalid-name
4849
50+ # constant_current_range options
51+ AW9523_4_4_RANGE = const (0 ) # Full range: 0 - 37 mA (typical)
52+ AW9523_3_4_RANGE = const (1 ) # 3/4 range: 0 - 27.8 mA
53+ AW9523_2_4_RANGE = const (2 ) # 2/4 range: 0 - 18.5 mA
54+ AW9523_1_4_RANGE = const (3 ) # 1/4 range: 0 - 9.3 mA
55+
4956
5057class AW9523 :
5158 """CircuitPython helper class for using the AW9523 GPIO expander"""
@@ -67,6 +74,9 @@ class AW9523:
6774 # Whether port 0 is push-pull
6875 port0_push_pull = RWBit (_AW9523_REG_GCR , 4 )
6976
77+ # 256-step constant-current range selector 'ISEL' - choice of 'full' (4/4), 3/4, 2/4, or 1/4.
78+ constant_current_range = RWBits (2 , _AW9523_REG_GCR , 0 )
79+
7080 def __init__ (self , i2c_bus , address = _AW9523_DEFAULT_ADDR , reset = True ):
7181 self .i2c_device = i2c_device .I2CDevice (i2c_bus , address )
7282 self ._buffer = bytearray (2 )
0 commit comments