protected internal override void SetPinEventsToDetect(int bcmPinNumber, PinEvent events)
        {
            ValidatePinNumber(bcmPinNumber);

            PinEvent kind    = PinEvent.Low;
            bool     enabled = events.HasFlag(kind);

            SetEventDetection(bcmPinNumber, kind, enabled);

            kind    = PinEvent.High;
            enabled = events.HasFlag(kind);
            SetEventDetection(bcmPinNumber, kind, enabled);

            kind    = PinEvent.SyncRisingEdge;
            enabled = events.HasFlag(kind);
            SetEventDetection(bcmPinNumber, kind, enabled);

            kind    = PinEvent.SyncFallingEdge;
            enabled = events.HasFlag(kind);
            SetEventDetection(bcmPinNumber, kind, enabled);

            kind    = PinEvent.AsyncRisingEdge;
            enabled = events.HasFlag(kind);
            SetEventDetection(bcmPinNumber, kind, enabled);

            kind    = PinEvent.AsyncFallingEdge;
            enabled = events.HasFlag(kind);
            SetEventDetection(bcmPinNumber, kind, enabled);

            ClearDetectedEvent(bcmPinNumber);
        }
예제 #2
0
        private string EventKindToStringValue(PinEvent kind)
        {
            string result;

            if (kind == PinEvent.None)
            {
                result = "none";
            }
            else if (kind.HasFlag(PinEvent.SyncBoth) ||
                     kind.HasFlag(PinEvent.AsyncBoth))
            {
                result = "both";
            }
            else if (kind.HasFlag(PinEvent.SyncRisingEdge) ||
                     kind.HasFlag(PinEvent.AsyncRisingEdge))
            {
                result = "rising";
            }
            else if (kind.HasFlag(PinEvent.SyncFallingEdge) ||
                     kind.HasFlag(PinEvent.AsyncFallingEdge))
            {
                result = "falling";
            }
            else
            {
                throw new NotSupportedException($"Not supported GPIO event kind '{kind}'");
            }

            return(result);
        }