View Single Post
  #8   Spotlight this post!  
Unread Yesterday, 18:23
charlier999's Avatar
charlier999 charlier999 is offline
Registered User
FRC #1662 (Raptor Force Engineering)
Team Role: Programmer
 
Join Date: Feb 2017
Rookie Year: 2013
Location: Lodi, CA
Posts: 18
charlier999 is an unknown quantity at this point
Re: Pneumatics code problems.

Quote:
Originally Posted by euhlmann View Post
My code shouldn't do that. Notice how it sets a flag wasAPressed to make sure it doesn't continuously run shifting. Make sure wasAPressed is a member variable, not a local variable
Code:
bool shifter_varable = true;

//later in teleopPeriodic

if (driver->GetRawButton(2)){
  if (!shifter_varable){
    shifter_varable = true;
    shifter->Set(shifter->Get() == 
DoubleSolenoid::Value::kReverse ?
DoubleSolenoid::Value::kForward :
DoubleSolenoid::Value::kReverse);

}else{
  shifter_varable = false;
  }
}
all tho i did the exact same thing except change the name of the wasAPressed to shifter_varable. It still does the exact same thing as before, going hyper-speed switching back and forth.
Reply With Quote