BistableThreshold tracks the state of a value over time, and determines which side of the threshold the value is in. It is superior to a typical single-value threshold in being resistant to noise and jitter because it "resists" change.

The "edge" of the BistableThreshold has an "activate" side and a "deactivate" side, and adjusting the difference between them will make the threshold more or less resistant to change.

Constructors

Methods

  • Clear the state of the threshold, returning to null for the state

    Returns void

  • get the current state of the Threshold. This is less useful than the update method since it only tells us the current state, not if it has changed recently

    Returns NullableBoolean

  • update the Threshold and return a boolean if the state changed, or null if it did not

    Parameters

    • newVal: number

    Returns NullableBoolean

  • update a system of thresholds together, maininting the bistability of each as well as the bistability of the system as a whole

    Parameters

    • Rest...system: [threshold: default, value: number][]

    Returns NullableBoolean