logo elektroda
logo elektroda
X
logo elektroda

Passing #define values to a custom library in PlatformIO, Arduino ESP32

xury 441 2
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 20202561
    xury
    Automation specialist
    I have, for example, in the file main.cpp declared the definition of

    #define CHRGDETECT GPIO_NUM_35

    Now I have my own library and I would like the declared value not to have to be duplicated in it as well. How do I do this?

    ESP32 arduino platform environment
  • ADVERTISEMENT
  • #2 20202598
    LightOfWinter
    Level 38  
    Hello

    Put #define CHRGDETECT GPIO_NUM_35 into a *.h file and attach this file to the *.cpp file where the definition is needed.
  • #3 20202669
    ex-or
    Level 28  
    The symbol to be globally visible can be passed with the compiler call parameter. For gcc this is -D
    Code: Bash
    Log in, to see the code
    .
ADVERTISEMENT