Skip to content

Commit e894e32

Browse files
IT: Sop.SonLzw655
IT: Sop.Son
authored andcommitted
feat(example): add support for PlatformIO by @isthaison (#37)
Closes #37
1 parent 9cdc53e commit e894e32

File tree

11 files changed

+2231
-0
lines changed

11 files changed

+2231
-0
lines changed

examples/platformio/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.pio
2+
.vscode/.browse.c_cpp.db*
3+
.vscode/c_cpp_properties.json
4+
.vscode/launch.json
5+
.vscode/ipch

examples/platformio/README.md

Whitespace-only changes.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"build": {
3+
"arduino": {
4+
"ldscript": "esp32s3_out.ld",
5+
"partitions": "default_16MB.csv",
6+
"memory_type": "qio_opi"
7+
},
8+
"core": "esp32",
9+
"extra_flags": [
10+
"-DBOARD_HAS_PSRAM",
11+
"-DARDUINO_USB_MODE=1",
12+
"-DARDUINO_RUNNING_CORE=1",
13+
"-DARDUINO_EVENT_RUNNING_CORE=1"
14+
],
15+
"f_cpu": "240000000L",
16+
"f_flash": "80000000L",
17+
"flash_mode": "qio",
18+
"hwids": [["0x303A", "0x1001"]],
19+
"mcu": "esp32s3",
20+
"variant": "esp32s3"
21+
},
22+
"connectivity": ["wifi"],
23+
"debug": {
24+
"default_tool": "esp-builtin",
25+
"onboard_tools": ["esp-builtin"],
26+
"openocd_target": "esp32s3.cfg"
27+
},
28+
"frameworks": ["arduino", "espidf"],
29+
"name": "ESP-LCD (16M Flash 8M OPI PSRAM )",
30+
"upload": {
31+
"flash_size": "16MB",
32+
"maximum_ram_size": 327680,
33+
"maximum_size": 16777216,
34+
"require_upload_port": true,
35+
"speed": 921600
36+
},
37+
"url": "https://www.espressif.com",
38+
"vendor": "ESP-LCD"
39+
}

examples/platformio/platformio.ini

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[env:ESP-LCD]
2+
platform = espressif32
3+
board = ESP-LCD
4+
framework = arduino
5+
platform_packages =
6+
platformio/framework-arduinoespressif32@https://github.com/espressif/arduino-esp32.git
7+
platformio/framework-arduinoespressif32-libs@https://github.com/espressif/esp32-arduino-libs.git#idf-release/v5.1
8+
upload_speed = 921600
9+
monitor_speed = 115200
10+
build_flags =
11+
-DBOARD_HAS_PSRAM
12+
-DLV_CONF_INCLUDE_SIMPLE
13+
-DDISABLE_ALL_LIBRARY_WARNINGS
14+
-DARDUINO_USB_CDC_ON_BOOT=1
15+
-DCORE_DEBUG_LEVEL=1
16+
-DLV_LVGL_H_INCLUDE_SIMPLE
17+
-I src
18+
lib_deps =
19+
https://github.com/esp-arduino-libs/ESP32_Display_Panel.git
20+
https://github.com/esp-arduino-libs/ESP32_IO_Expander.git
21+
https://github.com/lvgl/lvgl.git#release/v8.3
22+

examples/platformio/src/ESP_Panel_Board_Custom.h

