2021-05-13 20:28:46 +00:00
|
|
|
import time
|
2021-05-18 10:18:41 +00:00
|
|
|
from pimoroni_i2c import PimoroniI2C
|
2021-05-13 20:28:46 +00:00
|
|
|
from breakout_msa301 import BreakoutMSA301
|
|
|
|
|
2021-05-18 10:18:41 +00:00
|
|
|
PINS_BREAKOUT_GARDEN = {"sda": 4, "scl": 5}
|
|
|
|
PINS_PICO_EXPLORER = {"sda": 20, "scl": 21}
|
|
|
|
|
|
|
|
i2c = PimoroniI2C(**PINS_BREAKOUT_GARDEN)
|
|
|
|
msa = BreakoutMSA301(i2c)
|
2021-05-13 20:28:46 +00:00
|
|
|
|
|
|
|
part_id = msa.part_id()
|
|
|
|
print("Found MSA301. Part ID: 0x", '{:02x}'.format(part_id), sep="")
|
|
|
|
|
|
|
|
msa.enable_interrupts(BreakoutMSA301.FREEFALL | BreakoutMSA301.ORIENTATION)
|
|
|
|
|
|
|
|
while True:
|
|
|
|
print("X:", msa.get_x_axis(), end=",\t")
|
|
|
|
print("Y:", msa.get_y_axis(), end=",\t")
|
|
|
|
print("Z:", msa.get_z_axis(), end=",\t")
|
|
|
|
print("Freefall?", msa.read_interrupt(BreakoutMSA301.FREEFALL), end=",\t")
|
|
|
|
print("Orientation:", msa.get_orientation())
|
|
|
|
time.sleep(0.1)
|