Skip to content

Add support for Pixelbuf #48

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 17 commits into from
May 11, 2020
Merged

Add support for Pixelbuf #48

merged 17 commits into from
May 11, 2020

Conversation

dunkmann00
Copy link
Contributor

@dunkmann00 dunkmann00 commented May 9, 2020

This adds support for pixelbuf which addresses #25.

I tested this with the DotStar on my itsybitsy and everything seemed to work okay. If someone else could give it a look with multiple DotStars that would be great.

This also fixes #37 and fixes #41.

@FoamyGuy
Copy link
Contributor

FoamyGuy commented May 9, 2020

I tested the pixelbuf branch successfully on Itsy Bitsy M0 CP version 5.3.0 with this code:

import time
import random
import board
import adafruit_dotstar as dotstar
 
# Using a DotStar Digital LED Strip with 30 LEDs connected to hardware SPI
dots = dotstar.DotStar(board.SCK, board.MOSI, 30, brightness=0.2)
 
# HELPERS
# a random color 0 -> 224
def random_color():
    return random.randrange(0, 7) * 32
 
 
# MAIN LOOP
n_dots = len(dots)
while True:
    # Fill each dot with a random color
    for dot in range(n_dots):
        dots[dot] = (random_color(), random_color(), random_color())
        
    for dot in range(n_dots):
        dots[dot] = (0,0,0)

Seems to work correctly as far as I can tell and blazing fast compared to current library.

@kevinjwalters
Copy link

Is it worth cleaning up the comment in the example code (https://github.com/adafruit/Adafruit_CircuitPython_DotStar/blob/master/examples/dotstar_simpletest.py#L17-L19) on the back of this? It should read 0 -> 192 as random.randrange() upper limit is exclusive.

@dunkmann00
Copy link
Contributor Author

@FoamyGuy If you could, it would be good to test the library with the same code, but with a version of CP < 5. This way you are also testing the pypixelbuf library implementation (which is needed in CP < 5 since pixelbuf isn't included).

@FoamyGuy
Copy link
Contributor

FoamyGuy commented May 10, 2020

@dunkmann00 On CP version 4.1.2 with the external pixelbuf library in the lib directory I get this error:

Traceback (most recent call last):
  File "code.py", line 7, in <module>
  File "/lib/adafruit_dotstar.py", line 144, in __init__
TypeError: unexpected keyword argument 'header'

On CP Version 5.0.0 the example code does work successfully as long as the external pixelbuf library in the lib directory. whether or not the external lib is present.

@FoamyGuy
Copy link
Contributor

@dunkmann00 Actually the previous error was a result of using the new dotstar branch along with a newer pixelbuf library on the Itsy Bitsy M0 with CP 4.1.2.

Using the new dotstar branch along with the pixelbuf library from the 4.x bundle it does work successfully (albeit noticeably a tad slower than the 5.X ones imo)

@dunkmann00
Copy link
Contributor Author

@FoamyGuy Thanks for checking that out! And you are correct that it is slower. The python version of pixelbuf, being python, isn't as performant. So if someone is currently using CP 4.x and looking for a performance boost, they would need to upgrade to CP 5.

@kattni
Copy link
Contributor

kattni commented May 11, 2020

@dunkmann00 Thank you for picking this up! Please take a look at the PR submitted to your PR by @rhooper as it resolves a couple of issues we found with your submission.

@rhooper
Copy link
Contributor

rhooper commented May 11, 2020

@dunkmann00 this looks great! Thanks for finishing it up!

I sent a small PR (@kattni already mentioned it).

I really should have checked for new PRs before I re-did my work... I even totally forgot about my old fork and branch, because I couldn't find it locally (It must be on my laptop).

@kattni
Copy link
Contributor

kattni commented May 11, 2020

@dunkmann00 @FoamyGuy Were the updates to dotstar_image_pov.py tested with a DotStar strip as intended?

@dunkmann00
Copy link
Contributor Author

@rhooper Np! I'm glad that @kattni did point out you already had worked on it...saved me some time!

@kattni
Copy link
Contributor

kattni commented May 11, 2020

@FoamyGuy will be testing the dotstar_image_pov.py update. Please wait to merge until the example is tested. Thanks!

@FoamyGuy
Copy link
Contributor

Tested with RasPi 3 B+. I had to install these:

pip3 install pillow
apt install libopenjp2-7
apt install libtiff5

After doing so the dotstar_image_pov.py seems to be working correctly. It's difficult to see with the bare eye. But I was able to wave a camera in front of it and see the text getting displayed.

Copy link
Contributor

@kattni kattni left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks all!

@kattni kattni merged commit f4f66fa into adafruit:master May 11, 2020
@dunkmann00 dunkmann00 deleted the pixelbuf branch May 12, 2020 02:35
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request May 12, 2020
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.

__get_item__ needs to support different pixel orders fill() function has undesired delay
5 participants