/ examples / icm20x_icm20948_gyro_data_rate_test.py
icm20x_icm20948_gyro_data_rate_test.py
 1  import time
 2  import board
 3  import busio
 4  from adafruit_icm20x import ICM20948
 5  
 6  cycles = 200
 7  i2c = busio.I2C(board.SCL, board.SDA)
 8  icm = ICM20948(i2c)
 9  
10  # Cycle between two data rates
11  # Best viewed in the Mu serial plotter where you can see how
12  # the data rate affects the resolution of the data
13  while True:
14      icm.gyro_data_rate_divisor = 0  # minimum
15      print("Data Rate:", icm.gyro_data_rate)
16      time.sleep(2)
17      for i in range(cycles):
18          print(icm.gyro)
19  
20      icm.gyro_data_rate_divisor = 255  # maximum
21      print("Data Rate:", icm.gyro_data_rate)
22      time.sleep(2)
23      for i in range(cycles):
24          print(icm.gyro)