|
1 |
| -# The MIT License (MIT) |
| 1 | +# SPDX-FileCopyrightText: 2017 Mike McWethy for Adafruit Industries |
2 | 2 | #
|
3 |
| -# Copyright (c) 2017 Mike McWethy for Adafruit Industries |
4 |
| -# |
5 |
| -# Permission is hereby granted, free of charge, to any person obtaining a copy |
6 |
| -# of this software and associated documentation files (the "Software"), to deal |
7 |
| -# in the Software without restriction, including without limitation the rights |
8 |
| -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
9 |
| -# copies of the Software, and to permit persons to whom the Software is |
10 |
| -# furnished to do so, subject to the following conditions: |
11 |
| -# |
12 |
| -# The above copyright notice and this permission notice shall be included in |
13 |
| -# all copies or substantial portions of the Software. |
14 |
| -# |
15 |
| -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
16 |
| -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
17 |
| -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
18 |
| -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
19 |
| -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
20 |
| -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
21 |
| -# THE SOFTWARE. |
| 3 | +# SPDX-License-Identifier: MIT |
| 4 | + |
22 | 5 | """
|
23 | 6 | :mod:`adafruit_dhtlib`
|
24 | 7 | ======================
|
|
47 | 30 |
|
48 | 31 |
|
49 | 32 | class DHTBase:
|
50 |
| - """ base support for DHT11 and DHT22 devices |
51 |
| - """ |
| 33 | + """base support for DHT11 and DHT22 devices""" |
52 | 34 |
|
53 | 35 | __hiLevel = 51
|
54 | 36 |
|
@@ -110,7 +92,7 @@ def _pulses_to_binary(self, pulses, start, stop):
|
110 | 92 | return binary
|
111 | 93 |
|
112 | 94 | def _get_pulses_pulseio(self):
|
113 |
| - """ _get_pulses implements the communication protcol for |
| 95 | + """_get_pulses implements the communication protcol for |
114 | 96 | DHT11 and DHT22 type devices. It sends a start signal
|
115 | 97 | of a specific length and listens and measures the
|
116 | 98 | return signal lengths.
|
@@ -138,7 +120,7 @@ def _get_pulses_pulseio(self):
|
138 | 120 | return pulses
|
139 | 121 |
|
140 | 122 | def _get_pulses_bitbang(self):
|
141 |
| - """ _get_pulses implements the communication protcol for |
| 123 | + """_get_pulses implements the communication protcol for |
142 | 124 | DHT11 and DHT22 type devices. It sends a start signal
|
143 | 125 | of a specific length and listens and measures the
|
144 | 126 | return signal lengths.
|
@@ -182,12 +164,12 @@ def _get_pulses_bitbang(self):
|
182 | 164 | return pulses
|
183 | 165 |
|
184 | 166 | def measure(self):
|
185 |
| - """ measure runs the communications to the DHT11/22 type device. |
186 |
| - if successful, the class properties temperature and humidity will |
187 |
| - return the reading returned from the device. |
| 167 | + """measure runs the communications to the DHT11/22 type device. |
| 168 | + if successful, the class properties temperature and humidity will |
| 169 | + return the reading returned from the device. |
188 | 170 |
|
189 |
| - Raises RuntimeError exception for checksum failure and for insuffcient |
190 |
| - data returned from the device (try again) |
| 171 | + Raises RuntimeError exception for checksum failure and for insuffcient |
| 172 | + data returned from the device (try again) |
191 | 173 | """
|
192 | 174 | delay_between_readings = 2 # 2 seconds per read according to datasheet
|
193 | 175 | # Initiate new reading if this is the first call or if sufficient delay
|
@@ -253,39 +235,39 @@ def measure(self):
|
253 | 235 |
|
254 | 236 | @property
|
255 | 237 | def temperature(self):
|
256 |
| - """ temperature current reading. It makes sure a reading is available |
| 238 | + """temperature current reading. It makes sure a reading is available |
257 | 239 |
|
258 |
| - Raises RuntimeError exception for checksum failure and for insuffcient |
259 |
| - data returned from the device (try again) |
| 240 | + Raises RuntimeError exception for checksum failure and for insuffcient |
| 241 | + data returned from the device (try again) |
260 | 242 | """
|
261 | 243 | self.measure()
|
262 | 244 | return self._temperature
|
263 | 245 |
|
264 | 246 | @property
|
265 | 247 | def humidity(self):
|
266 |
| - """ humidity current reading. It makes sure a reading is available |
| 248 | + """humidity current reading. It makes sure a reading is available |
267 | 249 |
|
268 |
| - Raises RuntimeError exception for checksum failure and for insuffcient |
269 |
| - data returned from the device (try again) |
| 250 | + Raises RuntimeError exception for checksum failure and for insuffcient |
| 251 | + data returned from the device (try again) |
270 | 252 | """
|
271 | 253 | self.measure()
|
272 | 254 | return self._humidity
|
273 | 255 |
|
274 | 256 |
|
275 | 257 | class DHT11(DHTBase):
|
276 |
| - """ Support for DHT11 device. |
| 258 | + """Support for DHT11 device. |
277 | 259 |
|
278 |
| - :param ~board.Pin pin: digital pin used for communication |
| 260 | + :param ~board.Pin pin: digital pin used for communication |
279 | 261 | """
|
280 | 262 |
|
281 | 263 | def __init__(self, pin, use_pulseio=_USE_PULSEIO):
|
282 | 264 | super().__init__(True, pin, 18000, use_pulseio)
|
283 | 265 |
|
284 | 266 |
|
285 | 267 | class DHT22(DHTBase):
|
286 |
| - """ Support for DHT22 device. |
| 268 | + """Support for DHT22 device. |
287 | 269 |
|
288 |
| - :param ~board.Pin pin: digital pin used for communication |
| 270 | + :param ~board.Pin pin: digital pin used for communication |
289 | 271 | """
|
290 | 272 |
|
291 | 273 | def __init__(self, pin, use_pulseio=_USE_PULSEIO):
|
|
0 commit comments