Hardware Interfaces
The hardware classes of EasyStack are built on small interfaces. You can write your own class that implements one of them, or you can type a variable with the interface so your code works with any compatible device. Every interface lives in the package dev.easyfamily.EasyStack.controllable.
import dev.easyfamily.EasyStack.controllable.EasyGyro;
EasyGyro gyro = new EasyRevIMU(hardwareMap, "imu", logo, usb);#EasyHardwareDevice
The base interface of every sensor and actuator. It gives all devices the same on and off switch.
enable(): turns the device on.disable(): turns the device off and stops using it.isEnabled(): true while the device is on.getDeviceType(): a text with the class name and the device name. Useful for telemetry.
#EasyGyro
A sensor that measures the heading of the robot. EasyRevIMU implements it.
init(): starts the sensor.getHeading(): heading relative to the last reset.getAbsoluteHeading(): heading that ignores resets.getAngles(): the three angles in an array.invertGyro(): reverses the direction of the heading.reset(): makes the current heading the new zero.
#EasyColorSensor
A sensor that reads colors. EasyRevColorSensor implements it, and EasyRevColorSensorV3 inherits it.
red(),green(),blue(),alpha(): the raw channels.argb(),getARGBArray(): all channels together.getHSVArray(),getHue(),getSaturation(),getValue(): the color in hue, saturation and value.isRed(),isBlue(),isYellow(),isGreen(): true when the color matches.getDominantColor(): the name of the color, or UNKNOWN.getHexCode(): the color as a text like #FF0000.enableLed(on): turns the light of the sensor on or off. It returns the sensor so calls can be chained.
#EasyDistanceSensor
A sensor that measures distance and compares it with named targets. EasyRevDistanceSensor and EasyRevColorSensorV3 implement it.
getDistance(unit): the distance in the unit you ask for.addTarget(target),addTargets(list): registers targets.targetReached(target): true when the distance is inside the target.checkAllTargets(): a map that tells which registered targets are reached.
A DistanceTarget has a target value and a minimum and maximum limit:
DistanceTarget wall = new DistanceTarget(DistanceUnit.CM, 18, 22, "Wall");
sensor.addTarget(wall);
if (sensor.targetReached(wall)) {
drive.stop();
}DistanceTarget(unit, target): limits are the target minus 5 and plus 5.DistanceTarget(unit, min, max, name): you choose both limits and a name. Limits cannot be negative, and min cannot be bigger than max, or an IllegalArgumentException is thrown.atTarget(distance): true when the distance is inside the limits.- setTarget, setThreshold, setMinThreshold, setMaxThreshold, setUnit, setName: change the target after creating it.
#EasyPowerable
Anything that receives a power between -1 and 1.
setPower(power): sets the power.getPower(): reads the last power.
#EasyControllable
Extends EasyPowerable with feedback. EasyMotor and EasyMotorGroup implement it, so a controller can drive any of them.
getPosition(): current position.getVelocity(): current velocity.
#EasyRpmControllable
Anything that can hold a speed in revolutions per minute. EasyCRServo and EasyCRServoGroup implement it.
setTargetRpm(rpm): sets the speed to hold.getTargetRpm(),getRpm(),getMaxRpm(): the target, the measured and the maximum speed.isAtTargetRpm(): true when the speed reached the target.setTargetAngularVelocity(value, unit),getAngularVelocity(unit): the same, but in the angle unit you prefer.
Last updated 2026-11-16