您尚未登录。

楼主 #1 2021-04-14 16:50:58

542396750@qq.com
会员
注册时间: 2021-03-26
已发帖子: 153
积分: 14.5

f1c100s 移植lvgl lv_demo_widget();触摸事件有打印,屏幕没响应

# ./demo
The framebuffer device was opened successfully.
800x480, 32bpp
The framebuffer device was mapped to memory successfully.
821.911751:    315    299    255
821.950681:    315    299      0
822.191773:    315    306    255
822.231869:    312    314    255
822.270684:    310    319      0
832.591837:    288    256    255
832.630736:    288    256      0
833.071773:    338    304    255
833.110677:    338    304      0
833.511785:    356    304    255
833.550708:    356    304      0
833.831788:    516    306    255
833.870702:    516    306      0
834.991818:    307    257    255
835.030721:    307    257      0
835.311827:    307    256    255
835.350679:    307    256      0
835.671765:    431    258    255
835.710709:    431    258      0
837.511792:    590    287    255
837.550737:    590    287      0
838.031806:    338    283    255
838.070690:    338    283      0
839.551763:    319    301    255
839.590715:    319    301      0

FluxBB bbcode 测试

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

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

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

    /*Initialize a descriptor for the buffer*/
    static lv_disp_buf_t disp_buf;
    lv_disp_buf_init(&disp_buf, buf, NULL, 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);

    /*Create a "Hello world!" label*/
    //lv_obj_t * label = lv_label_create(lv_scr_act(), NULL);
    //lv_label_set_text(label, "Hello world!");
    //lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);

     lv_indev_drv_t indev_drv;
     lv_indev_drv_init(&indev_drv);          /*Basic initialization*/
     evdev_init();
     indev_drv.type = LV_INDEV_TYPE_POINTER; /*See below.*/
     indev_drv.read_cb = evdev_read;            /*See below.*/
     lv_indev_drv_register(&indev_drv);      /*Register the driver in LittlevGL*/

    lv_demo_widgets();
    //lv_demo_keypad_encoder();
    //lv_demo_stress();
    //lv_test_theme_1(lv_theme_night_init(210, NULL));
    //lv_demo_benchmark();
    /*Handle LitlevGL tasks (tickless mode)*/
    while(1) {
        lv_tick_inc(5);
        lv_task_handler();
        usleep(5000);
    }

    return 0;
}

evdev_read
{
#if 0

    struct input_event in;

    while(read(evdev_fd, &in, sizeof(struct input_event)) > 0) {
        if(in.type == EV_REL) {
            if(in.code == REL_X)
				#if EVDEV_SWAP_AXES
					evdev_root_y += in.value;
				#else
					evdev_root_x += in.value;
				#endif
            else if(in.code == REL_Y)
				#if EVDEV_SWAP_AXES
					evdev_root_x += in.value;
				#else
					evdev_root_y += in.value;
				#endif
        } else if(in.type == EV_ABS) {
            if(in.code == ABS_X)
				#if EVDEV_SWAP_AXES
					evdev_root_y = in.value;
				#else
					evdev_root_x = in.value;
				#endif
            else if(in.code == ABS_Y)
				#if EVDEV_SWAP_AXES
					evdev_root_x = in.value;
				#else
					evdev_root_y = in.value;
				#endif
        } else if(in.type == EV_KEY) {
            if(in.code == BTN_MOUSE || in.code == BTN_TOUCH) {
                if(in.value == 0)
                    evdev_button = LV_INDEV_STATE_REL;
                else if(in.value == 1)
                    evdev_button = LV_INDEV_STATE_PR;
            }
        }
    }

#endif

    // tslib
	struct ts_sample samp;
	int ret;

    /* 修改自tslib ts_print.c */
    
	while (ts_read(ts, &samp, 1) == 1) {

		printf("%ld.%06ld: %6d %6d %6d\n", samp.tv.tv_sec, samp.tv.tv_usec, samp.x, samp.y, samp.pressure);
        
		
		
		
		#if EVDEV_SWAP_AXES
			evdev_root_x = samp.y;
			evdev_root_y = samp.x;
		#else
			evdev_root_x = samp.x;
			evdev_root_y = samp.y;
		#endif
		
        
        if(samp.pressure == 0)
            evdev_button = LV_INDEV_STATE_REL;      //抬起
        else if(samp.pressure == 255)
            evdev_button = LV_INDEV_STATE_PR;
	}
	
	

    /*Store the collected data*/

#if EVDEV_SCALE
    data->point.x = map(evdev_root_x, 0, EVDEV_SCALE_HOR_RES, 0, LV_HOR_RES);
    data->point.y = map(evdev_root_y, 0, EVDEV_SCALE_VER_RES, 0, LV_VER_RES);
#else
#if EVDEV_CALIBRATE
	data->point.x = map(evdev_root_x, EVDEV_HOR_MIN, EVDEV_HOR_MAX, 0, LV_HOR_RES);
	data->point.y = map(evdev_root_y, EVDEV_VER_MIN, EVDEV_VER_MAX, 0, LV_VER_RES);
#else
    data->point.x = evdev_root_x;
    data->point.y = evdev_root_y;
#endif
#endif

    data->state = evdev_button;

    if(data->point.x < 0)
      data->point.x = 0;
    if(data->point.y < 0)
      data->point.y = 0;
    if(data->point.x >= LV_HOR_RES)
      data->point.x = LV_HOR_RES - 1;
    if(data->point.y >= LV_VER_RES)
      data->point.y = LV_VER_RES - 1;

    return false;
}

