From ffd8a7fc3d0a9b6763c67a3a53bc1c08f1dbf7cc Mon Sep 17 00:00:00 2001 From: tekktrik <89490472+tekktrik@users.noreply.github.com> Date: Sat, 18 Dec 2021 18:13:32 -0500 Subject: [PATCH 1/4] Update ValueError text for storing anything but int in index --- adafruit_fram.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_fram.py b/adafruit_fram.py index 95e2e16..fa9461e 100755 --- a/adafruit_fram.py +++ b/adafruit_fram.py @@ -170,7 +170,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( From 1af04ad0bdc860e177426c93daf2322d24dc252b Mon Sep 17 00:00:00 2001 From: tekktrik <89490472+tekktrik@users.noreply.github.com> Date: Sat, 18 Dec 2021 18:14:15 -0500 Subject: [PATCH 2/4] Update example files to correctly implement getting and setting with slices --- examples/fram_i2c_simpletest.py | 6 +++--- examples/fram_spi_simpletest.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/fram_i2c_simpletest.py b/examples/fram_i2c_simpletest.py index 2bab14b..ec3c121 100644 --- a/examples/fram_i2c_simpletest.py +++ b/examples/fram_i2c_simpletest.py @@ -36,6 +36,6 @@ ## a buffer the size of slice, which may cause ## problems on memory-constrained platforms. -# values = list(range(100)) # or bytearray or tuple -# fram[0] = values -# print(fram[0:99]) +values = list(range(100)) # or bytearray or tuple +fram[0:100] = values +print(fram[0:100]) diff --git a/examples/fram_spi_simpletest.py b/examples/fram_spi_simpletest.py index 7af5c54..b0d3ef1 100644 --- a/examples/fram_spi_simpletest.py +++ b/examples/fram_spi_simpletest.py @@ -27,6 +27,6 @@ ## a buffer the size of 'length', which may cause ## problems on memory-constrained platforms. -# values = list(range(100)) # or bytearray or tuple -# fram[0] = values -# print(fram[0:99]) +values = list(range(100)) # or bytearray or tuple +fram[0:100] = values +print(fram[0:100]) From b9e888a505ebf3db08075197cf26b2895a7e3098 Mon Sep 17 00:00:00 2001 From: tekktrik <89490472+tekktrik@users.noreply.github.com> Date: Sat, 18 Dec 2021 18:16:38 -0500 Subject: [PATCH 3/4] Reofrmatted per pre-commit --- examples/fram_i2c_simpletest.py | 2 +- examples/fram_spi_simpletest.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/fram_i2c_simpletest.py b/examples/fram_i2c_simpletest.py index ec3c121..3555ff9 100644 --- a/examples/fram_i2c_simpletest.py +++ b/examples/fram_i2c_simpletest.py @@ -36,6 +36,6 @@ ## a buffer the size of slice, which may cause ## problems on memory-constrained platforms. -values = list(range(100)) # or bytearray or tuple +values = list(range(100)) # or bytearray or tuple fram[0:100] = values print(fram[0:100]) diff --git a/examples/fram_spi_simpletest.py b/examples/fram_spi_simpletest.py index b0d3ef1..ffb7a20 100644 --- a/examples/fram_spi_simpletest.py +++ b/examples/fram_spi_simpletest.py @@ -27,6 +27,6 @@ ## a buffer the size of 'length', which may cause ## problems on memory-constrained platforms. -values = list(range(100)) # or bytearray or tuple +values = list(range(100)) # or bytearray or tuple fram[0:100] = values print(fram[0:100]) From 23c8e36c1c2c996c4720b77c87d2c8fd3ca0a6c8 Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Tue, 21 Dec 2021 09:22:36 -0500 Subject: [PATCH 4/4] Comment out writes from examples --- examples/fram_i2c_simpletest.py | 6 +++--- examples/fram_spi_simpletest.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/fram_i2c_simpletest.py b/examples/fram_i2c_simpletest.py index 3555ff9..53851f7 100644 --- a/examples/fram_i2c_simpletest.py +++ b/examples/fram_i2c_simpletest.py @@ -36,6 +36,6 @@ ## a buffer the size of slice, which may cause ## problems on memory-constrained platforms. -values = list(range(100)) # or bytearray or tuple -fram[0:100] = values -print(fram[0:100]) +# values = list(range(100)) # or bytearray or tuple +# fram[0:100] = values +# print(fram[0:100]) diff --git a/examples/fram_spi_simpletest.py b/examples/fram_spi_simpletest.py index ffb7a20..920efa3 100644 --- a/examples/fram_spi_simpletest.py +++ b/examples/fram_spi_simpletest.py @@ -27,6 +27,6 @@ ## a buffer the size of 'length', which may cause ## problems on memory-constrained platforms. -values = list(range(100)) # or bytearray or tuple -fram[0:100] = values -print(fram[0:100]) +# values = list(range(100)) # or bytearray or tuple +# fram[0:100] = values +# print(fram[0:100])