コード例 #1
0
ファイル: Generator.cs プロジェクト: ArunPrakashG/Luna
        private void OnPollResult(bool currentValue, GpioPinState currentState)
        {
            if (!IsPossible)
            {
                return;
            }

            bool isSame    = PreviousValue.PinState == currentState;
            Pin  pinConfig = Driver.GetPinConfig(Config.GpioPin);
            OnValueChangedEventArgs args;

            switch (Config.PinEventState)
            {
            case PinEventStates.Activated when currentState == GpioPinState.On && !isSame:
                args = new OnValueChangedEventArgs(Config.GpioPin, currentState, currentValue,
                                                   Config.PinMode, PinEventStates.Activated, PreviousValue.PinState, PreviousValue.DigitalValue);
                Config.OnEvent?.Invoke(args);
                break;

            case PinEventStates.Deactivated when currentState == GpioPinState.Off && !isSame:
                args = new OnValueChangedEventArgs(Config.GpioPin, currentState, currentValue,
                                                   Config.PinMode, PinEventStates.Deactivated, PreviousValue.PinState, PreviousValue.DigitalValue);
                Config.OnEvent?.Invoke(args);
                break;

            case PinEventStates.Both when PreviousValue.PinState != currentState:
                args = new OnValueChangedEventArgs(Config.GpioPin, currentState, currentValue,
                                                   Config.PinMode, PinEventStates.Both, PreviousValue.PinState, PreviousValue.DigitalValue);
                Config.OnEvent?.Invoke(args);
                break;
            }

            PreviousValue.Set(currentState, currentValue);
        }
コード例 #2
0
ファイル: GpioCore.cs プロジェクト: ArunPrakashG/Luna
        private void GeneratePinConfiguration(IGpioControllerDriver _driver)
        {
            List <Pin> pinConfigs = new List <Pin>();

            for (int i = 0; i < Constants.BcmGpioPins.Length; i++)
            {
                pinConfigs.Add(_driver.GetPinConfig(Constants.BcmGpioPins[i]));
                Logger.Trace($"Generated pin config for '{Constants.BcmGpioPins[i]}' gpio pin.");
            }

            ConfigManager.Init(new PinConfig(pinConfigs, false));
        }