Adding driver for rotary encoder support

This commit is contained in:
BCG
2024-01-26 07:49:11 -05:00
committed by Ron Evans
parent c41f2e472d
commit 308763f500
5 changed files with 133 additions and 1 deletions
@@ -0,0 +1,28 @@
//go:build macropad_rp2040
package main
import (
"machine"
"tinygo.org/x/drivers/encoders"
)
var (
enc = encoders.NewQuadratureViaInterrupt(machine.ROT_A, machine.ROT_B)
)
func main() {
enc.Configure(encoders.QuadratureConfig{
Precision: 4,
})
for oldValue := 0; ; {
if newValue := enc.Position(); newValue != oldValue {
println("value: ", newValue)
oldValue = newValue
}
}
}