blaz-r / pi_pico_neopixel

Pi Pico library for NeoPixel led-strip written in MicroPython. Works with ws2812b (RGB) and sk6812 (RGBW).
MIT License
254 stars 54 forks source link

Update neopixel.py #3

Closed AndrewdAzotus closed 2 years ago

AndrewdAzotus commented 2 years ago

Amended to allow pixels to be set at non-default brightness

blaz-r commented 2 years ago

You can already set brightness using brightness function, where you call it like this: strip.brightness(<brightness value on interval 0 to 255>)

Is there a reason this doesn't do what you intended, because to me it looks like you could just use that.

AndrewdAzotus commented 2 years ago

When the brightness function is used, it sets the brightness for all future set_pixel calls. Adding the howBright parameter enables that default brightness to be overridden for that one single set_pixel rather than the program having to remember or retrieve the current brightness, change it to a different value, set a single pixel, then change the brightness back to its original value.

I thought it helped and made coding easier when calling set_pixel.

I have an existing fade candy where I 'ripple' a single pixel along the length of neoPixel strips by making it brighter than the default 'background' brightness then setting it back after a momentary delay and moving onto the next one.

HTH,

blaz-r commented 2 years ago

Yeah, I imagined it could be something like this. I will test this out tomorrow, but since the code seems backwards compatible, I'll most likely merge.

AndrewdAzotus commented 2 years ago

Thank you. I was careful to ensure backwards compatibility; it can be a nightmare when new code breaks old implementations.