How to invert scrolling?

Hello,
I am using a Renesas RA6M3 microcontroller to drive the display I am using. It all works fine.

However, I am trying to flip the display via dedicated hardware, which visually speaking works well, but the touch inputs are read the wrong way around.

I have fixed this by simply inverting the read inputs in my input’s callback function:

void touch_read_cb(lv_indev_drv_t* drv, lv_indev_data_t* data)
{
    FSP_PARAMETER_NOT_USED(drv);

    if (xMessageBufferReceiveFromISR(g_touch_message_buffer, &touch_data, sizeof(touch_data_t), NULL))
    {
#if !FLIP_INPUT
        data->point.x = (lv_coord_t)touch_data.point[0].x;
        data->point.y = (lv_coord_t)touch_data.point[0].y;
#else
        data->point.x = (lv_coord_t)(DISP_HOR_RES - touch_data.point[0].x);
        data->point.y = (lv_coord_t)(DISP_VER_RES - touch_data.point[0].y);

#endif
        data->state = LV_INDEV_STATE_PRESSED;
    }
    else
    {
        data->state = LV_INDEV_STATE_RELEASED;
    }
}

This works fine for buttons and even sliders in the horizontal axis… but when I try to use scrollable objects in the vertical axis, the input is inverted. I understand WHY this happens, but is there an easy fix?

EDIT: Sorry to bother you, @kisvegabor but I really think you are the only person who might know this and I’m still pondering this issue. Inverting the display using LVGL also inverts touch, so it is definitely possible.

Hi,

Just to be sure, you don’t set disp_drv->rotated, right? So LVGL doesn’t want to do any flipping internally.

To better see what’s going on, please create a cursor like this:

  lv_obj_t * cursor_obj = lv_img_create(lv_scr_act()); /*Create an image object for the cursor */
  lv_img_set_src(cursor_obj, LV_SYMBOL_HOME);           /*Set the image source*/
  lv_indev_set_cursor(mouse_indev, cursor_obj);             /*Connect the image  object to the driver*/

and send a video about it.

1 Like

Hello,

First of all, thanks for responding and I am very sorry for the very late response.

Since asking this question I have moved on to LVGL V9, in which I am now able to rotate the display in hardware. Using the (new?) lv_display_set_rotation() function, touch is also inverted properly.
The trick now is to just NOT invert the coordinates yourself.

1 Like