DebounceFilter4ms - PaulMurrayCbr/DebounceInput GitHub Wiki
DebounceFilter4ms
is a subclass of DebounceFilter that is able to rate-limit samples to no more than one per 4ms
Constructors
Construct a DebounceFilter4ms
, initialising its state to false
.
DebounceFilter4ms(boolean initialState)
Construct a DebounceFilter4ms
, initialising its state to initialState
.
Members
A value which the internal filter must exceed to change from false
(LOW
) to true
(HIGH
). The default value is 0x90
. The internal filter has a maximum value of 255, which means that if you set risingThreshhold
to 255, then the filter can never rise and will remain stuck in the false
(LOW
) state.
A value which the internal filter must be less than to change from true
(HIGH
) to false
(LOW
). The default value is 0x70
. The internal filter has a minimum value of 0, which means that if you set fallingThreshhold
to 0, then the filter can never fall and will remain stuck in the true
(HIGH
) state.
Methods
void addSample(boolean sample)
Add a sample to the filter.
void addSampleRateLimited(boolean sample)
Add a sample to the filter, selectively ignoring samples to force no more than one per 4ms. This keeps the filter behaviour consistent over time. The 'changing' bit will still be updated, to keep the behaviour that if the output does not change after a sample, changing
becomes false.
Get the debounced signal.
True if the debounced signal changes as a result of the most recent sample.
Reset the filter to the given state. This has the effect of saturating the filter. stateChanged
will return false irrespective of whether the reset caused the state to change.