1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00

Merge 1b37ee88739dc266f74d80f4fd032fff3b40e3e2 into dev

This commit is contained in:
github-actions[bot] 2020-11-28 11:42:02 +00:00 committed by GitHub
commit 138c5423a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 53 additions and 20 deletions

View File

@ -6,6 +6,7 @@
- make DMA2D non blocking
- add unscii-16 built-in font
- add KConfig
- add lv_refr_get_fps_avg()
### Bugfixes
- fix(btnmatrix) handle arabic texts in button matrices

View File

@ -54,6 +54,10 @@ static void lv_refr_vdb_flush(void);
**********************/
static uint32_t px_num;
static lv_disp_t * disp_refr; /*Display being refreshed*/
#if LV_USE_PERF_MONITOR
static uint32_t fps_sum_cnt;
static uint32_t fps_sum_all;
#endif
/**********************
* MACROS
@ -290,17 +294,28 @@ void _lv_disp_refr_task(lv_timer_t * tmr)
}
static uint32_t perf_last_time = 0;
static uint32_t elaps_max = 1;
static uint32_t elaps_sum = 0;
static uint32_t frame_cnt = 0;
if(lv_tick_elaps(perf_last_time) < 300) {
elaps_max = LV_MATH_MAX(elaps, elaps_max);
if(px_num > 5000) {
elaps_sum += elaps;
frame_cnt ++;
}
}
else {
perf_last_time = lv_tick_get();
uint32_t fps = 1000 / (elaps_max == 0 ? 1 : elaps_max);
elaps_max = 1;
uint32_t fps_limit = 1000 / disp_refr->refr_task->period;
uint32_t fps;
if(elaps_sum == 0) elaps_sum = 1;
if(frame_cnt == 0) fps = fps_limit;
else fps = (1000 * frame_cnt) / elaps_sum;
elaps_sum = 0;
frame_cnt = 0;
if(fps > fps_limit) fps = fps_limit;
fps_sum_all += fps;
fps_sum_cnt ++;
uint32_t cpu = 100 - lv_task_get_idle();
lv_label_set_text_fmt(perf_label, "%d FPS\n%d%% CPU", fps, cpu);
lv_obj_align(perf_label, NULL, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
@ -310,6 +325,13 @@ void _lv_disp_refr_task(lv_timer_t * tmr)
LV_LOG_TRACE("lv_refr_task: ready");
}
#if LV_USE_PERF_MONITOR
uint32_t lv_refr_get_fps_avg(void)
{
return fps_sum_all / fps_sum_cnt;
}
#endif
/**********************
* STATIC FUNCTIONS
**********************/
@ -381,7 +403,7 @@ static void lv_refr_areas(void)
disp_refr->driver.buffer->last_part = 0;
lv_refr_area(&disp_refr->inv_areas[i]);
if(disp_refr->driver.monitor_cb) px_num += lv_area_get_size(&disp_refr->inv_areas[i]);
px_num += lv_area_get_size(&disp_refr->inv_areas[i]);
}
}
}

View File

