Week7-2_I2C_IMU_lib

import smbus2 as smbus			
from imusensor.MPU9250 import MPU9250
from time import sleep

bus = smbus.SMBus(1) 	
address = 0x68
imu = MPU9250.MPU9250(bus, address)
imu.begin()

while True:
    imu.readSensor()
    imu.computeOrientation()
    print('Ax:{0};Ay:{1};Az:{2}'.format(imu.AccelVals[0], 
                                        imu.AccelVals[1], imu.AccelVals[2]))
    print('Gx:{0};Gy:{1};Gz:{2}'.format(imu.GyroVals[0], 
                                        imu.GyroVals[1], imu.GyroVals[2]))
    print('Mx:{0};My:{1};Mz:{2}'.format(imu.MagVals[0], 
                                        imu.MagVals[1], imu.MagVals[2]))
    print('roll:{0};pitch:{1};yaw:{2}'.format(imu.roll, 
                                              imu.pitch, imu.yaw))
    print('temperature:{0}'.format(imu.Temp))
    print('--------------------------------------------------------')
    sleep(1)