Skip to content
This repository was archived by the owner on Apr 10, 2020. It is now read-only.

Commit 53159dd

Browse files
authored
Merge pull request #3 from lucagraziani82/patch-1
Update DhtConnection.cs
2 parents e90ec57 + 769df7d commit 53159dd

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

Raspberry.IO.Components/Sensors/Temperature/Dht/DhtConnection.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public abstract class DhtConnection : IDisposable
2929
private bool started;
3030

3131
private static readonly TimeSpan timeout = TimeSpan.FromMilliseconds(100);
32-
private static readonly TimeSpan bitSetUptime = new TimeSpan(10 * (26 +70) / 2); // 26µs for "0", 70µs for "1"
32+
private static readonly TimeSpan bitSetUptime = new TimeSpan(10 * 50); // 26µs -> 50 for "0", 50 -> 70µs for "1"
3333

3434
#endregion
3535

@@ -157,6 +157,16 @@ public void Close()
157157
protected abstract TimeSpan DefaultSamplingInterval { get; }
158158

159159
protected abstract TimeSpan WakeupInterval { get; }
160+
161+
/// <summary>
162+
/// Time that host use before pull down and wait for response
163+
/// </summary>
164+
protected abstract TimeSpan HostReleaseBusInterval { get; }
165+
166+
/// <summary>
167+
/// If true host have a release bus that use before acquiring data
168+
/// </summary>
169+
protected abstract bool HaveHostReleaseBus { get; }
160170

161171
#endregion
162172

@@ -180,6 +190,12 @@ private DhtData TryGetData()
180190
pin.Write(false);
181191
HighResolutionTimer.Sleep(WakeupInterval);
182192
pin.Write(true);
193+
194+
if(HaveHostReleaseBus)
195+
{
196+
HighResolutionTimer.Sleep(HostReleaseBusInterval);
197+
pin.Write(false);
198+
}
183199

184200
// Read acknowledgement from DHT
185201
pin.Wait(true, timeout);
@@ -233,4 +249,4 @@ private DhtData TryGetData()
233249

234250
#endregion
235251
}
236-
}
252+
}

0 commit comments

Comments
 (0)