Skip to content

Commit d33ee46

Browse files
Charly-sketchnedseb
authored andcommitted
lis2mdl: add exemple
1 parent 6179225 commit d33ee46

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# exemple of heading reading with direction label
2+
from time import sleep_ms
3+
from machine import I2C
4+
from lis2mdl.device import LIS2MDL
5+
from lis2mdl.const import *
6+
7+
i2c = I2C(1)
8+
mag = LIS2MDL(i2c)
9+
10+
while True:
11+
angle = mag.heading_flat_only()
12+
direction = mag.direction_label(angle)
13+
print("Cap:", angle, "°", "-", direction)
14+
sleep_ms(100)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# exemple of heading reading with direction label
2+
from time import sleep_ms
3+
from machine import I2C
4+
from lis2mdl.device import LIS2MDL
5+
from lis2mdl.const import *
6+
7+
i2c = I2C(1)
8+
mag = LIS2MDL(i2c)
9+
10+
while True:
11+
field_strength = mag.magnitude_uT()
12+
print("Champ magnétique :", field_strength, "µT")
13+
sleep_ms(100)

0 commit comments

Comments
 (0)