Resistance screen and capacitance screen

Keywords: kernel

1, Resistance screen

1. Principle of resistance screen

The resistance screen is based on Ohm's law. It has two layers of thin films. The thin film is the resistance.

When the upper and lower layers are in contact, the upper and lower films are in contact. At this time, the contact voltage can be measured.

  • X coordinate: when 3.3v voltage is applied at both ends of xp and xm and yp and ym are not applied, yp is equivalent to the probe to measure the voltage of yp. The voltage is proportional to the distance.
  • Y coordinate: similarly, the y-axis coordinate can also be obtained

2. Resistance screen data

In the Linux driver, the X and Y data of electric shock will be reported. This is not the coordinate value of LCD. APP needs to process it again to convert it into coordinate value.
Corresponding input_ In the event structure, "type, code and value" are as follows:

//When pressed
EV_KEY		BTN_TOUCH			1				/* Press */
EV_ABS		ABS_PRESSURE		1				/* Pressure value, can be reported, can not be reported, and can be other pressure values */
EV_ABS		ABS_X					x_value	/* X coordinate */
EV_ABS		ABS_Y					y_value	/* Y coordinate */
EV_SYNC	0							0				/* Synchronization event */

//When loosening
EV_KEY		BTN_TOUCH			0				/* release */
EV_ABS		ABS_PRESSURE		0				/* The pressure value can be reported or not */
EV_SYNC	0							0				/* Synchronization event */

2, Capacitive screen

2.1 principle

There is a control chip in the capacitor screen, which periodically generates a driving signal, the receiving electrode receives the signal, and can measure the charge.
When the capacitor screen is pressed, it is equivalent to introducing a new capacitor, which affects the charge received by the receiving electrode.
According to the charge, the main control chip can calculate the electric shock position. This kind of chip is generally I2C interface. Obtain data by reading I2C chip register.

2.2 capacitance screen data

Reference document: Documentation / input / multi touch protocol.txt
The capacitive screen can support multi touch. The driver can distinguish multi touch in two ways:

  • Type A: this type of touch screen can't distinguish which contact it is. It just reports the coordinates of all contacts one by one, and the software will distinguish which electric shock these data belong to. It is out of date. There is no source code of type A in the Linux kernel
  • Type B: this type of touch screen can distinguish which contact. When reporting data, it will report the contact ID first and then its data. example:
/* When there are 2 contacts */
EV_ABS		ABS_MT_SLOT					0				/* Indicates that I want to report a contact information, which is used to separate the contact information */
EV_ABS		ABS_MT_TRACKING_ID		45			/* The ID of this contact is 45 */
EV_ABS		ABS_MT_POSITION_X			x[0]			/* Contact X coordinate */
EV_ABS		ABS_MT_POSITION_Y			y[0]			/* Contact Y coordinate */
EV_ABS		ABS_MT_SLOT					1				/* Indicates the end of a contact message */
EV_ABS		ABS_MT_TRACKING_ID		45			/* The contact ID is 46 */
EV_ABS		ABS_MT_POSITION_X			x[1]			/* Contact X coordinate */
EV_ABS		ABS_MT_POSITION_Y			y[1]			/* Contact Y coordinate */
EV_SYNC	SYN_REPORT						0				/* All data are reported */

/* When the contact with IO 45 is moving */
EV_ABS		ABS_MT_SLOT					0				/* Indicates that the contact information is to be reported. If the ID has been reported before, the ID will not be reported */
EV_ABS		ABS_MT_POSITION_X			x[0]			/* Contact X coordinate */
EV_SYNC	SYN_REPORT						0				/* All data are reported */

/* When releasing the contact with ID 45 */
EV_ABS		ABS_MT_TRACKING_ID		-1			/* ABS has just been set_ MT_ If the slot is 0 and the ID becomes - 1, it indicates that it is released */
EV_SYNC	SYN_REPORT						0				/* All data are reported */

/* Finally release the contact with ID 46 */
EV_ABS		ABS_MT_SLOT					1				/* Indicates that the contact information is to be reported. If the ID has been reported before, the ID will not be reported */
EV_ABS		ABS_MT_TRACKING_ID		-1			/* ID Is - 1, indicating that slot 1 is released, that is, the contact with ID 46 is released */
EV_SYNC	SYN_REPORT										/* All data are reported */

2.3 analysis of experimental data

  1. Click the touch screen with one finger to get data similar to the following:
