Skip to content

Conversation

@MichaelLesirge
Copy link
Contributor

@MichaelLesirge MichaelLesirge commented Oct 26, 2025

Add a simple tap counting filter for boolean streams.

The filter activates when the input has risen (transitioned from false to true, like when a button is tapped) the required number of times within the time window after the first rising edge. Once activated, the output remains true as long as the input is true. The tap count resets when the time window expires or when the input goes false after activation.

Example usage:

    xbox.a()
      .multiPress(2, 0.2) // Detect a double tap within 0.2 seconds
      .onTrue(Commands.print("Double tapped A button"));
      
     xbox.a()
      .debounce(0.2)
      .whileTrue(Commands.print("A held").repeatedly());

This is not a noise reduction and/or input smoothing filter, but it is similar in usage to debounce, so I believe it could be considered a filter, but am open to a better location.

I believe this would be a useful addition, as double/triple tapping a button is a common control option in games, yet is not often utilized by newer FRC teams. I believe adding it to WPILib in a standard way will allow more teams to make the most out of their controls.

@MichaelLesirge MichaelLesirge requested review from a team as code owners October 26, 2025 23:28
@github-actions
Copy link
Contributor

This PR modifies commands. Please open a corresponding PR in Python Commands and include a link to this PR.

@github-actions github-actions bot added component: command-based WPILib Command Based Library component: wpimath Math library labels Oct 26, 2025
@MichaelLesirge MichaelLesirge changed the title Multi tap filter and trigger modifier. Add multi tap boolean stream filter and multi tap trigger modifier Oct 26, 2025
@MichaelLesirge
Copy link
Contributor Author

I left it as a filter named EdgeCounterFilter for now, and renamed the trigger factory to .multiPress() since that is the main use case.

@MichaelLesirge MichaelLesirge changed the title Add multi tap boolean stream filter and multi tap trigger modifier Add multi tap boolean stream filter and multi tap trigger modifier (double tap detector) Nov 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: command-based WPILib Command Based Library component: wpimath Math library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants