mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-21 06:53:01 +08:00
Test threshold for value jupming
This commit is contained in:
parent
856368284e
commit
e1761d50a1
@ -109,6 +109,7 @@ lv_obj_t * lv_rotary_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->dragging = copy_ext->dragging;
|
||||
ext->sym = copy_ext->sym;
|
||||
ext->sensitivity = copy_ext->sensitivity;
|
||||
ext->threshold = copy_ext->threshold;
|
||||
lv_style_list_copy(&ext->style_knob, ©_ext->style_knob);
|
||||
|
||||
lv_obj_refresh_style(rotary, LV_OBJ_PART_ALL);
|
||||
@ -174,6 +175,8 @@ void lv_rotary_set_range(lv_obj_t * rotary, int16_t min, int16_t max)
|
||||
ext->cur_value = max;
|
||||
}
|
||||
|
||||
ext->threshold = (abs(ext->min_value) + abs(ext->max_value)) / 10;
|
||||
|
||||
lv_rotary_set_value(rotary, ext->cur_value, false);
|
||||
}
|
||||
|
||||
@ -334,9 +337,9 @@ static lv_res_t lv_rotary_signal(lv_obj_t * rotary, lv_signal_t sign, void * par
|
||||
lv_indev_get_point(param, &p);
|
||||
lv_coord_t drag_x_diff = p.x -ext->last_drag_x;
|
||||
|
||||
if (abs(drag_x_diff) > abs(ext->sensitivity)) {
|
||||
if (drag_x_diff > 0) drag_x_diff = ext->sensitivity;
|
||||
else drag_x_diff = -ext->sensitivity;
|
||||
if (abs(drag_x_diff) > ext->threshold) {
|
||||
if (drag_x_diff > 0) drag_x_diff = ext->threshold;
|
||||
else drag_x_diff = -ext->threshold;
|
||||
}
|
||||
ext->last_drag_x = p.x;
|
||||
|
||||
|
@ -68,6 +68,7 @@ typedef struct {
|
||||
int16_t min_value; /*Minimum value of the rotary*/
|
||||
int16_t max_value; /*Maximum value of the rotary*/
|
||||
int16_t sensitivity; /*Increment multiplier of the rotary*/
|
||||
int16_t threshold; /*Increment threshold of the rotary*/
|
||||
lv_coord_t last_drag_x; /*Last drag x coordintate of the rotary*/
|
||||
uint16_t dragging :1;
|
||||
uint16_t sym :1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user