您尚未登录。

楼主 #1 2019-09-19 11:40:26

shiqx429
会员
注册时间: 2019-09-04
已发帖子: 48
积分: 48

littlevgl触摸点是怎么映射的?

我现在将littlevgl移植到nano板子上
Linux上运行ts_calibrate正常
Linux运行ts_test也正常

1608.891816:    529    287    255                                               
1608.931818:    505    266    255                                               
1608.971854:    474    243    255                                               
1609.011849:    448    220    255                                               
1609.051823:    423    199    255                                               
1609.091839:    395    176    255                                               
1609.131810:    358    158    255                                               
1609.171840:    358    144    255                                               
1609.211843:    343    132    255                                               
1609.251849:    329    120    255                                               
1609.291859:    326    116    255                                               
1609.331852:    305    102    255                                               
1609.371806:    290     88    255                                               
1609.411850:    288     81    255    

点击屏幕后,上面的数据至少都在800*480之间

之后运行littlevgl的demo程序,发现demo自动运行(就是3个tab循环播放那种),点击屏幕没有任何效果,我在littlevgl中的evdev.c打印了log,获得的点坐标非常不对
code如下:

bool evdev_read(lv_indev_drv_t * drv, lv_indev_data_t * data)
{
    struct input_event in;

    while(read(evdev_fd, &in, sizeof(struct input_event)) > 0) {
 printf("in.type = %d\n", in.type);
printf("in.code = %d\n", in.code);
        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.code == ABS_MT_POSITION_X)
                                #if EVDEV_SWAP_AXES
                                        evdev_root_y = in.value;
                                #else
                                        evdev_root_x = in.value;
                                #endif
            else if(in.code == ABS_MT_POSITION_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;
            } else if(drv->type == LV_INDEV_TYPE_KEYPAD) {
		data->state = (in.value) ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL;
		switch(in.code) {
			case KEY_BACKSPACE:
				data->key = LV_KEY_BACKSPACE;
				break;
			case KEY_ENTER:
				data->key = LV_KEY_ENTER;
				break;
			case KEY_UP:
				data->key = LV_KEY_UP;
				break;
			case KEY_LEFT:
				data->key = LV_KEY_PREV;
				break;
			case KEY_RIGHT:
				data->key = LV_KEY_NEXT;
				break;
			case KEY_DOWN:
				data->key = LV_KEY_DOWN;
				break;
			default:
				data->key = 0;
				break;
		}
		evdev_key_val = data->key;
		evdev_button = data->state;
		return false;
	    }
        }
    }

    if(drv->type == LV_INDEV_TYPE_KEYPAD) {
        /* No data retrieved */
        data->key = evdev_key_val;
	data->state = evdev_button;
	return false;
    }
    if(drv->type != LV_INDEV_TYPE_POINTER)
        return false;
    /*Store the collected data*/

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

    data->state = evdev_button;
printf("before data->point.x = %d\n", data->point.x);
printf("before data->point.y = %d\n", data->point.y);
    if(data->point.x < 0)
      data->point.x = 0;
    if(data->point.y < 0)
      data->point.y = 0;
    if(data->point.x >= lv_disp_get_hor_res(drv->disp))
      data->point.x = lv_disp_get_hor_res(drv->disp) - 1;
    if(data->point.y >= lv_disp_get_ver_res(drv->disp))
      data->point.y = lv_disp_get_ver_res(drv->disp) - 1;
printf("after data->point.x = %d\n", data->point.x);
printf("after data->point.y = %d\n", data->point.y);
    return false;
}

log如下

before data->point.x = 3921                                                     
before data->point.y = 3773                                                     
after data->point.x = 799                                                       
after data->point.y = 479                                                       
before data->point.x = 3921                                                     
before data->point.y = 3773                                                     
after data->point.x = 799                                                       
after data->point.y = 479                                                       
before data->point.x = 3921                                                     
before data->point.y = 3773                                                     
after data->point.x = 799                                                       
after data->point.y = 479      

从(read(evdev_fd, &in, sizeof(struct input_event))获得的点基本都是3000多以上的,之后由于都超过800*480了,在下边的代码中都处理为799*499了

if(data->point.x < 0)
      data->point.x = 0;
    if(data->point.y < 0)
      data->point.y = 0;
    if(data->point.x >= lv_disp_get_hor_res(drv->disp))
      data->point.x = lv_disp_get_hor_res(drv->disp) - 1;
    if(data->point.y >= lv_disp_get_ver_res(drv->disp))
      data->point.y = lv_disp_get_ver_res(drv->disp) - 1;

lv_drv_conf.h如下

#ifndef USE_EVDEV
#  define USE_EVDEV           1
#endif

#if USE_EVDEV
#  define EVDEV_NAME   "/dev/input/event1"        /*You can use the "evtest" Linux tool to get the list of devices and test them*/

main.c如下

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*/

我现在搞不清我哪里配置错了,请帮忙看看?
另外运行官方的littlevgl的demo后,3个tab是循环播放吗?我感觉这个现象也怪怪的,我在pc_imulator上也运行过,他那个就没循环播放

离线

楼主 #3 2019-09-19 11:59:34

shiqx429
会员
注册时间: 2019-09-04
已发帖子: 48
积分: 48

Re: littlevgl触摸点是怎么映射的?

你的意思是要将tslib整合至littlevgl中吗?就像 https://whycan.cn/t_2303.html 说的, 下午我试试看看

firstman 说:

before data->point.x = 3921     
before data->point.y = 3773 

这种一看就是 ADC 值,
要获取 LCD X/Y 要通过 tslib
tslib 有做滤波、去抖、校准等功能了。

离线

楼主 #6 2019-09-19 13:33:42

shiqx429
会员
注册时间: 2019-09-04
已发帖子: 48
积分: 48

Re: littlevgl触摸点是怎么映射的?

可以了,感谢二位!

离线

楼主 #7 2019-09-19 13:34:46

shiqx429
会员
注册时间: 2019-09-04
已发帖子: 48
积分: 48

Re: littlevgl触摸点是怎么映射的?

是啊,谢谢!!!

Jmhh247 说:

点进去看了下,是我发的帖子。。。


shiqx429 说:

你的意思是要将tslib整合至littlevgl中吗?就像 https://whycan.cn/t_2303.html 说的, 下午我试试看看

firstman 说:

before data->point.x = 3921     
before data->point.y = 3773 

这种一看就是 ADC 值,
要获取 LCD X/Y 要通过 tslib
tslib 有做滤波、去抖、校准等功能了。

离线

页脚

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

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