I’d like to be able to control the brightness setting on individual LEDs. I know you can do this on the PiGlow, but is there way to do this on the Unicorn HAT and Unicorn pHAT?
Internally, all the brightness really does is scale down your colour values accordingly. You can do this manually quite easily.
Imagine you set a pixel to full white, that’s RGB 255, 255, 255
. If brightness is set to 50% then internally it will write 128,128,128
to the Unicorn HAT.
You can scale your own colours in the same way. Something like:
r, g, b = 128, 255, 78
brightness = 0.2
r, g, b = [int(x * brightness) for x in (r, g, b)]
Thanks! That suggestion helped make my program do what I wanted it to do.