diff --git a/src/lv_widgets/lv_rotary.c b/src/lv_widgets/lv_rotary.c index 7dc88d4cc..d6a3253ec 100644 --- a/src/lv_widgets/lv_rotary.c +++ b/src/lv_widgets/lv_rotary.c @@ -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); @@ -173,6 +174,8 @@ void lv_rotary_set_range(lv_obj_t * rotary, int16_t min, int16_t max) if(ext->cur_value > 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,12 +337,12 @@ 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; - + if (ext->knob_area.y1 < p.y && p.y < ext->knob_area.y2) { if (drag_x_diff > 0 && p.x < ext->knob_area.x2) { lv_rotary_set_value(rotary, lv_rotary_get_value(rotary) + drag_x_diff * ext->sensitivity, LV_ANIM_ON); diff --git a/src/lv_widgets/lv_rotary.h b/src/lv_widgets/lv_rotary.h index 65766812e..07dc308cd 100644 --- a/src/lv_widgets/lv_rotary.h +++ b/src/lv_widgets/lv_rotary.h @@ -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;