Bodmer / TFT_eSPI

Arduino and PlatformIO IDE compatible TFT library optimised for the Raspberry Pi Pico (RP2040), STM32, ESP8266 and ESP32 that supports different driver chips
Other
3.54k stars 1.02k forks source link

ESP-IDF gives the error "GPIO was not declared in this scope" when compiling with ESP-IDF v5.1 #2628

Open devrim-oguz opened 1 year ago

devrim-oguz commented 1 year ago

Hello, thank you for creating this library.

I've been using this library with ESP-IDF v4.4 in a project for a while. But when I upgrade to the ESP-IDF version v5.1, the compilation gives the following errors:

/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.c: In member function 'uint8_t TFT_eSPI::readByte()':
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.h:446:20: error: 'GPIO' was not declared in this scope
  446 |       #define RD_L GPIO.out_w1tc = (1 << TFT_RD)
      |                    ^~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.c:98:3: note: in expansion of macro 'RD_L'
   98 |   RD_L;
      |   ^~~~
In file included from /home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/TFT_eSPI.cpp:20:
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.c:100:9: error: 'gpio_input_get' was not declared in this scope; did you mean 'gpio_num_t'?
  100 |   reg = gpio_input_get(); // Read three times to allow for bus access time
      |         ^~~~~~~~~~~~~~
      |         gpio_num_t
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.c: In member function 'void TFT_eSPI::pushBlock(uint16_t, uint32_t)':
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.h:412:31: error: 'GPIO' was not declared in this scope
  412 |       #define tft_Write_16(C) GPIO.out_w1tc = GPIO_OUT_CLR_MASK; GPIO.out_w1ts = set_mask((uint8_t) ((C) >> 8)); WR_H; \
      |                               ^~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.c:547:5: note: in expansion of macro 'tft_Write_16'
  547 |     tft_Write_16(color);
      |     ^~~~~~~~~~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.h:412:31: error: 'GPIO' was not declared in this scope
  412 |       #define tft_Write_16(C) GPIO.out_w1tc = GPIO_OUT_CLR_MASK; GPIO.out_w1ts = set_mask((uint8_t) ((C) >> 8)); WR_H; \
      |                               ^~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.c:558:23: note: in expansion of macro 'tft_Write_16'
  558 |   else while (len--) {tft_Write_16(color);}
      |                       ^~~~~~~~~~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.c: In member function 'void TFT_eSPI::pushSwapBytePixels(const void*, uint32_t)':
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.h:412:31: error: 'GPIO' was not declared in this scope
  412 |       #define tft_Write_16(C) GPIO.out_w1tc = GPIO_OUT_CLR_MASK; GPIO.out_w1ts = set_mask((uint8_t) ((C) >> 8)); WR_H; \
      |                               ^~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.c:568:20: note: in expansion of macro 'tft_Write_16'
  568 |   while ( len-- ) {tft_Write_16(*data); data++;}
      |                    ^~~~~~~~~~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.c: In member function 'void TFT_eSPI::pushPixels(const void*, uint32_t)':
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.h:412:31: error: 'GPIO' was not declared in this scope
  412 |       #define tft_Write_16(C) GPIO.out_w1tc = GPIO_OUT_CLR_MASK; GPIO.out_w1ts = set_mask((uint8_t) ((C) >> 8)); WR_H; \
      |                               ^~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.c:578:37: note: in expansion of macro 'tft_Write_16'
  578 |   if(_swapBytes) { while ( len-- ) {tft_Write_16(*data); data++; } }
      |                                     ^~~~~~~~~~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.h:416:32: error: 'GPIO' was not declared in this scope
  416 |       #define tft_Write_16S(C) GPIO.out_w1tc = GPIO_OUT_CLR_MASK; GPIO.out_w1ts = set_mask((uint8_t) ((C) >> 0)); WR_H; \
      |                                ^~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.c:579:27: note: in expansion of macro 'tft_Write_16S'
  579 |   else { while ( len-- ) {tft_Write_16S(*data); data++;} }
      |                           ^~~~~~~~~~~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/TFT_eSPI.cpp: In member function 'void TFT_eSPI::spiwrite(uint8_t)':
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.h:392:27: error: 'GPIO' was not declared in this scope
  392 |   #define tft_Write_8(C)  GPIO.out_w1tc = GPIO_OUT_CLR_MASK; GPIO.out_w1ts = set_mask((uint8_t)(C)); WR_H
      |                           ^~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/TFT_eSPI.cpp:910:3: note: in expansion of macro 'tft_Write_8'
  910 |   tft_Write_8(c);
      |   ^~~~~~~~~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/TFT_eSPI.cpp: In member function 'void TFT_eSPI::writecommand(uint8_t)':
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.h:167:20: error: 'GPIO' was not declared in this scope
  167 |       #define DC_C GPIO.out_w1tc = (1 << TFT_DC)
      |                    ^~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/TFT_eSPI.cpp:924:3: note: in expansion of macro 'DC_C'
  924 |   DC_C;
      |   ^~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/TFT_eSPI.cpp: In member function 'void TFT_eSPI::writedata(uint8_t)':
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.h:168:20: error: 'GPIO' was not declared in this scope
  168 |       #define DC_D GPIO.out_w1ts = (1 << TFT_DC)
      |                    ^~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/TFT_eSPI.cpp:972:3: note: in expansion of macro 'DC_D'
  972 |   DC_D;        // Play safe, but should already be in data mode
      |   ^~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/TFT_eSPI.cpp: In member function 'virtual void TFT_eSPI::drawChar(int32_t, int32_t, uint16_t, uint32_t, uint32_t, uint8_t)':
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.h:412:31: error: 'GPIO' was not declared in this scope
  412 |       #define tft_Write_16(C) GPIO.out_w1tc = GPIO_OUT_CLR_MASK; GPIO.out_w1ts = set_mask((uint8_t) ((C) >> 8)); WR_H; \
      |                               ^~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/TFT_eSPI.cpp:3051:32: note: in expansion of macro 'tft_Write_16'
 3051 |         if (column[k] & mask) {tft_Write_16(color);}
      |                                ^~~~~~~~~~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.h:412:31: error: 'GPIO' was not declared in this scope
  412 |       #define tft_Write_16(C) GPIO.out_w1tc = GPIO_OUT_CLR_MASK; GPIO.out_w1ts = set_mask((uint8_t) ((C) >> 8)); WR_H; \
      |                               ^~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/TFT_eSPI.cpp:3052:15: note: in expansion of macro 'tft_Write_16'
 3052 |         else {tft_Write_16(bg);}
      |               ^~~~~~~~~~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.h:412:31: error: 'GPIO' was not declared in this scope
  412 |       #define tft_Write_16(C) GPIO.out_w1tc = GPIO_OUT_CLR_MASK; GPIO.out_w1ts = set_mask((uint8_t) ((C) >> 8)); WR_H; \
      |                               ^~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/TFT_eSPI.cpp:3055:7: note: in expansion of macro 'tft_Write_16'
 3055 |       tft_Write_16(bg);
      |       ^~~~~~~~~~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/TFT_eSPI.cpp: In member function 'virtual void TFT_eSPI::setWindow(int32_t, int32_t, int32_t, int32_t)':
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.h:167:20: error: 'GPIO' was not declared in this scope
  167 |       #define DC_C GPIO.out_w1tc = (1 << TFT_DC)
      |                    ^~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/TFT_eSPI.cpp:3303:5: note: in expansion of macro 'DC_C'
 3303 |     DC_C; tft_Write_8(TFT_CASET);
      |     ^~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/TFT_eSPI.cpp: In member function 'void TFT_eSPI::readAddrWindow(int32_t, int32_t, int32_t, int32_t)':
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.h:167:20: error: 'GPIO' was not declared in this scope
  167 |       #define DC_C GPIO.out_w1tc = (1 << TFT_DC)
      |                    ^~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/TFT_eSPI.cpp:3379:3: note: in expansion of macro 'DC_C'
 3379 |   DC_C; tft_Write_8(TFT_CASET);
      |   ^~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/TFT_eSPI.cpp: In member function 'virtual void TFT_eSPI::drawPixel(int32_t, int32_t, uint32_t)':
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.h:167:20: error: 'GPIO' was not declared in this scope
  167 |       #define DC_C GPIO.out_w1tc = (1 << TFT_DC)
      |                    ^~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/TFT_eSPI.cpp:3561:7: note: in expansion of macro 'DC_C'
 3561 |       DC_C; tft_Write_8(TFT_CASET);
      |       ^~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.h:167:20: error: 'GPIO' was not declared in this scope
  167 |       #define DC_C GPIO.out_w1tc = (1 << TFT_DC)
      |                    ^~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/TFT_eSPI.cpp:3568:7: note: in expansion of macro 'DC_C'
 3568 |       DC_C; tft_Write_8(TFT_PASET);
      |       ^~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.h:167:20: error: 'GPIO' was not declared in this scope
  167 |       #define DC_C GPIO.out_w1tc = (1 << TFT_DC)
      |                    ^~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/TFT_eSPI.cpp:3574:3: note: in expansion of macro 'DC_C'
 3574 |   DC_C; tft_Write_8(TFT_RAMWR);
      |   ^~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/TFT_eSPI.cpp: In member function 'virtual void TFT_eSPI::pushColor(uint16_t)':
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.h:412:31: error: 'GPIO' was not declared in this scope
  412 |       #define tft_Write_16(C) GPIO.out_w1tc = GPIO_OUT_CLR_MASK; GPIO.out_w1ts = set_mask((uint8_t) ((C) >> 8)); WR_H; \
      |                               ^~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.h:605:25: note: in expansion of macro 'tft_Write_16'
  605 |   #define tft_Write_16N tft_Write_16
      |                         ^~~~~~~~~~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/TFT_eSPI.cpp:3595:3: note: in expansion of macro 'tft_Write_16N'
 3595 |   tft_Write_16N(color);
      |   ^~~~~~~~~~~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/TFT_eSPI.cpp: In member function 'virtual int16_t TFT_eSPI::drawChar(uint16_t, int32_t, int32_t, uint8_t)':
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.h:412:31: error: 'GPIO' was not declared in this scope
  412 |       #define tft_Write_16(C) GPIO.out_w1tc = GPIO_OUT_CLR_MASK; GPIO.out_w1ts = set_mask((uint8_t) ((C) >> 8)); WR_H; \
      |                               ^~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/TFT_eSPI.cpp:4741:31: note: in expansion of macro 'tft_Write_16'
 4741 |             if (line & mask) {tft_Write_16(textcolor);}
      |                               ^~~~~~~~~~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.h:412:31: error: 'GPIO' was not declared in this scope
  412 |       #define tft_Write_16(C) GPIO.out_w1tc = GPIO_OUT_CLR_MASK; GPIO.out_w1ts = set_mask((uint8_t) ((C) >> 8)); WR_H; \
      |                               ^~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/TFT_eSPI.cpp:4742:19: note: in expansion of macro 'tft_Write_16'
 4742 |             else {tft_Write_16(textbgcolor);}
      |                   ^~~~~~~~~~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.h:412:31: error: 'GPIO' was not declared in this scope
  412 |       #define tft_Write_16(C) GPIO.out_w1tc = GPIO_OUT_CLR_MASK; GPIO.out_w1ts = set_mask((uint8_t) ((C) >> 8)); WR_H; \
      |                               ^~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/TFT_eSPI.cpp:4747:18: note: in expansion of macro 'tft_Write_16'
 4747 |         if (pX) {tft_Write_16(textbgcolor);}
      |                  ^~~~~~~~~~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.h:412:31: error: 'GPIO' was not declared in this scope
  412 |       #define tft_Write_16(C) GPIO.out_w1tc = GPIO_OUT_CLR_MASK; GPIO.out_w1ts = set_mask((uint8_t) ((C) >> 8)); WR_H; \
      |                               ^~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/TFT_eSPI.cpp:4796:30: note: in expansion of macro 'tft_Write_16'
 4796 |               while (tnp--) {tft_Write_16(textcolor);}
      |                              ^~~~~~~~~~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.h:412:31: error: 'GPIO' was not declared in this scope
  412 |       #define tft_Write_16(C) GPIO.out_w1tc = GPIO_OUT_CLR_MASK; GPIO.out_w1ts = set_mask((uint8_t) ((C) >> 8)); WR_H; \
      |                               ^~~~
/home/ado/Projects/Espressif/OPIS_Cloud_Module/main/lib/TFT_eSPI/TFT_eSPI.cpp:4798:19: note: in expansion of macro 'tft_Write_16'
 4798 |             else {tft_Write_16(textcolor);}
      |                   ^~~~~~~~~~~~

It seems like, in the new ESP-IDF, the GPIO construct is not readily available to all users like it used to be. And there is a related issue on the idf page: https://github.com/espressif/esp-idf/issues/9184

From what I understand from that issue, the GPIO was never supposed to be available to users. Instead, it is a low-level library. I guess it is used in the library for fast pin updates by using the pin registers directly. But with the new version, it causes an error. I don't know what to do, so I'm writing an issue here. Maybe we can also collaborate with the idf developers to resolve this problem. I'm available if you need to ask anything more. Thanks for your help.

Bodmer commented 1 year ago

Thanks for raising this. The Espressif software team like to change things that are not broken!

The fix is in the link you provided. I will try this next week.

Bodmer commented 1 year ago

Adding the include to the relevant processor header files does not break the library for the Arduino environment so I will add it in the next update.

For example for the ESP32 add the following line here:

#include "hal/gpio_ll.h"
devrim-oguz commented 1 year ago

Hello, I have added the line as you said in the ESP32_S3.h file (my board is esp32-s3) and now the other errors are disappeared but this error came up:

