问题
I'm testing Win10 IoT on my Rpi2, with the following code:
private void InitializeInterrupt()
{
GpioController gpioController = GpioController.GetDefault();
GpioPin buttonPin = gpioController.OpenPin(24);
_ledPin= gpioController.OpenPin(25);
buttonPin.SetDriveMode(GpioPinDriveMode.InputPullUp);
_ledPin.Write(buttonPin.Read());
_ledPin.SetDriveMode(GpioPinDriveMode.Output);
buttonPin.ValueChanged += OnButtonChanged;
}
private void OnButtonChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
{
//I know the condition is inversed, I want the led UP when the button is not closed
_buttonFeedbackPin.Write(args.Edge != GpioPinEdge.RisingEdge ? GpioPinValue.High : GpioPinValue.Low);
}
The issue is that my OnButtonChanged is not called. I basically just wire my GPIO button to the Ground(also tested to VCC).
The weird thing is that if I call manually the buttonPin.Read()
, I got the correct GpioPinValue
inside, so what could I've done wrong
来源:https://stackoverflow.com/questions/31445905/win10-iot-raspberry-pi2-valuechanged-not-called-when-gpio-change