From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Blinking text in CVI

Solved!
Go to solution

Hi there !

I would like to make a text blink thanks to a timer callback. Here is the code of my timer (which has a period of 1sec) callback:

int CVICALLBACK REFRESH(int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
    if (bool==1)
    {
        bool=0;
        SetCtrlVal(atlas, PANEL_txt, "   ");
    }
    else
    {
        bool=1;
        SetCtrlVal(atlas, PANEL_txt, "ESSAI EN COURS");
    }
    return 0;
}

 

My code is compilling and the blinking is working. However, when I close the program, I get an error on this line :

SetCtrlVal(atlas, PANEL_txt, "   "); 

 with the error message "Library function error (return value ==-13). Invalid control ID ". Do you know where from it could be ? Or do you have another idea to make the text blink ?

Thank you in advance !

0 Kudos
Message 1 of 3
(2,249 Views)
Solution
Accepted by topic author emilie_grd

Timer controls generate two events: an EVENT_TIMER_TICK at every time interval and an EVENT_DISCARD when the panel containing the timer is discarded.  It appears that when you close your program, the EVENT_DISCARD calls your callback and tries to operate a control on a panel that you've previously discarded.

 

To prevent this, only execute the code in your timer callback when the event is EVENT_TIMER_TICK:

 

int CVICALLBACK REFRESH(int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
    if (event == EVENT_TIMER_TICK)
    {
        ...
    }
}
Message 2 of 3
(2,234 Views)

Thank you so much for your answer, now it is working !

0 Kudos
Message 3 of 3
(2,217 Views)