In file included from /home/ado/Projects/Espressif/idf_deneme/main/lib/TFT_eSPI/TFT_eSPI.h:94,
                 from /home/ado/Projects/Espressif/idf_deneme/main/lib/TFT_eSPI/TFT_eSPI.cpp:16:
/home/ado/Projects/Espressif/idf_deneme/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.h:11:3: warning: #warning >>>>------>> DMA is not supported on the ESP32 S3 (possible future update) [-Wcpp]
   11 |  #warning >>>>------>> DMA is not supported on the ESP32 S3 (possible future update)
      |   ^~~~~~~
/home/ado/Projects/Espressif/idf_deneme/main/lib/TFT_eSPI/TFT_eSPI.h:909:8: warning: #warning >>>>------>> TOUCH_CS pin not defined, TFT_eSPI touch functions will not be available! [-Wcpp]
  909 |       #warning >>>>------>> TOUCH_CS pin not defined, TFT_eSPI touch functions will not be available!
      |        ^~~~~~~
In file included from /home/ado/Projects/Espressif/idf_deneme/main/lib/TFT_eSPI/TFT_eSPI.cpp:20:
/home/ado/Projects/Espressif/idf_deneme/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.c: In member function 'uint8_t TFT_eSPI::readByte()':
/home/ado/Projects/Espressif/idf_deneme/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.c:100:9: error: 'gpio_input_get' was not declared in this scope; did you mean 'gpio_num_t'?
  100 |   reg = gpio_input_get(); // Read three times to allow for bus access time
      |         ^~~~~~~~~~~~~~
      |         gpio_num_t