离线

楼主 #2 2021-04-14 16:51:40

542396750@qq.com
会员
注册时间: 2021-03-26
已发帖子: 153
积分: 14.5

Re: f1c100s 移植lvgl lv_demo_widget();触摸事件有打印,屏幕没响应

请问触摸和lvgl是如何关联起来的?

离线

#3 2021-04-14 17:24:27

哇酷小二
wechat微信:whycan_cn
所在地: 你猜
注册时间: 2020-04-22
已发帖子: 3,378
积分: 1902
个人网站

Re: f1c100s 移植lvgl lv_demo_widget();触摸事件有打印,屏幕没响应

lv_indev_drv_t indev_drv;
     lv_indev_drv_init(&indev_drv);          /*Basic initialization*/
     evdev_init();
     indev_drv.type = LV_INDEV_TYPE_POINTER; /*See below.*/
     indev_drv.read_cb = evdev_read;            /*See below.*/
     lv_indev_drv_register(&indev_drv);      /*Register the driver in LittlevGL*/

注册输入设备驱动





离线

楼主 #4 2021-04-14 17:42:07

542396750@qq.com
会员
注册时间: 2021-03-26
已发帖子: 153
积分: 14.5

Re: f1c100s 移植lvgl lv_demo_widget();触摸事件有打印,屏幕没响应

哇酷小二 说:

lv_indev_drv_t indev_drv;
     lv_indev_drv_init(&indev_drv);          /*Basic initialization*/
     evdev_init();
     indev_drv.type = LV_INDEV_TYPE_POINTER; /*See below.*/
     indev_drv.read_cb = evdev_read;            /*See below.*/
     lv_indev_drv_register(&indev_drv);      /*Register the driver in LittlevGL*/

注册输入设备驱动


您好,有注册的。

触摸屏幕有打印出坐标

离线

#5 2021-04-14 20:43:05

哇酷小二
wechat微信:whycan_cn
所在地: 你猜
注册时间: 2020-04-22
已发帖子: 3,378
积分: 1902
个人网站

Re: f1c100s 移植lvgl lv_demo_widget();触摸事件有打印,屏幕没响应

while (ts_read(ts, &samp, 1) == 1) {

        printf("%ld.%06ld: %6d %6d %6d\n", samp.tv.tv_sec, samp.tv.tv_usec, samp.x, samp.y, samp.pressure);
       
       


这里有执行吗?





离线

楼主 #6 2021-04-15 08:39:20

542396750@qq.com
会员
注册时间: 2021-03-26
已发帖子: 153
积分: 14.5

Re: f1c100s 移植lvgl lv_demo_widget();触摸事件有打印,屏幕没响应

哇酷小二 说:

while (ts_read(ts, &samp, 1) == 1) {

        printf("%ld.%06ld: %6d %6d %6d\n", samp.tv.tv_sec, samp.tv.tv_usec, samp.x, samp.y, samp.pressure);
       
       


这里有执行吗?


有执行的,触摸终端就会printf坐标。
现在怀疑是不是lvgl要加事件处理回调函数

离线

楼主 #7 2021-04-15 11:19:20

542396750@qq.com
会员
注册时间: 2021-03-26
已发帖子: 153
积分: 14.5

Re: f1c100s 移植lvgl lv_demo_widget();触摸事件有打印,屏幕没响应

typedef struct _lv_indev_drv_t {

    /**< Input device type*/
    lv_indev_type_t type;

    /**< Function pointer to read input device data.
     * Return 'true' if there is more data to be read (buffered).
     * Most drivers can safely return 'false' */
    bool (*read_cb)(struct _lv_indev_drv_t * indev_drv, lv_indev_data_t * data);

    /** Called when an action happened on the input device.
     * The second parameter is the event from `lv_event_t`*/
    void (*feedback_cb)(struct _lv_indev_drv_t *, uint8_t);

#if LV_USE_USER_DATA
    lv_indev_drv_user_data_t user_data;
#endif

    /**< Pointer to the assigned display*/
    struct _disp_t * disp;

    /**< Task to read the periodically read the input device*/
    lv_task_t * read_task;

    /**< Number of pixels to slide before actually drag the object*/
    uint8_t drag_limit;

    /**< Drag throw slow-down in [%]. Greater value means faster slow-down */
    uint8_t drag_throw;

    /**< At least this difference should between two points to evaluate as gesture */
    uint8_t gesture_min_velocity;

    /**< At least this difference should be to send a gesture */
    uint8_t gesture_limit;

    /**< Long press time in milliseconds*/
    uint16_t long_press_time;

    /**< Repeated trigger period in long press [ms] */
    uint16_t long_press_rep_time;
} lv_indev_drv_t;

MD,可以了,由于版本差异,evdev_read的形参没对应上
bool evdev_read(lv_indev_data_t * data);改为
bool evdev_read(lv_indev_drv_t * indev_drv,lv_indev_data_t * data);

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn