Skip to content

Commit

Permalink
Upgrade lvgl to the latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
mrQzs committed Jan 27, 2022
1 parent 46482eb commit 26a57b4
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 17 deletions.
6 changes: 4 additions & 2 deletions lvgl/lvgl/src/lv_core/lv_disp.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,15 @@ void lv_scr_load_anim(lv_obj_t * new_scr, lv_scr_load_anim_t anim_type, uint32_t
lv_disp_t * d = lv_obj_get_disp(new_scr);
lv_obj_t * act_scr = lv_scr_act();

if(d->del_prev && act_scr != d->scr_to_load && d->scr_to_load) {
lv_obj_del(act_scr);
if(d->scr_to_load && act_scr != d->scr_to_load) {
lv_disp_load_scr(d->scr_to_load);
lv_anim_del(d->scr_to_load, NULL);
lv_obj_set_pos(d->scr_to_load, 0, 0);
lv_style_remove_prop(lv_obj_get_local_style(d->scr_to_load, LV_OBJ_PART_MAIN), LV_STYLE_OPA_SCALE);

if(d->del_prev) {
lv_obj_del(act_scr);
}
act_scr = d->scr_to_load;
}

Expand Down
11 changes: 10 additions & 1 deletion lvgl/lvgl/src/lv_core/lv_refr.c
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ static void lv_refr_vdb_rotate(lv_area_t * area, lv_color_t * color_p)
area->y1 = area->x1;
area->y2 = area->y1 + area_w - 1;
}
vdb->flushing = 0;

/*Rotate the screen in chunks, flushing after each one*/
lv_coord_t row = 0;
while(row < area_h) {
Expand Down Expand Up @@ -895,6 +895,15 @@ static void lv_refr_vdb_rotate(lv_area_t * area, lv_color_t * color_p)
area->x1 = area->x2 - height + 1;
}
}

/* The original part (chunk of the current area) were split into more parts here.
* Set the original last_part flag on the last part of rotation. */
if(row + height >= area_h && vdb->last_area && vdb->last_part) {
vdb->flushing_last = 1;
} else {
vdb->flushing_last = 0;
}

/*Flush the completed area to the display*/
drv->flush_cb(drv, area, rot_buf == NULL ? color_p : rot_buf);
/*FIXME: Rotation forces legacy behavior where rendering and flushing are done serially*/
Expand Down
14 changes: 8 additions & 6 deletions lvgl/lvgl/src/lv_draw/lv_draw_label.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,14 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_
int32_t col_bit;
col_bit = bit_ofs & 0x7; /* "& 0x7" equals to "% 8" just faster */

lv_area_t map_area;
map_area.x1 = col_start / 3 + pos_x;
map_area.x2 = col_end / 3 + pos_x - 1;
map_area.y1 = row_start + pos_y;
map_area.y2 = map_area.y1;

if(map_area.x2 <= map_area.x1) return;

int32_t mask_buf_size = box_w * box_h > LV_HOR_RES_MAX ? LV_HOR_RES_MAX : g->box_w * g->box_h;
lv_opa_t * mask_buf = _lv_mem_buf_get(mask_buf_size);
int32_t mask_p = 0;
Expand All @@ -673,12 +681,6 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_
/*If the letter is partially out of mask the move there on VDB*/
vdb_buf_tmp += (row_start * vdb_width) + col_start / 3;

lv_area_t map_area;
map_area.x1 = col_start / 3 + pos_x;
map_area.x2 = col_end / 3 + pos_x - 1;
map_area.y1 = row_start + pos_y;
map_area.y2 = map_area.y1;

uint8_t other_mask_cnt = lv_draw_mask_get_cnt();

uint8_t font_rgb[3];
Expand Down
2 changes: 1 addition & 1 deletion lvgl/lvgl/src/lv_themes/lv_theme_material.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

/*SCREEN*/

#define COLOR_SCR (IS_LIGHT ? lv_color_hex(0xffffff) : lv_color_hex(0x444b5a))
#define COLOR_SCR (IS_LIGHT ? lv_color_hex(0xeaeff3) : lv_color_hex(0x444b5a))
#define COLOR_SCR_TEXT (IS_LIGHT ? lv_color_hex(0x3b3e42) : lv_color_hex(0xe7e9ec))

/*BUTTON*/
Expand Down
3 changes: 2 additions & 1 deletion lvgl/lvgl/src/lv_widgets/lv_canvas.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "../lv_misc/lv_debug.h"
#include "../lv_misc/lv_math.h"
#include "../lv_draw/lv_draw.h"
#include "../lv_draw/lv_img_cache.h"
#include "../lv_core/lv_refr.h"
#include "../lv_themes/lv_theme.h"

