LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

LED tristate

Solved!
Go to solution

How to set LED indicator to three colors? Dark green (default), Green (Off) and RED (ON).

No callback used, only postUI message to set the led to on or off state.

Thanks.

0 Kudos
Message 1 of 3
(3,452 Views)
Solution
Accepted by topic author sonotk

Hi,

 

you almost gave the answer yourself Smiley Wink : I see two possibilities:

 

1) Use SetCtrlAttribute (, , ATTR_DFLT_VALUE, ); SetCtrlAttribute (, , ATTR_OFF_COLOR, ); or SetCtrlAttribute (, , ATTR_ON_COLOR, );

2) Since you are using the LED as indicator I see no functional difference between ON and OFF, so you could define your own function SetLEDState ( 0 / 1 / 2 ) where you simply change the ON color depending on your state, something like

 

int SetLEDState ( int panel, int control, int state )

{
    switch ( state ) 

    {
        case 0:

            color = VAL_DK_GREEN;

            break;    

        case 1:

            color = VAL_GREEN;

            break;

        case 2:

            color = VAL_RED;

            break;

     }

     SetCtrlAttribute ( panel, control, ATTR_ON_COLOR, color );

}

Message 2 of 3
(3,448 Views)

Another alternative is to use a picture ring loaded with three LED images with the proper colors and associated values: the desired color can then be obtained with a simple SetCtrlVal (panelHandle, PANEL_LED, color); call



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 3 of 3
(3,439 Views)