I use lvgl v6.0, but as far as I can tell, this still is usable in v7 too.
Following change is suggested to lv_refr_join_area():
static void lv_refr_join_area(void) {
uint32_t join_from;
uint32_t join_in;
uint32_t diff;
lv_area_t joined_area;
if (disp_refr->inv_p == 0) return; // sanity
for(join_in = 0; join_in < disp_refr->inv_p - 1; join_in++) {
diff = 0;
/*Check all areas to join them in 'join_in'*/
for(join_from = join_in + 1; join_from < disp_refr->inv_p; join_from++) {
// move if there was some joining previously
if (diff) {
lv_area_copy(&disp_refr->inv_areas[join_from - diff], &disp_refr->inv_areas[join_from]);
}
/*Check if the areas are on each other*/
if(lv_area_is_on(&disp_refr->inv_areas[join_in], &disp_refr->inv_areas[join_from]) == false) {
continue;
}
lv_area_join(&joined_area, &disp_refr->inv_areas[join_in], &disp_refr->inv_areas[join_from]);
/*Join two area only if the joined area size is smaller*/
if(lv_area_get_size(&joined_area) < (lv_area_get_size(&disp_refr->inv_areas[join_in]) +
lv_area_get_size(&disp_refr->inv_areas[join_from]))) {
lv_area_copy(&disp_refr->inv_areas[join_in], &joined_area);
diff++;
}
}
disp_refr->inv_p -= diff;
}
}
This removes the need for inv_area_joined array in lv_disp_t, sparing some precious RAM space. All code related to that array may be removed. Whether this reduces execution time may depend on context but I believe it mostly does. In v7 it should also simplify the finding of the “last” area to trivial (my motivation was different - I have a modified refresher, which allows function calls (cooperative multitasking) during refresh, leaving the refresh process during DMAing from the partial buffer; so I needed a way to be able to add new areas to the refresh FIFO while refresh process is running).
JW