You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Alternative to adjust Brightness on RGB matrix #3409
Hey guys, Sorry if this as been discussed already but I can't find anything using google and search on here.
I've been playing around with the Feather M4 express and an 64x32 RGB matrix. First thing I've been looking for when I started running demos is for a way to reduce the brightness.
Is there any way I can hack my way to adjust the brightness? On all my other raspberry pi projects where I run an rgb matrix, I set them to half brightness because I feel like looking at it 100% brightness is way too intense.
Louis Beaudoin has it worked out in the SmartMatrix library. Maybe you could steal his code.
This works for me 64x64 panel, SmartMatrix, Teensy 3.6
void setBrightness(uint8_t brightness);
just select different color constants, like 0x7f7f7f or (127,127,127) instead of 0xffffff or WHITE or (255,255,255)
FYI, this approach doesn't seem to work on the MatrixPortal S3 with CircuitPython. The actual brightness of 0x7f7f7f is exactly the same as 0xffffff. :-(.
I was hoping this would be a solution, but no dice. I'm getting complaints about the LED being so bright it's hurting people's eyes, so I'm hoping a workaround will show up somehow.
I haven’t used the S3 version of the MatrixPortal yet, but suspect that the default color bit depth is set to two bits, just four levels of color brightness, limiting the granularity of intensity.
When instantiating the display in CircuitPython, the bit depth can be set to 6-bits which increases the brightness granularity — at a price of needing more memory to hold the display buffer.
If you are using CircuitPython displayio objects, you could apply something like PaletteFader to help. https://github.com/CedarGroveStudios/CircuitPython_PaletteFader It’s in the Community Bundle and can be installed using circup.
So, I have a RGBMatrix brightness workaround... you can even use a brightness control to adjust the brightness values of all text/vectorio shapes and displayed BMP images. I'm defining all color values in HLS instead of Hex, which makes it super simple to change the brightness without changing the color value (just adjust L/level). For BMPs, feed the pixel_shader into a function that converts the integer colors to HSL, then adjusts their level and inserts the new value back into the pixel_shader.
All colors are defined like this: device.hls(.85, .3, 1), and the hsl function in device.py applies the brightness adjustment.
All BMPs need their shader fed into this function: device.alphaPalette(bmpimage.pixel_shader) - which again applies the brightness adjustment to every indexed color used by the BMP.
It works well, although if you set the brightness too low... (anything around .2 or lower) colors will start shifting hue.
I haven’t used the S3 version of the MatrixPortal yet, but suspect that the default color bit depth is set to two bits, just four levels of color brightness, limiting the granularity of intensity. When instantiating the display in CircuitPython, the bit depth can be set to 6-bits which increases the brightness granularity — at a price of needing more memory to hold the display buffer. If you are using CircuitPython displayio objects, you could apply something like PaletteFader to help. https://github.com/CedarGroveStudios/CircuitPython_PaletteFader It’s in the Community Bundle and can be installed using circup.
Yup, that was the problem. After setting the buffer depth to 6-bits adjusting the RGB values by a scale enabled a decent control over brightness. Thanks for the suggestion!
Activity
jepler commentedon Sep 13, 2020
You're right that this isn't possible right now. It would need to be added "upstream", so I've filed a bug there: adafruit/Adafruit_Protomatter#19
Until that feature is added and then made available in Circuitpython, depending on what you're doing, you can
For the latter, we have some example code within another guide that you may be able to adapt -- the "Reshader" class https://learn.adafruit.com/ocean-epoxy-resin-lightbox-with-rgb-led-matrix-image-scroller/code-explanation
riffnshred commentedon Sep 13, 2020
Sweet, thank you Ill test those out
tejasxo commentedon Mar 21, 2022
Any update on this?
ladyada commentedon Mar 22, 2022
unlikely to be added any time soon, it is nontrivial
wb8nbs commentedon Dec 17, 2023
Louis Beaudoin has it worked out in the SmartMatrix library. Maybe you could steal his code.
This works for me 64x64 panel, SmartMatrix, Teensy 3.6
void setBrightness(uint8_t brightness);
czei commentedon Feb 21, 2024
FYI, this approach doesn't seem to work on the MatrixPortal S3 with CircuitPython. The actual brightness of 0x7f7f7f is exactly the same as 0xffffff. :-(.
I was hoping this would be a solution, but no dice. I'm getting complaints about the LED being so bright it's hurting people's eyes, so I'm hoping a workaround will show up somehow.
CedarGroveStudios commentedon Feb 21, 2024
I haven’t used the S3 version of the MatrixPortal yet, but suspect that the default color bit depth is set to two bits, just four levels of color brightness, limiting the granularity of intensity.
When instantiating the display in CircuitPython, the bit depth can be set to 6-bits which increases the brightness granularity — at a price of needing more memory to hold the display buffer.
If you are using CircuitPython displayio objects, you could apply something like PaletteFader to help. https://github.com/CedarGroveStudios/CircuitPython_PaletteFader It’s in the Community Bundle and can be installed using circup.
no3rdw commentedon Feb 21, 2024
So, I have a RGBMatrix brightness workaround... you can even use a brightness control to adjust the brightness values of all text/vectorio shapes and displayed BMP images. I'm defining all color values in HLS instead of Hex, which makes it super simple to change the brightness without changing the color value (just adjust L/level). For BMPs, feed the pixel_shader into a function that converts the integer colors to HSL, then adjusts their level and inserts the new value back into the pixel_shader.
Relevant code is in this file:
https://github.com/no3rdw/ledmatrix-effects/blob/main/device.py
All colors are defined like this:
device.hls(.85, .3, 1), and the hsl function in device.py applies the brightness adjustment.All BMPs need their shader fed into this function:
device.alphaPalette(bmpimage.pixel_shader)- which again applies the brightness adjustment to every indexed color used by the BMP.It works well, although if you set the brightness too low... (anything around .2 or lower) colors will start shifting hue.
czei commentedon Feb 21, 2024
Yup, that was the problem. After setting the buffer depth to 6-bits adjusting the RGB values by a scale enabled a decent control over brightness. Thanks for the suggestion!