tinygo.org/x/drivers@v0.27.1-0.20240509133757-7dbca2a54349/examples/ft6336/basic/main.go (about)

     1  package main
     2  
     3  func main() {
     4  	touchScreen, _ := initDevices()
     5  
     6  	for {
     7  		touch := touchScreen.ReadTouchPoint()
     8  		if touch.Z > 0 {
     9  			//X and Y are 16 bit with 12 bit resolution and need to be scaled for the display size
    10  			//Z is 24 bit and is typically > 2000 for a touch
    11  			println("touch:", touch.X, touch.Y, touch.Z)
    12  			//Example of scaling for m5stack-core2's 320x240 display with 320x270 touch area
    13  			println("screen:", (touch.X*320)>>16, (touch.Y*270)>>16)
    14  		}
    15  	}
    16  }