Problems using lvgl with touchscreen


  • Global Moderator

    I ported the lvgl8 arduino to my core2 today, it can run the lvgl_demo_benchmark in 39fps, the touch was fuction too.
    Then I tried to put the lvglhandler into a task by freertos (it was in loop before), with priority 3. It worked as well.

    So I put some other task in my code, the first one is a blink (by using m5.apx.setled and vtaskdelay), It worked too. Then I tested it with demos of benchmark, music and widgets. And blink task, lvgl and touch fuction were all normal.

    Seems everything went well, I changed the blink task into serial.println sth per 1s. Then I tested those 3 demos again, I found that the serial task worked well, lvgl worked well, but the touch funtion didn't worked. The serial task is sending thing every seconds normally, but i cant move the screen by touching in those demos, lvgl is working cus in benchmark demo, every tests is going but i cant move the screen to see the marks at the end of the demo.

    So I try change the task back to blink, the touch function again. Seems it's sth about serial affect the touch function? But i dont know why.
    Part of my code:

    Task of blink or serial:

    void Taskblink( void *pvParameters )
    {
    for(;;)
    {
    M5.Axp.SetLed(1);
    vTaskDelay(800);
    M5.Axp.SetLed(0);
    vTaskDelay(800);
    // Serial.println("i'm good..");
    // vTaskDelay(1000);
    }
    }

    Task of lvglhandler:

    void Tasklvglhandler( void pvParameters )
    {
    for(;;)
    {
    lv_timer_handler(); /
    let the GUI do its work */
    vTaskDelay(5);
    }
    }

    lvgl touchpad read recall
    void my_touchpad_read( lv_indev_drv_t * indev_driver, lv_indev_data_t * data )
    {
    TouchPoint_t coordinate;
    M5.Touch.getPressPoint();

    if (!M5.Touch.ispressed()){
        data->state = LV_INDEV_STATE_REL;
    } else {
        data->state = LV_INDEV_STATE_PR;
        /*Set the coordinates*/
        coordinate = M5.Touch.getPressPoint();
        data->point.x = coordinate.x;
        data->point.y = coordinate.y;
    }
    

    }

    Thanks for helping.



  • Hello @Forairaaaaa

    have you seen this posting?

    Thanks
    Felix


  • Global Moderator

    @felmue Thank you, I've learn a lot from it