Beispiel #1
0
static void mpu6050_work(struct work_struct *work)
{
    int ret;
    struct mpu6050_data *mpu6050 = container_of(
            (struct delayed_work *)work, struct mpu6050_data, work);

    mpu6050_read_gyro(mpu6050);
    mpu6050_read_accel(mpu6050);
    mpu6050_read_temprature(mpu6050);

    mpu6050_dump_all(mpu6050);

    schedule_delayed_work(&mpu6050->work,
            msecs_to_jiffies(mpu6050->delay_ms));
}
void calibrate_gyro() {
  axis_int16_t gyro_raws;
  axis_float_t gyro_sums;

  delay(5000);
  Serial.println("calibrating gyro");

  for(int i = 0; i < 10000; i++) {
    mpu6050_read_gyro(&gyro_raws);
    gyro_sums.x += gyro_raws.x;
    gyro_sums.y += gyro_raws.y;
    gyro_sums.z += gyro_raws.z;
    delay(1);
  }

  Serial.print("x avg: ");
  Serial.println(gyro_sums.x / 10000);
  Serial.print("y avg: ");
  Serial.println(gyro_sums.y / 10000);
  Serial.print("z avg: ");
  Serial.println(gyro_sums.z / 10000);
}
Beispiel #3
0
static void read_gyro_raws() {
  mpu6050_read_gyro(&gyro_raws);
  record_max_gyro_value();
}