Description
Once 180° display rotation is enabled (fbdev device), the touchscreen (evdev device) is not working correctly and the coordinates seems swapped/wrong.
After rotation the library notify me with LOG messages that indicates the coordinates are negative.
PREMISE: The display resolution is 800x480 instead the touchscreen is a 2047x2047, so calibration is needed from my side.
Thank you in advance for the support
What MCU/Processor/Board and compiler are you using?
ARM Linux (NXP IMX6)
What LVGL version are you using?
LVGL v.9.1
What do you want to achieve?
I’ve temporary workaround the problem and the device is now working (see below), but I want to notify you about the strange behaviour of the library and maybe you can guide me to the correct manner for fix my problem.
What have you tried so far?
- I’ve temporary fix the problem calling differently the method lv_evdev_set_calibration(…) in case the display is rotated:
-
DISPLAY NOT ROTATED → lv_evdev_set_calibration(touch, 0, 0, 2047, 2047);
-
DISPLAY ROTATED → lv_evdev_set_calibration(touch, 2047, 2047, 0, 0);
- I’ve also modified the file lv_indev.c as follows:
if(disp->rotation == LV_DISPLAY_ROTATION_180 || disp->rotation == LV_DISPLAY_ROTATION_270) {
data->point.x = (disp->hor_res - data->point.x - 1) * -1;
data->point.y = (disp->ver_res - data->point.y - 1) * -1;
}
Code to reproduce
#include "generated/ui.h"
#define ROTATE_DISPLAY
int main() {
lv_init();
/*DISPLAY*/
lv_display_t *disp = lv_linux_fbdev_create();
lv_linux_fbdev_set_file(disp, "/dev/fb0");
lv_display_set_resolution(disp, 800, 480);
lv_display_set_physical_resolution(disp, 800, 480);
/*TOUCHSCREEN*/
lv_indev_t *touch = lv_evdev_create(LV_INDEV_TYPE_POINTER, "/dev/input/event4");
#ifdef ROTATE_DISPLAY
lv_evdev_set_calibration(touch, 2047, 2047, 0, 0);
lv_display_set_rotation(disp, LV_DISPLAY_ROTATION_180);
#else
lv_evdev_set_calibration(touch, 0, 0, 2047, 2047);
#endif
lv_indev_set_display(touch, disp);
ui_init();
while (true) {
lv_timer_handler();
lv_tick_inc( 10 );
}
}