Important: unclear posts may not receive useful answers.
Before posting
- Get familiar with Markdown to format and structure your post
- Be sure to update lvgl from the latest version from the
master
branch.
- Be sure you have checked the FAQ and read the relevant part of the documentation.
- If applicable use the Simulator to eliminate hardware related issues.
Delete this section if you read and applied the mentioned points.
Description
What MCU/Processor/Board and compiler are you using?
BES2700BP
What LVGL version are you using?
I am using LVGL 8.3
What do you want to achieve?
I am syncing the commit of #5057, some functions depend on some previous modifications, such as send_event(LV_EVENT_ROTARY, &diff);
. What other previous modifications do I also need to sync? Thank you.
What have you tried so far?
syncing the commit of #5057
Code to reproduce
Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.
The code block(s) should be formatted like:
/*You code here*/
Screenshot and/or video
If possible, add screenshots and/or videos about the current state.
Itās might be complicated to cherry-pick this feature from v9 to v8.
What is the main problem with updating your project to v9?
Hi kisvegabor,
The current code has been merged for adaptation, but the rotary knob is not responding. However, some functions are missing, and I am still using version 8, I am not sure if it has any impact.
/* get crown movemnet_px */
static void lv_knob_read(lv_indev_drv_t *indev_drv, lv_indev_data_t *data)
{
static lv_coord_t last_y = 0;
static int16_t knob_diff = 0;
if (knob_is_rotating()) {
knob_get_movement_px(&knob_diff);
STO_LOG_ERR(T_DRV_KNOB, ">>> knob_diff: %3d", knob_diff);
data->enc_diff = knob_diff;
data->state = LV_INDEV_STATE_PR;
} else {
data->state = LV_INDEV_STATE_REL;
}
}`
static void indev_proc_pointer_diff(lv_indev_t * indev)
{
lv_obj_t * obj = indev->proc.types.pointer.last_pressed;
if(obj == NULL) {
LV_LOG_WARN("obj is NULL.");
return;
}
if(indev->proc.types.pointer.diff == 0) {
LV_LOG_WARN("diff is 0.");
return;
}
indev_obj_act = obj;
bool editable = lv_obj_is_editable(obj);
if(editable) {
uint32_t indev_sensitivity = indev->driver->rotary_sensitvity;
uint32_t obj_sensitivity = lv_obj_get_style_rotary_sensitivity(indev_obj_act, 0);
int32_t diff = (int32_t)((int32_t)indev->proc.types.pointer.diff * indev_sensitivity * obj_sensitivity + 32768) >> 16;
// send_event(LV_EVENT_ROTARY, &diff);
lv_event_send(indev_obj_act, LV_EVENT_ROTARY, &diff);
}
else {
int32_t vect = indev->proc.types.pointer.diff > 0 ? indev->driver->scroll_limit : -indev->driver->scroll_limit;
indev->proc.types.pointer.vect.y = vect;
indev->proc.types.pointer.act_obj = obj;
lv_obj_t * scroll_obj = find_scroll_obj(&(indev->proc));
if(scroll_obj == NULL) {
LV_LOG_WARN("scroll_obj is NULL.");
return;
}
uint32_t indev_sensitivity = indev->driver->rotary_sensitvity;
uint32_t obj_sensitivity = lv_obj_get_style_rotary_sensitivity(scroll_obj, 0);
int32_t diff = (int32_t)((int32_t)indev->proc.types.pointer.diff * indev_sensitivity * obj_sensitivity + 32768) >> 16;
indev->proc.types.pointer.scroll_throw_vect.y = diff;
indev->proc.types.pointer.scroll_throw_vect_ori.y = diff;
_lv_indev_scroll_handler(&(indev->proc));
}
}
For a watch crown that only functions to scroll through the menu list, is āeditableā always set to āfalseā, and therefore no āLV_EVENT_ROTARYā event will be generated? Iām not sure if my understanding is correct.
The mouse-related code has not been merged; currently, it is not needed for the crown.
A total of 22 files have been modified.
The function āindev_proc_pressā has not been modified.
/**
* Process the pressed state of LV_INDEV_TYPE_POINTER input devices
* @param indev pointer to an input device 'proc'
* @return LV_RES_OK: no indev reset required; LV_RES_INV: indev reset is required
*/
static void indev_proc_press(_lv_indev_proc_t * proc)
{
LV_LOG_INFO("pressed at x:%d y:%d", proc->types.pointer.act_point.x, proc->types.pointer.act_point.y);
indev_obj_act = proc->types.pointer.act_obj;
if(proc->wait_until_release != 0) return;
lv_disp_t * disp = indev_act->driver->disp;
bool new_obj_searched = false;
/*If there is no last object then search*/
if(indev_obj_act == NULL) {
indev_obj_act = lv_indev_search_obj(lv_disp_get_layer_sys(disp), &proc->types.pointer.act_point);
if(indev_obj_act == NULL) indev_obj_act = lv_indev_search_obj(lv_disp_get_layer_top(disp),
&proc->types.pointer.act_point);
if(indev_obj_act == NULL) indev_obj_act = lv_indev_search_obj(lv_disp_get_scr_act(disp),
&proc->types.pointer.act_point);
new_obj_searched = true;
}
/*If there is last object but it is not scrolled and not protected also search*/
else if(proc->types.pointer.scroll_obj == NULL &&
lv_obj_has_flag(indev_obj_act, LV_OBJ_FLAG_PRESS_LOCK) == false) {
indev_obj_act = lv_indev_search_obj(lv_disp_get_layer_sys(disp), &proc->types.pointer.act_point);
if(indev_obj_act == NULL) indev_obj_act = lv_indev_search_obj(lv_disp_get_layer_top(disp),
&proc->types.pointer.act_point);
if(indev_obj_act == NULL) indev_obj_act = lv_indev_search_obj(lv_disp_get_scr_act(disp),
&proc->types.pointer.act_point);
new_obj_searched = true;
}
/*The last object might have scroll throw. Stop it manually*/
if(new_obj_searched && proc->types.pointer.last_obj) {
proc->types.pointer.scroll_throw_vect.x = 0;
proc->types.pointer.scroll_throw_vect.y = 0;
_lv_indev_scroll_throw_handler(proc);
if(indev_reset_check(proc)) return;
}
/*If a new object was found reset some variables and send a pressed event handler*/
if(indev_obj_act != proc->types.pointer.act_obj) {
proc->types.pointer.last_point.x = proc->types.pointer.act_point.x;
proc->types.pointer.last_point.y = proc->types.pointer.act_point.y;
/*If a new object found the previous was lost, so send a Call the ancestor's event handler*/
if(proc->types.pointer.act_obj != NULL) {
/*Save the obj because in special cases `act_obj` can change in the Call the ancestor's event handler function*/
lv_obj_t * last_obj = proc->types.pointer.act_obj;
lv_event_send(last_obj, LV_EVENT_PRESS_LOST, indev_act);
if(indev_reset_check(proc)) return;
}
proc->types.pointer.act_obj = indev_obj_act; /*Save the pressed object*/
proc->types.pointer.last_obj = indev_obj_act;
if(indev_obj_act != NULL) {
/*Save the time when the obj pressed to count long press time.*/
proc->pr_timestamp = lv_tick_get();
proc->long_pr_sent = 0;
proc->types.pointer.scroll_sum.x = 0;
proc->types.pointer.scroll_sum.y = 0;
proc->types.pointer.scroll_dir = LV_DIR_NONE;
proc->types.pointer.gesture_dir = LV_DIR_NONE;
proc->types.pointer.gesture_sent = 0;
proc->types.pointer.gesture_sum.x = 0;
proc->types.pointer.gesture_sum.y = 0;
proc->types.pointer.vect.x = 0;
proc->types.pointer.vect.y = 0;
/*Call the ancestor's event handler about the press*/
lv_event_send(indev_obj_act, LV_EVENT_PRESSED, indev_act);
if(indev_reset_check(proc)) return;
if(indev_act->proc.wait_until_release) return;
/*Handle focus*/
indev_click_focus(&indev_act->proc);
if(indev_reset_check(proc)) return;
}
}
/*Calculate the vector and apply a low pass filter: new value = 0.5 * old_value + 0.5 * new_value*/
proc->types.pointer.vect.x = proc->types.pointer.act_point.x - proc->types.pointer.last_point.x;
proc->types.pointer.vect.y = proc->types.pointer.act_point.y - proc->types.pointer.last_point.y;
proc->types.pointer.scroll_throw_vect.x = (proc->types.pointer.scroll_throw_vect.x + proc->types.pointer.vect.x) / 2;
proc->types.pointer.scroll_throw_vect.y = (proc->types.pointer.scroll_throw_vect.y + proc->types.pointer.vect.y) / 2;
proc->types.pointer.scroll_throw_vect_ori = proc->types.pointer.scroll_throw_vect;
if(indev_obj_act) {
lv_event_send(indev_obj_act, LV_EVENT_PRESSING, indev_act);
if(indev_reset_check(proc)) return;
if(indev_act->proc.wait_until_release) return;
_lv_indev_scroll_handler(proc);
if(indev_reset_check(proc)) return;
indev_gesture(proc);
if(indev_reset_check(proc)) return;
/*If there is no scrolling then check for long press time*/
if(proc->types.pointer.scroll_obj == NULL && proc->long_pr_sent == 0) {
/*Call the ancestor's event handler about the long press if enough time elapsed*/
if(lv_tick_elaps(proc->pr_timestamp) > indev_act->driver->long_press_time) {
lv_event_send(indev_obj_act, LV_EVENT_LONG_PRESSED, indev_act);
if(indev_reset_check(proc)) return;
/*Mark the Call the ancestor's event handler sending to do not send it again*/
proc->long_pr_sent = 1;
/*Save the long press time stamp for the long press repeat handler*/
proc->longpr_rep_timestamp = lv_tick_get();
}
}
/*Send long press repeated Call the ancestor's event handler*/
if(proc->types.pointer.scroll_obj == NULL && proc->long_pr_sent == 1) {
/*Call the ancestor's event handler about the long press repeat if enough time elapsed*/
if(lv_tick_elaps(proc->longpr_rep_timestamp) > indev_act->driver->long_press_repeat_time) {
lv_event_send(indev_obj_act, LV_EVENT_LONG_PRESSED_REPEAT, indev_act);
if(indev_reset_check(proc)) return;
proc->longpr_rep_timestamp = lv_tick_get();
}
}
}
}
Hi kisvegabor,
Currently, there are several other issues with the project. My original intention was to make minimal changes to avoid triggering additional problems, and I plan to upgrade in new projects in the future, which is why I havenāt upgraded to version 9. Do you have any good suggestions?
Iām sorry, but in lack of time I cannot immerse in this topic now. 
To find the root of the issue I recommend debugging it on PC. By clicking through the code you should find where the information is lost. At least Iād do this.
Iām planning to use the lv_port_win_codeblock simulator for debugging. Thank you.
1 Like