Skip to content

Update the API to support pypixelbuf 2.0 #15

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
Apr 29, 2020

Conversation

dunkmann00
Copy link
Contributor

Voila! #14

@dunkmann00
Copy link
Contributor Author

I'm pretty sure that both of those pylint complaints will go away with the changes to pypixelbuf.

@tannewt tannewt requested a review from caternuson April 28, 2020 03:12
@@ -95,7 +104,10 @@ def __init__(
if not pixel_order:
pixel_order = GRB if bpp == 3 else GRBW
else:
bpp = len(pixel_order)
if isinstance(pixel_order, tuple):
Copy link
Collaborator

Choose a reason for hiding this comment

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

What if it's a string instead of a tuple?

Strings are currently used in this library, but I'm not sure what the current desire is for pixel_order? tuple? string? both?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I should have left that line outside of the tuple check. That way when pixel_order is supplied we always use its length as bpp. Then we check if it is a tuple, if yes, it gets converted to a string. And if it is already a string it is good to go as is.

This fixes the problem you were seeing for RBGW as well.

@caternuson
Copy link
Collaborator

See code comment. Works for RGB but breaks for RGBW. It's failing to set bpp correctly.

import time
import board
import neopixel_spi as neopixel

NUM_PIXELS = 12
PIXEL_ORDER = neopixel.GRBW
COLORS = (0xFF0000, 0x00FF00, 0x0000FF)
DELAY = 0.1

pixels = neopixel.NeoPixel_SPI(board.SPI(), NUM_PIXELS, pixel_order=PIXEL_ORDER)

while True:
    for color in COLORS:
        for i in range(NUM_PIXELS):
            pixels[i] = color
            pixels.show()
            time.sleep(DELAY)
            pixels.fill(0)
Adafruit CircuitPython 5.1.0 on 2020-04-02; Adafruit ItsyBitsy M4 Express with samd51g19
>>> import test
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "test.py", line 15, in <module>
  File "/lib/neopixel_spi.py", line 147, in _transmit
  File "/lib/neopixel_spi.py", line 163, in _transmogrify
IndexError: bytearray index out of range
>>>  

@dunkmann00 dunkmann00 force-pushed the pypixelbuf-2.0-compat branch from 47a3357 to c953ef3 Compare April 28, 2020 21:33
@caternuson
Copy link
Collaborator

Yep. That seems to have fixed it.

@tannewt
Copy link
Member

tannewt commented Apr 29, 2020

Ok great! I'm going to merge now because the lint errors are based on the old version of pypixelbuf that is released.

@tannewt tannewt merged commit 887bb5e into adafruit:master Apr 29, 2020
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request May 1, 2020
Updating https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel to 6.0.0 from 5.1.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_NeoPixel#83 from adafruit/tannewt-patch-1
  > Merge pull request adafruit/Adafruit_CircuitPython_NeoPixel#82 from dunkmann00/pixelbuf

Updating https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel_SPI to 0.8.0 from 0.4.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_NeoPixel_SPI#15 from dunkmann00/pypixelbuf-2.0-compat

Updating https://github.com/adafruit/Adafruit_CircuitPython_AzureIoT to 2.0.0 from 1.1.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_AzureIoT#11 from jimbobbennett/master
  > build.yml: add black formatting check

Updating https://github.com/adafruit/Adafruit_CircuitPython_Pypixelbuf to 2.0.0 from 1.0.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_Pypixelbuf#19 from dunkmann00/dotstar_brightness
  > Merge pull request adafruit/Adafruit_CircuitPython_Pypixelbuf#18 from dunkmann00/_pixelbuf_cp
  > Merge pull request adafruit/Adafruit_CircuitPython_Pypixelbuf#17 from adafruit/black-update
  > build.yml: add black formatting check
  > Merge pull request adafruit/Adafruit_CircuitPython_Pypixelbuf#16 from kattni/update-example-name
  > Merge pull request adafruit/Adafruit_CircuitPython_Pypixelbuf#12 from adafruit/pylint-update
  > update code of coduct: discord moderation contact section
  > Merge pull request adafruit/Adafruit_CircuitPython_Pypixelbuf#11 from sommersoft/patch_coc
  > update pylintrc for black
@dunkmann00 dunkmann00 deleted the pypixelbuf-2.0-compat branch May 2, 2020 01:41
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