Skip to content

Allow disabling auto-show #14

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

Closed
adammhaile opened this issue Nov 19, 2018 · 5 comments
Closed

Allow disabling auto-show #14

adammhaile opened this issue Nov 19, 2018 · 5 comments

Comments

@adammhaile
Copy link
Contributor

I'll likely just make a PR of this myself when I have a minute, but it would be nice to have an auto_write param like the DotStar and NeoPixel libraries have. In fact, that param is already set in the Trellis M4 library when it loads the NeoPixel library. I realize this library is for convenience, but having auto_write always on every pixel set absolutely kills the performance. Once I wrote a little work-around like below, the performance is 10x better:

def set_pixel(x, y, c):
    offset = _w * y + x
    trellis.pixels._neopixel[offset] = c

# Convenience mapping
show_pixels = trellis.pixels._neopixel.show

I'm thinking it could be as simple as adding auto_write to the TrellisM4Express.init() method and passing it into the NeoPixel class if no one objects to just leaving it at that.

@kattni
Copy link
Contributor

kattni commented Nov 19, 2018

I think it would be as simple as that, yes, but I'm not sure I like the idea. The TrellisM4Express() init applies to the entire board. At the moment the only thing you can pass in is rotation which applies to both the NeoPixels and the buttons. auto_write is specific to the LEDs only and could be confusing. I'm not sure how else this could be implemented, and in the end, that may be what we do, but I'd like to consider some other options as well.

@adammhaile
Copy link
Contributor Author

@kattni What about calling it pixels_auto_write?
Or even letting you do something like this would be nice:

trellis = adafruit_trellism4.TrellisM4Express()
trellis.pixels.auto_write = False

One extra line but I'm fine with that. And actually it would allow you to disable auto write, do some updates, then re-enable it for less intense updates after.

@kattni
Copy link
Contributor

kattni commented Nov 19, 2018

The second suggestion is more what I have in mind. You're still interacting with the pixels in the same way as you are with everything else, and it's clear that auto_write is specific to pixels. I imagine you'd also have to add show to the _NeoPixel_Array class so that you can call show when needed.

@adammhaile
Copy link
Contributor Author

Works for me, and easy enough. Will do a PR shortly.

@kattni
Copy link
Contributor

kattni commented Nov 20, 2018

Fixed by #15

@kattni kattni closed this as completed Nov 20, 2018
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

No branches or pull requests

2 participants