private float temp; // Temperature #endregion Fields #region Constructors // Instantiated via derived class protected DhtSensor(Cpu.Pin pin1, Cpu.Pin pin2, PullUpResistor pullUp) { var resistorMode = (Port.ResistorMode)pullUp; portIn = new InterruptPort(pin2, false, resistorMode, Port.InterruptMode.InterruptEdgeLow); portIn.OnInterrupt += new NativeEventHandler(portIn_OnInterrupt); portIn.DisableInterrupt(); // Enabled automatically in the previous call portOut = new TristatePort(pin1, true, false, resistorMode); if(!CheckPins()) { throw new InvalidOperationException("DHT sensor pins are not connected together."); } }
// Instantiated via derived class protected DhtSensor(Cpu.Pin pin1, Cpu.Pin pin2, PullUpResistor pullUp) { var resistorMode = (Port.ResistorMode)pullUp; portIn = new InterruptPort(pin2, false, resistorMode, Port.InterruptMode.InterruptEdgeLow); portIn.OnInterrupt += new NativeEventHandler(portIn_OnInterrupt); portIn.DisableInterrupt(); // Enabled automatically in the previous call portOut = new TristatePort(pin1, true, false, resistorMode); if (!CheckPins()) { throw new InvalidOperationException("DHT sensor pins are not connected together."); } }
/// <summary> /// Initialize a new instance of the <see cref="Dht22Sensor"/> class. /// </summary> /// <param name="pin1">The identifier for the sensor's data bus port.</param> /// <param name="pin2">The identifier for the sensor's data bus port.</param> /// <param name="pullUp">The pull-up resistor type.</param> /// <remarks> /// The ports identified by <paramref name="pin1"/> and <paramref name="pin2"/> /// must be wired together. /// </remarks> public Dht22Sensor(Cpu.Pin pin1, Cpu.Pin pin2, PullUpResistor pullUp) : base(pin1, pin2, pullUp) { // This constructor is intentionally left blank. }
/// <summary> /// Initialize a new instance of the <see cref="Dht22Sensor"/> class. /// </summary> /// <param name="pin1">The identifier for the sensor's data bus port.</param> /// <param name="pin2">The identifier for the sensor's data bus port.</param> /// <param name="pullUp">The pull-up resistor type.</param> /// <remarks> /// The ports identified by <paramref name="pin1"/> and <paramref name="pin2"/> /// must be wired together. /// </remarks> public Dht22Sensor(Cpu.Pin pin1, Cpu.Pin pin2, PullUpResistor pullUp) : base(pin1, pin2, pullUp) { // This constructor is intentionally left blank. }
/// <summary> /// Initialize a new instance of the <see cref="RHT03Sensor"/> class. /// </summary> /// <param name="pin1">The identifier for the sensor's data bus port.</param> /// <param name="pin2">The identifier for the sensor's data bus port.</param> /// <param name="pullUp">The pull-up resistor type.</param> /// <remarks> /// The ports identified by <paramref name="pin1"/> and <paramref name="pin2"/> /// must be wired together. /// </remarks> public RHT03Sensor(Cpu.Pin pin1, Cpu.Pin pin2, PullUpResistor pullUp) : base(pin1, pin2, pullUp) { }