Skip to content

Fix bytearray TypeError Issue For Non-Express Boards #5

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 5 commits into from
Apr 6, 2018

Conversation

sommersoft
Copy link
Collaborator

As outlined in Issue #4, the library was failing on a Trinket. I reproduced the error on a Trinket, but it ran fine on a Feather M0 Express (which was the dev platform I used). The non-express boards don't have array slicing enabled, which was causing the issue.

All slicing has been removed. Tested on 2.2.4 firmware with a Trinket and a Feather M0 Express. Runs without any issues I could capture.

Thanks to @chris-schmitz for submitting the well documented issue.

@@ -196,10 +196,9 @@ def brightness(self, brightness):

def show(self):
"""Refresh the LED buffer and show the changes."""
temp_led_buffer = bytearray(self._num_leds + 1)
Copy link
Member

Choose a reason for hiding this comment

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

Why did this have an extra byte? I see you shifted the indices above but I don't remember why.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's because the first byte when sending register info to the HT16K33 is the register location; in this case it should be 0x00 (the +1 in the buffer construct leaves the first byte untouched). Thanks for asking this question though, because it highlighted the fact that I forgot to change the array size of ._led_buffer to 17... Which was coincidentally causing the simpletest off-one-at-a-time problem. I really need to do better with curbing familiarity influencing methodical reviewing. 🤔

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

Close! One other off by one error I believe.

@@ -105,7 +105,7 @@ def __setitem__(self, x, value):
def fill(self, on):
fill = 0xff if on else 0x00
for buff in range(len(self._parent._i2c_devices)):
for i in range(16):
for i in range(1, 16):
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be 17 because the end is exclusive I believe.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Literally just facepalmed myself... Even though the HT16K33 didn't have a problem with it testing this way.

@tannewt
Copy link
Member

tannewt commented Apr 6, 2018

Thanks for the fix!

@tannewt tannewt merged commit 4b82601 into adafruit:master Apr 6, 2018
tannewt pushed a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Aug 9, 2018
Updating https://github.com/adafruit/Adafruit_CircuitPython_TLC5947 to 1.1.0 from 1.0.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_TLC5947#3 from kattni/pypi
  > updated CoC

Updating https://github.com/adafruit/Adafruit_CircuitPython_TLC59711 to 1.1.0 from 1.0.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_TLC59711#3 from kattni/pypi
  > updated CoC
  > Merge pull request adafruit/Adafruit_CircuitPython_TLC59711#2 from sommersoft/new_docs

Updating https://github.com/adafruit/Adafruit_CircuitPython_Trellis to 1.1.0 from 1.0.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_Trellis#8 from kattni/pypi
  > updated CoC
  > Merge pull request adafruit/Adafruit_CircuitPython_Trellis#7 from sommersoft/val_checks
  > Merge pull request adafruit/Adafruit_CircuitPython_Trellis#5 from sommersoft/bytearray_fix

Updating https://github.com/adafruit/Adafruit_CircuitPython_TSL2561 to 3.1.1 from 3.0.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_TSL2561#16 from kattni/pypi
  > updated CoC
  > Merge pull request adafruit/Adafruit_CircuitPython_TSL2561#15 from caternuson/master
  > Merge pull request adafruit/Adafruit_CircuitPython_TSL2561#14 from sommersoft/new_docs
  > Merge pull request adafruit/Adafruit_CircuitPython_TSL2561#13 from caternuson/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_TSL2591 to 1.1.0 from 1.0.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_TSL2591#4 from kattni/pypi
  > updated CoC

Updating https://github.com/adafruit/Adafruit_CircuitPython_VC0706 to 3.1.0 from 3.0.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_VC0706#4 from kattni/pypi
  > updated CoC

Updating https://github.com/adafruit/Adafruit_CircuitPython_VCNL4010 to 0.9.0 from 0.8.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_VCNL4010#4 from kattni/pypi
  > updated CoC
  > Merge pull request adafruit/Adafruit_CircuitPython_VCNL4010#3 from sommersoft/new_docs

Updating https://github.com/adafruit/Adafruit_CircuitPython_VEML6070 to 1.1.0 from 1.0.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_VEML6070#4 from kattni/pypi
  > updated CoC
  > Merge pull request adafruit/Adafruit_CircuitPython_VEML6070#3 from sommersoft/new_docs

Updating https://github.com/adafruit/Adafruit_CircuitPython_VL53L0X to 3.1.0 from 3.0.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_VL53L0X#4 from kattni/pypi
  > updated CoC
  > Merge pull request adafruit/Adafruit_CircuitPython_VL53L0X#3 from sommersoft/new_docs

Updating https://github.com/adafruit/Adafruit_CircuitPython_VL6180X to 1.1.0 from 1.0.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_VL6180X#4 from kattni/pypi
  > updated CoC
  > Merge pull request adafruit/Adafruit_CircuitPython_VL6180X#3 from sommersoft/new_docs

Updating https://github.com/adafruit/Adafruit_CircuitPython_WS2801 to 0.9.0 from 0.8.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_WS2801#2 from kattni/pypi
  > updated CoC
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.

2 participants