Package edu.wpi.first.math.filter
Class Debouncer
java.lang.Object
edu.wpi.first.math.filter.Debouncer
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Type of debouncing to perform. -
Constructor Summary
ConstructorsConstructorDescriptionDebouncer
(double debounceTime) Creates a new Debouncer.Debouncer
(double debounceTime, Debouncer.DebounceType type) Creates a new Debouncer. -
Method Summary
Modifier and TypeMethodDescriptionboolean
calculate
(boolean input) Applies the debouncer to the input stream.double
Gets the time to debounce.Gets the debounce type.void
setDebounceTime
(double time) Sets the time to debounce.void
Sets the debounce type.
-
Constructor Details
-
Debouncer
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.
-
Debouncer
Creates a new Debouncer. Baseline value defaulted to "false."- Parameters:
debounceTime
- The number of seconds the value must change from baseline for the filtered value to change.
-
-
Method Details
-
calculate
Applies the debouncer to the input stream.- Parameters:
input
- The current value of the input stream.- Returns:
- The debounced value of the input stream.
-
setDebounceTime
Sets the time to debounce.- Parameters:
time
- The number of seconds the value must change from baseline for the filtered value to change.
-
getDebounceTime
Gets the time to debounce.- Returns:
- The number of seconds the value must change from baseline for the filtered value to change.
-
setDebounceType
Sets the debounce type.- Parameters:
type
- Which type of state change the debouncing will be performed on.
-
getDebounceType
Gets the debounce type.- Returns:
- Which type of state change the debouncing will be performed on.
-