EasyStack Docs

EdgeDetector

#EdgeDetector

An EdgeDetector compares a boolean signal with its value from the previous update. It tells you when the signal went from false to true, from true to false, or changed in either direction.

#Creating an EdgeDetector

Java
EdgeDetector beamBreak = new EdgeDetector();

#Updating and Reading

Call update() once per loop, then read the edge methods:

Java
while (opModeIsActive()) {
    beamBreak.update(sensor.isBroken());

    if (beamBreak.rising()) {
        pieceCount++;
    }
}
MethodReturns
update(value)Stores the new value and returns the same value, so it can be used inside a condition.
rising()true if the last update went from false to true.
falling()true if the last update went from true to false.
changed()true if the last update changed the value in either direction.
get()The value passed to the last update.

The edge methods describe only the last update. They return to false after the next update if the signal did not change again.

The first call to update() never produces an edge, because there is no earlier value to compare with. A signal that is already true at the start is not reported as rising.

Before the first update, get() and all edge methods return false. There is no reset method, so create a new EdgeDetector to start over.

Combine it with Debouncer when the signal is noisy, so that a flicker is not counted as several edges:

Java
boolean stable = debouncer.calculate(sensor.isBroken());
edge.update(stable);

if (edge.rising()) {
    pieceCount++;
}

Last updated 2026-11-16

EasyStack - FTC Java library

This site records page views of visitors to understand how the documentation is used. Nothing is sold or shared with third parties.