From 9dba90fd92149f2d6e58f653cf35b0b1f366f6f6 Mon Sep 17 00:00:00 2001 From: Tony Hansen Date: Fri, 5 Jan 2024 20:59:43 -0500 Subject: [PATCH 1/3] Update adafruit_24lc32.py to add max_size parameter to EEPROM_I2C I would like to use this library with other EEPROMs in the 24C series or other EEPROMs that use the same I2C protocol. The only real difference is that they have different maximum sizes. The minimal change is to add a parameter to specify that maximum size. --- adafruit_24lc32.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/adafruit_24lc32.py b/adafruit_24lc32.py index 56e146f..d250407 100644 --- a/adafruit_24lc32.py +++ b/adafruit_24lc32.py @@ -232,13 +232,14 @@ def __init__( address: int = 0x50, write_protect: bool = False, wp_pin: Optional[DigitalInOut] = None, + max_size: in = _MAX_SIZE_I2C ) -> None: from adafruit_bus_device.i2c_device import ( # pylint: disable=import-outside-toplevel I2CDevice as i2cdev, ) self._i2c = i2cdev(i2c_bus, address) - super().__init__(_MAX_SIZE_I2C, write_protect, wp_pin) + super().__init__(max_size, write_protect, wp_pin) def _read_address(self, address: int, read_buffer: bytearray) -> bytearray: write_buffer = bytearray(2) From c0645afbb57f745fd6b16e1ef81aa9a4624d89b8 Mon Sep 17 00:00:00 2001 From: Tony Hansen Date: Fri, 5 Jan 2024 22:19:18 -0500 Subject: [PATCH 2/3] Update adafruit_24lc32.py fix typo also improve comment --- adafruit_24lc32.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/adafruit_24lc32.py b/adafruit_24lc32.py index d250407..51c45f9 100644 --- a/adafruit_24lc32.py +++ b/adafruit_24lc32.py @@ -223,6 +223,8 @@ class EEPROM_I2C(EEPROM): Default is ``False``. :param wp_pin: (Optional) Physical pin connected to the ``WP`` breakout pin. Must be a ``DigitalInOut`` object. + :param max_int: (Optional) Maximum # bytes stored in the EEPROM. + Default is ``_MAX_SIZE_I2C`` """ # pylint: disable=too-many-arguments @@ -232,7 +234,7 @@ def __init__( address: int = 0x50, write_protect: bool = False, wp_pin: Optional[DigitalInOut] = None, - max_size: in = _MAX_SIZE_I2C + max_size: int = _MAX_SIZE_I2C ) -> None: from adafruit_bus_device.i2c_device import ( # pylint: disable=import-outside-toplevel I2CDevice as i2cdev, From 303349bea2784175f8941856ca641190363d3921 Mon Sep 17 00:00:00 2001 From: Tony Hansen Date: Fri, 5 Jan 2024 22:23:58 -0500 Subject: [PATCH 3/3] Update adafruit_24lc32.py for black compatibility black requires a trailing comma --- adafruit_24lc32.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_24lc32.py b/adafruit_24lc32.py index 51c45f9..4f4360b 100644 --- a/adafruit_24lc32.py +++ b/adafruit_24lc32.py @@ -234,7 +234,7 @@ def __init__( address: int = 0x50, write_protect: bool = False, wp_pin: Optional[DigitalInOut] = None, - max_size: int = _MAX_SIZE_I2C + max_size: int = _MAX_SIZE_I2C, ) -> None: from adafruit_bus_device.i2c_device import ( # pylint: disable=import-outside-toplevel I2CDevice as i2cdev,