@ -78,6 +78,14 @@ lv_disp_t * _lv_refr_get_disp_refreshing(void);
*/
void _lv_refr_set_disp_refreshing(lv_disp_t * disp);
#if LV_USE_PERF_MONITOR
/**
* Get the average FPS since start up
* @return the average FPS
*/
uint32_t lv_refr_get_fps_avg(void);
#endif
/**
* Called periodically to handle the refreshing
* @param task pointer to the task itself

View File

@ -367,20 +367,20 @@ void lv_img_set_zoom(lv_obj_t * img, uint16_t zoom)
lv_coord_t h = lv_obj_get_height(img);
lv_area_t a;
_lv_img_buf_get_transformed_area(&a, w, h, transf_angle, (transf_zoom * ext->zoom) >> 8, &ext->pivot);
a.x1 += img->coords.x1;
a.y1 += img->coords.y1;
a.x2 += img->coords.x1;
a.y2 += img->coords.y1;
a.x1 += img->coords.x1 - 1;
a.y1 += img->coords.y1 - 1;
a.x2 += img->coords.x1 + 1;
a.y2 += img->coords.y1 + 1;
lv_obj_invalidate_area(img, &a);
ext->zoom = zoom;
_lv_obj_refresh_ext_draw_pad(img);
_lv_img_buf_get_transformed_area(&a, w, h, transf_angle, (transf_zoom * ext->zoom) >> 8, &ext->pivot);
a.x1 += img->coords.x1;
a.y1 += img->coords.y1;
a.x2 += img->coords.x1;
a.y2 += img->coords.y1;
a.x1 += img->coords.x1 - 1;
a.y1 += img->coords.y1 - 1;
a.x2 += img->coords.x1 + 1;
a.y2 += img->coords.y1 + 1;
lv_obj_invalidate_area(img, &a);
}

View File

@ -82,7 +82,7 @@ lv_obj_t * lv_slider_create(lv_obj_t * parent, const lv_obj_t * copy)
/*Initialize the allocated 'ext' */
ext->value_to_set = NULL;
ext->dragging = 0;
ext->right_knob_focus = 0;
ext->left_knob_focus = 0;
lv_style_list_init(&ext->style_knob);
/*The signal and design functions are not copied so set them here*/
@ -315,6 +315,8 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par
}
}
else if(sign == LV_SIGNAL_PRESSING && ext->value_to_set != NULL) {
if(lv_indev_get_type(param) != LV_INDEV_TYPE_POINTER) return res;
lv_indev_get_point(param, &p);
lv_bidi_dir_t base_dir = lv_obj_get_base_dir(slider);
@ -380,9 +382,9 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par
if(indev_type == LV_INDEV_TYPE_ENCODER) {
if(editing) {
if(lv_slider_get_type(slider) == LV_SLIDER_TYPE_RANGE) {
if(ext->right_knob_focus == 0) ext->right_knob_focus = 1;
if(ext->left_knob_focus == 0) ext->left_knob_focus = 1;
else {
ext->right_knob_focus = 0;
ext->left_knob_focus = 0;
lv_group_set_editing(g, false);
}
} else {
@ -394,7 +396,7 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par
}
else if(sign == LV_SIGNAL_FOCUS) {
ext->right_knob_focus = 0;
ext->left_knob_focus = 0;
}
else if(sign == LV_SIGNAL_COORD_CHG) {
/* The knob size depends on slider size.
@ -427,14 +429,14 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par
char c = *((char *)param);
if(c == LV_KEY_RIGHT || c == LV_KEY_UP) {
if(ext->right_knob_focus) lv_slider_set_value(slider, lv_slider_get_value(slider) + 1, LV_ANIM_ON);
if(!ext->left_knob_focus) lv_slider_set_value(slider, lv_slider_get_value(slider) + 1, LV_ANIM_ON);
else lv_slider_set_left_value(slider, lv_slider_get_left_value(slider) + 1, LV_ANIM_ON);
res = lv_event_send(slider, LV_EVENT_VALUE_CHANGED, NULL);
if(res != LV_RES_OK) return res;
}
else if(c == LV_KEY_LEFT || c == LV_KEY_DOWN) {
if(ext->right_knob_focus) lv_slider_set_value(slider, lv_slider_get_value(slider) - 1, LV_ANIM_ON);
if(!ext->left_knob_focus) lv_slider_set_value(slider, lv_slider_get_value(slider) - 1, LV_ANIM_ON);
else lv_slider_set_left_value(slider, lv_slider_get_left_value(slider) - 1, LV_ANIM_ON);
res = lv_event_send(slider, LV_EVENT_VALUE_CHANGED, NULL);

View File

@ -49,7 +49,7 @@ typedef struct {
lv_area_t right_knob_area;
int16_t * value_to_set; /* Which bar value to set */
uint8_t dragging : 1; /*1: the slider is being dragged*/
uint8_t right_knob_focus :1; /*1: with encoder now the right knob can be adjusted*/
uint8_t left_knob_focus :1; /*1: with encoder now the right knob can be adjusted*/
} lv_slider_ext_t;
/** Built-in styles of slider*/