mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Add an example showing how to use a hid rumbler (#1394)
This commit is contained in:
committed by
Peter Johnson
parent
761933a164
commit
f774e47c80
@@ -0,0 +1,34 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <frc/GenericHID.h>
|
||||
#include <frc/Joystick.h>
|
||||
#include <frc/TimedRobot.h>
|
||||
#include <frc/XboxController.h>
|
||||
|
||||
/**
|
||||
* This is a demo program showing the use of GenericHID's rumble feature.
|
||||
*/
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void AutonomousInit() override {
|
||||
// Turn on rumble at the start of auto
|
||||
m_hid.SetRumble(frc::GenericHID::RumbleType::kLeftRumble, 1.0);
|
||||
m_hid.SetRumble(frc::GenericHID::RumbleType::kRightRumble, 1.0);
|
||||
}
|
||||
|
||||
void DisabledInit() override {
|
||||
// Stop the rumble when entering disabled
|
||||
m_hid.SetRumble(frc::GenericHID::RumbleType::kLeftRumble, 0.0);
|
||||
m_hid.SetRumble(frc::GenericHID::RumbleType::kRightRumble, 0.0);
|
||||
}
|
||||
|
||||
private:
|
||||
frc::XboxController m_hid{0};
|
||||
};
|
||||
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
@@ -144,6 +144,15 @@
|
||||
"foldername": "GyroMecanum",
|
||||
"gradlebase": "cpp"
|
||||
},
|
||||
{
|
||||
"name": "HID Rumble",
|
||||
"description": "An example program showing how to make human interface devices rumble.",
|
||||
"tags": [
|
||||
"Joystick"
|
||||
],
|
||||
"foldername": "HidRumble",
|
||||
"gradlebase": "cpp"
|
||||
},
|
||||
{
|
||||
"name": "PotentiometerPID",
|
||||
"description": "An example to demonstrate the use of a potentiometer and PID control to reach elevator position setpoints.",
|
||||
|
||||
Reference in New Issue
Block a user