Button events are not working in fbdev(display)

Hi,

I am unable to use button events in fbdev.

i wrote some sample code with buttons and created events.

and when i executes it on board the button events are not working.

is there any solution?

Thanks

Please fill the template to provide enough information to investigate your issue. You can copy it into a new post and add your information within.

> ## Important: posts that do not use this template will be ignored or closed.
>
> ## Before posting
> - Get familiar with [Markdown](https://forum.littlevgl.com/t/get-familiar-with-markdown/403) to format and structure your post
> - Be sure to update [lvgl](https://github.com/littlevgl/lvgl) from the latest version from the `master` branch.
> - Be sure you have checked the relevant part of the [documentation](https://docs.littlevgl.com/en/html/index.html). **We will not respond in detail to posts where you haven't read the relevant documentation.**
> - If applicable use the [Simulator](https://docs.littlevgl.com/en/html/get-started/pc-simulator.html) to eliminate hardware related issues.
> 
>  *Delete this section if you read and applied the mentioned points.*
  
## Description

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

###  What do you want to achieve?

### What have you tried so far?

## 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:
```c
/*You code here*/
```

Description

Button Events are not working in fbdev (Display).

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

What do you want to achieve?

  1. How to Work with button events in fbdev?

What have you tried so far?

Again, you still haven’t provided a clear description of what isn’t working. “Not working” is not enough information on its own for us to help you.

Please describe exactly what the problem is, the exact steps you’ve tried, and any debugging steps you’ve taken.

Description

I created a button and added an even handler to it (navigate to other screen when it is clicked)
it worked for me on PC Simulator. But same code i used in fbdev for my board. it showing button on my board but when i click on it, nothing is happen.

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

i am using gcc linaro arm linux gnueabihf compiler.

What do you want to achieve?

  1. How to work with this event handler on board?

What have you tried so far?

i tried below code in my main.c file
lv_indev_drv_t indev_drv;
lv_indev_drv_init(&indev_drv);
indev_drv.type = LV_INDEV_TYPE_BUTTON;
indev_drv.read_cb =button_read;
lv_indev_t * my_indev = lv_indev_drv_register(&indev_drv);

Sample Code i am running on my board:

lv_obj_t * label;
lv_obj_t * btn1 = lv_btn_create(lv_scr_act(), NULL);
lv_obj_set_event_cb(btn1, event_handler);
lv_obj_align(btn1, NULL, LV_ALIGN_CENTER, 0, 0);

label = lv_label_create(btn1, NULL);
lv_label_set_text(label, "Button");

static void event_handler(lv_obj_t * obj, lv_event_t event)
{
if(event == LV_EVENT_CLICKED) {
// printf(“Clicked\n”);
next();
}
else if(event == LV_EVENT_VALUE_CHANGED) {
//printf(“Toggled\n”);
next();
}
}

Do you have a physical hardware button, or are you using a touchscreen? If it’s the latter you should be registering an LV_INDEV_TYPE_POINTER device instead. See the documentation.

You mentioned that you are using the fbdev driver, so I assume this is a Linux system. Does your input device use the standard Linux evdev interface? We have a driver for that already.

i am using touch screen(linux).
I just used evdev.h file in my main.c and used evdev_init();
But this evdev_init() is not getting into the main.c file.
lv_init(); and fbdev_init(); are working.

main.c file

#include "lvgl/lvgl.h"
#include "lv_drivers/display/fbdev.h"
#include "lv_drivers/indev/evdev.h"
#include "lv_examples/lv_apps/test/test.h"
#include <unistd.h>

#define DISP_BUF_SIZE (480*854)

int main(void)
{
	/*LittlevGL init*/
	lv_init();

	/*Linux frame buffer device init*/
	fbdev_init();

	/*Linux touchscreen device init*/
	evdev_init();

	/*A small buffer for LittlevGL to draw the screen's content*/
	static lv_color_t buf1[DISP_BUF_SIZE];
	static lv_color_t buf2[DISP_BUF_SIZE];

	/*Initialize a descriptor for the buffer*/
	static lv_disp_buf_t disp_buf;
	lv_disp_buf_init(&disp_buf, buf1, buf2, DISP_BUF_SIZE);

	/*Initialize and register a display driver*/
	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);

	/*Initialize and register an input device*/
	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_t * my_indev = lv_indev_drv_register(&indev_drv);

	 test_sceens();

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

	return 0;
}

Getting implicit declaration of function warning.

Thanks.

Did you enable the evdev driver in lv_drv_conf.h?

Yes I Enabled evdev driver in lv_drv_conf.h (0 to 1)

and included them in my main.c file.
still got error at indev_drv.read_cb=evdev_read(evdev_read could not be resolved)
but the code compiled without any errors.
when i run on board it showing unable open evdev interface::No such file or directory

The issue solved for me.

Thanks for your help.