Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   NI LabVIEW (http://www.chiefdelphi.com/forums/forumdisplay.php?f=182)
-   -   Boolean Help? (http://www.chiefdelphi.com/forums/showthread.php?t=132668)

aspadiyath 12-01-2015 00:08

Boolean Help?
 
So I was harmlessly programming, when one of our drivers requested that when he presses a button, the indicator should show true. Then after he's pressed it once, it should stay true until he presses the same button again, making it false.
I know this is possible, but how?

Thanks!

Ether 12-01-2015 00:11

Re: Boolean Help?
 
Quote:

Originally Posted by aspadiyath (Post 1426550)
So I was harmlessly programming, when one of our drivers requested that when he presses a button, the indicator should show true. Then after he's pressed it once, it should stay true until he presses the same button again, making it false.
I know this is possible, but how?!

https://www.google.com/?gws_rd=ssl#q...m+latch+button

https://www.google.com/?gws_rd=ssl#q...+button+toggle



aspadiyath 12-01-2015 00:31

Re: Boolean Help?
 
How do I get the latch without a while loop?

Team118Joseph 12-01-2015 01:05

Re: Boolean Help?
 
So he wants it to toggle? If so you will need 2 bools. One will store the current mode state and the other will store the last state of the button. If the button is true, it will check the the last state of the button. If the last state is false, change the state of the mode.

Here is an example in C++
Code:

//this code is in the class header
bool pressed;
bool value;

//this code is in the initializer
pressed = false;//saves the button press
value = false;//what ever is being toggled


//this code is in the periodic thread
if(joystick->GetRawButton(1))//gets the button value and checks if it is true
{
        if(pressed == false)//Checks if the last button state was false
        {
                value = !value; //flips the value
        }
        pressed = true;//saves the buttons state
}
else//if the button is not pressed
{
        pressed = false;//saves the buttons state
}

I know its not LabView but the concept should be the same.

adciv 12-01-2015 07:24

Re: Boolean Help?
 
We have this VI in our programming library, available from this thread
http://www.chiefdelphi.com/forums/sh...d.php?t=131783
I believe it's under 'logic'.

Mark McLeod 12-01-2015 10:14

Re: Boolean Help?
 
One way, except note that buttons are now (2015) retrieved from an array.


All times are GMT -5. The time now is 08:47.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi