Search in sources :

Example 1 with I2cDevice

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

the class HardwareDeviceManager method createI2cDeviceSynch.

protected I2cDeviceSynch createI2cDeviceSynch(I2cController controller, int channel, String name) {
    I2cDevice i2cDevice = new I2cDeviceImpl(controller, channel);
    I2cDeviceSynch i2cDeviceSynch = new I2cDeviceSynchImpl(i2cDevice, true);
    i2cDeviceSynch.setUserConfiguredName(name);
    return i2cDeviceSynch;
}
Also used : I2cDeviceSynchImpl(com.qualcomm.robotcore.hardware.I2cDeviceSynchImpl) I2cDevice(com.qualcomm.robotcore.hardware.I2cDevice) LynxI2cDeviceSynch(com.qualcomm.hardware.lynx.LynxI2cDeviceSynch) I2cDeviceSynch(com.qualcomm.robotcore.hardware.I2cDeviceSynch) I2cDeviceImpl(com.qualcomm.robotcore.hardware.I2cDeviceImpl)

Example 2 with I2cDevice

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

the class HardwareFactory method mapI2cDeviceSynch.

private void mapI2cDeviceSynch(HardwareMap map, DeviceManager deviceMgr, I2cController i2cController, DeviceConfiguration devConf) {
    if (!devConf.isEnabled()) {
        return;
    }
    I2cDevice i2cDevice = deviceMgr.createI2cDevice(i2cController, devConf.getI2cChannel(), devConf.getName());
    I2cDeviceSynch i2cDeviceSynch = new I2cDeviceSynchImpl(i2cDevice, true);
    map.i2cDeviceSynch.put(devConf.getName(), i2cDeviceSynch);
}
Also used : I2cDeviceSynchImpl(com.qualcomm.robotcore.hardware.I2cDeviceSynchImpl) I2cDevice(com.qualcomm.robotcore.hardware.I2cDevice) I2cDeviceSynch(com.qualcomm.robotcore.hardware.I2cDeviceSynch)

Example 3 with I2cDevice

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

the class HardwareFactory method mapI2cDevice.

private void mapI2cDevice(HardwareMap map, DeviceManager deviceMgr, I2cController i2cController, DeviceConfiguration devConf) {
    if (!devConf.isEnabled()) {
        return;
    }
    I2cDevice i2cDevice = deviceMgr.createI2cDevice(i2cController, devConf.getI2cChannel(), devConf.getName());
    map.i2cDevice.put(devConf.getName(), i2cDevice);
}
Also used : I2cDevice(com.qualcomm.robotcore.hardware.I2cDevice)

Example 4 with I2cDevice

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

the class UserI2cSensorType method createInstance.

@NonNull
public HardwareDevice createInstance(I2cController controller, int port) throws InvocationTargetException {
    try {
        Constructor ctor;
        ctor = findMatch(ctorI2cDeviceSynch);
        if (null == ctor) {
            ctor = findMatch(ctorI2cDeviceSynchSimple);
        }
        if (null != ctor) {
            I2cDevice i2cDevice = new I2cDeviceImpl(controller, port);
            I2cDeviceSynch i2cDeviceSynch = new I2cDeviceSynchImpl(i2cDevice, true);
            return (HardwareDevice) ctor.newInstance(i2cDeviceSynch);
        }
        ctor = findMatch(ctorI2cDevice);
        if (null != ctor) {
            I2cDevice i2cDevice = new I2cDeviceImpl(controller, port);
            return (HardwareDevice) ctor.newInstance(i2cDevice);
        }
        ctor = findMatch(ctorI2cControllerPort);
        if (null != ctor) {
            return (HardwareDevice) ctor.newInstance(controller, port);
        }
    } catch (IllegalAccessException | InstantiationException e) {
        throw new RuntimeException("internal error: exception");
    }
    throw new RuntimeException("internal error: unable to locate constructor for user sensor type");
}
Also used : I2cDeviceSynchImpl(com.qualcomm.robotcore.hardware.I2cDeviceSynchImpl) Constructor(java.lang.reflect.Constructor) I2cDevice(com.qualcomm.robotcore.hardware.I2cDevice) I2cDeviceSynch(com.qualcomm.robotcore.hardware.I2cDeviceSynch) HardwareDevice(com.qualcomm.robotcore.hardware.HardwareDevice) I2cDeviceImpl(com.qualcomm.robotcore.hardware.I2cDeviceImpl) NonNull(android.support.annotation.NonNull)

Aggregations

I2cDevice (com.qualcomm.robotcore.hardware.I2cDevice)4 I2cDeviceSynch (com.qualcomm.robotcore.hardware.I2cDeviceSynch)3 I2cDeviceSynchImpl (com.qualcomm.robotcore.hardware.I2cDeviceSynchImpl)3 I2cDeviceImpl (com.qualcomm.robotcore.hardware.I2cDeviceImpl)2 NonNull (android.support.annotation.NonNull)1 LynxI2cDeviceSynch (com.qualcomm.hardware.lynx.LynxI2cDeviceSynch)1 HardwareDevice (com.qualcomm.robotcore.hardware.HardwareDevice)1 Constructor (java.lang.reflect.Constructor)1