Lines changed: 369 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#pragma once
8+
9+
/* Set to 1 if using a supported board */
10+
#define ESP_PANEL_USE_SUPPORTED_BOARD (0) // 0/1
11+
12+
#if ESP_PANEL_USE_SUPPORTED_BOARD
13+
/**
14+
* Uncomment one of the following macros to select an supported development board. If multiple macros are uncommented
15+
* at the same time, an error will be prompted during compilation.
16+
*
17+
*/
18+
19+
/*
20+
* Espressif Supported Boards (https://www.espressif.com/en/products/devkits):
21+
*
22+
* - ESP32-C3-LCDkit: https://docs.espressif.com/projects/esp-dev-kits/en/latest/esp32c3/esp32-c3-lcdkit/index.html
23+
* - ESP32-S3-Box: https://github.com/espressif/esp-box/tree/master
24+
* - ESP32-S3-Box-3: https://github.com/espressif/esp-box/tree/master
25+
* - ESP32-S3-Box-3(beta): https://github.com/espressif/esp-box/tree/c4c954888e11250423f083df0067d99e22d59fbe
26+
* - ESP32-S3-Box-Lite: https://github.com/espressif/esp-box/tree/master
27+
* - ESP32-S3-EYE: https://github.com/espressif/esp-who/blob/master/docs/en/get-started/ESP32-S3-EYE_Getting_Started_Guide.md
28+
* - ESP32-S3-Korvo-2: https://docs.espressif.com/projects/esp-adf/en/latest/design-guide/dev-boards/user-guide-esp32-s3-korvo-2.html
29+
* - ESP32-S3-LCD-EV-Board: https://docs.espressif.com/projects/esp-dev-kits/en/latest/esp32s3/esp32-s3-lcd-ev-board/user_guide_v1.4.html
30+
* - ESP32-S3-LCD-EV-Board(v1.5): https://docs.espressif.com/projects/esp-dev-kits/en/latest/esp32s3/esp32-s3-lcd-ev-board/user_guide.html
31+
* - ESP32-S3-LCD-EV-Board-2: https://docs.espressif.com/projects/esp-dev-kits/en/latest/esp32s3/esp32-s3-lcd-ev-board/user_guide_v1.4.html
32+
* - ESP32-S3-LCD-EV-Board-2(v1.5): https://docs.espressif.com/projects/esp-dev-kits/en/latest/esp32s3/esp32-s3-lcd-ev-board/user_guide.html
33+
* - ESP32-S3-USB-OTG: https://docs.espressif.com/projects/esp-dev-kits/en/latest/esp32s3/esp32-s3-usb-otg/index.html
34+
*
35+
*/
36+
// #define BOARD_ESP32_C3_LCDKIT
37+
// #define BOARD_ESP32_S3_BOX
38+
// #define BOARD_ESP32_S3_BOX_3
39+
// #define BOARD_ESP32_S3_BOX_3_BETA
40+
// #define BOARD_ESP32_S3_BOX_LITE
41+
// #define BOARD_ESP32_S3_EYE
42+
// #define BOARD_ESP32_S3_KORVO_2
43+
// #define BOARD_ESP32_S3_LCD_EV_BOARD
44+
// #define BOARD_ESP32_S3_LCD_EV_BOARD_V1_5
45+
// #define BOARD_ESP32_S3_LCD_EV_BOARD_2
46+
// #define BOARD_ESP32_S3_LCD_EV_BOARD_2_V1_5
47+
// #define BOARD_ESP32_S3_USB_OTG
48+
49+
/*
50+
* Shenzhen Jingcai Intelligent Supported Boards (https://www.displaysmodule.com/):
51+
*
52+
* - ESP32-4848S040C_I_Y_3:
53+
* - https://www.displaysmodule.com/sale-41828962-experience-the-power-of-the-esp32-display-module-sku-esp32-4848s040c-i-y-3.html
54+
* - http://pan.jczn1688.com/directlink/1/ESP32%20module/4.0inch_ESP32-4848S040.zip
55+
*
56+
*/
57+
// #define BOARD_ESP32_4848S040C_I_Y_3
58+
59+
/**
60+
* Do not change the following versions, they are used to check if the configurations in this file are compatible with
61+
* the current version of `ESP_Panel_Board_Supported.h` in the library. The detailed rules are as follows:
62+
*
63+
* 1. If the major version is not consistent, then the configurations in this file are incompatible with the library
64+
* and must be replaced with the file from the library.
65+
* 2. If the minor version is not consistent, this file might be missing some new configurations, which will be set to
66+
* default values. It is recommended to replace it with the file from the library.
67+
* 3. If the patch version is not consistent, it will not affect normal functionality.
68+
*
69+
*/
70+
#define ESP_PANEL_BOARD_SUPPORTED_FILE_VERSION_MAJOR 0
71+
#define ESP_PANEL_BOARD_SUPPORTED_FILE_VERSION_MINOR 1
72+
#define ESP_PANEL_BOARD_SUPPORTED_FILE_VERSION_PATCH 0
73+
74+
#endif
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/**
2+
* Debug configurations
3+
*
4+
*/
5+
/* Set to 1 if assert on error. Otherwise print error message */
6+
#define ESP_PANEL_CHECK_RESULT_ASSERT (0) // 0/1
7+
8+
/* Set to 1 if print log message for debug */
9+
#define ESP_PANEL_ENABLE_LOG (0) // 0/1
10+
11+
/**
12+
* Touch driver configurations
13+
*
14+
*/
15+
/* Maximum point number */
16+
#define ESP_PANEL_TOUCH_MAX_POINTS (3)
17+
18+
/* Maximum button number */
19+
#define ESP_PANEL_TOUCH_MAX_BUTTONS (1)
20+
21+
/* Model configurations */
22+
// XPT2046
23+
#define ESP_PANEL_TOUCH_XPT2046_Z_THRESHOLD (400) // Minimum Z pressure threshold
24+
/**
25+
* Enable Interrupt (PENIRQ) output, also called Full Power Mode.
26+
* Enable this to configure the XPT2046 to output low on the PENIRQ output if a touch is detected.
27+
* This mode uses more power when enabled. Note that this signal goes low normally when a read is active.
28+
*/
29+
#define ESP_PANEL_TOUCH_XPT2046_INTERRUPT_MODE (0) // 0/1
30+
/**
31+
* Keep internal Vref enabled.
32+
* Enable this to keep the internal Vref enabled between conversions. This uses slightly more power,
33+
* but requires fewer transactions when reading the battery voltage, aux voltage and temperature.
34+
*
35+
*/
36+
#define ESP_PANEL_TOUCH_XPT2046_VREF_ON_MODE (0) // 0/1
37+
/**
38+
* Convert touch coordinates to screen coordinates.
39+
* When this option is enabled the raw ADC values will be converted from 0-4096 to 0-{screen width} or 0-{screen height}.
40+
* When this option is disabled the process_coordinates method will need to be used to convert the raw ADC values into a
41+
* screen coordinate.
42+
*
43+
*/
44+
#define ESP_PANEL_TOUCH_XPT2046_CONVERT_ADC_TO_COORDS (1) // 0/1
45+
/**
46+
* Enable data structure locking.
47+
* By enabling this option the XPT2046 driver will lock the touch position data structures when reading values from the
48+
* XPT2046 and when reading position data via API.
49+
* WARNING: enabling this option may result in unintended crashes.
50+
*
51+
*/
52+
#define ESP_PANEL_TOUCH_XPT2046_ENABLE_LOCKING (0) // 0/1

