Win10 IoT - RaspBerry Pi2:GPIO更改时未调用ValueChanged

时间:2015-07-16 05:25:28

标签: .net events raspberry-pi gpio windows-10-iot-core

我在Rpi2上测试Win10 IoT,代码如下:

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);
}

问题是我的OnButtonChanged没有被调用。我基本上只是将GPIO按钮连接到地面(也测试到VCC)。

奇怪的是,如果我手动调用buttonPin.Read(),我会在内部找到正确的GpioPinValue,那么我可能做错了什么

0 个答案:

没有答案