8000 dht: Change the sequence for importing dht_readinto. · micropython/micropython-lib@0e25b10 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0e25b10

Browse files
robert-hhdpgeorge
authored andcommitted
dht: Change the sequence for importing dht_readinto.
Check the machine module first, then search in previous places. This supports having machine.dht_readinto as the new standard, while still being backwards compatible.
1 parent 900dd1c commit 0e25b10

File tree

1 file changed

+7
-8
lines changed
  • micropython/drivers/sensor/dht

1 file changed

+7
-8
lines changed

micropython/drivers/sensor/dht/dht.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@
22
# MIT license; Copyright (c) 2016 Damien P. George
33

44
import sys
5+
import machine
56

6-
if sys.platform.startswith("esp"):
7+
if hasattr(machine, "dht_readinto"):
8+
from machine import dht_readinto
9+
elif sys.platform.startswith("esp"):
710
from esp import dht_readinto
8-
elif sys.platform == "mimxrt":
9-
from mimxrt import dht_readinto
10-
elif sys.platform == "rp2":
11-
from rp2 import dht_readinto
12-
elif sys.platform == "pyboard":
13-
from pyb import dht_readinto
1411
else:
15-
from machine import dht_readinto
12+
dht_readinto = __import__(sys.platform).dht_readinto
13+
14+
del machine
1615

1716

1817
class DHTBase:

0 commit comments

Comments
 (0)
0