Skip to content

Commit 6167d6e

Browse files
committed
Update to release/v4.0 and document idf_register_component installation.
1 parent abdebcc commit 6167d6e

File tree

3 files changed

+59
-13
lines changed

3 files changed

+59
-13
lines changed

README.md

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33

44
---
55

6-
**This library must be built with the latest esp-idf master branch and xtensa toolchain**
7-
8-
If you are using the esp-idf v2.1, checkout the commit *0518df81a6566820352dad7bf6c539995d41ad18*
6+
**This library must be built with the esp-idf release/v4.0 branch and xtensa toolchain**
97

108
---
119

@@ -152,7 +150,7 @@ Full **demo application**, well documented, is included, please **analyze it** t
152150
| GND | GND | Power supply ground |
153151
| 3.3V or +5V | Vcc | Power supply positive |
154152

155-
**Make shure the display module has 3.3V compatible interface, if not you must use level shifter!**
153+
**Make sure the display module has 3.3V compatible interface, if not you must use level shifter!**
156154

157155
---
158156

@@ -189,24 +187,65 @@ Using *make menuconfig* **select tick rate 1000** ( → Component config → Fre
189187

190188
---
191189

192-
#### How to build
190+
#### Installing as Library
191+
This repository is intended to be installable as a component library using the ESP-IDF 4.0 build system.
192+
193+
It is recommended though that you first follow the [demo instructions](#building-the-demo) below to build this repository as a standalone example to validate your hardware and have a basis to learn the library features.
194+
195+
When you are ready to incorporate it into your existing project, it is recommended to:
196+
197+
```shell
198+
mkdir -p externals
199+
git submodule add https://github.com/jeremyjh/ESP32_TFT_library.git externals/ESP32_TFT_library
200+
```
201+
202+
In your project's root CMakeLists.txt add the components folder to `EXTRA_COMPONENT_DIRS` - make sure this is before the project() config e.g.
193203

194-
Configure your esp32 build environment as for **esp-idf examples**
204+
```cmake
205+
cmake_minimum_required(VERSION 3.5)
195206
196-
Clone the repository
207+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
208+
set(EXTRA_COMPONENT_DIRS
209+
externals/ESP32_TFT_library/components)
197210
198-
`git clone https://github.com/loboris/ESP32_TFT_library.git`
211+
project(hello-world)
212+
```
213+
214+
In your own components/<my-component>/CMakeLists.txt or main/CMakeLists.txt add `tft` and `spiffs` (if you are using spiffs) as `REQUIRES` e.g.
215+
216+
```cmake
217+
set(SOURCES tft_demo.c)
218+
idf_component_register(
219+
SRCS ${SOURCES}
220+
INCLUDE_DIRS
221+
${CMAKE_CURRENT_LIST_DIR}
222+
$ENV{IDF_PATH}/components
223+
REQUIRES
224+
tft
225+
spiffs
226+
)
227+
```
228+
229+
---
230+
231+
#### Building the Demo
232+
233+
Clone the repository to your esp folder (same level as esp-idf, as explained [in instructions](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/index.html)).
234+
235+
`git clone https://github.com/jeremyjh/ESP32_TFT_library.git`
199236

200237
Execute `idf.py menuconfig` and configure your Serial flash config and other settings. Included *sdkconfig.defaults* sets some defaults to be used.
201238

202-
Navigate to **Components -> TFT Display** and set **display** options or select a pre-defined display configuration for a kit.
239+
Navigate to **Components -> TFT Display** and set **display and pin** options or select a pre-defined display configuration for a kit.
203240

204241
To enable **Wifi** in the demo (recommended - gets time from NTP), select **TFT Display DEMO Configuration** from the top-level menu and select those options.
205242

206243
Make and flash the example.
207244

208245
`idf.py build && idf.py -p <PORT> flash monitor`
209246

247+
Deploy the SPIFFS image as below to make the image and font examples work.
248+
210249
---
211250

212251
#### Prepare **SPIFFS** image

main/CMakeLists.txt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1-
set(COMPONENT_SRCDIRS ".")
2-
set(COMPONENT_ADD_INCLUDEDIRS ".")
3-
register_component()
1+
set(SOURCES tft_demo.c)
2+
idf_component_register(
3+
SRCS ${SOURCES}
4+
INCLUDE_DIRS
5+
${CMAKE_CURRENT_LIST_DIR}
6+
$ENV{IDF_PATH}/components
7+
REQUIRES
8+
tft
9+
spiffs
10+
)

main/tft_demo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include "freertos/event_groups.h"
2525
#include "esp_sntp.h"
2626
#include "esp_log.h"
27-
#include "nvs_flash.h"
27+
#include "nvs_flash/include/nvs_flash.h"
2828

2929
#endif
3030

0 commit comments

Comments
 (0)