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


Java I2cDevice类代码示例

本文整理汇总了Java中com.google.android.things.pio.I2cDevice的典型用法代码示例。如果您正苦于以下问题:Java I2cDevice类的具体用法?Java I2cDevice怎么用?Java I2cDevice使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


I2cDevice类属于com.google.android.things.pio包,在下文中一共展示了I2cDevice类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Adafruit_FXAS21002C

import com.google.android.things.pio.I2cDevice; //导入依赖的package包/类
public Adafruit_FXAS21002C(I2cDevice device) {
        raw.x = 0;
        raw.y = 0;
        raw.z = 0;

//        _sensorID = sensorID;
        _device = device;
        _fifoMode = FifoModeEnum.Disabled;
        _waterMark = 0;

        _cutOff = 0;
        _fourWireMode = 0;
        _highPassFilterCutoff = 0;
        _highPassFilterEnable = 0;
        _range = RangeEnum.DPS250;

        _ODR = ODREnum.ODR_100;

        _interruptConfiguration = 0;

        // CTRL_REG3 (0x15)
        _wraptToOne = 0;
        _extCtrlen = 0;
        _fs_Double = 0;
    }
 
开发者ID:ekalyvio,项目名称:CowBit,代码行数:26,代码来源:Adafruit_FXAS21002C.java

示例2: Cap12xx

import com.google.android.things.pio.I2cDevice; //导入依赖的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: getI2cDevice

import com.google.android.things.pio.I2cDevice; //导入依赖的package包/类
/**
 * I2cDeviceを取得します.
 * <p>
 * 取得できなかった場合はnullを返却します。
 * </p>
 * <p>
 * 一度開いているI2cDeviceは、マップで管理して、取得します。
 * </p>
 * @param address アドレス
 * @return I2cDeviceのインスタンス
 */
I2cDevice getI2cDevice(final int address) {
    if (mI2cDeviceMap.containsKey(address)) {
        return mI2cDeviceMap.get(address);
    }

    List<String> i2cList = mManagerService.getI2cBusList();
    if (i2cList.isEmpty()) {
        if (DEBUG) {
            Log.i(TAG, "No I2C port available on this device.");
        }
        return null;
    } else {
        try {
            I2cDevice device = mManagerService.openI2cDevice(i2cList.get(0), address);
            if (device != null) {
                mI2cDeviceMap.put(address, device);
            }
            return device;
        } catch (IOException e) {
            return null;
        }
    }
}
 
开发者ID:DeviceConnect,项目名称:DeviceConnect-Android,代码行数:35,代码来源:FaBoThingsDeviceControl.java

示例4: HMC5883LDriver

import com.google.android.things.pio.I2cDevice; //导入依赖的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: connect

import com.google.android.things.pio.I2cDevice; //导入依赖的package包/类
private void connect(I2cDevice device) throws IOException {
    this.mDevice = device;
    setSamplesAvarage(SAMPLES_AVARAGE_8);
    setOutputRate(OUTPUT_RATE_4);
    setMeasurementMode(MEASUREMENT_NORMAL);
    setMeasurementGain(GAIN_1090);
    setOperationMode(OPERATION_MODE_CONT);
}
 
开发者ID:kevalpatel2106,项目名称:robo-car,代码行数:9,代码来源:HMC5883LDriver.java

示例6: ADXL345

import com.google.android.things.pio.I2cDevice; //导入依赖的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

示例7: connect

import com.google.android.things.pio.I2cDevice; //导入依赖的package包/类
private void connect(I2cDevice device) throws IOException {
    this.mDevice = device;
    this.mDevice.writeRegByte(ADXL345_RA_POWER_CTL, (byte) 0);
    setAutoSleepEnabled(true);
    setMeasureEnabled(true);

}
 
开发者ID:cagdasc,项目名称:AndroidThings-ADXL345,代码行数:8,代码来源:ADXL345.java

示例8: HMC5883L

import com.google.android.things.pio.I2cDevice; //导入依赖的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

示例9: Ssd1306

import com.google.android.things.pio.I2cDevice; //导入依赖的package包/类
/**
 * Create a new Ssd1306 driver connected to the named I2C bus and address
 * with the given dimensions.
 * @param i2cName I2C bus name the display is connected to
 * @param i2cAddress I2C address of the display
 * @param width display width in pixels.
 * @param height display height in pixels.
 * @throws IOException
 */
public Ssd1306(String i2cName, int i2cAddress, int width, int height) throws IOException {
    I2cDevice device = new PeripheralManagerService().openI2cDevice(i2cName, i2cAddress);
    try {
        init(device, width, height);
    } catch (IOException | RuntimeException e) {
        try {
            close();
        } catch (IOException | RuntimeException ignored) {
        }
        throw e;
    }
}
 
开发者ID:androidthings,项目名称:contrib-drivers,代码行数:22,代码来源:Ssd1306.java

示例10: init

import com.google.android.things.pio.I2cDevice; //导入依赖的package包/类
/**
 * Recommended start sequence for initializing the communications with the OLED display.
 * WARNING: If you change this code, power cycle your display before testing.
 * @throws IOException
 */
private void init(I2cDevice device, int width, int height) throws IOException {
    mI2cDevice = device;
    mWidth = width;
    mHeight = height;
    mBuffer = new byte[((mWidth * mHeight) / 8) + 1];
    BitmapHelper.bmpToBytes(mBuffer, DATA_OFFSET,
            Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888),
            false);
    mBuffer[0] = (byte) COMMAND_START_LINE;

    // Recommended initialization sequence based on http://goo.gl/VSu0C8
    mI2cDevice.write(INIT_PAYLOAD, INIT_PAYLOAD.length);
    stopScroll();
}
 
开发者ID:androidthings,项目名称:contrib-drivers,代码行数:20,代码来源:Ssd1306.java

示例11: Vcnl4200

import com.google.android.things.pio.I2cDevice; //导入依赖的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

示例12: connect

import com.google.android.things.pio.I2cDevice; //导入依赖的package包/类
private void connect(I2cDevice device, Configuration configuration) throws IOException {
    if (mDevice != null) {
        throw new IllegalStateException("device already connected");
    }
    mDevice = device;
    applyConfiguration(configuration);
}
 
开发者ID:androidthings,项目名称:contrib-drivers,代码行数:8,代码来源:Vcnl4200.java

示例13: Mma7660Fc

import com.google.android.things.pio.I2cDevice; //导入依赖的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: connect

import com.google.android.things.pio.I2cDevice; //导入依赖的package包/类
private void connect(I2cDevice device) throws IOException {
    if (mDevice != null) {
        throw new IllegalStateException("device already connected");
    }
    mDevice = device;
    setSamplingRate(RATE_120HZ);
}
 
开发者ID:androidthings,项目名称:contrib-drivers,代码行数:8,代码来源:Mma7660Fc.java

示例15: MotorHat

import com.google.android.things.pio.I2cDevice; //导入依赖的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


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