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