bool sensorsAutodetect(void) { memset(&acc, 0, sizeof(acc)); memset(&gyro, 0, sizeof(gyro)); #if defined(USE_GYRO_MPU6050) || defined(USE_GYRO_MPU3050) || defined(USE_GYRO_MPU6500) || defined(USE_GYRO_SPI_MPU6500) || defined(USE_GYRO_SPI_MPU6000) || defined(USE_ACC_MPU6050) const extiConfig_t *extiConfig = selectMPUIntExtiConfig(); mpuDetectionResult_t *mpuDetectionResult = detectMpu(extiConfig); UNUSED(mpuDetectionResult); #endif if (!detectGyro()) { return false; } detectAcc(sensorSelectionConfig()->acc_hardware); detectBaro(sensorSelectionConfig()->baro_hardware); // Now time to init things, acc first if (sensors(SENSOR_ACC)) acc.init(); // this is safe because either mpu6050 or mpu3050 or lg3d20 sets it, and in case of fail, we never get here. gyro.init(gyroConfig()->gyro_lpf); #ifdef MAG detectMag(sensorSelectionConfig()->mag_hardware); #endif reconfigureAlignment(sensorAlignmentConfig()); return true; }
bool sensorsAutodetect(void) { memset(&acc, 0, sizeof(acc)); memset(&gyro, 0, sizeof(gyro)); #if defined(USE_GYRO_MPU6050) || defined(USE_GYRO_MPU3050) || defined(USE_GYRO_MPU6500) || defined(USE_GYRO_SPI_MPU6500) || defined(USE_GYRO_SPI_MPU6000) || defined(USE_ACC_MPU6050) const extiConfig_t *extiConfig = selectMPUIntExtiConfig(); mpuDetectionResult_t *mpuDetectionResult = detectMpu(extiConfig); UNUSED(mpuDetectionResult); #endif if (!detectGyro()) { return false; } gyro.sampleFrequencyHz = gyroConfig()->gyro_sample_hz; // this is safe because either mpu6050 or mpu3050 or lg3d20 sets it, and in case of fail, we never get here. gyro.init(&gyro, gyroConfig()->gyro_lpf); gyroInit(); // the combination of LPF and GYRO_SAMPLE_HZ may be invalid for the gyro, update the configuration to use the sample frequency that was determined for the desired LPF. gyroConfig()->gyro_sample_hz = gyro.sampleFrequencyHz; if (detectAcc(sensorSelectionConfig()->acc_hardware)) { acc.acc_1G = 256; // set default acc.init(&acc); } #ifdef BARO detectBaro(sensorSelectionConfig()->baro_hardware); #endif #ifdef MAG if (detectMag(sensorSelectionConfig()->mag_hardware)) { if (!compassInit()) { sensorsClear(SENSOR_MAG); } } #endif reconfigureAlignment(sensorAlignmentConfig()); return true; }
bool sensorsAutodetect(void) { memset(&acc, 0, sizeof(acc)); memset(&gyro, 0, sizeof(gyro)); #if defined(USE_GYRO_MPU6050) || defined(USE_GYRO_MPU3050) || defined(USE_GYRO_MPU6500) || defined(USE_GYRO_SPI_MPU6500) || defined(USE_GYRO_SPI_MPU6000) || defined(USE_ACC_MPU6050) const extiConfig_t *extiConfig = selectMPUIntExtiConfig(); mpuDetectionResult_t *mpuDetectionResult = detectMpu(extiConfig); UNUSED(mpuDetectionResult); #endif if (!detectGyro()) { return false; } // this is safe because either mpu6050 or mpu3050 or lg3d20 sets it, and in case of fail, we never get here. gyro.init(gyroConfig()->gyro_lpf); if (detectAcc(sensorSelectionConfig()->acc_hardware)) { acc.acc_1G = 256; // set default acc.init(&acc); } #ifdef BARO detectBaro(sensorSelectionConfig()->baro_hardware); #endif #ifdef MAG if (detectMag(sensorSelectionConfig()->mag_hardware)) { if (!compassInit()) { sensorsClear(SENSOR_MAG); } } #endif reconfigureAlignment(sensorAlignmentConfig()); return true; }
// Default settings STATIC_UNIT_TESTED void resetConf(void) { pgResetAll(MAX_PROFILE_COUNT); setProfile(0); pgActivateProfile(0); setControlRateProfile(0); parseRcChannels("AETR1234", rxConfig()); featureClearAll(); featureSet(DEFAULT_RX_FEATURE | FEATURE_FAILSAFE | FEATURE_BLACKBOX); #ifdef DEFAULT_FEATURES featureSet(DEFAULT_FEATURES); #endif #ifdef BOARD_HAS_VOLTAGE_DIVIDER // only enable the feature by default if the board has supporting hardware featureSet(FEATURE_VBAT); #endif #ifdef BOARD_HAS_AMPERAGE_METER // only enable the feature by default if the board has supporting hardware featureSet(FEATURE_AMPERAGE_METER); batteryConfig()->amperageMeterSource = AMPERAGE_METER_ADC; #endif // alternative defaults settings for ALIENFLIGHTF1 and ALIENFLIGHTF3 targets #ifdef ALIENFLIGHT #ifdef ALIENFLIGHTF3 serialConfig()->portConfigs[2].functionMask = FUNCTION_RX_SERIAL; getVoltageMeterConfig(ADC_BATTERY)->vbatscale = 20; sensorSelectionConfig()->mag_hardware = MAG_NONE; // disabled by default # else serialConfig()->portConfigs[1].functionMask = FUNCTION_RX_SERIAL; # endif rxConfig()->serialrx_provider = SERIALRX_SPEKTRUM2048; rxConfig()->spektrum_sat_bind = 5; motorConfig()->minthrottle = 1000; motorConfig()->maxthrottle = 2000; motorConfig()->motor_pwm_rate = 32000; failsafeConfig()->failsafe_delay = 2; failsafeConfig()->failsafe_off_delay = 0; mixerConfig()->yaw_jump_prevention_limit = YAW_JUMP_PREVENTION_LIMIT_HIGH; currentControlRateProfile->rcRate8 = 100; currentControlRateProfile->rates[PITCH] = 20; currentControlRateProfile->rates[ROLL] = 20; currentControlRateProfile->rates[YAW] = 20; parseRcChannels("TAER1234", rxConfig()); *customMotorMixer(0) = (motorMixer_t){ 1.0f, -0.414178f, 1.0f, -1.0f }; // REAR_R *customMotorMixer(1) = (motorMixer_t){ 1.0f, -0.414178f, -1.0f, 1.0f }; // FRONT_R *customMotorMixer(2) = (motorMixer_t){ 1.0f, 0.414178f, 1.0f, 1.0f }; // REAR_L *customMotorMixer(3) = (motorMixer_t){ 1.0f, 0.414178f, -1.0f, -1.0f }; // FRONT_L *customMotorMixer(4) = (motorMixer_t){ 1.0f, -1.0f, -0.414178f, -1.0f }; // MIDFRONT_R *customMotorMixer(5) = (motorMixer_t){ 1.0f, 1.0f, -0.414178f, 1.0f }; // MIDFRONT_L *customMotorMixer(6) = (motorMixer_t){ 1.0f, -1.0f, 0.414178f, 1.0f }; // MIDREAR_R *customMotorMixer(7) = (motorMixer_t){ 1.0f, 1.0f, 0.414178f, -1.0f }; // MIDREAR_L #endif // copy first profile into remaining profile PG_FOREACH_PROFILE(reg) { for (int i = 1; i < MAX_PROFILE_COUNT; i++) { memcpy(reg->address + i * pgSize(reg), reg->address, pgSize(reg)); } } for (int i = 1; i < MAX_PROFILE_COUNT; i++) { configureRateProfileSelection(i, i % MAX_CONTROL_RATE_PROFILE_COUNT); } }