Add ESP32 DHT support

Add ESP32 DHT support (#8503)
This commit is contained in:
Theo Arends 2020-06-24 15:36:54 +02:00
parent 81d2527ff6
commit f4adce5fb1
2 changed files with 5 additions and 3 deletions

View File

@ -372,8 +372,10 @@ const char kWebColors[] PROGMEM =
#ifdef ESP8266
#define AGPIO(x) (x)
#define BGPIO(x) (x)
#else // ESP32
#define AGPIO(x) (x<<5)
#define BGPIO(x) (x>>5)
#endif // ESP8266 - ESP32
#ifdef USE_DEVICE_GROUPS

View File

@ -188,12 +188,12 @@ bool DhtRead(uint32_t sensor)
bool DhtPinState()
{
if ((XdrvMailbox.index >= GPIO_DHT11) && (XdrvMailbox.index <= GPIO_SI7021)) {
if ((XdrvMailbox.index >= AGPIO(GPIO_DHT11)) && (XdrvMailbox.index <= AGPIO(GPIO_SI7021))) {
if (dht_sensors < DHT_MAX_SENSORS) {
Dht[dht_sensors].pin = XdrvMailbox.payload;
Dht[dht_sensors].type = XdrvMailbox.index;
Dht[dht_sensors].type = BGPIO(XdrvMailbox.index);
dht_sensors++;
XdrvMailbox.index = GPIO_DHT11;
XdrvMailbox.index = AGPIO(GPIO_DHT11);
} else {
XdrvMailbox.index = 0;
}