From b75b01b4c51b60ecba032f70855f25e882f01cbb Mon Sep 17 00:00:00 2001 From: Moto Moto Date: Thu, 3 Mar 2016 23:06:04 -0600 Subject: [PATCH 01/14] Fixed ON_USB beeper inhibit --- src/main/io/beeper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/io/beeper.c b/src/main/io/beeper.c index 7a0e1d6b98..e7ec349649 100644 --- a/src/main/io/beeper.c +++ b/src/main/io/beeper.c @@ -185,7 +185,7 @@ static const beeperTableEntry_t *currentBeeperEntry = NULL; */ void beeper(beeperMode_e mode) { - if (mode == BEEPER_SILENCE || (mode == BEEPER_USB && (feature(FEATURE_VBAT) && (batteryCellCount < 2)))) { + if (mode == BEEPER_SILENCE || ((getBeeperOffMask() & (1 << (BEEPER_USB-1))) && (feature(FEATURE_VBAT) && (batteryCellCount < 2)))) { beeperSilence(); return; } From 8c8da923a71f440c6ff3ae6e5730d2faf2208b06 Mon Sep 17 00:00:00 2001 From: borisbstyle Date: Fri, 4 Mar 2016 09:10:10 +0100 Subject: [PATCH 02/14] 2.5 Patch 1 --- src/main/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/version.h b/src/main/version.h index 7b7bdd3379..9e353dbc44 100644 --- a/src/main/version.h +++ b/src/main/version.h @@ -17,7 +17,7 @@ #define FC_VERSION_MAJOR 2 // increment when a major release is made (big new feature, etc) #define FC_VERSION_MINOR 5 // increment when a minor release is made (small new feature, change etc) -#define FC_VERSION_PATCH_LEVEL 0 // increment when a bug is fixed +#define FC_VERSION_PATCH_LEVEL 1 // increment when a bug is fixed #define STR_HELPER(x) #x #define STR(x) STR_HELPER(x) From 65e17dd957889539014acdf403cb05210442d1f8 Mon Sep 17 00:00:00 2001 From: borisbstyle Date: Fri, 4 Mar 2016 09:13:51 +0100 Subject: [PATCH 03/14] Equal throttle scaling for stick and switch armers // Changed default min_check to get the same effect --- src/main/config/config.c | 2 +- src/main/mw.c | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/main/config/config.c b/src/main/config/config.c index 194a9af5cc..de05f41af5 100755 --- a/src/main/config/config.c +++ b/src/main/config/config.c @@ -442,7 +442,7 @@ static void resetConf(void) masterConfig.rxConfig.spektrum_sat_bind = 0; masterConfig.rxConfig.spektrum_sat_bind_autoreset = 1; masterConfig.rxConfig.midrc = 1500; - masterConfig.rxConfig.mincheck = 1100; + masterConfig.rxConfig.mincheck = 1040; masterConfig.rxConfig.maxcheck = 1900; masterConfig.rxConfig.rx_min_usec = 885; // any of first 4 channels below this value will trigger rx loss detection masterConfig.rxConfig.rx_max_usec = 2115; // any of first 4 channels above this value will trigger rx loss detection diff --git a/src/main/mw.c b/src/main/mw.c index f9b73c050d..70396af390 100644 --- a/src/main/mw.c +++ b/src/main/mw.c @@ -270,13 +270,8 @@ void annexCode(void) rcCommand[axis] = -rcCommand[axis]; } - if (isUsingSticksForArming()) { - tmp = constrain(rcData[THROTTLE], masterConfig.rxConfig.mincheck, PWM_RANGE_MAX); - tmp = (uint32_t)(tmp - masterConfig.rxConfig.mincheck) * PWM_RANGE_MIN / (PWM_RANGE_MAX - masterConfig.rxConfig.mincheck); - } else { - tmp = constrain(rcData[THROTTLE], PWM_RANGE_MIN, PWM_RANGE_MAX); - tmp = (uint32_t)(tmp - PWM_RANGE_MIN) * PWM_RANGE_MIN / (PWM_RANGE_MAX - PWM_RANGE_MIN); // [MINCHECK;2000] -> [0;1000] - } + tmp = constrain(rcData[THROTTLE], masterConfig.rxConfig.mincheck, PWM_RANGE_MAX); + tmp = (uint32_t)(tmp - masterConfig.rxConfig.mincheck) * PWM_RANGE_MIN / (PWM_RANGE_MAX - masterConfig.rxConfig.mincheck); tmp2 = tmp / 100; rcCommand[THROTTLE] = lookupThrottleRC[tmp2] + (tmp - tmp2 * 100) * (lookupThrottleRC[tmp2 + 1] - lookupThrottleRC[tmp2]) / 100; // [0;1000] -> expo -> [MINTHROTTLE;MAXTHROTTLE] From bafdbf4b2a1f363a2bbd48112dd1cf242a1fd9de Mon Sep 17 00:00:00 2001 From: borisbstyle Date: Fri, 4 Mar 2016 22:03:13 +0100 Subject: [PATCH 04/14] Change min threshold for mix reduction --- src/main/flight/mixer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/flight/mixer.c b/src/main/flight/mixer.c index f24e38e2c9..9d1404eb07 100755 --- a/src/main/flight/mixer.c +++ b/src/main/flight/mixer.c @@ -787,7 +787,7 @@ void mixTable(void) bool isFailsafeActive = failsafeIsActive(); // TODO - Find out if failsafe checks are really needed here in mixer code if (motorLimitReached) { - uint8_t pidAttenuation = constrain(qPercent(mixReduction), 20, 100); + uint8_t pidAttenuation = constrain(qPercent(mixReduction), 30, 100); for (axis = 0; axis < 2; axis++) axisPID[axis] *= pidAttenuation / 100; if (debugMode == DEBUG_AIRMODE) debug[0] = pidAttenuation; } From bd9f93660b325d2d94d3faa67e6769f63bb420ed Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Fri, 19 Feb 2016 15:02:27 +0100 Subject: [PATCH 05/14] SPRACINGF3MINI - Cleanup PWM output mapping. Remove no-longer needed TIM3 / OneShot workaround. --- src/main/drivers/pwm_mapping.c | 49 +++++++++++++++---------- src/main/drivers/timer.c | 29 ++++++--------- src/main/target/SPRACINGF3MINI/target.h | 2 +- 3 files changed, 43 insertions(+), 37 deletions(-) diff --git a/src/main/drivers/pwm_mapping.c b/src/main/drivers/pwm_mapping.c index d250fcff96..28651dd00e 100755 --- a/src/main/drivers/pwm_mapping.c +++ b/src/main/drivers/pwm_mapping.c @@ -521,6 +521,8 @@ static const uint16_t airPWM[] = { static const uint16_t multiPPM[] = { PWM1 | (MAP_TO_PPM_INPUT << 8), // PPM input + PWM2 | (MAP_TO_MOTOR_OUTPUT << 8), + PWM3 | (MAP_TO_MOTOR_OUTPUT << 8), PWM4 | (MAP_TO_MOTOR_OUTPUT << 8), PWM5 | (MAP_TO_MOTOR_OUTPUT << 8), PWM6 | (MAP_TO_MOTOR_OUTPUT << 8), @@ -529,35 +531,49 @@ static const uint16_t multiPPM[] = { PWM9 | (MAP_TO_MOTOR_OUTPUT << 8), PWM10 | (MAP_TO_MOTOR_OUTPUT << 8), PWM11 | (MAP_TO_MOTOR_OUTPUT << 8), - PWM12 | (MAP_TO_MOTOR_OUTPUT << 8), - PWM13 | (MAP_TO_MOTOR_OUTPUT << 8), - PWM2 | (MAP_TO_MOTOR_OUTPUT << 8), - PWM3 | (MAP_TO_MOTOR_OUTPUT << 8), 0xFFFF }; static const uint16_t multiPWM[] = { + PWM2 | (MAP_TO_MOTOR_OUTPUT << 8), + PWM3 | (MAP_TO_MOTOR_OUTPUT << 8), + PWM4 | (MAP_TO_MOTOR_OUTPUT << 8), + PWM5 | (MAP_TO_MOTOR_OUTPUT << 8), + PWM6 | (MAP_TO_MOTOR_OUTPUT << 8), + PWM7 | (MAP_TO_MOTOR_OUTPUT << 8), + PWM8 | (MAP_TO_MOTOR_OUTPUT << 8), + PWM9 | (MAP_TO_MOTOR_OUTPUT << 8), + PWM10 | (MAP_TO_MOTOR_OUTPUT << 8), + PWM11 | (MAP_TO_MOTOR_OUTPUT << 8), 0xFFFF }; static const uint16_t airPPM[] = { PWM1 | (MAP_TO_PPM_INPUT << 8), // PPM input - PWM4 | (MAP_TO_MOTOR_OUTPUT << 8), // motor #1 - PWM5 | (MAP_TO_MOTOR_OUTPUT << 8), // motor #2 - PWM6 | (MAP_TO_SERVO_OUTPUT << 8), // servo #1 + PWM2 | (MAP_TO_MOTOR_OUTPUT << 8), // motor #1 + PWM3 | (MAP_TO_MOTOR_OUTPUT << 8), // motor #2 + PWM4 | (MAP_TO_SERVO_OUTPUT << 8), // servo #1 + PWM5 | (MAP_TO_SERVO_OUTPUT << 8), + PWM6 | (MAP_TO_SERVO_OUTPUT << 8), PWM7 | (MAP_TO_SERVO_OUTPUT << 8), PWM8 | (MAP_TO_SERVO_OUTPUT << 8), PWM9 | (MAP_TO_SERVO_OUTPUT << 8), PWM10 | (MAP_TO_SERVO_OUTPUT << 8), - PWM11 | (MAP_TO_SERVO_OUTPUT << 8), - PWM12 | (MAP_TO_SERVO_OUTPUT << 8), - PWM13 | (MAP_TO_SERVO_OUTPUT << 8), - PWM2 | (MAP_TO_SERVO_OUTPUT << 8), - PWM3 | (MAP_TO_SERVO_OUTPUT << 8), // servo #10 + PWM11 | (MAP_TO_SERVO_OUTPUT << 8), // servo #8 0xFFFF }; static const uint16_t airPWM[] = { + PWM2 | (MAP_TO_MOTOR_OUTPUT << 8), // motor #1 + PWM3 | (MAP_TO_MOTOR_OUTPUT << 8), // motor #2 + PWM4 | (MAP_TO_SERVO_OUTPUT << 8), // servo #1 + PWM5 | (MAP_TO_SERVO_OUTPUT << 8), + PWM6 | (MAP_TO_SERVO_OUTPUT << 8), + PWM7 | (MAP_TO_SERVO_OUTPUT << 8), + PWM8 | (MAP_TO_SERVO_OUTPUT << 8), + PWM9 | (MAP_TO_SERVO_OUTPUT << 8), + PWM10 | (MAP_TO_SERVO_OUTPUT << 8), + PWM11 | (MAP_TO_SERVO_OUTPUT << 8), // servo #8 0xFFFF }; #endif @@ -724,8 +740,8 @@ if (init->useBuzzerP6) { #endif #if defined(SPRACINGF3MINI) - // remap PWM8+9 as servos - if ((timerIndex == PWM8 || timerIndex == PWM9) && timerHardwarePtr->tim == TIM15) + // remap PWM6+7 as servos + if ((timerIndex == PWM6 || timerIndex == PWM7) && timerHardwarePtr->tim == TIM15) type = MAP_TO_SERVO_OUTPUT; #endif @@ -784,11 +800,6 @@ if (init->useBuzzerP6) { if (init->useOneshot || isMotorBrushed(init->motorPwmRate)) { ppmAvoidPWMTimerClash(timerHardwarePtr, TIM2); } -#endif -#ifdef SPRACINGF3MINI - if (init->useOneshot || isMotorBrushed(init->motorPwmRate)) { - ppmAvoidPWMTimerClash(timerHardwarePtr, TIM3); - } #endif ppmInConfig(timerHardwarePtr); } else if (type == MAP_TO_PWM_INPUT) { diff --git a/src/main/drivers/timer.c b/src/main/drivers/timer.c index 19f3bae6a0..cb5c30fccd 100755 --- a/src/main/drivers/timer.c +++ b/src/main/drivers/timer.c @@ -305,30 +305,25 @@ const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { // PPM Pad #ifdef SPRACINGF3MINI_MKII_REVA - { TIM3, GPIOB, Pin_5, TIM_Channel_2, TIM3_IRQn, 0, Mode_AF_PP, GPIO_PinSource5, GPIO_AF_2}, // RC_CH5 - PB5 - *TIM3_CH1 + { TIM3, GPIOB, Pin_5, TIM_Channel_2, TIM3_IRQn, 0, Mode_AF_PP, GPIO_PinSource5, GPIO_AF_2}, // PPM - PB5 // PB4 / TIM3 CH1 is connected to USBPresent #else - { TIM3, GPIOB, Pin_4, TIM_Channel_1, TIM3_IRQn, 0, Mode_AF_PP, GPIO_PinSource4, GPIO_AF_2}, // RC_CH5 - PB4 - *TIM3_CH1 + { TIM3, GPIOB, Pin_4, TIM_Channel_1, TIM3_IRQn, 0, Mode_AF_PP, GPIO_PinSource4, GPIO_AF_2}, // PPM - PB4 // PB5 / TIM3 CH2 is connected to USBPresent #endif - // PAD6/7 Sonar Pads - { TIM3, GPIOB, Pin_0, TIM_Channel_3, TIM3_IRQn, 0, Mode_AF_PP, GPIO_PinSource0, GPIO_AF_2}, // RC_CH7 - PB0 - *TIM3_CH3, TIM1_CH2N, TIM8_CH2N - { TIM3, GPIOB, Pin_1, TIM_Channel_4, TIM3_IRQn, 0, Mode_AF_PP, GPIO_PinSource1, GPIO_AF_2}, // RC_CH8 - PB1 - *TIM3_CH4, TIM1_CH3N, TIM8_CH3N - // UART3 RX/TX pads - { TIM16, GPIOA, Pin_6, TIM_Channel_1, TIM1_UP_TIM16_IRQn, 1, Mode_AF_PP, GPIO_PinSource6, GPIO_AF_1}, // PWM1 - PA6 - TIM3_CH1, TIM8_BKIN, TIM1_BKIN, *TIM16_CH1 - { TIM17, GPIOA, Pin_7, TIM_Channel_1, TIM1_TRG_COM_TIM17_IRQn, 1, Mode_AF_PP, GPIO_PinSource7, GPIO_AF_1}, // PWM2 - PA7 - TIM3_CH2, *TIM17_CH1, TIM1_CH1N, TIM8_CH1 - { TIM4, GPIOB, Pin_8, TIM_Channel_3, TIM4_IRQn, 1, Mode_AF_PP, GPIO_PinSource8, GPIO_AF_2}, // PWM5 - PB8 - { TIM4, GPIOB, Pin_9, TIM_Channel_4, TIM4_IRQn, 1, Mode_AF_PP, GPIO_PinSource9, GPIO_AF_2}, // PWM6 - PB9 - { TIM15, GPIOA, Pin_2, TIM_Channel_1, TIM1_BRK_TIM15_IRQn, 1, Mode_AF_PP, GPIO_PinSource2, GPIO_AF_9}, // PWM7 - PA2 - { TIM15, GPIOA, Pin_3, TIM_Channel_2, TIM1_BRK_TIM15_IRQn, 1, Mode_AF_PP, GPIO_PinSource3, GPIO_AF_9}, // PWM8 - PA3 + { TIM16, GPIOA, Pin_6, TIM_Channel_1, TIM1_UP_TIM16_IRQn, 1, Mode_AF_PP, GPIO_PinSource6, GPIO_AF_1}, // PWM1 - PA6 + { TIM17, GPIOA, Pin_7, TIM_Channel_1, TIM1_TRG_COM_TIM17_IRQn, 1, Mode_AF_PP, GPIO_PinSource7, GPIO_AF_1}, // PWM2 - PA7 + { TIM4, GPIOB, Pin_8, TIM_Channel_3, TIM4_IRQn, 1, Mode_AF_PP, GPIO_PinSource8, GPIO_AF_2}, // PWM3 - PB8 + { TIM4, GPIOB, Pin_9, TIM_Channel_4, TIM4_IRQn, 1, Mode_AF_PP, GPIO_PinSource9, GPIO_AF_2}, // PWM4 - PB9 + { TIM15, GPIOA, Pin_2, TIM_Channel_1, TIM1_BRK_TIM15_IRQn, 1, Mode_AF_PP, GPIO_PinSource2, GPIO_AF_9}, // PWM5 - PA2 + { TIM15, GPIOA, Pin_3, TIM_Channel_2, TIM1_BRK_TIM15_IRQn, 1, Mode_AF_PP, GPIO_PinSource3, GPIO_AF_9}, // PWM6 - PA3 + { TIM2, GPIOA, Pin_0, TIM_Channel_1, TIM2_IRQn, 1, Mode_AF_PP, GPIO_PinSource0, GPIO_AF_1}, // PWM7 - PA0 + { TIM2, GPIOA, Pin_1, TIM_Channel_2, TIM2_IRQn, 1, Mode_AF_PP, GPIO_PinSource1, GPIO_AF_1}, // PWM8 - PA1 - // PAD3/4 - { TIM2, GPIOA, Pin_0, TIM_Channel_1, TIM2_IRQn, 1, Mode_AF_PP, GPIO_PinSource0, GPIO_AF_1}, // PWM7 - PA0 - *TIM2_CH1 - { TIM2, GPIOA, Pin_1, TIM_Channel_2, TIM2_IRQn, 1, Mode_AF_PP, GPIO_PinSource1, GPIO_AF_1}, // PWM8 - PA1 - *TIM2_CH2, TIM15_CH1N // UART3 RX/TX - { TIM2, GPIOB, Pin_10, TIM_Channel_3, TIM2_IRQn, 1, Mode_AF_PP, GPIO_PinSource10, GPIO_AF_1}, // RC_CH4 - PB10 - *TIM2_CH3, USART3_TX (AF7) - { TIM2, GPIOB, Pin_11, TIM_Channel_4, TIM2_IRQn, 1, Mode_AF_PP, GPIO_PinSource11, GPIO_AF_1}, // RC_CH3 - PB11 - *TIM2_CH4, USART3_RX (AF7) + { TIM2, GPIOB, Pin_10, TIM_Channel_3, TIM2_IRQn, 1, Mode_AF_PP, GPIO_PinSource10, GPIO_AF_1}, // PWM9 - PB10 - TIM2_CH3 / USART3_TX (AF7) + { TIM2, GPIOB, Pin_11, TIM_Channel_4, TIM2_IRQn, 1, Mode_AF_PP, GPIO_PinSource11, GPIO_AF_1}, // PWM10 - PB11 - TIM2_CH4 / USART3_RX (AF7) // LED Strip Pad { TIM1, GPIOA, Pin_8, TIM_Channel_1, TIM1_CC_IRQn, 1, Mode_AF_PP, GPIO_PinSource8, GPIO_AF_6}, // GPIO_TIMER / LED_STRIP diff --git a/src/main/target/SPRACINGF3MINI/target.h b/src/main/target/SPRACINGF3MINI/target.h index 817f39d2a7..b2fc739413 100644 --- a/src/main/target/SPRACINGF3MINI/target.h +++ b/src/main/target/SPRACINGF3MINI/target.h @@ -31,7 +31,7 @@ #define BEEP_PERIPHERAL RCC_AHBPeriph_GPIOC #define BEEPER_INVERTED -#define USABLE_TIMER_CHANNEL_COUNT 14 // 8 Outputs; PPM; LED Strip; SonarPads; 2 additional PWM pins also on UART3 RX/TX pins. +#define USABLE_TIMER_CHANNEL_COUNT 12 // 8 Outputs; PPM; LED Strip; 2 additional PWM pins also on UART3 RX/TX pins. #define EXTI15_10_CALLBACK_HANDLER_COUNT 2 // MPU_INT, SDCardDetect From c9a35d278d97963ae82c03a57ec93f161bee94f3 Mon Sep 17 00:00:00 2001 From: borisbstyle Date: Sat, 5 Mar 2016 20:27:07 +0100 Subject: [PATCH 06/14] yaw protection pirouette // hard yaw manouvres --- src/main/flight/mixer.c | 6 ++---- src/main/version.h | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/flight/mixer.c b/src/main/flight/mixer.c index 9d1404eb07..44610f6393 100755 --- a/src/main/flight/mixer.c +++ b/src/main/flight/mixer.c @@ -782,14 +782,12 @@ void mixTable(void) uint32_t i; fix12_t vbatCompensationFactor; static fix12_t mixReduction; - uint8_t axis; bool isFailsafeActive = failsafeIsActive(); // TODO - Find out if failsafe checks are really needed here in mixer code if (motorLimitReached) { - uint8_t pidAttenuation = constrain(qPercent(mixReduction), 30, 100); - for (axis = 0; axis < 2; axis++) axisPID[axis] *= pidAttenuation / 100; - if (debugMode == DEBUG_AIRMODE) debug[0] = pidAttenuation; + axisPID[YAW] *= constrain(qPercent(mixReduction), 40, 100); + if (debugMode == DEBUG_AIRMODE) debug[0] = axisPID[YAW]; } if (IS_RC_MODE_ACTIVE(BOXACROPLUS)) { diff --git a/src/main/version.h b/src/main/version.h index 9e353dbc44..5171f711a7 100644 --- a/src/main/version.h +++ b/src/main/version.h @@ -17,7 +17,7 @@ #define FC_VERSION_MAJOR 2 // increment when a major release is made (big new feature, etc) #define FC_VERSION_MINOR 5 // increment when a minor release is made (small new feature, change etc) -#define FC_VERSION_PATCH_LEVEL 1 // increment when a bug is fixed +#define FC_VERSION_PATCH_LEVEL 2 // increment when a bug is fixed #define STR_HELPER(x) #x #define STR(x) STR_HELPER(x) From dc6529ec9e86057a30f5fc16cfddc825f4de8b31 Mon Sep 17 00:00:00 2001 From: borisbstyle Date: Sat, 5 Mar 2016 20:49:34 +0100 Subject: [PATCH 07/14] New 1000 looptime default --- src/main/config/config.c | 4 ++-- src/main/io/serial_msp.c | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/config/config.c b/src/main/config/config.c index de05f41af5..04cb944b68 100755 --- a/src/main/config/config.c +++ b/src/main/config/config.c @@ -408,8 +408,8 @@ static void resetConf(void) masterConfig.current_profile_index = 0; // default profile masterConfig.dcm_kp = 2500; // 1.0 * 10000 masterConfig.dcm_ki = 0; // 0.003 * 10000 - masterConfig.gyro_lpf = 1; // 188HZ - masterConfig.gyro_sync_denom = 4; + masterConfig.gyro_lpf = 0; // 256HZ default + masterConfig.gyro_sync_denom = 8; masterConfig.gyro_soft_lpf_hz = 60; masterConfig.pid_process_denom = 1; diff --git a/src/main/io/serial_msp.c b/src/main/io/serial_msp.c index 3d3b381080..7dd0e84ade 100644 --- a/src/main/io/serial_msp.c +++ b/src/main/io/serial_msp.c @@ -133,7 +133,8 @@ void setGyroSamplingSpeed(uint16_t looptime) { masterConfig.pid_process_denom = 2; } } else { - masterConfig.gyro_lpf = 1; + masterConfig.gyro_lpf = 0; + masterConfig.gyro_sync_denom = 8; masterConfig.pid_process_denom = 1; masterConfig.acc_hardware = 0; masterConfig.baro_hardware = 0; @@ -159,7 +160,8 @@ void setGyroSamplingSpeed(uint16_t looptime) { } } } else { - masterConfig.gyro_lpf = 1; + masterConfig.gyro_lpf = 0; + masterConfig.gyro_sync_denom = 8; masterConfig.acc_hardware = 0; masterConfig.baro_hardware = 0; masterConfig.mag_hardware = 0; From 37bd1d65fdeeb02ceec0537b864eddd1add448bc Mon Sep 17 00:00:00 2001 From: borisbstyle Date: Sat, 5 Mar 2016 22:35:09 +0100 Subject: [PATCH 08/14] Fix 1000 looptime auto config --- src/main/io/serial_msp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/io/serial_msp.c b/src/main/io/serial_msp.c index 7dd0e84ade..122f2e77b1 100644 --- a/src/main/io/serial_msp.c +++ b/src/main/io/serial_msp.c @@ -132,10 +132,10 @@ void setGyroSamplingSpeed(uint16_t looptime) { masterConfig.mag_hardware = 1; masterConfig.pid_process_denom = 2; } + masterConfig.gyro_sync_denom = constrain(looptime / gyroSampleRate, 1, maxDivider); } else { masterConfig.gyro_lpf = 0; masterConfig.gyro_sync_denom = 8; - masterConfig.pid_process_denom = 1; masterConfig.acc_hardware = 0; masterConfig.baro_hardware = 0; masterConfig.mag_hardware = 0; @@ -159,8 +159,10 @@ void setGyroSamplingSpeed(uint16_t looptime) { masterConfig.pid_process_denom = 2; } } + masterConfig.gyro_sync_denom = constrain(looptime / gyroSampleRate, 1, maxDivider); } else { masterConfig.gyro_lpf = 0; + masterConfig.gyro_sync_denom = 8; masterConfig.acc_hardware = 0; masterConfig.baro_hardware = 0; @@ -168,7 +170,6 @@ void setGyroSamplingSpeed(uint16_t looptime) { masterConfig.pid_process_denom = 1; } #endif - masterConfig.gyro_sync_denom = constrain(looptime / gyroSampleRate, 1, maxDivider); if (!(masterConfig.use_multiShot || masterConfig.use_oneshot42) && ((masterConfig.gyro_sync_denom * gyroSampleRate) == 125)) masterConfig.pid_process_denom = 3; } From 0aac02549485953233492bb374d719816ed12abe Mon Sep 17 00:00:00 2001 From: borisbstyle Date: Sun, 6 Mar 2016 14:04:09 +0100 Subject: [PATCH 09/14] Version 2.5.3 / Configurable yaw_p_limit for all pid controllers --- src/main/flight/mixer.c | 5 ----- src/main/flight/pid.c | 12 +++++++++++- src/main/flight/pid.h | 2 +- src/main/version.h | 2 +- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main/flight/mixer.c b/src/main/flight/mixer.c index 44610f6393..29c0ac41bd 100755 --- a/src/main/flight/mixer.c +++ b/src/main/flight/mixer.c @@ -785,11 +785,6 @@ void mixTable(void) bool isFailsafeActive = failsafeIsActive(); // TODO - Find out if failsafe checks are really needed here in mixer code - if (motorLimitReached) { - axisPID[YAW] *= constrain(qPercent(mixReduction), 40, 100); - if (debugMode == DEBUG_AIRMODE) debug[0] = axisPID[YAW]; - } - if (IS_RC_MODE_ACTIVE(BOXACROPLUS)) { acroPlusApply(); } diff --git a/src/main/flight/pid.c b/src/main/flight/pid.c index 94fe1a3de6..c8496db4a3 100644 --- a/src/main/flight/pid.c +++ b/src/main/flight/pid.c @@ -213,6 +213,11 @@ static void pidLuxFloat(pidProfile_t *pidProfile, controlRateConfig_t *controlRa // -----calculate P component PTerm = RateError * pidProfile->P_f[axis] * PIDweight[axis] / 100; + // Constrain YAW by yaw_p_limit value if not servo driven in that case servolimits apply + if((motorCount >= 4 && pidProfile->yaw_p_limit) && axis == YAW) { + PTerm = constrainf(PTerm, -pidProfile->yaw_p_limit, pidProfile->yaw_p_limit); + } + // -----calculate I component. errorGyroIf[axis] = constrainf(errorGyroIf[axis] + RateError * dT * pidProfile->I_f[axis] * 10, -250.0f, 250.0f); @@ -407,7 +412,7 @@ static void pidMultiWii23(pidProfile_t *pidProfile, controlRateConfig_t *control PTerm = (int32_t)error * pidProfile->P8[FD_YAW] >> 6; // TODO: Bitwise shift on a signed integer is not recommended - // Constrain YAW by D value if not servo driven in that case servolimits apply + // Constrain YAW by yaw_p_limit value if not servo driven in that case servolimits apply if(motorCount >= 4 && pidProfile->yaw_p_limit < YAW_P_LIMIT_MAX) { PTerm = constrain(PTerm, -pidProfile->yaw_p_limit, pidProfile->yaw_p_limit); } @@ -504,6 +509,11 @@ static void pidMultiWiiRewrite(pidProfile_t *pidProfile, controlRateConfig_t *co // -----calculate P component PTerm = (RateError * pidProfile->P8[axis] * PIDweight[axis] / 100) >> 7; + // Constrain YAW by yaw_p_limit value if not servo driven in that case servolimits apply + if((motorCount >= 4 && pidProfile->yaw_p_limit) && axis == YAW) { + PTerm = constrain(PTerm, -pidProfile->yaw_p_limit, pidProfile->yaw_p_limit); + } + // -----calculate I component // there should be no division before accumulating the error to integrator, because the precision would be reduced. // Precision is critical, as I prevents from long-time drift. Thus, 32 bits integrator is used. diff --git a/src/main/flight/pid.h b/src/main/flight/pid.h index 709c0309a2..8cd7c3621b 100644 --- a/src/main/flight/pid.h +++ b/src/main/flight/pid.h @@ -20,7 +20,7 @@ #define GYRO_I_MAX 256 // Gyro I limiter #define YAW_P_LIMIT_MIN 100 // Maximum value for yaw P limiter -#define YAW_P_LIMIT_MAX 500 // Maximum value for yaw P limiter +#define YAW_P_LIMIT_MAX 300 // Maximum value for yaw P limiter typedef enum { PIDROLL, diff --git a/src/main/version.h b/src/main/version.h index 5171f711a7..f2581c2eca 100644 --- a/src/main/version.h +++ b/src/main/version.h @@ -17,7 +17,7 @@ #define FC_VERSION_MAJOR 2 // increment when a major release is made (big new feature, etc) #define FC_VERSION_MINOR 5 // increment when a minor release is made (small new feature, change etc) -#define FC_VERSION_PATCH_LEVEL 2 // increment when a bug is fixed +#define FC_VERSION_PATCH_LEVEL 3 // increment when a bug is fixed #define STR_HELPER(x) #x #define STR(x) STR_HELPER(x) From 1187c575ed3a26c9bfa3b3731b15bb8d61fe38b7 Mon Sep 17 00:00:00 2001 From: borisbstyle Date: Tue, 8 Mar 2016 22:46:54 +0100 Subject: [PATCH 10/14] Gyro Calibration scaled to looptime setting --- src/main/io/rc_controls.c | 3 ++- src/main/main.c | 2 +- src/main/sensors/gyro.c | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/io/rc_controls.c b/src/main/io/rc_controls.c index c89c50bef3..2a66bb19af 100644 --- a/src/main/io/rc_controls.c +++ b/src/main/io/rc_controls.c @@ -34,6 +34,7 @@ #include "drivers/system.h" #include "drivers/sensor.h" #include "drivers/accgyro.h" +#include "drivers/gyro_sync.h" #include "sensors/barometer.h" #include "sensors/battery.h" @@ -215,7 +216,7 @@ void processRcStickPositions(rxConfig_t *rxConfig, throttleStatus_e throttleStat if (rcSticks == THR_LO + YAW_LO + PIT_LO + ROL_CE) { // GYRO calibration - gyroSetCalibrationCycles(CALIBRATING_GYRO_CYCLES); + gyroSetCalibrationCycles((CALIBRATING_GYRO_CYCLES / targetLooptime) * CALIBRATING_GYRO_CYCLES); #ifdef GPS if (feature(FEATURE_GPS)) { diff --git a/src/main/main.c b/src/main/main.c index d856a36ea9..e0c80f93b7 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -598,7 +598,7 @@ void init(void) if (masterConfig.mixerMode == MIXER_GIMBAL) { accSetCalibrationCycles(CALIBRATING_ACC_CYCLES); } - gyroSetCalibrationCycles(CALIBRATING_GYRO_CYCLES); + gyroSetCalibrationCycles((CALIBRATING_GYRO_CYCLES / targetLooptime) * CALIBRATING_GYRO_CYCLES); #ifdef BARO baroSetCalibrationCycles(CALIBRATING_BARO_CYCLES); #endif diff --git a/src/main/sensors/gyro.c b/src/main/sensors/gyro.c index 5fe75d2819..8249694135 100644 --- a/src/main/sensors/gyro.c +++ b/src/main/sensors/gyro.c @@ -79,7 +79,7 @@ bool isOnFinalGyroCalibrationCycle(void) bool isOnFirstGyroCalibrationCycle(void) { - return calibratingG == CALIBRATING_GYRO_CYCLES; + return calibratingG == (CALIBRATING_GYRO_CYCLES / targetLooptime) * CALIBRATING_GYRO_CYCLES; } static void performAcclerationCalibration(uint8_t gyroMovementCalibrationThreshold) @@ -108,10 +108,10 @@ static void performAcclerationCalibration(uint8_t gyroMovementCalibrationThresho float dev = devStandardDeviation(&var[axis]); // check deviation and startover in case the model was moved if (gyroMovementCalibrationThreshold && dev > gyroMovementCalibrationThreshold) { - gyroSetCalibrationCycles(CALIBRATING_GYRO_CYCLES); + gyroSetCalibrationCycles((CALIBRATING_GYRO_CYCLES / targetLooptime) * CALIBRATING_GYRO_CYCLES); return; } - gyroZero[axis] = (g[axis] + (CALIBRATING_GYRO_CYCLES / 2)) / CALIBRATING_GYRO_CYCLES; + gyroZero[axis] = (g[axis] + ((CALIBRATING_GYRO_CYCLES / targetLooptime) * CALIBRATING_GYRO_CYCLES / 2)) / (CALIBRATING_GYRO_CYCLES / targetLooptime) * CALIBRATING_GYRO_CYCLES; } } From 21bc85335e47b401facc9b76140d530c8680df1f Mon Sep 17 00:00:00 2001 From: borisbstyle Date: Wed, 9 Mar 2016 00:05:13 +0100 Subject: [PATCH 11/14] pidUpdateCountdown set based on condition --- src/main/mw.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/mw.c b/src/main/mw.c index 70396af390..d9ad9453bc 100644 --- a/src/main/mw.c +++ b/src/main/mw.c @@ -741,6 +741,14 @@ void taskMotorUpdate(void) { } } +uint8_t setPidUpdateCountDown(void) { + if (masterConfig.gyro_soft_lpf_hz) { + return masterConfig.pid_process_denom - 1; + } else { + return 1; + } +} + // Check for oneshot125 protection. With fast looptimes oneshot125 pulse duration gets more near the pid looptime bool shouldUpdateMotorsAfterPIDLoop(void) { if (targetPidLooptime > 375 ) { @@ -782,7 +790,7 @@ void taskMainPidLoopCheck(void) { if (pidUpdateCountdown) { pidUpdateCountdown--; } else { - pidUpdateCountdown = masterConfig.pid_process_denom - 1; + pidUpdateCountdown = setPidUpdateCountDown(); taskMainPidLoop(); if (shouldUpdateMotorsAfterPIDLoop()) taskMotorUpdate(); runTaskMainSubprocesses = true; From 03cc5fa4388ef21670e818b688e37aef90865723 Mon Sep 17 00:00:00 2001 From: borisbstyle Date: Wed, 9 Mar 2016 22:31:16 +0100 Subject: [PATCH 12/14] Function for calculating calibration cycles --- src/main/io/rc_controls.c | 2 +- src/main/main.c | 2 +- src/main/sensors/gyro.c | 10 +++++++--- src/main/sensors/gyro.h | 1 + 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/io/rc_controls.c b/src/main/io/rc_controls.c index 2a66bb19af..03a108d6f5 100644 --- a/src/main/io/rc_controls.c +++ b/src/main/io/rc_controls.c @@ -216,7 +216,7 @@ void processRcStickPositions(rxConfig_t *rxConfig, throttleStatus_e throttleStat if (rcSticks == THR_LO + YAW_LO + PIT_LO + ROL_CE) { // GYRO calibration - gyroSetCalibrationCycles((CALIBRATING_GYRO_CYCLES / targetLooptime) * CALIBRATING_GYRO_CYCLES); + gyroSetCalibrationCycles(calculateCalibratingCycles()); #ifdef GPS if (feature(FEATURE_GPS)) { diff --git a/src/main/main.c b/src/main/main.c index e0c80f93b7..f75dc570ef 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -598,7 +598,7 @@ void init(void) if (masterConfig.mixerMode == MIXER_GIMBAL) { accSetCalibrationCycles(CALIBRATING_ACC_CYCLES); } - gyroSetCalibrationCycles((CALIBRATING_GYRO_CYCLES / targetLooptime) * CALIBRATING_GYRO_CYCLES); + gyroSetCalibrationCycles(calculateCalibratingCycles()); #ifdef BARO baroSetCalibrationCycles(CALIBRATING_BARO_CYCLES); #endif diff --git a/src/main/sensors/gyro.c b/src/main/sensors/gyro.c index 8249694135..de34127604 100644 --- a/src/main/sensors/gyro.c +++ b/src/main/sensors/gyro.c @@ -77,9 +77,13 @@ bool isOnFinalGyroCalibrationCycle(void) return calibratingG == 1; } +uint16_t calculateCalibratingCycles(void) { + return (CALIBRATING_GYRO_CYCLES / targetLooptime) * CALIBRATING_GYRO_CYCLES; +} + bool isOnFirstGyroCalibrationCycle(void) { - return calibratingG == (CALIBRATING_GYRO_CYCLES / targetLooptime) * CALIBRATING_GYRO_CYCLES; + return calibratingG == calculateCalibratingCycles(); } static void performAcclerationCalibration(uint8_t gyroMovementCalibrationThreshold) @@ -108,10 +112,10 @@ static void performAcclerationCalibration(uint8_t gyroMovementCalibrationThresho float dev = devStandardDeviation(&var[axis]); // check deviation and startover in case the model was moved if (gyroMovementCalibrationThreshold && dev > gyroMovementCalibrationThreshold) { - gyroSetCalibrationCycles((CALIBRATING_GYRO_CYCLES / targetLooptime) * CALIBRATING_GYRO_CYCLES); + gyroSetCalibrationCycles(calculateCalibratingCycles()); return; } - gyroZero[axis] = (g[axis] + ((CALIBRATING_GYRO_CYCLES / targetLooptime) * CALIBRATING_GYRO_CYCLES / 2)) / (CALIBRATING_GYRO_CYCLES / targetLooptime) * CALIBRATING_GYRO_CYCLES; + gyroZero[axis] = (g[axis] + (calculateCalibratingCycles() / 2)) / calculateCalibratingCycles(); } } diff --git a/src/main/sensors/gyro.h b/src/main/sensors/gyro.h index bb7a152f06..48e5e677e2 100644 --- a/src/main/sensors/gyro.h +++ b/src/main/sensors/gyro.h @@ -43,4 +43,5 @@ void useGyroConfig(gyroConfig_t *gyroConfigToUse, float gyro_lpf_hz); void gyroSetCalibrationCycles(uint16_t calibrationCyclesRequired); void gyroUpdate(void); bool isGyroCalibrationComplete(void); +uint16_t calculateCalibratingCycles(void); From fa63ab52e148cd8cb03053085e638ddd0a492632 Mon Sep 17 00:00:00 2001 From: borisbstyle Date: Thu, 10 Mar 2016 00:27:44 +0100 Subject: [PATCH 13/14] Disabling of 3D Feature on switch --- .testThrottle.c.swp | Bin 0 -> 1024 bytes src/main/flight/mixer.c | 10 +++++----- src/main/io/rc_controls.h | 3 ++- src/main/io/rc_curves.c | 5 ++++- src/main/io/serial_msp.c | 3 ++- src/main/mw.c | 14 ++++++++++++-- src/main/version.h | 2 +- 7 files changed, 26 insertions(+), 11 deletions(-) create mode 100644 .testThrottle.c.swp diff --git a/.testThrottle.c.swp b/.testThrottle.c.swp new file mode 100644 index 0000000000000000000000000000000000000000..d53eb7fc58a9e35a883bcc6a29354427711bf836 GIT binary patch literal 1024 zcmYc?$V<%2S1{5u(KBK|0ylIR7?SdfGK-PKa4}0#i*hsb5=-)n%*@PiDFTY?=ccA) zChCKY)ptoONz_kCElbVGFUU>JE74C%ElEtv$xP2E(Jx6YE(ysf$}cI&N!3fnW8$dP PXb6mk00|)wimny_;r1ZO literal 0 HcmV?d00001 diff --git a/src/main/flight/mixer.c b/src/main/flight/mixer.c index 29c0ac41bd..f61c068eea 100755 --- a/src/main/flight/mixer.c +++ b/src/main/flight/mixer.c @@ -822,18 +822,18 @@ void mixTable(void) int16_t throttleMin, throttleMax; static int16_t throttlePrevious = 0; // Store the last throttle direction for deadband transitions - // Find min and max throttle based on condition. Use rcData for 3D to prevent loss of power due to min_check + // Find min and max throttle based on condition. if (feature(FEATURE_3D)) { if (!ARMING_FLAG(ARMED)) throttlePrevious = rxConfig->midrc; // When disarmed set to mid_rc. It always results in positive direction after arming. - if ((rcData[THROTTLE] <= (rxConfig->midrc - flight3DConfig->deadband3d_throttle))) { // Out of band handling + if ((rcCommand[THROTTLE] <= (rxConfig->midrc - flight3DConfig->deadband3d_throttle))) { // Out of band handling throttleMax = flight3DConfig->deadband3d_low; throttleMin = escAndServoConfig->minthrottle; - throttlePrevious = throttle = rcData[THROTTLE]; - } else if (rcData[THROTTLE] >= (rxConfig->midrc + flight3DConfig->deadband3d_throttle)) { // Positive handling + throttlePrevious = throttle = rcCommand[THROTTLE]; + } else if (rcCommand[THROTTLE] >= (rxConfig->midrc + flight3DConfig->deadband3d_throttle)) { // Positive handling throttleMax = escAndServoConfig->maxthrottle; throttleMin = flight3DConfig->deadband3d_high; - throttlePrevious = throttle = rcData[THROTTLE]; + throttlePrevious = throttle = rcCommand[THROTTLE]; } else if ((throttlePrevious <= (rxConfig->midrc - flight3DConfig->deadband3d_throttle))) { // Deadband handling from negative to positive throttle = throttleMax = flight3DConfig->deadband3d_low; throttleMin = escAndServoConfig->minthrottle; diff --git a/src/main/io/rc_controls.h b/src/main/io/rc_controls.h index 8cdc3c7750..c512ed64bb 100644 --- a/src/main/io/rc_controls.h +++ b/src/main/io/rc_controls.h @@ -49,7 +49,8 @@ typedef enum { BOXBLACKBOX, BOXFAILSAFE, BOXAIRMODE, - BOXACROPLUS, + BOXACROPLUS, + BOX3DDISABLESWITCH, CHECKBOX_ITEM_COUNT } boxId_e; diff --git a/src/main/io/rc_curves.c b/src/main/io/rc_curves.c index 80b0bd4aa7..e6abf1d86c 100644 --- a/src/main/io/rc_curves.c +++ b/src/main/io/rc_curves.c @@ -24,6 +24,8 @@ #include "io/rc_curves.h" +#include "config/config.h" + int16_t lookupPitchRollRC[PITCH_LOOKUP_LENGTH]; // lookup table for expo & RC rate PITCH+ROLL int16_t lookupYawRC[YAW_LOOKUP_LENGTH]; // lookup table for expo & RC rate YAW int16_t lookupThrottleRC[THROTTLE_LOOKUP_LENGTH]; // lookup table for expo & mid THROTTLE @@ -48,6 +50,7 @@ void generateYawCurve(controlRateConfig_t *controlRateConfig) void generateThrottleCurve(controlRateConfig_t *controlRateConfig, escAndServoConfig_t *escAndServoConfig) { uint8_t i; + uint16_t minThrottle = (feature(FEATURE_3D && IS_RC_MODE_ACTIVE(BOX3DDISABLESWITCH)) ? PWM_RANGE_MIN : escAndServoConfig->minthrottle); for (i = 0; i < THROTTLE_LOOKUP_LENGTH; i++) { int16_t tmp = 10 * i - controlRateConfig->thrMid8; @@ -57,6 +60,6 @@ void generateThrottleCurve(controlRateConfig_t *controlRateConfig, escAndServoCo if (tmp < 0) y = controlRateConfig->thrMid8; lookupThrottleRC[i] = 10 * controlRateConfig->thrMid8 + tmp * (100 - controlRateConfig->thrExpo8 + (int32_t) controlRateConfig->thrExpo8 * (tmp * tmp) / (y * y)) / 10; - lookupThrottleRC[i] = escAndServoConfig->minthrottle + (int32_t) (escAndServoConfig->maxthrottle - escAndServoConfig->minthrottle) * lookupThrottleRC[i] / 1000; // [MINTHROTTLE;MAXTHROTTLE] + lookupThrottleRC[i] = minThrottle + (int32_t) (escAndServoConfig->maxthrottle - minThrottle) * lookupThrottleRC[i] / 1000; // [MINTHROTTLE;MAXTHROTTLE] } } diff --git a/src/main/io/serial_msp.c b/src/main/io/serial_msp.c index 122f2e77b1..a2a09fabf9 100644 --- a/src/main/io/serial_msp.c +++ b/src/main/io/serial_msp.c @@ -217,6 +217,7 @@ static const box_t boxes[CHECKBOX_ITEM_COUNT + 1] = { { BOXFAILSAFE, "FAILSAFE;", 27 }, { BOXAIRMODE, "AIR MODE;", 28 }, { BOXACROPLUS, "ACRO PLUS;", 29 }, + { BOX3DDISABLESWITCH, "DISABLE 3D SWITCH;", 30}, { CHECKBOX_ITEM_COUNT, NULL, 0xFF } }; @@ -544,7 +545,7 @@ void mspInit(serialConfig_t *serialConfig) activeBoxIds[activeBoxIdCount++] = BOXAIRMODE; activeBoxIds[activeBoxIdCount++] = BOXACROPLUS; - + activeBoxIds[activeBoxIdCount++] = BOX3DDISABLESWITCH; if (sensors(SENSOR_BARO)) { activeBoxIds[activeBoxIdCount++] = BOXBARO; diff --git a/src/main/mw.c b/src/main/mw.c index d9ad9453bc..2c8dad31a0 100644 --- a/src/main/mw.c +++ b/src/main/mw.c @@ -270,11 +270,21 @@ void annexCode(void) rcCommand[axis] = -rcCommand[axis]; } - tmp = constrain(rcData[THROTTLE], masterConfig.rxConfig.mincheck, PWM_RANGE_MAX); - tmp = (uint32_t)(tmp - masterConfig.rxConfig.mincheck) * PWM_RANGE_MIN / (PWM_RANGE_MAX - masterConfig.rxConfig.mincheck); + if (feature(FEATURE_3D)) { + tmp = constrain(rcData[THROTTLE], PWM_RANGE_MIN, PWM_RANGE_MAX); + tmp = (uint32_t)(tmp - PWM_RANGE_MIN); + } else { + tmp = constrain(rcData[THROTTLE], masterConfig.rxConfig.mincheck, PWM_RANGE_MAX); + tmp = (uint32_t)(tmp - masterConfig.rxConfig.mincheck) * PWM_RANGE_MIN / (PWM_RANGE_MAX - masterConfig.rxConfig.mincheck); + } tmp2 = tmp / 100; rcCommand[THROTTLE] = lookupThrottleRC[tmp2] + (tmp - tmp2 * 100) * (lookupThrottleRC[tmp2 + 1] - lookupThrottleRC[tmp2]) / 100; // [0;1000] -> expo -> [MINTHROTTLE;MAXTHROTTLE] + if (IS_RC_MODE_ACTIVE(BOX3DDISABLESWITCH) && !failsafeIsActive()) { + fix12_t throttleScaler = qConstruct(rcCommand[THROTTLE] - 1000, 1000); + rcCommand[THROTTLE] = masterConfig.rxConfig.midrc + qMultiply(throttleScaler, PWM_RANGE_MAX - masterConfig.rxConfig.midrc); + } + if (FLIGHT_MODE(HEADFREE_MODE)) { float radDiff = degreesToRadians(DECIDEGREES_TO_DEGREES(attitude.values.yaw) - headFreeModeHold); float cosDiff = cos_approx(radDiff); diff --git a/src/main/version.h b/src/main/version.h index f2581c2eca..65e7dc436e 100644 --- a/src/main/version.h +++ b/src/main/version.h @@ -17,7 +17,7 @@ #define FC_VERSION_MAJOR 2 // increment when a major release is made (big new feature, etc) #define FC_VERSION_MINOR 5 // increment when a minor release is made (small new feature, change etc) -#define FC_VERSION_PATCH_LEVEL 3 // increment when a bug is fixed +#define FC_VERSION_PATCH_LEVEL 4 // increment when a bug is fixed #define STR_HELPER(x) #x #define STR(x) STR_HELPER(x) From 1e8f2bacb871dac9630698f3641b71301d838bab Mon Sep 17 00:00:00 2001 From: borisbstyle Date: Thu, 10 Mar 2016 00:35:19 +0100 Subject: [PATCH 14/14] Oops only 3D Mode needs this --- src/main/mw.c | 2 +- testThrottle.c.save | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 testThrottle.c.save diff --git a/src/main/mw.c b/src/main/mw.c index 2c8dad31a0..d8e2f30820 100644 --- a/src/main/mw.c +++ b/src/main/mw.c @@ -280,7 +280,7 @@ void annexCode(void) tmp2 = tmp / 100; rcCommand[THROTTLE] = lookupThrottleRC[tmp2] + (tmp - tmp2 * 100) * (lookupThrottleRC[tmp2 + 1] - lookupThrottleRC[tmp2]) / 100; // [0;1000] -> expo -> [MINTHROTTLE;MAXTHROTTLE] - if (IS_RC_MODE_ACTIVE(BOX3DDISABLESWITCH) && !failsafeIsActive()) { + if (feature(FEATURE_3D) && IS_RC_MODE_ACTIVE(BOX3DDISABLESWITCH) && !failsafeIsActive()) { fix12_t throttleScaler = qConstruct(rcCommand[THROTTLE] - 1000, 1000); rcCommand[THROTTLE] = masterConfig.rxConfig.midrc + qMultiply(throttleScaler, PWM_RANGE_MAX - masterConfig.rxConfig.midrc); } diff --git a/testThrottle.c.save b/testThrottle.c.save new file mode 100644 index 0000000000..51cab990bc --- /dev/null +++ b/testThrottle.c.save @@ -0,0 +1,5 @@ +#include "stdint.h" +#include "stdio.h" + + +int main()