Consider this:
Code:
class Posedge_toggle{
bool value,last;
public:
Posedge_toggle():value(0),last(1){}
void update(bool sample){
if(sample&&!last) value=!value;
last=sample;
}
bool get()const{ return value; }
};
//...
Posedge_toggle t;
while (IsOperatorControl())
{
t.update(secondaryController->GetRawButton(6));
if(t.get()){
//do tank drive
}else{
//do arcade drive
}
wait(0.02);
}
It decouples the logic of how to make things toggle from the logic to read joysticks, etc.