47
47
class EEPROM :
48
48
"""
49
49
Driver base for the EEPROM Breakout.
50
+
51
+ :param int max_size: The maximum size of the EEPROM
52
+ :param bool write_protect: Turns on/off initial write protection
53
+ :param DigitalInOut wp_pin: (Optional) Physical pin connected to the ``WP`` breakout pin.
54
+ Must be a ``DigitalInOut`` object.
50
55
"""
51
56
52
57
def __init__ (self , max_size : int , write_protect : bool = False , wp_pin : Optional [DigitalInOut ] = None ) -> None :
@@ -79,9 +84,11 @@ def write_wraparound(self, value: bool) -> None:
79
84
def write_protected (self ) -> bool :
80
85
"""The status of write protection. Default value on initialization is
81
86
``False``.
87
+
82
88
When a ``WP`` pin is supplied during initialization, or using
83
89
``write_protect_pin``, the status is tied to that pin and enables
84
90
hardware-level protection.
91
+
85
92
When no ``WP`` pin is supplied, protection is only at the software
86
93
level in this library.
87
94
"""
@@ -90,7 +97,9 @@ def write_protected(self) -> bool:
90
97
def __len__ (self ) -> int :
91
98
"""The size of the current EEPROM chip. This is one more than the highest
92
99
address location that can be read or written to.
100
+
93
101
.. code-block:: python
102
+
94
103
eeprom = adafruit_24lc32.EEPROM_I2C()
95
104
# size returned by len()
96
105
len(eeprom)
@@ -101,7 +110,9 @@ def __len__(self) -> int:
101
110
102
111
def __getitem__ (self , address : Union [int , slice ]) -> bytearray :
103
112
"""Read the value at the given index, or values in a slice.
113
+
104
114
.. code-block:: python
115
+
105
116
# read single index
106
117
eeprom[0]
107
118
# read values 0 thru 9 with a slice
@@ -139,7 +150,9 @@ def __getitem__(self, address: Union[int, slice]) -> bytearray:
139
150
140
151
def __setitem__ (self , address : Union [int , slice ], value : Union [int , Sequence [int ]]) -> None :
141
152
"""Write the value at the given starting index.
153
+
142
154
.. code-block:: python
155
+
143
156
# write single index
144
157
eeprom[0] = 1
145
158
# write values 0 thru 4 with a list
@@ -194,12 +207,13 @@ def _write(self, start_address: int, data: Union[int, Sequence[int]], wraparound
194
207
195
208
class EEPROM_I2C (EEPROM ):
196
209
"""I2C class for EEPROM.
197
- :param: ~busio.I2C i2c_bus: The I2C bus the EEPROM is connected to.
198
- :param: int address: I2C address of EEPROM. Default address is ``0x50``.
199
- :param: bool write_protect: Turns on/off initial write protection.
200
- Default is ``False``.
201
- :param: wp_pin: (Optional) Physical pin connected to the ``WP`` breakout pin.
202
- Must be a ``digitalio.DigitalInOut`` object.
210
+
211
+ :param ~busio.I2C i2c_bus: The I2C bus the EEPROM is connected to.
212
+ :param int address: I2C address of EEPROM. Default address is ``0x50``.
213
+ :param bool write_protect: Turns on/off initial write protection.
214
+ Default is ``False``.
215
+ :param wp_pin: (Optional) Physical pin connected to the ``WP`` breakout pin.
216
+ Must be a ``DigitalInOut`` object.
203
217
"""
204
218
205
219
# pylint: disable=too-many-arguments
0 commit comments