ninja: build stopped: subcommand failed.
ninja failed with exit code 1, output of the command is in the /home/ado/Projects/Espressif/idf_deneme/build/log/idf_py_stderr_output_24645 and /home/ado/Projects/Espressif/idf_deneme/build/log/idf_py_stdout_output_24645
alba-ado commented 1 year ago

I'm devrim-oguz, this is my business account. Here is an update of the errors when I switched to v5.1-rc2:

In file included from /home/ado/Projects/Espressif/idf-v5.1_deneme/main/lib/TFT_eSPI/TFT_eSPI.h:97,
                 from /home/ado/Projects/Espressif/idf-v5.1_deneme/main/lib/TFT_eSPI/TFT_eSPI.cpp:16:
/home/ado/Projects/Espressif/idf-v5.1_deneme/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.h:111:3: warning: #warning >>>>------>> DMA is not supported in parallel mode [-Wcpp]
  111 |  #warning >>>>------>> DMA is not supported in parallel mode
      |   ^~~~~~~
/home/ado/Projects/Espressif/idf-v5.1_deneme/main/lib/TFT_eSPI/TFT_eSPI.h:977:8: warning: #warning >>>>------>> TOUCH_CS pin not defined, TFT_eSPI touch functions will not be available! [-Wcpp]
  977 |       #warning >>>>------>> TOUCH_CS pin not defined, TFT_eSPI touch functions will not be available!
      |        ^~~~~~~
