# Touch screen

<abstract>
This article explains how to use the CM-Panel touch screen
</abstract>

## Using evtest

Install <code>evtest</code>

	$ sudo apt update
	$ sudo apt install evtest
	
Check the list of available devices:

	$ sudo evtest

	No device specified, trying to scan all of /dev/input/event*
	Available devices:
	/dev/input/event0:	1-005d Goodix Capacitive TouchScreen
	Select the device event number [0-x]: 

Select the Goodix device and touch it to see the incoming data:

	Testing ... (interrupt to exit)
	Event: time 1705002268.269590, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value 0
	Event: time 1705002268.269590, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 302
	Event: time 1705002268.269590, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 270
	Event: time 1705002268.269590, type 3 (EV_ABS), code 48 (ABS_MT_TOUCH_MAJOR), value 23
	Event: time 1705002268.269590, type 3 (EV_ABS), code 50 (ABS_MT_WIDTH_MAJOR), value 23
	Event: time 1705002268.269590, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 1
	Event: time 1705002268.269590, type 3 (EV_ABS), code 0 (ABS_X), value 302
	Event: time 1705002268.269590, type 3 (EV_ABS), code 1 (ABS_Y), value 270
	
## Using a Python program

Install <code>python3-evdev</code>

	$ sudo apt update
	$ sudo apt install python3-evdev

Create a file called <code>touch.py</code> with this code:

	#!/usr/bin/python

	from evdev import InputDevice,ecodes

	print("Touch test")
	print("  ctrl-c to exit")

	x=0
	y=0
	device = InputDevice('/dev/input/event0')

	for event in device.read_loop():
		if event.type==ecodes.EV_ABS:
			print(event.code,event)
			if event.code==53:
				x=event.value
			if event.code==54:
				y=event.value           
			print(x,y)   

<hr>

@include='adv_cmpanel'
