当前位置: 首页>>代码示例>>Java>>正文


Java GpioCallback类代码示例

本文整理汇总了Java中com.google.android.things.pio.GpioCallback的典型用法代码示例。如果您正苦于以下问题:Java GpioCallback类的具体用法?Java GpioCallback怎么用?Java GpioCallback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GpioCallback类属于com.google.android.things.pio包,在下文中一共展示了GpioCallback类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setup

import com.google.android.things.pio.GpioCallback; //导入依赖的package包/类
@Before
public void setup() throws Exception {
    ViewConfigurationMock.mockStatic();

    // Note: we need PowerMockito, so instantiate mocks here instead of using a MockitoRule
    mGpio = PowerMockito.mock(Gpio.class);
    mGpioCallback = PowerMockito.mock(InterruptCallback.class);
    PowerMockito.doNothing().when(mGpio).registerGpioCallback(any(GpioCallback.class));
    PowerMockito.whenNew(InterruptCallback.class).withNoArguments().thenReturn(mGpioCallback);
}
 
开发者ID:androidthings,项目名称:contrib-drivers,代码行数:11,代码来源:ButtonTest.java

示例2: setup

import com.google.android.things.pio.GpioCallback; //导入依赖的package包/类
@Before
public void setup() throws Exception {
    mGpio = PowerMockito.mock(Gpio.class);
    mGpioCallback = PowerMockito.mock(AlertCallback.class);
    PowerMockito.doNothing().when(mGpio).registerGpioCallback(any(GpioCallback.class));
    PowerMockito.whenNew(AlertCallback.class).withNoArguments().thenReturn(mGpioCallback);

    mDriver = new Cap12xx(mI2c, mGpio, CONFIGURATION);
    // clear invocations from driver init
    Mockito.reset(mGpio);
    Mockito.reset(mI2c);
}
 
开发者ID:androidthings,项目名称:contrib-drivers,代码行数:13,代码来源:Cap12xxTest.java

示例3: onCreate

import com.google.android.things.pio.GpioCallback; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.i(TAG, "Starting ButtonActivity");

    PeripheralManagerService service = new PeripheralManagerService();
    try {
        String pinName = BoardDefaults.getGPIOForButton();
        mButtonGpio = service.openGpio(pinName);
        mButtonGpio.setDirection(Gpio.DIRECTION_IN);
        mButtonGpio.setEdgeTriggerType(Gpio.EDGE_FALLING);
        mButtonGpio.registerGpioCallback(new GpioCallback() {
            @Override
            public boolean onGpioEdge(Gpio gpio) {
                Log.i(TAG, "GPIO changed, button pressed");
                // Return true to continue listening to events
                return true;
            }
        });
    } catch (IOException e) {
        Log.e(TAG, "Error on PeripheralIO API", e);
    }
}
 
开发者ID:androidthings,项目名称:sample-simplepio,代码行数:24,代码来源:ButtonActivity.java


注:本文中的com.google.android.things.pio.GpioCallback类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。