View previous topic :: View next topic |
Author |
Message |
Gerhard
Joined: 30 Aug 2007 Posts: 144 Location: South Africa
|
Disable ainput after it has been used once |
Posted: Wed Oct 10, 2007 2:51 pm |
|
|
Is it posible to disable a input after it has been pushed once??
For instance, say you want to have 2 pushbuttons, one for the forward direction of a motor and one for reverse. Is it posible to disable the forward input after it has been pushed once until the reverse button is pushed and then disable the reverse button until the forward has been pushed? |
|
|
jecottrell
Joined: 16 Jan 2005 Posts: 559 Location: Tucson, AZ
|
|
Posted: Wed Oct 10, 2007 3:05 pm |
|
|
Use flags. Upon startup both flags are false. When a button is depressed it sets the flag disabling the button depressed. When the opposite button is depressed it clears the previous flag and sets the new on associated with that button. To get into the handling code for each button, just add an if() to check the state of the flag. |
|
|
Gerhard
Joined: 30 Aug 2007 Posts: 144 Location: South Africa
|
|
Posted: Wed Oct 10, 2007 3:16 pm |
|
|
Thanks, I checked the c-reference manual as well as help file but i can't find anything on flags. How is it setup and used as i have not used it before? |
|
|
jecottrell
Joined: 16 Jan 2005 Posts: 559 Location: Tucson, AZ
|
|
Posted: Wed Oct 10, 2007 3:27 pm |
|
|
Code: |
int1 allow_fwd_flg = TRUE;
int1 allow_rvs_flg = TRUE;
if(allow_fwd_flg)
{
handle button here
allow_fwd_flg = FALSE;
allow_rvs_flg = TRUE;
}
if(allow_rvs_flg)
{
handle button here
allow_rvs_flg = FALSE;
allow_fwd_flg = TRUE;
} |
|
|
|
Gerhard
Joined: 30 Aug 2007 Posts: 144 Location: South Africa
|
|
Posted: Wed Oct 10, 2007 6:02 pm |
|
|
Thanks. It helps alot. |
|
|
|