Merge branch 'dev' of https://github.com/littlevgl/lvgl into dev

This commit is contained in:
Gabor Kiss-Vamosi
2020-11-27 10:05:16 +01:00
19 changed files with 144 additions and 166 deletions

View File

@@ -14,6 +14,12 @@
- fix(textarea) support Arabic letter connections - fix(textarea) support Arabic letter connections
- fix(dropdown) support Arabic letter connections - fix(dropdown) support Arabic letter connections
- fix(value_str) support Arabic letter connections in value string property - fix(value_str) support Arabic letter connections in value string property
- 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
- fix(linemeter) fix invalidation when setting new value
## v7.7.2 (17.11.2020) ## v7.7.2 (17.11.2020)
### Bugfixes ### Bugfixes

View File

@@ -59,3 +59,4 @@ Planned to November/December 2020
- Need static analize (via coverity.io or somehing else) - Need static analize (via coverity.io or somehing else)
- Support dot_begin and dot_middle long modes for labels - Support dot_begin and dot_middle long modes for labels
- Add new label alignment modes. [#1656](https://github.com/lvgl/lvgl/issues/1656) - Add new label alignment modes. [#1656](https://github.com/lvgl/lvgl/issues/1656)
- Support larger images: [#1892](https://github.com/lvgl/lvgl/issues/1892)

2
lvgl.h
View File

@@ -68,8 +68,6 @@ extern "C" {
#include "src/lv_api_map.h" #include "src/lv_api_map.h"
//#define LV_BUILD_TEST 1
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/

View File

@@ -1308,7 +1308,7 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */
/* Support bidirectional texts. /* Support bidirectional texts.
* Allows mixing Left-to-Right and Right-to-Left texts. * Allows mixing Left-to-Right and Right-to-Left texts.
* The direction will be processed according to the Unicode Bidirectioanl Algorithm: * The direction will be processed according to the Unicode Bidirectional Algorithm:
* https://www.w3.org/International/articles/inline-bidi-markup/uba-basics*/ * https://www.w3.org/International/articles/inline-bidi-markup/uba-basics*/
#ifndef LV_USE_BIDI #ifndef LV_USE_BIDI
# ifdef CONFIG_LV_USE_BIDI # ifdef CONFIG_LV_USE_BIDI

View File

@@ -788,19 +788,28 @@ static void indev_button_proc(lv_indev_t * i, lv_indev_data_t * data)
return; return;
} }
i->proc.types.pointer.act_point.x = i->btn_points[data->btn_id].x; lv_coord_t x = i->btn_points[data->btn_id].x;
i->proc.types.pointer.act_point.y = i->btn_points[data->btn_id].y; lv_coord_t y = i->btn_points[data->btn_id].y;
/*Still the same point is pressed*/ /*If a new point comes always make a release*/
if(i->proc.types.pointer.last_point.x == i->proc.types.pointer.act_point.x && if(data->state == LV_INDEV_STATE_PR) {
i->proc.types.pointer.last_point.y == i->proc.types.pointer.act_point.y && data->state == LV_INDEV_STATE_PR) { if(i->proc.types.pointer.last_point.x != x ||
indev_proc_press(&i->proc); i->proc.types.pointer.last_point.y != y) {
} indev_proc_release(&i->proc);
else { }
/*If a new point comes always make a release*/
indev_proc_release(&i->proc);
} }
if(indev_reset_check(&i->proc)) return;
/*Save the new points*/
i->proc.types.pointer.act_point.x = x;
i->proc.types.pointer.act_point.y = y;
if(data->state == LV_INDEV_STATE_PR) indev_proc_press(&i->proc);
else indev_proc_release(&i->proc);
if(indev_reset_check(&i->proc)) return;
i->proc.types.pointer.last_point.x = i->proc.types.pointer.act_point.x; i->proc.types.pointer.last_point.x = i->proc.types.pointer.act_point.x;
i->proc.types.pointer.last_point.y = i->proc.types.pointer.act_point.y; i->proc.types.pointer.last_point.y = i->proc.types.pointer.act_point.y;
} }

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(style_prop_is_cacheable(prop) == false) return;
if(part != LV_OBJ_PART_ALL) { for(part = 0; part < _LV_OBJ_PART_MAX; part++) {
lv_style_list_t * list = _lv_obj_get_style_list(obj, part); lv_style_list_t * list = _lv_obj_get_style_list(obj, part);
if(list == NULL) return; if(list == NULL) break;
list->valid_cache = 0; 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); lv_obj_t * child = lv_obj_get_child(obj, NULL);
while(child) { 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; int32_t thick_half = tickness / 2;
uint8_t thick_corr = (tickness & 0x01) ? 0 : 1; 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_x;
int32_t cir_y; int32_t cir_y;
cir_x = ((radius - rx_corr - thick_half) * _lv_trigo_sin(90 - angle)) >> (LV_TRIGO_SHIFT - ps); cir_x = ((radius - 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_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*/ /* Actually the center of the pixel need to be calculated so apply 1/2 px offset*/
if(cir_x > 0) { if(cir_x > 0) {

View File

@@ -25,7 +25,6 @@
*********************/ *********************/
#define GPU_SIZE_LIMIT 240 #define GPU_SIZE_LIMIT 240
/********************** /**********************
* TYPEDEFS * TYPEDEFS
**********************/ **********************/

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(point_cnt < 3) return;
if(points == NULL) 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}; 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++) { for(i = 0; i < point_cnt; i++) {
poly_coords.x1 = LV_MATH_MIN(poly_coords.x1, points[i].x); poly_coords.x1 = LV_MATH_MIN(poly_coords.x1, p[i].x);
poly_coords.y1 = LV_MATH_MIN(poly_coords.y1, points[i].y); poly_coords.y1 = LV_MATH_MIN(poly_coords.y1, p[i].y);
poly_coords.x2 = LV_MATH_MAX(poly_coords.x2, points[i].x); poly_coords.x2 = LV_MATH_MAX(poly_coords.x2, p[i].x);
poly_coords.y2 = LV_MATH_MAX(poly_coords.y2, points[i].y); poly_coords.y2 = LV_MATH_MAX(poly_coords.y2, p[i].y);
} }
bool is_common; bool is_common;
lv_area_t poly_mask; lv_area_t poly_mask;
is_common = _lv_area_intersect(&poly_mask, &poly_coords, clip_area); 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*/ /*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; int16_t y_min_i = 0;
for(i = 1; i < point_cnt; i++) { for(i = 1; i < point_cnt; i++) {
if(points[i].y < y_min) { if(p[i].y < y_min) {
y_min = points[i].y; y_min = p[i].y;
y_min_i = i; 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_left < dy_right/dx_right
* dy_left * dx_right < dy_right * dx_left * 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 dxl = p[i_next_left].x - p[y_min_i].x;
lv_coord_t dxr = points[i_next_right].x - points[y_min_i].x; lv_coord_t dxr = p[i_next_right].x - p[y_min_i].x;
lv_coord_t dyl = points[i_next_left].y - points[y_min_i].y; lv_coord_t dyl = p[i_next_left].y - p[y_min_i].y;
lv_coord_t dyr = points[i_next_right].y - points[y_min_i].y; lv_coord_t dyr = p[i_next_right].y - p[y_min_i].y;
bool inv = false; bool inv = false;
if(dyl * dxr < dyr * dxl) inv = true; 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(i_next_right < 0) i_next_right = point_cnt + i_next_right;
} }
if(points[i_next_left].y >= points[i_prev_left].y) { if(p[i_next_left].y >= p[i_prev_left].y) {
if(points[i_next_left].y != points[i_prev_left].y && if(p[i_next_left].y != p[i_prev_left].y &&
points[i_next_left].x != points[i_prev_left].x) { p[i_next_left].x != p[i_prev_left].x) {
lv_draw_mask_line_points_init(mp_next, points[i_prev_left].x, points[i_prev_left].y, lv_draw_mask_line_points_init(mp_next, p[i_prev_left].x, p[i_prev_left].y,
points[i_next_left].x, points[i_next_left].y, p[i_next_left].x, p[i_next_left].y,
LV_DRAW_MASK_LINE_SIDE_RIGHT); LV_DRAW_MASK_LINE_SIDE_RIGHT);
lv_draw_mask_add(mp_next, mp); lv_draw_mask_add(mp_next, mp);
mp_next++; 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(mask_cnt == point_cnt) break;
if(points[i_next_right].y >= points[i_prev_right].y) { if(p[i_next_right].y >= p[i_prev_right].y) {
if(points[i_next_right].y != points[i_prev_right].y && if(p[i_next_right].y != p[i_prev_right].y &&
points[i_next_right].x != points[i_prev_right].x) { 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, lv_draw_mask_line_points_init(mp_next, p[i_prev_right].x, p[i_prev_right].y,
points[i_next_right].x, points[i_next_right].y, p[i_next_right].x, p[i_next_right].y,
LV_DRAW_MASK_LINE_SIDE_LEFT); LV_DRAW_MASK_LINE_SIDE_LEFT);
lv_draw_mask_add(mp_next, mp); lv_draw_mask_add(mp_next, mp);
mp_next++; 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_draw_mask_remove_custom(mp);
_lv_mem_buf_release(mp); _lv_mem_buf_release(mp);
_lv_mem_buf_release(p);
} }

View File

@@ -241,7 +241,8 @@ static void invalidate_cache(void)
if(disp->driver.clean_dcache_cb) disp->driver.clean_dcache_cb(&disp->driver); if(disp->driver.clean_dcache_cb) disp->driver.clean_dcache_cb(&disp->driver);
else { else {
#if __CORTEX_M >= 0x07 #if __CORTEX_M >= 0x07
SCB_CleanInvalidateDCache(); if((SCB->CCR) & (uint32_t)SCB_CCR_DC_Msk)
SCB_CleanInvalidateDCache();
#endif #endif
} }
} }

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); LV_UNUSED(path);
/*Calculate the current step*/ /*Calculate the current step*/
uint32_t t; int32_t t;
if(a->time == a->act_time) if(a->time == a->act_time)
t = 1024; t = 1024;
else 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 -= 408;
t = t * 5; /*to [0..1024] range*/ t = t * 5; /*to [0..1024] range*/
t = 1024 - t; t = 1024 - t;
diff = diff / 6; diff = diff / 20;
} }
else if(t >= 614 && t < 819) { else if(t >= 614 && t < 819) {
/*Fall back*/ /*Fall back*/
t -= 614; t -= 614;
t = t * 5; /*to [0..1024] range*/ t = t * 5; /*to [0..1024] range*/
diff = diff / 6; diff = diff / 20;
} }
else if(t >= 819 && t < 921) { else if(t >= 819 && t < 921) {
/*Second bounce back*/ /*Second bounce back*/
t -= 819; t -= 819;
t = t * 10; /*to [0..1024] range*/ t = t * 10; /*to [0..1024] range*/
t = 1024 - t; t = 1024 - t;
diff = diff / 16; diff = diff / 40;
} }
else if(t >= 921 && t <= 1024) { else if(t >= 921 && t <= 1024) {
/*Fall back*/ /*Fall back*/
t -= 921; t -= 921;
t = t * 10; /*to [0..1024] range*/ t = t * 10; /*to [0..1024] range*/
diff = diff / 16; diff = diff / 40;
} }
if(t > 1024) t = 1024; 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; int32_t new_value;
new_value = (int32_t)step * diff; new_value = (int32_t)step * diff;

View File

@@ -108,9 +108,9 @@ enum {
* Macros for all existing color depths * Macros for all existing color depths
* to set/get values of the color channels * to set/get values of the color channels
*------------------------------------------*/ *------------------------------------------*/
# define LV_COLOR_SET_R1(c, v) (c).ch.red = (uint8_t)((v) & 0x1); # define LV_COLOR_SET_R1(c, v) (c).ch.red = (uint8_t)((v) & 0x1)
# define LV_COLOR_SET_G1(c, v) (c).ch.green = (uint8_t)((v) & 0x1); # define LV_COLOR_SET_G1(c, v) (c).ch.green = (uint8_t)((v) & 0x1)
# define LV_COLOR_SET_B1(c, v) (c).ch.blue = (uint8_t)((v) & 0x1); # define LV_COLOR_SET_B1(c, v) (c).ch.blue = (uint8_t)((v) & 0x1)
# define LV_COLOR_SET_A1(c, v) # define LV_COLOR_SET_A1(c, v)
# define LV_COLOR_GET_R1(c) (c).ch.red # define LV_COLOR_GET_R1(c) (c).ch.red
@@ -118,9 +118,9 @@ enum {
# define LV_COLOR_GET_B1(c) (c).ch.blue # define LV_COLOR_GET_B1(c) (c).ch.blue
# define LV_COLOR_GET_A1(c) 1 # define LV_COLOR_GET_A1(c) 1
# define LV_COLOR_SET_R8(c, v) (c).ch.red = (uint8_t)(v) & 0x7U; # define LV_COLOR_SET_R8(c, v) (c).ch.red = (uint8_t)(v) & 0x7U
# define LV_COLOR_SET_G8(c, v) (c).ch.green = (uint8_t)(v) & 0x7U; # define LV_COLOR_SET_G8(c, v) (c).ch.green = (uint8_t)(v) & 0x7U
# define LV_COLOR_SET_B8(c, v) (c).ch.blue = (uint8_t)(v) & 0x3U; # define LV_COLOR_SET_B8(c, v) (c).ch.blue = (uint8_t)(v) & 0x3U
# define LV_COLOR_SET_A8(c, v) do {} while(0) # define LV_COLOR_SET_A8(c, v) do {} while(0)
# define LV_COLOR_GET_R8(c) (c).ch.red # define LV_COLOR_GET_R8(c) (c).ch.red
@@ -128,10 +128,10 @@ enum {
# define LV_COLOR_GET_B8(c) (c).ch.blue # define LV_COLOR_GET_B8(c) (c).ch.blue
# define LV_COLOR_GET_A8(c) 0xFF # define LV_COLOR_GET_A8(c) 0xFF
# define LV_COLOR_SET_R16(c, v) (c).ch.red = (uint8_t)(v) & 0x1FU; # define LV_COLOR_SET_R16(c, v) (c).ch.red = (uint8_t)(v) & 0x1FU
# define LV_COLOR_SET_G16(c, v) (c).ch.green = (uint8_t)(v) & 0x3FU; # define LV_COLOR_SET_G16(c, v) (c).ch.green = (uint8_t)(v) & 0x3FU
# define LV_COLOR_SET_G16_SWAP(c, v) {(c).ch.green_h = (uint8_t)(((v) >> 3) & 0x7); (c).ch.green_l = (uint8_t)((v) & 0x7);} # define LV_COLOR_SET_G16_SWAP(c, v) {(c).ch.green_h = (uint8_t)(((v) >> 3) & 0x7); (c).ch.green_l = (uint8_t)((v) & 0x7);}
# define LV_COLOR_SET_B16(c, v) (c).ch.blue = (uint8_t)(v) & 0x1FU; # define LV_COLOR_SET_B16(c, v) (c).ch.blue = (uint8_t)(v) & 0x1FU
# define LV_COLOR_SET_A16(c, v) do {} while(0) # define LV_COLOR_SET_A16(c, v) do {} while(0)
# define LV_COLOR_GET_R16(c) (c).ch.red # define LV_COLOR_GET_R16(c) (c).ch.red
@@ -140,10 +140,10 @@ enum {
# define LV_COLOR_GET_B16(c) (c).ch.blue # define LV_COLOR_GET_B16(c) (c).ch.blue
# define LV_COLOR_GET_A16(c) 0xFF # define LV_COLOR_GET_A16(c) 0xFF
# define LV_COLOR_SET_R32(c, v) (c).ch.red = (uint32_t)((v) & 0xFF); # define LV_COLOR_SET_R32(c, v) (c).ch.red = (uint32_t)((v) & 0xFF)
# define LV_COLOR_SET_G32(c, v) (c).ch.green = (uint32_t)((v) & 0xFF); # define LV_COLOR_SET_G32(c, v) (c).ch.green = (uint32_t)((v) & 0xFF)
# define LV_COLOR_SET_B32(c, v) (c).ch.blue = (uint32_t)((v) & 0xFF); # define LV_COLOR_SET_B32(c, v) (c).ch.blue = (uint32_t)((v) & 0xFF)
# define LV_COLOR_SET_A32(c, v) (c).ch.alpha = (uint32_t)((v) & 0xFF); # define LV_COLOR_SET_A32(c, v) (c).ch.alpha = (uint32_t)((v) & 0xFF)
# define LV_COLOR_GET_R32(c) (c).ch.red # define LV_COLOR_GET_R32(c) (c).ch.red
# define LV_COLOR_GET_G32(c) (c).ch.green # define LV_COLOR_GET_G32(c) (c).ch.green

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; return NULL;
} }

View File

@@ -20,6 +20,7 @@ extern "C" {
#include "lv_area.h" #include "lv_area.h"
#include "../lv_font/lv_font.h" #include "../lv_font/lv_font.h"
#include "lv_printf.h" #include "lv_printf.h"
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/

View File

@@ -865,6 +865,12 @@ static lv_res_t lv_arc_signal(lv_obj_t * arc, lv_signal_t sign, void * param)
_lv_obj_reset_style_list_no_refr(arc, LV_ARC_PART_KNOB); _lv_obj_reset_style_list_no_refr(arc, LV_ARC_PART_KNOB);
_lv_obj_reset_style_list_no_refr(arc, LV_ARC_PART_INDIC); _lv_obj_reset_style_list_no_refr(arc, LV_ARC_PART_INDIC);
} }
else if(sign == LV_SIGNAL_GET_EDITABLE) {
#if LV_USE_GROUP
bool * editable = (bool *)param;
*editable = true;
#endif
}
return res; return res;
} }

View File

@@ -153,9 +153,11 @@ void lv_bar_set_value(lv_obj_t * bar, int16_t value, lv_anim_enable_t anim)
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar); lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
if(ext->cur_value == value) return; if(ext->cur_value == value) return;
int16_t new_value; int16_t new_value = value;
new_value = value > ext->max_value ? ext->max_value : value; new_value = value > ext->max_value ? ext->max_value : new_value;
new_value = new_value < ext->min_value ? ext->min_value : new_value; new_value = new_value < ext->min_value ? ext->min_value : new_value;
new_value = new_value < ext->start_value ? ext->start_value : new_value;
if(ext->cur_value == new_value) return; if(ext->cur_value == new_value) return;
#if LV_USE_ANIMATION == 0 #if LV_USE_ANIMATION == 0
@@ -180,9 +182,10 @@ void lv_bar_set_start_value(lv_obj_t * bar, int16_t start_value, lv_anim_enable_
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar); lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
if(ext->start_value == start_value) return; if(ext->start_value == start_value) return;
int16_t new_value; int16_t new_value = start_value;
new_value = start_value > ext->max_value ? ext->max_value : start_value; new_value = new_value > ext->max_value ? ext->max_value : new_value;
new_value = new_value < ext->min_value ? ext->min_value : start_value; new_value = new_value < ext->min_value ? ext->min_value : new_value;
new_value = new_value > ext->cur_value ? ext->cur_value : new_value;
if(ext->start_value == new_value) return; if(ext->start_value == new_value) return;
#if LV_USE_ANIMATION == 0 #if LV_USE_ANIMATION == 0

