LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to dim the Boolean LED

A "color" in LabVIEW is a U32 constant. The last 24 bits indicate the RGB color, 8 bit each.

 

I am generating a white value of a certain brightness R=G=B (0(black)...255(white)). A bitwise AND with a certain mask sets some of the bits to zero, so the colors no longer add up to grey, but some color tint.

 

For example if I do a white (R=255, G=255, B=255), the constant in hex is x00FFFFFF , a bitwise AND with x000000FF, will give x000000FF, and a blue color.

Message 11 of 16
(2,247 Views)

Very nice trick. Cool.

Thanks for the explanation.

It took me some time to understand your words.

I know about RGB values from black (0,0,0) to white (255,255,255) .. but it didn't strike my mind that R=G=B keeps you on a Gray strip. Ok, so that you used as a Brightness factor. And with AND operator, it is doing "AND" with the hex. values.

I was also a bit confused with "sets some of the bits to zero" but finally understood you meant to say "sets some of the bits to zero, thus making them different from the others (R<>G<>B) and that's your deviation from the gray strip.

Cool.

 

But that AND will work only with the certain colors, with either 00 or FF values in each byte. Otherwise it will not give the same color after AND operation. For e.g. I changed the Red value to 00FFA000 and it became orange when full brightness, but on the way till complete dark, it was some color of greenish type also.

Good trick though!

Thanks for the explanation!

Vaibhav
0 Kudos
Message 12 of 16
(2,239 Views)

Vaibhav wrote:

But that AND will work only with the certain colors, with either 00 or FF values in each byte. Otherwise it will not give the same color after AND operation. For e.g. I changed the Red value to 00FFA000 and it became orange when full brightness, but on the way till complete dark, it was some color of greenish type also.


I does not make a lot of sense to use a mask that is not aligned with the color component boundary. You'll get some pretty useless results. 😉

0 Kudos
Message 13 of 16
(2,231 Views)

True.

So you are specifically working with the FF mask. What to do when there is a broad range of colors which do not share a common mask value? I guess some more complex logic is needed then.

Vaibhav
0 Kudos
Message 14 of 16
(2,224 Views)

If you want more complicated color ramps, you should not use masking, because you don't get very useful results. I would only use it to generate primary and secondary colors.

 

For example if you would mask off low oder bits of a color, you'll get stairsteps, while if you mask off high order bits, you'll get multiple sawtooths instead of a ramp.

 

For a more general color ramp, e.g. 0...255=white...yellow...red...blue, you would generate it as a lookup table and index into it.

 

 

Message 15 of 16
(2,202 Views)
Thanks for the tips!
Vaibhav
0 Kudos
Message 16 of 16
(2,159 Views)