examples/platformio/src/app.cpp

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
2+
#include <Arduino.h>
3+
#include <ESP_Panel_Library.h>
4+
#include <lvgl.h>
5+
#include "lvgl_port_v8.h"
6+
7+
/**
8+
/* To use the built-in examples and demos of LVGL uncomment the includes below respectively.
9+
* You also need to copy `lvgl/examples` to `lvgl/src/examples`. Similarly for the demos `lvgl/demos` to `lvgl/src/demos`.
10+
*/
11+
// #include <demos/lv_demos.h>
12+
// #include <examples/lv_examples.h>
13+
14+
void setup()
15+
{
16+
String title = "LVGL porting example";
17+
18+
Serial.begin(115200);
19+
Serial.println(title + " start");
20+
21+
Serial.println("Initialize panel device");
22+
ESP_Panel *panel = new ESP_Panel();
23+
panel->init();
24+
#if LVGL_PORT_AVOID_TEAR
25+
// When avoid tearing function is enabled, configure the RGB bus according to the LVGL configuration
26+
ESP_PanelBus_RGB *rgb_bus = static_cast<ESP_PanelBus_RGB *>(panel->getLcd()->getBus());
27+
rgb_bus->configRgbFrameBufferNumber(LVGL_PORT_DISP_BUFFER_NUM);
28+
rgb_bus->configRgbBounceBufferSize(LVGL_PORT_RGB_BOUNCE_BUFFER_SIZE);
29+
#endif
30+
panel->begin();
31+
32+
Serial.println("Initialize LVGL");
33+
lvgl_port_init(panel->getLcd(), panel->getTouch());
34+
35+
Serial.println("Create UI");
36+
/* Lock the mutex due to the LVGL APIs are not thread-safe */
37+
lvgl_port_lock(-1);
38+
39+
/* Create a simple label */
40+
lv_obj_t *label = lv_label_create(lv_scr_act());
41+
lv_label_set_text(label, title.c_str());
42+
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
43+
44+
/**
45+
* Try an example. Don't forget to uncomment header.
46+
* See all the examples online: https://docs.lvgl.io/master/examples.html
47+
* source codes: https://github.com/lvgl/lvgl/tree/e7f88efa5853128bf871dde335c0ca8da9eb7731/examples
48+
*/
49+
// lv_example_btn_1();
50+
51+
/**
52+
* Or try out a demo.
53+
* Don't forget to uncomment header and enable the demos in `lv_conf.h`. E.g. `LV_USE_DEMOS_WIDGETS`
54+
*/
55+
// lv_demo_widgets();
56+
// lv_demo_benchmark();
57+
// lv_demo_music();
58+
// lv_demo_stress();
59+
60+
/* Release the mutex */
61+
lvgl_port_unlock();
62+
63+
Serial.println(title + " end");
64+
}
65+
66+
void loop()
67+
{
68+
Serial.println("IDLE loop");
69+
delay(1000);
70+
}

0 commit comments

Comments
 (0)