View File

@@ -131,83 +131,9 @@ void lv_linemeter_set_value(lv_obj_t * lmeter, int32_t value)
int16_t level_new = int16_t level_new =
(int32_t)((int32_t)(ext->cur_value - ext->min_value) * (ext->line_cnt - 1)) / (ext->max_value - ext->min_value); (int32_t)((int32_t)(ext->cur_value - ext->min_value) * (ext->line_cnt - 1)) / (ext->max_value - ext->min_value);
if(level_new == level_old) { if(level_new == level_old) return;
return;
}
lv_style_int_t left = lv_obj_get_style_pad_left(lmeter, LV_LINEMETER_PART_MAIN);
lv_style_int_t right = lv_obj_get_style_pad_right(lmeter, LV_LINEMETER_PART_MAIN);
lv_style_int_t top = lv_obj_get_style_pad_top(lmeter, LV_LINEMETER_PART_MAIN);
lv_style_int_t bottom = lv_obj_get_style_pad_bottom(lmeter, LV_LINEMETER_PART_MAIN);
lv_coord_t r_out = (lv_obj_get_width(lmeter) - left - right) / 2 ;
lv_coord_t r_in = r_out - lv_obj_get_style_scale_width(lmeter, LV_LINEMETER_PART_MAIN);
if(r_in < 1) r_in = 1;
lv_coord_t x_ofs = lmeter->coords.x1 + r_out + left;
lv_coord_t y_ofs = lmeter->coords.y1 + r_out + top;
int16_t angle_ofs = ext->angle_ofs + 90 + (360 - ext->scale_angle) / 2;
lv_style_int_t line_width = lv_obj_get_style_scale_end_line_width(lmeter, LV_LINEMETER_PART_MAIN);
lv_style_int_t end_line_width = lv_obj_get_style_scale_end_line_width(lmeter, LV_LINEMETER_PART_MAIN);
line_width = LV_MATH_MAX(line_width, end_line_width);
int32_t angle_old = (level_old * ext->scale_angle) / (ext->line_cnt - 1);
/*Use smaller clip area only around the visible line*/
int32_t y_in_old = (int32_t)((int32_t)_lv_trigo_sin(angle_old + angle_ofs) * r_in) >> LV_TRIGO_SHIFT;
int32_t x_in_old = (int32_t)((int32_t)_lv_trigo_sin(angle_old + 90 + angle_ofs) * r_in) >> LV_TRIGO_SHIFT;
int32_t y_out_old = (int32_t)((int32_t)_lv_trigo_sin(angle_old + angle_ofs) * r_out) >> LV_TRIGO_SHIFT;
int32_t x_out_old = (int32_t)((int32_t)_lv_trigo_sin(angle_old + 90 + angle_ofs) * r_out) >> LV_TRIGO_SHIFT;
int32_t angle_new = (level_new * ext->scale_angle) / (ext->line_cnt - 1);
/*Use smaller clip area only around the visible line*/
int32_t y_in_new = (int32_t)((int32_t)_lv_trigo_sin(angle_new + angle_ofs) * r_in) >> LV_TRIGO_SHIFT;
int32_t x_in_new = (int32_t)((int32_t)_lv_trigo_sin(angle_new + 90 + angle_ofs) * r_in) >> LV_TRIGO_SHIFT;
int32_t y_out_new = (int32_t)((int32_t)_lv_trigo_sin(angle_new + angle_ofs) * r_out) >> LV_TRIGO_SHIFT;
int32_t x_out_new = (int32_t)((int32_t)_lv_trigo_sin(angle_new + 90 + angle_ofs) * r_out) >> LV_TRIGO_SHIFT;
lv_area_t a;
if(x_out_old < 0 && x_out_new < 0) {
a.x1 = lmeter->coords.x1 + left - line_width;
a.y1 = LV_MATH_MIN4(y_out_old, y_out_new, y_in_old, y_in_new) + y_ofs - line_width;
a.x2 = LV_MATH_MAX(x_in_old, x_in_new) + x_ofs + line_width;
a.y2 = LV_MATH_MAX4(y_out_old, y_out_new, y_in_old, y_in_new) + y_ofs + line_width;
}
else if(x_out_old > 0 && x_out_new > 0) {
a.x1 = LV_MATH_MIN(x_in_old, x_in_new) + x_ofs - line_width;
a.y1 = LV_MATH_MIN4(y_out_old, y_out_new, y_in_old, y_in_new) + y_ofs - line_width;
a.x2 = lmeter->coords.x2 - right + line_width;
a.y2 = LV_MATH_MAX4(y_out_old, y_out_new, y_in_old, y_in_new) + y_ofs + line_width;
}
else if(y_out_old < 0 && y_out_new < 0) {
a.x1 = LV_MATH_MIN4(x_out_old, x_out_new, x_in_old, x_in_new) + x_ofs - line_width;
a.y1 = lmeter->coords.y1 + top - line_width;
a.x2 = LV_MATH_MAX4(x_out_old, x_out_new, x_in_old, x_in_new) + x_ofs + line_width;
a.y2 = LV_MATH_MAX(y_in_old, y_in_new) + y_ofs + line_width;
}
else if(y_out_old > 0 && y_out_new > 0) {
a.x1 = LV_MATH_MIN4(x_out_old, x_out_new, x_in_old, x_in_new) + x_ofs - line_width;
a.y1 = LV_MATH_MIN(y_in_old, y_in_new) + y_ofs - line_width;
a.x2 = LV_MATH_MAX4(x_out_old, x_out_new, x_in_old, x_in_new) + x_ofs + line_width;
a.y2 = lmeter->coords.y2 - bottom + line_width;
}
else {
a.x1 = lmeter->coords.x1 + left - line_width;
a.y1 = lmeter->coords.y1 + top - line_width;
a.x2 = lmeter->coords.x2 - right + line_width;
a.y2 = lmeter->coords.y2 - bottom + line_width;
}
lv_obj_invalidate_area(lmeter, &a);
lv_obj_invalidate(lmeter);
} }
/** /**
@@ -521,7 +447,7 @@ void lv_linemeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uin
p1.y = y_out_extra; p1.y = y_out_extra;
/* Set the color of the lines */ /* Set the color of the lines */
if((!ext->mirrored && i >= level) || (ext->mirrored && i <= level)) { if((!ext->mirrored && i > level) || (ext->mirrored && i < level)) {
line_dsc.color = end_color; line_dsc.color = end_color;
line_dsc.width = end_line_width; line_dsc.width = end_line_width;
} }

