Skip to content

add example build with PlatformIO #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions examples/platformio/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
Empty file added examples/platformio/README.md
Empty file.
39 changes: 39 additions & 0 deletions examples/platformio/boards/ESP-LCD.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"build": {
"arduino": {
"ldscript": "esp32s3_out.ld",
"partitions": "default_16MB.csv",
"memory_type": "qio_opi"
},
"core": "esp32",
"extra_flags": [
"-DBOARD_HAS_PSRAM",
"-DARDUINO_USB_MODE=1",
"-DARDUINO_RUNNING_CORE=1",
"-DARDUINO_EVENT_RUNNING_CORE=1"
],
"f_cpu": "240000000L",
"f_flash": "80000000L",
"flash_mode": "qio",
"hwids": [["0x303A", "0x1001"]],
"mcu": "esp32s3",
"variant": "esp32s3"
},
"connectivity": ["wifi"],
"debug": {
"default_tool": "esp-builtin",
"onboard_tools": ["esp-builtin"],
"openocd_target": "esp32s3.cfg"
},
"frameworks": ["arduino", "espidf"],
"name": "ESP-LCD (16M Flash 8M OPI PSRAM )",
"upload": {
"flash_size": "16MB",
"maximum_ram_size": 327680,
"maximum_size": 16777216,
"require_upload_port": true,
"speed": 921600
},
"url": "https://www.espressif.com",
"vendor": "ESP-LCD"
}
22 changes: 22 additions & 0 deletions examples/platformio/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[env:ESP-LCD]
platform = espressif32
board = ESP-LCD
framework = arduino
platform_packages =
platformio/framework-arduinoespressif32@https://github.com/espressif/arduino-esp32.git
platformio/framework-arduinoespressif32-libs@https://github.com/espressif/esp32-arduino-libs.git#idf-release/v5.1
upload_speed = 921600
monitor_speed = 115200
build_flags =
-DBOARD_HAS_PSRAM
-DLV_CONF_INCLUDE_SIMPLE
-DDISABLE_ALL_LIBRARY_WARNINGS
-DARDUINO_USB_CDC_ON_BOOT=1
-DCORE_DEBUG_LEVEL=1
-DLV_LVGL_H_INCLUDE_SIMPLE
-I src
lib_deps =
https://github.com/esp-arduino-libs/ESP32_Display_Panel.git
https://github.com/esp-arduino-libs/ESP32_IO_Expander.git
https://github.com/lvgl/lvgl.git#release/v8.3

369 changes: 369 additions & 0 deletions examples/platformio/src/ESP_Panel_Board_Custom.h

Large diffs are not rendered by default.

74 changes: 74 additions & 0 deletions examples/platformio/src/ESP_Panel_Board_Supported.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

#pragma once

/* Set to 1 if using a supported board */
#define ESP_PANEL_USE_SUPPORTED_BOARD (0) // 0/1

#if ESP_PANEL_USE_SUPPORTED_BOARD
/**
* Uncomment one of the following macros to select an supported development board. If multiple macros are uncommented
* at the same time, an error will be prompted during compilation.
*
*/

/*
* Espressif Supported Boards (https://www.espressif.com/en/products/devkits):
*
* - ESP32-C3-LCDkit: https://docs.espressif.com/projects/esp-dev-kits/en/latest/esp32c3/esp32-c3-lcdkit/index.html
* - ESP32-S3-Box: https://github.com/espressif/esp-box/tree/master
* - ESP32-S3-Box-3: https://github.com/espressif/esp-box/tree/master
* - ESP32-S3-Box-3(beta): https://github.com/espressif/esp-box/tree/c4c954888e11250423f083df0067d99e22d59fbe
* - ESP32-S3-Box-Lite: https://github.com/espressif/esp-box/tree/master
* - ESP32-S3-EYE: https://github.com/espressif/esp-who/blob/master/docs/en/get-started/ESP32-S3-EYE_Getting_Started_Guide.md
* - ESP32-S3-Korvo-2: https://docs.espressif.com/projects/esp-adf/en/latest/design-guide/dev-boards/user-guide-esp32-s3-korvo-2.html
* - 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
* - 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
* - 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
* - 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
* - ESP32-S3-USB-OTG: https://docs.espressif.com/projects/esp-dev-kits/en/latest/esp32s3/esp32-s3-usb-otg/index.html
*
*/
// #define BOARD_ESP32_C3_LCDKIT
// #define BOARD_ESP32_S3_BOX
// #define BOARD_ESP32_S3_BOX_3
// #define BOARD_ESP32_S3_BOX_3_BETA
// #define BOARD_ESP32_S3_BOX_LITE
// #define BOARD_ESP32_S3_EYE
// #define BOARD_ESP32_S3_KORVO_2
// #define BOARD_ESP32_S3_LCD_EV_BOARD
// #define BOARD_ESP32_S3_LCD_EV_BOARD_V1_5
// #define BOARD_ESP32_S3_LCD_EV_BOARD_2
// #define BOARD_ESP32_S3_LCD_EV_BOARD_2_V1_5
// #define BOARD_ESP32_S3_USB_OTG

/*
* Shenzhen Jingcai Intelligent Supported Boards (https://www.displaysmodule.com/):
*
* - ESP32-4848S040C_I_Y_3:
* - https://www.displaysmodule.com/sale-41828962-experience-the-power-of-the-esp32-display-module-sku-esp32-4848s040c-i-y-3.html
* - http://pan.jczn1688.com/directlink/1/ESP32%20module/4.0inch_ESP32-4848S040.zip
*
*/
// #define BOARD_ESP32_4848S040C_I_Y_3

