diff --git a/docs/Settings.md b/docs/Settings.md index ec328afa938..2c350cac643 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -103,7 +103,6 @@ | failsafe_throttle_low_delay | 0 | 0 | 300 | If failsafe activated when throttle is low for this much time - bypass failsafe and disarm, in 10th of seconds. 0 = No timeout | | fixed_wing_auto_arm | OFF | | | Auto-arm fixed wing aircraft on throttle above min_check, and disarming with stick commands are disabled, so power cycle is required to disarm. Requires enabled motorstop and no arm switch configured. | | flaperon_throw_offset | 200 | FLAPERON_THROW_MIN | FLAPERON_THROW_MAX | Defines throw range in us for both ailerons that will be passed to servo mixer via input source 14 (`FEATURE FLAPS`) when FLAPERON mode is activated. | -| flip_over_after_crash_power_factor | 65 | 0 | 100 | flip over after crash power factor | | fpv_mix_degrees | 0 | 0 | 50 | | | frsky_coordinates_format | 0 | 0 | FRSKY_FORMAT_NMEA | D-Series telemetry only: FRSKY_FORMAT_DMS (default), FRSKY_FORMAT_NMEA | | frsky_default_latitude | 0 | -90 | 90 | D-Series telemetry only: OpenTX needs a valid set of coordinates to show compass value. A fake value defined in this setting is sent while no fix is acquired. | @@ -517,6 +516,7 @@ | tpa_breakpoint | 1500 | PWM_RANGE_MIN | PWM_RANGE_MAX | See tpa_rate. | | tpa_rate | 0 | 0 | 100 | Throttle PID attenuation reduces influence of P on ROLL and PITCH as throttle increases. For every 1% throttle after the TPA breakpoint, P is reduced by the TPA rate. | | tri_unarmed_servo | ON | | | On tricopter mix only, if this is set to ON, servo will always be correcting regardless of armed state. to disable this, set it to OFF. | +| turtle_mode_power_factor | 55 | 0 | 100 | Turtle mode power factor | | tz_automatic_dst | OFF | | | Automatically add Daylight Saving Time to the GPS time when needed or simply ignore it. Includes presets for EU and the USA - if you live outside these areas it is suggested to manage DST manually via `tz_offset`. | | tz_offset | 0 | -1440 | 1440 | Time zone offset from UTC, in minutes. This is applied to the GPS time for logging and time-stamping of Blackbox logs | | vbat_adc_channel | _target default_ | ADC_CHN_NONE | ADC_CHN_MAX | ADC channel to use for battery voltage sensor. Defaults to board VBAT input (if available). 0 = disabled | diff --git a/src/main/fc/fc_core.c b/src/main/fc/fc_core.c index d6a6019fc64..025dfef050b 100755 --- a/src/main/fc/fc_core.c +++ b/src/main/fc/fc_core.c @@ -419,9 +419,9 @@ void disarm(disarmReason_t disarmReason) } #endif #ifdef USE_DSHOT - if (FLIGHT_MODE(FLIP_OVER_AFTER_CRASH)) { + if (FLIGHT_MODE(TURTLE_MODE)) { sendDShotCommand(DSHOT_CMD_SPIN_DIRECTION_NORMAL); - DISABLE_FLIGHT_MODE(FLIP_OVER_AFTER_CRASH); + DISABLE_FLIGHT_MODE(TURTLE_MODE); } #endif statsOnDisarm(); @@ -493,15 +493,31 @@ void tryArm(void) { updateArmingStatus(); +#ifdef USE_DSHOT + if ( + STATE(MULTIROTOR) && + IS_RC_MODE_ACTIVE(BOXTURTLE) && + emergencyArmingCanOverrideArmingDisabled() && + isMotorProtocolDshot() && + !ARMING_FLAG(ARMED) && + !FLIGHT_MODE(TURTLE_MODE) + ) { + sendDShotCommand(DSHOT_CMD_SPIN_DIRECTION_REVERSED); + ENABLE_ARMING_FLAG(ARMED); + enableFlightMode(TURTLE_MODE); + return; + } +#endif + #ifdef USE_PROGRAMMING_FRAMEWORK if ( - !isArmingDisabled() || - emergencyArmingIsEnabled() || + !isArmingDisabled() || + emergencyArmingIsEnabled() || LOGIC_CONDITION_GLOBAL_FLAG(LOGIC_CONDITION_GLOBAL_FLAG_OVERRIDE_ARMING_SAFETY) ) { -#else +#else if ( - !isArmingDisabled() || + !isArmingDisabled() || emergencyArmingIsEnabled() ) { #endif @@ -509,21 +525,6 @@ void tryArm(void) return; } -#ifdef USE_DSHOT - if ( - STATE(MULTIROTOR) && - IS_RC_MODE_ACTIVE(BOXFLIPOVERAFTERCRASH) && - emergencyArmingCanOverrideArmingDisabled() && - isMotorProtocolDshot() && - !FLIGHT_MODE(FLIP_OVER_AFTER_CRASH) - ) { - sendDShotCommand(DSHOT_CMD_SPIN_DIRECTION_REVERSED); - ENABLE_ARMING_FLAG(ARMED); - enableFlightMode(FLIP_OVER_AFTER_CRASH); - return; - } -#endif - #if defined(USE_NAV) // If nav_extra_arming_safety was bypassed we always // allow bypassing it even without the sticks set diff --git a/src/main/fc/fc_msp_box.c b/src/main/fc/fc_msp_box.c index 65bf1de1cc3..9ba7e4a0f49 100644 --- a/src/main/fc/fc_msp_box.c +++ b/src/main/fc/fc_msp_box.c @@ -89,7 +89,7 @@ static const box_t boxes[CHECKBOX_ITEM_COUNT + 1] = { { BOXLOITERDIRCHN, "LOITER CHANGE", 49 }, { BOXMSPRCOVERRIDE, "MSP RC OVERRIDE", 50 }, { BOXPREARM, "PREARM", 51 }, - { BOXFLIPOVERAFTERCRASH, "TURTLE", 52 }, + { BOXTURTLE, "TURTLE", 52 }, { CHECKBOX_ITEM_COUNT, NULL, 0xFF } }; @@ -312,7 +312,7 @@ void initActiveBoxIds(void) #ifdef USE_DSHOT if(STATE(MULTIROTOR) && isMotorProtocolDshot()) - activeBoxIds[activeBoxIdCount++] = BOXFLIPOVERAFTERCRASH; + activeBoxIds[activeBoxIdCount++] = BOXTURTLE; #endif } diff --git a/src/main/fc/rc_modes.h b/src/main/fc/rc_modes.h index 6b3f877197c..4a840a4d3a7 100755 --- a/src/main/fc/rc_modes.h +++ b/src/main/fc/rc_modes.h @@ -69,7 +69,7 @@ typedef enum { BOXLOITERDIRCHN = 40, BOXMSPRCOVERRIDE = 41, BOXPREARM = 42, - BOXFLIPOVERAFTERCRASH = 43, + BOXTURTLE = 43, CHECKBOX_ITEM_COUNT } boxId_e; diff --git a/src/main/fc/runtime_config.h b/src/main/fc/runtime_config.h index 84fe113c59a..55f3c3df560 100644 --- a/src/main/fc/runtime_config.h +++ b/src/main/fc/runtime_config.h @@ -98,7 +98,7 @@ typedef enum { NAV_COURSE_HOLD_MODE = (1 << 12), FLAPERON = (1 << 13), TURN_ASSISTANT = (1 << 14), - FLIP_OVER_AFTER_CRASH = (1 << 15), + TURTLE_MODE = (1 << 15), } flightModeFlags_e; extern uint32_t flightModeFlags; diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index c40ca0d1cbc..713994820d6 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -847,10 +847,10 @@ groups: min: 4 max: 255 default_value: 14 - - name: flip_over_after_crash_power_factor - field: flipOverAfterPowerFactor - default_value: 65 - description: "flip over after crash power factor" + - name: turtle_mode_power_factor + field: turtleModePowerFactor + default_value: 55 + description: "Turtle mode power factor" condition: "USE_DSHOT" min: 0 max: 100 diff --git a/src/main/flight/mixer.c b/src/main/flight/mixer.c index cc9f6b2bcc2..2ee79621f08 100755 --- a/src/main/flight/mixer.c +++ b/src/main/flight/mixer.c @@ -116,13 +116,12 @@ PG_RESET_TEMPLATE(motorConfig_t, motorConfig, .throttleScale = SETTING_THROTTLE_SCALE_DEFAULT, .motorPoleCount = SETTING_MOTOR_POLES_DEFAULT, // Most brushless motors that we use are 14 poles #ifdef USE_DSHOT - .flipOverAfterPowerFactor = SETTING_FLIP_OVER_AFTER_CRASH_POWER_FACTOR_DEFAULT, + .turtleModePowerFactor = SETTING_TURTLE_MODE_POWER_FACTOR_DEFAULT, #endif ); PG_REGISTER_ARRAY(motorMixer_t, MAX_SUPPORTED_MOTORS, primaryMotorMixer, PG_MOTOR_MIXER, 0); -#define CRASH_OVER_AFTER_CRASH_FLIP_DEADBAND 20.0f #define CRASH_OVER_AFTER_CRASH_FLIP_STICK_MIN 0.15f typedef void (*motorRateLimitingApplyFnPtr)(const float dT); @@ -328,10 +327,10 @@ static uint16_t handleOutputScaling( } return value; } -static void applyFlipOverAfterCrashModeToMotors(void) { +static void applyTurtleModeToMotors(void) { if (ARMING_FLAG(ARMED)) { - const float flipPowerFactor = ((float)motorConfig()->flipOverAfterPowerFactor)/100.0f; + const float flipPowerFactor = ((float)motorConfig()->turtleModePowerFactor)/100.0f; const float stickDeflectionPitchAbs = ABS(((float) rcCommand[PITCH]) / 500.0f); const float stickDeflectionRollAbs = ABS(((float) rcCommand[ROLL]) / 500.0f); const float stickDeflectionYawAbs = ABS(((float) rcCommand[YAW]) / 500.0f); @@ -394,13 +393,7 @@ static void applyFlipOverAfterCrashModeToMotors(void) { motorOutputNormalised = MIN(1.0f, flipPower * motorOutputNormalised); - float motorOutput = (float)motorConfig()->mincommand + motorOutputNormalised * (float)motorConfig()->maxthrottle; - - // Add a little bit to the motorOutputMin so props aren't spinning when sticks are centered - motorOutput = (motorOutput < (float)motorConfig()->mincommand + CRASH_OVER_AFTER_CRASH_FLIP_DEADBAND) ? DSHOT_DISARM_COMMAND : ( - motorOutput - CRASH_OVER_AFTER_CRASH_FLIP_DEADBAND); - - motor[i] = motorOutput; + motor[i] = (int16_t)scaleRangef(motorOutputNormalised, 0, 1, motorConfig()->mincommand, motorConfig()->maxthrottle); } } else { // Disarmed mode @@ -532,8 +525,8 @@ static int getReversibleMotorsThrottleDeadband(void) void FAST_CODE mixTable(const float dT) { #ifdef USE_DSHOT - if (FLIGHT_MODE(FLIP_OVER_AFTER_CRASH)) { - applyFlipOverAfterCrashModeToMotors(); + if (FLIGHT_MODE(TURTLE_MODE)) { + applyTurtleModeToMotors(); return; } #endif diff --git a/src/main/flight/mixer.h b/src/main/flight/mixer.h index 4d79d9f291c..6dcb5138350 100644 --- a/src/main/flight/mixer.h +++ b/src/main/flight/mixer.h @@ -87,7 +87,7 @@ typedef struct motorConfig_s { float throttleIdle; // Throttle IDLE value based on min_command, max_throttle, in percent float throttleScale; // Scaling factor for throttle. uint8_t motorPoleCount; // Magnetic poles in the motors for calculating actual RPM from eRPM provided by ESC telemetry - uint8_t flipOverAfterPowerFactor; // Power factor from 0 to 100% of flip over after crash + uint8_t turtleModePowerFactor; // Power factor from 0 to 100% of flip over after crash } motorConfig_t; PG_DECLARE(motorConfig_t, motorConfig); diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 7302ee568ff..b6aaf1e0b10 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -1709,6 +1709,8 @@ static bool osdDrawSingleElement(uint8_t item) p = "!FS!"; else if (FLIGHT_MODE(MANUAL_MODE)) p = "MANU"; + else if (FLIGHT_MODE(TURTLE_MODE)) + p = "TURT"; else if (FLIGHT_MODE(NAV_RTH_MODE)) p = "RTH "; else if (FLIGHT_MODE(NAV_POSHOLD_MODE)) @@ -1729,8 +1731,6 @@ static bool osdDrawSingleElement(uint8_t item) p = "ANGL"; else if (FLIGHT_MODE(HORIZON_MODE)) p = "HOR "; - else if (FLIGHT_MODE(FLIP_OVER_AFTER_CRASH)) - p = "TURT"; displayWrite(osdDisplayPort, elemPosX, elemPosY, p); return true;