/// <summary> /// Initializes a new instance of the <see cref="TemperatureSensorAM2302" /> class. /// </summary> /// <param name="dataPin">The data pin. Must be a GPIO-only pin on the P1 Header of the Pi.</param> /// <exception cref="ArgumentException">dataPin When it is invalid.</exception> public TemperatureSensorAM2302(IGpioPin dataPin) { if (AllowedPins.Contains(dataPin) == false) { throw new ArgumentException($"{nameof(dataPin)}, {dataPin} is not available to service this driver."); } DataPin = dataPin; ReadWorker = new Thread(PerformContinuousReads); }
/// <summary> /// Initializes a new instance of the <see cref="DhtSensor" /> class. /// </summary> /// <param name="dataPin">The data pin. Must be a GPIO-only pin on the P1 Header of the Pi.</param> /// <exception cref="ArgumentException">dataPin When it is invalid.</exception> protected DhtSensor(IGpioPin dataPin) { if (!AllowedPins.Contains(dataPin)) { throw new ArgumentException($"{nameof(dataPin)}, {dataPin} is not available to service this driver."); } _dataPin = dataPin; _readTimer = new Timer(PerformContinuousReads, null, Timeout.Infinite, Timeout.Infinite); }
/// <summary> /// Initializes a new instance of the <see cref="UltrasonicHcsr04"/> class. /// </summary> /// <param name="triggerPin">The trigger pin.</param> /// <param name="echoPin">The echo pin.</param> /// <exception cref="ArgumentException">When it is provided invalid trigger or echo pins.</exception> public UltrasonicHcsr04(IGpioPin triggerPin, IGpioPin echoPin) { if (AllowedPins.Contains(triggerPin) == false) { throw new ArgumentException($"{nameof(triggerPin)}, {triggerPin} is not available to service this driver."); } if (AllowedPins.Contains(echoPin) == false) { throw new ArgumentException($"{nameof(echoPin)}, {echoPin} is not available to service this driver."); } _triggerPin = triggerPin; _echoPin = echoPin; _readWorker = new Thread(PerformContinuousReads); }
/// <summary> /// Initializes a new instance of the <see cref="TemperatureSensorAM2302" /> class. /// </summary> /// <param name="dataPin">The data pin. Must be a GPIO-only pin on the P1 Header of the Pi</param> /// <exception cref="ArgumentException">dataPin When it is invalid</exception> public TemperatureSensorAM2302(GpioPin dataPin) { if (AllowedPins.Contains(dataPin) == false) { throw new ArgumentException($"{nameof(dataPin)}, {dataPin} is not available to service this driver."); } _systemTiming = Timing.Instance; DataPin = dataPin; ReadWorker = new Thread(PerformContinuousReads) { IsBackground = true, Name = nameof(TemperatureSensorAM2302), Priority = ThreadPriority.AboveNormal }; }