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

evdev reverse mapping is broken #291

Open
elgerg opened this issue Sep 3, 2023 · 2 comments
Open

evdev reverse mapping is broken #291

elgerg opened this issue Sep 3, 2023 · 2 comments

Comments

@elgerg
Copy link
Contributor

elgerg commented Sep 3, 2023

Hi,

After the introduction of code based on:
#251

The reverse functionality based on doing thing like:

#  define EVDEV_CALIBRATE         1               /*Scale and offset the touchscreen coordinates by using maximum and minimum values for each axis*/

#  if EVDEV_CALIBRATE
#    define EVDEV_HOR_MIN         2000               /*to invert axis swap EVDEV_XXX_MIN by EVDEV_XXX_MAX*/
#    define EVDEV_HOR_MAX      0               /*"evtest" Linux tool can help to get the correct calibraion values>*/
#    define EVDEV_VER_MIN        2000
#    define EVDEV_VER_MAX      0
#  endif  /*EVDEV_CALIBRATE*/
#endif  /*USE_EVDEV*/

Does not work anymore.

I have a screen that I have rotated 180 defgees and when using the current lib with:

#if EVDEV_CALIBRATE
    evdev_root_x = LV_CLAMP(EVDEV_HOR_MIN, evdev_root_x, EVDEV_HOR_MAX);
    evdev_root_y = LV_CLAMP(EVDEV_VER_MIN, evdev_root_y, EVDEV_VER_MAX);

    data->point.x = map(evdev_root_x, EVDEV_HOR_MIN, EVDEV_HOR_MAX, 0, drv->disp->driver->hor_res);
    data->point.y = map(evdev_root_y, EVDEV_VER_MIN, EVDEV_VER_MAX, 0, drv->disp->driver->ver_res);
#else

Then all touch points seem to register as 0.

Using the following:

#if EVDEV_CALIBRATE
    //evdev_root_x = LV_CLAMP(EVDEV_HOR_MIN, evdev_root_x, EVDEV_HOR_MAX);
    //evdev_root_y = LV_CLAMP(EVDEV_VER_MIN, evdev_root_y, EVDEV_VER_MAX);

    data->point.x = map(evdev_root_x, EVDEV_HOR_MIN, EVDEV_HOR_MAX, 0, drv->disp->driver->hor_res);
    data->point.y = map(evdev_root_y, EVDEV_VER_MIN, EVDEV_VER_MAX, 0, drv->disp->driver->ver_res);
#else

It all works as expected.

Related forum post:
https://forum.lvgl.io/t/how-to-invert-x-and-y-axises-not-swap-them/12866/2

Any chance this change can check if a mouse is involved as apposed to a touch screen?

Thanks!

@elgerg elgerg changed the title endev reverse mapping is broken evdev reverse mapping is broken Sep 4, 2023
@kisvegabor
Copy link
Member

With lv_map LV_CLAMP is not required indeed. Could you send a Pull request?

elgerg added a commit to elgerg/lv_drivers that referenced this issue Sep 4, 2023
Removed clamp from Calibrate section as it has map in it.
lvgl#291
@elgerg elgerg mentioned this issue Sep 4, 2023
@elgerg
Copy link
Contributor Author

elgerg commented Sep 4, 2023

PR created but it's my first one. Let me know if you need anything correcting.

Thanks

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

2 participants