Skip to content

Fixed size when polling length of FRAM to reflect actual size #7

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 9 commits into from
Jan 26, 2019

Conversation

makermelissa
Copy link
Collaborator

Addressing #6

I also updated examples, comments, and error messages to reflect the change.

Copy link
Contributor

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Some style changes and also check for < 0 on __getitem__ and __setitem__

adafruit_fram.py Outdated
@@ -172,10 +172,9 @@ def __setitem__(self, key, value):
if not isinstance(value, (int, bytearray, list, tuple)):
raise ValueError("Data must be a single integer, or a bytearray,"
" list, or tuple.")
if key > self._max_size:
if key >= self._max_size:
raise ValueError("Requested register '{0}' greater than maximum"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Contributor

@jerryneedell jerryneedell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Tested on an I2C FRAM - len(fram) = 32768 -- yay!
Thank you!

@jerryneedell
Copy link
Contributor

of course Dan was far more thorough ... good suggestions.

@makermelissa
Copy link
Collaborator Author

I went ahead and implemented your changes and fixed a bug that I found with address slicing that caused the last address to not be included.

Copy link
Contributor

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good testing, finding the slice problem.

I noted some error messages that still said "register". It is up to you whether to change all the internal uses of "register" to "address" as well, for consistency. I think you could do a global search/replace and it would be fine (_read_register -> _read_adsress, etc.)

@makermelissa
Copy link
Collaborator Author

makermelissa commented Jan 25, 2019

Thanks. I went through and changed most of register to address except where it didn't make sense and tested again. Also I just did it manually because I don't trust the search/replace on mu.

@makermelissa
Copy link
Collaborator Author

I just noticed I had used a < instead of <= check for the first address. That's now fixed.

Copy link
Contributor

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Thank you for fixing the original bugs and for your patience with my nitpicking! I think the code is more readable now.

@dhalbert dhalbert merged commit 7d8369f into adafruit:master Jan 26, 2019
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Jan 26, 2019
Updating https://github.com/adafruit/Adafruit_CircuitPython_FRAM to 1.2.2 from 1.2.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_FRAM#7 from melissagirl/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_RA8875 to 1.0.1 from 1.0.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_RA8875#2 from melissagirl/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_BluefruitConnect to 1.0.5 from 1.0.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_BluefruitConnect#6 from dhalbert/add-simpletest

Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA:
  > Added the following libraries: Adafruit_CircuitPython_RA8875, Adafruit_CircuitPython_MIDI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants