当前位置: 首页>>代码示例>>Java>>正文


Java PeripheralManagerService.openI2cDevice方法代码示例

本文整理汇总了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);
}
 
开发者ID:hongcheng79,项目名称:androidthings,代码行数:17,代码来源:LSM9DS0.java

示例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;
    }
}
 
开发者ID:androidthings,项目名称:contrib-drivers,代码行数:31,代码来源:Cap12xx.java

示例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();
}
 
开发者ID:zugaldia,项目名称:android-robocar,代码行数:17,代码来源:AdafruitPwm.java

示例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;
    }
}
 
开发者ID:kevalpatel2106,项目名称:robo-car,代码行数:14,代码来源:HMC5883LDriver.java

示例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();
}
 
开发者ID:mariob316,项目名称:AndyBot,代码行数:14,代码来源:AdafruitPwm.java

示例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;
    }
}
 
开发者ID:jpuderer,项目名称:jpuderer-things-drivers,代码行数:11,代码来源:Ds3231Rtc.java

示例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();
    }
}
 
开发者ID:bregydoc,项目名称:MarsWeatherSimulator,代码行数:10,代码来源:MarsI2cControl.java

示例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();
    }
}
 
开发者ID:bregydoc,项目名称:MarsWeatherSimulator,代码行数:13,代码来源:Phoenix.java

示例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();
    }
}
 
开发者ID:bregydoc,项目名称:MarsWeatherSimulator,代码行数:10,代码来源:MarsI2cControl.java

示例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;
    }
}
 
开发者ID:cagdasc,项目名称:AndroidThings-ADXL345,代码行数:14,代码来源:ADXL345.java

示例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;
    }
}
 
开发者ID:cagdasc,项目名称:AndroidThings-HMC5883L,代码行数:14,代码来源:HMC5883L.java

示例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;
    }
}
 
开发者ID:androidthings,项目名称:contrib-drivers,代码行数:20,代码来源:Vcnl4200.java

示例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;
    }
}
 
开发者ID:androidthings,项目名称:contrib-drivers,代码行数:19,代码来源:Mma7660Fc.java

示例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;
    }
}
 
开发者ID:androidthings,项目名称:contrib-drivers,代码行数:14,代码来源:MotorHat.java

示例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;
    }
}
 
开发者ID:androidthings,项目名称:contrib-drivers,代码行数:20,代码来源:Bmx280.java


注:本文中的com.google.android.things.pio.PeripheralManagerService.openI2cDevice方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。