Skip to content

Commit

Permalink
Merge pull request #4 from tekktrik/fix/update-value-error
Browse files Browse the repository at this point in the history
Update ValueError raised when storing non-integer in index
  • Loading branch information
FoamyGuy committed Dec 20, 2021
2 parents f5c5b3c + 84e610b commit f8fc83f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion adafruit_24lc32.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def __setitem__(self, address, value):

if isinstance(address, int):
if not isinstance(value, int):
raise ValueError("Data must be a single integer for single addresses")
raise ValueError("Data stored in an address must be an integer 0-255")
if not 0 <= address < self._max_size:
raise ValueError(
"Address '{0}' out of range. It must be 0 <= address < {1}.".format(
Expand Down
10 changes: 4 additions & 6 deletions examples/24lc32_simpletest.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# SPDX-FileCopyrightText: Copyright (c) 2021 Tim Cocks for Adafruit Industries
#
# SPDX-License-Identifier: Unlicense

import board
import adafruit_eeprom
import adafruit_24lc32 as adafruit_eeprom

i2c = board.I2C()
eeprom = adafruit_eeprom.EEPROM_I2C(i2c)
Expand All @@ -12,8 +13,5 @@
eeprom[0] = 4
print(eeprom[0])

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

while True:
pass
eeprom[0:4] = [9, 3, 8, 1]
print(eeprom[0:4])

0 comments on commit f8fc83f

Please sign in to comment.