Search in sources :

Example 1 with I2cDeviceSynchSimple

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

the class UserI2cSensorType method createInstance.

// ----------------------------------------------------------------------------------------------
// Instance creation
// ----------------------------------------------------------------------------------------------
@NonNull
public HardwareDevice createInstance(RobotCoreLynxModule lynxModule, Func<I2cDeviceSynchSimple> simpleSynchFunc, Func<I2cDeviceSynch> synchFunc) throws InvocationTargetException {
    try {
        Constructor ctor;
        ctor = findMatch(ctorI2cDeviceSynchSimple);
        if (null != ctor) {
            I2cDeviceSynchSimple i2cDeviceSynchSimple = simpleSynchFunc.value();
            return (HardwareDevice) ctor.newInstance(i2cDeviceSynchSimple);
        }
        ctor = findMatch(ctorI2cDeviceSynch);
        if (null != ctor) {
            I2cDeviceSynch i2cDeviceSynch = synchFunc.value();
            return (HardwareDevice) ctor.newInstance(i2cDeviceSynch);
        }
    } 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 : I2cDeviceSynchSimple(com.qualcomm.robotcore.hardware.I2cDeviceSynchSimple) Constructor(java.lang.reflect.Constructor) I2cDeviceSynch(com.qualcomm.robotcore.hardware.I2cDeviceSynch) HardwareDevice(com.qualcomm.robotcore.hardware.HardwareDevice) NonNull(android.support.annotation.NonNull)

Example 2 with I2cDeviceSynchSimple

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

the class HardwareDeviceManager method createI2cDeviceSynchSimple.

protected I2cDeviceSynchSimple createI2cDeviceSynchSimple(RobotCoreLynxModule lynxModule, DeviceConfiguration.I2cChannel channel, String name) {
    I2cDeviceSynchSimple result = LynxFirmwareVersionManager.createLynxI2cDeviceSynch(context, (LynxModule) lynxModule, channel.channel);
    result.setUserConfiguredName(name);
    return result;
}
Also used : I2cDeviceSynchSimple(com.qualcomm.robotcore.hardware.I2cDeviceSynchSimple)

Example 3 with I2cDeviceSynchSimple

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

the class HardwareDeviceManager method createI2cDeviceSynch.

@Override
public I2cDeviceSynch createI2cDeviceSynch(RobotCoreLynxModule lynxModule, DeviceConfiguration.I2cChannel channel, String name) {
    RobotLog.v("Creating I2cDeviceSynch (Lynx) - mod=%d bus=%d", lynxModule.getModuleAddress(), channel.channel);
    I2cDeviceSynchSimple i2cDeviceSynchSimple = createI2cDeviceSynchSimple(lynxModule, channel, name);
    I2cDeviceSynch result = new I2cDeviceSynchImplOnSimple(i2cDeviceSynchSimple, true);
    return result;
}
Also used : I2cDeviceSynchSimple(com.qualcomm.robotcore.hardware.I2cDeviceSynchSimple) LynxI2cDeviceSynch(com.qualcomm.hardware.lynx.LynxI2cDeviceSynch) I2cDeviceSynch(com.qualcomm.robotcore.hardware.I2cDeviceSynch) I2cDeviceSynchImplOnSimple(com.qualcomm.robotcore.hardware.I2cDeviceSynchImplOnSimple)

Aggregations

I2cDeviceSynchSimple (com.qualcomm.robotcore.hardware.I2cDeviceSynchSimple)3 I2cDeviceSynch (com.qualcomm.robotcore.hardware.I2cDeviceSynch)2 NonNull (android.support.annotation.NonNull)1 LynxI2cDeviceSynch (com.qualcomm.hardware.lynx.LynxI2cDeviceSynch)1 HardwareDevice (com.qualcomm.robotcore.hardware.HardwareDevice)1 I2cDeviceSynchImplOnSimple (com.qualcomm.robotcore.hardware.I2cDeviceSynchImplOnSimple)1 Constructor (java.lang.reflect.Constructor)1