示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GpioConnection"/> class.
        /// </summary>
        /// <param name="settings">The settings.</param>
        /// <param name="pins">The pins.</param>
        public GpioConnection(GpioConnectionSettings settings, IEnumerable <PinConfiguration> pins)
        {
            this.settings = settings ?? new GpioConnectionSettings();
            Pins          = new ConnectedPins(this);

            var pinList = pins.ToList();

            pinConfigurations = pinList.ToDictionary(p => p.Pin);

            namedPins = pinList.Where(p => !string.IsNullOrEmpty(p.Name)).ToDictionary(p => p.Name);

            timer = Timer.Create();

            timer.Interval = this.settings.PollInterval;
            timer.Action   = CheckInputPins;

            if (this.settings.Opened)
            {
                Open();
            }
        }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GpioConnection"/> class.
 /// </summary>
 /// <param name="settings">The settings.</param>
 /// <param name="pins">The pins.</param>
 public GpioConnection(GpioConnectionSettings settings, params PinConfiguration[] pins) : this(settings, (IEnumerable <PinConfiguration>)pins)
 {
 }