EdgeCounterFilter

class EdgeCounterFilter(var requiredEdges: Int, var windowTimeSeconds: Double)(source)

A rising edge counter for boolean streams. Requires that the boolean change value to true for a specified number of times within a specified time window after the first rising edge before the filtered value changes.

The filter activates when the input has risen (transitioned from false to true) the required number of times within the time window. Once activated, the output remains true as long as the input is true. The edge count resets when the time window expires or when the input goes false after activation.

Input must be stable; consider using a Debouncer before this filter to avoid counting noise as multiple edges.

Parameters

requiredEdges

The number of rising edges required before the output goes true.

windowTimeSeconds

The maximum number of seconds in which all required edges must occur after the first rising edge.

Constructors

Link copied to clipboard
constructor(requiredEdges: Int, windowTimeSeconds: Double)

Properties

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun calculate(input: Boolean, timestamp: ComparableTimeMark = TimeSource.Monotonic.markNow()): Boolean

Applies the edge counter filter to the input stream.