Skip to content

Commit

Permalink
Little LVGL Optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
jgauchia committed Jun 25, 2024
1 parent 7e08145 commit bf629f2
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
2 changes: 2 additions & 0 deletions lib/gui/src/mainScr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ void unselectWidget(lv_event_t *event)
lv_obj_add_flag(tilesScreen, LV_OBJ_FLAG_SCROLLABLE);
widgetSelected = false;
}
isScrolled = true;
}
}

Expand All @@ -85,6 +86,7 @@ void dragWidget(lv_event_t *event)
{
if (canMoveWidget)
{
isScrolled = false;
lv_obj_t *obj = (lv_obj_t *)lv_event_get_target(event);
if (!widgetSelected)
{
Expand Down
4 changes: 2 additions & 2 deletions lib/lvgl/lvgl_ESP32S3_N16R8_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
*====================*/

/*Default display refresh period. LVG will redraw changed areas with this period time*/
#define LV_DEF_REFR_PERIOD 30 /*[ms]*/
#define LV_DEF_REFR_PERIOD 10 /*[ms]*/

/*Default Dot Per Inch. Used to initialize default sizes such as widgets sized, style paddings.
*(Not so important, you can adjust it to modify default sizes and spaces)*/
Expand Down Expand Up @@ -303,7 +303,7 @@
#define LV_COLOR_MIX_ROUND_OFS 0

/* Add 2 x 32 bit variables to each lv_obj_t to speed up getting style properties */
#define LV_OBJ_STYLE_CACHE 0
#define LV_OBJ_STYLE_CACHE 1

/* Add `id` field to `lv_obj_t` */
#define LV_USE_OBJ_ID 0
Expand Down
4 changes: 2 additions & 2 deletions lib/lvgl/lvgl_ESP32_N16R4_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
*====================*/

/*Default display refresh period. LVG will redraw changed areas with this period time*/
#define LV_DEF_REFR_PERIOD 30 /*[ms]*/
#define LV_DEF_REFR_PERIOD 10 /*[ms]*/

/*Default Dot Per Inch. Used to initialize default sizes such as widgets sized, style paddings.
*(Not so important, you can adjust it to modify default sizes and spaces)*/
Expand Down Expand Up @@ -303,7 +303,7 @@
#define LV_COLOR_MIX_ROUND_OFS 0

/* Add 2 x 32 bit variables to each lv_obj_t to speed up getting style properties */
#define LV_OBJ_STYLE_CACHE 0
#define LV_OBJ_STYLE_CACHE 1

/* Add `id` field to `lv_obj_t` */
#define LV_USE_OBJ_ID 0
Expand Down
4 changes: 2 additions & 2 deletions lib/lvgl/lvgl_MAKERF_ESP32S3_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
*====================*/

/*Default display refresh period. LVG will redraw changed areas with this period time*/
#define LV_DEF_REFR_PERIOD 30 /*[ms]*/
#define LV_DEF_REFR_PERIOD 10 /*[ms]*/

/*Default Dot Per Inch. Used to initialize default sizes such as widgets sized, style paddings.
*(Not so important, you can adjust it to modify default sizes and spaces)*/
Expand Down Expand Up @@ -303,7 +303,7 @@
#define LV_COLOR_MIX_ROUND_OFS 0

/* Add 2 x 32 bit variables to each lv_obj_t to speed up getting style properties */
#define LV_OBJ_STYLE_CACHE 0
#define LV_OBJ_STYLE_CACHE 1

/* Add `id` field to `lv_obj_t` */
#define LV_USE_OBJ_ID 0
Expand Down
16 changes: 12 additions & 4 deletions lib/lvgl/src/lvglSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,18 @@ void displayFlush(lv_display_t *disp, const lv_area_t *area, uint8_t *px_map)
{
uint32_t w = (area->x2 - area->x1 + 1);
uint32_t h = (area->y2 - area->y1 + 1);
tft.startWrite();
//tft.startWrite();
if (tft.getStartCount() == 0)
tft.startWrite();


tft.setAddrWindow(area->x1, area->y1, w, h);
tft.pushPixels((uint16_t *)px_map, w * h, true);
tft.endWrite();

//tft.endWrite();
if (tft.getStartCount() > 0)
tft.endWrite();

lv_display_flush_ready(disp);
}

Expand Down Expand Up @@ -145,8 +153,8 @@ void initLVGL()
DRAW_BUF_SIZE = ( TFT_WIDTH * TFT_HEIGHT * sizeof(lv_color_t) / 8);

log_v("LVGL: allocating %u bytes PSRAM for draw buffer",DRAW_BUF_SIZE * 2);
lv_color_t * drawBuf1 = (lv_color_t *)heap_caps_malloc(DRAW_BUF_SIZE, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
lv_color_t * drawBuf2 = (lv_color_t *)heap_caps_malloc(DRAW_BUF_SIZE, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
lv_color_t * drawBuf1 = (lv_color_t *)heap_caps_aligned_alloc(16, DRAW_BUF_SIZE, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
lv_color_t * drawBuf2 = (lv_color_t *)heap_caps_aligned_alloc(16, DRAW_BUF_SIZE, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
lv_display_set_buffers(display, drawBuf1, drawBuf2, DRAW_BUF_SIZE, LV_DISPLAY_RENDER_MODE_PARTIAL);

#else
Expand Down

0 comments on commit bf629f2

Please sign in to comment.