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