initial support for ttp229 (BSF)

This commit is contained in:
Daniel Esteban
2023-05-20 18:01:15 +02:00
committed by Ron Evans
parent 42e4d29157
commit 95f0ca8c3e
3 changed files with 150 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
package main
import (
"time"
"tinygo.org/x/drivers/ttp229"
"machine"
)
func main() {
time.Sleep(5 * time.Second)
sensor := ttp229.NewPin(machine.A5, machine.A4)
sensor.Configure(ttp229.Configuration{Inputs: 16})
println("READY")
for {
sensor.ReadKeys()
for i := byte(0); i < 16; i++ {
if sensor.IsKeyPressed(i) {
print("1 ")
} else {
print("0 ")
}
}
println("")
println("Pressed key:", sensor.GetKey())
for i := byte(0); i < 16; i++ {
if sensor.IsKeyDown(i) {
println("Key", i, "is down")
} else if sensor.IsKeyUp(i) {
println("Key", i, "is up")
}
}
time.Sleep(100 * time.Millisecond)
}
}