Touch event handling on NXP RT1064 EVK not working with LVGL 7.0.2, causes distortion of frame buffer


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

Using MCUExpresso IDE from NXP
I have a 480p x 272p LCD touchscreen attached to the board, I have ran other programs that involve touch on it (and previous version of LVGL) and the display works perfectly as expected.

What do you want to achieve?

Touch events to work as expected.

What have you tried so far?

Implemented touch event handling and a test button in LVGL 5.2 (works)
Implemented touch event handling and a test button in LVGL 7.0.2 (does not work as expected)

Code to reproduce

void lv_port_indev_init(void)
    lv_indev_drv_t indev_drv;

     * Touchpad
     * -----------------*/

    /*Initialize your touchpad */

    indev_drv.type = LV_INDEV_TYPE_POINTER;
    indev_drv.read_cb = touchpad_read;
    indev_touchpad = lv_indev_drv_register(&indev_drv);

static void DEMO_InitTouch(void)
    status_t status;

    lpi2c_master_config_t masterConfig = {0};

    /*Clock setting for LPI2C*/

     * masterConfig.debugEnable = false;
     * masterConfig.ignoreAck = false;
     * masterConfig.pinConfig = kLPI2C_2PinOpenDrain;
     * masterConfig.baudRate_Hz = 100000U;
     * masterConfig.busIdleTimeout_ns = 0;
     * masterConfig.pinLowTimeout_ns = 0;
     * masterConfig.sdaGlitchFilterWidth_ns = 0;
     * masterConfig.sclGlitchFilterWidth_ns = 0;

    /* Change the default baudrate configuration */
    masterConfig.baudRate_Hz = TOUCH_I2C_BAUDRATE;

    /* Initialize the LPI2C master peripheral */
    LPI2C_MasterInit(TOUCH_I2C, &masterConfig, TOUCH_I2C_CLOCK_FREQ);

    /* Initialize touch panel controller */
    status = FT5406_RT_Init(&touchHandle, TOUCH_I2C);
    if (status != kStatus_Success)
        PRINTF("Touch panel init failed\n");


lv_obj_t * btn = lv_btn_create(lv_scr_act(), NULL);     /*Add a button the current screen*/
lv_obj_set_pos(btn, 10, 10);                            /*Set its position*/
lv_obj_set_size(btn, 100, 50);                          /*Set its size*/
lv_obj_set_event_cb(btn, btn_event_cb);                 /*Assign a callback to the button*/

lv_obj_t * label = lv_label_create(btn, NULL);          /*Add a label to the button*/
lv_label_set_text(label, "Button");                     /*Set the labels text*/


void btn_event_cb(lv_obj_t * btn, lv_event_t event)
    if(event == LV_EVENT_CLICKED) {

Screenshot and/or video

When I click the button which does display perfectly, distortion occurs at the top of the screen.

The post template says to include a video but I cannot add links, so the link is broken up below to a video of me clicking the button and the distortion appearing. Remove the spaces.

streamable . c o m /15cfz7

The contents of touchpad_read()

static bool touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
    touch_event_t touch_event;
    static int touch_x = 0;
    static int touch_y = 0;

    if (kStatus_Success == FT5406_RT_GetSingleTouch(&touchHandle, &touch_event, &touch_x, &touch_y))
        data->state = LV_INDEV_STATE_PR;
    } else {
        data->state = LV_INDEV_STATE_REL;

    /*Set the last pressed coordinates*/
    data->point.x = touch_y;
    data->point.y = touch_x;

    /*Return `false` because we are not buffering and no more data to read*/
    return false;

Yes, I am aware x/y are inverted, un-inverting it does not change the issue.

Let’s keep the discussion in one place (

did you solve this problem?