Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 10:36 10 May 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Waveshare RP2040-MCU Board 1.28“ round touch LCD with gesture control

Author Message
Arne
Newbie

Joined: 05/01/2025
Location: Germany
Posts: 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



PicoMite configuration:





More functions can be found in the register declaration:

https://files.waveshare.com/upload/c/c2/CST816S_register_declaration.pdf

Maybe it’s usefull for someone. Best would be if a driver could be integral part of MMBasic, then all other GUI-functions can directly be accessed.

Arne
 
Arne
Newbie

Joined: 05/01/2025
Location: Germany
Posts: 22
Posted: 04:06pm 24 Apr 2025
Copy link to clipboard 
Print this post

Now with double click enabled:

'Small test-routine for Waveshare RP2040/RP2350A-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,1,2,&HEC,&H01 'enable double click
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
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


Arne
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025