Class ToggleRumble

java.lang.Object
com.crossbotics.ftchelper.gamepad.ToggleRumble

public final class ToggleRumble extends Object
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 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

      public ToggleRumble(com.qualcomm.robotcore.hardware.Gamepad gamepad, LongSupplier clockNanos)
      Makes one with your own clock. Used by tests.
      Parameters:
      gamepad - the gamepad to buzz
      clockNanos - gives the current time in nanoseconds
  • Method Details

    • setPattern

      public ToggleRumble setPattern(double strength, int stepMs, int gapMs)
      Changes how the buzz feels. Defaults: strength 0.8, 120 ms buzz, 80 ms gap (last season's values).
      Parameters:
      strength - 0 to 1
      stepMs - length of each buzz, milliseconds
      gapMs - 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 example AimRumble) so the two do not mix.