CM Panel technical documentation Buy
Install evtest
$ 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
Install python3-evdev
$ sudo apt update
$ sudo apt install python3-evdev
Create a file called touch.py
with this code:
#!/usr/bin/python
import RPi.GPIO as GPIO
import time
import sys
import getopt
import string
import datetime
import select
import sys
import os
import termios
import tty
from evdev import InputDevice,ecodes
#http://www.termsys.demon.co.uk/vtansi.htm
color_white = "\x1B[37;40m"
color_red = "\x1B[31;40m"
clear_screen = "\x1B[2J"
cursor_home = "\x1B[H"
white_blue = "\x1B[37;44m"
print("Touch test")
print("ctrl-c to exit")
x=0
y=0
device = InputDevice('/dev/input/event3')
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)