stm32: Add support for DHT11/DHT22 sensors.

pull/3572/merge
Damien George 2018-01-31 18:12:53 +11:00
rodzic a40ce1d829
commit efdda2c62d
4 zmienionych plików z 11 dodań i 2 usunięć

Wyświetl plik

@ -1,7 +1,10 @@
# DHT11/DHT22 driver for MicroPython on ESP8266
# MIT license; Copyright (c) 2016 Damien P. George
import esp
try:
from esp import dht_readinto
except:
from pyb import dht_readinto
class DHTBase:
def __init__(self, pin):
@ -10,7 +13,7 @@ class DHTBase:
def measure(self):
buf = self.buf
esp.dht_readinto(self.pin, buf)
dht_readinto(self.pin, buf)
if (buf[0] + buf[1] + buf[2] + buf[3]) & 0xff != buf[4]:
raise Exception("checksum error")

Wyświetl plik

@ -186,6 +186,7 @@ EXTMOD_SRC_C = $(addprefix extmod/,\
DRIVERS_SRC_C = $(addprefix drivers/,\
memory/spiflash.c \
dht/dht.c \
)
SRC_C = \

Wyświetl plik

@ -34,6 +34,7 @@
#include "lib/utils/pyexec.h"
#include "lib/oofatfs/ff.h"
#include "lib/oofatfs/diskio.h"
#include "drivers/dht/dht.h"
#include "gccollect.h"
#include "stm32_it.h"
#include "irq.h"
@ -168,6 +169,9 @@ STATIC const mp_rom_map_elem_t pyb_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_sync), MP_ROM_PTR(&mod_os_sync_obj) },
{ MP_ROM_QSTR(MP_QSTR_mount), MP_ROM_PTR(&mp_vfs_mount_obj) },
// This function is not intended to be public and may be moved elsewhere
{ MP_ROM_QSTR(MP_QSTR_dht_readinto), MP_ROM_PTR(&dht_readinto_obj) },
{ MP_ROM_QSTR(MP_QSTR_Timer), MP_ROM_PTR(&pyb_timer_type) },
#if MICROPY_HW_ENABLE_RNG

Wyświetl plik

@ -0,0 +1 @@
../../../drivers/dht/dht.py