|
Re: Toggle through button?
Okay, so the setup for LabView will be the same as in Java, you need to variables. In LabView, variables are just read/write calls to indicators and controls. Create two indicators or controls on the front panel (one boolean, one numeric). Then go to the block diagram, right-click, and go to the Structures pallet. There will be a gray box near the bottom that says "LOCAL". Click this and place it on the block diagram. It will have a question mark and a pin on the left. Click the question mark, and it will show a list of indicators and controls that currently exist in that VI. Select your boolean or numeric. To change the variable to read instead of write, right-click on the variable, and select "Change to Read". This will allow you to input and output data from the controls and indicators in your VI more than once.
However, since LabView is by nature a parallel language, we need a way of doing the increment and setting the last seen variable separately. To do this, you can use either a Flat Sequence Structure or a Stacked Sequence Structure (both in the structures pallet). A Flat Sequence structure looks like a film reel, and each frame is executed one after another, from left to right. To add a frame, right click on the right edge of the structure and select "Add Frame After". In the first frame, you need to have an AND operator (boolean pallet), a NOT operator on the lastSeen variable to negate its value (also boolean pallet), a Quotient and Remainder VI (numeric pallet, I think), and a case statement. The Quotient and Remainder VI works just like the "%" modulus symbol in the Java example, you plug in "number + 1" into X and "3" into Y, and the remainder appears on the top right corner (R, for "remainder). Wire that to your "number" variable.
In the next frame, you need to set "lastSeen" (or whatever you called your boolean variable) to the joystick button value.
That should be it, let me know if you want me to explain anything further.
|