In file included from /home/ado/Projects/Espressif/idf-v5.1_deneme/main/lib/TFT_eSPI/TFT_eSPI.cpp:20:
/home/ado/Projects/Espressif/idf-v5.1_deneme/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.c: In member function 'uint8_t TFT_eSPI::readByte()':
/home/ado/Projects/Espressif/idf-v5.1_deneme/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.c:96:8: error: 'gpio_get_level' was not declared in this scope; did you mean 'gpio_ll_get_level'?
   96 |   b  = gpio_get_level((gpio_num_t)TFT_D0); // Read three times to allow for bus access time
      |        ^~~~~~~~~~~~~~
      |        gpio_ll_get_level
ninja: build stopped: subcommand failed.
ninja failed with exit code 1, output of the command is in the /home/ado/Projects/Espressif/idf-v5.1_deneme/build/log/idf_py_stderr_output_18292 and /home/ado/Projects/Espressif/idf-v5.1_deneme/build/log/idf_py_stdout_output_18292

It says to change the gpio_get_level commands to the ones with ll, so I did. But now it gives this error, and I don't know how to convert the pin numbers into (gpio_dev_t *)

In file included from /home/ado/Projects/Espressif/idf-v5.1_deneme/main/lib/TFT_eSPI/TFT_eSPI.cpp:20:
/home/ado/Projects/Espressif/idf-v5.1_deneme/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.c: In member function 'uint8_t TFT_eSPI::readByte()':
/home/ado/Projects/Espressif/idf-v5.1_deneme/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.c:96:26: error: cannot convert 'gpio_num_t' to 'gpio_dev_t*' {aka 'volatile gpio_dev_s*'}
   96 |   b  = gpio_ll_get_level((gpio_num_t)TFT_D0); // Read three times to allow for bus access time
In file included from /home/ado/Projects/Espressif/idf-v5.1_deneme/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.h:16:
/home/ado/Programs/Espressif/esp-idf-v5.1/components/hal/esp32s3/include/hal/gpio_ll.h:337:49: note:   initializing argument 1 of 'int gpio_ll_get_level(gpio_dev_t*, uint32_t)'
  337 | static inline int gpio_ll_get_level(gpio_dev_t *hw, uint32_t gpio_num)
      |                                     ~~~~~~~~~~~~^~
