Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XPT2046 from time to time does not work #208

Open
Silvesterrr opened this issue Sep 23, 2022 · 0 comments
Open

XPT2046 from time to time does not work #208

Silvesterrr opened this issue Sep 23, 2022 · 0 comments

Comments

@Silvesterrr
Copy link

I've seen some weid problem with XPT2046. Im using esp32-s3 with ILI9486 driver and XPT2046 driver + SD card on the same SPI bus. Everything works fine but from time to time the touch stops working. The command line does not show any difference to proper working run.
The "Solution" is to unplug the SPI connector plug it back in and reboot. Than it works without any problem.
Here is my initialization:

static void guiTask(void *pvParameter)
{
    esp_err_t rc;

    xGuiSemaphore = xSemaphoreCreateMutex();

    lv_init();

    lvgl_driver_init();
    lv_color_t *buf1 = heap_caps_malloc(DISP_BUF_SIZE * sizeof(lv_color_t), MALLOC_CAP_DMA);
    assert(buf1 != NULL);

    lv_color_t *buf2 = heap_caps_malloc(DISP_BUF_SIZE * sizeof(lv_color_t), MALLOC_CAP_DMA);
    assert(buf2 != NULL);

    static lv_disp_draw_buf_t disp_buf;

    uint32_t size_in_px = DISP_BUF_SIZE;

    lv_disp_draw_buf_init(&disp_buf, buf1, buf2, size_in_px);

    lv_disp_drv_t disp_drv;
    lv_disp_drv_init(&disp_drv);
    disp_drv.flush_cb = disp_driver_flush;
    disp_drv.draw_buf = &disp_buf;
    disp_drv.ver_res = 320;
    disp_drv.hor_res = 480;
    lv_disp_drv_register(&disp_drv);

    lv_indev_drv_t indev_drv;
    lv_indev_drv_init(&indev_drv);
    indev_drv.read_cb = touch_driver_read;
    indev_drv.type = LV_INDEV_TYPE_POINTER;
    lv_indev_drv_register(&indev_drv);

    const esp_timer_create_args_t periodic_timer_args = {
        .callback = &lv_tick_task,
        .name = "periodic_gui"};
    esp_timer_handle_t periodic_timer;
    esp_timer_create(&periodic_timer_args, &periodic_timer);
    esp_timer_start_periodic(periodic_timer, LV_TICK_PERIOD_MS * 1000);

    keypad_lvgl_port_init();

    main_tabview();

    sd_card_lvgl_port_init();


    lv_timer_create(memory_monitor, 3000, NULL); // to delete

    while (1)
    {
        vTaskDelay(pdMS_TO_TICKS(100));
        if (pdTRUE == xSemaphoreTake(xGuiSemaphore, portMAX_DELAY))
        {
            lv_task_handler();

            xSemaphoreGive(xGuiSemaphore);
        }
    }
}

static void lv_tick_task(void *arg)
{
    (void)arg;
    lv_tick_inc(LV_TICK_PERIOD_MS);
}

Waiting for any response :)

@Silvesterrr Silvesterrr changed the title XPT2046 from time to tile does not work XPT2046 from time to time does not work Sep 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant