LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Control 32-bit register with buttons

I am quite new with Labwindows.

 

I need to control a lot of 32-bit registers by using buttons to set or reset each bits.

(It would be so complicated to manage each button by  CALLBACK function).

Is there a simple way to controll array of buttons in Labwindows ? Or is there even a concept for "array of buttons" ?

Like in Labview with array and buttons as boolean variables.

 

0 Kudos
Message 1 of 5
(3,108 Views)

This depends on the version of CVI you have; CVI 2012 provides control arrays (http://zone.ni.com/reference/en-XX/help/370051T-01/cvi/uiref/programming_with_control_arrays/ But even in earlier versions you can use one callback for several controls.

0 Kudos
Message 2 of 5
(3,103 Views)

If you are using CVI 2010 or later you can use arrays of controls which can help you in this issue: here a tip on using them

 

EDIT Wolfgang preceded me often! Smiley Wink

 

Going a little bit further on his idea of a single callback for several controls, you can add to the controls appropriate callbackData with which can taylor the behaviour of the callback. Suppose you install a single callback on 32 buttons and add the bit index as callbackData on each of then with SetCtrlAttribute (..., ..., ATTR_CALLBACK_DATA, (void *)index); with index from 1 to 32: when you enter the callback you can simply read the callbackData you receive to immediately have the index of the bit to manipulate. The callbackData can only be assigned programmatically, you cannot set it in the UIR editor.



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?
0 Kudos
Message 3 of 5
(3,096 Views)

Thank for ur reply.

 

I am using CVI 2010. And i dont see how to assign a callback function to a control array.

Is it possible to control the buttons like a array of boolean variables?

 

 

 

0 Kudos
Message 4 of 5
(3,088 Views)

An alternative to using the callback data as suggested by Roberto is to simply check for the control id:

 

int CVICALLBACK DipSwitchButtonCallback (int panel, int ctrl, int event, void *cb, int e1, int e2)
{
    switch (ctrl)

 

This could be further simplified if the controls are built programmatically. But since you have CVI2010 you might try the control array...

0 Kudos
Message 5 of 5
(3,078 Views)