Exemple #1
0
static void cmd_fullscale(BaseSequentialStream *chp, int argc, char *argv[]) {
  (void)argv;
  if (argc != 1) {
    chprintf(chp, "Usage: fullscale [250|500|2000]\r\n");
    return;
  }
#if CHPRINTF_USE_ANSI_CODE
    chprintf(chp, "\033[2J\033[1;1H");
#endif
  if(!strcmp (argv[0], "250")) {
    gyroscopeSetFullScale(&L3GD20D1, L3GD20_FS_250DPS);
    chprintf(chp, "L3GD20 Gyroscope full scale set to 250 dps...\r\n");
  }
  else if(!strcmp (argv[0], "500")) {
    gyroscopeSetFullScale(&L3GD20D1, L3GD20_FS_500DPS);
    chprintf(chp, "L3GD20 Gyroscope full scale set to 500 dps...\r\n");
  }
  else if(!strcmp (argv[0], "2000")) {
    gyroscopeSetFullScale(&L3GD20D1, L3GD20_FS_2000DPS);
    chprintf(chp, "L3GD20 Gyroscope full scale set to 2000 dps...\r\n");
  }
  else {
    chprintf(chp, "Usage: fullscale [250|500|2000]\r\n");
    return;
  }
}
Exemple #2
0
static void cmd_fullscale(BaseSequentialStream *chp, int argc, char *argv[]) {
  (void)argv;
  if (argc < 1) {
    chprintf(chp, "Usage: fullscale [acc|gyro] [value]\r\n");
    return;
  }
  if (!strcmp (argv[0], "acc")) {
#if CHPRINTF_USE_ANSI_CODE
      chprintf(chp, "\033[2J\033[1;1H");
#endif
    if(!strcmp (argv[1], "2G")) {
      accelerometerSetFullScale(&LSM6DS0D1, LSM6DS0_ACC_FS_2G);
      chprintf(chp, "LSM6DS0 Accelerometer full scale set to 2G...\r\n");
    }
    else if(!strcmp (argv[1], "4G")) {
      accelerometerSetFullScale(&LSM6DS0D1, LSM6DS0_ACC_FS_4G);
      chprintf(chp, "LSM6DS0 Accelerometer full scale set to 4G...\r\n");
    }
    else if(!strcmp (argv[1], "8G")) {
      accelerometerSetFullScale(&LSM6DS0D1, LSM6DS0_ACC_FS_8G);
      chprintf(chp, "LSM6DS0 Accelerometer full scale set to 8G...\r\n");
    }
    else if(!strcmp (argv[1], "16G")) {
      accelerometerSetFullScale(&LSM6DS0D1, LSM6DS0_ACC_FS_16G);
      chprintf(chp, "LSM6DS0 Accelerometer full scale set to 16G...\r\n");
    }
    else {
      chprintf(chp, "Usage: fullscale acc [2G|4G|8G|16G]\r\n");
      return;
    }
  }
  else if (!strcmp (argv[0], "gyro")) {
#if CHPRINTF_USE_ANSI_CODE
      chprintf(chp, "\033[2J\033[1;1H");
#endif
      if(!strcmp (argv[1], "245")) {
        gyroscopeSetFullScale(&LSM6DS0D1, LSM6DS0_GYRO_FS_245DPS);
        chprintf(chp, "LSM6DS0 Gyroscope full scale set to 245 DPS...\r\n");
      }
      else if(!strcmp (argv[1], "500")) {
        gyroscopeSetFullScale(&LSM6DS0D1, LSM6DS0_GYRO_FS_500DPS);
        chprintf(chp, "LSM6DS0 Gyroscope full scale set to 500 DPS...\r\n");
      }
      else if(!strcmp (argv[1], "2000")) {
        gyroscopeSetFullScale(&LSM6DS0D1, LSM6DS0_GYRO_FS_2000DPS);
        chprintf(chp, "LSM6DS0 Gyroscope full scale set to 2000 DPS...\r\n");
      }
      else {
        chprintf(chp, "Usage: fullscale gyro [245|500|2000]\r\n");
        return;
      }
  }
  else {
    chprintf(chp, "Usage: fullscale [acc|gyro] [value]\r\n");
    return;
  }
}