コード例 #1
0
        /// <summary>
        /// Starts the specified behavior on the connection.
        /// </summary>
        /// <param name="connection">The connection.</param>
        /// <param name="behavior">The behavior.</param>
        public static void Start(this GpioConnection connection, PinsBehavior behavior)
        {
            foreach (var configuration in behavior.Configurations)
            {
                if (!connection.Contains(configuration))
                {
                    connection.Add(configuration);
                }
            }

            behavior.Start(connection);
        }
コード例 #2
0
ファイル: Main.cs プロジェクト: moelski/RaspberrySharp
        private void ToogleGPIO(ProcessorPin selectedGPIO)
        {
            OutputPinConfiguration _gpio = selectedGPIO.Output();

            try
            {
                if (_connectionGlobalPin == null)
                {
                    _connectionGlobalPin = new GpioConnection(_gpio);
                }

                if (!_connectionGlobalPin.Contains(_gpio))
                {
                    _connectionGlobalPin.Add(_gpio);
                }

                _connectionGlobalPin.Pins[_gpio].Enabled = !_connectionGlobalPin.Pins[_gpio].Enabled;
                CommonHelper.Logger.Info("GPIO {0}: enabled", _connectionGlobalPin.Pins[_gpio].Enabled);
            }
            catch (Exception e)
            {
                CommonHelper.Logger.Error(e, "GPIO Error : {0}", e.Message);
            }
        }