NextDigitalSensor

class NextDigitalSensor(initializer: () -> DigitalChannel, inverted: Boolean = true)

Lightweight wrapper around a DigitalChannel for reading digital sensors like limit switches, magnetic switches, and beam breaks.

Most digital sensors are "active low" — they read false when triggered (switch pressed, magnet present, beam broken) and true when idle. This wrapper handles that inversion via inverted so isTriggered always means what you'd expect.

Example:

val beamBreak = NextDigitalSensor("beamBreak")
if (beamBreak.isTriggered) { stopMotor() }

Author

28shettr

Parameters

initializer

Lazily resolves the backing DigitalChannel.

inverted

If true, isTriggered returns the opposite of the raw sensor state — i.e. triggered when the channel reads low. For example, a touch sensor reads false while it's being pressed, so inverting makes isTriggered read true when pressed, which is what you'd expect. Defaults to true, matching most FTC digital sensors, which are active-low.

Constructors

Link copied to clipboard
constructor(initializer: () -> DigitalChannel, inverted: Boolean = true)
constructor(name: String, inverted: Boolean = true)

Properties

Link copied to clipboard

True if the sensor is currently triggered (accounting for inverted).

Link copied to clipboard

Raw state of the digital channel

Functions

Link copied to clipboard
fun debug(): String

Returns a string of the sensor's current state for telemetry or logging.