EasyStack Docs

EasyRevDistanceSensor

This class provides a streamlined abstraction over the REV 2m Distance Sensor (DistanceSensor), with named distance targets.

#Initialization

Pass the HardwareMap and the device name configured on your Driver Station.

Java
EasyRevDistanceSensor rangesensor = new EasyRevDistanceSensor(hardwareMap, "range");
Java
// Or for TOF specific sensors
EasyRevDistanceSensor tofSensor = new EasyRevDistanceSensor(hardwareMap, "tofRange");

#Reading Distance

You can retrieve the current measured distance by passing your desired DistanceUnit (CM, MM, INCH, or METER).

Java
// Or for TOF specific sensors
EasyRevDistanceSensor rangeSensor = new EasyRevDistanceSensor(hardwareMap, "tofRange");
double currentDistance = rangeSensor.getDistance(DistanceUnit.CM);

if (currentDistance <= 5.0) {
    // Object is within 5 centimeters!
}

#Hardware Management

You can logically disable the sensor to stop polling and free up I2C bandwidth.

Java
rangeSensor.disable(); // Calls .close() on the native sensor
rangeSensor.enable();  // Flags the sensor as operational again

#EasyRevColorSensorV3 & EasyRevColorSensor

The EasyRevColorSensorV3 (Color + Proximity) and EasyRevColorSensor (Color only) classes remove the need for complex color math in your OpMode. They automatically handle RGB-to-HSV conversions, dominant color detection, and hex code generation.

#Initialization

Java
// V3 Sensor (Color + Distance)
EasyRevColorSensorV3 colorV3 = new EasyRevColorSensorV3(hardwareMap, "colorV3");

// Standard Color Sensor
EasyRevColorSensor colorStandard = new EasyRevColorSensor(hardwareMap, "colorsensor");

#Reading Colors

Instead of manually checking individual RGB channels, the class provides intelligent methods to instantly understand the color being scanned.

Java
// Returns a clean string: "RED", "BLUE", "YELLOW", "GREEN", or "UNKNOWN"
String dominant = colorV3.getDominantColor();

// Fast boolean checks based on HSV thresholds
if (colorV3.isRed()) {
    // Found a red game element!
}

// Generates a web-standard Hex Code (e.g., #FF0000)
String hexCode = colorV3.getHexCode();

//If you need the raw values for custom math, they are easily accessible:
int red = colorV3.red();
float hue = colorV3.getHue();
float[] hsvArray = colorV3.getHSVArray();

#Distance Reading (V3 Only)

Because the V3 sensor includes an IR proximity sensor, EasyRevColorSensorV3 also allows you to read distance. You can configure a default unit to save time:

Java
// Sets CM as the default unit so you don't have to specify it every time
colorV3.setDefaultDistanceUnit(DistanceUnit.CM);

// Reads distance in the default unit
double dist = colorV3.getDistance();

// Overrides the default and reads in INCHES
double distInches = colorV3.getDistance(DistanceUnit.INCH);

#Controlling the LED

You can manually turn the sensor's illumination LED on or off.

Java
colorV3.enableLed(true)

#EasyDigitalDevice

The EasyDigitalDevice class wraps standard DigitalChannel inputs (like limit switches, magnetic switches, or break-beam sensors) and adds a built-in Debouncing/Threshold system.

#Initialization & Thresholds

Standard limit switches often "bounce" (rapidly fluctuate between true/false) when physically triggered. You can define a time threshold (in milliseconds) to prevent these false reads.

Java
// Initializes the sensor with a 50ms debounce threshold
EasyDigitalDevice limitSwitch = new EasyDigitalDevice(hardwareMap, name•. "limitSwitch", 50.0)

#Inverting Logic

Depending on how your switch is wired (Normally Open vs. Normally Closed), it might return true when it shouldn't. You can invert the logic in software.

Java
limitSwitch.setInverted(true)

#The Update Loop and Reading State

If you are using a debounce threshold, you must call update() in your main loop so the internal timer can process the signal.

Java
// Inside your while(opModeIsActive()) loop:
limitSwitch.update();

// Safely returns the debounced and inverted state
if (limitSwitch.getState()) {
    // The switch has been continuously pressed for at least 50ms!
    elevator.stop();
}

(Note: If you initialize the device with a 0.0 threshold, you do not need to call update(); getState() will simply return the live hardware value).

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.