use of com.qualcomm.robotcore.hardware.DeviceInterfaceModule in project FTC-2017 by FIRST-4030.
the class SensorDIO method runOpMode.
@Override
public void runOpMode() {
// Input State
boolean inputPin;
// Output State
boolean outputPin;
// Device Object
DeviceInterfaceModule dim;
// Device Object
DigitalChannel digIn;
// Device Object
DigitalChannel digOut;
// get a reference to a Modern Robotics DIM, and IO channels.
// Use generic form of device mapping
dim = hardwareMap.get(DeviceInterfaceModule.class, "dim");
// Use generic form of device mapping
digIn = hardwareMap.get(DigitalChannel.class, "digin");
// Use generic form of device mapping
digOut = hardwareMap.get(DigitalChannel.class, "digout");
// Set the direction of each channel
digIn.setMode(DigitalChannel.Mode.INPUT);
digOut.setMode(DigitalChannel.Mode.OUTPUT);
// wait for the start button to be pressed.
telemetry.addData(">", "Press play, and then user X button to set DigOut");
telemetry.update();
waitForStart();
while (opModeIsActive()) {
// Set the output pin based on x button
outputPin = gamepad1.x;
digOut.setState(outputPin);
// Read the input pin
inputPin = digIn.getState();
// Display input pin state on LEDs
if (inputPin) {
dim.setLED(RED_LED_CHANNEL, true);
dim.setLED(BLUE_LED_CHANNEL, false);
} else {
dim.setLED(RED_LED_CHANNEL, false);
dim.setLED(BLUE_LED_CHANNEL, true);
}
telemetry.addData("Output", outputPin);
telemetry.addData("Input", inputPin);
telemetry.addData("LED", inputPin ? "Red" : "Blue");
telemetry.update();
}
}
use of com.qualcomm.robotcore.hardware.DeviceInterfaceModule in project robotcode by OutoftheBoxFTC.
the class HardwareFactory method mapCoreInterfaceDeviceModule.
private void mapCoreInterfaceDeviceModule(HardwareMap map, DeviceManager deviceMgr, DeviceInterfaceModuleConfiguration ctrlConf) throws RobotCoreException, InterruptedException {
if (!ctrlConf.isEnabled()) {
return;
}
DeviceInterfaceModule deviceInterfaceModule = deviceMgr.createDeviceInterfaceModule(ctrlConf.getSerialNumber(), ctrlConf.getName());
map.deviceInterfaceModule.put(ctrlConf.getName(), deviceInterfaceModule);
List<DeviceConfiguration> pwmDevices = ctrlConf.getPwmOutputs();
buildDevices(pwmDevices, map, deviceMgr, deviceInterfaceModule);
List<DeviceConfiguration> i2cDevices = ctrlConf.getI2cDevices();
buildI2cDevices(i2cDevices, map, deviceMgr, deviceInterfaceModule);
List<DeviceConfiguration> analogInputDevices = ctrlConf.getAnalogInputDevices();
buildDevices(analogInputDevices, map, deviceMgr, deviceInterfaceModule);
List<DeviceConfiguration> digitalDevices = ctrlConf.getDigitalDevices();
buildDevices(digitalDevices, map, deviceMgr, deviceInterfaceModule);
List<DeviceConfiguration> analogOutputDevices = ctrlConf.getAnalogOutputDevices();
buildDevices(analogOutputDevices, map, deviceMgr, deviceInterfaceModule);
}
use of com.qualcomm.robotcore.hardware.DeviceInterfaceModule in project robotcode by OutoftheBoxFTC.
the class SensorDIO method runOpMode.
@Override
public void runOpMode() {
// Input State
boolean inputPin;
// Output State
boolean outputPin;
// Device Object
DeviceInterfaceModule dim;
// Device Object
DigitalChannel digIn;
// Device Object
DigitalChannel digOut;
// get a reference to a Modern Robotics DIM, and IO channels.
// Use generic form of device mapping
dim = hardwareMap.get(DeviceInterfaceModule.class, "dim");
// Use generic form of device mapping
digIn = hardwareMap.get(DigitalChannel.class, "digin");
// Use generic form of device mapping
digOut = hardwareMap.get(DigitalChannel.class, "digout");
// Set the direction of each channel
digIn.setMode(DigitalChannel.Mode.INPUT);
digOut.setMode(DigitalChannel.Mode.OUTPUT);
// wait for the start button to be pressed.
telemetry.addData(">", "Press play, and then user X button to set DigOut");
telemetry.update();
waitForStart();
while (opModeIsActive()) {
// Set the output pin based on x button
outputPin = gamepad1.x;
digOut.setState(outputPin);
// Read the input pin
inputPin = digIn.getState();
// Display input pin state on LEDs
if (inputPin) {
dim.setLED(RED_LED_CHANNEL, true);
dim.setLED(BLUE_LED_CHANNEL, false);
} else {
dim.setLED(RED_LED_CHANNEL, false);
dim.setLED(BLUE_LED_CHANNEL, true);
}
telemetry.addData("Output", outputPin);
telemetry.addData("Input", inputPin);
telemetry.addData("LED", inputPin ? "Red" : "Blue");
telemetry.update();
}
}
use of com.qualcomm.robotcore.hardware.DeviceInterfaceModule in project Relic_Main by TeamOverdrive.
the class SensorDIO method runOpMode.
@Override
public void runOpMode() {
// Input State
boolean inputPin;
// Output State
boolean outputPin;
// Device Object
DeviceInterfaceModule dim;
// Device Object
DigitalChannel digIn;
// Device Object
DigitalChannel digOut;
// get a reference to a Modern Robotics DIM, and IO channels.
// Use generic form of device mapping
dim = hardwareMap.get(DeviceInterfaceModule.class, "dim");
// Use generic form of device mapping
digIn = hardwareMap.get(DigitalChannel.class, "digin");
// Use generic form of device mapping
digOut = hardwareMap.get(DigitalChannel.class, "digout");
// Set the direction of each channel
digIn.setMode(DigitalChannel.Mode.INPUT);
digOut.setMode(DigitalChannel.Mode.OUTPUT);
// wait for the start button to be pressed.
telemetry.addData(">", "Press play, and then user X button to set DigOut");
telemetry.update();
waitForStart();
while (opModeIsActive()) {
// Set the output pin based on x button
outputPin = gamepad1.x;
digOut.setState(outputPin);
// Read the input pin
inputPin = digIn.getState();
// Display input pin state on LEDs
if (inputPin) {
dim.setLED(RED_LED_CHANNEL, true);
dim.setLED(BLUE_LED_CHANNEL, false);
} else {
dim.setLED(RED_LED_CHANNEL, false);
dim.setLED(BLUE_LED_CHANNEL, true);
}
telemetry.addData("Output", outputPin);
telemetry.addData("Input", inputPin);
telemetry.addData("LED", inputPin ? "Red" : "Blue");
telemetry.update();
}
}
Aggregations