|
Re: Code doesnt work With While Loops
for button latching like the example you cited, you can do one of two things. if you only need to latch one button, go to the teleop front panel and drag two Boolean controls and two Boolean constants onto the front panel. I recommend naming the controls something like 'previous button value' &'last latched value' and the indicators 'button value' & 'latched value'. in the upper right corner of the front panel, right click on the vi icon and choose show connectors. hover over an empty box on the left side until the wire spool shows up,click the box and then click one of the controls, repeat for other control. then do the same for the indicators on the right side of the vi. now in the teleop block diagram you can recreate the case structures from the example but wire the shift registers on the while loop to the controls and indicators. finally in the robot main vi right click on the while loop and 'add shift register'(twice) then wire the shift registers to the new terminals we created on the teleop vi. this gives your latching function access to the main loop. 2nd option check out the typedef tutorial on FRCMastery.com, it is similar but way more useful for multiple reasons.
|