Loading [MathJax]/extensions/tex2jax.js
WPILibC++ 2025.3.2
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
frc::Debouncer Class Reference

A simple debounce filter for boolean streams. More...

#include <frc/filter/Debouncer.h>

Public Types

enum  DebounceType { kRising , kFalling , kBoth }
 Type of debouncing to perform. More...
 

Public Member Functions

 Debouncer (units::second_t debounceTime, DebounceType type=DebounceType::kRising)
 Creates a new Debouncer.
 
bool Calculate (bool input)
 Applies the debouncer to the input stream.
 
constexpr void SetDebounceTime (units::second_t time)
 Sets the time to debounce.
 
constexpr units::second_t GetDebounceTime () const
 Gets the time to debounce.
 
constexpr void SetDebounceType (DebounceType type)
 Set the debounce type.
 
constexpr DebounceType GetDebounceType () const
 Get the debounce type.
 

Detailed Description

A simple debounce filter for boolean streams.

Requires that the boolean change value from baseline for a specified period of time before the filtered value changes.

Member Enumeration Documentation

◆ DebounceType

Type of debouncing to perform.

Enumerator
kRising 

Rising edge.

kFalling 

Falling edge.

kBoth 

Both rising and falling edges.

Constructor & Destructor Documentation

◆ Debouncer()

frc::Debouncer::Debouncer ( units::second_t debounceTime,
DebounceType type = DebounceType::kRising )
explicit

Creates a new Debouncer.

Parameters
debounceTimeThe number of seconds the value must change from baseline for the filtered value to change.
typeWhich type of state change the debouncing will be performed on.

Member Function Documentation

◆ Calculate()

bool frc::Debouncer::Calculate ( bool input)

Applies the debouncer to the input stream.

Parameters
inputThe current value of the input stream.
Returns
The debounced value of the input stream.

◆ GetDebounceTime()

units::second_t frc::Debouncer::GetDebounceTime ( ) const
inlineconstexpr

Gets the time to debounce.

Returns
The number of seconds the value must change from baseline for the filtered value to change.

◆ GetDebounceType()

DebounceType frc::Debouncer::GetDebounceType ( ) const
inlineconstexpr

Get the debounce type.

Returns
Which type of state change the debouncing will be performed on.

◆ SetDebounceTime()

void frc::Debouncer::SetDebounceTime ( units::second_t time)
inlineconstexpr

Sets the time to debounce.

Parameters
timeThe number of seconds the value must change from baseline for the filtered value to change.

◆ SetDebounceType()

void frc::Debouncer::SetDebounceType ( DebounceType type)
inlineconstexpr

Set the debounce type.

Parameters
typeWhich type of state change the debouncing will be performed on.

The documentation for this class was generated from the following file: