How to invert x and y axises (not swap them)

Description

I have a Raspberry Pi with a 7 inch HDMI touch screen. I can rotate the screen by adding the following into the /boot/config.txt:
display_hdmi_rotate=2

However I am struggling to get the touch co-ordinates to rotate properly as well.

What MCU/Processor/Board and compiler are you using?

Pi Zero 2W

What LVGL version are you using?

8.3.9

What do you want to achieve?

I would like to rotate the touch co-ordinates to match the screen, IE rotated by 180 degrees.

What have you tried so far?

I have tried changing the following:

#  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         0               /*to invert axis swap EVDEV_XXX_MIN by EVDEV_XXX_MAX*/
#    define EVDEV_HOR_MAX      2000               /*"evtest" Linux tool can help to get the correct calibraion values>*/
#    define EVDEV_VER_MIN        20
#    define EVDEV_VER_MAX      2000
#  endif  /*EVDEV_CALIBRATE*/
#endif  /*USE_EVDEV*/

to:

#  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*/

But it looks like when I do press anything it always assumes that the touch co-ordinates are at the top left (0,0).

I’ve looked to see if there is a way to do this outside of LVGL but it seems like the only options would be to alter the xorg config, as I am not using xorg this isn’t really an option.

Code to reproduce

As above

Any help would be appreciated.

Thanks

Ok, weird interesting addition.

I have some other machines using different lv_drivers to the one I just cloned, once I copied one of those over with the corrected inverse defines it worked as expected.

I think I need to raise a bug.

I think I have managed to track it down.

It starts with this new addition here:

I’m not sure what this is supposed to do but it is to somehow convert 2000 from x and y to 1024/600 ?

Update:
If you update 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

to be:

#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 it works as expected. Is this intended if not what should I be doing to use this correctly?

Issue raised here:

@kisvegabor / @pete-pjb

Any ideas?

Thanks in advance!

Submitted PR and it’s been merged.