-
Notifications
You must be signed in to change notification settings - Fork 9
Add type annotation protocols for LEDs #11
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
Conversation
If this isn't widely used enough, I could also just type it in the relevant library |
If it's used in more than one library, it's good to have it in a central place. Otherwise you can put the definitions inside the |
If they get caught (or missed, really) because of the |
Right, it's static code size, either in the filesystem, or in a frozen module. |
Converted to draft for now. There may be other uses of this in the libraries but I'm not sure... I'll take a look and see if it's worth putting here or not! |
Okay, I found at least a few libraries that use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me to have this as a Protocol, I believe I've seen this concept used in multiple places and I'm sure there are likely more that I am unaware of.
Looks good to me.
I am more familiar with the ones that use fill()
. I don't recall seeing any that use color()
but they're probably among the ones I am unaware of.
I'm curious if you know about square bracket accessing in protocols? I believe neopixel and similar LEDs with a fill()
function also typically support things like:
led_strip_obj[0] = 0x00ff00
to set an individual LED by it's index to a given color. I don't know if it's possible to express this in a typing protocol but if so it might be nice to include that as well.
Looks like you'd need to define |
@FoamyGuy do you know of any libraries that would need that set in the Protocol? I don't necessarily want to over constrain the protocols if where they are doesn't require that specific behavior (ex: the only need to generically describe |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/adafruit/Adafruit_CircuitPython_led_animation
and the board specific helper libraries like:
https://github.com/adafruit/Adafruit_CircuitPython_PyBadger
https://github.com/adafruit/Adafruit_CircuitPython_CircuitPlayground
https://github.com/adafruit/Adafruit_CircuitPython_NeoTrellis
are the ones that come to mind that use neopixels. I'm not sure that any of them would specifically need this functionality though. The places I did see it typed so far looking around have it as NeoPixel. I think it makes sense to use that in these contexts instead of a protocol. So yeah, probably not worth adding the set_item. We can always do it later if a need arises.
Sounds good! |
Useful for typing LEDs without having to import them. Spawned from typing
adafruit_esp32spi
.