Skip to content

update docstrings. comment writes in simpletest #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions adafruit_24lc32.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,21 @@ def __len__(self):
"""The size of the current EEPROM chip. This is one more than the highest
address location that can be read or written to.
.. code-block:: python
fram = adafruit_fram.FRAM_xxx() # xxx = 'I2C' or 'SPI'
eeprom = adafruit_24lc32.EEPROM_I2C()
# size returned by len()
len(fram)
len(eeprom)
# can be used with range
for i in range(0, len(fram))
for i in range(0, len(eeprom))
"""
return self._max_size

def __getitem__(self, address):
"""Read the value at the given index, or values in a slice.
.. code-block:: python
# read single index
fram[0]
eeprom[0]
# read values 0 thru 9 with a slice
fram[0:9]
eeprom[0:9]
"""
if isinstance(address, int):
if not 0 <= address < self._max_size:
Expand Down Expand Up @@ -134,12 +134,12 @@ def __setitem__(self, address, value):
"""Write the value at the given starting index.
.. code-block:: python
# write single index
fram[0] = 1
eeprom[0] = 1
# write values 0 thru 4 with a list
fram[0:4] = [0,1,2,3]
eeprom[0:4] = [0,1,2,3]
"""
if self.write_protected:
raise RuntimeError("FRAM currently write protected.")
raise RuntimeError("EEPROM currently write protected.")

if isinstance(address, int):
if not isinstance(value, int):
Expand Down Expand Up @@ -230,7 +230,7 @@ def _write(self, start_address, data, wraparound=False):
else:
raise ValueError(
"Starting address + data length extends beyond"
" FRAM maximum address. Use ``write_wraparound`` to"
" EEPROM maximum address. Use ``write_wraparound`` to"
" override this warning."
)
with self._i2c as i2c:
Expand Down
12 changes: 6 additions & 6 deletions examples/24lc32_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
# SPDX-License-Identifier: Unlicense

import board
import adafruit_24lc32 as adafruit_eeprom
import adafruit_24lc32

i2c = board.I2C()
eeprom = adafruit_eeprom.EEPROM_I2C(i2c)
eeprom = adafruit_24lc32.EEPROM_I2C(i2c)

print("length: {}".format(len(eeprom)))

eeprom[0] = 4
print(eeprom[0])
# eeprom[0] = 4
# print(eeprom[0])

eeprom[0:4] = [9, 3, 8, 1]
print(eeprom[0:4])
# eeprom[0:4] = [9, 3, 8, 1]
# print(eeprom[0:4])