涉及两个主要函数:
一、input_report_abs,触摸屏显示区域向上报点函数。
正如前面所说,中断来时调用了mstar_ts_poscheck()函数,
1)该函数里包涵了sy_rxdata(&cinfo, &pinfo);读取芯片数据点的数据通过&cinfo传回mstar_ts_poscheck()函数处理。
由于lcd屏为320*480,而TP屏可能是N(此处应为2048),与LCD屏进行点的校正转换如下:
cinfo->x1 = (cinfo->x1 * MS_TS_MSG21XX_X_MAX) / 2048;//接收点时处理
input_report_abs(tsdata->input, ABS_MT_POSITION_X, ((point_slot[i].posy)*320/480));//报点再处理
其中左右反向可把报点时480-去掉,如下两句:
input_report_abs(tsdata->input, ABS_MT_POSITION_X, ((480-point_slot[i].posy)*320/480));//左右反
input_report_abs(tsdata->input, ABS_MT_POSITION_X, ((point_slot[i].posy)*320/480));//左右正向.
2)触摸显示区域完整报点如下:
首先得设置参数:
input_set_abs_params(input, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
input_set_abs_params(input, ABS_MT_POSITION_X, 0, MS_TS_MSG21XX_X_MAX, 0, 0);
input_set_abs_params(input, ABS_MT_POSITION_Y, 0, MS_TS_MSG21XX_Y_MAX, 0, 0);
input_set_abs_params(input, ABS_MT_WIDTH_MAJOR, 0, 200, 0, 0);
然后输入完整流程:
input_report_key(tsdata->input, BTN_TOUCH, 1);//置1按下
input_report_abs(tsdata->input, ABS_MT_POSITION_X, ((point_slot[i].posy)*320/480));
input_report_abs(tsdata->input, ABS_MT_POSITION_Y, ((320-point_slot[i].posx)*480/320));
input_mt_sync(tsdata->input);//多组时使用此多组同步先再下面同步
input_sync(tsdata->input);//同步
注意:平时没数据时得提起,即
input_report_key(tsdata->input, BTN_TOUCH, 0);//置0提起,不然触屏无效.
触摸按键区域完整报点如下:
首先得注册按键:
__set_bit(KEY_MENU, input->keybit);
__set_bit(KEY_BACK, input->keybit);
然后输入完整流程:
input_report_key(tsdata->input, KEY_MENU, 1);置1按下
//input_report_abs()//不用报点
input_sync(tsdata->input);//同步
注意:同样平时没数据时得提起,即
input_report_key(tsdata->input, KEY_MENU, 0);置0提起,不然触屏无效.
上层软件会自动根据KEY_MENU去读取该值