Class ToggleRumble
java.lang.Object
com.crossbotics.ftchelper.gamepad.ToggleRumble
Buzzes the gamepad to confirm a toggle, so the driver knows without looking:
two buzzes = ON, one buzz = OFF.
ToggleRumble confirm = new ToggleRumble(gamepad1);
controls.bindToggle(Pad.G1, Btn.Y,
() -> { slowMode = true; confirm.play(true); },
() -> { slowMode = false; confirm.play(false); });
It never waits: the whole buzz pattern is handed to the gamepad at once, and the gamepad plays it by itself while the robot keeps running. See docs/guides/non-blocking.md. Docs: docs/modules/gamepad.md
-
Constructor Summary
ConstructorsConstructorDescriptionToggleRumble(com.qualcomm.robotcore.hardware.Gamepad gamepad) Makes one that uses the real clock.ToggleRumble(com.qualcomm.robotcore.hardware.Gamepad gamepad, LongSupplier clockNanos) Makes one with your own clock. -
Method Summary
Modifier and TypeMethodDescriptionbooleanTrue while the confirmation is still playing.voidplay(boolean on) Plays the confirmation.setPattern(double strength, int stepMs, int gapMs) Changes how the buzz feels.
-
Constructor Details
-
ToggleRumble
public ToggleRumble(com.qualcomm.robotcore.hardware.Gamepad gamepad) Makes one that uses the real clock.- Parameters:
gamepad- the gamepad to buzz (usually gamepad1)
-
ToggleRumble
Makes one with your own clock. Used by tests.- Parameters:
gamepad- the gamepad to buzzclockNanos- gives the current time in nanoseconds
-
-
Method Details
-
setPattern
Changes how the buzz feels. Defaults: strength 0.8, 120 ms buzz, 80 ms gap (last season's values).- Parameters:
strength- 0 to 1stepMs- length of each buzz, millisecondsgapMs- pause between the two buzzes, milliseconds- Returns:
- this ToggleRumble, so you can chain more settings
-
play
public void play(boolean on) Plays the confirmation. A new one replaces one that is still playing.- Parameters:
on- true = two buzzes (ON), false = one buzz (OFF)
-
isPlaying
public boolean isPlaying()True while the confirmation is still playing. Use it to hold back other rumble (for exampleAimRumble) so the two do not mix.
-