本文整理汇总了Java中com.google.android.things.pio.PeripheralManagerService.openI2cDevice方法的典型用法代码示例。如果您正苦于以下问题:Java PeripheralManagerService.openI2cDevice方法的具体用法?Java PeripheralManagerService.openI2cDevice怎么用?Java PeripheralManagerService.openI2cDevice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.things.pio.PeripheralManagerService
的用法示例。
在下文中一共展示了PeripheralManagerService.openI2cDevice方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: LSM9DS0
import com.google.android.things.pio.PeripheralManagerService; //导入方法依赖的package包/类
public LSM9DS0(int gyroAdddress, int xmAddress) throws IOException {
PeripheralManagerService peripheralManagerService = new PeripheralManagerService();
// Make sure there is available I2C
List<String> i2cList = peripheralManagerService.getI2cBusList();
if (i2cList.isEmpty()) {
Log.i(TAG, "No I2C available on this device.");
throw new IOException("I2C interface is require");
} else {
Log.i(TAG, "List of available I2C : " + i2cList);
}
// Asssumption here to use the first available i2c
gyro = peripheralManagerService.openI2cDevice(i2cList.get(0), gyroAdddress);
xm = peripheralManagerService.openI2cDevice(i2cList.get(0), xmAddress);
}
示例2: Cap12xx
import com.google.android.things.pio.PeripheralManagerService; //导入方法依赖的package包/类
/**
* Create a new Cap12xx controller.
*
* @param i2cName I2C port name where the controller is attached. Cannot be null.
* @param alertName optional GPIO pin name connected to the controller's
* alert interrupt signal. Can be null.
* @param chip identifier for the connected controller device chip.
* @param handler optional {@link Handler} for software polling and callback events.
* @throws IOException
*/
public Cap12xx(String i2cName, String alertName, Configuration chip, Handler handler)
throws IOException {
mChipConfiguration = chip;
try {
PeripheralManagerService manager = new PeripheralManagerService();
I2cDevice device = manager.openI2cDevice(i2cName, I2C_ADDRESS);
Gpio alertPin = null;
if (alertName != null) {
alertPin = manager.openGpio(alertName);
}
init(device, alertPin, chip, handler);
} catch (IOException|RuntimeException e) {
// Close the peripherals if an init error occurs
try {
close();
} catch (IOException|RuntimeException ignored) {
}
throw e;
}
}
示例3: AdafruitPwm
import com.google.android.things.pio.PeripheralManagerService; //导入方法依赖的package包/类
/**
* Public constructor.
*/
public AdafruitPwm(String deviceName, int address, boolean debug) {
try {
// Attempt to access the I2C device
Timber.d("Connecting to I2C device %s @ 0x%02X.", deviceName, address);
PeripheralManagerService manager = new PeripheralManagerService();
i2c = manager.openI2cDevice(deviceName, address);
} catch (IOException e) {
Timber.e(e, "Unable to access I2C device.");
}
this.debug = debug;
reset();
}
示例4: HMC5883LDriver
import com.google.android.things.pio.PeripheralManagerService; //导入方法依赖的package包/类
HMC5883LDriver(String bus) throws IOException {
PeripheralManagerService peripheralManagerService = new PeripheralManagerService();
I2cDevice device = peripheralManagerService.openI2cDevice(bus, HMC5883L_DEV_ADD);
try {
connect(device);
} catch (IOException | RuntimeException e) {
try {
close();
} catch (IOException | RuntimeException ignored) {
}
throw e;
}
}
示例5: AdafruitPwm
import com.google.android.things.pio.PeripheralManagerService; //导入方法依赖的package包/类
public AdafruitPwm(String deviceName, int address, boolean debug) {
try {
// Attempt to access the I2C device
Log.d(LOG_TAG, String.format("Connecting to I2C device %s @ 0x%02X.", deviceName, address));
PeripheralManagerService manager = new PeripheralManagerService();
i2c = manager.openI2cDevice(deviceName, address);
} catch (IOException e) {
Log.w(LOG_TAG, "Unable to access I2C device:", e);
}
this.debug = debug;
reset();
}
示例6: Ds3231Rtc
import com.google.android.things.pio.PeripheralManagerService; //导入方法依赖的package包/类
public Ds3231Rtc(String i2cDeviceName) throws IOException {
// Attempt to access the I2C device
try {
PeripheralManagerService manager = new PeripheralManagerService();
mDevice = manager.openI2cDevice(i2cDeviceName, I2C_ADDRESS);
} catch (IOException e) {
Log.e(TAG, "Unable to access I2C device", e);
return;
}
}
示例7: MarsI2cControl
import com.google.android.things.pio.PeripheralManagerService; //导入方法依赖的package包/类
public MarsI2cControl(int address) {
manager = new PeripheralManagerService();
helperWebControl = new FirebaseCommunication();
try {
dueMarsControl = manager.openI2cDevice("I2C1", address);
} catch (IOException e) {
e.printStackTrace();
}
}
示例8: Phoenix
import com.google.android.things.pio.PeripheralManagerService; //导入方法依赖的package包/类
public Phoenix(int address) {
manager = new PeripheralManagerService();
try {
systemCommunication = manager.openI2cDevice("I2C1", address);
resetPin = manager.openGpio("BCM25");
resetPin.setDirection(Gpio.DIRECTION_OUT_INITIALLY_HIGH);
resetPin.setActiveType(Gpio.ACTIVE_HIGH);
} catch (IOException e) {
e.printStackTrace();
}
}
示例9: MarsI2cControl
import com.google.android.things.pio.PeripheralManagerService; //导入方法依赖的package包/类
public MarsI2cControl(int address) {
manager = new PeripheralManagerService();
try {
dueMarsControl = manager.openI2cDevice("I2C1", address);
} catch (IOException e) {
e.printStackTrace();
}
}
示例10: ADXL345
import com.google.android.things.pio.PeripheralManagerService; //导入方法依赖的package包/类
public ADXL345(String bus) throws IOException {
PeripheralManagerService peripheralManagerService = new PeripheralManagerService();
I2cDevice device = peripheralManagerService.openI2cDevice(bus, ADXL345_DEFAULT_ADDRESS);
try {
connect(device);
} catch (IOException | RuntimeException e) {
try {
close();
} catch (IOException | RuntimeException ignored) {
}
throw e;
}
}
示例11: HMC5883L
import com.google.android.things.pio.PeripheralManagerService; //导入方法依赖的package包/类
public HMC5883L(String bus) throws IOException {
PeripheralManagerService peripheralManagerService = new PeripheralManagerService();
I2cDevice device = peripheralManagerService.openI2cDevice(bus, HMC5883L_DEV_ADD);
try {
connect(device);
} catch (IOException | RuntimeException e) {
try {
close();
} catch (IOException | RuntimeException ignored) {
}
throw e;
}
}
示例12: Vcnl4200
import com.google.android.things.pio.PeripheralManagerService; //导入方法依赖的package包/类
/**
* Create a new VCNL4200 sensor driver connected to the given I2C bus.
* @param bus I2C bus the sensor is connected to.
* @param configuration Initial configuration of the sensor.
* @throws IOException
*/
public Vcnl4200(String bus, Configuration configuration) throws IOException {
PeripheralManagerService pioService = new PeripheralManagerService();
I2cDevice device = pioService.openI2cDevice(bus, I2C_ADDRESS);
try {
connect(device, configuration);
} catch (IOException|RuntimeException e) {
try {
close();
} catch (IOException|RuntimeException ignored) {
}
throw e;
}
}
示例13: Mma7660Fc
import com.google.android.things.pio.PeripheralManagerService; //导入方法依赖的package包/类
/**
* Create a new MMA7660FC driver connected to the given I2C bus.
* @param bus
* @throws IOException
*/
public Mma7660Fc(String bus) throws IOException {
PeripheralManagerService pioService = new PeripheralManagerService();
I2cDevice device = pioService.openI2cDevice(bus, I2C_ADDRESS);
try {
connect(device);
} catch (IOException|RuntimeException e) {
try {
close();
} catch (IOException|RuntimeException ignored) {
}
throw e;
}
}
示例14: MotorHat
import com.google.android.things.pio.PeripheralManagerService; //导入方法依赖的package包/类
public MotorHat(String i2cBusName, int i2cAddress) throws IOException {
PeripheralManagerService pioService = new PeripheralManagerService();
I2cDevice device = pioService.openI2cDevice(i2cBusName, i2cAddress);
try {
initialize(device);
} catch (IOException | RuntimeException e) {
try {
close();
} catch (IOException | RuntimeException ignored) {
}
throw e;
}
}
示例15: Bmx280
import com.google.android.things.pio.PeripheralManagerService; //导入方法依赖的package包/类
/**
* Create a new BMP/BME280 sensor driver connected on the given bus and address.
* @param bus I2C bus the sensor is connected to.
* @param address I2C address of the sensor.
* @throws IOException
*/
public Bmx280(String bus, int address) throws IOException {
PeripheralManagerService pioService = new PeripheralManagerService();
I2cDevice device = pioService.openI2cDevice(bus, address);
try {
connect(device);
} catch (IOException|RuntimeException e) {
try {
close();
} catch (IOException|RuntimeException ignored) {
}
throw e;
}
}