From 3e11ec2120b4014fa1cc004a43cc3cc37740afc1 Mon Sep 17 00:00:00 2001 From: impressionyang Date: Wed, 21 Jun 2023 00:28:03 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20=E6=9B=B4=E6=96=B0=EF=BC=88lvgl?= =?UTF-8?q?=EF=BC=89=EF=BC=9A=E5=B7=B2=E7=BB=8F=E6=AD=A3=E5=B8=B8=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=20=201.=20=E6=9B=B4=E6=96=B0=E4=BA=86=E5=88=B7?= =?UTF-8?q?=E5=B1=8F=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C=E4=B9=8B=E5=89=8D?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E6=AD=A3=E5=B8=B8=E5=88=B7=E5=B1=8F=E6=98=AF?= =?UTF-8?q?=E5=9B=A0=E4=B8=BA=E5=88=B7=E5=B1=8F=E7=9A=84=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E4=B8=8D=E5=AF=B9Q^Q=20=E7=BB=93=E6=9D=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/components/lvgl-8.3.4/lv_conf.h | 4 +-- main/APP/app_task_display/app_task_display.c | 32 +++++++++++++++---- .../APP/app_task_display/app_task_lvgl_port.c | 14 ++++---- main/drivers/st7789/st7789.c | 10 +++--- 4 files changed, 41 insertions(+), 19 deletions(-) diff --git a/components/components/lvgl-8.3.4/lv_conf.h b/components/components/lvgl-8.3.4/lv_conf.h index a377fff..8f1851b 100644 --- a/components/components/lvgl-8.3.4/lv_conf.h +++ b/components/components/lvgl-8.3.4/lv_conf.h @@ -271,9 +271,9 @@ *-----------*/ /*1: Show CPU usage and FPS count*/ -#define LV_USE_PERF_MONITOR 0 +#define LV_USE_PERF_MONITOR 1 #if LV_USE_PERF_MONITOR - #define LV_USE_PERF_MONITOR_POS LV_ALIGN_BOTTOM_RIGHT + #define LV_USE_PERF_MONITOR_POS LV_ALIGN_TOP_MID #endif /*1: Show the used memory and the memory fragmentation diff --git a/main/APP/app_task_display/app_task_display.c b/main/APP/app_task_display/app_task_display.c index 3a3cbc8..bb3c723 100644 --- a/main/APP/app_task_display/app_task_display.c +++ b/main/APP/app_task_display/app_task_display.c @@ -19,6 +19,8 @@ */ #include "app_task_display.h" #include "freertos/FreeRTOS.h" +#include "esp_freertos_hooks.h" +#include "esp_system.h" #include "freertos/task.h" #include "esp_err.h" #include "esp_log.h" @@ -27,6 +29,8 @@ #include "lv_conf.h" #include "lvgl.h" +#define LV_TICK_PERIOD_MS 1 + TFT_t lcd_disp_dev; TickType_t FillTest(TFT_t* dev, int width, int height) @@ -145,8 +149,8 @@ void lv_example_anim_233333(void) lv_anim_t a; lv_anim_init(&a); lv_anim_set_var(&a, obj); - lv_anim_set_values(&a, 10, 50); - lv_anim_set_time(&a, 1000); + lv_anim_set_values(&a, 10, 40); + lv_anim_set_time(&a, 500); lv_anim_set_playback_delay(&a, 100); lv_anim_set_playback_time(&a, 300); lv_anim_set_repeat_delay(&a, 500); @@ -156,7 +160,7 @@ void lv_example_anim_233333(void) lv_anim_set_exec_cb(&a, anim_size_cb); lv_anim_start(&a); lv_anim_set_exec_cb(&a, anim_x_cb); - lv_anim_set_values(&a, 10, 240); + lv_anim_set_values(&a, 10, 200); lv_anim_start(&a); } @@ -166,16 +170,17 @@ static void _lvgl_thread_entry() { vTaskDelay(10); lcdBacklightOn(&lcd_disp_dev); - FillTest(&lcd_disp_dev, CONFIG_WIDTH, CONFIG_HEIGHT); + // FillTest(&lcd_disp_dev, CONFIG_WIDTH, CONFIG_HEIGHT); lv_init(); lv_port_disp_init(); lv_port_indev_init(); + lcdFillScreen(&lcd_disp_dev, WHITE); lv_example_anim_233333(); while (1) { lv_task_handler(); - vTaskDelay(30); + vTaskDelay(pdMS_TO_TICKS(10)); } } @@ -188,6 +193,12 @@ static void _lvgl_thread_tick_entry() } } +static void lv_tick_task(void *arg) { + (void) arg; + + lv_tick_inc(LV_TICK_PERIOD_MS); +} + uint8_t app_task_display_start() { cst816t_begin(34, 33, 35, 36); @@ -200,8 +211,17 @@ uint8_t app_task_display_start() vTaskDelay(100); lcdFillScreen(&lcd_disp_dev, BLACK); vTaskDelay(100); + /* Create and start a periodic timer interrupt to call lv_tick_inc */ + const esp_timer_create_args_t periodic_timer_args = { + .callback = &lv_tick_task, + .name = "periodic_gui" + }; + esp_timer_handle_t periodic_timer; + ESP_ERROR_CHECK(esp_timer_create(&periodic_timer_args, &periodic_timer)); + ESP_ERROR_CHECK(esp_timer_start_periodic(periodic_timer, LV_TICK_PERIOD_MS * 1000)); + // xTaskCreatePinnedToCore(_display_thread_entry, "dsp test", 4096, NULL, 4, NULL, tskNO_AFFINITY); - xTaskCreatePinnedToCore(_lvgl_thread_tick_entry, "lvgl tick test", 9842, NULL, 5, NULL, tskNO_AFFINITY); + // xTaskCreatePinnedToCore(_lvgl_thread_tick_entry, "lvgl tick test", 9842, NULL, 16, NULL, tskNO_AFFINITY); xTaskCreatePinnedToCore(_lvgl_thread_entry, "lvgl test", 9842, NULL, 4, NULL, tskNO_AFFINITY); #if CONFIG_INVERSION diff --git a/main/APP/app_task_display/app_task_lvgl_port.c b/main/APP/app_task_display/app_task_lvgl_port.c index 66e6919..9c95feb 100644 --- a/main/APP/app_task_display/app_task_lvgl_port.c +++ b/main/APP/app_task_display/app_task_lvgl_port.c @@ -36,13 +36,13 @@ static void lcd_fb_flush(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_colo { static uint16_t datas[DISP_BUF_SIZE] = {0}; int i = 0, j = 0, index = 0; - for ( i = area->x1; i <= area->x2; i++) { - for (j = area->y1; j <= area->y2; j++) { - datas[index++] = color_p->full; - color_p++; - } - } - lcdDrawFillRectData(&lcd_disp_dev, area->x1, area->y1, area->x2, area->y2, datas); + // for ( i = area->y1; i <= area->y2; i++) { + // for (j = area->x1; j <= area->x2; j++) { + // datas[index++] = color_p->full; + // color_p++; + // } + // } + lcdDrawFillRectData(&lcd_disp_dev, area->x1, area->y1, area->x2, area->y2, (uint16_t*)color_p); lv_disp_flush_ready(disp_drv); } diff --git a/main/drivers/st7789/st7789.c b/main/drivers/st7789/st7789.c index da7bb2e..b1e8d2c 100644 --- a/main/drivers/st7789/st7789.c +++ b/main/drivers/st7789/st7789.c @@ -1134,13 +1134,15 @@ void lcdDrawFillRectData(TFT_t * dev, uint16_t x1, uint16_t y1, uint16_t x2, uin spi_master_write_command(dev, 0x2B); // set Page(y) address spi_master_write_addr(dev, _y1, _y2); spi_master_write_command(dev, 0x2C); // Memory Write - for(int i=_x1;i<=_x2;i++){ - uint16_t size = _y2-_y1+1; + // spi_master_write_colors(dev, data, (x2-x1)*(y2-y1)); + for(int i=0;i<=y2 - y1;i++){ + uint16_t size = _x2-_x1; spi_master_write_colors(dev, data, size * 2); + data += (x2 - x1); #if 0 - for(j=y1;j<=y2;j++){ + for(int j=0;j<=x2-x1;j++){ //ESP_LOGD(TAG,"i=%d j=%d",i,j); - spi_master_write_data_word(dev, color); + spi_master_write_data_word(dev, data[i * (y2 - y1) + j]); } #endif }