/**
* Do not change the following versions, they are used to check if the configurations in this file are compatible with
* the current version of `ESP_Panel_Board_Supported.h` in the library. The detailed rules are as follows:
*
* 1. If the major version is not consistent, then the configurations in this file are incompatible with the library
* and must be replaced with the file from the library.
* 2. If the minor version is not consistent, this file might be missing some new configurations, which will be set to
* default values. It is recommended to replace it with the file from the library.
* 3. If the patch version is not consistent, it will not affect normal functionality.
*
*/
#define ESP_PANEL_BOARD_SUPPORTED_FILE_VERSION_MAJOR 0
#define ESP_PANEL_BOARD_SUPPORTED_FILE_VERSION_MINOR 1
#define ESP_PANEL_BOARD_SUPPORTED_FILE_VERSION_PATCH 0

#endif
52 changes: 52 additions & 0 deletions examples/platformio/src/ESP_Panel_Conf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* Debug configurations
*
*/
/* Set to 1 if assert on error. Otherwise print error message */
#define ESP_PANEL_CHECK_RESULT_ASSERT (0) // 0/1

/* Set to 1 if print log message for debug */
#define ESP_PANEL_ENABLE_LOG (0) // 0/1

/**
* Touch driver configurations
*
*/
/* Maximum point number */
#define ESP_PANEL_TOUCH_MAX_POINTS (3)

/* Maximum button number */
#define ESP_PANEL_TOUCH_MAX_BUTTONS (1)

/* Model configurations */
// XPT2046
#define ESP_PANEL_TOUCH_XPT2046_Z_THRESHOLD (400) // Minimum Z pressure threshold
/**
* Enable Interrupt (PENIRQ) output, also called Full Power Mode.
* Enable this to configure the XPT2046 to output low on the PENIRQ output if a touch is detected.
* This mode uses more power when enabled. Note that this signal goes low normally when a read is active.
*/
#define ESP_PANEL_TOUCH_XPT2046_INTERRUPT_MODE (0) // 0/1
/**
* Keep internal Vref enabled.
* Enable this to keep the internal Vref enabled between conversions. This uses slightly more power,
* but requires fewer transactions when reading the battery voltage, aux voltage and temperature.
*
*/
#define ESP_PANEL_TOUCH_XPT2046_VREF_ON_MODE (0) // 0/1
/**
* Convert touch coordinates to screen coordinates.
* When this option is enabled the raw ADC values will be converted from 0-4096 to 0-{screen width} or 0-{screen height}.
* When this option is disabled the process_coordinates method will need to be used to convert the raw ADC values into a
* screen coordinate.
*
*/
#define ESP_PANEL_TOUCH_XPT2046_CONVERT_ADC_TO_COORDS (1) // 0/1
/**
* Enable data structure locking.
* By enabling this option the XPT2046 driver will lock the touch position data structures when reading values from the
* XPT2046 and when reading position data via API.
* WARNING: enabling this option may result in unintended crashes.
*
*/
#define ESP_PANEL_TOUCH_XPT2046_ENABLE_LOCKING (0) // 0/1
70 changes: 70 additions & 0 deletions examples/platformio/src/app.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@

#include <Arduino.h>
#include <ESP_Panel_Library.h>
#include <lvgl.h>
#include "lvgl_port_v8.h"

/**
/* To use the built-in examples and demos of LVGL uncomment the includes below respectively.
* You also need to copy `lvgl/examples` to `lvgl/src/examples`. Similarly for the demos `lvgl/demos` to `lvgl/src/demos`.
*/
// #include <demos/lv_demos.h>
// #include <examples/lv_examples.h>

void setup()
{
String title = "LVGL porting example";

Serial.begin(115200);
Serial.println(title + " start");

Serial.println("Initialize panel device");
ESP_Panel *panel = new ESP_Panel();
panel->init();
#if LVGL_PORT_AVOID_TEAR
// When avoid tearing function is enabled, configure the RGB bus according to the LVGL configuration
ESP_PanelBus_RGB *rgb_bus = static_cast<ESP_PanelBus_RGB *>(panel->getLcd()->getBus());
rgb_bus->configRgbFrameBufferNumber(LVGL_PORT_DISP_BUFFER_NUM);
rgb_bus->configRgbBounceBufferSize(LVGL_PORT_RGB_BOUNCE_BUFFER_SIZE);
#endif
panel->begin();

Serial.println("Initialize LVGL");
lvgl_port_init(panel->getLcd(), panel->getTouch());

Serial.println("Create UI");
/* Lock the mutex due to the LVGL APIs are not thread-safe */
lvgl_port_lock(-1);

/* Create a simple label */
lv_obj_t *label = lv_label_create(lv_scr_act());
lv_label_set_text(label, title.c_str());
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);

/**
* Try an example. Don't forget to uncomment header.
* See all the examples online: https://docs.lvgl.io/master/examples.html
* source codes: https://github.com/lvgl/lvgl/tree/e7f88efa5853128bf871dde335c0ca8da9eb7731/examples
*/
// lv_example_btn_1();

/**
* Or try out a demo.
* Don't forget to uncomment header and enable the demos in `lv_conf.h`. E.g. `LV_USE_DEMOS_WIDGETS`
*/
// lv_demo_widgets();
// lv_demo_benchmark();
// lv_demo_music();
// lv_demo_stress();

/* Release the mutex */
lvgl_port_unlock();

Serial.println(title + " end");
}

void loop()
{
Serial.println("IDLE loop");
delay(1000);
}
Loading
Loading