Gamma correction on RGB LED’s (or something like that).

So today I’ve been working with some RGB LED’s once again and I’ve notice (or rather re noticed) how non-linear LED’s appear.

A bit of background: I’m working with 5050 type LED’s with ws2803/1 drivers, so each LED gets 8bit PWM for Red, Green and Blue LED’s. The problem is that when you drive the LED’s with signal, zero is off, and 255 is the brightest, but 128 is brighter than half brightness. So in fact the input data to the perceived output level appears to be┬ánon linear.

So I could just work out a mapping of input values to output values, but that’s not very smart is it… I could use some primitive squaring to obtain a kind of gamma correction, of I could use some Maths (yes Maths is Maths and not Math!). The only problem there is that my ability to create a complex but awesome function way surpasses the abilities of the Arduino I’m using to drive the LED’s. Might have to get creative on this one…

Anyway here’s some LED’s to keep everyone happy,

Learning verilog….

So it’s not as bad as you first might think. It turns out that real time logic isn’t much different from process logic. Tho I did fall at the first hurdle:

So apparently the file name has to be the same as the entity name and that needs to be the top level entity. Furthermore the module inside it needs to have the same name also.

oh, and ‘end module’ is actually ‘endmodule’, or it will fail to compile!

(This is in QuartusII FYI.)