本文整理汇总了C++中EGamepad::Update方法的典型用法代码示例。如果您正苦于以下问题:C++ EGamepad::Update方法的具体用法?C++ EGamepad::Update怎么用?C++ EGamepad::Update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EGamepad
的用法示例。
在下文中一共展示了EGamepad::Update方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OperatorControl
void OperatorControl()
{
// Loop counter to ensure that the program is running (debug helper
// that can be removed when things get more stable)
int sanity, bigSanity = 0;
gamepad.Update();
while (IsOperatorControl() && IsEnabled())
{
controls = Controls::GetInstance();
controls->SetSpeed(LEFT_DRIVE_PWM, -1.0 * gamepad.GetRightY());
controls->SetSpeed(RIGHT_DRIVE_PWM, -1.0 * gamepad.GetRightY());
gamepad.Update();
dsLCD->Clear();
dsLCD->PrintfLine(DriverStationLCD::kUser_Line1, "2013 Test Fix");
dsLCD->PrintfLine(DriverStationLCD::kUser_Line2, "Teleop Mode");
dsLCD->PrintfLine(DriverStationLCD::kUser_Line6, "bigSanity: %d", sanity);
dsLCD->UpdateLCD();
sanity++;
if (0 == sanity % 20)
{
bigSanity++;
}
Wait(0.05); // wait for a motor update time
}
}
示例2: OperatorControl
// Code to be run during the remaining 2:20 of the match (after Autonomous())
//
// OperatorControl
// * Calls all the above methods
void OperatorControl()
{
// SAFETY AND SANITY - SET ALL TO ZERO
intake.Set(0.0);
rightWinch.Set(0.0);
leftWinch.Set(0.0);
arm.Set(DoubleSolenoid::kReverse);
/* TODO: Investigate. At least year's (GTR East) competition, we reached the conclusion that disabling this was
* the only way we could get out robot code to work (reliably). Should this be set to false?
*/
robotDrive.SetSafetyEnabled(false);
Timer clock;
int sanity = 0;
int bigSanity = 0;
loading = false;
loaded = winchSwitch.Get();
RegisterButtons();
gamepad.Update();
leftStick.Update();
compressor.Start();
while (IsOperatorControl() && IsEnabled())
{
clock.Start();
HandleDriverInputs();
HandleShooter();
HandleArm();
// HandleEject();
while (!clock.HasPeriodPassed(LOOP_PERIOD)); // add an IsEnabled???
clock.Reset();
sanity++;
if (sanity >= 100)
{
bigSanity++;
sanity = 0;
dsLCD->PrintfLine(DriverStationLCD::kUser_Line4, "%d", bigSanity);
}
gamepad.Update();
leftStick.Update();
dsLCD->UpdateLCD();
}
// SAFETY AND SANITY - SET ALL TO ZERO
intake.Set(0.0);
rightWinch.Set(0.0);
leftWinch.Set(0.0);
}
示例3: OperatorControl
void OperatorControl(void)
{
myRobot.SetSafetyEnabled(true);
gamepad.EnableButton(BUTTON_COLLECTOR_FWD);
gamepad.EnableButton(BUTTON_COLLECTOR_REV);
gamepad.EnableButton(BUTTON_SHOOTER);
gamepad.EnableButton(BUTTON_CLAW_1_LOCKED);
gamepad.EnableButton(BUTTON_CLAW_2_LOCKED);
gamepad.EnableButton(BUTTON_CLAW_1_UNLOCKED);
gamepad.EnableButton(BUTTON_CLAW_2_UNLOCKED);
gamepad.EnableButton(BUTTON_STOP_ALL);
gamepad.EnableButton(BUTTON_JOG_FWD);
gamepad.EnableButton(BUTTON_JOG_REV);
stick2.EnableButton(BUTTON_SHIFT);
// Set inital states for all switches and buttons
gamepad.Update();
indexSwitch.Update();
greenClawLockSwitch.Update();
yellowClawLockSwitch.Update();
stick2.Update();
// Set initial states for all pneumatic actuators
shifter.Set(DoubleSolenoid::kReverse);
greenClaw.Set(DoubleSolenoid::kReverse);
yellowClaw.Set(DoubleSolenoid::kReverse);
compressor.Start ();
while (IsOperatorControl())
{
gamepad.Update();
stick2.Update();
indexSwitch.Update();
greenClawLockSwitch.Update();
yellowClawLockSwitch.Update();
HandleCollectorInputs();
HandleDriverInputsManual();
HandleArmInputs();
HandleShooterInputs();
HandleResetButton();
UpdateStatusDisplays();
dsLCD->UpdateLCD();
Wait(0.005); // wait for a motor update time
}
}
示例4: Test
// Runs during test mode
// Test
// *
void Test()
{
shifters.Set(DoubleSolenoid::kForward);
leftDriveEncoder.Start();
leftDriveEncoder.Reset();
int start = leftDriveEncoder.Get();
while (IsTest()) {
if (rightStick.GetRawButton(7)) {
robotDrive.ArcadeDrive(rightStick.GetY(), -rightStick.GetX());
}
else {
robotDrive.ArcadeDrive(rightStick.GetY()/2, -rightStick.GetX()/2);
}
if (gamepad.GetEvent(4) == kEventClosed) {
start = leftDriveEncoder.Get();
}
dsLCD->PrintfLine(DriverStationLCD::kUser_Line3, "lde: %d", leftDriveEncoder.Get() - start);
dsLCD->UpdateLCD();
gamepad.Update();
}
}
示例5: OperatorControl
void OperatorControl(void)
{
myRobot.SetSafetyEnabled(true);
gamepad.EnableButton(BUTTON_COLLECTOR_FWD);
gamepad.EnableButton(BUTTON_COLLECTOR_REV);
gamepad.EnableButton(BUTTON_SHOOTER);
gamepad.EnableButton(BUTTON_CLAW_1_LOCKED);
gamepad.EnableButton(BUTTON_CLAW_2_LOCKED);
gamepad.EnableButton(BUTTON_CLAW_1_UNLOCKED);
gamepad.EnableButton(BUTTON_CLAW_2_UNLOCKED);
stick2.EnableButton(BUTTON_SHIFT);
// Set inital states for all switches and buttons
gamepad.Update();
indexSwitch.Update();
stick2.Update();
// Set initial states for all pneumatic actuators
shifter.Set(DoubleSolenoid::kReverse);
greenClaw.Set(DoubleSolenoid::kReverse);
yellowClaw.Set(DoubleSolenoid::kReverse);
compressor.Start ();
while (IsOperatorControl())
{
gamepad.Update();
stick2.Update();
indexSwitch.Update();
HandleCollectorInputs();
HandleDriverInputsManual();
HandleArmInputs();
HandleShooterInputs();
dsLCD->PrintfLine(DriverStationLCD::kUser_Line2, "Voltage: %f", potentiometer.GetVoltage()); dsLCD->UpdateLCD();
Wait(0.005); // wait for a motor update time
}
}
示例6: Test
void Test()
{
menuType currentMenu = TOP;
menuType newMenu = TOP;
BaseMenu * menus[NUM_MENU_TYPE];
menus[TOP] = new TopMenu;
menus[ANALOG] = new AnalogMenu;
menus[DIGITAL_TOP] = new DigitalMenu;
menus[SOLENOID] = new SolenoidMenu;
menus[DIGITAL_PWM] = new PWMMenu;
menus[DIGITAL_IO] = new DigitalIOMenu;
menus[DIGITAL_RELAY] = new RelayMenu;
menus[DIGITAL_IO_STATE] = new DigitalIOStateMenu;
menus[DIGITAL_IO_CLOCK] = new DigitalIOClockMenu;
menus[DIGITAL_IO_ENCODER] = new DigitalIOEncoderMenu;
// Write out the TOP menu for the first time
menus[currentMenu]->UpdateDisplay();
// Initialize the button states on the gamepad
gamepad.Update();
// Loop counter to ensure that the program us running (debug helper
// that can be removed when things get more stable)
int sanity = 0;
while (IsTest())
{
// The dpad "up" button is used to move the menu pointer up one line
// on the LCD display
if (kEventClosed == gamepad.GetDPadEvent(Gamepad::kUp))
{
menus[currentMenu]->HandleIndexUp();
}
// The dpad "down" button is used to move the menu pointer down one line
// on the LCD display
if (kEventClosed == gamepad.GetDPadEvent(Gamepad::kDown))
{
menus[currentMenu]->HandleIndexDown();
}
// The dpad left button is used to exit a submenu when the menu pointer
// points to the "back" menu item and to decrease a value (where
// appropriate) on any other menu item.
if (kEventClosed == gamepad.GetDPadEvent(Gamepad::kLeft))
{
newMenu = menus[currentMenu]->HandleSelectLeft();
}
// Theoretically, both the select buttons could be pressed in the
// same 10 msec window. However, if using the dpad on the game
// game controller this is physically impossible so we don't
// need to worry about a previous value of newMenu being
// overwritten in the next bit of code.
// The dpad right button is used to enter a submenu when the menu pointer
// points to a submenu item and to increase a value (where appropriate)
// on any other menu item.
if (kEventClosed == gamepad.GetDPadEvent(Gamepad::kRight))
{
newMenu = menus[currentMenu]->HandleSelectRight();
// Handle change from one menu to a sub menu
if (newMenu != currentMenu)
{
// When we enter a menu we need to set the record the
// menu to return to. We do *not* want to do this when
// returning from a menu to its calling menu.
menus[newMenu]->SetCallingMenu(currentMenu);
}
}
// Handle change from one menu to another
if (newMenu != currentMenu)
{
menus[newMenu]->UpdateDisplay();
currentMenu = newMenu;
}
// Set the motor speed(s) (if any have been enabled via the Digital PWM menu)
menus[DIGITAL_PWM]->SetSpeed(-1.0 * gamepad.GetRightY());
// Update gamepad button states
gamepad.Update();
// Update the display (we do this on every loop pass because some menus
// (analog, for example) need to have values updated even when there are
// no dpad events to handle)
menus[currentMenu]->UpdateDisplay();
// Dump the sanity time value to the LCD
dsLCD->PrintfLine(DriverStationLCD::kUser_Line6, "Sanity: %d", sanity);
dsLCD->UpdateLCD();
sanity++;
// Run the loop every 50 msec (20 times per second)
//.........这里部分代码省略.........