本文整理汇总了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);
}
}
示例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);
}
}
});
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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;
}
示例9: close
import com.google.android.things.contrib.driver.button.ButtonInputDriver; //导入依赖的package包/类
@Override
public void close() throws IOException {
for (ButtonInputDriver buttonDriver : buttonDrivers) {
buttonDriver.close();
}
}
示例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");
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}