Quantcast
Channel: LabWindows/CVI topics
Viewing all articles
Browse latest Browse all 5340

User Interface update issue while CVI executes callback functions

$
0
0

Hi,

 

I have a simple CVI code that is intended to blink an LED on the panel for certain amount of time when the user double clicks(right) on a button in the panel. The CVI code is as bellow.

 

#include <ansi_c.h>
#include <utility.h>
#include <cvirte.h>
#include <userint.h>
#include "Run Callback Fn.h"
#include <stdio.h>

static int panelHandle;
int i=0;

int main (int argc, char *argv[])
{
if (InitCVIRTE (0, argv, 0) == 0)
return -1; /* out of memory */
if ((panelHandle = LoadPanel (0, "Run Callback Fn.uir", PANEL)) < 0)
return -1;
DisplayPanel (panelHandle);
RunUserInterface ();
DiscardPanel (panelHandle);
}


int CVICALLBACK Run (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{ int i=0;
switch (event)
{
case EVENT_RIGHT_DOUBLE_CLICK:
printf("Event Detected");
SetCtrlVal(panelHandle,PANEL_NUMERIC,23.78);
SetCtrlVal(panelHandle,PANEL_LED,1);
for(i=0;i<=100;i++)
{
SetCtrlVal(panelHandle,PANEL_LED,0);
Delay(1);
SetCtrlVal(panelHandle,PANEL_LED,1);
}
break;
}
return 0;
}

 

But its not working as intended. The state of led on front panel is updated only after the switch case finishes execution. Actually it has to update during the for loop is executing. Being a newbie, I don't have much idea about CVI programming. However i found the following information.

 

http://zone.ni.com/reference/en-XX/help/370051V-01/cvi/uiref/cviprocessing_events/

http://zone.ni.com/reference/en-XX/help/370051V-01/cvi/uiref/cviprocessdrawevents/

 

But i'm not sure how to use them.

 

Any help is highly appreciated.

 

Best Regards

Deepu Jacob


Viewing all articles
Browse latest Browse all 5340

Trending Articles