pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

Atomic Base

UIFlow 1.0 Project

Unit IMU

Example

Gets the current gyroscope status

from m5stack import *
from m5ui import *
from uiflow import *
import unit

setScreenColor(0x222222)
unit_imu_0 = unit.get(unit.IMU6886, unit.PORTA)

unit_imu_0.setAccUnit(0)
unit_imu_0.gyroFullScaleRange(0x00)
while True:
  print((str('ACC Z:') + str((unit_imu_0.acceleration[0]))))
  print((str('ACC Y:') + str((unit_imu_0.acceleration[1]))))
  print((str('ACC Y:') + str((unit_imu_0.acceleration[2]))))
  print((str('Gyro X:') + str((unit_imu_0.gyro[0]))))
  print((str('Gyro Y:') + str((unit_imu_0.gyro[1]))))
  print((str('Gyro Z:') + str((unit_imu_0.gyro[2]))))
  wait_ms(2)

API

unit_imu_0.accFullScaleRange(0x00)
  • Set the full range of acceleration scales
print(unit_imu_0.acceleration[0])
  • Get the value of the accelerometer on the X-axis
print(unit_imu_0.acceleration[1])
  • Get the value of the accelerometer on the Y-axis
print(unit_imu_0.acceleration[2])
  • Get the value of the accelerometer on the Z-axis
print(unit_imu_0.gyro[0])
  • Get the value of the gyroscope on the X-axis
print(unit_imu_0.gyro[1])
  • Get the value of the gyroscope on the Y-axis
print(unit_imu_0.gyro[2])
  • Get the value of the gyroscope on the Z-axis
print(unit_imu_0.ypr[1])
  • Get the attitude angle on the X-axis
print(unit_imu_0.ypr[2])
  • Get the attitude angle on the Y-axis
unit_imu_0.gyroCalibrate(250, 5)
  • Set gyroscope calibration using the number of samples and delay per sample
unit_imu_0.gyroFullScaleRange(0x00)
  • Set the gyroscope scale range
unit_imu_0.setAccUnit(0)
  • Set the accelerometer unit to g or m/s^2
unit_imu_0.setGyroOffsets(0, 0, 0)
  • Set manual gyroscope calibration offset values
On This Page