martinberlin / CalEPD

Epaper ESP-IDF component with GFX capabilities and multi SPI support
https://fasani.de
Apache License 2.0
94 stars 11 forks source link

Build errors Adafruit-GFX WString.cpp: PGM_P, memcpy_P, strlen_P not declared in this scope #6

Closed michaelkargl closed 2 years ago

michaelkargl commented 2 years ago

Hello, thanks for the great effort of helping us ESP users use E-Ink displays to save energy and produce sustainable projects ♥!

At the moment I'm trying to get a hello-eink application to build but failing at Adadruit-GFX Library issues. The display of choice is this small 2.7Inch Waveshare e-Paper HAT.

lib/Adafruit-GFX-Library/Adafruit-GFX-Library-ESP-IDF/glcdfont.c:9:28: error: 'font' defined but not used [-Werror=unused-const-variable=]
 static const unsigned char font[] = {
                            ^~~~
cc1.exe: some warnings being treated as errors
Compiling .pio\build\esp32dev\libe2f\CalEPD\epd.o
Compiling .pio\build\esp32dev\libe2f\CalEPD\epd7color.o
lib/Adafruit-GFX-Library/Adafruit-GFX-Library-ESP-IDF/WString.cpp: In member function 'String& String::copy(const __FlashStringHelper*, unsigned int)':
lib/Adafruit-GFX-Library/Adafruit-GFX-Library-ESP-IDF/WString.cpp:225:26: error: 'PGM_P' was not declared in this scope
     memcpy_P(wbuffer(), (PGM_P)pstr, length + 1); // We know wbuffer() cannot ever be in PROGMEM, so memcpy safe here
                          ^~~~~
lib/Adafruit-GFX-Library/Adafruit-GFX-Library-ESP-IDF/WString.cpp:225:5: error: 'memcpy_P' was not declared in this scope
     memcpy_P(wbuffer(), (PGM_P)pstr, length + 1); // We know wbuffer() cannot ever be in PROGMEM, so memcpy safe here
     ^~~~~~~~
lib/Adafruit-GFX-Library/Adafruit-GFX-Library-ESP-IDF/WString.cpp:225:5: note: suggested alternative: 'memcpy'
     memcpy_P(wbuffer(), (PGM_P)pstr, length + 1); // We know wbuffer() cannot ever be in PROGMEM, so memcpy safe here
     ^~~~~~~~
     memcpy
...

My current setup is just a plain PlatformIO project using an ESP32Devkit board with custom libraries built using submodules of your two repos.

CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (3.4.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash

Dependency Graph
|-- <calepd> 1.0.0
|   |-- <adafruit-gfx-library-esp-idf> 1.0.0

PACKAGES:
 - framework-espidf 3.40301.0 (4.3.1)
 - tool-cmake 3.16.4
 - tool-esptoolpy 1.30100.210531 (3.1.0)
 - tool-idf 1.0.1
 - tool-mconf 1.4060000.20190628 (406.0.0)
 - tool-ninja 1.9.0
 - toolchain-esp32ulp 1.22851.191205 (2.28.51)
 - toolchain-riscv32-esp 8.4.0+2021r1
 - toolchain-xtensa-esp32 8.4.0+2021r1
 - toolchain-xtensa-esp32s2 8.4.0+2021r1

Basically the issue seems that required dependencies are missing (PGM_P, memcpy_P). Could it be that there are additional setup steps missing?

martinberlin commented 2 years ago

Hello Michael, In command line using: idf.py build it compiles correctly. Do not get what it happens with Platformio so far.

Will try to compile it myself first and let you know. This seem to be macros that are not defined right? What happens if you remove: (PGM_P) completely And update: memcpy_P for memcpy ?

The idea of this fork was to remove Arduino dependencies completely but I only updated so far until compiles for me. Maybe you can remove this last dependencies so it compiles also in Platformio and submit a pull request?

Additionally if that plans fails you can also search where this is defined on Arduino and then declare it yourself in the header file so it finds it when building.

https://github.com/espressif/arduino-esp32/search?q=PGM_P

#define memcpy_P      memcpy
#define PGM_P         const char *
#define strlen_P      strlen

But better clean it up and just use (const char *) instead of PGM_P...

Also: We can add from our side a library.json so you don't have to add a subdirectory to include our library.

martinberlin commented 2 years ago

Hi @michaelkargl I added already the library.json in CalEPD: https://github.com/martinberlin/CalEPD

And will do the same for the Adafruit GFX fork so you don't have to do that ugly subdirectories and it's easier to add my components. Please try to keep feedback on this one, I automatically close any tickets that are 3 weeks without any activity or feedback otherwise it's quite hard to track them and keep finding a solution.

Please update Adafruit GFX reference with this release: https://github.com/martinberlin/Adafruit-GFX-Library-ESP-IDF/releases/tag/v1.7.7

martinberlin commented 2 years ago

@michaelkargl can you please pull this last update and give it a try? If you need to make any other update before building it please let me know.

michaelkargl commented 2 years ago

Hello! Sorry for the late reply! Time flies lately... I can't thank you enough for taking such interest and the addition of a library.json 😄 ! I'll have time off tomorrow and will use that to get an e-paper example working. Reporting back once I've gotten my hands dirty.

michaelkargl commented 2 years ago

Update: I took a different approach once I foundthat the cale-idf project is already a platformio project with examples included. After a bit of trial and error I got a demo project to work but unfortunately wasn't able to yield the same results when moving the libraries from /components to /lib. To my understanding the epd_driver and FT6X36-IDF projects are also necessary to successfully initialize a valid

static FT6X36 touch_panel(CONFIG_TOUCH_INT);
static EpdSpi spi_io_interface;
static Gdew027w3T display(spi_io_interface, touch_panel);

so maybe it's only a missing dependency issue. I couldn't get a valid setup running yet. Maybe I can find the right library configuration over time.

But it is safe to say that the original error doesn't crop up anymore but is more or less replaced with others to be solved separately 👍🏽

martinberlin commented 2 years ago

But did you try the Adafruit GFX update?

To my understanding the epd_driver and FT6X36-IDF projects are also necessary to successfully initialize a valid

Not really: epd_driver only necessary if you use parallel epapers controlled by EPDiy board and FT6X36-IDF only if you use touch interface. Otherwise you can simply avoid using classes that implement those and just comment them in CalEPD/CMakeLists.txt

tell me if that works for you. You should be able to use lib instead of components folder that is the default in ESP-IDF but that will need a bit of extra configuration. This Cale-IDF repository was build compiling this with esp-IDF from command line, I leave the users freely to decide the way to define the components. But you can of course use Platformio to compile this and it should work too. Check this project where I collaborate to see how it uses Platformio with a lib folder: https://github.com/atomic14/diy-esp32-epub-reader

martinberlin commented 2 years ago

@michaelkargl did you find some time to test this? If there is no updates in some days I will close this. Thanks for trying this out and I hope it worked out for you