# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT

import time
import board
import busio
from adafruit_icm20x import ICM20948

cycles = 200
i2c = busio.I2C(board.SCL, board.SDA)
icm = ICM20948(i2c)

# Cycle between two data rates
# Best viewed in the Mu serial plotter where you can see how
# the data rate affects the resolution of the data
while True:
    icm.gyro_data_rate_divisor = 0  # minimum
    print("Data Rate:", icm.gyro_data_rate)
    time.sleep(2)
    for i in range(cycles):
        print(icm.gyro)

    icm.gyro_data_rate_divisor = 255  # maximum
    print("Data Rate:", icm.gyro_data_rate)
    time.sleep(2)
    for i in range(cycles):
        print(icm.gyro)

[((10, 6, 10, 37), 'busio.I2C', 'busio.I2C', ({(10, 16, 10, 25): 'board.SCL', (10, 27, 10, 36): 'board.SDA'}, {}), '(board.SCL, board.SDA)', False, 'import busio\n'), ((11, 6, 11, 19), 'adafruit_icm20x.ICM20948', 'ICM20948', ({(11, 15, 11, 18): 'i2c'}, {}), '(i2c)', False, 'from adafruit_icm20x import ICM20948\n'), ((19, 4, 19, 17), 'time.sleep', 'time.sleep', ({(19, 15, 19, 16): '(2)'}, {}), '(2)', False, 'import time\n'), ((25, 4, 25, 17), 'time.sleep', 'time.sleep', ({(25, 15, 25, 16): '(2)'}, {}), '(2)', False, 'import time\n')]