![]() |
Toggle Button For reverse
I have a command-based program with a DriveTrain subsystem that has this method:
void DriveTrain:: DriveDirectional(float x, float y){ robotDrive41->ArcadeDrive(y, x); //Call the ArcadeDrive Method using the Y //Axis as the speed and the x axis as the Turn. } How would I implement a command to have a toggle button (i.e. the joystick button) to set the robot in reverse (press button once, in reverse, press button again, back to moving forward)? |
Re: Toggle Button For reverse
The space after the D in : DriveDirectoinal is not a glitch. The : D was turning into :D when I posted the comment.
|
Re: Toggle Button For reverse
Quote:
Code:
import wpilib |
Re: Toggle Button For reverse
Quote:
Here's some C pseudo_code: Code:
button_now = get_button(); // get the button state (pressed or not pressed) |
Re: Toggle Button For reverse
As Ether said, you need to detect the "rising edge" of the button being held down. Here is a function I wrote for doing just this:
Code:
/*Code:
ToggleBool(oJoystick->GetRawButton(JOYSTICK_BUTTON_REVERSE), reverseButtonPressed, reverse); |
| All times are GMT -5. The time now is 10:26 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi