No-Touch GUI with Button

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


What do you want to achieve?

add a button as in device

What have you tried so far?

I consult materials at to give you, but it won’t work, I can assure you my key program is right.
I can detect that the data-> BTN is changing, but it is not a trigger event source for BTN

Code to reproduce

bool button_read(lv_indev_data_t*data){
    static uint32_t last_btn = 0;   /*Store the last pressed button*/
	int btn_pr=0;
     btn_pr = KEY_Scan();     /*Get the ID (0,1,2...) of the pressed button*/
    if(btn_pr >= 1) {               /*Is there a button press? (E.g. -1 indicated no button was pressed)*/
       last_btn = btn_pr;           /*Save the ID of the pressed button*/
       data->state = LV_INDEV_STATE_PR;  /*Set the pressed state*/
    } else {
       data->state = LV_INDEV_STATE_REL; /*Set the released state*/
    data->btn = last_btn;            /*Save the last button*/
    return false;                    /*No buffering now so no more data read*/
void lv_key_init(void)
    static lv_indev_t *indev;
    lv_indev_drv_t indev_drv;

    lv_indev_drv_init(&indev_drv); = button_read;
    indev_drv.type = LV_INDEV_TYPE_BUTTON;
    indev = lv_indev_drv_register(&indev_drv);

    /*points_array: these points will be assigned to the buttons to press a specific point on the screen.*/
    static lv_point_t points_array[] = {{40, 40}};
    lv_indev_set_button_points(indev, points_array);
static lv_res_t  key_event_cb(lv_obj_t * btn)
void key_ui()
	static lv_obj_t *btn1; 
	btn1 = lv_btn_create(lv_scr_act(), NULL);
	lv_obj_set_size(btn1, 100, 100);
	lv_obj_set_pos(btn1, 20, 20);
	lv_btn_set_action(btn1, LV_BTN_ACTION_CLICK,key_event_cb);
void rt_key_thread_entry(void * parameter)

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.

Next time, please read through the template carefully. There were a number of steps you didn’t follow:

  1. Code was not put within ```c and ``` blocks (the template does give instructions on how to do this).
  2. The top section of your post was not deleted.
  3. We need a clear explanation of what the issue is. Right now, all I know is that “it won’t work” and you want to make it detect button presses.

I know the template can seem like extra work, but believe me, it makes it much easier to answer questions.

hi , i just changed my format .how about this one?

Are you using LittlevGL 5.3 or 6.0? From the code it looks like you are using the older 5.3.

yeah you are’s nonsupport?

We didn’t set a specific EOL date, but it is a year old now, so I would definitely advise upgrading once you get this working.

I will try

i have done it ,thank you

Can you share source code for reference ?