def calib_gyro(n): gyro_avg = [0,0,0] for i in range(n): gyro_vals = imu.gyro_read() for i in range(3): gyro_avg[i] += float(gyro_vals[i])/n return gyro_avg
def gyro_data(gyro_avg): raw = imu.gyro_read() calibrated = [0,0,0] for i in range(3): calibrated[i] = math.radians(raw[i]/gyro_avg[i]) return calibrated