-
Notifications
You must be signed in to change notification settings - Fork 3
Digital Sensors
Johan Vandegriff edited this page Dec 15, 2016
·
5 revisions
EVLib has its own interface for Digital sensors. It extends InputExtractor of type Boolean, which means that every DigitalSensor has to have a getValue method that returns a Boolean.
ftc/evlib/hardware/sensors/DigitalSensor.java
package ftc.evlib.hardware.sensors;
import ftc.electronvolts.util.InputExtractor;
/**
* This file was made by the electronVolts, FTC team 7393
* Date Created: 9/12/16
*
* Interface for any type of digital sensor
* examples: touch sensor, digital line sensor, magnetic reed switch
*
* @see InputExtractor
* @see Sensors
*/
public interface DigitalSensor extends InputExtractor<Boolean> {
}
You can create a DigitalSensor from a DigitalChannel or TouchSensor using the Sensors factory class:
DigitalInput digitalInput = hardwareMap.touchSensor.get("limitSwitch");
DigitalSensor limitSwitch = Sensors.digitalSensor(digitalInput);
//To combine on one line:
DigitalSensor button = Sensors.digitalSensor(hardwareMap, "button");
To get the value of a DigitalSensor, call the getValue() method which returns a Boolean.
teletry.addData("limit switch pressed?", limitSwitch.getValue());
See also: Analog Sensors
This guide will step through the basics of how to set up OpModes using EVLib.
- Importing Into Your Project
- Sample Code
- Using EVLib Minimally
- Logging Example
- Robot Configuration
- Basic TeleOp Program
- Basic Autonomous Program
- Customizing StateMachineBuilder
- Servo Presets
- Adding Servos to the Configuration
- Adding Servos to TeleOp
- Adding Servos to Autonomous
- Vuforia and OpenCV Beacon Color Detection