RobTillaart / DHTNew

Arduino library for DHT11 and DHT22 with automatic sensor recognition
MIT License
99 stars 15 forks source link

consider an enhancement to be able to compile this lib directly under espressif/platformio without Arduino layer #91

Closed pabloandresm closed 1 year ago

pabloandresm commented 1 year ago

Title says it all. It would be nice.

As the library only uses pinMode() and digitalWrite(), a wrapper for those for ESP32 are pretty much straightforward:

They can even be taken from the Arduino/ESP32 libs at hardware/esp32/2.0.7/cores/esp32/esp32-hal-gpio.c

Then a modification in the library.json for the "frameworks":"*" et voila! :)

RobTillaart commented 1 year ago

Thanks for the issue,

I do not use platformIO and ESP32 only seldom. I'm on the 1.0.6 version for ESP32 under IDE1.8.19

do you think of wrappers like

inline void PM(pin, mode)
{
#ifdef ESP32
__pinMode(pin, mode)
#else
pinMode(pin, mode)
#endif
}

inline void DW(pin, value)
{
#ifdef ESP32
__digitalWrite(pin, mode)
#else
digitalWrite(pin, mode)
#endif
}

inline uint8_t DR(pin)
{
#ifdef ESP32
return __digitalRead(pin)
#else
return digitalRead(pin)
#endif
}

Is it possible for you to create a PR?

pabloandresm commented 1 year ago

Hi Rob for your answer.

I was thinking more of something like:

ifdef esp-idf, and not arduino pinMode() { } digitalWrite() { } endif

So the code is not touched at all.

I already compiled your lib for espressif only. Let me clean my code up and prepare a proper PR.

RobTillaart commented 1 year ago

OK, I will see the PR when it is ready

pabloandresm commented 1 year ago

Sorry for the delay Rob. Busy month. I already did the code. As soon as I clean it I'll generate the PR.

Thank you