ESP32 and tft_espi compile errors

I’m new to platformio, and I’ve been going in circles here trying to compile an example sketch (TFT_Matrix) from the tft_espi library. Adafruit GFX is installed with all dependencies, but I’m getting errors about missing files:

Processing lolin_d32_pro (platform: espressif32; board: lolin_d32_pro; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/lolin_d32_pro.html
PLATFORM: Espressif 32 (6.1.0) > WEMOS LOLIN D32 PRO
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 @ 3.20007.0 (2.0.7)
 - tool-esptoolpy @ 1.40500.0 (4.5.0)
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 36 compatible libraries
Scanning dependencies...
Dependency Graph
|-- TFT_eSPI @ 2.5.31
|-- Adafruit GFX Library @ 1.11.7
|-- SPI @ 2.0.0
Building in release mode
Compiling .pio\build\lolin_d32_pro\src\main.cpp.o
Building .pio\build\lolin_d32_pro\bootloader.bin
Generating partitions .pio\build\lolin_d32_pro\partitions.bin
esptool.py v4.5
Creating esp32 image...
Merged 1 ELF section
Successfully created esp32 image.
Compiling .pio\build\lolin_d32_pro\lib981\SPI\SPI.cpp.o
Compiling .pio\build\lolin_d32_pro\libd4e\FS\FS.cpp.o
Compiling .pio\build\lolin_d32_pro\libd4e\FS\vfs_api.cpp.o
Compiling .pio\build\lolin_d32_pro\lib448\SPIFFS\SPIFFS.cpp.o
Compiling .pio\build\lolin_d32_pro\liba03\LittleFS\LittleFS.cpp.o
Archiving .pio\build\lolin_d32_pro\lib981\libSPI.a
Compiling .pio\build\lolin_d32_pro\libd98\TFT_eSPI\TFT_eSPI.cpp.o
Compiling .pio\build\lolin_d32_pro\lib16f\Adafruit GFX Library\Adafruit_GFX.cpp.o
Compiling .pio\build\lolin_d32_pro\lib16f\Adafruit GFX Library\Adafruit_GrayOLED.cpp.o
In file included from src/main.cpp:18:
.pio/libdeps/lolin_d32_pro/TFT_eSPI/TFT_eSPI.h:975: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!
        ^~~~~~~
src/main.cpp: In function 'void setup()':
src/main.cpp:39:3: error: 'setupScrollArea' was not declared in this scope
   setupScrollArea(TOP_FIXED_AREA, BOT_FIXED_AREA);
   ^~~~~~~~~~~~~~~
src/main.cpp: In function 'void loop()':
src/main.cpp:53:13: error: 'scroll_slow' was not declared in this scope
     yDraw = scroll_slow(TEXT_HEIGHT, 14); // Scroll, 14ms per pixel line
             ^~~~~~~~~~~
src/main.cpp:53:13: note: suggested alternative: 'strcoll_l'
     yDraw = scroll_slow(TEXT_HEIGHT, 14); // Scroll, 14ms per pixel line
             ^~~~~~~~~~~
             strcoll_l
src/main.cpp:63:31: error: 'scroll_slow' was not declared in this scope
   while (1) {yield(); yDraw = scroll_slow(320,5); }// Scroll 320 lines, 5ms per line
                               ^~~~~~~~~~~
src/main.cpp:63:31: note: suggested alternative: 'strcoll_l'
   while (1) {yield(); yDraw = scroll_slow(320,5); }// Scroll 320 lines, 5ms per line
                               ^~~~~~~~~~~
                               strcoll_l
src/main.cpp: In function 'int scroll_slow(int, int)':
src/main.cpp:82:5: error: 'scrollAddress' was not declared in this scope
     scrollAddress(yStart);
     ^~~~~~~~~~~~~
src/main.cpp:82:5: note: suggested alternative: 'IPAddress'
     scrollAddress(yStart);
     ^~~~~~~~~~~~~
     IPAddress
*** [.pio\build\lolin_d32_pro\src\main.cpp.o] Error 1
In file included from .pio/libdeps/lolin_d32_pro/Adafruit GFX Library/Adafruit_GrayOLED.h:29,
                 from .pio/libdeps/lolin_d32_pro/Adafruit GFX Library/Adafruit_GrayOLED.cpp:20:
.pio/libdeps/lolin_d32_pro/Adafruit GFX Library/Adafruit_GFX.h:12:10: fatal error: Adafruit_I2CDevice.h: No such file or directory        

****************************************************************************
* Looking for Adafruit_I2CDevice.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:Adafruit_I2CDevice.h"
* Web  > https://registry.platformio.org/search?q=header:Adafruit_I2CDevice.h
*
****************************************************************************

 #include <Adafruit_I2CDevice.h>
          ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
In file included from .pio/libdeps/lolin_d32_pro/Adafruit GFX Library/Adafruit_GFX.cpp:34:
.pio/libdeps/lolin_d32_pro/Adafruit GFX Library/Adafruit_GFX.h:12:10: fatal error: Adafruit_I2CDevice.h: No such file or directory        

****************************************************************************
* Looking for Adafruit_I2CDevice.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:Adafruit_I2CDevice.h"
* Web  > https://registry.platformio.org/search?q=header:Adafruit_I2CDevice.h
*
****************************************************************************

 #include <Adafruit_I2CDevice.h>
          ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
*** [.pio\build\lolin_d32_pro\lib16f\Adafruit GFX Library\Adafruit_GrayOLED.cpp.o] Error 1
*** [.pio\build\lolin_d32_pro\lib16f\Adafruit GFX Library\Adafruit_GFX.cpp.o] Error 1
In file included from .pio/libdeps/lolin_d32_pro/TFT_eSPI/TFT_eSPI.cpp:16:
.pio/libdeps/lolin_d32_pro/TFT_eSPI/TFT_eSPI.h:975: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!
        ^~~~~~~
====================================================== [FAILED] Took 59.32 seconds ======================================================

You’re using the contents of an .ino sketch as a .cpp file without doing the necessary conversion. If you want the least amount of work and you just want to check out whether the sketch works, rename src/main.cppsrc/main.ino and press build again. If you want to develop your code based on that sketch, I’d heavily recommend staying with .cpp and doing the above conversion.

Thanks for the link. I’ve added the arduino include and renamed the file, but I haven’t added any function declarations. So for every declaration error I have to add an empty function declaration? How do I add a function with two parameters? This didn’t work:
void setupScrollArea(int num, int num);

Sorry, stupid question there… I’ve been away from C for a while. I found the functions in the library and added:

void setupScrollArea(uint16_t, uint16_t);

int scroll_slow(int, int);

void scrollAddress(uint16_t);

Moreover, I had to add Adafruit BusIO library and Wire.

1 Like