tinygo.org/x/drivers@v0.27.1-0.20240509133757-7dbca2a54349/examples/encoders/quadrature-interrupt/main.go (about) 1 //go:build macropad_rp2040 2 3 package main 4 5 import ( 6 "machine" 7 8 "tinygo.org/x/drivers/encoders" 9 ) 10 11 var ( 12 enc = encoders.NewQuadratureViaInterrupt(machine.ROT_A, machine.ROT_B) 13 ) 14 15 func main() { 16 17 enc.Configure(encoders.QuadratureConfig{ 18 Precision: 4, 19 }) 20 21 for oldValue := 0; ; { 22 if newValue := enc.Position(); newValue != oldValue { 23 println("value: ", newValue) 24 oldValue = newValue 25 } 26 } 27 28 }