Ejemplo n.º 1
0
        private void ValueChangedOnInputPin(GpioPin sender, GpioPinValueChangedEventArgs args)
        {
            switch (args.Edge)
            {
            case GpioPinEdge.FallingEdge:
                PinValueInputChangedLow?.Invoke(this, EventArgs.Empty);
                break;

            case GpioPinEdge.RisingEdge:
                PinValueInputChangedHigh?.Invoke(this, EventArgs.Empty);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        private ThreadPoolTimer StartInterruptTimer(int millisecondsBetweenInterrupts)
        {
            if (millisecondsBetweenInterrupts <= 0)
            {
                return(null);
            }

            return(ThreadPoolTimer.CreatePeriodicTimer(
                       (ThreadPoolTimer timer) =>
            {
                if (_pinHigh == false)
                {
                    _pinHigh = true;
                    PinValueInputChangedHigh?.Invoke(this, EventArgs.Empty);
                }
            },
                       TimeSpan.FromMilliseconds(millisecondsBetweenInterrupts)));
        }