Search in sources :

Example 1 with I2cDeviceImpl

use of com.qualcomm.robotcore.hardware.I2cDeviceImpl 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 I2cDeviceImpl

use of com.qualcomm.robotcore.hardware.I2cDeviceImpl 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)2 I2cDeviceImpl (com.qualcomm.robotcore.hardware.I2cDeviceImpl)2 I2cDeviceSynch (com.qualcomm.robotcore.hardware.I2cDeviceSynch)2 I2cDeviceSynchImpl (com.qualcomm.robotcore.hardware.I2cDeviceSynchImpl)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