lis2mdl: add LIS2MDL magnetometer (#187)

Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
Ron Evans
2020-08-20 13:21:39 +02:00
committed by GitHub
parent 5df96c8138
commit af4efceac1
5 changed files with 184 additions and 1 deletions
+29
View File
@@ -0,0 +1,29 @@
package main
import (
"machine"
"time"
"tinygo.org/x/drivers/lis2mdl"
)
func main() {
machine.I2C0.Configure(machine.I2CConfig{})
compass := lis2mdl.New(machine.I2C0)
if !compass.Connected() {
for {
println("LIS2MDL not connected!")
time.Sleep(1 * time.Second)
}
}
compass.Configure(lis2mdl.Configuration{}) //default settings
for {
heading := compass.ReadCompass()
println("Heading:", heading)
time.Sleep(time.Millisecond * 100)
}
}