Coordinates to callback mapping

I am pretty new to LVGL. This is start of my first project.


I am able to get x and y coordinates through lv_port_indev.c.
I am able to make a sample GUI and define its callback.

When I press the screen, I am able to get the touch coordinates in lv_port_indev but I do not get any button callback.

Do I have to manually map the touch input coordinates to button and manually define callbacks? I can not get callbacks automatically.

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


What LVGL version are you using?


What do you want to achieve?

I have touch coordinates but I do not get button callback. Pleae guide how to map these cooridnates to callback or I am thinking in wrong direction. There is a different approach?

What have you tried so far?

I am planning to define button maps and manually check where the touch input coordinates are and then make manual callback.

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

Get coordinates

static bool touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
static lv_coord_t last_x = 0;
static lv_coord_t last_y = 0;
int screen_id = ((struct disp_data*)(indev_drv->disp->driver.user_data))->sdm->handle->display_id;
/Save the pressed coordinates and the state/
if(touchpad_is_pressed(screen_id)) {
touchpad_get_xy(&last_x, &last_y, screen_id);
data->state = LV_INDEV_STATE_PR;

    >>>>>>> printf("%d   %d \n", last_x, last_y);
} else {
    data->state = LV_INDEV_STATE_REL;

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

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


static void content_create(lv_obj_t * parent)
    show_bg(parent, PNG_RES_PATH("img_background"));
    printf("Hello World 123456789");

    FL_TemperaturePlus_btn = lv_imgbtn_create(lv_scr_act(),NULL);
    lv_obj_set_event_cb(FL_TemperaturePlus_btn, imgbtn_event_handler);
static void imgbtn_event_handler(lv_obj_t *obj, lv_event_t e)
	printf("I AM IN imgbtn_event_handler \n");

	if(e == LV_EVENT_CLICKED) {
		if(obj == FL_TemperaturePlus_btn) {
			printf("--imgbtn_event_handler---click FL_TemperaturePlus_btn\n");


## Screenshot and/or video
If possible, add screenshots and/or videos about the current state.
May be not required.