/home/ado/Projects/Espressif/idf-v5.1_deneme/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.c:97:26: error: cannot convert 'gpio_num_t' to 'gpio_dev_t*' {aka 'volatile gpio_dev_s*'}
   97 |   b  = gpio_ll_get_level((gpio_num_t)TFT_D0);
/home/ado/Programs/Espressif/esp-idf-v5.1/components/hal/esp32s3/include/hal/gpio_ll.h:337:49: note:   initializing argument 1 of 'int gpio_ll_get_level(gpio_dev_t*, uint32_t)'
  337 | static inline int gpio_ll_get_level(gpio_dev_t *hw, uint32_t gpio_num)
      |                                     ~~~~~~~~~~~~^~
/home/ado/Projects/Espressif/idf-v5.1_deneme/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.c:98:26: error: cannot convert 'gpio_num_t' to 'gpio_dev_t*' {aka 'volatile gpio_dev_s*'}
   98 |   b  = gpio_ll_get_level((gpio_num_t)TFT_D0); // Data should be stable now
/home/ado/Programs/Espressif/esp-idf-v5.1/components/hal/esp32s3/include/hal/gpio_ll.h:337:49: note:   initializing argument 1 of 'int gpio_ll_get_level(gpio_dev_t*, uint32_t)'
  337 | static inline int gpio_ll_get_level(gpio_dev_t *hw, uint32_t gpio_num)
      |                                     ~~~~~~~~~~~~^~
/home/ado/Projects/Espressif/idf-v5.1_deneme/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.c:101:27: error: cannot convert 'gpio_num_t' to 'gpio_dev_t*' {aka 'volatile gpio_dev_s*'}
  101 |   b  = (gpio_ll_get_level((gpio_num_t)TFT_D0) << 0);
/home/ado/Programs/Espressif/esp-idf-v5.1/components/hal/esp32s3/include/hal/gpio_ll.h:337:49: note:   initializing argument 1 of 'int gpio_ll_get_level(gpio_dev_t*, uint32_t)'
  337 | static inline int gpio_ll_get_level(gpio_dev_t *hw, uint32_t gpio_num)
      |                                     ~~~~~~~~~~~~^~
/home/ado/Projects/Espressif/idf-v5.1_deneme/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.c:102:27: error: cannot convert 'gpio_num_t' to 'gpio_dev_t*' {aka 'volatile gpio_dev_s*'}
  102 |   b |= (gpio_ll_get_level((gpio_num_t)TFT_D1) << 1);
/home/ado/Programs/Espressif/esp-idf-v5.1/components/hal/esp32s3/include/hal/gpio_ll.h:337:49: note:   initializing argument 1 of 'int gpio_ll_get_level(gpio_dev_t*, uint32_t)'
  337 | static inline int gpio_ll_get_level(gpio_dev_t *hw, uint32_t gpio_num)
      |                                     ~~~~~~~~~~~~^~
/home/ado/Projects/Espressif/idf-v5.1_deneme/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.c:103:27: error: cannot convert 'gpio_num_t' to 'gpio_dev_t*' {aka 'volatile gpio_dev_s*'}
  103 |   b |= (gpio_ll_get_level((gpio_num_t)TFT_D2) << 2);
/home/ado/Programs/Espressif/esp-idf-v5.1/components/hal/esp32s3/include/hal/gpio_ll.h:337:49: note:   initializing argument 1 of 'int gpio_ll_get_level(gpio_dev_t*, uint32_t)'
  337 | static inline int gpio_ll_get_level(gpio_dev_t *hw, uint32_t gpio_num)
      |                                     ~~~~~~~~~~~~^~
/home/ado/Projects/Espressif/idf-v5.1_deneme/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.c:104:27: error: cannot convert 'gpio_num_t' to 'gpio_dev_t*' {aka 'volatile gpio_dev_s*'}
  104 |   b |= (gpio_ll_get_level((gpio_num_t)TFT_D3) << 3);
