void pgResetFn_compassConfig(compassConfig_t *compassConfig) { compassConfig->mag_align = ALIGN_DEFAULT; compassConfig->mag_declination = 0; compassConfig->mag_hardware = MAG_DEFAULT; // Generate a reasonable default for backward compatibility // Strategy is // 1. If SPI device is defined, it will take precedence, assuming it's onboard. // 2. I2C devices are will be handled by address = 0 (per device default). // 3. Slave I2C device on SPI gyro #if defined(USE_SPI) && (defined(USE_MAG_SPI_HMC5883) || defined(USE_MAG_SPI_AK8963)) compassConfig->mag_bustype = BUSTYPE_SPI; #ifdef USE_MAG_SPI_HMC5883 compassConfig->mag_spi_device = SPI_DEV_TO_CFG(spiDeviceByInstance(HMC5883_SPI_INSTANCE)); compassConfig->mag_spi_csn = IO_TAG(HMC5883_CS_PIN); #else compassConfig->mag_spi_device = SPI_DEV_TO_CFG(spiDeviceByInstance(AK8963_SPI_INSTANCE)); compassConfig->mag_spi_csn = IO_TAG(AK8963_CS_PIN); #endif compassConfig->mag_i2c_device = I2C_DEV_TO_CFG(I2CINVALID); compassConfig->mag_i2c_address = 0; #elif defined(USE_MAG_HMC5883) || defined(USE_MAG_AK8975) || (defined(USE_MAG_AK8963) && !(defined(USE_GYRO_SPI_MPU6500) || defined(USE_GYRO_SPI_MPU9250))) compassConfig->mag_bustype = BUSTYPE_I2C; compassConfig->mag_i2c_device = I2C_DEV_TO_CFG(MAG_I2C_INSTANCE); compassConfig->mag_i2c_address = 0; compassConfig->mag_spi_device = SPI_DEV_TO_CFG(SPIINVALID); compassConfig->mag_spi_csn = IO_TAG_NONE; #elif defined(USE_MAG_AK8963) && (defined(USE_GYRO_SPI_MPU6500) || defined(USE_GYRO_SPI_MPU9250)) compassConfig->mag_bustype = BUSTYPE_MPU_SLAVE; compassConfig->mag_i2c_device = I2C_DEV_TO_CFG(I2CINVALID); compassConfig->mag_i2c_address = 0; compassConfig->mag_spi_device = SPI_DEV_TO_CFG(SPIINVALID); compassConfig->mag_spi_csn = IO_TAG_NONE; #else compassConfig->mag_hardware = MAG_NONE; compassConfig->mag_bustype = BUSTYPE_NONE; compassConfig->mag_i2c_device = I2C_DEV_TO_CFG(I2CINVALID); compassConfig->mag_i2c_address = 0; compassConfig->mag_spi_device = SPI_DEV_TO_CFG(SPIINVALID); compassConfig->mag_spi_csn = IO_TAG_NONE; #endif compassConfig->interruptTag = COMPASS_INTERRUPT_TAG; }
#include "rx/rx.h" #include "scheduler/scheduler.h" #include "sensors/acceleration.h" #include "sensors/battery.h" #include "sensors/compass.h" #include "sensors/gyro.h" #include "sensors/sensors.h" PG_REGISTER_WITH_RESET_TEMPLATE(dashboardConfig_t, dashboardConfig, PG_DASHBOARD_CONFIG, 0); PG_RESET_TEMPLATE(dashboardConfig_t, dashboardConfig, .device = I2C_DEV_TO_CFG(DASHBOARD_I2C_INSTANCE), .address = DASHBOARD_I2C_ADDRESS, ); #define MICROSECONDS_IN_A_SECOND (1000 * 1000) #define DISPLAY_UPDATE_FREQUENCY (MICROSECONDS_IN_A_SECOND / 5) #define PAGE_CYCLE_FREQUENCY (MICROSECONDS_IN_A_SECOND * 5) static busDevice_t *bus; static uint32_t nextDisplayUpdateAt = 0; static bool dashboardPresent = false; static displayPort_t *displayPort;
void pgResetFn_barometerConfig(barometerConfig_t *barometerConfig) { barometerConfig->baro_sample_count = 21; barometerConfig->baro_noise_lpf = 600; barometerConfig->baro_cf_vel = 985; barometerConfig->baro_hardware = BARO_DEFAULT; // For backward compatibility; ceate a valid default value for bus parameters // // 1. If DEFAULT_BARO_xxx is defined, use it. // 2. Determine default based on USE_BARO_xxx // a. Precedence is in the order of popularity; BMP280, MS5611 then BMP085, then // b. If SPI variant is specified, it is likely onboard, so take it. #if !(defined(DEFAULT_BARO_SPI_BMP280) || defined(DEFAULT_BARO_BMP280) || defined(DEFAULT_BARO_SPI_MS5611) || defined(DEFAULT_BARO_MS5611) || defined(DEFAULT_BARO_BMP085) || defined(DEFAULT_BARO_SPI_LPS) || defined(DEFAULT_BARO_SPI_QMP6988) || defined(DEFAULT_BARO_QMP6988)) #if defined(USE_BARO_BMP280) || defined(USE_BARO_SPI_BMP280) #if defined(USE_BARO_SPI_BMP280) #define DEFAULT_BARO_SPI_BMP280 #else #define DEFAULT_BARO_BMP280 #endif #elif defined(USE_BARO_MS5611) || defined(USE_BARO_SPI_MS5611) #if defined(USE_BARO_SPI_MS5611) #define DEFAULT_BARO_SPI_MS5611 #else #define DEFAULT_BARO_MS5611 #endif #elif defined(USE_BARO_QMP6988) || defined(USE_BARO_SPI_QMP6988) #if defined(USE_BARO_SPI_QMP6988) #define DEFAULT_BARO_SPI_QMP6988 #else #define DEFAULT_BARO_QMP6988 #endif #elif defined(USE_BARO_SPI_LPS) #define DEFAULT_BARO_SPI_LPS #elif defined(DEFAULT_BARO_BMP085) #define DEFAULT_BARO_BMP085 #endif #endif #if defined(DEFAULT_BARO_SPI_BMP280) || defined(DEFAULT_BARO_SPI_MS5611) || defined(DEFAULT_BARO_SPI_QMP6988) || defined(DEFAULT_BARO_SPI_LPS) barometerConfig->baro_bustype = BUSTYPE_SPI; barometerConfig->baro_spi_device = SPI_DEV_TO_CFG(spiDeviceByInstance(BARO_SPI_INSTANCE)); barometerConfig->baro_spi_csn = IO_TAG(BARO_CS_PIN); barometerConfig->baro_i2c_device = I2C_DEV_TO_CFG(I2CINVALID); barometerConfig->baro_i2c_address = 0; #elif defined(DEFAULT_BARO_MS5611) || defined(DEFAULT_BARO_BMP280) || defined(DEFAULT_BARO_BMP085)||defined(DEFAULT_BARO_QMP6988) // All I2C devices shares a default config with address = 0 (per device default) barometerConfig->baro_bustype = BUSTYPE_I2C; barometerConfig->baro_i2c_device = I2C_DEV_TO_CFG(BARO_I2C_INSTANCE); barometerConfig->baro_i2c_address = 0; barometerConfig->baro_spi_device = SPI_DEV_TO_CFG(SPIINVALID); barometerConfig->baro_spi_csn = IO_TAG_NONE; #else barometerConfig->baro_hardware = BARO_NONE; barometerConfig->baro_bustype = BUSTYPE_NONE; barometerConfig->baro_i2c_device = I2C_DEV_TO_CFG(I2CINVALID); barometerConfig->baro_i2c_address = 0; barometerConfig->baro_spi_device = SPI_DEV_TO_CFG(SPIINVALID); barometerConfig->baro_spi_csn = IO_TAG_NONE; #endif }