Class PollingBStream

java.lang.Object
com.stuypulse.stuylib.streams.booleans.PollingBStream
All Implemented Interfaces:
BStream, BooleanSupplier

public class PollingBStream extends Object implements BStream
A PollingBStream is a BStream but its .get() method is called for you at a certain rate. This is really helpful when you want to read from a sensor using a debouncer, but you dont always call .get() in your periodic loop. This will do that for you, and give you the most recent result. It is not recommended to filter a PollingBStream as you should ideally filter before you poll.
  • Constructor Details

    • PollingBStream

      public PollingBStream(BStream stream, double dt)
      Creates a PollingBStream from an BStream and a time value
      Parameters:
      stream - BStream to poll from
      dt - time inbetween each poll
  • Method Details

    • get

      public boolean get()
      Specified by:
      get in interface BStream
      Returns:
      next value in the stream
    • finalize

      protected void finalize()
      Overrides:
      finalize in class Object
    • close

      public void close()