Skip to content
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

add optional pixel_buffer and output_buffer args to NeoPixel to pass … #66

Open
wants to merge 1 commit into
base: master
from

Conversation

@rhooper
Copy link
Contributor

rhooper commented Jan 10, 2020

…in own buffers

Workaround for Issue #65

@tannewt

This comment has been minimized.

Copy link
Contributor

tannewt commented Jan 10, 2020

Why do we want this? Usually we only have buffers passed in if the object is short lived. Neopixel is long lived so it seems like we don't need this.

@rhooper

This comment has been minimized.

Copy link
Contributor Author

rhooper commented Jan 10, 2020

I don't know if we do. There might be something about #65 and what @sta-c0000 is doing that's worth supporting directly in NeoPixel, or if we should document how to use _pixelbuf with neopixel_write directly instead? This PR can be discarded if we don't want to support direct .buf updates (and the adafruit/circuitpython#2502 can also be closed).

@thanpolas

This comment has been minimized.

Copy link

thanpolas commented Jan 17, 2020

Hey @rhooper fwiw I tried this patch on my local and i still get the error:

Traceback (most recent call last):
  File "zzz.py", line 6, in <module>
    pixels[0] = (255, 0, 0)
  File "/home/pi/.local/lib/python3.7/site-packages/adafruit_pypixelbuf.py", line 260, in __setitem__
    self.show()
  File "/home/pi/.local/lib/python3.7/site-packages/neopixel.py", line 163, in show
    neopixel_write(self.pin, self.buf)
AttributeError: 'NeoPixel' object has no attribute 'buf'

My code:

import board
import neopixel

pixels = neopixel.NeoPixel(board.D18, 8)

pixels[0] = (255, 0, 0)

pixels.fill((0, 255, 0))
@Maxternight

This comment has been minimized.

Copy link

Maxternight commented Jan 17, 2020

Shouldn't you warn the users when you make these kind of changes? Im having the same problem as @thanpolas, I also tried to use the optional_buffer but it says that the init function has no optional_buffer parameter so i don't know what to do. I really wanted to change the color of a certain number of pixels not all like the fill function and I don't know how to do it now. Can you guys help ?

@rhooper

This comment has been minimized.

Copy link
Contributor Author

rhooper commented Jan 18, 2020

@Maxternight making things break wasn't intentional. You probably don't want this PR.

You can change arbitrary pixels with something like:

import board
import neopixel

pixels = neopixel.NeoPixel(board.NEOPIXEL, 10)
pixels[0] = (255, 0, 0)
pixels[3:6] = [(255, 0, 0), (0, 0, 255), (255,255,255)]
print(pixels)

which would set the first and 4th, 5th, and 6th pixels

@ladyada

This comment has been minimized.

Copy link
Member

ladyada commented Jan 18, 2020

@Maxternight @thanpolas hi i just pushed a fix, please reinstall adafruit-circuitpython-pypixelbuf (uninstall and reinstall thru pip)

@Maxternight

This comment has been minimized.

Copy link

Maxternight commented Jan 19, 2020

@rhooper im sorry for my comment, i know you guys work hard and sometimes some bugs can appear. It all works fine now, thank you @rhooper and @ladyada.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.