Expand Down Expand Up @@ -1107,7 +1108,7 @@ static lv_res_t lv_canvas_signal(lv_obj_t * canvas, lv_signal_t sign, void * par
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);

if(sign == LV_SIGNAL_CLEANUP) {
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
lv_img_cache_invalidate_src(lv_canvas_get_img(canvas));
}

return res;
Expand Down
1 change: 1 addition & 0 deletions lvgl/lvgl/src/lv_widgets/lv_gauge.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, const lv_obj_t * copy)
}

/*Initialize the allocated 'ext' */
ext->lmeter.lvl_ofs = -1;
ext->needle_count = 0;
ext->values = NULL;
ext->needle_colors = NULL;
Expand Down
8 changes: 7 additions & 1 deletion lvgl/lvgl/src/lv_widgets/lv_gauge.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,13 @@ static inline void lv_gauge_set_range(lv_obj_t * gauge, int32_t min, int32_t max
*/
static inline void lv_gauge_set_critical_value(lv_obj_t * gauge, int32_t value)
{
lv_linemeter_set_value(gauge, value - 1);
lv_linemeter_ext_t * ext = (lv_linemeter_ext_t *)lv_obj_get_ext_attr(gauge);
if(value > lv_linemeter_get_max_value(gauge)) {
ext->lvl_ofs = 1;
} else {
ext->lvl_ofs = -1;
}
lv_linemeter_set_value(gauge, value);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lvgl/lvgl/src/lv_widgets/lv_img.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ void lv_img_set_offset_x(lv_obj_t * img, lv_coord_t x)

lv_img_ext_t * ext = lv_obj_get_ext_attr(img);

if(ext->w != 0) x = x % ext->w;
x = x % ext->w;

ext->offset.x = x;
lv_obj_invalidate(img);
Expand All @@ -279,7 +279,7 @@ void lv_img_set_offset_y(lv_obj_t * img, lv_coord_t y)

lv_img_ext_t * ext = lv_obj_get_ext_attr(img);

if(ext->h != 0) y = y % ext->h;
y = y % ext->h;

ext->offset.y = y;
lv_obj_invalidate(img);
Expand Down
7 changes: 4 additions & 3 deletions lvgl/lvgl/src/lv_widgets/lv_linemeter.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ lv_obj_t * lv_linemeter_create(lv_obj_t * par, const lv_obj_t * copy)
ext->scale_angle = 240;
ext->angle_ofs = 0;
ext->mirrored = 0;
ext->lvl_ofs = 0;

/*The signal and design functions are not copied so set them here*/
lv_obj_set_signal_cb(linemeter, lv_linemeter_signal);
Expand Down Expand Up @@ -446,7 +447,7 @@ void lv_linemeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uin
p1.y = y_out_extra;

/* Set the color of the lines */
if(ext->cur_value == ext->min_value || (!ext->mirrored && i > level) || (ext->mirrored && i < level)) {
if(ext->cur_value == ext->min_value || (!ext->mirrored && i > level + ext->lvl_ofs) || (ext->mirrored && i <= level + ext->lvl_ofs)) {
line_dsc.color = end_color;
line_dsc.width = end_line_width;
}
Expand All @@ -465,12 +466,12 @@ void lv_linemeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uin
lv_draw_mask_remove_id(mask_out_id);
#endif

if(part == LV_LINEMETER_PART_MAIN && level + 1 < ext->line_cnt - 1) {
if(part == LV_LINEMETER_PART_MAIN && level < ext->line_cnt - 1) {
lv_style_int_t border_width = lv_obj_get_style_scale_border_width(lmeter, part);
lv_style_int_t end_border_width = lv_obj_get_style_scale_end_border_width(lmeter, part);

if(border_width || end_border_width) {
int16_t end_angle = ((level + 1) * ext->scale_angle) / (ext->line_cnt - 1) + angle_ofs;
int16_t end_angle = (level * ext->scale_angle) / (ext->line_cnt - 1) + angle_ofs;
lv_draw_line_dsc_t arc_dsc;
lv_draw_line_dsc_init(&arc_dsc);
lv_obj_init_draw_line_dsc(lmeter, part, &arc_dsc);
Expand Down
1 change: 1 addition & 0 deletions lvgl/lvgl/src/lv_widgets/lv_linemeter.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ typedef struct {
uint16_t scale_angle; /*Angle of the scale in deg. (0..360)*/
uint16_t angle_ofs;
uint16_t line_cnt; /*Count of lines */
int16_t lvl_ofs;
int32_t cur_value;
int32_t min_value;
int32_t max_value;
Expand Down

0 comments on commit 26a57b4

Please sign in to comment.