Search in sources :

Example 1 with DigitalChannel

use of com.qualcomm.robotcore.hardware.DigitalChannel in project robotcode by OutoftheBoxFTC.

the class HardwareFactory method mapDigitalDevice.

private void mapDigitalDevice(HardwareMap map, DeviceManager deviceMgr, DigitalChannelController digitalChannelController, DeviceConfiguration devConf) {
    if (!devConf.isEnabled()) {
        return;
    }
    DigitalChannel digitalChannel = deviceMgr.createDigitalChannelDevice(digitalChannelController, devConf.getPort(), devConf.getName());
    map.digitalChannel.put(devConf.getName(), digitalChannel);
}
Also used : DigitalChannel(com.qualcomm.robotcore.hardware.DigitalChannel)

Example 2 with DigitalChannel

use of com.qualcomm.robotcore.hardware.DigitalChannel 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();
    }
}
Also used : DeviceInterfaceModule(com.qualcomm.robotcore.hardware.DeviceInterfaceModule) DigitalChannel(com.qualcomm.robotcore.hardware.DigitalChannel)

Example 3 with DigitalChannel

use of com.qualcomm.robotcore.hardware.DigitalChannel 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();
    }
}
Also used : DeviceInterfaceModule(com.qualcomm.robotcore.hardware.DeviceInterfaceModule) DigitalChannel(com.qualcomm.robotcore.hardware.DigitalChannel)

Example 4 with DigitalChannel

use of com.qualcomm.robotcore.hardware.DigitalChannel 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();
    }
}
Also used : DeviceInterfaceModule(com.qualcomm.robotcore.hardware.DeviceInterfaceModule) DigitalChannel(com.qualcomm.robotcore.hardware.DigitalChannel)

Aggregations

DigitalChannel (com.qualcomm.robotcore.hardware.DigitalChannel)4 DeviceInterfaceModule (com.qualcomm.robotcore.hardware.DeviceInterfaceModule)3