stable
Look up stable.for, which passes a value only after it holds steady for a duration.
The stable module removes short changes from a signal. Import it with import stable.
for
Passes a value only after the value stays the same for duration.
durationi64 nsRequiredHow long the value must stay the same, such as
500ms.
duration takes a literal or a variable. A new variable value applies from the next
change of the input value.
- Input -> a numeric or
boolvalue. Astrvalue gives the errorstable.for input must be a numeric or bool type, got str. - Output -> the steady value, of the same type as the input. It has the time of the cycle that sends it.
- Runs -> on each new input value. A change of value starts the hold time again, from
the timestamp of that value. When an input arrives after the value has held for
duration,stable.forsends the value once. It sends again only when a different value holds forduration.
Because stable.for checks the hold time only when an input arrives, a slow channel can
send the value later than duration. When its stage starts, stable.for forgets the
last value.
import stable
tank_pt > 500 -> stable.for{duration=500ms} -> high_ptstable.for works the same on the Core and on a Driver.