Пример #1
0
        private async Task SetupButton()
        {
            var gpio = await GpioController.GetDefaultAsync();

            if (gpio == null)
            {
                this.txtMessages.Text = "No GPIO controller found!";
                return;
            }

            GpioButtonPin = gpio.OpenPin(ButtonPinNr);
            GpioButtonPin.SetDriveMode(GpioButtonPin.IsDriveModeSupported(GpioPinDriveMode.InputPullUp)
                ? GpioPinDriveMode.InputPullUp
                : GpioPinDriveMode.Input);

            GpioButtonPin.DebounceTimeout = TimeSpan.FromMilliseconds(50);
            GpioButtonPin.ValueChanged   += ButtonPin_ValueChanged;

            var timer = new DispatcherTimer {
                Interval = TimeSpan.FromMilliseconds(500)
            };

            timer.Tick += Timer_Tick;
            timer.Start();
        }
Пример #2
0
 private void Page_Unloaded(object sender, object args)
 {
     GpioButtonPin.Dispose();
 }