File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# DHT11/DHT22 driver for MicroPython on ESP8266
22# MIT license; Copyright (c) 2016 Damien P. George
33
4- import esp
4+ try :
5+ from esp import dht_readinto
6+ except :
7+ from pyb import dht_readinto
58
69class DHTBase :
710 def __init__ (self , pin ):
@@ -10,7 +13,7 @@ def __init__(self, pin):
1013
1114 def measure (self ):
1215 buf = self .buf
13- esp . dht_readinto (self .pin , buf )
16+ dht_readinto (self .pin , buf )
1417 if (buf [0 ] + buf [1 ] + buf [2 ] + buf [3 ]) & 0xff != buf [4 ]:
1518 raise Exception ("checksum error" )
1619
Original file line number Diff line number Diff line change @@ -186,6 +186,7 @@ EXTMOD_SRC_C = $(addprefix extmod/,\
186186
187187DRIVERS_SRC_C = $(addprefix drivers/,\
188188 memory/spiflash.c \
189+ dht/dht.c \
189190 )
190191
191192SRC_C = \
Original file line number Diff line number Diff line change 3434#include "lib/utils/pyexec.h"
3535#include "lib/oofatfs/ff.h"
3636#include "lib/oofatfs/diskio.h"
37+ #include "drivers/dht/dht.h"
3738#include "gccollect.h"
3839#include "stm32_it.h"
3940#include "irq.h"
@@ -168,6 +169,9 @@ STATIC const mp_rom_map_elem_t pyb_module_globals_table[] = {
168169 { MP_ROM_QSTR (MP_QSTR_sync ), MP_ROM_PTR (& mod_os_sync_obj ) },
169170 { MP_ROM_QSTR (MP_QSTR_mount ), MP_ROM_PTR (& mp_vfs_mount_obj ) },
170171
172+ // This function is not intended to be public and may be moved elsewhere
173+ { MP_ROM_QSTR (MP_QSTR_dht_readinto ), MP_ROM_PTR (& dht_readinto_obj ) },
174+
171175 { MP_ROM_QSTR (MP_QSTR_Timer ), MP_ROM_PTR (& pyb_timer_type ) },
172176
173177#if MICROPY_HW_ENABLE_RNG
Original file line number Diff line number Diff line change 1+ ../ ../ ../ drivers / dht / dht .py
You can’t perform that action at this time.
0 commit comments