• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ButtonInputDriver类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java XMLInputSource类代码示例发布时间:2022-05-22
下一篇:
Java DebugCounterServiceImpl类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap