1
1
/* LVGL Example project
2
- *
2
+ *
3
3
* Basic project to test LVGL on ESP32 based projects.
4
4
*
5
5
* This example code is in the Public Domain (or CC0 licensed, at your option.)
@@ -60,7 +60,7 @@ static void create_demo_application(void);
60
60
* APPLICATION MAIN
61
61
**********************/
62
62
void app_main () {
63
-
63
+
64
64
/* If you want to use a task to create the graphic, you NEED to create a Pinned task
65
65
* Otherwise there can be problem such as memory corruption and so on.
66
66
* NOTE: When not using Wi-Fi nor Bluetooth you can pin the guiTask to core 0 */
@@ -73,20 +73,22 @@ void app_main() {
73
73
SemaphoreHandle_t xGuiSemaphore ;
74
74
75
75
static void guiTask (void * pvParameter ) {
76
-
76
+
77
77
(void ) pvParameter ;
78
78
xGuiSemaphore = xSemaphoreCreateMutex ();
79
79
80
80
lv_init ();
81
-
81
+
82
82
/* Initialize SPI or I2C bus used by the drivers */
83
83
lvgl_driver_init ();
84
84
85
- static lv_color_t buf1 [DISP_BUF_SIZE ];
85
+ lv_color_t * buf1 = heap_caps_malloc (DISP_BUF_SIZE * sizeof (lv_color_t ), MALLOC_CAP_DMA );
86
+ assert (buf1 != NULL );
86
87
87
88
/* Use double buffered when not working with monochrome displays */
88
89
#ifndef CONFIG_LV_TFT_DISPLAY_MONOCHROME
89
- static lv_color_t buf2 [DISP_BUF_SIZE ];
90
+ lv_color_t * buf2 = heap_caps_malloc (DISP_BUF_SIZE * sizeof (lv_color_t ), MALLOC_CAP_DMA );
91
+ assert (buf2 != NULL );
90
92
#else
91
93
static lv_color_t * buf2 = NULL ;
92
94
#endif
@@ -98,7 +100,7 @@ static void guiTask(void *pvParameter) {
98
100
#if defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_IL3820 \
99
101
|| defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_JD79653A \
100
102
|| defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_UC8151D
101
-
103
+
102
104
/* Actual size in pixels, not bytes. */
103
105
size_in_px *= 8 ;
104
106
#endif
@@ -130,7 +132,7 @@ static void guiTask(void *pvParameter) {
130
132
indev_drv .type = LV_INDEV_TYPE_POINTER ;
131
133
lv_indev_drv_register (& indev_drv );
132
134
#endif
133
-
135
+
134
136
/* Create and start a periodic timer interrupt to call lv_tick_inc */
135
137
const esp_timer_create_args_t periodic_timer_args = {
136
138
.callback = & lv_tick_task ,
@@ -142,7 +144,7 @@ static void guiTask(void *pvParameter) {
142
144
143
145
/* Create the demo application */
144
146
create_demo_application ();
145
-
147
+
146
148
while (1 ) {
147
149
/* Delay 1 tick (assumes FreeRTOS tick is 10ms */
148
150
vTaskDelay (pdMS_TO_TICKS (10 ));
@@ -155,16 +157,20 @@ static void guiTask(void *pvParameter) {
155
157
}
156
158
157
159
/* A task should NEVER return */
160
+ free (buf1 );
161
+ #ifndef CONFIG_LV_TFT_DISPLAY_MONOCHROME
162
+ free (buf2 );
163
+ #endif
158
164
vTaskDelete (NULL );
159
165
}
160
166
161
167
static void create_demo_application (void )
162
168
{
163
- /* When using a monochrome display we only show "Hello World" centered on the
169
+ /* When using a monochrome display we only show "Hello World" centered on the
164
170
* screen */
165
171
#if defined CONFIG_LV_TFT_DISPLAY_MONOCHROME || \
166
172
defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7735S
167
-
173
+
168
174
/* use a pretty small demo for monochrome displays */
169
175
/* Get the current screen */
170
176
lv_obj_t * scr = lv_disp_get_scr_act (NULL );
0 commit comments