NextColorDistanceSensor
Combines a color sensor and an optional distance sensor into one class. Call update each loop to read the hardware. Use isColor to check against a dev.nextftc.hardware.sensors.colors.ColorProfile.
Example:
val green = ColorProfile(
space = ColorSpace.HSV,
color = NextColor.HSV(160f, 0.8f, 0.7f),
tolerance = NextColor.HSV(15f, 0.3f, 1f),
)
override fun periodic() {
sensor.update()
if (sensor.isWithinDistance(4.0) && sensor.isColor(green)) { ... }
}Use debug in telemetry to calibrate dev.nextftc.hardware.sensors.colors.ColorProfiles.
Author
28shettr
Parameters
Lazily resolves the backing NormalizedColorSensor.
Optional lazy distance sensor.
Constructors
Constructor to create a NextColorDistanceSensor using a configuration name.
Constructor to create a NextColorDistanceSensor using a LynxModule and I2C bus number.
Functions
Single-line telemetry string showing current HSV and distance. Useful for calibrating ColorProfiles.
Returns the last cached distance converted to the requested unit.
True if the cached color reading matches profile.