當前位置: 首頁>>代碼示例>>Java>>正文


Java PeripheralManagerService.getSpiBusList方法代碼示例

本文整理匯總了Java中com.google.android.things.pio.PeripheralManagerService.getSpiBusList方法的典型用法代碼示例。如果您正苦於以下問題:Java PeripheralManagerService.getSpiBusList方法的具體用法?Java PeripheralManagerService.getSpiBusList怎麽用?Java PeripheralManagerService.getSpiBusList使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.android.things.pio.PeripheralManagerService的用法示例。


在下文中一共展示了PeripheralManagerService.getSpiBusList方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: OLEDBlock

import com.google.android.things.pio.PeripheralManagerService; //導入方法依賴的package包/類
public OLEDBlock() throws IOException {
    PeripheralManagerService peripheralManagerService = new PeripheralManagerService();

    // Make sure GPIO is available for buttons
    List<String> gpioList = peripheralManagerService.getGpioList();
    if (gpioList.isEmpty()) {
        Log.i(TAG, "No GPIO available on this device.");
        throw new IOException("GPIO interface is require");
    } else {
        Log.i(TAG, "List of available GPIO : " + gpioList);
        for ( int i = 0; i < GPIOButtons.length; i ++ ) {
            if ( gpioList.contains(GPIOButtons[i]) == false )
                Log.i(TAG, "GPIO "+GPIOButtons[i]+" is not available on this device.");
        }
        // SSD1306
        if (gpioList.contains("GP14")== false )
            Log.i(TAG, "GPIO GP14 is not available on this device.");
        if (gpioList.contains("GP15")== false )
            Log.i(TAG, "GPIO GP15 is not available on this device.");
    }

    // SPI will be use by SSD1306 OLED display
    List<String> spiList = peripheralManagerService.getSpiBusList();
    if (spiList.isEmpty()) {
        Log.i(TAG, "No SPI available on this device.");
        throw new IOException("SPI interface is require");
    } else {
        Log.i(TAG, "List of available SPI : " + spiList);
    }

    // Setup button
    for ( int i = 0 ; i < GPIOButtons.length; i++ ) {
        ButtonInputDriver buttonInputDriver = new ButtonInputDriver(GPIOButtons[i],
                Button.LogicState.PRESSED_WHEN_LOW,
                buttons[i] // the keycode to send
        );
        buttonInputDriver.register();
        buttonInputDriverList.add(buttonInputDriver);
    }

    try {
        ssd1306 = new SSD1306(spiList.get(0));
    } catch (InterruptedException e) {
        Log.e(TAG,"error",e);
        throw new IOException("Unable to init SSD1306");
    }

    Log.i(TAG, "Completed init");
}
 
開發者ID:hongcheng79,項目名稱:androidthings,代碼行數:50,代碼來源:OLEDBlock.java


注:本文中的com.google.android.things.pio.PeripheralManagerService.getSpiBusList方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。