在这个程序中,我可以读取GPIO 引脚。但是为单个事件按下硬件按钮(与按钮连接的GPIO引脚)会导致状态变化的爆发并导致动作事件的爆发......那么我怎样才能消除在一定时间段内同时发生的GPIO状态变化来消除这种情况爆裂。
final GpioController gpio = GpioFactory.getInstance();
GpioPinDigitalInput myButton = null;
try {
myButton = gpio.provisionDigitalInputPin(RaspiPin.GPIO_02,PinPullResistance.PULL_DOWN);
} catch(GpioPinExistsException e) {
}
try {
myButton.addListener(new GpioPinListenerDigital() {
@Override
public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent event) {
if(event.getState().toString().equalsIgnoreCase("HIGH") || event.getState().toString().equalsIgnoreCase("LOW")) {
System.out.println("Pressed");
}
}
});
} catch(NullPointerException e2) {
}