/home/ado/Programs/Espressif/esp-idf-v5.1/components/hal/esp32s3/include/hal/gpio_ll.h:337:49: note:   initializing argument 1 of 'int gpio_ll_get_level(gpio_dev_t*, uint32_t)'
  337 | static inline int gpio_ll_get_level(gpio_dev_t *hw, uint32_t gpio_num)
      |                                     ~~~~~~~~~~~~^~
/home/ado/Projects/Espressif/idf-v5.1_deneme/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.c:105:27: error: cannot convert 'gpio_num_t' to 'gpio_dev_t*' {aka 'volatile gpio_dev_s*'}
  105 |   b |= (gpio_ll_get_level((gpio_num_t)TFT_D4) << 4);
/home/ado/Programs/Espressif/esp-idf-v5.1/components/hal/esp32s3/include/hal/gpio_ll.h:337:49: note:   initializing argument 1 of 'int gpio_ll_get_level(gpio_dev_t*, uint32_t)'
  337 | static inline int gpio_ll_get_level(gpio_dev_t *hw, uint32_t gpio_num)
      |                                     ~~~~~~~~~~~~^~
/home/ado/Projects/Espressif/idf-v5.1_deneme/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.c:106:27: error: cannot convert 'gpio_num_t' to 'gpio_dev_t*' {aka 'volatile gpio_dev_s*'}
  106 |   b |= (gpio_ll_get_level((gpio_num_t)TFT_D5) << 5);
/home/ado/Programs/Espressif/esp-idf-v5.1/components/hal/esp32s3/include/hal/gpio_ll.h:337:49: note:   initializing argument 1 of 'int gpio_ll_get_level(gpio_dev_t*, uint32_t)'
  337 | static inline int gpio_ll_get_level(gpio_dev_t *hw, uint32_t gpio_num)
      |                                     ~~~~~~~~~~~~^~
/home/ado/Projects/Espressif/idf-v5.1_deneme/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.c:107:27: error: cannot convert 'gpio_num_t' to 'gpio_dev_t*' {aka 'volatile gpio_dev_s*'}
  107 |   b |= (gpio_ll_get_level((gpio_num_t)TFT_D6) << 6);
/home/ado/Programs/Espressif/esp-idf-v5.1/components/hal/esp32s3/include/hal/gpio_ll.h:337:49: note:   initializing argument 1 of 'int gpio_ll_get_level(gpio_dev_t*, uint32_t)'
  337 | static inline int gpio_ll_get_level(gpio_dev_t *hw, uint32_t gpio_num)
      |                                     ~~~~~~~~~~~~^~
/home/ado/Projects/Espressif/idf-v5.1_deneme/main/lib/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.c:108:27: error: cannot convert 'gpio_num_t' to 'gpio_dev_t*' {aka 'volatile gpio_dev_s*'}
  108 |   b |= (gpio_ll_get_level((gpio_num_t)TFT_D7) << 7);
/home/ado/Programs/Espressif/esp-idf-v5.1/components/hal/esp32s3/include/hal/gpio_ll.h:337:49: note:   initializing argument 1 of 'int gpio_ll_get_level(gpio_dev_t*, uint32_t)'
  337 | static inline int gpio_ll_get_level(gpio_dev_t *hw, uint32_t gpio_num)
      |                                     ~~~~~~~~~~~~^~
ninja: build stopped: subcommand failed.
ninja failed with exit code 1, output of the command is in the /home/ado/Projects/Espressif/idf-v5.1_deneme/build/log/idf_py_stderr_output_18384 and /home/ado/Projects/Espressif/idf-v5.1_deneme/build/log/idf_py_stdout_output_18384
alba-ado commented 1 year ago

Update: I managed to find what the gpio_ll_get_level expects. It expected a device pointer. So I changed the lines in ESP32_S3.c like this:

#if defined (TFT_PARALLEL_8_BIT)
  RD_L;
  b  = gpio_ll_get_level(&GPIO, TFT_D0); // Read three times to allow for bus access time
  b  = gpio_ll_get_level(&GPIO, TFT_D0);
  b  = gpio_ll_get_level(&GPIO, TFT_D0); // Data should be stable now

  // Check GPIO bits used and build value
  b  = (gpio_ll_get_level(&GPIO, TFT_D0) << 0);
  b |= (gpio_ll_get_level(&GPIO, TFT_D1) << 1);
  b |= (gpio_ll_get_level(&GPIO, TFT_D2) << 2);
  b |= (gpio_ll_get_level(&GPIO, TFT_D3) << 3);
  b |= (gpio_ll_get_level(&GPIO, TFT_D4) << 4);
  b |= (gpio_ll_get_level(&GPIO, TFT_D5) << 5);
  b |= (gpio_ll_get_level(&GPIO, TFT_D6) << 6);
  b |= (gpio_ll_get_level(&GPIO, TFT_D7) << 7);
  RD_H;
#endif

and this solved the issue. However, I didn't create a pull request for this since this time the linker gives an error about something using the filesystem inside TFT_eSPI. I couldn't decide if this issue is actually caused by your library or by the arduino-esp32 component itself. Still, here is the linker error if you would like to investigate further into this:

/home/ado/Programs/Espressif/tools-v5.1/tools/xtensa-esp32s3-elf/esp-12.2.0_20230208/xtensa-esp32s3-elf/bin/../lib/gcc/xtensa-esp32s3-elf/12.2.0/../../../../xtensa-esp32s3-elf/bin/ld: esp-idf/arduino/libarduino.a(vfs_api.cpp.obj):(.literal._ZN11VFSFileImplD2Ev+0x4): undefined reference to `_ZTVN2fs8FileImplE'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
ninja failed with exit code 1, output of the command is in the /home/ado/Projects/Espressif/idf-v5.1_deneme/build/log/idf_py_stderr_output_33478 and /home/ado/Projects/Espressif/idf-v5.1_deneme/build/log/idf_py_stdout_output_33478

From what I understand, it complains that it can't find fs::FileImpl class for some reason. However, this error disappears when I don't include the library and the project build succeeds.

alba-ado commented 1 year ago

Another update: It gives the same error when I call SPIFFS.begin(); without including this library. So, I think the error comes from the Arduino core for the esp32. These two changes should fix the library but I can't test it now. So I am not creating a pull request, but maybe you might add these lines in the future.

pablobatch commented 8 months ago

Adding the include to the relevant processor header files does not break the library for the Arduino environment so I will add it in the next update.

For example for the ESP32 add the following line here:

#include "hal/gpio_ll.h"

Doing this the error dissapeares, but the display of my Lilgo T-Display is not working.

tonhuisman commented 7 months ago

Another update: It gives the same error when I call SPIFFS.begin(); without including this library.

SPIFFS is removed from IDF 5.x. It has been deprecated for some years, and is now (finally/actually) removed. You should switch to LittleFS, but there is no migration path available (AFAICS).

devrim-oguz commented 7 months ago

Another update: It gives the same error when I call SPIFFS.begin(); without including this library.

SPIFFS is removed from IDF 5.x. It has been deprecated for some years, and is now (finally/actually) removed. You should switch to LittleFS, but there is no migration path available (AFAICS).

Not me, but the library needs to switch. It is using the SPIFFS internally. So, it wouldn’t compile for IDF v5.1

kdg3737 commented 6 months ago

I can confirm that I got this library working with the LilyGO T-display-S3 screen on ESP-IDF v5.1, ran into much of the same issues as the OP here but not the SPIFFS issues, thank god.

landscapejohn commented 1 week ago

I can confirm that the fix @alba-ado added works with the LilyGO T-display-S3 using the Arduino 2 IDE. Excellent work, this should be merged to the library.