use of com.qualcomm.robotcore.hardware.I2cDeviceSynch 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");
}
use of com.qualcomm.robotcore.hardware.I2cDeviceSynch 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;
}
use of com.qualcomm.robotcore.hardware.I2cDeviceSynch 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;
}
use of com.qualcomm.robotcore.hardware.I2cDeviceSynch 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);
}
use of com.qualcomm.robotcore.hardware.I2cDeviceSynch in project robotcode by OutoftheBoxFTC.
the class HardwareFactory method mapI2cDeviceSynch.
private void mapI2cDeviceSynch(HardwareMap map, DeviceManager deviceMgr, LynxModule module, DeviceConfiguration devConf) {
I2cDeviceSynch i2cDeviceSynch = deviceMgr.createI2cDeviceSynch(module, devConf.getI2cChannel(), devConf.getName());
map.i2cDeviceSynch.put(devConf.getName(), i2cDeviceSynch);
}
Aggregations