本文整理匯總了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");
}