I'm about to give up / Touchscreen

Hi there,

My simple goal - “Button and action”. :smile:

This is my code:

#include "lvgl/lvgl.h"
#include "lv_drivers/display/fbdev.h"
#include "lv_drivers/indev/evdev.h"
#include <unistd.h>
#include <pthread.h>
#include <time.h>
#include <sys/time.h>
#include <stdio.h>

#define DISP_BUF_SIZE (80*LV_HOR_RES_MAX)

void btn_event_cb(lv_obj_t * btn, lv_event_t event)
{
    if(event == LV_EVENT_CLICKED) {
        printf("Clicked\n");
    }
}

int main(void)
{

    lv_init();

    fbdev_init();

    static lv_color_t buf[DISP_BUF_SIZE];

    static lv_disp_buf_t disp_buf;
    lv_disp_buf_init(&disp_buf, buf, NULL, DISP_BUF_SIZE);

    lv_disp_drv_t disp_drv;
    lv_disp_drv_init(&disp_drv);
    disp_drv.buffer = &disp_buf;
    disp_drv.flush_cb = fbdev_flush;
    lv_disp_drv_register(&disp_drv);


    evdev_init();
    lv_indev_drv_t indev_drv;
    lv_indev_drv_init(&indev_drv);
    indev_drv.type = LV_INDEV_TYPE_POINTER;
    indev_drv.read_cb = evdev_read;
    lv_indev_drv_register(&indev_drv);    /*Add a display the LittlevGL sing the frame buffer driver*/


    lv_obj_t * btn = lv_btn_create(lv_scr_act(), NULL);     
    lv_obj_set_pos(btn, 10, 10);                            
    lv_obj_set_size(btn, 300, 200);                          
    lv_obj_set_event_cb(btn, btn_event_cb);               
    lv_obj_t * label = lv_label_create(btn, NULL);       
    lv_label_set_text(label, "Button");                 

    /*Handle LitlevGL tasks (tickless mode)*/
    while(1) {
        lv_task_handler();
        usleep(5000);

    }
    return 0;
}

I’m using a Raspberry with an attached touchscreen. Evtest shows everything is fine with /dev/input/event1.

lv_conf.h:

#define LV_HOR_RES_MAX (800)
#define LV_VER_RES_MAX (480)
#define LV_COLOR_DEPTH 32

lv_drv_conf.h:

#define USE_EVDEV 1
#LIBINPUT_NAME “/dev/input/event1”
#define USE_FBDEV 1
#define FBDEV_PATH “/dev/fb0”

Screen is working fine as expected but I don’t get any feedback from my button. I’m sure it must be a silly mistake…

Any ideas?

Thank you very much in advance.