CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Disable ainput after it has been used once

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Gerhard



Joined: 30 Aug 2007
Posts: 144
Location: South Africa

View user's profile Send private message Send e-mail

Disable ainput after it has been used once
PostPosted: Wed Oct 10, 2007 2:51 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Oct 10, 2007 3:05 pm     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Wed Oct 10, 2007 3:16 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Oct 10, 2007 3:27 pm     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Wed Oct 10, 2007 6:02 pm     Reply with quote

Thanks. It helps alot.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group