#define xyz vs -Dxyz

I’m at a project with an esp32 using a touch tft display an sd-card and gps module.

The platformio.ini is this:

[platformio]
name =
description =

[env]
platform = espressif32
board = esp32doit-devkit-v1
framework = arduino
lib_deps = 
	mikalhart/TinyGPSPlus @ ^1.1.0
	
monitor_speed = 115200
upload_port = COM8

[env:build]
build_type = release

build_flags =
    -D AZD_2P4TFT_COLDISP
    -Wfatal-errors
;    -v

[env:debug]
build_type = debug

build_flags = 
    -D CORE_DEBUG_LEVEL=5
    -D DEBUG_LEVEL=3
    -Og
    -g2
    -D DEBUG
    -D AZD_2P4TFT_COLDISP
;	-D TOUCH_CS
    -Wfatal-errors
;    -v

debug_tool = esp-prog
debug_init_break = tbreak setup

The includes in the main.cpp are:

#include <Arduino.h>
#include "HW_DEV-Kit_V1.h"
#include <TFT_eSPI.h>
#include "main.h"

The include-files in <> are at the standard location of all standard libraries of
platformio and the include-files in “” are in the lib folder of the project.

As I want to have the definition of all pins of my used board in one file I use the header file “HW_DEV-Kit_V1.h”. There is the definition of “TOUCH_CS”.

When I compile i get the error:

In file included from C:/Users/heinz/.platformio/packages/framework-arduinoespressif32/libraries/myTFT_eSPI/TFT_eSPI.cpp:16:
C:/Users/heinz/.platformio/packages/framework-arduinoespressif32/libraries/myTFT_eSPI/TFT_eSPI.h:973:8: warning: #warning >>>>------>> TOUCH_CS pin not defined, TFT_eSPI touch functions will not be available! [-Wcpp]
       #warning >>>>------>> TOUCH_CS pin not defined, TFT_eSPI touch functions will not be available!
        ^~~~~~~

If anybody could give an advise I would be happy.

Your “HW_DEV-Kit_V1.h” will not be included by TFT_eSPI.
How should the library know about this?

Use the build_flags in the platformio.ini.
A detailed description for TFT_eSPI can be found here: TFT_eSPI/docs/PlatformIO/Configuring options.txt at master · Bodmer/TFT_eSPI · GitHub

The defines in the build_flag section are project- / environment-wide available to your source files.

Thank you sivar2311. I thought the ‘#defines’ are global definitions for all other included files. As you can see I have already tested if it would work adding it to the ini filed.