Arne Newbie
 Joined: 05/01/2025 Location: GermanyPosts: 22 |
Posted: 02:56pm 22 Apr 2025 |
Copy link to clipboard |
 Print this post |
|
Hello,
Here is a short test/demo program for the CST816S capacitive touch display:
'Small test-routine for Waveshare RP2040-MCU Board 1.28inch touch LCD and gesture control 'Calibration & high bits for x and y coordinates are not needed SetPin gp6,gp7,i2c2 'set pins of I2C2 interface SetPin gp21,intl,SUB_TOUCH 'set interrupt pin I2C2 open 400,100 'Open I2C2 CLS
Do Loop
I2C2 close
Sub SUB_TOUCH 'Interupt subroutine I2C2 write &H15,0,1,&H01:I2C2 read &H15,0,1,g 'read gesture I2C2 write &H15,0,1,&H04:I2C2 read &H15,0,1,x 'read x-coordinate lower byte I2C2 write &H15,0,1,&H06:I2C2 read &H15,0,1,y 'read y-coordinate lower byte If g=1 Then CLS RGB(green):Text 120,100,"slide up",C If g=2 Then CLS RGB(blue):Text 120,100,"slide down",C If g=3 Then CLS RGB(red):Text 120,100,"slide left",C If g=4 Then CLS RGB(yellow):Text 120,100,"slide rigth",C If g=5 Then CLS RGB(black):Text 120,100,"single click",C If g=11 Then CLS RGB(magenta):Text 120,100,"double click",C 'no function ?? If g=12 Then CLS RGB(white):Text 120,100,"long press",C Text 120,120,"x: "+Str$(x)+" y: "+Str$(y),C Print g,x,y End Sub
|