Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Touch pad is unresponsive #3

Closed
Uup115 opened this issue Sep 8, 2019 · 15 comments
Closed

Touch pad is unresponsive #3

Uup115 opened this issue Sep 8, 2019 · 15 comments

Comments

@Uup115
Copy link

Uup115 commented Sep 8, 2019

Hello,

Thanks for the frame buffer example. These types of examples are a huge help.

I'm trying to get the mouse (touch pad) working... The following code gives me a light gray cursor (LV_SYMBOL_UP) in the upper left corner of the frame, as shown in the attached photo.

`// get an input device like mouse
lv_indev_drv_t indev_drv;
lv_indev_drv_init(&indev_drv);
indev_drv.type = LV_INDEV_TYPE_POINTER;
indev_drv.read_cb = evdev_read;

lv_indev_t * mouse_indev = lv_indev_drv_register(&indev_drv);
lv_obj_t * cursor_obj = lv_img_create(lv_scr_act(), NULL); //Create an image for the cursor
lv_img_set_src(cursor_obj, LV_SYMBOL_UP); //Add a built in symbol not an image
lv_indev_set_cursor(mouse_indev, cursor_obj); //Connect mouse object to the driver
`
When the LEFT touch pad button is pressed, Tab 1 is highlighted (buttons seem to be working). However, when I put my finger on the touch pad, the cursor disappears and buttons stop working.

Not sure why this is happening. Does anyone know?

Best Regards

lvgl_FrameBuffer

@embeddedt
Copy link
Member

Does the application crash, or does it just hang? Do you have the ability to debug using GDB?

@Uup115
Copy link
Author

Uup115 commented Sep 9, 2019

The application doesn't crash or hang. The text box cursor keeps blinking and the spinner (bottom left) keeps spinning. As soon as I put my finger on the touch pad, the touch pad cursor simply disappears and the touch pad buttons no longer work.

GDB also shows no evidence of hanging. I've attached the project for your reference. I must run as sudo ./demo. Otherwise, permission is denied for "evdev" interface.

Best Regards

lv_linux_frame_buffer_Uup115.tar.gz

@embeddedt
Copy link
Member

Can you run evtest <your input device>? What happens there when you put your finger on the touchpad? Do the events stop firing?

@Uup115
Copy link
Author

Uup115 commented Sep 9, 2019

Yes, from the X window console command prompt, I ran evtest many times yesterday. No issues. Touch events fire successfully.

However, now that you mention it... Perhaps, I should run evtest within the virtual console (Ctrl + Alt + F1). This is where ./demo actually runs. I'll try this, later this evening, and report back.

@Uup115
Copy link
Author

Uup115 commented Sep 9, 2019

Within the virtual console (Ctrl + Alt + F1), I ran sudo evtest /dev/input/event5. ALL touch pad events fire successfully. No issues.

@kisvegabor
Copy link
Member

Could you printf the coordinates passed to LittlevGL libinput_read?

@embeddedt
Copy link
Member

@kisvegabor I think he is using evdev_read, not libinput_read.

@kisvegabor
Copy link
Member

@embeddedt

I think he is using evdev_read, not libinput_read.

My bad, sorry. I meant evdev_read.

@Uup115
Copy link
Author

Uup115 commented Sep 10, 2019

Thanks to both of you for the insight!

It seems the touch pad's coordinates don't begin at zero for X & Y (something that never crossed my mind). Lines 208 - 211 of evdev.c are forcing the x & y data points outside (below) the touch pad's active coordinate range (x: 799, y: 479; which equals the frame's dimensions - 1).

if(data->point.x >= lv_disp_get_hor_res(drv->disp))
      data->point.x = lv_disp_get_hor_res(drv->disp) - 1;
if(data->point.y >= lv_disp_get_ver_res(drv->disp))
      data->point.y = lv_disp_get_ver_res(drv->disp) - 1;

In this case, scaling is needed. I expect calibration will also be needed, to keep the touch pad's cursor from moving outside of the frame. Scaling and Calibration can be adjusted within lv_drv_conf.h (lines 282 - 294):

#  define EVDEV_SCALE             0               /* Scale input, e.g. if touchscreen resolution does not match display resolution */
#  if EVDEV_SCALE
#    define EVDEV_SCALE_HOR_RES     (4096)          /* Horizontal resolution of touchscreen */
#    define EVDEV_SCALE_VER_RES     (4096)          /* Vertical resolution of touchscreen */
#  endif  /*EVDEV_SCALE*/

#  define EVDEV_CALIBRATE         0               /*Scale and offset the touchscreen coordinates by using maximum and minimum values for each axis*/
#  if EVDEV_CALIBRATE
#    define EVDEV_HOR_MIN   3800                    /*If EVDEV_XXX_MIN > EVDEV_XXX_MAX the XXX axis is automatically inverted*/
#    define EVDEV_HOR_MAX   200
#    define EVDEV_VER_MIN   200
#    define EVDEV_VER_MAX   3800
#  endif  /*EVDEV_SCALE*/

Is this the direction I should take, or should I do something else?

@kisvegabor
Copy link
Member

You should check raw the min max coordinates (e.g. printf them) and use them in EVDEV_HOR/VER_MIN/MAX.

@Uup115
Copy link
Author

Uup115 commented Sep 12, 2019

I now have the touch pad working! However, as the code is written, it's functioning similar to a touch screen, rather than a mouse. Not a problem though. I plan to use a touch screen anyway.

Thanks again, to the both of you, for the excellent support and learning experience!

@kisvegabor
Copy link
Member

Glad to hear that it works!

@Shabina-dotcom
Copy link

Can you help me, I am also facing same issue.

@Uup115
Copy link
Author

Uup115 commented Jun 12, 2023

Have you tried the tutorial? It's a challenge to get it working. What specifically are you having trouble with?

@Shabina-dotcom
Copy link

Have you tried the tutorial? It's a challenge to get it working. What specifically are you having trouble with?

I developed UI which is responsive in Display monitor using mouse, Same UI, I wanted to use with touch panel. But it is not responsive (touch is not working). I am using 1024x600 TFT LCD Display with capacitive touch panel. (Touch Screen Controller FT5406).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants