mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-21 06:53:01 +08:00
Test sensitivity threshold for value jumping
This commit is contained in:
parent
ad990994d0
commit
856368284e
@ -332,31 +332,31 @@ static lv_res_t lv_rotary_signal(lv_obj_t * rotary, lv_signal_t sign, void * par
|
||||
}
|
||||
else if(sign == LV_SIGNAL_PRESSING) {
|
||||
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;
|
||||
}
|
||||
ext->last_drag_x = p.x;
|
||||
|
||||
if (ext->last_drag_x == -1) {
|
||||
ext->last_drag_x = p.x;
|
||||
} else {
|
||||
lv_coord_t drag_x_diff = p.x - ext->last_drag_x;
|
||||
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);
|
||||
res = lv_event_send(rotary, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
if(res != LV_RES_OK) return res;
|
||||
}
|
||||
else if (drag_x_diff < 0 && p.x > ext->knob_area.x1) {
|
||||
ext->last_drag_x = p.x;
|
||||
lv_rotary_set_value(rotary, lv_rotary_get_value(rotary) + drag_x_diff * ext->sensitivity, LV_ANIM_ON);
|
||||
res = lv_event_send(rotary, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
if(res != LV_RES_OK) return res;
|
||||
}
|
||||
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);
|
||||
res = lv_event_send(rotary, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
if(res != LV_RES_OK) return res;
|
||||
}
|
||||
else if (drag_x_diff < 0 && p.x > ext->knob_area.x1) {
|
||||
ext->last_drag_x = p.x;
|
||||
lv_rotary_set_value(rotary, lv_rotary_get_value(rotary) + drag_x_diff * ext->sensitivity, LV_ANIM_ON);
|
||||
res = lv_event_send(rotary, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
if(res != LV_RES_OK) return res;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if(sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESS_LOST) {
|
||||
ext->dragging = false;
|
||||
ext->last_drag_x = -1; /** Reset drag diff calc */
|
||||
|
||||
#if LV_USE_GROUP
|
||||
/*Leave edit mode if released. (No need to wait for LONG_PRESS) */
|
||||
|
Loading…
x
Reference in New Issue
Block a user