Skip to content

Commit 48c5df6

Browse files
committed
Add hid-rumble example
1 parent 39d2b49 commit 48c5df6

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

hid-rumble/robot.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env python3
2+
"""
3+
This is a demo program showing the use of GenericHID's rumble feature.
4+
"""
5+
6+
import wpilib
7+
8+
9+
class MyRobot(wpilib.TimedRobot):
10+
11+
def robotInit(self):
12+
"""Robot initialization function"""
13+
14+
self.hid = wpilib.XboxController(0)
15+
16+
def autonomousInit(self):
17+
# Turn on rumble at the start of auto
18+
self.hid.setRumble(wpilib.XboxController.RumbleType.kLeftRumble, 1.0)
19+
self.hid.setRumble(wpilib.XboxController.RumbleType.kRightRumble, 1.0)
20+
21+
def disabledInit(self):
22+
# Stop the rumble when entering disabled
23+
self.hid.setRumble(wpilib.XboxController.RumbleType.kLeftRumble, 0.0)
24+
self.hid.setRumble(wpilib.XboxController.RumbleType.kRightRumble, 0.0)
25+
26+
27+
if __name__ == "__main__":
28+
wpilib.run(MyRobot)

run_tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ BASE_TESTS="
2626
getting-started
2727
gyro
2828
gyro-mecanum
29+
hid-rumble
2930
i2c-communication
3031
magicbot-simple
3132
mecanum-drive

0 commit comments

Comments
 (0)