View File

@@ -82,6 +82,7 @@ lv_obj_t * lv_slider_create(lv_obj_t * parent, const lv_obj_t * copy)
/*Initialize the allocated 'ext' */ /*Initialize the allocated 'ext' */
ext->value_to_set = NULL; ext->value_to_set = NULL;
ext->dragging = 0; ext->dragging = 0;
ext->right_knob_focus = 0;
lv_style_list_init(&ext->style_knob); lv_style_list_init(&ext->style_knob);
/*The signal and design functions are not copied so set them here*/ /*The signal and design functions are not copied so set them here*/
@@ -377,11 +378,24 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par
bool editing = lv_group_get_editing(g); bool editing = lv_group_get_editing(g);
lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act()); lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
if(indev_type == LV_INDEV_TYPE_ENCODER) { if(indev_type == LV_INDEV_TYPE_ENCODER) {
if(editing) lv_group_set_editing(g, false); 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 #endif
} }
else if(sign == LV_SIGNAL_FOCUS) {
ext->right_knob_focus = 0;
}
else if(sign == LV_SIGNAL_COORD_CHG) { else if(sign == LV_SIGNAL_COORD_CHG) {
/* The knob size depends on slider size. /* The knob size depends on slider size.
* During the drawing method the ext. size is used by the knob so refresh the ext. size.*/ * During the drawing method the ext. size is used by the knob so refresh the ext. size.*/
@@ -413,12 +427,16 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par
char c = *((char *)param); char c = *((char *)param);
if(c == LV_KEY_RIGHT || c == LV_KEY_UP) { if(c == LV_KEY_RIGHT || c == LV_KEY_UP) {
lv_slider_set_value(slider, lv_slider_get_value(slider) + 1, LV_ANIM_ON); if(ext->right_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); res = lv_event_send(slider, LV_EVENT_VALUE_CHANGED, NULL);
if(res != LV_RES_OK) return res; if(res != LV_RES_OK) return res;
} }
else if(c == LV_KEY_LEFT || c == LV_KEY_DOWN) { else if(c == LV_KEY_LEFT || c == LV_KEY_DOWN) {
lv_slider_set_value(slider, lv_slider_get_value(slider) - 1, LV_ANIM_ON); if(ext->right_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); res = lv_event_send(slider, LV_EVENT_VALUE_CHANGED, NULL);
if(res != LV_RES_OK) return res; if(res != LV_RES_OK) return res;
} }

View File

@@ -49,6 +49,7 @@ typedef struct {
lv_area_t right_knob_area; lv_area_t right_knob_area;
int16_t * value_to_set; /* Which bar value to set */ int16_t * value_to_set; /* Which bar value to set */
uint8_t dragging : 1; /*1: the slider is being dragged*/ 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*/
} lv_slider_ext_t; } lv_slider_ext_t;
/** Built-in styles of slider*/ /** Built-in styles of slider*/