pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

IMU

Example

Reads and displays current IMU attitude data.

from m5stack import *
from m5ui import *
from uiflow import *
import imu

setScreenColor(0x222222)
imu0 = imu.IMU()

while True:
  print((str('X: ') + str((imu0.ypr[1]))))
  print((str('Y: ') + str((imu0.ypr[2]))))
  print((str('X ACC: ') + str((imu0.acceleration[0]))))
  print((str('Y ACC: ') + str((imu0.acceleration[1]))))
  print((str('Z ACC: ') + str((imu0.acceleration[2]))))
  print((str('X Gyr: ') + str((imu0.gyro[0]))))
  print((str('Y Gyr: ') + str((imu0.gyro[1]))))
  print((str('Z Gyr: ') + str((imu0.gyro[2]))))
  wait_ms(2)

API

imu0.ypr[1]
  • Getting the roll-over data
imu0.ypr[2]
  • Getting pitch data
imu0.acceleration[0]
  • Getting X-axis acceleration data
imu0.acceleration[1]
  • Get Y-axis acceleration data
imu0.acceleration[2]
  • Getting Z-axis acceleration data
imu0.gyro[0]
  • Get angular velocity in X direction
imu0.gyro[1]
  • Get the angular velocity in the Y direction
imu0.gyro[2]
  • Get angular velocity in Z direction
On This Page