示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GroveBarDevice"/> class.
 /// </summary>
 /// <param name="dataPin">The data pin.</param>
 /// <param name="clockPin">The clock pin.</param>
 /// <param name="threadFactory">The thread factory.</param>
 public GroveBarDevice(IOutputBinaryPin dataPin, IInputOutputBinaryPin clockPin, IThreadFactory threadFactory = null)
 {
     this.dataPin  = dataPin;
     this.clockPin = clockPin;
     this.thread   = ThreadFactory.EnsureThreadFactory(threadFactory).Create();
     this.Initialize();
 }
示例#2
0
        public DhtConnection(IInputOutputBinaryPin pin)
        {
            this.pin = pin;

            pin.Write(true);
            Timer.Sleep(100);
        }
        public DhtConnection(IInputOutputBinaryPin pin)
        {
            this.pin = pin;

            pin.Write(true);
            Timer.Sleep(100);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DhtConnection" /> class.
        /// </summary>
        /// <param name="pin">The pin.</param>
        /// <param name="autoStart">if set to <c>true</c>, DHT is automatically started. Default value is <c>true</c>.</param>
        protected DhtConnection(IInputOutputBinaryPin pin, bool autoStart = true)
        {
            this.pin = pin;

            if (autoStart)
                Start();
            else
                Stop();
        }
        private static readonly TimeSpan bitSetUptime = new TimeSpan(10 * (26 + 70) / 2); // 26µs for "0", 70µs for "1"

        #endregion

        #region Instance Management

        /// <summary>
        /// Initializes a new instance of the <see cref="DhtConnection" /> class.
        /// </summary>
        /// <param name="pin">The pin.</param>
        /// <param name="autoStart">if set to <c>true</c>, DHT is automatically started. Default value is <c>true</c>.</param>
        protected DhtConnection(IInputOutputBinaryPin pin, bool autoStart = true)
        {
            this.pin = pin;

            if (autoStart)
            {
                Start();
            }
            else
            {
                Stop();
            }
        }
示例#6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DhtDevice" /> class.
        /// </summary>
        /// <param name="pin">The pin.</param>
        /// <param name="autoStart">if set to <c>true</c>, DHT is automatically started. Default value is <c>true</c>.</param>
        /// <param name="threadFactory">The thread factory.</param>
        /// <param name="dhtDeviceReporter">The DHT device reporter.</param>
        protected DhtDevice(IInputOutputBinaryPin pin, bool autoStart = true, IThreadFactory threadFactory = null, IDhtDeviceReporter dhtDeviceReporter = null)
        {
            this.thread            = ThreadFactory.EnsureThreadFactory(threadFactory).Create();
            this.pin               = pin;
            this.dhtDeviceReporter = dhtDeviceReporter;

            if (autoStart)
            {
                this.Start();
            }
            else
            {
                this.Stop();
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DhtConnection" /> class.
        /// </summary>
        /// <param name="serviceProvider">IServiceProvider</param>
        /// <param name="pin">The pin.</param>
        /// <param name="autoStart">if set to <c>true</c>, DHT is automatically started. Default value is <c>true</c>.</param>
        protected DhtConnection(IServiceProvider serviceProvider, IInputOutputBinaryPin pin, bool autoStart = true)
        {
            log = serviceProvider.GetRequiredService <ILogger <DhtConnection> >();

            this.pin = pin;

            if (autoStart)
            {
                Start();
            }
            else
            {
                Stop();
            }
        }
示例#8
0
        public GPIO(ConnectorPin pin, PinDirection direction)
        {
            //_gpioDriver = new FileGpioConnectionDriver();
            _gpioDriver = new MemoryGpioConnectionDriver();
            _gpioDriver.InOut(pin);

            _syncRoot   = _gpioDriver;
            _pin        = pin;
            _connection = _gpioDriver.InOut(pin);

            if (direction == PinDirection.Input)
            {
                _connection.AsInput();
            }
            else
            {
                _connection.AsOutput();
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DhtConnection" /> class.
 /// </summary>
 /// <param name="pin">The pin.</param>
 /// <param name="autoStart">if set to <c>true</c>, DHT is automatically started. Default value is <c>true</c>.</param>
 public Dht22Connection(IInputOutputBinaryPin pin, bool autoStart = true)
     : base(pin, autoStart)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DhtConnection" /> class.
 /// </summary>
 /// <param name="pin">The pin.</param>
 /// <param name="autoStart">if set to <c>true</c>, DHT is automatically started. Default value is <c>true</c>.</param>
 public Dht22Connection(IInputOutputBinaryPin pin, bool autoStart = true) : base(pin, autoStart)
 {
 }
 public GroveBarConnection(IOutputBinaryPin dataPin, IInputOutputBinaryPin clockPin)
 {
     this.dataPin = dataPin;
     this.clockPin = clockPin;
     Initialize();
 }
示例#12
0
        public ConnectorPin ConnectorPinDetector(int PinNumber)//gets number of the port from user and assigns real port
        {
            //3 5 7 8  10 11 12 13 15 16 18 19 21 22 23 24 26 27 28 29 31 32 33 35 36 37 38 40 its phisical location
            ConnectorPin pin = ConnectorPin.P1Pin3;

            switch (this.PinNumber)
            {
            case 3:
                pin = ConnectorPin.P1Pin3;
                break;

            case 5:
                pin = ConnectorPin.P1Pin5;
                break;

            case 7:
                pin = ConnectorPin.P1Pin7;
                break;

            case 8:
                pin = ConnectorPin.P1Pin8;
                break;

            case 10:
                pin = ConnectorPin.P1Pin10;
                break;

            case 11:
                pin = ConnectorPin.P1Pin11;
                break;

            case 12:
                pin = ConnectorPin.P1Pin12;
                break;

            case 13:
                pin = ConnectorPin.P1Pin13;
                break;

            case 15:
                pin = ConnectorPin.P1Pin15;
                break;

            case 16:
                pin = ConnectorPin.P1Pin16;
                break;

            case 18:
                pin = ConnectorPin.P1Pin18;
                break;

            case 19:
                pin = ConnectorPin.P1Pin19;
                break;

            case 21:
                pin = ConnectorPin.P1Pin21;
                break;

            case 22:
                pin = ConnectorPin.P1Pin22;
                break;

            case 23:
                pin = ConnectorPin.P1Pin23;
                break;

            case 24:
                pin = ConnectorPin.P1Pin24;
                break;

            case 26:
                pin = ConnectorPin.P1Pin26;
                break;

            case 27:
                pin = ConnectorPin.P1Pin27;
                break;

            case 28:
                pin = ConnectorPin.P1Pin28;
                break;

            case 29:
                pin = ConnectorPin.P1Pin29;
                break;

            case 31:
                pin = ConnectorPin.P1Pin31;
                break;

            case 32:
                pin = ConnectorPin.P1Pin32;
                break;

            case 33:
                pin = ConnectorPin.P1Pin33;
                break;

            case 35:
                pin = ConnectorPin.P1Pin35;
                break;

            case 36:
                pin = ConnectorPin.P1Pin36;
                break;

            case 37:
                pin = ConnectorPin.P1Pin37;
                break;

            case 38:
                pin = ConnectorPin.P1Pin38;
                break;

            case 40:
                pin = ConnectorPin.P1Pin40;
                break;
            }
            return(pin);
        }
示例#13
0
 public GroveBarConnection(IOutputBinaryPin dataPin, IInputOutputBinaryPin clockPin)
 {
     this.dataPin  = dataPin;
     this.clockPin = clockPin;
     Initialize();
 }
示例#14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DhtConnection" /> class.
 /// </summary>
 /// <param name="serviceProvider">IServiceProvider</param>
 /// <param name="pin">The pin.</param>
 /// <param name="autoStart">if set to <c>true</c>, DHT is automatically started. Default value is <c>true</c>.</param>
 public Dht22Connection(IServiceProvider serviceProvider, IInputOutputBinaryPin pin, bool autoStart = true) : base(serviceProvider, pin, autoStart)
 {
 }
示例#15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Dht22Device" /> class.
 /// </summary>
 /// <param name="pin">The pin.</param>
 /// <param name="autoStart">if set to <c>true</c> [automatic start].</param>
 /// <param name="threadFactory">The thread factory.</param>
 /// <param name="dhtDeviceReporter">The DHT device reporter.</param>
 public Dht22Device(IInputOutputBinaryPin pin, bool autoStart = true, IThreadFactory threadFactory = null, IDhtDeviceReporter dhtDeviceReporter = null)
     : base(pin, autoStart, threadFactory, dhtDeviceReporter)
 {
 }