This repository was archived by the owner on Apr 10, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
Raspberry.IO.Components/Sensors/Temperature/Dht Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ public abstract class DhtConnection : IDisposable
29
29
private bool started ;
30
30
31
31
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"
33
33
34
34
#endregion
35
35
@@ -157,6 +157,16 @@ public void Close()
157
157
protected abstract TimeSpan DefaultSamplingInterval { get ; }
158
158
159
159
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 ; }
160
170
161
171
#endregion
162
172
@@ -180,6 +190,12 @@ private DhtData TryGetData()
180
190
pin . Write ( false ) ;
181
191
HighResolutionTimer . Sleep ( WakeupInterval ) ;
182
192
pin . Write ( true ) ;
193
+
194
+ if ( HaveHostReleaseBus )
195
+ {
196
+ HighResolutionTimer . Sleep ( HostReleaseBusInterval ) ;
197
+ pin . Write ( false ) ;
198
+ }
183
199
184
200
// Read acknowledgement from DHT
185
201
pin . Wait ( true , timeout ) ;
@@ -233,4 +249,4 @@ private DhtData TryGetData()
233
249
234
250
#endregion
235
251
}
236
- }
252
+ }
You can’t perform that action at this time.
0 commit comments