mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-26 09:45:33 +03:00
Align PITOT detection code with acc/gyro/baro code
This commit is contained in:
parent
b7c7f036db
commit
f6ba7d548c
7 changed files with 51 additions and 18 deletions
|
@ -55,7 +55,8 @@ static const char * eventDescription[BOOT_EVENT_CODE_COUNT] = {
|
|||
[BOOT_EVENT_HMC5883L_READ_FAILED] = "HMC5883L_READ_FAILED",
|
||||
[BOOT_EVENT_HMC5883L_SATURATION] = "HMC5883L_SATURATION",
|
||||
[BOOT_EVENT_TIMER_CH_SKIPPED] = "TIMER_CHANNEL_SKIPPED",
|
||||
[BOOT_EVENT_TIMER_CH_MAPPED] = "TIMER_CHANNEL_MAPPED"
|
||||
[BOOT_EVENT_TIMER_CH_MAPPED] = "TIMER_CHANNEL_MAPPED",
|
||||
[BOOT_EVENT_PITOT_DETECTION] = "PITOT_DETECTION",
|
||||
};
|
||||
|
||||
const char * getBootlogEventDescription(bootLogEventCode_e eventCode)
|
||||
|
|
|
@ -47,6 +47,7 @@ typedef enum {
|
|||
BOOT_EVENT_HMC5883L_SATURATION = 17,
|
||||
BOOT_EVENT_TIMER_CH_SKIPPED = 18, // 1 - MAX_MOTORS exceeded, 2 - MAX_SERVOS exceeded, 3 - feature clash
|
||||
BOOT_EVENT_TIMER_CH_MAPPED = 19, // 0 - PPM, 1 - PWM, 2 - MOTOR, 3 - SERVO
|
||||
BOOT_EVENT_PITOT_DETECTION = 20,
|
||||
|
||||
BOOT_EVENT_CODE_COUNT
|
||||
} bootLogEventCode_e;
|
||||
|
|
|
@ -515,7 +515,7 @@ static bool mspFcProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst, mspPostProcessFn
|
|||
#else
|
||||
sbufWriteU16(dst, 0);
|
||||
#endif
|
||||
sbufWriteU16(dst, sensors(SENSOR_ACC) | sensors(SENSOR_BARO) << 1 | sensors(SENSOR_MAG) << 2 | sensors(SENSOR_GPS) << 3 | sensors(SENSOR_SONAR) << 4);
|
||||
sbufWriteU16(dst, sensors(SENSOR_ACC) | sensors(SENSOR_BARO) << 1 | sensors(SENSOR_MAG) << 2 | sensors(SENSOR_GPS) << 3 | sensors(SENSOR_SONAR) << 4 | sensors(SENSOR_PITOT) << 6);
|
||||
sbufWriteU32(dst, packFlightModeFlags());
|
||||
sbufWriteU8(dst, masterConfig.current_profile_index);
|
||||
sbufWriteU16(dst, averageSystemLoadPercent);
|
||||
|
@ -528,7 +528,7 @@ static bool mspFcProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst, mspPostProcessFn
|
|||
#else
|
||||
sbufWriteU16(dst, 0);
|
||||
#endif
|
||||
sbufWriteU16(dst, sensors(SENSOR_ACC) | sensors(SENSOR_BARO) << 1 | sensors(SENSOR_MAG) << 2 | sensors(SENSOR_GPS) << 3 | sensors(SENSOR_SONAR) << 4);
|
||||
sbufWriteU16(dst, sensors(SENSOR_ACC) | sensors(SENSOR_BARO) << 1 | sensors(SENSOR_MAG) << 2 | sensors(SENSOR_GPS) << 3 | sensors(SENSOR_SONAR) << 4 | sensors(SENSOR_PITOT) << 6);
|
||||
sbufWriteU32(dst, packFlightModeFlags());
|
||||
sbufWriteU8(dst, masterConfig.current_profile_index);
|
||||
break;
|
||||
|
|
|
@ -234,22 +234,24 @@ static const rxFailsafeChannelMode_e rxFailsafeModesTable[RX_FAILSAFE_TYPE_COUNT
|
|||
#if (FLASH_SIZE > 64)
|
||||
// sync this with sensors_e
|
||||
static const char * const sensorTypeNames[] = {
|
||||
"GYRO", "ACC", "BARO", "MAG", "SONAR", "GPS", "GPS+MAG", NULL
|
||||
"GYRO", "ACC", "BARO", "MAG", "SONAR", "PITOT", "GPS", "GPS+MAG", NULL
|
||||
};
|
||||
|
||||
#define SENSOR_NAMES_MASK (SENSOR_GYRO | SENSOR_ACC | SENSOR_BARO | SENSOR_MAG | SENSOR_SONAR)
|
||||
// sync with gyroSensor_e
|
||||
static const char * const gyroNames[] = { "", "None", "MPU6050", "L3G4200D", "MPU3050", "L3GD20", "MPU6000", "MPU6500", "MPU9250", "FAKE"};
|
||||
// sync with accelerationSensor_e
|
||||
static const char * const accNames[] = { "None", "", "ADXL345", "MPU6050", "MMA845x", "BMA280", "LSM303DLHC", "MPU6000", "MPU6500", "MPU9250", "FAKE"};
|
||||
static const char * const accNames[] = { "", "None", "ADXL345", "MPU6050", "MMA845x", "BMA280", "LSM303DLHC", "MPU6000", "MPU6500", "MPU9250", "FAKE"};
|
||||
// sync with baroSensor_e
|
||||
static const char * const baroNames[] = { "", "None", "BMP085", "MS5611", "BMP280", "FAKE"};
|
||||
// sync with magSensor_e
|
||||
static const char * const magNames[] = { "None", "", "HMC5883", "AK8975", "MAG_GPS", "MAG_MAG3110", "MAG_AK8963", "FAKE"};
|
||||
static const char * const magNames[] = { "", "None", "HMC5883", "AK8975", "MAG_GPS", "MAG_MAG3110", "MAG_AK8963", "FAKE"};
|
||||
// sycn with rangefinderType_e
|
||||
static const char * const rangefinderNames[] = { "None", "HCSR04", "SRF10"};
|
||||
// sync with pitotSensor_e
|
||||
static const char * const pitotmeterNames[] = { "Auto", "None", "MS4525"};
|
||||
|
||||
static const char * const *sensorHardwareNames[] = {gyroNames, accNames, baroNames, magNames, rangefinderNames};
|
||||
static const char * const *sensorHardwareNames[] = {gyroNames, accNames, baroNames, magNames, rangefinderNames, pitotmeterNames};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ extern mag_t mag;
|
|||
extern sensor_align_e gyroAlign;
|
||||
extern pitot_t pitot;
|
||||
|
||||
uint8_t detectedSensors[SENSOR_INDEX_COUNT] = { GYRO_NONE, ACC_NONE, BARO_NONE, MAG_NONE, RANGEFINDER_NONE };
|
||||
uint8_t detectedSensors[SENSOR_INDEX_COUNT] = { GYRO_NONE, ACC_NONE, BARO_NONE, MAG_NONE, RANGEFINDER_NONE, PITOT_NONE };
|
||||
|
||||
|
||||
const extiConfig_t *selectMPUIntExtiConfig(void)
|
||||
|
@ -463,15 +463,36 @@ static bool detectBaro(baroSensor_e baroHardwareToUse)
|
|||
#ifdef PITOT
|
||||
static bool detectPitot()
|
||||
{
|
||||
// Detect what pressure sensors are available.
|
||||
pitotSensor_e pitotHardware = PITOT_DEFAULT;
|
||||
|
||||
switch (pitotHardware) {
|
||||
case PITOT_DEFAULT:
|
||||
; // Fallthrough
|
||||
|
||||
case PITOT_MS4525:
|
||||
#ifdef USE_PITOT_MS4525
|
||||
if (ms4525Detect(&pitot)) {
|
||||
sensorsSet(SENSOR_PITOT);
|
||||
return true;
|
||||
pitotHardware = PITOT_MS4525;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
; // Fallthrough
|
||||
|
||||
case PITOT_NONE:
|
||||
pitotHardware = PITOT_NONE;
|
||||
break;
|
||||
}
|
||||
|
||||
addBootlogEvent6(BOOT_EVENT_PITOT_DETECTION, BOOT_EVENT_FLAGS_NONE, pitotHardware, 0, 0, 0);
|
||||
|
||||
if (pitotHardware == PITOT_NONE) {
|
||||
sensorsClear(SENSOR_PITOT);
|
||||
return false;
|
||||
}
|
||||
|
||||
detectedSensors[SENSOR_INDEX_PITOT] = pitotHardware;
|
||||
sensorsSet(SENSOR_PITOT);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -17,6 +17,12 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
typedef enum {
|
||||
PITOT_DEFAULT = 0,
|
||||
PITOT_NONE = 1,
|
||||
PITOT_MS4525 = 2
|
||||
} pitotSensor_e;
|
||||
|
||||
#define PITOT_SAMPLE_COUNT_MAX 48
|
||||
|
||||
typedef struct pitotmeterConfig_s {
|
||||
|
|
|
@ -23,6 +23,7 @@ typedef enum {
|
|||
SENSOR_INDEX_BARO,
|
||||
SENSOR_INDEX_MAG,
|
||||
SENSOR_INDEX_RANGEFINDER,
|
||||
SENSOR_INDEX_PITOT,
|
||||
SENSOR_INDEX_COUNT
|
||||
} sensorIndex_e;
|
||||
|
||||
|
@ -42,15 +43,16 @@ typedef union flightDynamicsTrims_u {
|
|||
#define CALIBRATING_BARO_CYCLES 200 // 10 seconds init_delay + 200 * 25 ms = 15 seconds before ground pressure settles
|
||||
#define CALIBRATING_PITOT_CYCLES 200
|
||||
|
||||
// These bits have to be aligned with sensorIndex_e
|
||||
typedef enum {
|
||||
SENSOR_GYRO = 1 << 0, // always present
|
||||
SENSOR_ACC = 1 << 1,
|
||||
SENSOR_BARO = 1 << 2,
|
||||
SENSOR_MAG = 1 << 3,
|
||||
SENSOR_SONAR = 1 << 4,
|
||||
SENSOR_GPS = 1 << 5,
|
||||
SENSOR_GPSMAG = 1 << 6,
|
||||
SENSOR_PITOT = 1 << 7,
|
||||
SENSOR_PITOT = 1 << 5,
|
||||
SENSOR_GPS = 1 << 6,
|
||||
SENSOR_GPSMAG = 1 << 7,
|
||||
} sensors_e;
|
||||
|
||||
typedef enum {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue