nopnop2002 / esp-idf-ili9340

SPI TFT and XPT2046 touch screen controller driver for esp-idf
MIT License
163 stars 34 forks source link

Guide how to use as esp-idf component #32

Closed trusch closed 3 years ago

trusch commented 3 years ago

Hello!

Can you provide instructions on how to use this properly as a component in another idf project? I was able to run your demo, but wasn't able to integrate your code into another project. Even if I copy all the stuff into the main folder of my app, I ran into linker errors because it can't find the lcd* functions.

Any help would be appreciated!

Thanks in advance!

nopnop2002 commented 3 years ago

@trusch

cp -r esp-idf-ili9340 YourProject/

cd YourProject

cd main

vi main.c OR Replace with your main.c

If you replace main.c with your main.c, your main.c needs these:

#include "ili9340.h"
#include "fontx.h"
#include "bmpfile.h"
#include "decode_image.h"
#include "pngle.h"
trusch commented 3 years ago

@nopnop2002 When I clone your project directly into the components folder and reference the headers as you suggested I only get this:

Executing action: all (aliases: build)
Running cmake in directory /home/tino/Code/greenhouse/wifi/build
Executing "cmake -G Ninja -DPYTHON_DEPS_CHECKED=1 -DESP_PLATFORM=1 -DIDF_TARGET=esp32 -DCCACHE_ENABLE=0 /home/tino/Code/greenhouse/wifi"...
-- Found Git: /usr/bin/git (found version "2.30.0") 
-- The C compiler identification is GNU 8.4.0
-- The CXX compiler identification is GNU 8.4.0
-- The ASM compiler identification is GNU
-- Found assembler: /home/tino/.espressif/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /home/tino/.espressif/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /home/tino/.espressif/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Building ESP-IDF components for target esp32
-- Found Git: /usr/bin/git (found version "2.30.0") 
CMake Error at /home/tino/esp/esp-idf/tools/cmake/component.cmake:224 (message):
  CMake Error at /usr/share/cmake-3.19/Modules/ExternalProject.cmake:1117
  (define_property):

    define_property command is not scriptable

  Call Stack (most recent call first):

    /home/tino/esp/esp-idf/tools/cmake/kconfig.cmake:1 (include)
    /home/tino/esp/esp-idf/tools/cmake/idf.cmake:41 (include)
    /home/tino/esp/esp-idf/tools/cmake/project.cmake:7 (include)
    /home/tino/Code/greenhouse/wifi/components/esp-idf-ili9340/CMakeLists.txt:5 (include)
    /home/tino/esp/esp-idf/tools/cmake/scripts/component_get_requirements.cmake:97 (include)
    /home/tino/esp/esp-idf/tools/cmake/scripts/component_get_requirements.cmake:115 (__component_get_requirements)

Call Stack (most recent call first):
  /home/tino/esp/esp-idf/tools/cmake/build.cmake:416 (__component_get_requirements)
  /home/tino/esp/esp-idf/tools/cmake/project.cmake:396 (idf_build_process)
  CMakeLists.txt:8 (project)

-- Configuring incomplete, errors occurred!
See also "/home/tino/Code/greenhouse/wifi/build/CMakeFiles/CMakeOutput.log".
cmake failed with exit code 1

However, when I just extract the .c and .h, cmake and component.mk files into a folder in components it builds fine, but at the linking stage the linker thinks that all the functions from theses headers are in the libmain.a archive (the map file of my app says that)

edit: I forgot the I also worked around the spiffs stuff my integrating that in my toplevel cmake.

nopnop2002 commented 3 years ago

I'm not sure about your situation.

No need for components folder.

This is all you do.

git clone https://github.com/nopnop2002/esp-idf-ili934
cp -r esp-idf-ili9340 YourProject/
cd YourProject
cd main
vi main.c
cd ..
idf.py set-target esp32
idf.py menuconfig
idf.py flash
nopnop2002 commented 3 years ago

If you want to turn this library into a component, see here:

https://github.com/nopnop2002/esp-idf-parallel-tft

trusch commented 3 years ago

@nopnop2002 I think now I understood! You mean I should just fork this repo and adjust the main.c. That should work for sure. Thanks for the link to the component, that's what I searched :)

JarrettR commented 3 years ago

FYI I turned this repo into a component: https://github.com/JarrettR/esp-idf-ili9340

(Your particular issue was a cmake file that expected to be a main project instead of a component)

nopnop2002 commented 3 years ago

@JarrettR

I added a link to your repository in my README.