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


Java PeripheralManagerService.openSpiDevice方法代码示例

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


在下文中一共展示了PeripheralManagerService.openSpiDevice方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: LedControl

import com.google.android.things.pio.PeripheralManagerService; //导入方法依赖的package包/类
public LedControl(String spiGpio) throws IOException {
    PeripheralManagerService pioService = new PeripheralManagerService();
    spiDevice = pioService.openSpiDevice(spiGpio);
    spiDevice.setMode(SpiDevice.MODE0);
    spiDevice.setFrequency(1000000); // 1MHz
    spiDevice.setBitsPerWord(8); // 8 BPW
    spiDevice.setBitJustification(false); // MSB first

    spiTransfer(OP_DECODEMODE, 0); // decoding: BCD
    setScanLimit(7); // scanlimit: 8 LEDs
    spiTransfer(OP_DISPLAYTEST, 0);

    shutdown(false);
    setIntensity(3);
    clearDisplay();
}
 
开发者ID:Nilhcem,项目名称:blefun-androidthings,代码行数:17,代码来源:LedControl.java

示例2: LedControl

import com.google.android.things.pio.PeripheralManagerService; //导入方法依赖的package包/类
public LedControl(String spiGpio, int numDevices) throws IOException {
    PeripheralManagerService pioService = new PeripheralManagerService();
    spiDevice = pioService.openSpiDevice(spiGpio);
    spiDevice.setMode(SpiDevice.MODE0);
    spiDevice.setFrequency(1000000); // 1MHz
    spiDevice.setBitsPerWord(8); // 8 BPW
    spiDevice.setBitJustification(false); // MSB first

    maxDevices = numDevices;
    if (numDevices < 1 || numDevices > 8) {
        maxDevices = 8;
    }

    for (int i = 0; i < maxDevices; i++) {
        spiTransfer(i, OP_DISPLAYTEST, 0);
        setScanLimit(i, 7); // scanlimit: 8 LEDs
        spiTransfer(i, OP_DECODEMODE, 0); // decoding: BCD
        clearDisplay(i);
        // we go into shutdown-mode on startup
        shutdown(i, true);
    }
}
 
开发者ID:Nilhcem,项目名称:ledcontrol-androidthings,代码行数:23,代码来源:LedControl.java

示例3: Apa102

import com.google.android.things.pio.PeripheralManagerService; //导入方法依赖的package包/类
/**
 * Create a new Apa102 driver.
 *
 * @param spiBusPort Name of the SPI bus
 * @param ledMode The {@link Mode} indicating the red/green/blue byte ordering for the device.
 * @param direction The {@link Direction} or the led strip.
 */
public Apa102(String spiBusPort, Mode ledMode, Direction direction) throws IOException {
    mLedMode = ledMode;
    mDirection = direction;
    PeripheralManagerService pioService = new PeripheralManagerService();
    mDevice = pioService.openSpiDevice(spiBusPort);
    try {
        configure(mDevice);
    } catch (IOException|RuntimeException e) {
        try {
            close();
        } catch (IOException|RuntimeException ignored) {
        }
        throw e;
    }
}
 
开发者ID:androidthings,项目名称:contrib-drivers,代码行数:23,代码来源:Apa102.java

示例4: TM1838Driver

import com.google.android.things.pio.PeripheralManagerService; //导入方法依赖的package包/类
/**
 * Setup and initialize object using SPI device (MOSI pulled up to MISO by 1K resistor)
 * @param spiDeviceName
 * @param brightness desired display brightness 0-7
 * @throws IOException
 */
public TM1838Driver(@NonNull String spiDeviceName, int brightness) throws IOException {
    PeripheralManagerService service = new PeripheralManagerService();
    spiDevice = service.openSpiDevice(spiDeviceName);
    spiDevice.setMode(SpiDevice.MODE3);
    spiDevice.setFrequency(16000000);     // 16MHz
    spiDevice.setDelay(80);
    spiDevice.setBitsPerWord(8);          // 8 BPW
    spiDevice.setBitJustification(false); // MSB first
    spiDevice.setCsChange(false);
    init(brightness);
}
 
开发者ID:dglabs,项目名称:androidthings-drivers,代码行数:18,代码来源:TM1838Driver.java

示例5: onCreate

import com.google.android.things.pio.PeripheralManagerService; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mTagDetectedView = (TextView)findViewById(R.id.tag_read);
    mTagUidView = (TextView)findViewById(R.id.tag_uid);
    mTagResultsView = (TextView) findViewById(R.id.tag_results);
    button = (Button)findViewById(R.id.button);
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mRfidTask = new RfidTask(mRc522);
            mRfidTask.execute();
            ((Button)v).setText(R.string.reading);
        }
    });
    PeripheralManagerService pioService = new PeripheralManagerService();
    try {
        spiDevice = pioService.openSpiDevice(SPI_PORT);
        gpioReset = pioService.openGpio(PIN_RESET);
        mRc522 = new Rc522(spiDevice, gpioReset);
        mRc522.setDebugging(true);
    } catch (IOException e) {
        Toast.makeText(this, e.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
        e.printStackTrace();
    }
}
 
开发者ID:Galarzaa90,项目名称:android-things-rc522,代码行数:29,代码来源:MainActivity.java

示例6: Adxl362

import com.google.android.things.pio.PeripheralManagerService; //导入方法依赖的package包/类
public Adxl362(String spiPort) throws IOException {
    PeripheralManagerService service = new PeripheralManagerService();
    device = service.openSpiDevice(spiPort);
    connfigureSpi(device);
}
 
开发者ID:vishal-android-freak,项目名称:ADXL362-Interfacing-Library,代码行数:6,代码来源:Adxl362.java

示例7: Adxl362

import com.google.android.things.pio.PeripheralManagerService; //导入方法依赖的package包/类
/**
 * Creates a new SpiDevice instance
 * @param spiPort - can be either SPI0.0 or SPI0.1 (for Raspberry Pi)
 * @param frequencyInHz - This will vary according to the peripheral to be interfaced, default should be 1MHz.
 *                      ADXL362 has a range of 1MHz to 8MHz
 * @param mode - Modes are MODE_0, MODE_1, MODE_2, MODE_3.
 *             ADXL362 works on MODE_0
 * @throws IOException
 */
public Adxl362(String spiPort, int frequencyInHz, int mode) throws IOException {
    PeripheralManagerService service = new PeripheralManagerService();
    device = service.openSpiDevice(spiPort);
    connfigureSpi(device, frequencyInHz, mode);
}
 
开发者ID:vishal-android-freak,项目名称:ADXL362-Interfacing-Library,代码行数:15,代码来源:Adxl362.java


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