本文整理汇总了Java中com.google.android.things.contrib.driver.button.ButtonInputDriver类的典型用法代码示例。如果您正苦于以下问题:Java ButtonInputDriver类的具体用法?Java ButtonInputDriver怎么用?Java ButtonInputDriver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ButtonInputDriver类属于com.google.android.things.contrib.driver.button包,在下文中一共展示了ButtonInputDriver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: initPIO
import com.google.android.things.contrib.driver.button.ButtonInputDriver; //导入依赖的package包/类
/**
* This method should only be called when running on an Android Things device.
*/
private void initPIO() {
PeripheralManagerService pioService = new PeripheralManagerService();
try {
mReadyLED = pioService.openGpio(BoardDefaults.getGPIOForLED());
mReadyLED.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);
mButtonDriver = new ButtonInputDriver(
BoardDefaults.getGPIOForButton(),
Button.LogicState.PRESSED_WHEN_LOW,
KeyEvent.KEYCODE_ENTER);
mButtonDriver.register();
} catch (IOException e) {
mButtonDriver = null;
Log.w(TAG, "Could not open GPIO pins", e);
}
}
开发者ID:androidthings,项目名称:sample-tensorflow-imageclassifier,代码行数:19,代码来源:ImageClassifierActivity.java
示例2: onCreate
import com.google.android.things.contrib.driver.button.ButtonInputDriver; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.i(TAG, "Starting ButtonActivity");
PeripheralManagerService pioService = new PeripheralManagerService();
try {
Log.i(TAG, "Configuring GPIO pins");
mLedGpio = pioService.openGpio(BoardDefaults.getGPIOForLED());
mLedGpio.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);
Log.i(TAG, "Registering button driver");
// Initialize and register the InputDriver that will emit SPACE key events
// on GPIO state changes.
mButtonInputDriver = new ButtonInputDriver(
BoardDefaults.getGPIOForButton(),
Button.LogicState.PRESSED_WHEN_LOW,
KeyEvent.KEYCODE_SPACE);
mButtonInputDriver.register();
} catch (IOException e) {
Log.e(TAG, "Error configuring GPIO pins", e);
}
}
开发者ID:androidthings,项目名称:sample-button,代码行数:24,代码来源:ButtonActivity.java
示例3: testButtonInputDriver
import com.google.android.things.contrib.driver.button.ButtonInputDriver; //导入依赖的package包/类
/**
* Registers button as an InputDriver
*/
@Test
@UiThreadTest
public void testButtonInputDriver() throws IOException {
InstrumentationTestUtils.assertRaspberryPiOnly();
getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
try {
ButtonInputDriver driver =
VoiceHat.createButtonInputDriver(KeyEvent.KEYCODE_ENTER);
driver.register();
driver.unregister();
driver.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
});
}
开发者ID:androidthings,项目名称:contrib-drivers,代码行数:23,代码来源:VoiceHatPeripheralInstrumentationTest.java
示例4: initPIO
import com.google.android.things.contrib.driver.button.ButtonInputDriver; //导入依赖的package包/类
private void initPIO() {
PeripheralManagerService pioService = new PeripheralManagerService();
try {
mReadyLED = pioService.openGpio(BoardDefaults.getGPIOForLED());
mReadyLED.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);
mButtonDriver = new ButtonInputDriver(
BoardDefaults.getGPIOForButton(),
Button.LogicState.PRESSED_WHEN_LOW,
KeyEvent.KEYCODE_ENTER);
mButtonDriver.register();
} catch (IOException e) {
mButtonDriver = null;
Log.w(TAG, "Could not open GPIO pins", e);
}
}
开发者ID:FoxLabMakerSpace,项目名称:SIGHT-For-the-Blind,代码行数:16,代码来源:ImageClassifierActivity.java
示例5: configureButton
import com.google.android.things.contrib.driver.button.ButtonInputDriver; //导入依赖的package包/类
private void configureButton() {
try {
mPairingButtonDriver = new ButtonInputDriver(BoardDefaults.getGPIOForPairing(),
Button.LogicState.PRESSED_WHEN_LOW, KeyEvent.KEYCODE_P);
mPairingButtonDriver.register();
mDisconnectAllButtonDriver = new ButtonInputDriver(
BoardDefaults.getGPIOForDisconnectAllBTDevices(),
Button.LogicState.PRESSED_WHEN_LOW, KeyEvent.KEYCODE_D);
mDisconnectAllButtonDriver.register();
} catch (IOException e) {
Log.w(TAG, "Could not register GPIO button drivers. Use keyboard events to trigger " +
"the functions instead", e);
}
}
开发者ID:androidthings,项目名称:sample-bluetooth-audio,代码行数:15,代码来源:A2dpSinkActivity.java
示例6: initPIO
import com.google.android.things.contrib.driver.button.ButtonInputDriver; //导入依赖的package包/类
private void initPIO() {
try {
mButtonInputDriver = new ButtonInputDriver(
BoardDefaults.getGPIOForButton(),
Button.LogicState.PRESSED_WHEN_LOW,
KeyEvent.KEYCODE_ENTER);
mButtonInputDriver.register();
} catch (IOException e) {
mButtonInputDriver = null;
Log.w(TAG, "Could not open GPIO pins", e);
}
}
开发者ID:androidthings,项目名称:doorbell,代码行数:13,代码来源:DoorbellActivity.java
示例7: Buttons
import com.google.android.things.contrib.driver.button.ButtonInputDriver; //导入依赖的package包/类
public Buttons(ButtonInputDriver buttonA, ButtonInputDriver buttonB, ButtonInputDriver buttonC) throws IOException {
buttonDrivers.add(buttonA);
buttonDrivers.add(buttonB);
buttonDrivers.add(buttonC);
}
开发者ID:JeppeLeth,项目名称:android-things-rainbow-hat-sample,代码行数:6,代码来源:Buttons.java
示例8: registerButtonDriver
import com.google.android.things.contrib.driver.button.ButtonInputDriver; //导入依赖的package包/类
private static ButtonInputDriver registerButtonDriver(String pin, int keycode) throws IOException {
ButtonInputDriver driver = new ButtonInputDriver(pin, Button.LogicState.PRESSED_WHEN_LOW, keycode);
driver.register();
return driver;
}
开发者ID:JeppeLeth,项目名称:android-things-rainbow-hat-sample,代码行数:6,代码来源:Buttons.java
示例9: close
import com.google.android.things.contrib.driver.button.ButtonInputDriver; //导入依赖的package包/类
@Override
public void close() throws IOException {
for (ButtonInputDriver buttonDriver : buttonDrivers) {
buttonDriver.close();
}
}
开发者ID:JeppeLeth,项目名称:android-things-rainbow-hat-sample,代码行数:7,代码来源:Buttons.java
示例10: OLEDBlock
import com.google.android.things.contrib.driver.button.ButtonInputDriver; //导入依赖的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
示例11: createButtonAInputDriver
import com.google.android.things.contrib.driver.button.ButtonInputDriver; //导入依赖的package包/类
public static ButtonInputDriver createButtonAInputDriver(int keycode) throws IOException {
return createButtonInputDriver(BOARD.getButtonA(), keycode);
}
开发者ID:androidthings,项目名称:contrib-drivers,代码行数:4,代码来源:RainbowHat.java
示例12: createButtonBInputDriver
import com.google.android.things.contrib.driver.button.ButtonInputDriver; //导入依赖的package包/类
public static ButtonInputDriver createButtonBInputDriver(int keycode) throws IOException {
return createButtonInputDriver(BOARD.getButtonB(), keycode);
}
开发者ID:androidthings,项目名称:contrib-drivers,代码行数:4,代码来源:RainbowHat.java
示例13: createButtonCInputDriver
import com.google.android.things.contrib.driver.button.ButtonInputDriver; //导入依赖的package包/类
public static ButtonInputDriver createButtonCInputDriver(int keycode) throws IOException {
return createButtonInputDriver(BOARD.getButtonC(), keycode);
}
开发者ID:androidthings,项目名称:contrib-drivers,代码行数:4,代码来源:RainbowHat.java
示例14: createButtonInputDriver
import com.google.android.things.contrib.driver.button.ButtonInputDriver; //导入依赖的package包/类
public static ButtonInputDriver createButtonInputDriver(String pin, int keycode) throws IOException {
return new ButtonInputDriver(pin, BUTTON_LOGIC_STATE, keycode);
}
开发者ID:androidthings,项目名称:contrib-drivers,代码行数:4,代码来源:RainbowHat.java
示例15: createButtonInputDriver
import com.google.android.things.contrib.driver.button.ButtonInputDriver; //导入依赖的package包/类
/**
* Opens an InputDriver using the default pin on the Raspberry Pi.
*
* @return InputDriver for the pushbutton on the VoiceHat
*/
public static ButtonInputDriver createButtonInputDriver(int keyCode) throws IOException {
assertRaspberryPi3();
return createButtonInputDriver(RPI_BUTTON_GPIO, keyCode);
}
开发者ID:androidthings,项目名称:contrib-drivers,代码行数:10,代码来源:VoiceHat.java
注:本文中的com.google.android.things.contrib.driver.button.ButtonInputDriver类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论