Debouncer

class wpimath.filter.Debouncer(debounceTime: wpimath.units.seconds, type: wpimath.filter._filter.Debouncer.DebounceType = <DebounceType.kRising: 0>)

Bases: pybind11_object

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.

Creates a new Debouncer.

Parameters:
  • debounceTime – The number of seconds the value must change from baseline for the filtered value to change.

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

class DebounceType(value: SupportsInt)

Bases: pybind11_object

Type of debouncing to perform.

Members:

kRising : Rising edge.

kFalling : Falling edge.

kBoth : Both rising and falling edges.

kBoth = <DebounceType.kBoth: 2>
kFalling = <DebounceType.kFalling: 1>
kRising = <DebounceType.kRising: 0>
property name
property value
calculate(input: bool) bool

Applies the debouncer to the input stream.

Parameters:

input – The current value of the input stream.

Returns:

The debounced value of the input stream.

getDebounceTime() wpimath.units.seconds

Gets the time to debounce.

Returns:

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

getDebounceType() wpimath.filter._filter.Debouncer.DebounceType

Get the debounce type.

Returns:

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

setDebounceTime(time: wpimath.units.seconds) None

Sets the time to debounce.

Parameters:

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

setDebounceType(type: wpimath.filter._filter.Debouncer.DebounceType) None

Set the debounce type.

Parameters:

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