lvgl / lv_port_linux

LVGL configured to work with a standard Linux framebuffer
MIT License
258 stars 160 forks source link

Touch pad is unresponsive #3

Closed Uup115 closed 5 years ago

Uup115 commented 5 years ago

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 commented 5 years ago

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

Uup115 commented 5 years ago

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 commented 5 years ago

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

Uup115 commented 5 years ago

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 commented 5 years ago

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

kisvegabor commented 5 years ago

Could you printf the coordinates passed to LittlevGL libinput_read?

embeddedt commented 5 years ago

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

kisvegabor commented 5 years ago

@embeddedt

I think he is using evdev_read, not libinput_read.

My bad, sorry. I meant evdev_read.

Uup115 commented 5 years ago

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 commented 5 years ago

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

Uup115 commented 5 years ago

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 commented 5 years ago

Glad to hear that it works!

Shabina-dotcom commented 1 year ago

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

Uup115 commented 1 year ago

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

Shabina-dotcom commented 1 year ago

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).