SensorBuffer
A wrapper for sensors that supply double values, meant to smoothen results by averaging past values. This class uses a RollingAverage to provide a more stable and less noisy sensor reading by averaging a specified number of recent values.
Methods
SensorBuffer(Supplier<Double> input, int size)
Constructs a new SensorBuffer.
input: ASupplier<Double>that provides the raw sensor readings.size: The number of past values to include in the rolling average. This determines the smoothing effect.
get()
Returns the current smoothed sensor reading. This method retrieves a new raw reading from the input supplier, adds it to the internal RollingAverage, and then returns the updated average.