LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Feeding hex value into a color property node throws error

Solved!
Go to solution

Hello all,

 

First, thank you so much for all the help with a complete noob here.

 

I'm trying to simply figure how to throw a hex value at a color propery node to change the background color of a numeric indicator. I think I have the correct propery, the numtext.bgcolor.

 

I'm trying in a case structure in a simple example, to use a numeric constant that I set to Hex for the color code I want...and it throws a error 1077.

 

Here is an image of what I'm trying to do and the error....any suggestions where I'm going wrong?

 

Trying to change bg color block diagram

And the error:

 

Error trying to change bg on numeric indicator

Thank you in advance,

 

cayenne

0 Kudos
Message 1 of 13
(6,266 Views)

Don't attach huge images that are mostly white background. Attach your actual VI instead.

 

What is the datatype and value of your diagram constant? Colors should typcially not be larger than 00FFFFFF.

0 Kudos
Message 2 of 13
(6,263 Views)

Sorry....I thought they were small images....but I'm on a new, pretty high resolution monitor..that might have done it, and I didn't notice the size.

 

Here's the sample VI i'm trying.

 

In the case, I've tried for one case to use a hex number constant...the other case is a decimal..just trying both out...both fail with same error.

 

 

0 Kudos
Message 3 of 13
(6,259 Views)

The VI you have attached does not have any property nodes and does not resemble anything in your pictures above. Try again.

0 Kudos
Message 4 of 13
(6,258 Views)
Solution
Accepted by topic author cayenne

The value you are inputting is invalid, because it is too big. LabVIEW expects the RGB colors in the range 000000h (black) to FFFFFFh (white) and all combinations in between. The number you show in the screen shot is bigger, hence the error.

 

If you wan to experiment wire a color box control to a numeric indicator (U32) and set the display format for Hex.

David C
Message 5 of 13
(6,247 Views)

There are valid colors outside x000000 and xFFFFFF, so the above statement is not completely accurate. (see here). ... and tha's why I said "typically" above. 😉

 


cayenne wrote:

I'm trying to simply figure how to throw a hex value at a color propery node to change the background color of a numeric indicator. I think I have the correct propery, the numtext.bgcolor.

 


You seem to have some serious confusion. All the property node expects is an U32 integer in the correct range, it does not matter how it is formatted in the display, that is just cosmetic. Only the value is important.

 

Message 6 of 13
(6,225 Views)

@DavidCorney wrote:

The value you are inputting is invalid, because it is too big. LabVIEW expects the RGB colors in the range 000000h (black) to FFFFFFh (white) and all combinations in between. The number you show in the screen shot is bigger, hence the error.

 

If you wan to experiment wire a color box control to a numeric indicator (U32) and set the display format for Hex.


Thank you....after playing around...I finally got it to work.  ON the property, had to set the representation of my numerical constant (feeding into the color property of the numeric indicator)  to I32 or U32  (is one better than the other for changing color properties?)

 

Then in the properties of the numeric constant...I found where to toggle between display format (hex or decimal).

 

I was getting confused between the representation, and the display format....I'm still a little confused, but I"m guessing the former is how the number is actually stored in memory...while the display just is that...you can display it any way you want, but that doesn't change how it is stored in memory and used programmatically...is that correct?

 

Also, for help in finding colors....I found a calculator that calculates the RGB for you....into hex.

 

That way, can use the color picker tool bar....find the RGB for the color I like, plug it into this, and it spits out the hex code. This page also has a chart showing colors and their accompanyin hex codes...which helps things out much faster!!

 

RGB to Hex Calculator

 

Anyway, thanks...I think I'm now on the path to being able to change properties programmatically.

 

C

0 Kudos
Message 7 of 13
(6,224 Views)

@altenbach wrote:

There are valid colors outside x000000 and xFFFFFF, so the above statement is not completely accurate. (see here). ... and tha's why I said "typically" above. 😉

 


cayenne wrote:

I'm trying to simply figure how to throw a hex value at a color propery node to change the background color of a numeric indicator. I think I have the correct propery, the numtext.bgcolor.

 


You seem to have some serious confusion. All the property node expects is an U32 integer in the correct range, it does not matter how it is formatted in the display, that is just cosmetic. Only the value is important.

 


Part of my confusion was...that everything I was reading said that it was expecting a hex code for a RGB value in the color propery....I'd only gotten that it had to be either I32 or U32 from ya'll answer on this thread.

 

Is U32 better than I32 for some reason...it seemed to work with either as I play with it....

 

I think I'm in the ballpark now.

 

Thank you,

 

C

0 Kudos
Message 8 of 13
(6,223 Views)

@cayenne wrote:
Is U32 better than I32 for some reason...it seemed to work with either as I play with it....


You get ther correct datatype if you right-click the property node and select "create constant". Don't overthink things!

 

(While many other datatypes should work, you will get a coercion dot, which is considered ugly.)

0 Kudos
Message 9 of 13
(6,209 Views)

Part of my confusion was...that everything I was reading said that it was expecting a hex code for a RGB value in the color propery....I'd only gotten that it had to be either I32 or U32 from ya'll answer on this thread.

 

Is U32 better than I32 for some reason...it seemed to work with either as I play with it...

 


The property expects an unsigned 32 bit integer (U32). A U32 allows you to represent decimal numbers in the range 0 to 4294967295. With a signed 32 bit integer (I32) the most significant bit is used to represent the sign of the number. This gives you a number range between -2147483648 and 2147483647. What this means is that an I32 will work, but as has been noted, LabVIEW will coerce the datatype to a U32.

 

Showing the numbers using hexadecimal does not change the binary value, simply the way the number is displayed (Base 16). A value of 4294967295 decimal is Hex FFFFFFFF. Each pair of numbers (e.g. FF) represents a value between 1 and 255 decimal, making it easier to read the data (once you get the hang of base 16 :-).That is why the RGB colors are represented by 3 bytes of data as 000000 to FFFFFF in Hex. The additional byte (4 bytes = 32 bits), as has been explained, is used by LabVIEW for special colors, such as transparent.

 

Hope the above helps.

David C
Message 10 of 13
(6,202 Views)