Debouncer

class wpimath.Debouncer(debounce_time: wpimath.units.seconds, type: wpimath._wpimath.Debouncer.DebounceType = <DebounceType.RISING: 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:
  • debounce_time – 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 | SupportsIndex)

Bases: pybind11_object

Type of debouncing to perform.

Members:

RISING : Rising edge.

FALLING : Falling edge.

BOTH : Both rising and falling edges.

BOTH = <DebounceType.BOTH: 2>
FALLING = <DebounceType.FALLING: 1>
RISING = <DebounceType.RISING: 0>
Debouncer.DebounceType.name -> str
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.

get_debounce_time() 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.

get_debounce_type() wpimath._wpimath.Debouncer.DebounceType

Get the debounce type.

Returns:

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

set_debounce_time(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.

set_debounce_type(type: wpimath._wpimath.Debouncer.DebounceType) None

Set the debounce type.

Parameters:

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