diff --git a/src/main/fc/config.c b/src/main/fc/config.c index cdcc43e8e8c..8937097a7b4 100755 --- a/src/main/fc/config.c +++ b/src/main/fc/config.c @@ -301,6 +301,12 @@ void validateAndFixConfig(void) // Call target-specific validation function validateAndFixTargetConfig(); +#ifdef USE_MAG + if (compassConfig()->mag_align == ALIGN_DEFAULT) { + compassConfigMutable()->mag_align = CW270_DEG_FLIP; + } +#endif + if (settingsValidate(NULL)) { DISABLE_ARMING_FLAG(ARMING_DISABLED_INVALID_SETTING); } else { diff --git a/src/main/sensors/compass.c b/src/main/sensors/compass.c index 8e1da170b95..1089f6fbb6c 100644 --- a/src/main/sensors/compass.c +++ b/src/main/sensors/compass.c @@ -95,9 +95,6 @@ bool compassDetect(magDev_t *dev, magSensor_e magHardwareToUse) case MAG_QMC5883: #ifdef USE_MAG_QMC5883 if (qmc5883Detect(dev)) { -#ifdef MAG_QMC5883_ALIGN - dev->magAlign.onBoard = MAG_QMC5883_ALIGN; -#endif magHardware = MAG_QMC5883; break; } @@ -111,9 +108,6 @@ bool compassDetect(magDev_t *dev, magSensor_e magHardwareToUse) case MAG_HMC5883: #ifdef USE_MAG_HMC5883 if (hmc5883lDetect(dev)) { -#ifdef MAG_HMC5883_ALIGN - dev->magAlign.onBoard = MAG_HMC5883_ALIGN; -#endif magHardware = MAG_HMC5883; break; } @@ -127,9 +121,6 @@ bool compassDetect(magDev_t *dev, magSensor_e magHardwareToUse) case MAG_AK8975: #ifdef USE_MAG_AK8975 if (ak8975Detect(dev)) { -#ifdef MAG_AK8975_ALIGN - dev->magAlign.onBoard = MAG_AK8975_ALIGN; -#endif magHardware = MAG_AK8975; break; } @@ -143,9 +134,6 @@ bool compassDetect(magDev_t *dev, magSensor_e magHardwareToUse) case MAG_AK8963: #ifdef USE_MAG_AK8963 if (ak8963Detect(dev)) { -#ifdef MAG_AK8963_ALIGN - dev->magAlign.onBoard = MAG_AK8963_ALIGN; -#endif magHardware = MAG_AK8963; break; } @@ -159,9 +147,6 @@ bool compassDetect(magDev_t *dev, magSensor_e magHardwareToUse) case MAG_GPS: #ifdef USE_GPS if (gpsMagDetect(dev)) { -#ifdef MAG_GPS_ALIGN - dev->magAlign.onBoard = MAG_GPS_ALIGN; -#endif magHardware = MAG_GPS; break; } @@ -175,9 +160,6 @@ bool compassDetect(magDev_t *dev, magSensor_e magHardwareToUse) case MAG_MAG3110: #ifdef USE_MAG_MAG3110 if (mag3110detect(dev)) { -#ifdef MAG_MAG3110_ALIGN - dev->magAlign.onBoard = MAG_MAG3110_ALIGN; -#endif magHardware = MAG_MAG3110; break; } @@ -191,9 +173,6 @@ bool compassDetect(magDev_t *dev, magSensor_e magHardwareToUse) case MAG_IST8310: #ifdef USE_MAG_IST8310 if (ist8310Detect(dev)) { -#ifdef MAG_IST8310_ALIGN - dev->magAlign.onBoard = MAG_IST8310_ALIGN; -#endif magHardware = MAG_IST8310; break; } @@ -207,9 +186,6 @@ bool compassDetect(magDev_t *dev, magSensor_e magHardwareToUse) case MAG_IST8308: #ifdef USE_MAG_IST8308 if (ist8308Detect(dev)) { -#ifdef MAG_IST8308_ALIGN - dev->magAlign.onBoard = MAG_IST8308_ALIGN; -#endif magHardware = MAG_IST8308; break; } @@ -223,9 +199,6 @@ bool compassDetect(magDev_t *dev, magSensor_e magHardwareToUse) case MAG_MPU9250: #ifdef USE_MAG_MPU9250 if (mpu9250CompassDetect(dev)) { -#ifdef MAG_MPU9250_ALIGN - dev->magAlign.onBoard = MAG_MPU9250_ALIGN; -#endif magHardware = MAG_MPU9250; break; } @@ -235,9 +208,6 @@ bool compassDetect(magDev_t *dev, magSensor_e magHardwareToUse) case MAG_LIS3MDL: #ifdef USE_MAG_LIS3MDL if (lis3mdlDetect(dev)) { -#ifdef MAG_LIS3MDL_ALIGN - dev->magAlign = MAG_LIS3MDL_ALIGN; -#endif magHardware = MAG_LIS3MDL; break; } @@ -266,9 +236,6 @@ bool compassDetect(magDev_t *dev, magSensor_e magHardwareToUse) case MAG_RM3100: #ifdef USE_MAG_RM3100 if (rm3100MagDetect(dev)) { -#ifdef MAG_RM3100_ALIGN - dev->magAlign.onBoard = MAG_RM3100_ALIGN; -#endif magHardware = MAG_RM3100; break; } @@ -344,6 +311,8 @@ bool compassInit(void) mag.dev.magAlign.useExternal = false; if (compassConfig()->mag_align != ALIGN_DEFAULT) { mag.dev.magAlign.onBoard = compassConfig()->mag_align; + } else { + mag.dev.magAlign.onBoard = CW270_DEG_FLIP; // The most popular default is 270FLIP for external mags } } diff --git a/src/main/target/AIRBOTF4/target.h b/src/main/target/AIRBOTF4/target.h index 596a0b54fd9..70279b57b25 100644 --- a/src/main/target/AIRBOTF4/target.h +++ b/src/main/target/AIRBOTF4/target.h @@ -46,7 +46,6 @@ #define USE_MAG #define MAG_I2C_BUS BUS_I2C2 -#define MAG_HMC5883_ALIGN CW90_DEG #define USE_MAG_HMC5883 #define USE_MAG_AK8963 #define USE_MAG_AK8975 @@ -128,8 +127,6 @@ #define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT -#define MAG_GPS_ALIGN CW180_DEG_FLIP - #define DEFAULT_RX_TYPE RX_TYPE_PPM #define DISABLE_RX_PWM_FEATURE #define DEFAULT_FEATURES (FEATURE_TX_PROF_SEL | FEATURE_BLACKBOX | FEATURE_VBAT) diff --git a/src/main/target/ALIENFLIGHTF3/target.h b/src/main/target/ALIENFLIGHTF3/target.h index 1fe6bae942c..d60025155c8 100644 --- a/src/main/target/ALIENFLIGHTF3/target.h +++ b/src/main/target/ALIENFLIGHTF3/target.h @@ -60,7 +60,6 @@ #define USE_MAG #define MAG_I2C_BUS BUS_I2C2 #define USE_MAG_MPU9250 -#define MAG_MPU9250_ALIGN CW0_DEG #define USE_MAG_AK8963 #define USE_MAG_AK8975 #define USE_MAG_HMC5883 diff --git a/src/main/target/ALIENFLIGHTF4/config.c b/src/main/target/ALIENFLIGHTF4/config.c index f57dae63170..aae496c07dd 100644 --- a/src/main/target/ALIENFLIGHTF4/config.c +++ b/src/main/target/ALIENFLIGHTF4/config.c @@ -45,6 +45,7 @@ #include "sensors/battery.h" #include "sensors/sensors.h" +#include "sensors/compass.h" #include "telemetry/telemetry.h" @@ -56,6 +57,8 @@ // alternative defaults settings for AlienFlight targets void targetConfiguration(void) { + compassConfigMutable()->mag_align = CW90_DEG; + serialConfigMutable()->portConfigs[2].functionMask = FUNCTION_RX_SERIAL; batteryMetersConfigMutable()->current.offset = CURRENTOFFSET; batteryMetersConfigMutable()->current.scale = CURRENTSCALE; diff --git a/src/main/target/ALIENFLIGHTF4/target.h b/src/main/target/ALIENFLIGHTF4/target.h index 9d7718d6405..feb65d8dcb4 100644 --- a/src/main/target/ALIENFLIGHTF4/target.h +++ b/src/main/target/ALIENFLIGHTF4/target.h @@ -61,8 +61,6 @@ #define USE_MAG_IST8308 #define USE_MAG_LIS3MDL -#define MAG_MPU9250_ALIGN CW0_DEG - #define TEMPERATURE_I2C_BUS BUS_I2C1 #define BNO055_I2C_BUS BUS_I2C1 diff --git a/src/main/target/ALIENFLIGHTNGF7/config.c b/src/main/target/ALIENFLIGHTNGF7/config.c index 3fcda3d1b20..0b56c008f5f 100644 --- a/src/main/target/ALIENFLIGHTNGF7/config.c +++ b/src/main/target/ALIENFLIGHTNGF7/config.c @@ -47,6 +47,7 @@ #include "config/feature.h" #include "sensors/battery.h" +#include "sensors/compass.h" #include "hardware_revision.h" @@ -58,6 +59,8 @@ // alternative defaults settings for AlienFlight targets void targetConfiguration(void) { + compassConfigMutable()->mag_align = CW90_DEG; + serialConfigMutable()->portConfigs[2].functionMask = FUNCTION_RX_SERIAL; batteryMetersConfigMutable()->current.offset = CURRENTOFFSET; batteryMetersConfigMutable()->current.scale = CURRENTSCALE; diff --git a/src/main/target/ALIENFLIGHTNGF7/target.h b/src/main/target/ALIENFLIGHTNGF7/target.h index 0a4522d312c..9f48f87c373 100644 --- a/src/main/target/ALIENFLIGHTNGF7/target.h +++ b/src/main/target/ALIENFLIGHTNGF7/target.h @@ -59,9 +59,6 @@ #define USE_MAG_IST8308 #define USE_MAG_LIS3MDL -#define MAG_AK9863_ALIGN CW0_DEG -#define MAG_MPU9250_ALIGN CW0_DEG - #define AK8963_CS_PIN PC15 #define AK8963_SPI_BUS BUS_SPI3 diff --git a/src/main/target/ANYFC/target.h b/src/main/target/ANYFC/target.h index ad5fdf17a78..3d868668978 100644 --- a/src/main/target/ANYFC/target.h +++ b/src/main/target/ANYFC/target.h @@ -47,7 +47,6 @@ #define USE_MAG_IST8310 #define USE_MAG_IST8308 #define USE_MAG_LIS3MDL -#define MAG_HMC5883_ALIGN CW270_DEG_FLIP #define TEMPERATURE_I2C_BUS BUS_I2C2 @@ -104,8 +103,6 @@ //#define HIL -#define MAG_GPS_ALIGN CW180_DEG_FLIP - #define USE_ADC #define ADC_CHANNEL_1_PIN PC0 #define ADC_CHANNEL_2_PIN PC1 diff --git a/src/main/target/ANYFCF7/target.h b/src/main/target/ANYFCF7/target.h index 1e6d6c9f42b..fbd9683c920 100644 --- a/src/main/target/ANYFCF7/target.h +++ b/src/main/target/ANYFCF7/target.h @@ -40,7 +40,6 @@ #define USE_MAG #define MAG_I2C_BUS BUS_I2C2 -#define MAG_HMC5883_ALIGN CW270_DEG_FLIP #define USE_MAG_HMC5883 #define USE_MAG_QMC5883 #define USE_MAG_IST8310 @@ -142,8 +141,6 @@ #define USE_I2C_DEVICE_4 #define USE_I2C_DEVICE_2 -#define MAG_GPS_ALIGN CW180_DEG_FLIP - #define SENSORS_SET (SENSOR_ACC|SENSOR_MAG|SENSOR_BARO) #define USE_NAV diff --git a/src/main/target/ANYFCM7/target.h b/src/main/target/ANYFCM7/target.h index 07e09434a11..0bb51355eca 100644 --- a/src/main/target/ANYFCM7/target.h +++ b/src/main/target/ANYFCM7/target.h @@ -40,7 +40,6 @@ #define USE_MAG #define MAG_I2C_BUS BUS_I2C2 -#define MAG_HMC5883_ALIGN CW270_DEG_FLIP #define USE_MAG_HMC5883 #define USE_MAG_QMC5883 #define USE_MAG_IST8310 diff --git a/src/main/target/BEEROTORF4/target.h b/src/main/target/BEEROTORF4/target.h index 7963cae436e..9d86514f9d4 100644 --- a/src/main/target/BEEROTORF4/target.h +++ b/src/main/target/BEEROTORF4/target.h @@ -45,7 +45,6 @@ #define USE_MAG #define MAG_I2C_BUS BUS_I2C1 -#define MAG_HMC5883_ALIGN CW90_DEG #define USE_MAG_HMC5883 #define USE_MAG_AK8963 #define USE_MAG_AK8975 diff --git a/src/main/target/BETAFLIGHTF4/target.h b/src/main/target/BETAFLIGHTF4/target.h index 0b33a587556..872327b41ae 100755 --- a/src/main/target/BETAFLIGHTF4/target.h +++ b/src/main/target/BETAFLIGHTF4/target.h @@ -119,7 +119,6 @@ #define USE_MAG #define MAG_I2C_BUS BUS_I2C2 -//#define MAG_HMC5883_ALIGN CW90_DEG #define USE_MAG_AK8963 #define USE_MAG_AK8975 #define USE_MAG_HMC5883 diff --git a/src/main/target/CHEBUZZF3/target.h b/src/main/target/CHEBUZZF3/target.h index eae3c8ebdd8..507936adf53 100644 --- a/src/main/target/CHEBUZZF3/target.h +++ b/src/main/target/CHEBUZZF3/target.h @@ -48,7 +48,6 @@ #define USE_MAG #define MAG_I2C_BUS BUS_I2C1 -#define MAG_AK8975_ALIGN CW90_DEG_FLIP #define USE_MAG_AK8975 #define USE_MAG_HMC5883 #define USE_MAG_QMC5883 diff --git a/src/main/target/CLRACINGF4AIR/config.c b/src/main/target/CLRACINGF4AIR/config.c new file mode 100644 index 00000000000..fa0d0196d70 --- /dev/null +++ b/src/main/target/CLRACINGF4AIR/config.c @@ -0,0 +1,55 @@ +/* + * This file is part of Cleanflight. + * + * Cleanflight is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Cleanflight is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Cleanflight. If not, see . + */ + +#include +#include + +#include + +#include "common/axis.h" + +#include "drivers/sensor.h" +#include "drivers/pwm_esc_detect.h" +#include "drivers/pwm_mapping.h" +#include "drivers/pwm_output.h" +#include "drivers/serial.h" + +#include "fc/rc_controls.h" + +#include "flight/failsafe.h" +#include "flight/mixer.h" +#include "flight/pid.h" + +#include "rx/rx.h" + +#include "io/serial.h" + +#include "telemetry/telemetry.h" + +#include "sensors/battery.h" +#include "sensors/sensors.h" + +#include "config/config_master.h" +#include "config/feature.h" + +#include "sensors/battery.h" +#include "sensors/compass.h" + +void targetConfiguration(void) +{ + compassConfigMutable()->mag_align = CW90_DEG; +} diff --git a/src/main/target/CLRACINGF4AIR/target.h b/src/main/target/CLRACINGF4AIR/target.h index e5f5aa5a4f8..56c3918affa 100644 --- a/src/main/target/CLRACINGF4AIR/target.h +++ b/src/main/target/CLRACINGF4AIR/target.h @@ -52,7 +52,6 @@ #define USE_MAG #define USE_MAG_MPU9250 -#define MAG_MPU9250_ALIGN CW90_DEG // MPU6 interrupts #define USE_EXTI diff --git a/src/main/target/COLIBRI/config.c b/src/main/target/COLIBRI/config.c index 02c9785f62a..84e9e625ed2 100755 --- a/src/main/target/COLIBRI/config.c +++ b/src/main/target/COLIBRI/config.c @@ -20,18 +20,18 @@ #include "platform.h" #include "config/feature.h" - #include "fc/config.h" - #include "flight/mixer.h" - #include "io/serial.h" - #include "rx/rx.h" +#include "sensors/compass.h" void targetConfiguration(void) { rxConfigMutable()->serialrx_provider = SERIALRX_SBUS; rxConfigMutable()->receiverType = RX_TYPE_SERIAL; serialConfigMutable()->portConfigs[2].functionMask = FUNCTION_RX_SERIAL; +#ifdef QUANTON + compassConfigMutable()->mag_align = CW90_DEG; +#endif } diff --git a/src/main/target/COLIBRI/target.h b/src/main/target/COLIBRI/target.h index eff71edd241..c111bcb3781 100755 --- a/src/main/target/COLIBRI/target.h +++ b/src/main/target/COLIBRI/target.h @@ -60,10 +60,8 @@ #ifdef QUANTON #define IMU_MPU6000_ALIGN CW90_DEG -#define MAG_HMC5883_ALIGN CW90_DEG #else #define IMU_MPU6000_ALIGN CW270_DEG_FLIP -#define MAG_HMC5883_ALIGN CW270_DEG_FLIP #endif #define USE_BARO diff --git a/src/main/target/F4BY/config.c b/src/main/target/F4BY/config.c new file mode 100755 index 00000000000..d538e04b50b --- /dev/null +++ b/src/main/target/F4BY/config.c @@ -0,0 +1,32 @@ +/* + * This file is part of Cleanflight. + * + * Cleanflight is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Cleanflight is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Cleanflight. If not, see . + */ + +#include + +#include "platform.h" + +#include "config/feature.h" +#include "fc/config.h" +#include "flight/mixer.h" +#include "io/serial.h" +#include "rx/rx.h" +#include "sensors/compass.h" + +void targetConfiguration(void) +{ + compassConfigMutable()->mag_align = CW90_DEG; +} diff --git a/src/main/target/F4BY/target.h b/src/main/target/F4BY/target.h index 6dbb58442fb..e50a360d41d 100644 --- a/src/main/target/F4BY/target.h +++ b/src/main/target/F4BY/target.h @@ -47,7 +47,6 @@ #define USE_MAG #define MAG_I2C_BUS BUS_I2C2 -#define MAG_HMC5883_ALIGN CW90_DEG #define USE_MAG_HMC5883 #define USE_MAG_QMC5883 #define USE_MAG_IST8310 diff --git a/src/main/target/FF_F35_LIGHTNING/config.c b/src/main/target/FF_F35_LIGHTNING/config.c index 4de3455f243..d0825a06fe6 100644 --- a/src/main/target/FF_F35_LIGHTNING/config.c +++ b/src/main/target/FF_F35_LIGHTNING/config.c @@ -18,21 +18,16 @@ #include #include - #include "config/config_master.h" - #include "flight/mixer.h" - #include "rx/rx.h" - #include "io/serial.h" - #include "telemetry/telemetry.h" +#include "sensors/compass.h" -// alternative defaults settings for FF_F35_LIGHTNING targets void targetConfiguration(void) { - motorConfigMutable()->maxthrottle = 2000; + compassConfigMutable()->mag_align = CW90_DEG; serialConfigMutable()->portConfigs[1].functionMask = FUNCTION_MSP; serialConfigMutable()->portConfigs[1].msp_baudrateIndex = BAUD_57600; diff --git a/src/main/target/FF_F35_LIGHTNING/target.h b/src/main/target/FF_F35_LIGHTNING/target.h index 73e3e0fee97..a916b186d72 100644 --- a/src/main/target/FF_F35_LIGHTNING/target.h +++ b/src/main/target/FF_F35_LIGHTNING/target.h @@ -42,7 +42,6 @@ #define USE_MAG #define USE_MAG_MPU9250 -#define MAG_MPU9250_ALIGN CW90_DEG_FLIP #define USE_BARO #define USE_BARO_BMP280 diff --git a/src/main/target/FISHDRONEF4/target.h b/src/main/target/FISHDRONEF4/target.h index 40c0fd199e0..45b8b5b8658 100644 --- a/src/main/target/FISHDRONEF4/target.h +++ b/src/main/target/FISHDRONEF4/target.h @@ -60,7 +60,6 @@ #define USE_MAG_IST8308 #define USE_MAG_QMC5883 #define USE_MAG_LIS3MDL -#define MAG_IST8310_ALIGN CW270_DEG // *************** Temperature sensor ***************** #define TEMPERATURE_I2C_BUS BUS_I2C1 diff --git a/src/main/target/KAKUTEF4/target.h b/src/main/target/KAKUTEF4/target.h index 134889a0f3c..2b0f908a917 100755 --- a/src/main/target/KAKUTEF4/target.h +++ b/src/main/target/KAKUTEF4/target.h @@ -57,7 +57,6 @@ # define USE_MAG # define MAG_I2C_BUS BUS_I2C1 # define USE_MAG_HMC5883 -# define MAG_HMC5883_ALIGN CW180_DEG # define USE_MAG_QMC5883 # define USE_MAG_MAG3110 # define USE_MAG_IST8310 diff --git a/src/main/target/KAKUTEF7/target.h b/src/main/target/KAKUTEF7/target.h index da8f8c9d1a9..0d42c7e2d62 100644 --- a/src/main/target/KAKUTEF7/target.h +++ b/src/main/target/KAKUTEF7/target.h @@ -140,7 +140,6 @@ #define USE_MAG #define MAG_I2C_BUS BUS_I2C1 #define USE_MAG_HMC5883 -#define MAG_HMC5883_ALIGN CW180_DEG #define USE_MAG_QMC5883 #define USE_MAG_MAG3110 #define USE_MAG_IST8310 diff --git a/src/main/target/KROOZX/target.h b/src/main/target/KROOZX/target.h index d0b86ce00c9..4f5eac5f7ce 100755 --- a/src/main/target/KROOZX/target.h +++ b/src/main/target/KROOZX/target.h @@ -41,7 +41,6 @@ #define USE_MAG #define MAG_I2C_BUS BUS_I2C1 -#define MAG_HMC5883_ALIGN CW270_DEG_FLIP #define USE_MAG_HMC5883 #define USE_MAG_QMC5883 #define USE_MAG_IST8310 diff --git a/src/main/target/MATEKF405CAN/config.c b/src/main/target/MATEKF405CAN/config.c index f3f22b74a9c..34166b55120 100644 --- a/src/main/target/MATEKF405CAN/config.c +++ b/src/main/target/MATEKF405CAN/config.c @@ -20,11 +20,12 @@ #include "config/config_master.h" #include "config/feature.h" #include "io/serial.h" +#include "sensors/compass.h" void targetConfiguration(void) { - + compassConfigMutable()->mag_align = CW0_DEG_FLIP; serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART4)].functionMask = FUNCTION_GPS; // serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART4)].gps_baudrateIndex = BAUD_115200; diff --git a/src/main/target/MATEKF405CAN/target.h b/src/main/target/MATEKF405CAN/target.h index f2c0999ee80..b9dde1e434c 100644 --- a/src/main/target/MATEKF405CAN/target.h +++ b/src/main/target/MATEKF405CAN/target.h @@ -85,7 +85,6 @@ #define SPI2_MOSI_PIN PB15 #define USE_MAG_RM3100 -#define MAG_RM3100_ALIGN CW0_DEG_FLIP #define RM3100_CS_PIN PB12 #define RM3100_SPI_BUS BUS_SPI2 diff --git a/src/main/target/OMNIBUSF4/target.h b/src/main/target/OMNIBUSF4/target.h index 2a4383ab4dc..4027144c8d2 100644 --- a/src/main/target/OMNIBUSF4/target.h +++ b/src/main/target/OMNIBUSF4/target.h @@ -90,7 +90,6 @@ #define USE_MAG #define MAG_I2C_BUS I2C_EXT_BUS -#define MAG_HMC5883_ALIGN CW90_DEG #define USE_MAG_HMC5883 #define USE_MAG_QMC5883 #define USE_MAG_IST8310 diff --git a/src/main/target/OMNIBUSF7/target.h b/src/main/target/OMNIBUSF7/target.h index d82ba047b15..50e10578b44 100644 --- a/src/main/target/OMNIBUSF7/target.h +++ b/src/main/target/OMNIBUSF7/target.h @@ -149,7 +149,6 @@ #define USE_MAG #define MAG_I2C_BUS BUS_I2C2 -#define MAG_HMC5883_ALIGN CW270_DEG_FLIP #define USE_MAG_HMC5883 #define USE_MAG_QMC5883 #define USE_MAG_IST8310 diff --git a/src/main/target/PIXRACER/config.c b/src/main/target/PIXRACER/config.c new file mode 100755 index 00000000000..d538e04b50b --- /dev/null +++ b/src/main/target/PIXRACER/config.c @@ -0,0 +1,32 @@ +/* + * This file is part of Cleanflight. + * + * Cleanflight is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Cleanflight is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Cleanflight. If not, see . + */ + +#include + +#include "platform.h" + +#include "config/feature.h" +#include "fc/config.h" +#include "flight/mixer.h" +#include "io/serial.h" +#include "rx/rx.h" +#include "sensors/compass.h" + +void targetConfiguration(void) +{ + compassConfigMutable()->mag_align = CW90_DEG; +} diff --git a/src/main/target/PIXRACER/target.h b/src/main/target/PIXRACER/target.h index 5d6f71b1c89..96fcd682376 100755 --- a/src/main/target/PIXRACER/target.h +++ b/src/main/target/PIXRACER/target.h @@ -44,7 +44,6 @@ #define USE_IMU_MPU9250 #define IMU_MPU9250_ALIGN CW180_DEG_FLIP -#define MAG_MPU9250_ALIGN CW90_DEG #define USE_DUAL_GYRO diff --git a/src/main/target/RADIX/target.h b/src/main/target/RADIX/target.h index 2f778992b59..dd29db84e61 100644 --- a/src/main/target/RADIX/target.h +++ b/src/main/target/RADIX/target.h @@ -36,7 +36,6 @@ // #define USE_MAG // #define MAG_I2C_BUS BUS_I2C1 -// #define MAG_HMC5883_ALIGN CW90_DEG // #define USE_MAG_HMC5883 // #define USE_MAG_QMC5883 // #define USE_MAG_IST8310 diff --git a/src/main/target/REVO/config.c b/src/main/target/REVO/config.c new file mode 100755 index 00000000000..d538e04b50b --- /dev/null +++ b/src/main/target/REVO/config.c @@ -0,0 +1,32 @@ +/* + * This file is part of Cleanflight. + * + * Cleanflight is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Cleanflight is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Cleanflight. If not, see . + */ + +#include + +#include "platform.h" + +#include "config/feature.h" +#include "fc/config.h" +#include "flight/mixer.h" +#include "io/serial.h" +#include "rx/rx.h" +#include "sensors/compass.h" + +void targetConfiguration(void) +{ + compassConfigMutable()->mag_align = CW90_DEG; +} diff --git a/src/main/target/REVO/target.h b/src/main/target/REVO/target.h index 360d097c699..f8a3c7264c8 100644 --- a/src/main/target/REVO/target.h +++ b/src/main/target/REVO/target.h @@ -47,7 +47,6 @@ #define USE_DUAL_MAG #define MAG_I2C_BUS_EXT BUS_I2C2 #define MAG_I2C_BUS_INT BUS_I2C1 -#define MAG_HMC5883_ALIGN CW90_DEG #define USE_MAG_HMC5883 #define USE_MAG_QMC5883 #define USE_MAG_IST8310 @@ -131,8 +130,6 @@ #define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT -#define MAG_GPS_ALIGN CW180_DEG_FLIP - #define DEFAULT_RX_TYPE RX_TYPE_SERIAL #define DEFAULT_FEATURES (FEATURE_TX_PROF_SEL | FEATURE_BLACKBOX) diff --git a/src/main/target/SPARKY/target.h b/src/main/target/SPARKY/target.h index 26baef81c2c..5052027dc44 100644 --- a/src/main/target/SPARKY/target.h +++ b/src/main/target/SPARKY/target.h @@ -42,7 +42,6 @@ #define USE_MAG #define MAG_I2C_BUS BUS_I2C2 -#define MAG_AK8975_ALIGN CW0_DEG #define USE_MAG_AK8975 #define USE_MAG_HMC5883 #define USE_MAG_QMC5883 diff --git a/src/main/target/SPARKY2/config.c b/src/main/target/SPARKY2/config.c new file mode 100755 index 00000000000..a6dc77f9e0e --- /dev/null +++ b/src/main/target/SPARKY2/config.c @@ -0,0 +1,32 @@ +/* + * This file is part of Cleanflight. + * + * Cleanflight is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Cleanflight is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Cleanflight. If not, see . + */ + +#include + +#include "platform.h" + +#include "config/feature.h" +#include "fc/config.h" +#include "flight/mixer.h" +#include "io/serial.h" +#include "rx/rx.h" +#include "sensors/compass.h" + +void targetConfiguration(void) +{ + compassConfigMutable()->mag_align = CW0_DEG; +} diff --git a/src/main/target/SPARKY2/target.h b/src/main/target/SPARKY2/target.h index c1d18603d57..d5b291b323f 100644 --- a/src/main/target/SPARKY2/target.h +++ b/src/main/target/SPARKY2/target.h @@ -42,7 +42,6 @@ #define USE_MAG #define USE_MAG_MPU9250 -#define MAG_MPU9250_ALIGN CW0_DEG #define MAG_I2C_BUS BUS_I2C1 #define USE_MAG_HMC5883 diff --git a/src/main/target/SPEEDYBEEF4/target.h b/src/main/target/SPEEDYBEEF4/target.h index c51b5588320..183492c42b6 100644 --- a/src/main/target/SPEEDYBEEF4/target.h +++ b/src/main/target/SPEEDYBEEF4/target.h @@ -140,7 +140,6 @@ #define USE_MAG_IST8310 #define USE_MAG_MAG3110 #define USE_MAG_LIS3MDL -#define MAG_HMC5883_ALIGN CW90_DEG /*** ADC ***/ #define USE_ADC diff --git a/src/main/target/SPRACINGF3/target.h b/src/main/target/SPRACINGF3/target.h index 05727f5d42c..bab9f28842c 100644 --- a/src/main/target/SPRACINGF3/target.h +++ b/src/main/target/SPRACINGF3/target.h @@ -42,7 +42,6 @@ #define USE_MAG #define MAG_I2C_BUS BUS_I2C1 -#define MAG_HMC5883_ALIGN CW270_DEG #define USE_MAG_HMC5883 #define USE_MAG_QMC5883 #define USE_MAG_IST8310 diff --git a/src/main/target/SPRACINGF3EVO/target.h b/src/main/target/SPRACINGF3EVO/target.h index c2b139a0445..a6671880929 100755 --- a/src/main/target/SPRACINGF3EVO/target.h +++ b/src/main/target/SPRACINGF3EVO/target.h @@ -47,7 +47,6 @@ #define USE_MAG #define MAG_I2C_BUS BUS_I2C1 -#define MAG_MPU9250_ALIGN CW270_DEG #define USE_MAG_MPU9250 #define USE_MAG_HMC5883 #define USE_MAG_QMC5883 diff --git a/src/main/target/SPRACINGF3MINI/target.h b/src/main/target/SPRACINGF3MINI/target.h index 6a7ec647f1f..406ee535f0b 100644 --- a/src/main/target/SPRACINGF3MINI/target.h +++ b/src/main/target/SPRACINGF3MINI/target.h @@ -47,7 +47,6 @@ #define USE_MAG #define MAG_I2C_BUS BUS_I2C1 -#define MAG_AK8963_ALIGN CW270_DEG #define USE_MAG_AK8963 #define USE_MAG_HMC5883 #define USE_MAG_QMC5883 diff --git a/src/main/target/YUPIF4/target.h b/src/main/target/YUPIF4/target.h index 7f05ef7ef4d..741f2242527 100644 --- a/src/main/target/YUPIF4/target.h +++ b/src/main/target/YUPIF4/target.h @@ -64,7 +64,6 @@ #define USE_MAG #define MAG_I2C_BUS BUS_I2C2 #define USE_MAG_HMC5883 -#define MAG_HMC5883_ALIGN CW270_DEG_FLIP #define USE_MAG_QMC5883 #define TEMPERATURE_I2C_BUS BUS_I2C2 diff --git a/src/main/target/YUPIF7/target.h b/src/main/target/YUPIF7/target.h index 820431f3e3d..a95336a738d 100644 --- a/src/main/target/YUPIF7/target.h +++ b/src/main/target/YUPIF7/target.h @@ -44,7 +44,6 @@ #define USE_MAG #define MAG_I2C_BUS BUS_I2C1 #define USE_MAG_HMC5883 -#define MAG_HMC5883_ALIGN CW270_DEG_FLIP #define USE_MAG_QMC5883 #define TEMPERATURE_I2C_BUS BUS_I2C1 #define BNO055_I2C_BUS BUS_I2C1