-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathPorting.ino
92 lines (83 loc) · 3.33 KB
/
Porting.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/**
* # SquareLine Porting Example
*
* The example demonstrates how to port SquareLine (v1.3.x) project. And for RGB LCD, it can enable the avoid tearing function.
*
* ## How to Use
*
* To use this example, please firstly install the following dependent libraries:
*
* - lvgl (>= v8.3.9, < v9)
*
* Follow the steps below to configure:
*
* 1. For **ESP32_Display_Panel**:
*
* - Follow the [steps](https://github.com/esp-arduino-libs/ESP32_Display_Panel/blob/master/docs/How_To_Use.md#configuring-drivers) to configure drivers if needed.
* - If using a supported development board, follow the [steps](https://github.com/esp-arduino-libs/ESP32_Display_Panel/blob/master/docs/How_To_Use.md#using-supported-development-boards) to configure it.
* - If using a custom board, follow the [steps](https://github.com/esp-arduino-libs/ESP32_Display_Panel/blob/master/docs/How_To_Use.md#using-custom-development-boards) to configure it.
*
* 2. For **lvgl**:
*
* - Follow the [steps](https://github.com/esp-arduino-libs/ESP32_Display_Panel/blob/master/docs/How_To_Use.md#configuring-lvgl) to add *lv_conf.h* file and change the configurations.
* - Modify the macros in the [lvgl_port_v8.h](./lvgl_port_v8.h) file to configure the LVGL porting parameters.
*
* 3. Navigate to the `Tools` menu in the Arduino IDE to choose a ESP board and configure its parameters. For supported
* boards, please refter to [Configuring Supported Development Boards](https://github.com/esp-arduino-libs/ESP32_Display_Panel/blob/master/docs/How_To_Use.md#configuring-supported-development-boards)
* 4. Verify and upload the example to your ESP board.
*
* ## Serial Output
*
* ```bash
* ...
* Squareline porting example start
* Initialize panel device
* Initialize LVGL
* Create UI
* Squareline porting example end
* IDLE loop
* IDLE loop
* IDLE loop
* ...
* ```
*
* ## Troubleshooting
*
* Please first check [FAQ](https://github.com/esp-arduino-libs/ESP32_Display_Panel/blob/master/docs/FAQ.md) for troubleshooting. If you still cannot solve the problem, please create a [Github issue](https://github.com/esp-arduino-libs/ESP32_Display_Panel/issues). We will get back to you as soon as possible.
*
*/
#include <Arduino.h>
#include <ESP_Panel_Library.h>
#include <lvgl.h>
#include <ui.h>
#include "lvgl_port_v8.h"
void setup()
{
Serial.begin(115200);
Serial.println("Squareline porting example 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);
/* Initialize LVGL UI generated by Squareline */
ui_init();
/* Release the mutex */
lvgl_port_unlock();
Serial.println("Squareline porting example end");
}
void loop()
{
Serial.println("IDLE loop");
delay(1000);
}