Hi All,
i’m new to the forum, i hope someone can help me with this.
I bought a unicorn phat and i’ve installed all the necessary libraries for python.
When i run thru the examlpes everything seems to work fine, but when i’ve actually started coding my own thing, i’ve noticed that the phat dosent light up if the value of the color i’m passing is smaller than 50 (with set_color or set_all functions).
What i mean is that i set some code like this:
unicornphat.set_all(40,40,40)
unicornphat.show()
all the pixels stays black. As soon as i put 50 or more i’m starting to see the pixel lighting up and with a correct luminance, it seems. I mean, they are starting to behave normally from 50 to 255 value, on any channel (rgb).
I thought it could be a power supply problem, so i’ve tried not only connected via usb to my computer but also with the official raspberry power supply 2.5A.
thanks for any help
[edit]
Doing some more experiments i can see that this threshold is changing if i change the brightness (with the berightness() function)
the lower limit of 50 is for maximum brightness (1). Going down with the brightness make the situation worse, and for example with 0,4 of brightness, the phat dosen’t light up until more than 100 of 255
Ok,
i think i found myself the reason why it’s happening, and if i’m correct all of you should have the same problem i have.
actually reading thru the unicorn-hat library, i can see that there is a gamma correction applied by default, and the first 22 numbers are 0. That mean that the numbers from 0 to 22 should give black. And on top of that, the unicorn library is set to half brightness by default, i mean that the brigntess(1) that is the maximum i can set, correspond to 128 of 255 brightness levels of the actual leds. That’s a “safety meausre” because otherwise the unicorn hat draws too much power, but what about the phat that is half the pixels? Should it be able to handle the full brightness? And that mean doubling the 22 zeroes to a nice 44, that is exactly when i start to see something.
I’ll have to fire up a Unicorn pHAT to confirm this since I haven’t played with the code for a while.
The limited brightness is a safety measure, but the gamma correction is to prevent things looking utterly terrible/washed out. It’s possible somethings borked up that makes it worse than it should be, but generally these effects are deliberate.
The problem is the difference between what you want, and what you actually see.
Say we simplify our colour range to just 8 levels:
level | what we want | what we see
0 | 0 | 0
1 | 1 | 4
2 | 2 | 4
3 | 3 | 4
4 | 4 | 4
5 | 5 | 5
6 | 6 | 6
7 | 7 | 7
This may not look like a problem when you take a single LED- sure it’s a bit bright at steps 1 through 3 but at least it’s on when we expect it.
Now, apply this to Red, Green and Blue pixels and that overbrightness translates into a washed-out look in certain colours.
I can’t recall if it’s in a release version of the library yet, but you could disable gamma correction to avoid this problem if you’re not worried about colour:
unicornhat.disable_gamma()
Or, alternatively, set your own gamma table: unicornhat.set_gamma(list_of_256_byte_values)