Go to Post Not everything has to be cashed in or has to have instant recognition. Sometimes being a part of a program of value and opportunity is enough. And, what you put into the program is what you get out of it. - JaneYoung [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 12-01-2015, 00:08
aspadiyath aspadiyath is offline
Registered User
FRC #3206
 
Join Date: Jan 2015
Location: Minnesota
Posts: 2
aspadiyath is an unknown quantity at this point
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!
Reply With Quote
  #2   Spotlight this post!  
Unread 12-01-2015, 00:11
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,015
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Boolean Help?

Quote:
Originally Posted by aspadiyath View Post
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



Last edited by Ether : 12-01-2015 at 00:15.
Reply With Quote
  #3   Spotlight this post!  
Unread 12-01-2015, 00:31
aspadiyath aspadiyath is offline
Registered User
FRC #3206
 
Join Date: Jan 2015
Location: Minnesota
Posts: 2
aspadiyath is an unknown quantity at this point
Re: Boolean Help?

How do I get the latch without a while loop?
Reply With Quote
  #4   Spotlight this post!  
Unread 12-01-2015, 01:05
Team118Joseph's Avatar
Team118Joseph Team118Joseph is offline
The guy that did the lighting
AKA: Joseph Foster
FRC #0118 (Robonauts)
Team Role: Alumni
 
Join Date: Jan 2014
Rookie Year: 2013
Location: League City
Posts: 61
Team118Joseph will become famous soon enoughTeam118Joseph will become famous soon enough
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.
__________________
FRC Countdown Website: http://frccountdown.hosthorde.net/
FRC Countdowns App: https://play.google.com/store/apps/d...h.frccountdown

Last edited by Team118Joseph : 12-01-2015 at 01:16. Reason: added comments to the code
Reply With Quote
  #5   Spotlight this post!  
Unread 12-01-2015, 07:24
adciv adciv is offline
One Eyed Man
FRC #0836 (RoboBees)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2010
Location: Southern Maryland
Posts: 478
adciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to all
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'.
__________________
Quote:
Originally Posted by texarkana View Post
I would not want the task of devising a system that 50,000 very smart people try to outwit.
Reply With Quote
  #6   Spotlight this post!  
Unread 12-01-2015, 10:14
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,713
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Boolean Help?

One way, except note that buttons are now (2015) retrieved from an array.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


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

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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