Win10 IoT - RaspBerry Pi2: ValueChanged not called when GPIO change

最后都变了- 提交于 2020-01-04 14:11:13

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!