merge master

This commit is contained in:
Gabor Kiss-Vamosi
2020-11-26 15:39:58 +01:00
7 changed files with 71 additions and 56 deletions

View File

@@ -17,6 +17,8 @@
- fix(indev) in LV_INDEV_TYPE_BUTTON recognize 1 cycle long presses too
- fix(arc) make arc work with encoder
- fix(slider) adjusting the left knob too with encoder
- fix reference to LV_DRAW_BUF_MAX_NUM in lv_mem.c
- fix(polygon draw) join adjacent points if they are on the same coordinate
## v7.7.2 (17.11.2020)
### Bugfixes

View File

@@ -312,19 +312,11 @@ void _lv_obj_invalidate_style_cache(lv_obj_t * obj, uint8_t part, lv_style_prope
{
if(style_prop_is_cacheable(prop) == false) return;
if(part != LV_OBJ_PART_ALL) {
lv_style_list_t * list = _lv_obj_get_style_list(obj, part);
if(list == NULL) return;
list->valid_cache = 0;
}
else {
for(part = 0; part < _LV_OBJ_PART_MAX; part++) {
lv_style_list_t * list = _lv_obj_get_style_list(obj, part);
if(list == NULL) break;
list->valid_cache = 0;
}
}
lv_obj_t * child = lv_obj_get_child(obj, NULL);
while(child) {

View File

@@ -394,20 +394,11 @@ static void get_rounded_area(int16_t angle, lv_coord_t radius, uint8_t tickness,
int32_t thick_half = tickness / 2;
uint8_t thick_corr = (tickness & 0x01) ? 0 : 1;
int32_t rx_corr;
int32_t ry_corr;
if(angle > 90 && angle < 270) rx_corr = 0;
else rx_corr = 0;
if(angle > 0 && angle < 180) ry_corr = 0;
else ry_corr = 0;
int32_t cir_x;
int32_t cir_y;
cir_x = ((radius - rx_corr - thick_half) * _lv_trigo_sin(90 - angle)) >> (LV_TRIGO_SHIFT - ps);
cir_y = ((radius - ry_corr - thick_half) * _lv_trigo_sin(angle)) >> (LV_TRIGO_SHIFT - ps);
cir_x = ((radius - thick_half) * _lv_trigo_sin(90 - angle)) >> (LV_TRIGO_SHIFT - ps);
cir_y = ((radius - thick_half) * _lv_trigo_sin(angle)) >> (LV_TRIGO_SHIFT - ps);
/* Actually the center of the pixel need to be calculated so apply 1/2 px offset*/
if(cir_x > 0) {

View File

@@ -58,29 +58,53 @@ void lv_draw_polygon(const lv_point_t points[], uint16_t point_cnt, const lv_are
if(point_cnt < 3) return;
if(points == NULL) return;
int16_t i;
/*Join adjacent points if they are on the same coordinate*/
lv_point_t * p = _lv_mem_buf_get(point_cnt * sizeof(lv_point_t));
if(p == NULL) return;
uint16_t i;
uint16_t pcnt = 0;
p[0] = points[0];
for(i = 0; i < point_cnt - 1; i++) {
if(points[i].x != points[i+1].x ||points[i].y != points[i+1].y) {
p[pcnt] = points[i];
pcnt++;
}
}
/*The first and the last points are also adjacent */
if(points[0].x != points[point_cnt - 1].x || points[0].y != points[point_cnt - 1].y) {
p[pcnt] = points[point_cnt - 1];
pcnt++;
}
point_cnt = pcnt;
if(point_cnt < 3) {
_lv_mem_buf_release(p);
return;
}
lv_area_t poly_coords = {.x1 = LV_COORD_MAX, .y1 = LV_COORD_MAX, .x2 = LV_COORD_MIN, .y2 = LV_COORD_MIN};
for(i = 0; i < point_cnt; i++) {
poly_coords.x1 = LV_MATH_MIN(poly_coords.x1, points[i].x);
poly_coords.y1 = LV_MATH_MIN(poly_coords.y1, points[i].y);
poly_coords.x2 = LV_MATH_MAX(poly_coords.x2, points[i].x);
poly_coords.y2 = LV_MATH_MAX(poly_coords.y2, points[i].y);
poly_coords.x1 = LV_MATH_MIN(poly_coords.x1, p[i].x);
poly_coords.y1 = LV_MATH_MIN(poly_coords.y1, p[i].y);
poly_coords.x2 = LV_MATH_MAX(poly_coords.x2, p[i].x);
poly_coords.y2 = LV_MATH_MAX(poly_coords.y2, p[i].y);
}
bool is_common;
lv_area_t poly_mask;
is_common = _lv_area_intersect(&poly_mask, &poly_coords, clip_area);
if(!is_common) return;
if(!is_common) {
_lv_mem_buf_release(p);
return;
}
/*Find the lowest point*/
lv_coord_t y_min = points[0].y;
lv_coord_t y_min = p[0].y;
int16_t y_min_i = 0;
for(i = 1; i < point_cnt; i++) {
if(points[i].y < y_min) {
y_min = points[i].y;
if(p[i].y < y_min) {
y_min = p[i].y;
y_min_i = i;
}
}
@@ -109,10 +133,10 @@ void lv_draw_polygon(const lv_point_t points[], uint16_t point_cnt, const lv_are
* dy_left/dx_left < dy_right/dx_right
* dy_left * dx_right < dy_right * dx_left
*/
lv_coord_t dxl = points[i_next_left].x - points[y_min_i].x;
lv_coord_t dxr = points[i_next_right].x - points[y_min_i].x;
lv_coord_t dyl = points[i_next_left].y - points[y_min_i].y;
lv_coord_t dyr = points[i_next_right].y - points[y_min_i].y;
lv_coord_t dxl = p[i_next_left].x - p[y_min_i].x;
lv_coord_t dxr = p[i_next_right].x - p[y_min_i].x;
lv_coord_t dyl = p[i_next_left].y - p[y_min_i].y;
lv_coord_t dyr = p[i_next_right].y - p[y_min_i].y;
bool inv = false;
if(dyl * dxr < dyr * dxl) inv = true;
@@ -133,11 +157,11 @@ void lv_draw_polygon(const lv_point_t points[], uint16_t point_cnt, const lv_are
if(i_next_right < 0) i_next_right = point_cnt + i_next_right;
}
if(points[i_next_left].y >= points[i_prev_left].y) {
if(points[i_next_left].y != points[i_prev_left].y &&
points[i_next_left].x != points[i_prev_left].x) {
lv_draw_mask_line_points_init(mp_next, points[i_prev_left].x, points[i_prev_left].y,
points[i_next_left].x, points[i_next_left].y,
if(p[i_next_left].y >= p[i_prev_left].y) {
if(p[i_next_left].y != p[i_prev_left].y &&
p[i_next_left].x != p[i_prev_left].x) {
lv_draw_mask_line_points_init(mp_next, p[i_prev_left].x, p[i_prev_left].y,
p[i_next_left].x, p[i_next_left].y,
LV_DRAW_MASK_LINE_SIDE_RIGHT);
lv_draw_mask_add(mp_next, mp);
mp_next++;
@@ -148,12 +172,12 @@ void lv_draw_polygon(const lv_point_t points[], uint16_t point_cnt, const lv_are
if(mask_cnt == point_cnt) break;
if(points[i_next_right].y >= points[i_prev_right].y) {
if(points[i_next_right].y != points[i_prev_right].y &&
points[i_next_right].x != points[i_prev_right].x) {
if(p[i_next_right].y >= p[i_prev_right].y) {
if(p[i_next_right].y != p[i_prev_right].y &&
p[i_next_right].x != p[i_prev_right].x) {
lv_draw_mask_line_points_init(mp_next, points[i_prev_right].x, points[i_prev_right].y,
points[i_next_right].x, points[i_next_right].y,
lv_draw_mask_line_points_init(mp_next, p[i_prev_right].x, p[i_prev_right].y,
p[i_next_right].x, p[i_next_right].y,
LV_DRAW_MASK_LINE_SIDE_LEFT);
lv_draw_mask_add(mp_next, mp);
mp_next++;
@@ -169,6 +193,7 @@ void lv_draw_polygon(const lv_point_t points[], uint16_t point_cnt, const lv_are
lv_draw_mask_remove_custom(mp);
_lv_mem_buf_release(mp);
_lv_mem_buf_release(p);
}

View File

@@ -361,7 +361,7 @@ lv_anim_value_t lv_anim_path_bounce(const lv_anim_path_t * path, const lv_anim_t
LV_UNUSED(path);
/*Calculate the current step*/
uint32_t t;
int32_t t;
if(a->time == a->act_time)
t = 1024;
else
@@ -380,31 +380,32 @@ lv_anim_value_t lv_anim_path_bounce(const lv_anim_path_t * path, const lv_anim_t
t -= 408;
t = t * 5; /*to [0..1024] range*/
t = 1024 - t;
diff = diff / 6;
diff = diff / 20;
}
else if(t >= 614 && t < 819) {
/*Fall back*/
t -= 614;
t = t * 5; /*to [0..1024] range*/
diff = diff / 6;
diff = diff / 20;
}
else if(t >= 819 && t < 921) {
/*Second bounce back*/
t -= 819;
t = t * 10; /*to [0..1024] range*/
t = 1024 - t;
diff = diff / 16;
diff = diff / 40;
}
else if(t >= 921 && t <= 1024) {
/*Fall back*/
t -= 921;
t = t * 10; /*to [0..1024] range*/
diff = diff / 16;
diff = diff / 40;
}
if(t > 1024) t = 1024;
if(t < 0) t = 0;
int32_t step = _lv_bezier3(t, 1024, 1024, 800, 0);
int32_t step = _lv_bezier3(t, 1024, 800, 500, 0);
int32_t new_value;
new_value = (int32_t)step * diff;

View File

@@ -523,7 +523,7 @@ void * _lv_mem_buf_get(uint32_t size)
}
}
LV_DEBUG_ASSERT(false, "No free buffer. Increase LV_DRAW_BUF_MAX_NUM.", 0x00);
LV_DEBUG_ASSERT(false, "No free buffer. Increase LV_MEM_BUF_MAX_NUM.", 0x00);
return NULL;
}

View File

@@ -379,11 +379,15 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par
lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
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;
else {
ext->right_knob_focus = 0;
lv_group_set_editing(g, false);
}
} else {
lv_group_set_editing(g, false);
}
}
}
#endif