root@npi:~# hexdump /dev/input/event2
0000000 d56e 6149 34d0 000c 0003 0039 0000 0000		//type=ABS,code=ABS_MT_TRACKING_ID,value=0
0000010 d56e 6149 34d0 000c 0003 0035 01f7 0000		//type=ABS,code=ABS_MT_POSITION_X,value=0x01f70000
0000020 d56e 6149 34d0 000c 0003 0036 00ce 0000		//type=ABS,code=ABS_MT_POSITION_Y,value=0x00ce0000
0000030 d56e 6149 34d0 000c 0003 0030 0051 0000		//type=ABS,code=ABS_MT_TOUCH_MAJOR,value=0x00510000
0000040 d56e 6149 34d0 000c 0003 0032 0051 0000		//type=ABS,code=ABS_MT_WIDTH_MAJOR,value=0x00510000
0000050 d56e 6149 34d0 000c 0001 014a 0001 0000		//type=KEY,code=BTN_TOUCH,value=0x00010000
0000060 d56e 6149 34d0 000c 0003 0000 01f7 0000		//type=ABS,code=ABS_X,value=0x00ce0000
0000070 d56e 6149 34d0 000c 0003 0001 00ce 0000		//type=ABS,code=ABS_Y,value=0x00ce0000
0000080 d56e 6149 34d0 000c 0000 0000 0000 0000		//type=SYN,code=SYN_REPORT,value=0x00000000
0000090 d56e 6149 6373 000d 0003 0039 ffff ffff		//type=ABS,code=ABS_MT_TRACKING_ID,value=0xffffffff
00000a0 d56e 6149 6373 000d 0001 014a 0000 0000		//type=KEY,code=BTN_TOUCH,value=0x00000000
00000b0 d56e 6149 6373 000d 0000 0000 0000 0000		//type=SYN,code=SYN_REPORT,value=0x00000000

In the above data, ABS is also reported for compatibility with old programs_ X,ABS_Y data, resistance touch screen uses this kind of data.
The program based on resistance screen can also be used on capacitance screen.

  1. When you click the touch screen with two fingers, the following data:
root@npi:~# hexdump /dev/input/event2
0000000 891e 614e 1348 0000 0003 0039 0001 0000		//type=ABS,code=ABS_MT_TRACKING_ID,value=1
0000010 891e 614e 1348 0000 0003 0035 0187 0000		//type=ABS,code=ABS_MT_POSITION_X,value=0x01870000
0000020 891e 614e 1348 0000 0003 0036 00b2 0000		//type=ABS,code=ABS_MT_POSITION_Y,value=0x00b20000
0000030 891e 614e 1348 0000 0003 0030 0050 0000		//type=ABS,code=ABS_MT_TOUCH_MAJOR,value=0x00500000
0000040 891e 614e 1348 0000 0003 0032 0050 0000		//type=ABS,code=ABS_MT_WIDTH_MAJOR,value=0x00500000
0000050 891e 614e 1348 0000 0003 002f 0001 0000		//type=ABS,code=ABS_MT_SLOT,value=0x00010000
0000060 891e 614e 1348 0000 0003 0039 0002 0000		//type=ABS,code=ABS_MT_TRACKING_ID,value=0x00020000
0000070 891e 614e 1348 0000 0003 0035 024b 0000		//type=ABS,code=ABS_MT_POSITION_X,value=0x024b0000
0000080 891e 614e 1348 0000 0003 0036 00a9 0000		//type=ABS,code=ABS_MT_POSITION_Y,value=0x00a90000
0000090 891e 614e 1348 0000 0003 0030 005f 0000		//type=ABS,code=ABS_MT_TOUCH_MAJOR,value=0x005f0000
00000a0 891e 614e 1348 0000 0003 0032 005f 0000		//type=ABS,code=ABS_MT_WIDTH_MAJOR,value=0x005f0000
00000b0 891e 614e 1348 0000 0001 014a 0001 0000		//type=KEY,code=BTN_TOUCH,value=0x00010000
00000c0 891e 614e 1348 0000 0003 0000 0187 0000		//type=ABS,code=ABS_X,value=0x01870000
00000d0 891e 614e 1348 0000 0003 0001 00b2 0000		//type=ABS,code=ABS_Y,value=0x00b20000
00000e0 891e 614e 1348 0000 0000 0000 0000 0000		//type=SYN,code=SYN_REPORT,value=0x00000000
00000f0 891e 614e 0358 0006 0003 002f 0000 0000		//type=ABS,code=ABS_MT_SLOT,value=0x00000000
0000100 891e 614e 0358 0006 0003 0039 ffff ffff		//type=ABS,code=ABS_MT_TRACKING_ID,value=0xffffffff
0000110 891e 614e 0358 0006 0003 002f 0001 0000		//type=ABS,code=ABS_MT_SLOT,value=0x00010000
0000120 891e 614e 0358 0006 0003 0039 ffff ffff		//type=ABS,code=ABS_MT_TRACKING_ID,value=0xffffffff
0000130 891e 614e 0358 0006 0001 014a 0000 0000			//type=KEY,code=BTN_TOUCH,value=0x00000000
0000140 891e 614e 0358 0006 0000 0000 0000 0000		//type=SYN,code=SYN_REPORT,value=0x00000000

ABS was also reported for compatibility with old programs_ X,ABS_Y data, but only the data of the first contact is reported

Posted by sneskid on Fri, 24 Sep 2021 19:33:43 -0700