11
11
#include "lvgl/lvgl.h"
12
12
#include "lvgl_port.h"
13
13
14
- #define LVGL_DRAW_BUF_LINES 20 // number of display lines in each draw buffer
14
+ #define LVGL_DRAW_BUF_LINES 50 // number of display lines in each draw buffer
15
15
#define LVGL_TICK_PERIOD_MS 2
16
16
#define LVGL_TASK_MAX_DELAY_MS 500
17
17
#define LVGL_TASK_MIN_DELAY_MS 1
18
18
#define LVGL_TASK_STACK_SIZE (6 * 1024)
19
- #define LVGL_TASK_PRIORITY 2
19
+ #define LVGL_TASK_PRIORITY (4)
20
20
21
21
static _lock_t lvgl_api_lock ;
22
22
static const char * TAG = "lvgl_port" ;
@@ -29,38 +29,38 @@ bool lvgl_port_notify_lvgl_flush_ready(esp_lcd_panel_io_handle_t panel_io, esp_l
29
29
}
30
30
31
31
/* Rotate display and touch, when rotated screen in LVGL. Called when driver parameters are updated. */
32
- static void lvgl_port_update_callback (lv_display_t * disp )
33
- {
34
- esp_lcd_panel_handle_t panel_handle = lv_display_get_user_data (disp );
35
- lv_display_rotation_t rotation = lv_display_get_rotation (disp );
36
-
37
- switch (rotation ) {
38
- case LV_DISPLAY_ROTATION_0 :
39
- // Rotate LCD display
40
- esp_lcd_panel_swap_xy (panel_handle , false);
41
- esp_lcd_panel_mirror (panel_handle , true, false);
42
- break ;
43
- case LV_DISPLAY_ROTATION_90 :
44
- // Rotate LCD display
45
- esp_lcd_panel_swap_xy (panel_handle , true);
46
- esp_lcd_panel_mirror (panel_handle , true, true);
47
- break ;
48
- case LV_DISPLAY_ROTATION_180 :
49
- // Rotate LCD display
50
- esp_lcd_panel_swap_xy (panel_handle , false);
51
- esp_lcd_panel_mirror (panel_handle , false, true);
52
- break ;
53
- case LV_DISPLAY_ROTATION_270 :
54
- // Rotate LCD display
55
- esp_lcd_panel_swap_xy (panel_handle , true);
56
- esp_lcd_panel_mirror (panel_handle , false, false);
57
- break ;
58
- }
59
- }
32
+ // static void lvgl_port_update_callback(lv_display_t *disp)
33
+ // {
34
+ // esp_lcd_panel_handle_t panel_handle = lv_display_get_user_data(disp);
35
+ // lv_display_rotation_t rotation = lv_display_get_rotation(disp);
36
+
37
+ // switch (rotation) {
38
+ // case LV_DISPLAY_ROTATION_0:
39
+ // // Rotate LCD display
40
+ // esp_lcd_panel_swap_xy(panel_handle, false);
41
+ // esp_lcd_panel_mirror(panel_handle, true, false);
42
+ // break;
43
+ // case LV_DISPLAY_ROTATION_90:
44
+ // // Rotate LCD display
45
+ // esp_lcd_panel_swap_xy(panel_handle, true);
46
+ // esp_lcd_panel_mirror(panel_handle, true, true);
47
+ // break;
48
+ // case LV_DISPLAY_ROTATION_180:
49
+ // // Rotate LCD display
50
+ // esp_lcd_panel_swap_xy(panel_handle, false);
51
+ // esp_lcd_panel_mirror(panel_handle, false, true);
52
+ // break;
53
+ // case LV_DISPLAY_ROTATION_270:
54
+ // // Rotate LCD display
55
+ // esp_lcd_panel_swap_xy(panel_handle, true);
56
+ // esp_lcd_panel_mirror(panel_handle, false, false);
57
+ // break;
58
+ // }
59
+ // }
60
60
61
61
static void lvgl_flush_cb (lv_display_t * disp , const lv_area_t * area , uint8_t * px_map )
62
62
{
63
- lvgl_port_update_callback (disp );
63
+ // lvgl_port_update_callback(disp);
64
64
esp_lcd_panel_handle_t panel_handle = lv_display_get_user_data (disp );
65
65
int offsetx1 = area -> x1 ;
66
66
int offsetx2 = area -> x2 ;
@@ -72,6 +72,12 @@ static void lvgl_flush_cb(lv_display_t *disp, const lv_area_t *area, uint8_t *px
72
72
esp_lcd_panel_draw_bitmap (panel_handle , offsetx1 , offsety1 , offsetx2 + 1 , offsety2 + 1 , px_map );
73
73
}
74
74
75
+ static void lvgl_flush_wait_cb (lv_display_t * disp )
76
+ {
77
+ // wait for the flush to be ready
78
+ vTaskDelay (pdMS_TO_TICKS (LVGL_TASK_MIN_DELAY_MS ));
79
+ }
80
+
75
81
static void lvgl_touch_cb (lv_indev_t * indev , lv_indev_data_t * data )
76
82
{
77
83
uint16_t touchpad_x [1 ] = {0 };
@@ -108,13 +114,13 @@ static MP_DEFINE_CONST_FUN_OBJ_1(mp_lv_task_handler_obj, mp_lv_task_handler);
108
114
static void lvgl_port_task (void * arg )
109
115
{
110
116
printf ("Starting LVGL task\n" );
111
- uint32_t time_till_next_ms = 5 ;
117
+ uint32_t time_till_next_ms = 10 ;
112
118
// uint32_t time_threshold_ms = 1000 / CONFIG_FREERTOS_HZ;
113
119
while (1 ) {
114
120
mp_sched_schedule ((mp_obj_t )& mp_lv_task_handler_obj , mp_const_none );
115
121
// in case of triggering a task watch dog time out
116
122
// time_till_next_ms = MAX(time_till_next_ms, time_threshold_ms);
117
- usleep ( 1000 * time_till_next_ms );
123
+ vTaskDelay ( pdMS_TO_TICKS ( time_till_next_ms ) );
118
124
}
119
125
}
120
126
@@ -142,6 +148,7 @@ lv_display_t *lvgl_port_init(int h_res, int v_res, esp_lcd_panel_handle_t panel_
142
148
lv_display_set_color_format (display , LV_COLOR_FORMAT_RGB565 );
143
149
// set the callback which can copy the rendered image to an area of the display
144
150
lv_display_set_flush_cb (display , lvgl_flush_cb );
151
+ lv_display_set_flush_wait_cb (display , lvgl_flush_wait_cb );
145
152
146
153
printf ("Install LVGL tick timer\n" );
147
154
// Tick interface for LVGL (using esp_timer to generate 2ms periodic event)
0 commit comments