From 369fafdabcf5b9470653d94184dfff4162e56d89 Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Mon, 25 Jul 2022 22:28:03 +0100 Subject: [PATCH 001/241] Initial cut --- docs/Settings.md | 10 ++++++++++ src/main/fc/settings.yaml | 5 +++++ src/main/navigation/navigation.c | 1 + src/main/navigation/navigation.h | 1 + src/main/navigation/navigation_fw_launch.c | 14 +++++++++++++- 5 files changed, 30 insertions(+), 1 deletion(-) diff --git a/docs/Settings.md b/docs/Settings.md index 8966d74d828..9731c1fa48c 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -3032,6 +3032,16 @@ Launch idle throttle - throttle to be set before launch sequence is initiated. I --- +### nav_fw_launch_jerk_wake_idle + +Trigger the idle throttle by jerking the plane + +| Default | Min | Max | +| --- | --- | --- | +| OFF | OFF | ON | + +--- + ### nav_fw_launch_manual_throttle Allows launch with manually controlled throttle. INAV only levels wings and controls climb pitch during launch. Throttle is controlled directly by throttle stick movement. IF USED WITHOUT A GPS LOCK plane must be launched immediately after throttle is increased to avoid issues with climb out stabilisation and the launch ending sooner than expected (launch end timer starts as soon as the throttle stick is raised). diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index ae5d7d04ead..4e1800822f0 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -2797,6 +2797,11 @@ groups: field: fw.launch_idle_motor_timer min: 0 max: 60000 + - name: nav_fw_launch_jerk_wake_idle + description: "Trigger the idle throttle by jerking the plane" + field: fw.launch_jerk_wake_idle + type: bool + default_value: OFF - name: nav_fw_launch_motor_delay description: "Delay between detected launch and launch sequence start and throttling up (ms)" default_value: 500 diff --git a/src/main/navigation/navigation.c b/src/main/navigation/navigation.c index 56912d4b234..e6e8e189e77 100644 --- a/src/main/navigation/navigation.c +++ b/src/main/navigation/navigation.c @@ -196,6 +196,7 @@ PG_RESET_TEMPLATE(navConfig_t, navConfig, .launch_time_thresh = SETTING_NAV_FW_LAUNCH_DETECT_TIME_DEFAULT, // 40ms .launch_motor_timer = SETTING_NAV_FW_LAUNCH_MOTOR_DELAY_DEFAULT, // ms .launch_idle_motor_timer = SETTING_NAV_FW_LAUNCH_IDLE_MOTOR_DELAY_DEFAULT, // ms + .launch_jerk_wake_idle = SETTING_NAV_FW_LAUNCH_JERK_WAKE_IDLE_DEFAULT, // bool .launch_motor_spinup_time = SETTING_NAV_FW_LAUNCH_SPINUP_TIME_DEFAULT, // ms, time to gredually increase throttle from idle to launch .launch_end_time = SETTING_NAV_FW_LAUNCH_END_TIME_DEFAULT, // ms, time to gradually decrease/increase throttle and decrease pitch angle from launch to the current flight mode .launch_min_time = SETTING_NAV_FW_LAUNCH_MIN_TIME_DEFAULT, // ms, min time in launch mode diff --git a/src/main/navigation/navigation.h b/src/main/navigation/navigation.h index 21eda4a37c6..08cb2b1c463 100644 --- a/src/main/navigation/navigation.h +++ b/src/main/navigation/navigation.h @@ -294,6 +294,7 @@ typedef struct navConfig_s { uint16_t launch_time_thresh; // Time threshold for launch detection (ms) uint16_t launch_motor_timer; // Time to wait before setting launch_throttle (ms) uint16_t launch_idle_motor_timer; // Time to wait before motor starts at_idle throttle (ms) + bool launch_jerk_wake_idle; // Activate the idle throttle by jerking the plane uint16_t launch_motor_spinup_time; // Time to speed-up motors from idle to launch_throttle (ESC desync prevention) uint16_t launch_end_time; // Time to make the transition from launch angle to leveled and throttle transition from launch throttle to the stick position uint16_t launch_min_time; // Minimum time in launch mode to prevent possible bump of the sticks from leaving launch mode early diff --git a/src/main/navigation/navigation_fw_launch.c b/src/main/navigation/navigation_fw_launch.c index 1515f460042..5b8a1e7d666 100644 --- a/src/main/navigation/navigation_fw_launch.c +++ b/src/main/navigation/navigation_fw_launch.c @@ -312,16 +312,28 @@ static fixedWingLaunchEvent_t fwLaunchState_FW_LAUNCH_STATE_WAIT_THROTTLE(timeUs static fixedWingLaunchEvent_t fwLaunchState_FW_LAUNCH_STATE_IDLE_MOTOR_DELAY(timeUs_t currentTimeUs) { + bool isIdleJerkActivationTriggered = false; + if (isThrottleLow()) { return FW_LAUNCH_EVENT_THROTTLE_LOW; // go back to FW_LAUNCH_STATE_WAIT_THROTTLE } applyThrottleIdleLogic(true); - if (currentStateElapsedMs(currentTimeUs) > navConfig()->fw.launch_idle_motor_timer) { + // Check to see if the plane has been jerked. If so, wake the idle throttle now + if (navConfig()->fw.launch_jerk_wake_idle) { + const float preIdleSwingVelocity = (fabsf(imuMeasuredRotationBF.z) > SWING_LAUNCH_MIN_ROTATION_RATE) ? (imuMeasuredAccelBF.y / imuMeasuredRotationBF.z) : 0; + const bool isPreIdleSwingLaunched = (preIdleSwingVelocity > navConfig()->fw.launch_velocity_thresh) && (imuMeasuredAccelBF.x > 0); + const bool isPreIdleForwardAccelerationHigh = (imuMeasuredAccelBF.x > navConfig()->fw.launch_accel_thresh); + + isIdleJerkActivationTriggered = (isPreIdleSwingLaunched || isPreIdleForwardAccelerationHigh); + } + + if ((currentStateElapsedMs(currentTimeUs) > navConfig()->fw.launch_idle_motor_timer) || isIdleJerkActivationTriggered) { idleMotorAboutToStart = false; return FW_LAUNCH_EVENT_SUCCESS; } + // 5 second warning motor about to start at idle, changes Beeper sound idleMotorAboutToStart = navConfig()->fw.launch_idle_motor_timer - currentStateElapsedMs(currentTimeUs) < 5000; From 92d51edc5e4533de79ad65b7c7c105f675a11f26 Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Fri, 29 Jul 2022 15:45:48 +0100 Subject: [PATCH 002/241] FW launch: Wiggle to wake idle throttle - Added options for detection for different type/size planes - Changed trigger to only use the yaw axis gyro data. - Time limit for individual wiggle to prevent accidental triggers - Time limit for double wiggle, again to prevent accidental triggers. --- docs/Settings.md | 24 +++--- src/main/fc/settings.yaml | 16 ++-- src/main/navigation/navigation.c | 48 +++++------ src/main/navigation/navigation.h | 8 +- src/main/navigation/navigation_fw_launch.c | 92 ++++++++++++++++++---- 5 files changed, 126 insertions(+), 62 deletions(-) diff --git a/docs/Settings.md b/docs/Settings.md index 9731c1fa48c..eec9b274981 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -2974,11 +2974,11 @@ Launch abort stick deadband in [r/c points], applied after r/c deadband and expo ### nav_fw_launch_accel -Forward acceleration threshold for bungee launch of throw launch [cm/s/s], 1G = 981 cm/s/s +Forward acceleration threshold for bungee launch or throw launch [cm/s/s], 1G = 981 cm/s/s | Default | Min | Max | | --- | --- | --- | -| 1863 | 1000 | 20000 | +| 1863 | 1500 | 20000 | --- @@ -3032,16 +3032,6 @@ Launch idle throttle - throttle to be set before launch sequence is initiated. I --- -### nav_fw_launch_jerk_wake_idle - -Trigger the idle throttle by jerking the plane - -| Default | Min | Max | -| --- | --- | --- | -| OFF | OFF | ON | - ---- - ### nav_fw_launch_manual_throttle Allows launch with manually controlled throttle. INAV only levels wings and controls climb pitch during launch. Throttle is controlled directly by throttle stick movement. IF USED WITHOUT A GPS LOCK plane must be launched immediately after throttle is increased to avoid issues with climb out stabilisation and the launch ending sooner than expected (launch end timer starts as soon as the throttle stick is raised). @@ -3132,6 +3122,16 @@ Forward velocity threshold for swing-launch detection [cm/s] --- +### nav_fw_launch_wiggle_to_wake_idle + +Trigger the idle throttle by wiggling the plane. 0 = disabled. 1 and 2 signify 1 or 2 yaw wiggles to activate. 1 wiggle has a higher detection point, for airplanes without a tail. 2 wiggles has a lower detection point, but requires the repeated action. This is intended for larger models and airplanes with tails. + +| Default | Min | Max | +| --- | --- | --- | +| 0 | 0 | 2 | + +--- + ### nav_fw_loiter_radius PosHold radius. 3000 to 7500 is a good value (30-75m) [cm] diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index 4e1800822f0..cf95a162d20 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -2774,10 +2774,10 @@ groups: min: 100 max: 10000 - name: nav_fw_launch_accel - description: "Forward acceleration threshold for bungee launch of throw launch [cm/s/s], 1G = 981 cm/s/s" + description: "Forward acceleration threshold for bungee launch or throw launch [cm/s/s], 1G = 981 cm/s/s" default_value: 1863 field: fw.launch_accel_thresh - min: 1000 + min: 1500 max: 20000 - name: nav_fw_launch_max_angle description: "Max tilt angle (pitch/roll combined) to consider launch successful. Set to 180 to disable completely [deg]" @@ -2797,11 +2797,13 @@ groups: field: fw.launch_idle_motor_timer min: 0 max: 60000 - - name: nav_fw_launch_jerk_wake_idle - description: "Trigger the idle throttle by jerking the plane" - field: fw.launch_jerk_wake_idle - type: bool - default_value: OFF + - name: nav_fw_launch_wiggle_to_wake_idle + description: "Trigger the idle throttle by wiggling the plane. 0 = disabled. 1 and 2 signify 1 or 2 yaw wiggles to activate. 1 wiggle has a higher detection point, for airplanes without a tail. 2 wiggles has a lower detection point, but requires the repeated action. This is intended for larger models and airplanes with tails." + field: fw.launch_wiggle_wake_idle + type: uint8_t + default_value: 0 + min: 0 + max: 2 - name: nav_fw_launch_motor_delay description: "Delay between detected launch and launch sequence start and throttling up (ms)" default_value: 500 diff --git a/src/main/navigation/navigation.c b/src/main/navigation/navigation.c index e6e8e189e77..b0ceb77de48 100644 --- a/src/main/navigation/navigation.c +++ b/src/main/navigation/navigation.c @@ -178,40 +178,40 @@ PG_RESET_TEMPLATE(navConfig_t, navConfig, // Fixed wing .fw = { - .max_bank_angle = SETTING_NAV_FW_BANK_ANGLE_DEFAULT, // degrees - .max_climb_angle = SETTING_NAV_FW_CLIMB_ANGLE_DEFAULT, // degrees - .max_dive_angle = SETTING_NAV_FW_DIVE_ANGLE_DEFAULT, // degrees - .cruise_speed = SETTING_NAV_FW_CRUISE_SPEED_DEFAULT, // cm/s + .max_bank_angle = SETTING_NAV_FW_BANK_ANGLE_DEFAULT, // degrees + .max_climb_angle = SETTING_NAV_FW_CLIMB_ANGLE_DEFAULT, // degrees + .max_dive_angle = SETTING_NAV_FW_DIVE_ANGLE_DEFAULT, // degrees + .cruise_speed = SETTING_NAV_FW_CRUISE_SPEED_DEFAULT, // cm/s .control_smoothness = SETTING_NAV_FW_CONTROL_SMOOTHNESS_DEFAULT, .pitch_to_throttle_smooth = SETTING_NAV_FW_PITCH2THR_SMOOTHING_DEFAULT, .pitch_to_throttle_thresh = SETTING_NAV_FW_PITCH2THR_THRESHOLD_DEFAULT, - .loiter_radius = SETTING_NAV_FW_LOITER_RADIUS_DEFAULT, // 75m + .loiter_radius = SETTING_NAV_FW_LOITER_RADIUS_DEFAULT, // 75m //Fixed wing landing - .land_dive_angle = SETTING_NAV_FW_LAND_DIVE_ANGLE_DEFAULT, // 2 degrees dive by default + .land_dive_angle = SETTING_NAV_FW_LAND_DIVE_ANGLE_DEFAULT, // 2 degrees dive by default // Fixed wing launch - .launch_velocity_thresh = SETTING_NAV_FW_LAUNCH_VELOCITY_DEFAULT, // 3 m/s - .launch_accel_thresh = SETTING_NAV_FW_LAUNCH_ACCEL_DEFAULT, // cm/s/s (1.9*G) - .launch_time_thresh = SETTING_NAV_FW_LAUNCH_DETECT_TIME_DEFAULT, // 40ms - .launch_motor_timer = SETTING_NAV_FW_LAUNCH_MOTOR_DELAY_DEFAULT, // ms - .launch_idle_motor_timer = SETTING_NAV_FW_LAUNCH_IDLE_MOTOR_DELAY_DEFAULT, // ms - .launch_jerk_wake_idle = SETTING_NAV_FW_LAUNCH_JERK_WAKE_IDLE_DEFAULT, // bool - .launch_motor_spinup_time = SETTING_NAV_FW_LAUNCH_SPINUP_TIME_DEFAULT, // ms, time to gredually increase throttle from idle to launch - .launch_end_time = SETTING_NAV_FW_LAUNCH_END_TIME_DEFAULT, // ms, time to gradually decrease/increase throttle and decrease pitch angle from launch to the current flight mode - .launch_min_time = SETTING_NAV_FW_LAUNCH_MIN_TIME_DEFAULT, // ms, min time in launch mode - .launch_timeout = SETTING_NAV_FW_LAUNCH_TIMEOUT_DEFAULT, // ms, timeout for launch procedure - .launch_max_altitude = SETTING_NAV_FW_LAUNCH_MAX_ALTITUDE_DEFAULT, // cm, altitude where to consider launch ended - .launch_climb_angle = SETTING_NAV_FW_LAUNCH_CLIMB_ANGLE_DEFAULT, // 18 degrees - .launch_max_angle = SETTING_NAV_FW_LAUNCH_MAX_ANGLE_DEFAULT, // 45 deg - .launch_manual_throttle = SETTING_NAV_FW_LAUNCH_MANUAL_THROTTLE_DEFAULT,// OFF - .launch_abort_deadband = SETTING_NAV_FW_LAUNCH_ABORT_DEADBAND_DEFAULT, // 100 us - .cruise_yaw_rate = SETTING_NAV_FW_CRUISE_YAW_RATE_DEFAULT, // 20dps + .launch_velocity_thresh = SETTING_NAV_FW_LAUNCH_VELOCITY_DEFAULT, // 3 m/s + .launch_accel_thresh = SETTING_NAV_FW_LAUNCH_ACCEL_DEFAULT, // cm/s/s (1.9*G) + .launch_time_thresh = SETTING_NAV_FW_LAUNCH_DETECT_TIME_DEFAULT, // 40ms + .launch_motor_timer = SETTING_NAV_FW_LAUNCH_MOTOR_DELAY_DEFAULT, // ms + .launch_idle_motor_timer = SETTING_NAV_FW_LAUNCH_IDLE_MOTOR_DELAY_DEFAULT, // ms + .launch_wiggle_wake_idle = SETTING_NAV_FW_LAUNCH_WIGGLE_TO_WAKE_IDLE_DEFAULT, // uint8_t + .launch_motor_spinup_time = SETTING_NAV_FW_LAUNCH_SPINUP_TIME_DEFAULT, // ms, time to gredually increase throttle from idle to launch + .launch_end_time = SETTING_NAV_FW_LAUNCH_END_TIME_DEFAULT, // ms, time to gradually decrease/increase throttle and decrease pitch angle from launch to the current flight mode + .launch_min_time = SETTING_NAV_FW_LAUNCH_MIN_TIME_DEFAULT, // ms, min time in launch mode + .launch_timeout = SETTING_NAV_FW_LAUNCH_TIMEOUT_DEFAULT, // ms, timeout for launch procedure + .launch_max_altitude = SETTING_NAV_FW_LAUNCH_MAX_ALTITUDE_DEFAULT, // cm, altitude where to consider launch ended + .launch_climb_angle = SETTING_NAV_FW_LAUNCH_CLIMB_ANGLE_DEFAULT, // 18 degrees + .launch_max_angle = SETTING_NAV_FW_LAUNCH_MAX_ANGLE_DEFAULT, // 45 deg + .launch_manual_throttle = SETTING_NAV_FW_LAUNCH_MANUAL_THROTTLE_DEFAULT, // OFF + .launch_abort_deadband = SETTING_NAV_FW_LAUNCH_ABORT_DEADBAND_DEFAULT, // 100 us + .cruise_yaw_rate = SETTING_NAV_FW_CRUISE_YAW_RATE_DEFAULT, // 20dps .allow_manual_thr_increase = SETTING_NAV_FW_ALLOW_MANUAL_THR_INCREASE_DEFAULT, .useFwNavYawControl = SETTING_NAV_USE_FW_YAW_CONTROL_DEFAULT, .yawControlDeadband = SETTING_NAV_FW_YAW_DEADBAND_DEFAULT, - .soaring_pitch_deadband = SETTING_NAV_FW_SOARING_PITCH_DEADBAND_DEFAULT,// pitch angle mode deadband when Saoring mode enabled - .auto_disarm_delay = SETTING_NAV_FW_AUTO_DISARM_DELAY_DEFAULT, // ms - time delay to disarm when auto disarm after landing enabled + .soaring_pitch_deadband = SETTING_NAV_FW_SOARING_PITCH_DEADBAND_DEFAULT, // pitch angle mode deadband when Saoring mode enabled + .auto_disarm_delay = SETTING_NAV_FW_AUTO_DISARM_DELAY_DEFAULT, // ms - time delay to disarm when auto disarm after landing enabled } ); diff --git a/src/main/navigation/navigation.h b/src/main/navigation/navigation.h index 08cb2b1c463..412c025fe17 100644 --- a/src/main/navigation/navigation.h +++ b/src/main/navigation/navigation.h @@ -145,9 +145,9 @@ typedef enum { } navRTHClimbFirst_e; typedef enum { // keep aligned with fixedWingLaunchState_t - FW_LAUNCH_DETECTED = 4, - FW_LAUNCH_ABORTED = 9, - FW_LAUNCH_FLYING = 10, + FW_LAUNCH_DETECTED = 5, + FW_LAUNCH_ABORTED = 10, + FW_LAUNCH_FLYING = 11, } navFwLaunchStatus_e; typedef enum { @@ -294,7 +294,7 @@ typedef struct navConfig_s { uint16_t launch_time_thresh; // Time threshold for launch detection (ms) uint16_t launch_motor_timer; // Time to wait before setting launch_throttle (ms) uint16_t launch_idle_motor_timer; // Time to wait before motor starts at_idle throttle (ms) - bool launch_jerk_wake_idle; // Activate the idle throttle by jerking the plane + uint8_t launch_wiggle_wake_idle; // Activate the idle throttle by wiggling the plane. 0 = disabled, 1 or 2 specify the number of wiggles. uint16_t launch_motor_spinup_time; // Time to speed-up motors from idle to launch_throttle (ESC desync prevention) uint16_t launch_end_time; // Time to make the transition from launch angle to leveled and throttle transition from launch throttle to the stick position uint16_t launch_min_time; // Minimum time in launch mode to prevent possible bump of the sticks from leaving launch mode early diff --git a/src/main/navigation/navigation_fw_launch.c b/src/main/navigation/navigation_fw_launch.c index 5b8a1e7d666..c2045acfdf6 100644 --- a/src/main/navigation/navigation_fw_launch.c +++ b/src/main/navigation/navigation_fw_launch.c @@ -49,6 +49,7 @@ #include "io/gps.h" #include "sensors/battery.h" +#include "sensors/gyro.h" #define SWING_LAUNCH_MIN_ROTATION_RATE DEGREES_TO_RADIANS(100) // expect minimum 100dps rotation rate #define LAUNCH_MOTOR_IDLE_SPINUP_TIME 1500 // ms @@ -79,20 +80,22 @@ typedef enum { typedef enum { // if changed update navFwLaunchStatus_e FW_LAUNCH_STATE_WAIT_THROTTLE = 0, + FW_LAUNCH_STATE_IDLE_WIGGLE_WAIT, FW_LAUNCH_STATE_IDLE_MOTOR_DELAY, FW_LAUNCH_STATE_MOTOR_IDLE, FW_LAUNCH_STATE_WAIT_DETECTION, - FW_LAUNCH_STATE_DETECTED, // 4 + FW_LAUNCH_STATE_DETECTED, // FW_LAUNCH_DETECTED = 5 FW_LAUNCH_STATE_MOTOR_DELAY, FW_LAUNCH_STATE_MOTOR_SPINUP, FW_LAUNCH_STATE_IN_PROGRESS, FW_LAUNCH_STATE_FINISH, - FW_LAUNCH_STATE_ABORTED, // 9 - FW_LAUNCH_STATE_FLYING, // 10 + FW_LAUNCH_STATE_ABORTED, // FW_LAUNCH_ABORTED = 10 + FW_LAUNCH_STATE_FLYING, // FW_LAUNCH_FLYING = 11 FW_LAUNCH_STATE_COUNT } fixedWingLaunchState_t; static fixedWingLaunchEvent_t fwLaunchState_FW_LAUNCH_STATE_WAIT_THROTTLE(timeUs_t currentTimeUs); +static fixedWingLaunchEvent_t fwLaunchState_FW_LAUNCH_STATE_IDLE_WIGGLE_WAIT(timeUs_t currentTimeUs); static fixedWingLaunchEvent_t fwLaunchState_FW_LAUNCH_STATE_IDLE_MOTOR_DELAY(timeUs_t currentTimeUs); static fixedWingLaunchEvent_t fwLaunchState_FW_LAUNCH_STATE_MOTOR_IDLE(timeUs_t currentTimeUs); static fixedWingLaunchEvent_t fwLaunchState_FW_LAUNCH_STATE_WAIT_DETECTION(timeUs_t currentTimeUs); @@ -124,12 +127,22 @@ static const fixedWingLaunchStateDescriptor_t launchStateMachine[FW_LAUNCH_STATE [FW_LAUNCH_STATE_WAIT_THROTTLE] = { .onEntry = fwLaunchState_FW_LAUNCH_STATE_WAIT_THROTTLE, .onEvent = { - [FW_LAUNCH_EVENT_SUCCESS] = FW_LAUNCH_STATE_IDLE_MOTOR_DELAY, + [FW_LAUNCH_EVENT_SUCCESS] = FW_LAUNCH_STATE_IDLE_WIGGLE_WAIT, [FW_LAUNCH_EVENT_GOTO_DETECTION] = FW_LAUNCH_STATE_WAIT_DETECTION }, .messageType = FW_LAUNCH_MESSAGE_TYPE_WAIT_THROTTLE }, + [FW_LAUNCH_STATE_IDLE_WIGGLE_WAIT] = { + .onEntry = fwLaunchState_FW_LAUNCH_STATE_IDLE_WIGGLE_WAIT, + .onEvent = { + [FW_LAUNCH_EVENT_SUCCESS] = FW_LAUNCH_STATE_MOTOR_IDLE, + [FW_LAUNCH_EVENT_GOTO_DETECTION] = FW_LAUNCH_STATE_IDLE_MOTOR_DELAY, + [FW_LAUNCH_EVENT_THROTTLE_LOW] = FW_LAUNCH_STATE_WAIT_THROTTLE, + }, + .messageType = FW_LAUNCH_MESSAGE_TYPE_WAIT_IDLE + }, + [FW_LAUNCH_STATE_IDLE_MOTOR_DELAY] = { .onEntry = fwLaunchState_FW_LAUNCH_STATE_IDLE_MOTOR_DELAY, .onEvent = { @@ -253,6 +266,47 @@ static inline bool isThrottleLow(void) return calculateThrottleStatus(THROTTLE_STATUS_TYPE_RC) == THROTTLE_LOW; } +static bool hasIdleWakeWiggleSucceeded(timeUs_t currentTimeUs) { + static timeMs_t wiggleTime = 0; + static timeMs_t wigglesTime = 0; + static int8_t wiggleStageOne = 0; + static uint8_t wiggleCount = 0; + const bool isAircraftWithinLaunchAngle = (calculateCosTiltAngle() >= cos_approx(DEGREES_TO_RADIANS(navConfig()->fw.launch_max_angle))); + const uint8_t wiggleStrength = (navConfig()->fw.launch_wiggle_wake_idle == 1) ? 50 : 40; + int8_t wiggleDirection = 0; + int16_t yawRate = (int16_t)(gyroRateDps(YAW) * (4 / 16.4)); + + // Check to see if yaw rate has exceeded 50 dps. If so proceed to the next stage or continue to idle + if ((yawRate < -wiggleStrength || yawRate > wiggleStrength) && isAircraftWithinLaunchAngle) { + wiggleDirection = (yawRate > 0) ? 1 : -1; + + if (wiggleStageOne == 0) { + wiggleStageOne = wiggleDirection; + wigglesTime = US2MS(currentTimeUs); + } else if (wiggleStageOne != wiggleDirection) { + wiggleStageOne = 0; + wiggleCount++; + + if (wiggleCount == navConfig()->fw.launch_wiggle_wake_idle) { + return true; + } + } + + wiggleTime = US2MS(currentTimeUs); + } + + // If time between wiggle stages is > 100ms, or the time between two wiggles is > 1s. Reset the wiggle + if ( + ((wiggleStageOne != 0) && (US2MS(currentTimeUs) > (wiggleTime + 100))) || + ((wiggleCount != 0) && (US2MS(currentTimeUs) > (wigglesTime + 500))) + ) { + wiggleStageOne = 0; + wiggleCount = 0; + } + + return false; +} + static inline bool isLaunchMaxAltitudeReached(void) { return (navConfig()->fw.launch_max_altitude > 0) && (getEstimatedActualPosition(Z) >= navConfig()->fw.launch_max_altitude); @@ -310,26 +364,34 @@ static fixedWingLaunchEvent_t fwLaunchState_FW_LAUNCH_STATE_WAIT_THROTTLE(timeUs return FW_LAUNCH_EVENT_NONE; } -static fixedWingLaunchEvent_t fwLaunchState_FW_LAUNCH_STATE_IDLE_MOTOR_DELAY(timeUs_t currentTimeUs) -{ - bool isIdleJerkActivationTriggered = false; - +static fixedWingLaunchEvent_t fwLaunchState_FW_LAUNCH_STATE_IDLE_WIGGLE_WAIT(timeUs_t currentTimeUs) { if (isThrottleLow()) { return FW_LAUNCH_EVENT_THROTTLE_LOW; // go back to FW_LAUNCH_STATE_WAIT_THROTTLE } + if (navConfig()->fw.launch_wiggle_wake_idle == 0 || navConfig()->fw.launch_idle_motor_timer > 0 ) { + return FW_LAUNCH_EVENT_GOTO_DETECTION; + } + applyThrottleIdleLogic(true); - // Check to see if the plane has been jerked. If so, wake the idle throttle now - if (navConfig()->fw.launch_jerk_wake_idle) { - const float preIdleSwingVelocity = (fabsf(imuMeasuredRotationBF.z) > SWING_LAUNCH_MIN_ROTATION_RATE) ? (imuMeasuredAccelBF.y / imuMeasuredRotationBF.z) : 0; - const bool isPreIdleSwingLaunched = (preIdleSwingVelocity > navConfig()->fw.launch_velocity_thresh) && (imuMeasuredAccelBF.x > 0); - const bool isPreIdleForwardAccelerationHigh = (imuMeasuredAccelBF.x > navConfig()->fw.launch_accel_thresh); + if (hasIdleWakeWiggleSucceeded(currentTimeUs)) { + idleMotorAboutToStart = false; + return FW_LAUNCH_EVENT_SUCCESS; + } - isIdleJerkActivationTriggered = (isPreIdleSwingLaunched || isPreIdleForwardAccelerationHigh); + return FW_LAUNCH_EVENT_NONE; +} + +static fixedWingLaunchEvent_t fwLaunchState_FW_LAUNCH_STATE_IDLE_MOTOR_DELAY(timeUs_t currentTimeUs) +{ + if (isThrottleLow()) { + return FW_LAUNCH_EVENT_THROTTLE_LOW; // go back to FW_LAUNCH_STATE_WAIT_THROTTLE } - if ((currentStateElapsedMs(currentTimeUs) > navConfig()->fw.launch_idle_motor_timer) || isIdleJerkActivationTriggered) { + applyThrottleIdleLogic(true); + + if ((currentStateElapsedMs(currentTimeUs) > navConfig()->fw.launch_idle_motor_timer) || (navConfig()->fw.launch_wiggle_wake_idle > 0 && hasIdleWakeWiggleSucceeded(currentTimeUs))) { idleMotorAboutToStart = false; return FW_LAUNCH_EVENT_SUCCESS; } From 15c0b58c7de25a0aac56dd0fbdf9da003eb54a17 Mon Sep 17 00:00:00 2001 From: Roman Lut <11955117+RomanLut@users.noreply.github.com> Date: Tue, 2 Aug 2022 10:19:51 +0300 Subject: [PATCH 003/241] mavlink 2 output 18 channels --- src/main/telemetry/mavlink.c | 96 +++++++++++++++++++++++++++--------- 1 file changed, 72 insertions(+), 24 deletions(-) diff --git a/src/main/telemetry/mavlink.c b/src/main/telemetry/mavlink.c index b13a9f04971..716ec3258c3 100644 --- a/src/main/telemetry/mavlink.c +++ b/src/main/telemetry/mavlink.c @@ -489,30 +489,78 @@ void mavlinkSendSystemStatus(void) void mavlinkSendRCChannelsAndRSSI(void) { #define GET_CHANNEL_VALUE(x) ((rxRuntimeConfig.channelCount >= (x + 1)) ? rxGetChannelValue(x) : 0) - mavlink_msg_rc_channels_raw_pack(mavSystemId, mavComponentId, &mavSendMsg, - // time_boot_ms Timestamp (milliseconds since system boot) - millis(), - // port Servo output port (set of 8 outputs = 1 port). Most MAVs will just use one, but this allows to encode more than 8 servos. - 0, - // chan1_raw RC channel 1 value, in microseconds - GET_CHANNEL_VALUE(0), - // chan2_raw RC channel 2 value, in microseconds - GET_CHANNEL_VALUE(1), - // chan3_raw RC channel 3 value, in microseconds - GET_CHANNEL_VALUE(2), - // chan4_raw RC channel 4 value, in microseconds - GET_CHANNEL_VALUE(3), - // chan5_raw RC channel 5 value, in microseconds - GET_CHANNEL_VALUE(4), - // chan6_raw RC channel 6 value, in microseconds - GET_CHANNEL_VALUE(5), - // chan7_raw RC channel 7 value, in microseconds - GET_CHANNEL_VALUE(6), - // chan8_raw RC channel 8 value, in microseconds - GET_CHANNEL_VALUE(7), - // rssi Receive signal strength indicator, 0: 0%, 254: 100% - //https://github.com/mavlink/mavlink/issues/1027 - scaleRange(getRSSI(), 0, 1023, 0, 254)); + if (telemetryConfig()->mavlink.version == 1) { + mavlink_msg_rc_channels_raw_pack(mavSystemId, mavComponentId, &mavSendMsg, + // time_boot_ms Timestamp (milliseconds since system boot) + millis(), + // port Servo output port (set of 8 outputs = 1 port). Most MAVs will just use one, but this allows to encode more than 8 servos. + 0, + // chan1_raw RC channel 1 value, in microseconds + GET_CHANNEL_VALUE(0), + // chan2_raw RC channel 2 value, in microseconds + GET_CHANNEL_VALUE(1), + // chan3_raw RC channel 3 value, in microseconds + GET_CHANNEL_VALUE(2), + // chan4_raw RC channel 4 value, in microseconds + GET_CHANNEL_VALUE(3), + // chan5_raw RC channel 5 value, in microseconds + GET_CHANNEL_VALUE(4), + // chan6_raw RC channel 6 value, in microseconds + GET_CHANNEL_VALUE(5), + // chan7_raw RC channel 7 value, in microseconds + GET_CHANNEL_VALUE(6), + // chan8_raw RC channel 8 value, in microseconds + GET_CHANNEL_VALUE(7), + // rssi Receive signal strength indicator, 0: 0%, 254: 100% + //https://github.com/mavlink/mavlink/issues/1027 + scaleRange(getRSSI(), 0, 1023, 0, 254)); + } + else { + mavlink_msg_rc_channels_pack(mavSystemId, mavComponentId, &mavSendMsg, + // time_boot_ms Timestamp (milliseconds since system boot) + millis(), + // Total number of RC channels being received. + rxRuntimeConfig.channelCount, + // chan1_raw RC channel 1 value, in microseconds + GET_CHANNEL_VALUE(0), + // chan2_raw RC channel 2 value, in microseconds + GET_CHANNEL_VALUE(1), + // chan3_raw RC channel 3 value, in microseconds + GET_CHANNEL_VALUE(2), + // chan4_raw RC channel 4 value, in microseconds + GET_CHANNEL_VALUE(3), + // chan5_raw RC channel 5 value, in microseconds + GET_CHANNEL_VALUE(4), + // chan6_raw RC channel 6 value, in microseconds + GET_CHANNEL_VALUE(5), + // chan7_raw RC channel 7 value, in microseconds + GET_CHANNEL_VALUE(6), + // chan8_raw RC channel 8 value, in microseconds + GET_CHANNEL_VALUE(7), + // chan9_raw RC channel 9 value, in microseconds + GET_CHANNEL_VALUE(8), + // chan10_raw RC channel 10 value, in microseconds + GET_CHANNEL_VALUE(9), + // chan11_raw RC channel 11 value, in microseconds + GET_CHANNEL_VALUE(10), + // chan12_raw RC channel 12 value, in microseconds + GET_CHANNEL_VALUE(11), + // chan13_raw RC channel 13 value, in microseconds + GET_CHANNEL_VALUE(12), + // chan14_raw RC channel 14 value, in microseconds + GET_CHANNEL_VALUE(13), + // chan15_raw RC channel 15 value, in microseconds + GET_CHANNEL_VALUE(14), + // chan16_raw RC channel 16 value, in microseconds + GET_CHANNEL_VALUE(15), + // chan17_raw RC channel 17 value, in microseconds + GET_CHANNEL_VALUE(16), + // chan18_raw RC channel 18 value, in microseconds + GET_CHANNEL_VALUE(17), + // rssi Receive signal strength indicator, 0: 0%, 254: 100% + //https://github.com/mavlink/mavlink/issues/1027 + scaleRange(getRSSI(), 0, 1023, 0, 254)); + } #undef GET_CHANNEL_VALUE mavlinkSendMessage(); From 0246892708759f16d6910e6e570f7b5ce5acc582 Mon Sep 17 00:00:00 2001 From: breadoven <56191411+breadoven@users.noreply.github.com> Date: Tue, 7 Nov 2023 23:20:49 +0000 Subject: [PATCH 004/241] initial build --- src/main/navigation/navigation.c | 109 ++++++++++--------- src/main/navigation/navigation_fixedwing.c | 46 +++----- src/main/navigation/navigation_multicopter.c | 35 +++--- src/main/navigation/navigation_private.h | 6 +- 4 files changed, 92 insertions(+), 104 deletions(-) diff --git a/src/main/navigation/navigation.c b/src/main/navigation/navigation.c index c566c94bfad..57a6ba5c066 100644 --- a/src/main/navigation/navigation.c +++ b/src/main/navigation/navigation.c @@ -2927,8 +2927,7 @@ void setDesiredPosition(const fpVector3_t * pos, int32_t yaw, navSetWaypointFlag // Z-position if ((useMask & NAV_POS_UPDATE_Z) != 0) { - updateClimbRateToAltitudeController(0, 0, ROC_TO_ALT_RESET); // Reset RoC/RoD -> altitude controller - posControl.desiredState.pos.z = pos->z; + updateClimbRateToAltitudeController(navConfig()->general.max_auto_climb_rate, pos->z, ROC_TO_ALT_TARGET); } // Heading @@ -3036,66 +3035,68 @@ bool isProbablyStillFlying(void) /*----------------------------------------------------------- * Z-position controller *-----------------------------------------------------------*/ -void updateClimbRateToAltitudeController(float desiredClimbRate, float targetAltitude, climbRateToAltitudeControllerMode_e mode) +static bool isMaxAltitudeLimitExceeded(void) { -#define MIN_TARGET_CLIMB_RATE 100.0f // cm/s + return navGetCurrentActualPositionAndVelocity()->pos.z >= navConfig()->general.max_altitude; +} - static timeUs_t lastUpdateTimeUs; - timeUs_t currentTimeUs = micros(); +int32_t getDesiredClimbRate(float targetAltitude, timeDelta_t deltaMicros) +{ + if (navConfig()->general.max_altitude && isMaxAltitudeLimitExceeded()) { + targetAltitude = MIN(targetAltitude, navConfig()->general.max_altitude); + } - // Terrain following uses different altitude measurement - const float altitudeToUse = navGetCurrentActualPositionAndVelocity()->pos.z; + const bool emergLandingIsActive = navigationIsExecutingAnEmergencyLanding(); - if (mode != ROC_TO_ALT_RESET && desiredClimbRate) { - /* ROC_TO_ALT_CONSTANT - constant climb rate - * ROC_TO_ALT_TARGET - constant climb rate until close to target altitude reducing to min rate when altitude reached - * Rate reduction starts at distance from target altitude of 5 x climb rate for FW, 1 x climb rate for MC */ + float maxClimbRate = navConfig()->general.max_auto_climb_rate; + if (emergLandingIsActive) { + maxClimbRate = navConfig()->general.emerg_descent_rate; + } else if (posControl.flags.isAdjustingAltitude) { + maxClimbRate = navConfig()->general.max_manual_climb_rate; + } + const float targetAltitudeError = targetAltitude - navGetCurrentActualPositionAndVelocity()->pos.z; + float targetVel = 0.0f; - if (mode == ROC_TO_ALT_TARGET && fabsf(desiredClimbRate) > MIN_TARGET_CLIMB_RATE) { - const int8_t direction = desiredClimbRate > 0 ? 1 : -1; - const float absClimbRate = fabsf(desiredClimbRate); - const uint16_t maxRateCutoffAlt = STATE(AIRPLANE) ? absClimbRate * 5 : absClimbRate; - const float verticalVelScaled = scaleRangef(navGetCurrentActualPositionAndVelocity()->pos.z - targetAltitude, - 0.0f, -maxRateCutoffAlt * direction, MIN_TARGET_CLIMB_RATE, absClimbRate); + if (STATE(MULTIROTOR)) { + targetVel = getSqrtControllerVelocity(targetAltitude, deltaMicros); + } else { + targetVel = scaleRangef(targetAltitudeError, 0.0f, maxClimbRate * 5, 0.0f, maxClimbRate); + } - desiredClimbRate = direction * constrainf(verticalVelScaled, MIN_TARGET_CLIMB_RATE, absClimbRate); - } + if (emergLandingIsActive && targetAltitudeError > -50) { + return -100; + } else { + return constrainf(targetVel, -maxClimbRate, maxClimbRate); + } +} - /* - * If max altitude is set, reset climb rate if altitude is reached and climb rate is > 0 - * In other words, when altitude is reached, allow it only to shrink - */ - if (navConfig()->general.max_altitude > 0 && altitudeToUse >= navConfig()->general.max_altitude && desiredClimbRate > 0) { - desiredClimbRate = 0; - } +void updateClimbRateToAltitudeController(float desiredClimbRate, float targetAltitude, climbRateToAltitudeControllerMode_e mode) +{ + /* ROC_TO_ALT_CONSTANT - constant climb rate. desiredClimbRate direction (+ or -) is required + * ROC_TO_ALT_TARGET - constant climb rate until close to target altitude reducing to min rate when altitude reached + * Rate reduction starts at distance from target altitude of 5 x climb rate for FW, 1 x climb rate for MC. + * desiredClimbRate direction isn't required, set by target altitude direction instead + * NAV_IMPOSSIBLE_ALTITUDE_TARGET simply uses posControl.desiredState.pos.z to set a constant climb rate */ - if (STATE(FIXED_WING_LEGACY)) { - // Fixed wing climb rate controller is open-loop. We simply move the known altitude target - float timeDelta = US2S(currentTimeUs - lastUpdateTimeUs); - static bool targetHoldActive = false; - - if (timeDelta <= HZ2S(MIN_POSITION_UPDATE_RATE_HZ) && desiredClimbRate) { - // Update target altitude only if actual altitude moving in same direction and lagging by < 5 m, otherwise hold target - if (navGetCurrentActualPositionAndVelocity()->vel.z * desiredClimbRate >= 0 && fabsf(posControl.desiredState.pos.z - altitudeToUse) < 500) { - posControl.desiredState.pos.z += desiredClimbRate * timeDelta; - targetHoldActive = false; - } else if (!targetHoldActive) { // Reset and hold target to actual + climb rate boost until actual catches up - posControl.desiredState.pos.z = altitudeToUse + desiredClimbRate; - targetHoldActive = true; - } - } else { - targetHoldActive = false; - } - } - else { - // Multicopter climb-rate control is closed-loop, it's possible to directly calculate desired altitude setpoint to yield the required RoC/RoD - posControl.desiredState.pos.z = altitudeToUse + (desiredClimbRate / posControl.pids.pos[Z].param.kP); - } - } else { // ROC_TO_ALT_RESET or zero desired climbrate + // Terrain following uses different altitude measurement + const float altitudeToUse = navGetCurrentActualPositionAndVelocity()->pos.z; + + if (mode == ROC_TO_ALT_RESET) { posControl.desiredState.pos.z = altitudeToUse; + } else if (mode == ROC_TO_ALT_TARGET) { + posControl.desiredState.pos.z = targetAltitude; + } else { // ROC_TO_ALT_CONSTANT + posControl.desiredState.pos.z = NAV_IMPOSSIBLE_ALTITUDE_TARGET; + } + + /* + * If max altitude is set and altitude limit reached reset altitude target to max altitude unless desired climb rate is -ve + */ + if (navConfig()->general.max_altitude && isMaxAltitudeLimitExceeded() && desiredClimbRate >= 0.0f) { + posControl.desiredState.pos.z = MIN(posControl.desiredState.pos.z, navConfig()->general.max_altitude); } - lastUpdateTimeUs = currentTimeUs; + posControl.desiredState.vel.z = desiredClimbRate; } static void resetAltitudeController(bool useTerrainFollowing) @@ -4317,9 +4318,9 @@ void navigationUsePIDs(void) 0.0f ); - navPidInit(&posControl.pids.fw_alt, (float)pidProfile()->bank_fw.pid[PID_POS_Z].P / 10.0f, - (float)pidProfile()->bank_fw.pid[PID_POS_Z].I / 10.0f, - (float)pidProfile()->bank_fw.pid[PID_POS_Z].D / 10.0f, + navPidInit(&posControl.pids.fw_alt, (float)pidProfile()->bank_fw.pid[PID_POS_Z].P / 100.0f, + (float)pidProfile()->bank_fw.pid[PID_POS_Z].I / 100.0f, + (float)pidProfile()->bank_fw.pid[PID_POS_Z].D / 100.0f, 0.0f, NAV_DTERM_CUT_HZ, 0.0f diff --git a/src/main/navigation/navigation_fixedwing.c b/src/main/navigation/navigation_fixedwing.c index e6084e0972e..c5dde6dba48 100755 --- a/src/main/navigation/navigation_fixedwing.c +++ b/src/main/navigation/navigation_fixedwing.c @@ -123,7 +123,7 @@ bool adjustFixedWingAltitudeFromRCInput(void) else { // Adjusting finished - reset desired position to stay exactly where pilot released the stick if (posControl.flags.isAdjustingAltitude) { - updateClimbRateToAltitudeController(0, 0, ROC_TO_ALT_RESET); + updateClimbRateToAltitudeController(navConfig()->general.max_auto_climb_rate, 0, ROC_TO_ALT_RESET); } return false; } @@ -134,46 +134,34 @@ static void updateAltitudeVelocityAndPitchController_FW(timeDelta_t deltaMicros) { static pt1Filter_t velzFilterState; - // On a fixed wing we might not have a reliable climb rate source (if no BARO available), so we can't apply PID controller to - // velocity error. We use PID controller on altitude error and calculate desired pitch angle + float desiredClimbRate = posControl.desiredState.vel.z; - // Update energies - const float demSPE = (posControl.desiredState.pos.z * 0.01f) * GRAVITY_MSS; - const float demSKE = 0.0f; - - const float estSPE = (navGetCurrentActualPositionAndVelocity()->pos.z * 0.01f) * GRAVITY_MSS; - const float estSKE = 0.0f; - - // speedWeight controls balance between potential and kinetic energy used for pitch controller - // speedWeight = 1.0 : pitch will only control airspeed and won't control altitude - // speedWeight = 0.5 : pitch will be used to control both airspeed and altitude - // speedWeight = 0.0 : pitch will only control altitude - const float speedWeight = 0.0f; // no speed sensing for now - - const float demSEB = demSPE * (1.0f - speedWeight) - demSKE * speedWeight; - const float estSEB = estSPE * (1.0f - speedWeight) - estSKE * speedWeight; + if (posControl.desiredState.pos.z != NAV_IMPOSSIBLE_ALTITUDE_TARGET) { + desiredClimbRate = getDesiredClimbRate(posControl.desiredState.pos.z, deltaMicros); + } - // SEB to pitch angle gain to account for airspeed (with respect to specified reference (tuning) speed - const float pitchGainInv = 1.0f / 1.0f; + // Reduce max allowed climb pitch if performing loiter (stall prevention) + if (needToCalculateCircularLoiter && desiredClimbRate > 0.0f) { + desiredClimbRate *= 0.67f; + } // Here we use negative values for dive for better clarity - float maxClimbDeciDeg = DEGREES_TO_DECIDEGREES(navConfig()->fw.max_climb_angle); + const float maxClimbDeciDeg = DEGREES_TO_DECIDEGREES(navConfig()->fw.max_climb_angle); const float minDiveDeciDeg = -DEGREES_TO_DECIDEGREES(navConfig()->fw.max_dive_angle); - // Reduce max allowed climb pitch if performing loiter (stall prevention) - if (needToCalculateCircularLoiter) { - maxClimbDeciDeg = maxClimbDeciDeg * 0.67f; - } - - // PID controller to translate energy balance error [J] into pitch angle [decideg] - float targetPitchAngle = navPidApply3(&posControl.pids.fw_alt, demSEB, estSEB, US2S(deltaMicros), minDiveDeciDeg, maxClimbDeciDeg, 0, pitchGainInv, 1.0f); + // PID controller to translate desired climb rate error into pitch angle [decideg] + float currentClimbRate = navGetCurrentActualPositionAndVelocity()->vel.z; + float targetPitchAngle = navPidApply2(&posControl.pids.fw_alt, desiredClimbRate, currentClimbRate, US2S(deltaMicros), minDiveDeciDeg, maxClimbDeciDeg, PID_DTERM_FROM_ERROR); // Apply low-pass filter to prevent rapid correction targetPitchAngle = pt1FilterApply4(&velzFilterState, targetPitchAngle, getSmoothnessCutoffFreq(NAV_FW_BASE_PITCH_CUTOFF_FREQUENCY_HZ), US2S(deltaMicros)); - // Reconstrain pitch angle ( >0 - climb, <0 - dive) + // Reconstrain pitch angle (> 0 - climb, < 0 - dive) targetPitchAngle = constrainf(targetPitchAngle, minDiveDeciDeg, maxClimbDeciDeg); posControl.rcAdjustment[PITCH] = targetPitchAngle; + + posControl.desiredState.vel.z = desiredClimbRate; + navDesiredVelocity[Z] = constrain(lrintf(posControl.desiredState.vel.z), -32678, 32767); } void applyFixedWingAltitudeAndThrottleController(timeUs_t currentTimeUs) diff --git a/src/main/navigation/navigation_multicopter.c b/src/main/navigation/navigation_multicopter.c index 2264d842014..935665ee60e 100644 --- a/src/main/navigation/navigation_multicopter.c +++ b/src/main/navigation/navigation_multicopter.c @@ -63,28 +63,26 @@ static pt1Filter_t altholdThrottleFilterState; static bool prepareForTakeoffOnReset = false; static sqrt_controller_t alt_hold_sqrt_controller; -// Position to velocity controller for Z axis -static void updateAltitudeVelocityController_MC(timeDelta_t deltaMicros) +float getSqrtControllerVelocity(float targetAltitude, timeDelta_t deltaMicros) { - float targetVel = sqrtControllerApply( - &alt_hold_sqrt_controller, - posControl.desiredState.pos.z, - navGetCurrentActualPositionAndVelocity()->pos.z, - US2S(deltaMicros) + return sqrtControllerApply( + &alt_hold_sqrt_controller, + targetAltitude, + navGetCurrentActualPositionAndVelocity()->pos.z, + US2S(deltaMicros) ); +} - // hard limit desired target velocity to max_climb_rate - float vel_max_z = 0.0f; +// Position to velocity controller for Z axis +static void updateAltitudeVelocityController_MC(timeDelta_t deltaMicros) +{ + float targetVel = posControl.desiredState.vel.z; - if (posControl.flags.isAdjustingAltitude) { - vel_max_z = navConfig()->general.max_manual_climb_rate; - } else { - vel_max_z = navConfig()->general.max_auto_climb_rate; + if (posControl.desiredState.pos.z != NAV_IMPOSSIBLE_ALTITUDE_TARGET) { + targetVel = getDesiredClimbRate(posControl.desiredState.pos.z, deltaMicros); } - targetVel = constrainf(targetVel, -vel_max_z, vel_max_z); - - posControl.pids.pos[Z].output_constrained = targetVel; + posControl.pids.pos[Z].output_constrained = targetVel; // only used for Blackbox and OSD info // Limit max up/down acceleration target const float smallVelChange = US2S(deltaMicros) * (GRAVITY_CMSS * 0.1f); @@ -132,8 +130,7 @@ bool adjustMulticopterAltitudeFromRCInput(void) // In terrain follow mode we apply different logic for terrain control if (posControl.flags.estAglStatus == EST_TRUSTED && altTarget > 10.0f) { // We have solid terrain sensor signal - directly map throttle to altitude - updateClimbRateToAltitudeController(0, 0, ROC_TO_ALT_RESET); - posControl.desiredState.pos.z = altTarget; + updateClimbRateToAltitudeController(navConfig()->general.max_manual_climb_rate, altTarget, ROC_TO_ALT_TARGET); } else { updateClimbRateToAltitudeController(-50.0f, 0, ROC_TO_ALT_CONSTANT); @@ -165,7 +162,7 @@ bool adjustMulticopterAltitudeFromRCInput(void) else { // Adjusting finished - reset desired position to stay exactly where pilot released the stick if (posControl.flags.isAdjustingAltitude) { - updateClimbRateToAltitudeController(0, 0, ROC_TO_ALT_RESET); + updateClimbRateToAltitudeController(navConfig()->general.max_auto_climb_rate, 0, ROC_TO_ALT_RESET); } return false; diff --git a/src/main/navigation/navigation_private.h b/src/main/navigation/navigation_private.h index c408f109c9b..35e5492c6f1 100644 --- a/src/main/navigation/navigation_private.h +++ b/src/main/navigation/navigation_private.h @@ -47,6 +47,8 @@ #define NAV_RTH_TRACKBACK_POINTS 50 // max number RTH trackback points +#define NAV_IMPOSSIBLE_ALTITUDE_TARGET 10000000 // 100km in cm. Serves as a flag for vertical velocity control + #define MAX_POSITION_UPDATE_INTERVAL_US HZ2US(MIN_POSITION_UPDATE_RATE_HZ) // convenience macro _Static_assert(MAX_POSITION_UPDATE_INTERVAL_US <= TIMEDELTA_MAX, "deltaMicros can overflow!"); @@ -481,6 +483,7 @@ bool isWaypointNavTrackingActive(void); void updateActualHeading(bool headingValid, int32_t newHeading, int32_t newGroundCourse); void updateActualHorizontalPositionAndVelocity(bool estPosValid, bool estVelValid, float newX, float newY, float newVelX, float newVelY); void updateActualAltitudeAndClimbRate(bool estimateValid, float newAltitude, float newVelocity, float surfaceDistance, float surfaceVelocity, navigationEstimateStatus_e surfaceStatus, float gpsCfEstimatedAltitudeError); +int32_t getDesiredClimbRate(float targetAltitude, timeDelta_t deltaMicros); bool checkForPositionSensorTimeout(void); @@ -499,10 +502,9 @@ bool adjustMulticopterHeadingFromRCInput(void); bool adjustMulticopterPositionFromRCInput(int16_t rcPitchAdjustment, int16_t rcRollAdjustment); void applyMulticopterNavigationController(navigationFSMStateFlags_t navStateFlags, timeUs_t currentTimeUs); - bool isMulticopterLandingDetected(void); - void calculateMulticopterInitialHoldPosition(fpVector3_t * pos); +float getSqrtControllerVelocity(float targetAltitude, timeDelta_t deltaMicros); /* Fixed-wing specific functions */ void setupFixedWingAltitudeController(void); From 7ae41ad928348b0d253b6df49eace47138e0358c Mon Sep 17 00:00:00 2001 From: breadoven <56191411+breadoven@users.noreply.github.com> Date: Wed, 8 Nov 2023 22:48:33 +0000 Subject: [PATCH 005/241] cleanup + add roc to alt flag --- src/main/navigation/navigation.c | 26 +++++++++++--------- src/main/navigation/navigation_fixedwing.c | 6 ++--- src/main/navigation/navigation_multicopter.c | 9 +++---- src/main/navigation/navigation_private.h | 4 +-- 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/main/navigation/navigation.c b/src/main/navigation/navigation.c index 57a6ba5c066..f18c1cdc567 100644 --- a/src/main/navigation/navigation.c +++ b/src/main/navigation/navigation.c @@ -2927,7 +2927,7 @@ void setDesiredPosition(const fpVector3_t * pos, int32_t yaw, navSetWaypointFlag // Z-position if ((useMask & NAV_POS_UPDATE_Z) != 0) { - updateClimbRateToAltitudeController(navConfig()->general.max_auto_climb_rate, pos->z, ROC_TO_ALT_TARGET); + updateClimbRateToAltitudeController(0, pos->z, ROC_TO_ALT_TARGET); } // Heading @@ -3060,11 +3060,12 @@ int32_t getDesiredClimbRate(float targetAltitude, timeDelta_t deltaMicros) if (STATE(MULTIROTOR)) { targetVel = getSqrtControllerVelocity(targetAltitude, deltaMicros); } else { - targetVel = scaleRangef(targetAltitudeError, 0.0f, maxClimbRate * 5, 0.0f, maxClimbRate); + // 0.2f relates to climb rate starting to reduce from maxClimbRate at a distance of 5 x maxClimbRate from targetAltitude + targetVel = 0.2f * targetAltitudeError; } if (emergLandingIsActive && targetAltitudeError > -50) { - return -100; + return -100; // maintain 1 m/s descent during emerg landing when approaching T/O altitude } else { return constrainf(targetVel, -maxClimbRate, maxClimbRate); } @@ -3072,11 +3073,14 @@ int32_t getDesiredClimbRate(float targetAltitude, timeDelta_t deltaMicros) void updateClimbRateToAltitudeController(float desiredClimbRate, float targetAltitude, climbRateToAltitudeControllerMode_e mode) { - /* ROC_TO_ALT_CONSTANT - constant climb rate. desiredClimbRate direction (+ or -) is required - * ROC_TO_ALT_TARGET - constant climb rate until close to target altitude reducing to min rate when altitude reached - * Rate reduction starts at distance from target altitude of 5 x climb rate for FW, 1 x climb rate for MC. - * desiredClimbRate direction isn't required, set by target altitude direction instead - * NAV_IMPOSSIBLE_ALTITUDE_TARGET simply uses posControl.desiredState.pos.z to set a constant climb rate */ + /* ROC_TO_ALT_TARGET - constant climb rate until close to target altitude reducing to 0 when reached. + * Rate reduction starts at distance from target altitude of 5 x climb rate for Fixed wing. + * No climb rate required, set by target altitude direction instead. + * + * ROC_TO_ALT_RESET - similar to ROC_TO_ALT_TARGET except target altitude set to current altitude. + * No climb rate or altitude target required. + * + * ROC_TO_ALT_CONSTANT - constant climb rate. Climb rate and direction required. Target alt not required. */ // Terrain following uses different altitude measurement const float altitudeToUse = navGetCurrentActualPositionAndVelocity()->pos.z; @@ -3085,10 +3089,10 @@ void updateClimbRateToAltitudeController(float desiredClimbRate, float targetAlt posControl.desiredState.pos.z = altitudeToUse; } else if (mode == ROC_TO_ALT_TARGET) { posControl.desiredState.pos.z = targetAltitude; - } else { // ROC_TO_ALT_CONSTANT - posControl.desiredState.pos.z = NAV_IMPOSSIBLE_ALTITUDE_TARGET; } + posControl.flags.rocToAltMode = mode; + /* * If max altitude is set and altitude limit reached reset altitude target to max altitude unless desired climb rate is -ve */ @@ -3096,7 +3100,7 @@ void updateClimbRateToAltitudeController(float desiredClimbRate, float targetAlt posControl.desiredState.pos.z = MIN(posControl.desiredState.pos.z, navConfig()->general.max_altitude); } - posControl.desiredState.vel.z = desiredClimbRate; + posControl.desiredState.vel.z = desiredClimbRate; // only used for ROC_TO_ALT_CONSTANT } static void resetAltitudeController(bool useTerrainFollowing) diff --git a/src/main/navigation/navigation_fixedwing.c b/src/main/navigation/navigation_fixedwing.c index c5dde6dba48..0272df114c7 100755 --- a/src/main/navigation/navigation_fixedwing.c +++ b/src/main/navigation/navigation_fixedwing.c @@ -123,7 +123,7 @@ bool adjustFixedWingAltitudeFromRCInput(void) else { // Adjusting finished - reset desired position to stay exactly where pilot released the stick if (posControl.flags.isAdjustingAltitude) { - updateClimbRateToAltitudeController(navConfig()->general.max_auto_climb_rate, 0, ROC_TO_ALT_RESET); + updateClimbRateToAltitudeController(0, 0, ROC_TO_ALT_RESET); } return false; } @@ -136,7 +136,7 @@ static void updateAltitudeVelocityAndPitchController_FW(timeDelta_t deltaMicros) float desiredClimbRate = posControl.desiredState.vel.z; - if (posControl.desiredState.pos.z != NAV_IMPOSSIBLE_ALTITUDE_TARGET) { + if (posControl.flags.rocToAltMode != ROC_TO_ALT_CONSTANT) { desiredClimbRate = getDesiredClimbRate(posControl.desiredState.pos.z, deltaMicros); } @@ -757,7 +757,7 @@ void applyFixedWingEmergencyLandingController(timeUs_t currentTimeUs) if (posControl.flags.estAltStatus >= EST_USABLE) { // target min descent rate 10m above takeoff altitude - updateClimbRateToAltitudeController(-navConfig()->general.emerg_descent_rate, 1000.0f, ROC_TO_ALT_TARGET); + updateClimbRateToAltitudeController(0, 1000.0f, ROC_TO_ALT_TARGET); applyFixedWingAltitudeAndThrottleController(currentTimeUs); int16_t pitchCorrection = constrain(posControl.rcAdjustment[PITCH], -DEGREES_TO_DECIDEGREES(navConfig()->fw.max_dive_angle), DEGREES_TO_DECIDEGREES(navConfig()->fw.max_climb_angle)); diff --git a/src/main/navigation/navigation_multicopter.c b/src/main/navigation/navigation_multicopter.c index 935665ee60e..559898eadfd 100644 --- a/src/main/navigation/navigation_multicopter.c +++ b/src/main/navigation/navigation_multicopter.c @@ -78,7 +78,7 @@ static void updateAltitudeVelocityController_MC(timeDelta_t deltaMicros) { float targetVel = posControl.desiredState.vel.z; - if (posControl.desiredState.pos.z != NAV_IMPOSSIBLE_ALTITUDE_TARGET) { + if (posControl.flags.rocToAltMode != ROC_TO_ALT_CONSTANT) { targetVel = getDesiredClimbRate(posControl.desiredState.pos.z, deltaMicros); } @@ -130,7 +130,7 @@ bool adjustMulticopterAltitudeFromRCInput(void) // In terrain follow mode we apply different logic for terrain control if (posControl.flags.estAglStatus == EST_TRUSTED && altTarget > 10.0f) { // We have solid terrain sensor signal - directly map throttle to altitude - updateClimbRateToAltitudeController(navConfig()->general.max_manual_climb_rate, altTarget, ROC_TO_ALT_TARGET); + updateClimbRateToAltitudeController(0, altTarget, ROC_TO_ALT_TARGET); } else { updateClimbRateToAltitudeController(-50.0f, 0, ROC_TO_ALT_CONSTANT); @@ -162,7 +162,7 @@ bool adjustMulticopterAltitudeFromRCInput(void) else { // Adjusting finished - reset desired position to stay exactly where pilot released the stick if (posControl.flags.isAdjustingAltitude) { - updateClimbRateToAltitudeController(navConfig()->general.max_auto_climb_rate, 0, ROC_TO_ALT_RESET); + updateClimbRateToAltitudeController(0, 0, ROC_TO_ALT_RESET); } return false; @@ -249,7 +249,6 @@ static void applyMulticopterAltitudeController(timeUs_t currentTimeUs) if (prepareForTakeoffOnReset) { const navEstimatedPosVel_t *posToUse = navGetCurrentActualPositionAndVelocity(); - posControl.desiredState.vel.z = -navConfig()->general.max_manual_climb_rate; posControl.desiredState.pos.z = posToUse->pos.z - (navConfig()->general.max_manual_climb_rate / posControl.pids.pos[Z].param.kP); posControl.pids.vel[Z].integrator = -500.0f; pt1FilterReset(&altholdThrottleFilterState, -500.0f); @@ -930,7 +929,7 @@ static void applyMulticopterEmergencyLandingController(timeUs_t currentTimeUs) // Check if last correction was not too long ago if (deltaMicrosPositionUpdate < MAX_POSITION_UPDATE_INTERVAL_US) { // target min descent rate 5m above takeoff altitude - updateClimbRateToAltitudeController(-navConfig()->general.emerg_descent_rate, 500.0f, ROC_TO_ALT_TARGET); + updateClimbRateToAltitudeController(0, 500.0f, ROC_TO_ALT_TARGET); updateAltitudeVelocityController_MC(deltaMicrosPositionUpdate); updateAltitudeThrottleController_MC(deltaMicrosPositionUpdate); } diff --git a/src/main/navigation/navigation_private.h b/src/main/navigation/navigation_private.h index 35e5492c6f1..8452650ffaa 100644 --- a/src/main/navigation/navigation_private.h +++ b/src/main/navigation/navigation_private.h @@ -47,8 +47,6 @@ #define NAV_RTH_TRACKBACK_POINTS 50 // max number RTH trackback points -#define NAV_IMPOSSIBLE_ALTITUDE_TARGET 10000000 // 100km in cm. Serves as a flag for vertical velocity control - #define MAX_POSITION_UPDATE_INTERVAL_US HZ2US(MIN_POSITION_UPDATE_RATE_HZ) // convenience macro _Static_assert(MAX_POSITION_UPDATE_INTERVAL_US <= TIMEDELTA_MAX, "deltaMicros can overflow!"); @@ -95,6 +93,8 @@ typedef struct navigationFlags_s { navigationEstimateStatus_e estHeadingStatus; // Indicate valid heading - wither mag or GPS at certain speed on airplane bool gpsCfEstimatedAltitudeMismatch; // Indicates a mismatch between GPS altitude and estimated altitude + climbRateToAltitudeControllerMode_e rocToAltMode; + bool isAdjustingPosition; bool isAdjustingAltitude; bool isAdjustingHeading; From a8079c28423d74ae592cbd9c51a3911ad7f0b0e7 Mon Sep 17 00:00:00 2001 From: breadoven <56191411+breadoven@users.noreply.github.com> Date: Thu, 9 Nov 2023 11:24:37 +0000 Subject: [PATCH 006/241] fixes --- src/main/navigation/navigation.c | 8 +++----- src/main/navigation/navigation_private.h | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/navigation/navigation.c b/src/main/navigation/navigation.c index f18c1cdc567..7505260c889 100644 --- a/src/main/navigation/navigation.c +++ b/src/main/navigation/navigation.c @@ -3040,7 +3040,7 @@ static bool isMaxAltitudeLimitExceeded(void) return navGetCurrentActualPositionAndVelocity()->pos.z >= navConfig()->general.max_altitude; } -int32_t getDesiredClimbRate(float targetAltitude, timeDelta_t deltaMicros) +float getDesiredClimbRate(float targetAltitude, timeDelta_t deltaMicros) { if (navConfig()->general.max_altitude && isMaxAltitudeLimitExceeded()) { targetAltitude = MIN(targetAltitude, navConfig()->general.max_altitude); @@ -3082,11 +3082,8 @@ void updateClimbRateToAltitudeController(float desiredClimbRate, float targetAlt * * ROC_TO_ALT_CONSTANT - constant climb rate. Climb rate and direction required. Target alt not required. */ - // Terrain following uses different altitude measurement - const float altitudeToUse = navGetCurrentActualPositionAndVelocity()->pos.z; - if (mode == ROC_TO_ALT_RESET) { - posControl.desiredState.pos.z = altitudeToUse; + posControl.desiredState.pos.z = navGetCurrentActualPositionAndVelocity()->pos.z; } else if (mode == ROC_TO_ALT_TARGET) { posControl.desiredState.pos.z = targetAltitude; } @@ -3098,6 +3095,7 @@ void updateClimbRateToAltitudeController(float desiredClimbRate, float targetAlt */ if (navConfig()->general.max_altitude && isMaxAltitudeLimitExceeded() && desiredClimbRate >= 0.0f) { posControl.desiredState.pos.z = MIN(posControl.desiredState.pos.z, navConfig()->general.max_altitude); + posControl.flags.rocToAltMode = ROC_TO_ALT_TARGET; } posControl.desiredState.vel.z = desiredClimbRate; // only used for ROC_TO_ALT_CONSTANT diff --git a/src/main/navigation/navigation_private.h b/src/main/navigation/navigation_private.h index 8452650ffaa..428b54cd4f4 100644 --- a/src/main/navigation/navigation_private.h +++ b/src/main/navigation/navigation_private.h @@ -483,7 +483,7 @@ bool isWaypointNavTrackingActive(void); void updateActualHeading(bool headingValid, int32_t newHeading, int32_t newGroundCourse); void updateActualHorizontalPositionAndVelocity(bool estPosValid, bool estVelValid, float newX, float newY, float newVelX, float newVelY); void updateActualAltitudeAndClimbRate(bool estimateValid, float newAltitude, float newVelocity, float surfaceDistance, float surfaceVelocity, navigationEstimateStatus_e surfaceStatus, float gpsCfEstimatedAltitudeError); -int32_t getDesiredClimbRate(float targetAltitude, timeDelta_t deltaMicros); +float getDesiredClimbRate(float targetAltitude, timeDelta_t deltaMicros); bool checkForPositionSensorTimeout(void); From 1fcac6134a0fa3ad7a27ad1cc16d5096e5082ffd Mon Sep 17 00:00:00 2001 From: breadoven <56191411+breadoven@users.noreply.github.com> Date: Fri, 10 Nov 2023 22:29:19 +0000 Subject: [PATCH 007/241] fix multirotor velocity z --- src/main/navigation/navigation.c | 4 ++-- src/main/navigation/navigation_fixedwing.c | 2 +- src/main/navigation/navigation_multicopter.c | 3 ++- src/main/navigation/navigation_private.h | 1 + 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/navigation/navigation.c b/src/main/navigation/navigation.c index 7505260c889..ded835919dd 100644 --- a/src/main/navigation/navigation.c +++ b/src/main/navigation/navigation.c @@ -3086,6 +3086,8 @@ void updateClimbRateToAltitudeController(float desiredClimbRate, float targetAlt posControl.desiredState.pos.z = navGetCurrentActualPositionAndVelocity()->pos.z; } else if (mode == ROC_TO_ALT_TARGET) { posControl.desiredState.pos.z = targetAltitude; + } else { // ROC_TO_ALT_CONSTANT + posControl.desiredState.climbRateDemand = desiredClimbRate; } posControl.flags.rocToAltMode = mode; @@ -3097,8 +3099,6 @@ void updateClimbRateToAltitudeController(float desiredClimbRate, float targetAlt posControl.desiredState.pos.z = MIN(posControl.desiredState.pos.z, navConfig()->general.max_altitude); posControl.flags.rocToAltMode = ROC_TO_ALT_TARGET; } - - posControl.desiredState.vel.z = desiredClimbRate; // only used for ROC_TO_ALT_CONSTANT } static void resetAltitudeController(bool useTerrainFollowing) diff --git a/src/main/navigation/navigation_fixedwing.c b/src/main/navigation/navigation_fixedwing.c index 0272df114c7..f5c3fb159ae 100755 --- a/src/main/navigation/navigation_fixedwing.c +++ b/src/main/navigation/navigation_fixedwing.c @@ -134,7 +134,7 @@ static void updateAltitudeVelocityAndPitchController_FW(timeDelta_t deltaMicros) { static pt1Filter_t velzFilterState; - float desiredClimbRate = posControl.desiredState.vel.z; + float desiredClimbRate = posControl.desiredState.climbRateDemand; if (posControl.flags.rocToAltMode != ROC_TO_ALT_CONSTANT) { desiredClimbRate = getDesiredClimbRate(posControl.desiredState.pos.z, deltaMicros); diff --git a/src/main/navigation/navigation_multicopter.c b/src/main/navigation/navigation_multicopter.c index 559898eadfd..b35d88c6093 100644 --- a/src/main/navigation/navigation_multicopter.c +++ b/src/main/navigation/navigation_multicopter.c @@ -76,7 +76,7 @@ float getSqrtControllerVelocity(float targetAltitude, timeDelta_t deltaMicros) // Position to velocity controller for Z axis static void updateAltitudeVelocityController_MC(timeDelta_t deltaMicros) { - float targetVel = posControl.desiredState.vel.z; + float targetVel = posControl.desiredState.climbRateDemand; if (posControl.flags.rocToAltMode != ROC_TO_ALT_CONSTANT) { targetVel = getDesiredClimbRate(posControl.desiredState.pos.z, deltaMicros); @@ -249,6 +249,7 @@ static void applyMulticopterAltitudeController(timeUs_t currentTimeUs) if (prepareForTakeoffOnReset) { const navEstimatedPosVel_t *posToUse = navGetCurrentActualPositionAndVelocity(); + posControl.desiredState.vel.z = -navConfig()->general.max_manual_climb_rate; posControl.desiredState.pos.z = posToUse->pos.z - (navConfig()->general.max_manual_climb_rate / posControl.pids.pos[Z].param.kP); posControl.pids.vel[Z].integrator = -500.0f; pt1FilterReset(&altholdThrottleFilterState, -500.0f); diff --git a/src/main/navigation/navigation_private.h b/src/main/navigation/navigation_private.h index 428b54cd4f4..cf4698a24c8 100644 --- a/src/main/navigation/navigation_private.h +++ b/src/main/navigation/navigation_private.h @@ -140,6 +140,7 @@ typedef struct { fpVector3_t pos; fpVector3_t vel; int32_t yaw; + int16_t climbRateDemand; } navigationDesiredState_t; typedef enum { From 87faeb11ee6c25f024cf38832ec22746b9f6ce74 Mon Sep 17 00:00:00 2001 From: breadoven <56191411+breadoven@users.noreply.github.com> Date: Thu, 16 Nov 2023 11:13:21 +0000 Subject: [PATCH 008/241] WP Linear climb + Update max alt limter --- src/main/navigation/navigation.c | 38 ++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/src/main/navigation/navigation.c b/src/main/navigation/navigation.c index ded835919dd..2fd1cfd3256 100644 --- a/src/main/navigation/navigation.c +++ b/src/main/navigation/navigation.c @@ -1691,10 +1691,20 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_WAYPOINT_IN_PROGRESS(na fpVector3_t tmpWaypoint; tmpWaypoint.x = posControl.activeWaypoint.pos.x; tmpWaypoint.y = posControl.activeWaypoint.pos.y; - tmpWaypoint.z = scaleRangef(constrainf(posControl.wpDistance, posControl.wpInitialDistance / 10.0f, posControl.wpInitialDistance), - posControl.wpInitialDistance, posControl.wpInitialDistance / 10.0f, - posControl.wpInitialAltitude, posControl.activeWaypoint.pos.z); - setDesiredPosition(&tmpWaypoint, 0, NAV_POS_UPDATE_XY | NAV_POS_UPDATE_Z | NAV_POS_UPDATE_BEARING); + setDesiredPosition(&tmpWaypoint, 0, NAV_POS_UPDATE_XY | NAV_POS_UPDATE_BEARING); + + // Use linear climb bewtween WPs until within 10% of total distance to current active WP + float linearClimbDistRemaining = posControl.wpDistance - 0.1f * posControl.wpInitialDistance; + if (linearClimbDistRemaining > 0) { + int16_t climbRate = constrainf(posControl.actualState.velXY * + (posControl.activeWaypoint.pos.z - posControl.actualState.abs.pos.z) / linearClimbDistRemaining, + -navConfig()->general.max_auto_climb_rate, + navConfig()->general.max_auto_climb_rate); + updateClimbRateToAltitudeController(climbRate, 0, ROC_TO_ALT_CONSTANT); + } else { + updateClimbRateToAltitudeController(0, posControl.activeWaypoint.pos.z, ROC_TO_ALT_TARGET); + } + if(STATE(MULTIROTOR)) { switch (wpHeadingControl.mode) { case NAV_WP_HEAD_MODE_NONE: @@ -3035,17 +3045,8 @@ bool isProbablyStillFlying(void) /*----------------------------------------------------------- * Z-position controller *-----------------------------------------------------------*/ -static bool isMaxAltitudeLimitExceeded(void) -{ - return navGetCurrentActualPositionAndVelocity()->pos.z >= navConfig()->general.max_altitude; -} - float getDesiredClimbRate(float targetAltitude, timeDelta_t deltaMicros) { - if (navConfig()->general.max_altitude && isMaxAltitudeLimitExceeded()) { - targetAltitude = MIN(targetAltitude, navConfig()->general.max_altitude); - } - const bool emergLandingIsActive = navigationIsExecutingAnEmergencyLanding(); float maxClimbRate = navConfig()->general.max_auto_climb_rate; @@ -3093,11 +3094,16 @@ void updateClimbRateToAltitudeController(float desiredClimbRate, float targetAlt posControl.flags.rocToAltMode = mode; /* - * If max altitude is set and altitude limit reached reset altitude target to max altitude unless desired climb rate is -ve + * If max altitude is set and altitude limit reached reset altitude target to max altitude unless desired climb rate is -ve. + * Inhibit during RTH mode and also WP mode with altitude enforce active to avoid climbs getting stuck at max alt limit. */ - if (navConfig()->general.max_altitude && isMaxAltitudeLimitExceeded() && desiredClimbRate >= 0.0f) { + if (navConfig()->general.max_altitude && !FLIGHT_MODE(NAV_RTH_MODE) && !(FLIGHT_MODE(NAV_WP_MODE) && navConfig()->general.waypoint_enforce_altitude)) { posControl.desiredState.pos.z = MIN(posControl.desiredState.pos.z, navConfig()->general.max_altitude); - posControl.flags.rocToAltMode = ROC_TO_ALT_TARGET; + + if (navGetCurrentActualPositionAndVelocity()->pos.z >= navConfig()->general.max_altitude && desiredClimbRate >= 0.0f) { + posControl.desiredState.pos.z = navConfig()->general.max_altitude; + posControl.flags.rocToAltMode = ROC_TO_ALT_TARGET; + } } } From f521f9895f7781724f37a17ef5a90464a18e5b45 Mon Sep 17 00:00:00 2001 From: breadoven <56191411+breadoven@users.noreply.github.com> Date: Sat, 18 Nov 2023 20:50:04 +0000 Subject: [PATCH 009/241] WP linear climb improvements --- src/main/navigation/navigation.c | 35 +++++++++++++++++--------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/main/navigation/navigation.c b/src/main/navigation/navigation.c index 2fd1cfd3256..eae0be28756 100644 --- a/src/main/navigation/navigation.c +++ b/src/main/navigation/navigation.c @@ -1694,16 +1694,13 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_WAYPOINT_IN_PROGRESS(na setDesiredPosition(&tmpWaypoint, 0, NAV_POS_UPDATE_XY | NAV_POS_UPDATE_BEARING); // Use linear climb bewtween WPs until within 10% of total distance to current active WP - float linearClimbDistRemaining = posControl.wpDistance - 0.1f * posControl.wpInitialDistance; - if (linearClimbDistRemaining > 0) { - int16_t climbRate = constrainf(posControl.actualState.velXY * - (posControl.activeWaypoint.pos.z - posControl.actualState.abs.pos.z) / linearClimbDistRemaining, - -navConfig()->general.max_auto_climb_rate, - navConfig()->general.max_auto_climb_rate); - updateClimbRateToAltitudeController(climbRate, 0, ROC_TO_ALT_CONSTANT); - } else { - updateClimbRateToAltitudeController(0, posControl.activeWaypoint.pos.z, ROC_TO_ALT_TARGET); + float climbRate = posControl.actualState.velXY * (posControl.activeWaypoint.pos.z - posControl.wpInitialAltitude) / + (0.9f * posControl.wpInitialDistance); + + if (fabsf(climbRate) >= navConfig()->general.max_auto_climb_rate) { + climbRate = 0; } + updateClimbRateToAltitudeController(climbRate, posControl.activeWaypoint.pos.z, ROC_TO_ALT_TARGET); if(STATE(MULTIROTOR)) { switch (wpHeadingControl.mode) { @@ -3050,11 +3047,14 @@ float getDesiredClimbRate(float targetAltitude, timeDelta_t deltaMicros) const bool emergLandingIsActive = navigationIsExecutingAnEmergencyLanding(); float maxClimbRate = navConfig()->general.max_auto_climb_rate; - if (emergLandingIsActive) { + if (posControl.desiredState.climbRateDemand) { + maxClimbRate = ABS(posControl.desiredState.climbRateDemand); + } else if (emergLandingIsActive) { maxClimbRate = navConfig()->general.emerg_descent_rate; } else if (posControl.flags.isAdjustingAltitude) { maxClimbRate = navConfig()->general.max_manual_climb_rate; } + const float targetAltitudeError = targetAltitude - navGetCurrentActualPositionAndVelocity()->pos.z; float targetVel = 0.0f; @@ -3076,7 +3076,7 @@ void updateClimbRateToAltitudeController(float desiredClimbRate, float targetAlt { /* ROC_TO_ALT_TARGET - constant climb rate until close to target altitude reducing to 0 when reached. * Rate reduction starts at distance from target altitude of 5 x climb rate for Fixed wing. - * No climb rate required, set by target altitude direction instead. + * Any non zero climb rate sets the max allowed climb rate. Default max climb rate limits are used when set to 0. * * ROC_TO_ALT_RESET - similar to ROC_TO_ALT_TARGET except target altitude set to current altitude. * No climb rate or altitude target required. @@ -3087,21 +3087,24 @@ void updateClimbRateToAltitudeController(float desiredClimbRate, float targetAlt posControl.desiredState.pos.z = navGetCurrentActualPositionAndVelocity()->pos.z; } else if (mode == ROC_TO_ALT_TARGET) { posControl.desiredState.pos.z = targetAltitude; - } else { // ROC_TO_ALT_CONSTANT - posControl.desiredState.climbRateDemand = desiredClimbRate; } + posControl.desiredState.climbRateDemand = desiredClimbRate; posControl.flags.rocToAltMode = mode; /* - * If max altitude is set and altitude limit reached reset altitude target to max altitude unless desired climb rate is -ve. + * If max altitude is set limit desired altitude and impose altitude limit for constant climbs unless climb rate is -ve. * Inhibit during RTH mode and also WP mode with altitude enforce active to avoid climbs getting stuck at max alt limit. */ if (navConfig()->general.max_altitude && !FLIGHT_MODE(NAV_RTH_MODE) && !(FLIGHT_MODE(NAV_WP_MODE) && navConfig()->general.waypoint_enforce_altitude)) { posControl.desiredState.pos.z = MIN(posControl.desiredState.pos.z, navConfig()->general.max_altitude); - if (navGetCurrentActualPositionAndVelocity()->pos.z >= navConfig()->general.max_altitude && desiredClimbRate >= 0.0f) { - posControl.desiredState.pos.z = navConfig()->general.max_altitude; + if (mode == ROC_TO_ALT_TARGET || (mode == ROC_TO_ALT_CONSTANT && desiredClimbRate < 0.0f)) { + return; + } + + if (navGetCurrentActualPositionAndVelocity()->pos.z > navConfig()->general.max_altitude) { + posControl.desiredState.climbRateDemand = 0; posControl.flags.rocToAltMode = ROC_TO_ALT_TARGET; } } From 49715f8c22ac154d7cfc0486fcf540cfbb3c8be8 Mon Sep 17 00:00:00 2001 From: breadoven <56191411+breadoven@users.noreply.github.com> Date: Sun, 19 Nov 2023 21:52:58 +0000 Subject: [PATCH 010/241] Improvements --- src/main/navigation/navigation.c | 17 ++++++++++------- src/main/navigation/navigation_private.h | 1 - 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/navigation/navigation.c b/src/main/navigation/navigation.c index eae0be28756..b10a7dc6fe4 100644 --- a/src/main/navigation/navigation.c +++ b/src/main/navigation/navigation.c @@ -1627,7 +1627,6 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_WAYPOINT_PRE_ACTION(nav case NAV_WP_ACTION_LAND: calculateAndSetActiveWaypoint(&posControl.waypointList[posControl.activeWaypointIndex]); posControl.wpInitialDistance = calculateDistanceToDestination(&posControl.activeWaypoint.pos); - posControl.wpInitialAltitude = posControl.actualState.abs.pos.z; posControl.wpAltitudeReached = false; return NAV_FSM_EVENT_SUCCESS; // will switch to NAV_STATE_WAYPOINT_IN_PROGRESS @@ -1693,9 +1692,13 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_WAYPOINT_IN_PROGRESS(na tmpWaypoint.y = posControl.activeWaypoint.pos.y; setDesiredPosition(&tmpWaypoint, 0, NAV_POS_UPDATE_XY | NAV_POS_UPDATE_BEARING); - // Use linear climb bewtween WPs until within 10% of total distance to current active WP - float climbRate = posControl.actualState.velXY * (posControl.activeWaypoint.pos.z - posControl.wpInitialAltitude) / - (0.9f * posControl.wpInitialDistance); + // Use linear climb between WPs arriving at WP altitude when within 10% of total distance to WP + // Update climbrate until within 25% of total distance to WP, then hold constant + static float climbRate = 0; + if (posControl.wpDistance > 0.25f * posControl.wpInitialDistance) { + climbRate = posControl.actualState.velXY * (posControl.activeWaypoint.pos.z - posControl.actualState.abs.pos.z) / + (posControl.wpDistance - 0.1f * posControl.wpInitialDistance); + } if (fabsf(climbRate) >= navConfig()->general.max_auto_climb_rate) { climbRate = 0; @@ -3099,12 +3102,12 @@ void updateClimbRateToAltitudeController(float desiredClimbRate, float targetAlt if (navConfig()->general.max_altitude && !FLIGHT_MODE(NAV_RTH_MODE) && !(FLIGHT_MODE(NAV_WP_MODE) && navConfig()->general.waypoint_enforce_altitude)) { posControl.desiredState.pos.z = MIN(posControl.desiredState.pos.z, navConfig()->general.max_altitude); - if (mode == ROC_TO_ALT_TARGET || (mode == ROC_TO_ALT_CONSTANT && desiredClimbRate < 0.0f)) { + if (mode != ROC_TO_ALT_CONSTANT || (mode == ROC_TO_ALT_CONSTANT && desiredClimbRate < 0.0f)) { return; } - if (navGetCurrentActualPositionAndVelocity()->pos.z > navConfig()->general.max_altitude) { - posControl.desiredState.climbRateDemand = 0; + if (posControl.flags.isAdjustingAltitude) { + posControl.desiredState.pos.z = navConfig()->general.max_altitude; posControl.flags.rocToAltMode = ROC_TO_ALT_TARGET; } } diff --git a/src/main/navigation/navigation_private.h b/src/main/navigation/navigation_private.h index cf4698a24c8..3a669443835 100644 --- a/src/main/navigation/navigation_private.h +++ b/src/main/navigation/navigation_private.h @@ -423,7 +423,6 @@ typedef struct { #endif navWaypointPosition_t activeWaypoint; // Local position, current bearing and turn angle to next WP, filled on waypoint activation int8_t activeWaypointIndex; - float wpInitialAltitude; // Altitude at start of WP float wpInitialDistance; // Distance when starting flight to WP float wpDistance; // Distance to active WP timeMs_t wpReachedTime; // Time the waypoint was reached From dbd1ed103976b748a8fb4ceeafbbc121a067a2ad Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Mon, 4 Dec 2023 12:30:01 +0100 Subject: [PATCH 011/241] IFLIGHT_2RAW_H743 --- .../target/IFLIGHT_2RAW_H743/CMakeLists.txt | 1 + src/main/target/IFLIGHT_2RAW_H743/config.c | 31 ++++ src/main/target/IFLIGHT_2RAW_H743/target.c | 49 ++++++ src/main/target/IFLIGHT_2RAW_H743/target.h | 165 ++++++++++++++++++ 4 files changed, 246 insertions(+) create mode 100644 src/main/target/IFLIGHT_2RAW_H743/CMakeLists.txt create mode 100644 src/main/target/IFLIGHT_2RAW_H743/config.c create mode 100644 src/main/target/IFLIGHT_2RAW_H743/target.c create mode 100644 src/main/target/IFLIGHT_2RAW_H743/target.h diff --git a/src/main/target/IFLIGHT_2RAW_H743/CMakeLists.txt b/src/main/target/IFLIGHT_2RAW_H743/CMakeLists.txt new file mode 100644 index 00000000000..6a430dc6758 --- /dev/null +++ b/src/main/target/IFLIGHT_2RAW_H743/CMakeLists.txt @@ -0,0 +1 @@ +target_stm32h743xi(IFLIGHT_2RAW_H743) diff --git a/src/main/target/IFLIGHT_2RAW_H743/config.c b/src/main/target/IFLIGHT_2RAW_H743/config.c new file mode 100644 index 00000000000..0f1fec5a816 --- /dev/null +++ b/src/main/target/IFLIGHT_2RAW_H743/config.c @@ -0,0 +1,31 @@ +/* + * 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 "fc/fc_msp_box.h" +#include "fc/config.h" + +#include "io/piniobox.h" + +void targetConfiguration(void) +{ + pinioBoxConfigMutable()->permanentId[0] = BOX_PERMANENT_ID_USER1; + pinioBoxConfigMutable()->permanentId[1] = BOX_PERMANENT_ID_USER2; +} diff --git a/src/main/target/IFLIGHT_2RAW_H743/target.c b/src/main/target/IFLIGHT_2RAW_H743/target.c new file mode 100644 index 00000000000..23dd0e0c37a --- /dev/null +++ b/src/main/target/IFLIGHT_2RAW_H743/target.c @@ -0,0 +1,49 @@ +/* + * This file is part of INAV. + * + * INAV 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. + * + * INAV 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 INAV. If not, see . + */ + +#include + +#include "platform.h" + +#include "drivers/bus.h" +#include "drivers/io.h" +#include "drivers/pwm_mapping.h" +#include "drivers/timer.h" +#include "drivers/pinio.h" +#include "drivers/sensor.h" + +timerHardware_t timerHardware[] = { + DEF_TIM(TIM3, CH3, PB0, TIM_USE_OUTPUT_AUTO, 0, 0), // S1 + DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 1), // S2 + + DEF_TIM(TIM5, CH1, PA0, TIM_USE_OUTPUT_AUTO, 0, 2), // S3 + DEF_TIM(TIM5, CH2, PA1, TIM_USE_OUTPUT_AUTO, 0, 3), // S4 + DEF_TIM(TIM5, CH3, PA2, TIM_USE_OUTPUT_AUTO, 0, 4), // S5 + DEF_TIM(TIM5, CH4, PA3, TIM_USE_OUTPUT_AUTO, 0, 5), // S6 + + DEF_TIM(TIM4, CH1, PD12, TIM_USE_OUTPUT_AUTO, 0, 6), // S7 + DEF_TIM(TIM4, CH2, PD13, TIM_USE_OUTPUT_AUTO, 0, 7), // S8 + DEF_TIM(TIM4, CH3, PD14, TIM_USE_OUTPUT_AUTO, 0, 0), // S9 + DEF_TIM(TIM4, CH4, PD15, TIM_USE_OUTPUT_AUTO, 0, 0), // S10 DMA_NONE + + DEF_TIM(TIM15, CH1, PE5, TIM_USE_OUTPUT_AUTO, 0, 0), // S11 + DEF_TIM(TIM15, CH2, PE6, TIM_USE_OUTPUT_AUTO, 0, 0), // S12 DMA_NONE + + DEF_TIM(TIM1, CH1, PA8, TIM_USE_LED, 0, 9), // LED_2812 +}; + +const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]); diff --git a/src/main/target/IFLIGHT_2RAW_H743/target.h b/src/main/target/IFLIGHT_2RAW_H743/target.h new file mode 100644 index 00000000000..f0cf03e33da --- /dev/null +++ b/src/main/target/IFLIGHT_2RAW_H743/target.h @@ -0,0 +1,165 @@ +/* + * This file is part of INAV. + * + * INAV 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. + * + * INAV 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 INAV. If not, see . + */ + + +#pragma once + +#define TARGET_BOARD_IDENTIFIER "2RH7" + +#define USBD_PRODUCT_STRING "IFLIGHT_2RAW_H743" + +#define LED0 PE3 +#define LED1 PE4 + +#define BEEPER PC9 +#define BEEPER_INVERTED + +// SPI Buses +#define USE_SPI + +#define USE_SPI_DEVICE_1 +#define SPI1_SCK_PIN PA5 +#define SPI1_MISO_PIN PA6 +#define SPI1_MOSI_PIN PD7 + +#define USE_SPI_DEVICE_2 +#define SPI2_SCK_PIN PB13 +#define SPI2_MISO_PIN PB14 +#define SPI2_MOSI_PIN PB15 + +#define USE_SPI_DEVICE_3 +#define SPI3_SCK_PIN PC10 +#define SPI3_MISO_PIN PC11 +#define SPI3_MOSI_PIN PC12 + +// I2C +#define USE_I2C +#define USE_I2C_DEVICE_1 +#define I2C1_SCL PB6 +#define I2C1_SDA PB7 + +#define USE_I2C_DEVICE_2 +#define I2C2_SCL PB10 +#define I2C2_SDA PB11 + +// Gyro +#define USE_IMU_ICM42605 +#define IMU_ICM42605_ALIGN CW90_DEG +#define ICM42605_SPI_BUS BUS_SPI1 +#define ICM42605_CS_PIN PC15 + +// OSD +// #define USE_MAX7456 +// #define MAX7456_SPI_BUS BUS_SPI2 +// #define MAX7456_CS_PIN PB12 + +#define USE_BARO +#define BARO_I2C_BUS BUS_I2C2 +#define USE_BARO_ALL + +#define USE_MAG +#define MAG_I2C_BUS BUS_I2C1 +#define USE_MAG_ALL + +#define TEMPERATURE_I2C_BUS BUS_I2C1 +#define PITOT_I2C_BUS BUS_I2C1 +#define RANGEFINDER_I2C_BUS BUS_I2C1 + +// *************** UART ***************************** +#define USE_VCP + +#define USE_UART1 +#define UART1_TX_PIN PA9 +#define UART1_RX_PIN PA10 + +#define USE_UART2 +#define UART2_TX_PIN PD5 +#define UART2_RX_PIN PD6 + +#define USE_UART3 +#define UART3_TX_PIN PD8 +#define UART3_RX_PIN PD9 + +#define USE_UART4 +#define UART4_TX_PIN PB9 +#define UART4_RX_PIN PB8 + +#define USE_UART6 +#define UART6_TX_PIN PC6 +#define UART6_RX_PIN PC7 + +#define USE_UART7 +#define UART7_TX_PIN PE8 +#define UART7_RX_PIN PE7 + +#define USE_UART8 +#define UART8_TX_PIN PE1 +#define UART8_RX_PIN PE0 + +#define SERIAL_PORT_COUNT 8 + +#define DEFAULT_RX_TYPE RX_TYPE_SERIAL +#define SERIALRX_PROVIDER SERIALRX_CRSF +#define SERIALRX_UART SERIAL_PORT_USART6 + +// SD Card +#define USE_SDCARD +#define USE_SDCARD_SPI +#define SDCARD_SPI_BUS BUS_SPI3 +#define SDCARD_CS_PIN PA15 + +#define ENABLE_BLACKBOX_LOGGING_ON_SDCARD_BY_DEFAULT + +// ADC +#define USE_ADC +#define ADC_INSTANCE ADC1 + +#define ADC_CHANNEL_1_PIN PC0 +#define ADC_CHANNEL_2_PIN PC1 +#define ADC_CHANNEL_3_PIN PC5 +#define ADC_CHANNEL_4_PIN PC4 + +#define VBAT_ADC_CHANNEL ADC_CHN_1 +#define CURRENT_METER_ADC_CHANNEL ADC_CHN_2 +#define RSSI_ADC_CHANNEL ADC_CHN_3 +#define AIRSPEED_ADC_CHANNEL ADC_CHN_4 + +// PINIO +#define USE_PINIO +#define USE_PINIOBOX +#define PINIO1_PIN PD10 +#define PINIO2_PIN PD11 + +// *************** LEDSTRIP ************************ +// #define USE_LED_STRIP +// #define WS2811_PIN PA8 + +#define DEFAULT_FEATURES (FEATURE_OSD | FEATURE_TELEMETRY | FEATURE_CURRENT_METER | FEATURE_VBAT | FEATURE_TX_PROF_SEL | FEATURE_BLACKBOX) +#define CURRENT_METER_SCALE 250 + +#define USE_SERIAL_4WAY_BLHELI_INTERFACE + +#define TARGET_IO_PORTA 0xffff +#define TARGET_IO_PORTB 0xffff +#define TARGET_IO_PORTC 0xffff +#define TARGET_IO_PORTD 0xffff +#define TARGET_IO_PORTE 0xffff + +#define MAX_PWM_OUTPUT_PORTS 12 +#define USE_DSHOT +#define USE_ESC_SENSOR + From d6de35bf8b334032c9eb44264ed6baa8e98967ae Mon Sep 17 00:00:00 2001 From: breadoven <56191411+breadoven@users.noreply.github.com> Date: Wed, 6 Dec 2023 22:46:06 +0000 Subject: [PATCH 012/241] add control response setting --- docs/Settings.md | 10 ++++++++++ src/main/fc/settings.yaml | 6 ++++++ src/main/flight/pid.c | 9 +++++---- src/main/flight/pid.h | 2 ++ src/main/navigation/navigation.c | 6 ++---- 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/docs/Settings.md b/docs/Settings.md index 17384f92732..7b58d96cdbe 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -2842,6 +2842,16 @@ Enable the possibility to manually increase the throttle in auto throttle contro --- +### nav_fw_alt_control_response + +Adjusts the deceleration response of fixed wing altitude control as the target altitude is approached. Decrease value to help avoid overshooting the target altitude. + +| Default | Min | Max | +| --- | --- | --- | +| 20 | 5 | 100 | + +--- + ### nav_fw_bank_angle Max roll angle when rolling / turning in GPS assisted modes, is also restrained by global max_angle_inclination_rll diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index 4f870fa8f7a..8ce69c23123 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -2087,6 +2087,12 @@ groups: field: bank_fw.pid[PID_POS_Z].D min: 0 max: 255 + - name: nav_fw_alt_control_response + description: "Adjusts the deceleration response of fixed wing altitude control as the target altitude is approached. Decrease value to help avoid overshooting the target altitude." + default_value: 20 + field: fwAltControlResponseFactor + min: 5 + max: 100 - name: nav_fw_pos_xy_p description: "P gain of 2D trajectory PID controller. Play with this to get a straight line between waypoints or a straight RTH" default_value: 75 diff --git a/src/main/flight/pid.c b/src/main/flight/pid.c index bc794735eb2..9bae1799e45 100644 --- a/src/main/flight/pid.c +++ b/src/main/flight/pid.c @@ -170,7 +170,7 @@ static EXTENDED_FASTRAM bool angleHoldIsLevel = false; static EXTENDED_FASTRAM float fixedWingLevelTrim; static EXTENDED_FASTRAM pidController_t fixedWingLevelTrimController; -PG_REGISTER_PROFILE_WITH_RESET_TEMPLATE(pidProfile_t, pidProfile, PG_PID_PROFILE, 6); +PG_REGISTER_PROFILE_WITH_RESET_TEMPLATE(pidProfile_t, pidProfile, PG_PID_PROFILE, 7); PG_RESET_TEMPLATE(pidProfile_t, pidProfile, .bank_mc = { @@ -231,9 +231,9 @@ PG_RESET_TEMPLATE(pidProfile_t, pidProfile, }, [PID_HEADING] = { SETTING_NAV_FW_HEADING_P_DEFAULT, 0, 0, 0 }, [PID_POS_Z] = { - .P = SETTING_NAV_FW_POS_Z_P_DEFAULT, // FW_POS_Z_P * 10 - .I = SETTING_NAV_FW_POS_Z_I_DEFAULT, // FW_POS_Z_I * 10 - .D = SETTING_NAV_FW_POS_Z_D_DEFAULT, // FW_POS_Z_D * 10 + .P = SETTING_NAV_FW_POS_Z_P_DEFAULT, // FW_POS_Z_P * 100 + .I = SETTING_NAV_FW_POS_Z_I_DEFAULT, // FW_POS_Z_I * 100 + .D = SETTING_NAV_FW_POS_Z_D_DEFAULT, // FW_POS_Z_D * 100 .FF = 0, }, [PID_POS_XY] = { @@ -301,6 +301,7 @@ PG_RESET_TEMPLATE(pidProfile_t, pidProfile, .fixedWingLevelTrim = SETTING_FW_LEVEL_PITCH_TRIM_DEFAULT, .fixedWingLevelTrimGain = SETTING_FW_LEVEL_PITCH_GAIN_DEFAULT, + .fwAltControlResponseFactor = SETTING_NAV_FW_ALT_CONTROL_RESPONSE_DEFAULT, #ifdef USE_SMITH_PREDICTOR .smithPredictorStrength = SETTING_SMITH_PREDICTOR_STRENGTH_DEFAULT, .smithPredictorDelay = SETTING_SMITH_PREDICTOR_DELAY_DEFAULT, diff --git a/src/main/flight/pid.h b/src/main/flight/pid.h index e0a8b9d310b..3f3658ae162 100644 --- a/src/main/flight/pid.h +++ b/src/main/flight/pid.h @@ -151,6 +151,8 @@ typedef struct pidProfile_s { float fixedWingLevelTrim; float fixedWingLevelTrimGain; + + uint8_t fwAltControlResponseFactor; #ifdef USE_SMITH_PREDICTOR float smithPredictorStrength; float smithPredictorDelay; diff --git a/src/main/navigation/navigation.c b/src/main/navigation/navigation.c index b10a7dc6fe4..8fbe4c07854 100644 --- a/src/main/navigation/navigation.c +++ b/src/main/navigation/navigation.c @@ -3064,8 +3064,7 @@ float getDesiredClimbRate(float targetAltitude, timeDelta_t deltaMicros) if (STATE(MULTIROTOR)) { targetVel = getSqrtControllerVelocity(targetAltitude, deltaMicros); } else { - // 0.2f relates to climb rate starting to reduce from maxClimbRate at a distance of 5 x maxClimbRate from targetAltitude - targetVel = 0.2f * targetAltitudeError; + targetVel = pidProfile()->fwAltControlResponseFactor * targetAltitudeError / 100.0f; } if (emergLandingIsActive && targetAltitudeError > -50) { @@ -3077,8 +3076,7 @@ float getDesiredClimbRate(float targetAltitude, timeDelta_t deltaMicros) void updateClimbRateToAltitudeController(float desiredClimbRate, float targetAltitude, climbRateToAltitudeControllerMode_e mode) { - /* ROC_TO_ALT_TARGET - constant climb rate until close to target altitude reducing to 0 when reached. - * Rate reduction starts at distance from target altitude of 5 x climb rate for Fixed wing. + /* ROC_TO_ALT_TARGET - constant climb rate until close to target altitude then reducing down as altitude is reached. * Any non zero climb rate sets the max allowed climb rate. Default max climb rate limits are used when set to 0. * * ROC_TO_ALT_RESET - similar to ROC_TO_ALT_TARGET except target altitude set to current altitude. From 3378bcd8179296790969cf35ba0e6083280270f4 Mon Sep 17 00:00:00 2001 From: breadoven <56191411+breadoven@users.noreply.github.com> Date: Mon, 11 Dec 2023 10:48:52 +0000 Subject: [PATCH 013/241] change alt reset to alt current --- src/main/navigation/navigation.c | 6 +++--- src/main/navigation/navigation_fixedwing.c | 2 +- src/main/navigation/navigation_multicopter.c | 2 +- src/main/navigation/navigation_private.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/navigation/navigation.c b/src/main/navigation/navigation.c index 8fbe4c07854..3ca2d126e99 100644 --- a/src/main/navigation/navigation.c +++ b/src/main/navigation/navigation.c @@ -1474,7 +1474,7 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_HOVER_PRIOR_TO_LAND // Wait until target heading is reached for MR (with 15 deg margin for error), or continue for Fixed Wing if ((ABS(wrap_18000(posControl.rthState.homePosition.heading - posControl.actualState.yaw)) < DEGREES_TO_CENTIDEGREES(15)) || STATE(FIXED_WING_LEGACY)) { resetLandingDetector(); // force reset landing detector just in case - updateClimbRateToAltitudeController(0, 0, ROC_TO_ALT_RESET); + updateClimbRateToAltitudeController(0, 0, ROC_TO_ALT_CURRENT); return navigationRTHAllowsLanding() ? NAV_FSM_EVENT_SUCCESS : NAV_FSM_EVENT_SWITCH_TO_RTH_HOVER_ABOVE_HOME; // success = land } else { fpVector3_t * tmpHomePos = rthGetHomeTargetPosition(RTH_HOME_ENROUTE_FINAL); @@ -3079,12 +3079,12 @@ void updateClimbRateToAltitudeController(float desiredClimbRate, float targetAlt /* ROC_TO_ALT_TARGET - constant climb rate until close to target altitude then reducing down as altitude is reached. * Any non zero climb rate sets the max allowed climb rate. Default max climb rate limits are used when set to 0. * - * ROC_TO_ALT_RESET - similar to ROC_TO_ALT_TARGET except target altitude set to current altitude. + * ROC_TO_ALT_CURRENT - similar to ROC_TO_ALT_TARGET except target altitude set to current altitude. * No climb rate or altitude target required. * * ROC_TO_ALT_CONSTANT - constant climb rate. Climb rate and direction required. Target alt not required. */ - if (mode == ROC_TO_ALT_RESET) { + if (mode == ROC_TO_ALT_CURRENT) { posControl.desiredState.pos.z = navGetCurrentActualPositionAndVelocity()->pos.z; } else if (mode == ROC_TO_ALT_TARGET) { posControl.desiredState.pos.z = targetAltitude; diff --git a/src/main/navigation/navigation_fixedwing.c b/src/main/navigation/navigation_fixedwing.c index f5c3fb159ae..3d66f7d7d32 100755 --- a/src/main/navigation/navigation_fixedwing.c +++ b/src/main/navigation/navigation_fixedwing.c @@ -123,7 +123,7 @@ bool adjustFixedWingAltitudeFromRCInput(void) else { // Adjusting finished - reset desired position to stay exactly where pilot released the stick if (posControl.flags.isAdjustingAltitude) { - updateClimbRateToAltitudeController(0, 0, ROC_TO_ALT_RESET); + updateClimbRateToAltitudeController(0, 0, ROC_TO_ALT_CURRENT); } return false; } diff --git a/src/main/navigation/navigation_multicopter.c b/src/main/navigation/navigation_multicopter.c index b35d88c6093..d2bc457f340 100644 --- a/src/main/navigation/navigation_multicopter.c +++ b/src/main/navigation/navigation_multicopter.c @@ -162,7 +162,7 @@ bool adjustMulticopterAltitudeFromRCInput(void) else { // Adjusting finished - reset desired position to stay exactly where pilot released the stick if (posControl.flags.isAdjustingAltitude) { - updateClimbRateToAltitudeController(0, 0, ROC_TO_ALT_RESET); + updateClimbRateToAltitudeController(0, 0, ROC_TO_ALT_CURRENT); } return false; diff --git a/src/main/navigation/navigation_private.h b/src/main/navigation/navigation_private.h index 3a669443835..664787decff 100644 --- a/src/main/navigation/navigation_private.h +++ b/src/main/navigation/navigation_private.h @@ -60,7 +60,7 @@ typedef enum { } navSetWaypointFlags_t; typedef enum { - ROC_TO_ALT_RESET, + ROC_TO_ALT_CURRENT, ROC_TO_ALT_CONSTANT, ROC_TO_ALT_TARGET } climbRateToAltitudeControllerMode_e; From f4ab90d0151f79469db4804c2ec365817a340c80 Mon Sep 17 00:00:00 2001 From: Martin Luessi Date: Mon, 11 Dec 2023 13:53:36 -0800 Subject: [PATCH 014/241] PINIO: Fix inverted pin handling --- src/main/drivers/pinio.c | 6 ++---- src/main/drivers/pinio.h | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/drivers/pinio.c b/src/main/drivers/pinio.c index 69968ddb7d9..3e89e5fccca 100644 --- a/src/main/drivers/pinio.c +++ b/src/main/drivers/pinio.c @@ -100,16 +100,14 @@ void pinioInit(void) } } -void pinioSet(int index, bool on) +void pinioSet(int index, bool newState) { - const bool newState = on ^ pinioRuntime[index].inverted; - if (!pinioRuntime[index].io) { return; } if (newState != pinioRuntime[index].state) { - IOWrite(pinioRuntime[index].io, newState); + IOWrite(pinioRuntime[index].io, newState ^ pinioRuntime[index].inverted); pinioRuntime[index].state = newState; } } diff --git a/src/main/drivers/pinio.h b/src/main/drivers/pinio.h index baecc35a181..a1de21c12de 100644 --- a/src/main/drivers/pinio.h +++ b/src/main/drivers/pinio.h @@ -38,4 +38,4 @@ extern const pinioHardware_t pinioHardware[]; extern const int pinioHardwareCount; void pinioInit(void); -void pinioSet(int index, bool on); +void pinioSet(int index, bool newState); From dde9aabfc69cc46875dce08b98056e5fe06ac786 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Tue, 2 Jan 2024 17:21:43 +0100 Subject: [PATCH 015/241] Target update --- src/main/target/IFLIGHT_2RAW_H743/CMakeLists.txt | 1 - src/main/target/IFLIGHT_BLITZ_H7_PRO/CMakeLists.txt | 1 + .../{IFLIGHT_2RAW_H743 => IFLIGHT_BLITZ_H7_PRO}/config.c | 0 .../{IFLIGHT_2RAW_H743 => IFLIGHT_BLITZ_H7_PRO}/target.c | 0 .../{IFLIGHT_2RAW_H743 => IFLIGHT_BLITZ_H7_PRO}/target.h | 4 ++-- 5 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 src/main/target/IFLIGHT_2RAW_H743/CMakeLists.txt create mode 100644 src/main/target/IFLIGHT_BLITZ_H7_PRO/CMakeLists.txt rename src/main/target/{IFLIGHT_2RAW_H743 => IFLIGHT_BLITZ_H7_PRO}/config.c (100%) rename src/main/target/{IFLIGHT_2RAW_H743 => IFLIGHT_BLITZ_H7_PRO}/target.c (100%) rename src/main/target/{IFLIGHT_2RAW_H743 => IFLIGHT_BLITZ_H7_PRO}/target.h (97%) diff --git a/src/main/target/IFLIGHT_2RAW_H743/CMakeLists.txt b/src/main/target/IFLIGHT_2RAW_H743/CMakeLists.txt deleted file mode 100644 index 6a430dc6758..00000000000 --- a/src/main/target/IFLIGHT_2RAW_H743/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -target_stm32h743xi(IFLIGHT_2RAW_H743) diff --git a/src/main/target/IFLIGHT_BLITZ_H7_PRO/CMakeLists.txt b/src/main/target/IFLIGHT_BLITZ_H7_PRO/CMakeLists.txt new file mode 100644 index 00000000000..acea488c750 --- /dev/null +++ b/src/main/target/IFLIGHT_BLITZ_H7_PRO/CMakeLists.txt @@ -0,0 +1 @@ +target_stm32h743xi(IFLIGHT_BLITZ_H7_PRO) diff --git a/src/main/target/IFLIGHT_2RAW_H743/config.c b/src/main/target/IFLIGHT_BLITZ_H7_PRO/config.c similarity index 100% rename from src/main/target/IFLIGHT_2RAW_H743/config.c rename to src/main/target/IFLIGHT_BLITZ_H7_PRO/config.c diff --git a/src/main/target/IFLIGHT_2RAW_H743/target.c b/src/main/target/IFLIGHT_BLITZ_H7_PRO/target.c similarity index 100% rename from src/main/target/IFLIGHT_2RAW_H743/target.c rename to src/main/target/IFLIGHT_BLITZ_H7_PRO/target.c diff --git a/src/main/target/IFLIGHT_2RAW_H743/target.h b/src/main/target/IFLIGHT_BLITZ_H7_PRO/target.h similarity index 97% rename from src/main/target/IFLIGHT_2RAW_H743/target.h rename to src/main/target/IFLIGHT_BLITZ_H7_PRO/target.h index f0cf03e33da..97116c078fb 100644 --- a/src/main/target/IFLIGHT_2RAW_H743/target.h +++ b/src/main/target/IFLIGHT_BLITZ_H7_PRO/target.h @@ -18,9 +18,9 @@ #pragma once -#define TARGET_BOARD_IDENTIFIER "2RH7" +#define TARGET_BOARD_IDENTIFIER "IH7P" -#define USBD_PRODUCT_STRING "IFLIGHT_2RAW_H743" +#define USBD_PRODUCT_STRING "IFLIGHT_BLITZ_H7_PRO" #define LED0 PE3 #define LED1 PE4 From 363d071c34b688189a13afcbe1b2bd38956b1b76 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Tue, 9 Jan 2024 18:33:27 +0100 Subject: [PATCH 016/241] Target updates for iFlight Blitz H7 Pro --- src/main/target/IFLIGHT_BLITZ_H7_PRO/target.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/target/IFLIGHT_BLITZ_H7_PRO/target.h b/src/main/target/IFLIGHT_BLITZ_H7_PRO/target.h index 97116c078fb..cc3205fd68d 100644 --- a/src/main/target/IFLIGHT_BLITZ_H7_PRO/target.h +++ b/src/main/target/IFLIGHT_BLITZ_H7_PRO/target.h @@ -58,7 +58,7 @@ // Gyro #define USE_IMU_ICM42605 -#define IMU_ICM42605_ALIGN CW90_DEG +#define IMU_ICM42605_ALIGN CW0_DEG #define ICM42605_SPI_BUS BUS_SPI1 #define ICM42605_CS_PIN PC15 @@ -138,6 +138,8 @@ #define RSSI_ADC_CHANNEL ADC_CHN_3 #define AIRSPEED_ADC_CHANNEL ADC_CHN_4 +#define VBAT_SCALE_DEFAULT 2100 + // PINIO #define USE_PINIO #define USE_PINIOBOX From afc87d24a35d86a08a3d1a3c3c5ef355dd0a8482 Mon Sep 17 00:00:00 2001 From: druckgott Date: Sat, 18 Nov 2023 20:01:24 +0100 Subject: [PATCH 017/241] add some icons for O3 with integra for ESP32 Radar instead of ? Add some icons for ESP32Radar instead of have ?. Update displayport_msp_bf_compat.c fix some ; --- src/main/io/displayport_msp_bf_compat.c | 42 +++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/main/io/displayport_msp_bf_compat.c b/src/main/io/displayport_msp_bf_compat.c index 4229e035b03..dd120a2295d 100644 --- a/src/main/io/displayport_msp_bf_compat.c +++ b/src/main/io/displayport_msp_bf_compat.c @@ -578,6 +578,48 @@ uint8_t getBfCharacter(uint8_t ch, uint8_t page) case (SYM_AH_V_START+4): case (SYM_AH_V_START+5): return BF_SYM_AH_BAR9_4; + + // BF for ESP_RADAR Symbols + case SYM_HUD_CARDINAL: + return BF_SYM_ARROW_SOUTH; + case SYM_HUD_CARDINAL + 1: + return BF_SYM_ARROW_16; + case SYM_HUD_CARDINAL + 2: + return BF_SYM_ARROW_15; + case SYM_HUD_CARDINAL + 3: + return BF_SYM_ARROW_WEST; + case SYM_HUD_CARDINAL + 4: + return BF_SYM_ARROW_12; + case SYM_HUD_CARDINAL + 5: + return BF_SYM_ARROW_11; + case SYM_HUD_CARDINAL + 6: + return BF_SYM_ARROW_NORTH; + case SYM_HUD_CARDINAL + 7: + return BF_SYM_ARROW_7; + case SYM_HUD_CARDINAL + 8: + return BF_SYM_ARROW_6; + case SYM_HUD_CARDINAL + 9: + return BF_SYM_ARROW_EAST; + case SYM_HUD_CARDINAL + 10: + return BF_SYM_ARROW_3; + case SYM_HUD_CARDINAL + 11: + return BF_SYM_ARROW_2; + + case SYM_HUD_ARROWS_R3: + return BF_SYM_AH_RIGHT; + case SYM_HUD_ARROWS_L3: + return BF_SYM_AH_LEFT; + + case SYM_HUD_SIGNAL_0: + return BF_SYM_AH_BAR9_1; + case SYM_HUD_SIGNAL_1: + return BF_SYM_AH_BAR9_3; + case SYM_HUD_SIGNAL_2: + return BF_SYM_AH_BAR9_4; + case SYM_HUD_SIGNAL_3: + return BF_SYM_AH_BAR9_5; + case SYM_HUD_SIGNAL_4: + return BF_SYM_AH_BAR9_7; /* case SYM_VARIO_UP_2A: return BF_SYM_VARIO_UP_2A; From 7caf60c91f07572031251c1d2440968e2796b8dd Mon Sep 17 00:00:00 2001 From: shota Date: Thu, 10 Aug 2023 01:07:48 +0900 Subject: [PATCH 018/241] trial --- src/main/flight/mixer.c | 5 +++++ src/main/flight/mixer.h | 3 ++- src/main/flight/pid.c | 12 +++++++++++- src/main/flight/servos.c | 2 +- src/main/telemetry/mavlink.c | 3 +++ 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/main/flight/mixer.c b/src/main/flight/mixer.c index 35674c1f5dc..d0d93a3348a 100644 --- a/src/main/flight/mixer.c +++ b/src/main/flight/mixer.c @@ -161,6 +161,7 @@ void mixerUpdateStateFlags(void) DISABLE_STATE(BOAT); DISABLE_STATE(AIRPLANE); DISABLE_STATE(MOVE_FORWARD_ONLY); + DISABLE_STATE(TAILSITTER); if (currentMixerConfig.platformType == PLATFORM_AIRPLANE) { ENABLE_STATE(FIXED_WING_LEGACY); @@ -181,6 +182,10 @@ void mixerUpdateStateFlags(void) } else if (currentMixerConfig.platformType == PLATFORM_TRICOPTER) { ENABLE_STATE(MULTIROTOR); ENABLE_STATE(ALTITUDE_CONTROL); + } else if (currentMixerConfig.platformType == PLATFORM_TAILSITTER) { + ENABLE_STATE(MULTIROTOR); + ENABLE_STATE(ALTITUDE_CONTROL); + ENABLE_STATE(TAILSITTER); } else if (currentMixerConfig.platformType == PLATFORM_HELICOPTER) { ENABLE_STATE(MULTIROTOR); ENABLE_STATE(ALTITUDE_CONTROL); diff --git a/src/main/flight/mixer.h b/src/main/flight/mixer.h index 9ee6a20654e..233ce37c229 100644 --- a/src/main/flight/mixer.h +++ b/src/main/flight/mixer.h @@ -41,7 +41,8 @@ typedef enum { PLATFORM_TRICOPTER = 3, PLATFORM_ROVER = 4, PLATFORM_BOAT = 5, - PLATFORM_OTHER = 6 + PLATFORM_OTHER = 6, + PLATFORM_TAILSITTER = 7, } flyingPlatformType_e; diff --git a/src/main/flight/pid.c b/src/main/flight/pid.c index bc794735eb2..dffbd69f2f6 100644 --- a/src/main/flight/pid.c +++ b/src/main/flight/pid.c @@ -1142,8 +1142,18 @@ void FAST_CODE pidController(float dT) } for (int axis = 0; axis < 3; axis++) { + int gyro_axis = axis; + // float noinvert=1.0f; + // if (STATE(TAILSITTER)){ + // if (axis == FD_ROLL) { + // gyro_axis = FD_YAW; + // } else if (axis == FD_YAW) { + // gyro_axis = FD_ROLL; + // noinvert=-1.0f; + // } + // } // Step 1: Calculate gyro rates - pidState[axis].gyroRate = gyro.gyroADCf[axis]; + pidState[axis].gyroRate = gyro.gyroADCf[gyro_axis] * noinvert; // Step 2: Read target float rateTarget; diff --git a/src/main/flight/servos.c b/src/main/flight/servos.c index f38a4ea108c..4b29397bf33 100755 --- a/src/main/flight/servos.c +++ b/src/main/flight/servos.c @@ -284,7 +284,7 @@ void servoMixer(float dT) // Reverse yaw servo when inverted in 3D mode only for multirotor and tricopter if (feature(FEATURE_REVERSIBLE_MOTORS) && (rxGetChannelValue(THROTTLE) < PWM_RANGE_MIDDLE) && - (currentMixerConfig.platformType == PLATFORM_MULTIROTOR || currentMixerConfig.platformType == PLATFORM_TRICOPTER)) { + (currentMixerConfig.platformType == PLATFORM_MULTIROTOR || currentMixerConfig.platformType == PLATFORM_TRICOPTER || currentMixerConfig.platformType == PLATFORM_TAILSITTER)) { input[INPUT_STABILIZED_YAW] *= -1; } } diff --git a/src/main/telemetry/mavlink.c b/src/main/telemetry/mavlink.c index f06eda57df6..eebfa85ba7f 100644 --- a/src/main/telemetry/mavlink.c +++ b/src/main/telemetry/mavlink.c @@ -694,6 +694,9 @@ void mavlinkSendHUDAndHeartbeat(void) case PLATFORM_TRICOPTER: mavSystemType = MAV_TYPE_TRICOPTER; break; + case PLATFORM_TAILSITTER: + mavSystemType = MAV_TYPE_QUADROTOR; + break; case PLATFORM_AIRPLANE: mavSystemType = MAV_TYPE_FIXED_WING; break; From c0842a284a63d4303a4668d423a5ea2f61eb7dad Mon Sep 17 00:00:00 2001 From: shota Date: Fri, 11 Aug 2023 02:09:09 +0900 Subject: [PATCH 019/241] initial cut on tail sitter support --- src/main/fc/settings.yaml | 2 +- src/main/flight/imu.c | 28 ++++++++++++++++++++++++++++ src/main/flight/mixer.h | 4 ++-- src/main/flight/pid.c | 13 +------------ src/main/sensors/boardalignment.c | 8 +++++++- 5 files changed, 39 insertions(+), 16 deletions(-) diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index 3df7beebb1e..fb81f19c0fa 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -1154,7 +1154,7 @@ groups: field: mixer_config.motorDirectionInverted type: bool - name: platform_type - description: "Defines UAV platform type. Allowed values: \"MULTIROTOR\", \"AIRPLANE\", \"HELICOPTER\", \"TRICOPTER\", \"ROVER\", \"BOAT\". Currently only MULTIROTOR, AIRPLANE and TRICOPTER types are implemented" + description: "Defines UAV platform type. Allowed values: \"MULTIROTOR\", \"AIRPLANE\", \"HELICOPTER\", \"TRICOPTER\", \"ROVER\", \"BOAT\", \"TAILSITTER\". Currently only MULTIROTOR, AIRPLANE and TRICOPTER types are implemented" default_value: "MULTIROTOR" field: mixer_config.platformType type: uint8_t diff --git a/src/main/flight/imu.c b/src/main/flight/imu.c index a99520a36b2..bc56306ba56 100644 --- a/src/main/flight/imu.c +++ b/src/main/flight/imu.c @@ -704,6 +704,33 @@ static void imuCalculateTurnRateacceleration(fpVector3_t *vEstcentrifugalAccelBF lastspeed = currentspeed; } +fpQuaternion_t* getTailSitterQuaternion(bool normal2tail){ + static bool firstRun = true; + static fpQuaternion_t qNormal2Tail; + static fpQuaternion_t qTail2Normal; + if(firstRun){ + fpAxisAngle_t axisAngle; + axisAngle.axis.x = 0; + axisAngle.axis.y = 1; + axisAngle.axis.z = 0; + axisAngle.angle = DEGREES_TO_RADIANS(90); + axisAngleToQuaternion(&qNormal2Tail, &axisAngle); + quaternionConjugate(&qTail2Normal, &qNormal2Tail); + firstRun = false; + } + return normal2tail ? &qNormal2Tail : &qTail2Normal; +} + +void imuUpdateTailSitter(void) +{ + static bool lastTailSitter=false; + if (((bool)STATE(TAILSITTER)) != lastTailSitter){ + fpQuaternion_t* rotation_for_tailsitter= getTailSitterQuaternion(STATE(TAILSITTER)); + quaternionMultiply(&orientation, &orientation, rotation_for_tailsitter); + } + lastTailSitter = STATE(TAILSITTER); +} + static void imuCalculateEstimatedAttitude(float dT) { #if defined(USE_MAG) @@ -800,6 +827,7 @@ static void imuCalculateEstimatedAttitude(float dT) useCOG, courseOverGround, accWeight, magWeight); + imuUpdateTailSitter(); imuUpdateEulerAngles(); } diff --git a/src/main/flight/mixer.h b/src/main/flight/mixer.h index 233ce37c229..ba0a856be6e 100644 --- a/src/main/flight/mixer.h +++ b/src/main/flight/mixer.h @@ -41,8 +41,8 @@ typedef enum { PLATFORM_TRICOPTER = 3, PLATFORM_ROVER = 4, PLATFORM_BOAT = 5, - PLATFORM_OTHER = 6, - PLATFORM_TAILSITTER = 7, + PLATFORM_TAILSITTER = 6, + PLATFORM_OTHER = 7, } flyingPlatformType_e; diff --git a/src/main/flight/pid.c b/src/main/flight/pid.c index dffbd69f2f6..1ee55a8a30d 100644 --- a/src/main/flight/pid.c +++ b/src/main/flight/pid.c @@ -1142,18 +1142,7 @@ void FAST_CODE pidController(float dT) } for (int axis = 0; axis < 3; axis++) { - int gyro_axis = axis; - // float noinvert=1.0f; - // if (STATE(TAILSITTER)){ - // if (axis == FD_ROLL) { - // gyro_axis = FD_YAW; - // } else if (axis == FD_YAW) { - // gyro_axis = FD_ROLL; - // noinvert=-1.0f; - // } - // } - // Step 1: Calculate gyro rates - pidState[axis].gyroRate = gyro.gyroADCf[gyro_axis] * noinvert; + pidState[axis].gyroRate = gyro.gyroADCf[axis]; // Step 2: Read target float rateTarget; diff --git a/src/main/sensors/boardalignment.c b/src/main/sensors/boardalignment.c index 86e41880f89..d23293dcce6 100644 --- a/src/main/sensors/boardalignment.c +++ b/src/main/sensors/boardalignment.c @@ -28,6 +28,7 @@ #include "config/parameter_group.h" #include "config/parameter_group_ids.h" +#include "fc/runtime_config.h" #include "drivers/sensor.h" @@ -87,7 +88,7 @@ void updateBoardAlignment(int16_t roll, int16_t pitch) void applyBoardAlignment(float *vec) { - if (standardBoardAlignment) { + if (standardBoardAlignment && (!STATE(TAILSITTER))) { return; } @@ -97,6 +98,11 @@ void applyBoardAlignment(float *vec) vec[X] = lrintf(fpVec.x); vec[Y] = lrintf(fpVec.y); vec[Z] = lrintf(fpVec.z); + + if (STATE(TAILSITTER)) { + vec[X] = lrintf(fpVec.z); + vec[Z] = -lrintf(fpVec.x); + } } void FAST_CODE applySensorAlignment(float * dest, float * src, uint8_t rotation) From 40986f00998cac7a5f89d169deddb9a324c61d46 Mon Sep 17 00:00:00 2001 From: shota Date: Fri, 11 Aug 2023 13:21:10 +0900 Subject: [PATCH 020/241] tailsitter support --- src/main/flight/imu.c | 2 +- src/main/flight/pid.c | 5 +++++ src/main/sensors/boardalignment.c | 15 +++++++++------ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/main/flight/imu.c b/src/main/flight/imu.c index bc56306ba56..d3f9d90d7db 100644 --- a/src/main/flight/imu.c +++ b/src/main/flight/imu.c @@ -713,7 +713,7 @@ fpQuaternion_t* getTailSitterQuaternion(bool normal2tail){ axisAngle.axis.x = 0; axisAngle.axis.y = 1; axisAngle.axis.z = 0; - axisAngle.angle = DEGREES_TO_RADIANS(90); + axisAngle.angle = DEGREES_TO_RADIANS(-90); axisAngleToQuaternion(&qNormal2Tail, &axisAngle); quaternionConjugate(&qTail2Normal, &qNormal2Tail); firstRun = false; diff --git a/src/main/flight/pid.c b/src/main/flight/pid.c index 1ee55a8a30d..b81718588c3 100644 --- a/src/main/flight/pid.c +++ b/src/main/flight/pid.c @@ -1178,6 +1178,11 @@ void FAST_CODE pidController(float dT) if (FLIGHT_MODE(ANGLE_MODE) || FLIGHT_MODE(HORIZON_MODE) || FLIGHT_MODE(ANGLEHOLD_MODE) || isFlightAxisAngleOverrideActive(axis)) { // If axis angle override, get the correct angle from Logic Conditions float angleTarget = getFlightAxisAngleOverride(axis, computePidLevelTarget(axis)); + + //apply 45 deg offset for tailsitter when isMixerTransitionMixing is activated + if (STATE(TAILSITTER) && isMixerTransitionMixing && axis == FD_PITCH){ + angleTarget += DEGREES_TO_DECIDEGREES(45); + } if (STATE(AIRPLANE)) { // update anglehold mode updateAngleHold(&angleTarget, axis); diff --git a/src/main/sensors/boardalignment.c b/src/main/sensors/boardalignment.c index d23293dcce6..ccad08163af 100644 --- a/src/main/sensors/boardalignment.c +++ b/src/main/sensors/boardalignment.c @@ -46,6 +46,7 @@ static bool standardBoardAlignment = true; // board orientation correction static fpMat3_t boardRotMatrix; +static fpMat3_t tailRotMatrix; // no template required since defaults are zero PG_REGISTER(boardAlignment_t, boardAlignment, PG_BOARD_ALIGNMENT, 0); @@ -70,6 +71,11 @@ void initBoardAlignment(void) rotationMatrixFromAngles(&boardRotMatrix, &rotationAngles); } + fp_angles_t rotationAngles; + rotationAngles.angles.roll = DECIDEGREES_TO_RADIANS(0); + rotationAngles.angles.pitch = DECIDEGREES_TO_RADIANS(900); + rotationAngles.angles.yaw = DECIDEGREES_TO_RADIANS(0); + rotationMatrixFromAngles(&tailRotMatrix, &rotationAngles); } void updateBoardAlignment(int16_t roll, int16_t pitch) @@ -94,15 +100,12 @@ void applyBoardAlignment(float *vec) fpVector3_t fpVec = { .v = { vec[X], vec[Y], vec[Z] } }; rotationMatrixRotateVector(&fpVec, &fpVec, &boardRotMatrix); - + if (STATE(TAILSITTER)) { + rotationMatrixRotateVector(&fpVec, &fpVec, &tailRotMatrix); + } vec[X] = lrintf(fpVec.x); vec[Y] = lrintf(fpVec.y); vec[Z] = lrintf(fpVec.z); - - if (STATE(TAILSITTER)) { - vec[X] = lrintf(fpVec.z); - vec[Z] = -lrintf(fpVec.x); - } } void FAST_CODE applySensorAlignment(float * dest, float * src, uint8_t rotation) From 2162b649bfd0e5eb089a5b84592867a899e118df Mon Sep 17 00:00:00 2001 From: shota Date: Sat, 12 Aug 2023 15:41:10 +0900 Subject: [PATCH 021/241] update tailsitter documents --- docs/MixerProfile.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/MixerProfile.md b/docs/MixerProfile.md index ec8685d0d4e..55aedd3a30b 100644 --- a/docs/MixerProfile.md +++ b/docs/MixerProfile.md @@ -104,6 +104,9 @@ TailSitter is supported by add a 90deg offset to the board alignment. Set the bo - Rate Settings - ······· +### TailSitter support +TailSitter is supported by add a 90deg offset to the board alignment. Set the board aliment normally in the mixer_profile for FW mode(`set platform_type = AIRPLANE`), The motor trust axis should be same direction as the airplane nose. Then, in the mixer_profile for takeoff and landing `set platform_type = TAILSITTER`. The `TAILSITTER` platform type is same as `MULTIROTOR` platform type, expect for a 90 deg board alignment offset. In `TAILSITTER` mixer_profile, when motor trust/airplane nose is pointing to the sky, 'airplane bottom'/'multi rotor front' should facing forward in model preview. Set the motor/servo mixer according to multirotor orientation, Model should roll around geography's longitudinal axis, the roll axis of `TAILSITTER` will be yaw axis of `AIRPLANE`. In addition, When `MIXER TRANSITION` input is activated, a 45deg offset will be add to the target angle for angle mode. + ## Happy flying Remember that this is currently an emerging capability: From b55164f6a51b52a7add1806927334d466be849db Mon Sep 17 00:00:00 2001 From: shota Date: Fri, 29 Sep 2023 00:09:07 +0900 Subject: [PATCH 022/241] add compass changing aliment --- src/main/sensors/boardalignment.c | 12 +++++++++--- src/main/sensors/boardalignment.h | 4 +++- src/main/sensors/compass.c | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/sensors/boardalignment.c b/src/main/sensors/boardalignment.c index ccad08163af..360ddec4a16 100644 --- a/src/main/sensors/boardalignment.c +++ b/src/main/sensors/boardalignment.c @@ -92,6 +92,14 @@ void updateBoardAlignment(int16_t roll, int16_t pitch) initBoardAlignment(); } +void applyTailSitterAlignment(fpVector3_t *fpVec) +{ + if (!STATE(TAILSITTER)) { + return; + } + rotationMatrixRotateVector(fpVec, fpVec, &tailRotMatrix); +} + void applyBoardAlignment(float *vec) { if (standardBoardAlignment && (!STATE(TAILSITTER))) { @@ -100,9 +108,7 @@ void applyBoardAlignment(float *vec) fpVector3_t fpVec = { .v = { vec[X], vec[Y], vec[Z] } }; rotationMatrixRotateVector(&fpVec, &fpVec, &boardRotMatrix); - if (STATE(TAILSITTER)) { - rotationMatrixRotateVector(&fpVec, &fpVec, &tailRotMatrix); - } + applyTailSitterAlignment(&fpVec); vec[X] = lrintf(fpVec.x); vec[Y] = lrintf(fpVec.y); vec[Z] = lrintf(fpVec.z); diff --git a/src/main/sensors/boardalignment.h b/src/main/sensors/boardalignment.h index 6bf01272650..17cd08e5ff3 100644 --- a/src/main/sensors/boardalignment.h +++ b/src/main/sensors/boardalignment.h @@ -18,6 +18,7 @@ #pragma once #include "config/parameter_group.h" +#include "common/vector.h" typedef struct boardAlignment_s { int16_t rollDeciDegrees; @@ -30,4 +31,5 @@ PG_DECLARE(boardAlignment_t, boardAlignment); void initBoardAlignment(void); void updateBoardAlignment(int16_t roll, int16_t pitch); void applySensorAlignment(float * dest, float * src, uint8_t rotation); -void applyBoardAlignment(float *vec); \ No newline at end of file +void applyBoardAlignment(float *vec); +void applyTailSitterAlignment(fpVector3_t *vec); \ No newline at end of file diff --git a/src/main/sensors/compass.c b/src/main/sensors/compass.c index 9c7ba99d9f9..02a9df69c44 100644 --- a/src/main/sensors/compass.c +++ b/src/main/sensors/compass.c @@ -472,7 +472,7 @@ void compassUpdate(timeUs_t currentTimeUs) fpVector3_t rotated; rotationMatrixRotateVector(&rotated, &v, &mag.dev.magAlign.externalRotation); - + applyTailSitterAlignment(&rotated); mag.magADC[X] = rotated.x; mag.magADC[Y] = rotated.y; mag.magADC[Z] = rotated.z; From aee7c4e449a241da1ec4c8f151e550fe8927a6bb Mon Sep 17 00:00:00 2001 From: shota Date: Sun, 8 Oct 2023 00:59:46 +0900 Subject: [PATCH 023/241] moved tailsitter platform type to tailsitter_board_orientation --- src/main/fc/settings.yaml | 7 ++++++- src/main/flight/mixer.c | 10 ++++++---- src/main/flight/mixer.h | 3 +-- src/main/flight/mixer_profile.c | 1 + src/main/flight/mixer_profile.h | 1 + src/main/flight/servos.c | 2 +- src/main/telemetry/mavlink.c | 3 --- 7 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index fb81f19c0fa..609408a6c6b 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -1154,7 +1154,7 @@ groups: field: mixer_config.motorDirectionInverted type: bool - name: platform_type - description: "Defines UAV platform type. Allowed values: \"MULTIROTOR\", \"AIRPLANE\", \"HELICOPTER\", \"TRICOPTER\", \"ROVER\", \"BOAT\", \"TAILSITTER\". Currently only MULTIROTOR, AIRPLANE and TRICOPTER types are implemented" + description: "Defines UAV platform type. Allowed values: \"MULTIROTOR\", \"AIRPLANE\", \"HELICOPTER\", \"TRICOPTER\", \"ROVER\", \"BOAT\". Currently only MULTIROTOR, AIRPLANE and TRICOPTER types are implemented" default_value: "MULTIROTOR" field: mixer_config.platformType type: uint8_t @@ -1191,6 +1191,11 @@ groups: field: mixer_config.switchTransitionTimer min: 0 max: 200 + - name: tailsitter_board_orientation + description: "If switch another mixer_profile is scheduled by mixer_automated_switch or mixer_automated_switch. Activate Mixertransion motor/servo mixing for this many decisecond(0.1s) before the actual mixer_profile switch." + default_value: OFF + field: mixer_config.tailsitterBoardOrientation + type: bool diff --git a/src/main/flight/mixer.c b/src/main/flight/mixer.c index d0d93a3348a..874f48c5c70 100644 --- a/src/main/flight/mixer.c +++ b/src/main/flight/mixer.c @@ -182,15 +182,17 @@ void mixerUpdateStateFlags(void) } else if (currentMixerConfig.platformType == PLATFORM_TRICOPTER) { ENABLE_STATE(MULTIROTOR); ENABLE_STATE(ALTITUDE_CONTROL); - } else if (currentMixerConfig.platformType == PLATFORM_TAILSITTER) { - ENABLE_STATE(MULTIROTOR); - ENABLE_STATE(ALTITUDE_CONTROL); - ENABLE_STATE(TAILSITTER); } else if (currentMixerConfig.platformType == PLATFORM_HELICOPTER) { ENABLE_STATE(MULTIROTOR); ENABLE_STATE(ALTITUDE_CONTROL); } + if (currentMixerConfig.tailsitterBoardOrientation) { + ENABLE_STATE(TAILSITTER); + } else { + DISABLE_STATE(TAILSITTER); + } + if (currentMixerConfig.hasFlaps) { ENABLE_STATE(FLAPERON_AVAILABLE); } else { diff --git a/src/main/flight/mixer.h b/src/main/flight/mixer.h index ba0a856be6e..9ee6a20654e 100644 --- a/src/main/flight/mixer.h +++ b/src/main/flight/mixer.h @@ -41,8 +41,7 @@ typedef enum { PLATFORM_TRICOPTER = 3, PLATFORM_ROVER = 4, PLATFORM_BOAT = 5, - PLATFORM_TAILSITTER = 6, - PLATFORM_OTHER = 7, + PLATFORM_OTHER = 6 } flyingPlatformType_e; diff --git a/src/main/flight/mixer_profile.c b/src/main/flight/mixer_profile.c index 64a6c39380d..c250e5ce318 100644 --- a/src/main/flight/mixer_profile.c +++ b/src/main/flight/mixer_profile.c @@ -53,6 +53,7 @@ void pgResetFn_mixerProfiles(mixerProfile_t *instance) .PIDProfileLinking = SETTING_MIXER_PID_PROFILE_LINKING_DEFAULT, .automated_switch = SETTING_MIXER_AUTOMATED_SWITCH_DEFAULT, .switchTransitionTimer = SETTING_MIXER_SWITCH_TRANS_TIMER_DEFAULT, + .tailsitterBoardOrientation = SETTING_TAILSITTER_BOARD_ORIENTATION_DEFAULT, }); for (int j = 0; j < MAX_SUPPORTED_MOTORS; j++) { diff --git a/src/main/flight/mixer_profile.h b/src/main/flight/mixer_profile.h index 50fbb4a82f1..040ae703470 100644 --- a/src/main/flight/mixer_profile.h +++ b/src/main/flight/mixer_profile.h @@ -18,6 +18,7 @@ typedef struct mixerConfig_s { bool PIDProfileLinking; bool automated_switch; int16_t switchTransitionTimer; + bool tailsitterBoardOrientation; } mixerConfig_t; typedef struct mixerProfile_s { mixerConfig_t mixer_config; diff --git a/src/main/flight/servos.c b/src/main/flight/servos.c index 4b29397bf33..f38a4ea108c 100755 --- a/src/main/flight/servos.c +++ b/src/main/flight/servos.c @@ -284,7 +284,7 @@ void servoMixer(float dT) // Reverse yaw servo when inverted in 3D mode only for multirotor and tricopter if (feature(FEATURE_REVERSIBLE_MOTORS) && (rxGetChannelValue(THROTTLE) < PWM_RANGE_MIDDLE) && - (currentMixerConfig.platformType == PLATFORM_MULTIROTOR || currentMixerConfig.platformType == PLATFORM_TRICOPTER || currentMixerConfig.platformType == PLATFORM_TAILSITTER)) { + (currentMixerConfig.platformType == PLATFORM_MULTIROTOR || currentMixerConfig.platformType == PLATFORM_TRICOPTER)) { input[INPUT_STABILIZED_YAW] *= -1; } } diff --git a/src/main/telemetry/mavlink.c b/src/main/telemetry/mavlink.c index eebfa85ba7f..f06eda57df6 100644 --- a/src/main/telemetry/mavlink.c +++ b/src/main/telemetry/mavlink.c @@ -694,9 +694,6 @@ void mavlinkSendHUDAndHeartbeat(void) case PLATFORM_TRICOPTER: mavSystemType = MAV_TYPE_TRICOPTER; break; - case PLATFORM_TAILSITTER: - mavSystemType = MAV_TYPE_QUADROTOR; - break; case PLATFORM_AIRPLANE: mavSystemType = MAV_TYPE_FIXED_WING; break; From 7b8dd3db2a8e2fad93028aad62d0c766456b2b2e Mon Sep 17 00:00:00 2001 From: shota Date: Sun, 8 Oct 2023 01:35:46 +0900 Subject: [PATCH 024/241] bug fixes --- docs/Settings.md | 10 ++++++++++ src/main/sensors/boardalignment.c | 29 ++++++++++++----------------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/docs/Settings.md b/docs/Settings.md index 5befa0aeffe..5b55fa6c67c 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -5812,6 +5812,16 @@ Delay before disarming when requested by switch (ms) [0-1000] --- +### tailsitter_board_orientation + +If switch another mixer_profile is scheduled by mixer_automated_switch or mixer_automated_switch. Activate Mixertransion motor/servo mixing for this many decisecond(0.1s) before the actual mixer_profile switch. + +| Default | Min | Max | +| --- | --- | --- | +| OFF | OFF | ON | + +--- + ### telemetry_halfduplex S.Port telemetry only: Turn UART into UNIDIR for usage on F1 and F4 target. See Telemetry.md for details diff --git a/src/main/sensors/boardalignment.c b/src/main/sensors/boardalignment.c index 360ddec4a16..1f149faeff6 100644 --- a/src/main/sensors/boardalignment.c +++ b/src/main/sensors/boardalignment.c @@ -58,24 +58,19 @@ static bool isBoardAlignmentStandard(const boardAlignment_t *boardAlignment) void initBoardAlignment(void) { - if (isBoardAlignmentStandard(boardAlignment())) { - standardBoardAlignment = true; - } else { - fp_angles_t rotationAngles; - - standardBoardAlignment = false; - - rotationAngles.angles.roll = DECIDEGREES_TO_RADIANS(boardAlignment()->rollDeciDegrees ); - rotationAngles.angles.pitch = DECIDEGREES_TO_RADIANS(boardAlignment()->pitchDeciDegrees); - rotationAngles.angles.yaw = DECIDEGREES_TO_RADIANS(boardAlignment()->yawDeciDegrees ); - - rotationMatrixFromAngles(&boardRotMatrix, &rotationAngles); - } + standardBoardAlignment=isBoardAlignmentStandard(boardAlignment()); fp_angles_t rotationAngles; - rotationAngles.angles.roll = DECIDEGREES_TO_RADIANS(0); - rotationAngles.angles.pitch = DECIDEGREES_TO_RADIANS(900); - rotationAngles.angles.yaw = DECIDEGREES_TO_RADIANS(0); - rotationMatrixFromAngles(&tailRotMatrix, &rotationAngles); + + rotationAngles.angles.roll = DECIDEGREES_TO_RADIANS(boardAlignment()->rollDeciDegrees ); + rotationAngles.angles.pitch = DECIDEGREES_TO_RADIANS(boardAlignment()->pitchDeciDegrees); + rotationAngles.angles.yaw = DECIDEGREES_TO_RADIANS(boardAlignment()->yawDeciDegrees ); + + rotationMatrixFromAngles(&boardRotMatrix, &rotationAngles); + fp_angles_t tailSitter_rotationAngles; + tailSitter_rotationAngles.angles.roll = DECIDEGREES_TO_RADIANS(0); + tailSitter_rotationAngles.angles.pitch = DECIDEGREES_TO_RADIANS(900); + tailSitter_rotationAngles.angles.yaw = DECIDEGREES_TO_RADIANS(0); + rotationMatrixFromAngles(&tailRotMatrix, &tailSitter_rotationAngles); } void updateBoardAlignment(int16_t roll, int16_t pitch) From 4e47e14feac234af8848a598661fec0534985269 Mon Sep 17 00:00:00 2001 From: shota Date: Sun, 8 Oct 2023 01:38:16 +0900 Subject: [PATCH 025/241] update docs --- docs/Settings.md | 2 +- src/main/fc/settings.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Settings.md b/docs/Settings.md index 5b55fa6c67c..3d3605b2452 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -5814,7 +5814,7 @@ Delay before disarming when requested by switch (ms) [0-1000] ### tailsitter_board_orientation -If switch another mixer_profile is scheduled by mixer_automated_switch or mixer_automated_switch. Activate Mixertransion motor/servo mixing for this many decisecond(0.1s) before the actual mixer_profile switch. +Apply a 90 deg pitch offset in sensor aliment for tailsitter flying mode | Default | Min | Max | | --- | --- | --- | diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index 609408a6c6b..1ef73339e5b 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -1192,7 +1192,7 @@ groups: min: 0 max: 200 - name: tailsitter_board_orientation - description: "If switch another mixer_profile is scheduled by mixer_automated_switch or mixer_automated_switch. Activate Mixertransion motor/servo mixing for this many decisecond(0.1s) before the actual mixer_profile switch." + description: "Apply a 90 deg pitch offset in sensor aliment for tailsitter flying mode" default_value: OFF field: mixer_config.tailsitterBoardOrientation type: bool From b9017cadcd6944a5b10dcbf564ef8c996085e19c Mon Sep 17 00:00:00 2001 From: shota Date: Mon, 16 Oct 2023 10:52:02 +0900 Subject: [PATCH 026/241] parameter rename --- docs/Settings.md | 2 +- src/main/fc/settings.yaml | 4 ++-- src/main/flight/mixer.c | 2 +- src/main/flight/mixer_profile.c | 2 +- src/main/flight/mixer_profile.h | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/Settings.md b/docs/Settings.md index 3d3605b2452..308c5fd783b 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -5812,7 +5812,7 @@ Delay before disarming when requested by switch (ms) [0-1000] --- -### tailsitter_board_orientation +### tailsitter_orientation_offset Apply a 90 deg pitch offset in sensor aliment for tailsitter flying mode diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index 1ef73339e5b..c68c611b052 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -1191,10 +1191,10 @@ groups: field: mixer_config.switchTransitionTimer min: 0 max: 200 - - name: tailsitter_board_orientation + - name: tailsitter_orientation_offset description: "Apply a 90 deg pitch offset in sensor aliment for tailsitter flying mode" default_value: OFF - field: mixer_config.tailsitterBoardOrientation + field: mixer_config.tailsitterOrientationOffset type: bool diff --git a/src/main/flight/mixer.c b/src/main/flight/mixer.c index 874f48c5c70..834841e6580 100644 --- a/src/main/flight/mixer.c +++ b/src/main/flight/mixer.c @@ -187,7 +187,7 @@ void mixerUpdateStateFlags(void) ENABLE_STATE(ALTITUDE_CONTROL); } - if (currentMixerConfig.tailsitterBoardOrientation) { + if (currentMixerConfig.tailsitterOrientationOffset) { ENABLE_STATE(TAILSITTER); } else { DISABLE_STATE(TAILSITTER); diff --git a/src/main/flight/mixer_profile.c b/src/main/flight/mixer_profile.c index c250e5ce318..7b2590ff70b 100644 --- a/src/main/flight/mixer_profile.c +++ b/src/main/flight/mixer_profile.c @@ -53,7 +53,7 @@ void pgResetFn_mixerProfiles(mixerProfile_t *instance) .PIDProfileLinking = SETTING_MIXER_PID_PROFILE_LINKING_DEFAULT, .automated_switch = SETTING_MIXER_AUTOMATED_SWITCH_DEFAULT, .switchTransitionTimer = SETTING_MIXER_SWITCH_TRANS_TIMER_DEFAULT, - .tailsitterBoardOrientation = SETTING_TAILSITTER_BOARD_ORIENTATION_DEFAULT, + .tailsitterOrientationOffset = SETTING_TAILSITTER_ORIENTATION_OFFSET_DEFAULT, }); for (int j = 0; j < MAX_SUPPORTED_MOTORS; j++) { diff --git a/src/main/flight/mixer_profile.h b/src/main/flight/mixer_profile.h index 040ae703470..947ca701553 100644 --- a/src/main/flight/mixer_profile.h +++ b/src/main/flight/mixer_profile.h @@ -18,7 +18,7 @@ typedef struct mixerConfig_s { bool PIDProfileLinking; bool automated_switch; int16_t switchTransitionTimer; - bool tailsitterBoardOrientation; + bool tailsitterOrientationOffset; } mixerConfig_t; typedef struct mixerProfile_s { mixerConfig_t mixer_config; From dc7147d1a88937166812914f6e900fc185b6e7d7 Mon Sep 17 00:00:00 2001 From: shota Date: Fri, 20 Oct 2023 09:15:03 +0900 Subject: [PATCH 027/241] logic condition RCcommand overide also works for angle mode --- src/main/flight/pid.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/flight/pid.c b/src/main/flight/pid.c index b81718588c3..16ad2bc431d 100644 --- a/src/main/flight/pid.c +++ b/src/main/flight/pid.c @@ -586,7 +586,11 @@ int16_t angleFreefloatDeadband(int16_t deadband, flight_dynamics_index_t axis) static float computePidLevelTarget(flight_dynamics_index_t axis) { // This is ROLL/PITCH, run ANGLE/HORIZON controllers +#ifdef USE_PROGRAMMING_FRAMEWORK + float angleTarget = pidRcCommandToAngle(getRcCommandOverride(rcCommand, axis), pidProfile()->max_angle_inclination[axis]); +#else float angleTarget = pidRcCommandToAngle(rcCommand[axis], pidProfile()->max_angle_inclination[axis]); +#endif // Automatically pitch down if the throttle is manually controlled and reduced bellow cruise throttle if ((axis == FD_PITCH) && STATE(AIRPLANE) && FLIGHT_MODE(ANGLE_MODE) && !navigationIsControllingThrottle()) { From 41e5b172d3a5fd53547e2365049e95a2ad189738 Mon Sep 17 00:00:00 2001 From: Martin Luessi Date: Sat, 16 Dec 2023 08:23:14 -0800 Subject: [PATCH 028/241] USB MSC: Fix SCIS mode sense write protection bit (#9572) --- .../Class/MSC/Src/usbd_msc_scsi.c | 12 ++++++++++++ .../Class/MSC/Src/usbd_msc_scsi.c | 12 ++++++++++++ .../Class/MSC/Src/usbd_msc_scsi.c | 11 +++++++++++ 3 files changed, 35 insertions(+) diff --git a/lib/main/STM32F4/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c b/lib/main/STM32F4/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c index 5d4d2521693..3c63a978f2c 100644 --- a/lib/main/STM32F4/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c +++ b/lib/main/STM32F4/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c @@ -343,6 +343,12 @@ static int8_t SCSI_ModeSense6 (USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t * len--; hmsc->bot_data[len] = MSC_Mode_Sense6_data[len]; } + + // set bit 7 of the device configuration byte to indicate write protection + if (((USBD_StorageTypeDef *)pdev->pMSC_UserData)->IsWriteProtected(lun) != 0) { + hmsc->bot_data[2] = hmsc->bot_data[2] | (1 << 7); + } + return 0; } @@ -365,6 +371,12 @@ static int8_t SCSI_ModeSense10 (USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t len--; hmsc->bot_data[len] = MSC_Mode_Sense10_data[len]; } + + // set bit 7 of the device configuration byte to indicate write protection + if (((USBD_StorageTypeDef *)pdev->pMSC_UserData)->IsWriteProtected(lun) != 0) { + hmsc->bot_data[3] = hmsc->bot_data[3] | (1 << 7); + } + return 0; } diff --git a/lib/main/STM32F7/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c b/lib/main/STM32F7/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c index ed3deef5959..b1d76cc25da 100644 --- a/lib/main/STM32F7/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c +++ b/lib/main/STM32F7/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c @@ -347,6 +347,12 @@ static int8_t SCSI_ModeSense6 (USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t * len--; hmsc->bot_data[len] = MSC_Mode_Sense6_data[len]; } + + // set bit 7 of the device configuration byte to indicate write protection + if (((USBD_StorageTypeDef *)pdev->pMSC_UserData)->IsWriteProtected(lun) != 0) { + hmsc->bot_data[2] = hmsc->bot_data[2] | (1 << 7); + } + return 0; } @@ -370,6 +376,12 @@ static int8_t SCSI_ModeSense10 (USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t len--; hmsc->bot_data[len] = MSC_Mode_Sense10_data[len]; } + + // set bit 7 of the device configuration byte to indicate write protection + if (((USBD_StorageTypeDef *)pdev->pMSC_UserData)->IsWriteProtected(lun) != 0) { + hmsc->bot_data[3] = hmsc->bot_data[3] | (1 << 7); + } + return 0; } diff --git a/lib/main/STM32H7/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c b/lib/main/STM32H7/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c index d15d9039a54..ffc615dac5a 100644 --- a/lib/main/STM32H7/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c +++ b/lib/main/STM32H7/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c @@ -346,6 +346,12 @@ static int8_t SCSI_ModeSense6(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *p len--; hmsc->bot_data[len] = MSC_Mode_Sense6_data[len]; } + + // set bit 7 of the device configuration byte to indicate write protection + if (((USBD_StorageTypeDef *)pdev->pMSC_UserData)->IsWriteProtected(lun) != 0) { + hmsc->bot_data[2] = hmsc->bot_data[2] | (1 << 7); + } + return 0; } @@ -371,6 +377,11 @@ static int8_t SCSI_ModeSense10(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t * hmsc->bot_data[len] = MSC_Mode_Sense10_data[len]; } + // set bit 7 of the device configuration byte to indicate write protection + if (((USBD_StorageTypeDef *)pdev->pMSC_UserData)->IsWriteProtected(lun) != 0) { + hmsc->bot_data[3] = hmsc->bot_data[3] | (1 << 7); + } + return 0; } From 88d4359a17a0f75e2a1bc6af5246a8f8feee63ed Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Sun, 24 Dec 2023 11:27:07 +0000 Subject: [PATCH 029/241] Reorganise stats screen The stats screen was changed to fit all the data on a single HD page. This was great, but the ordering, due to being the same as the SD layout, didn't really make sense. For example, Disarmed by was positioned somewhere in the middle of the stats. This PR reorders the stats. They should make more sense on both SD and HD now. - Increased min voltage start value. This will be good up to 26S now. Yes, I know someone who is looking at a build with that much voltage. - Added stats for min/max sats - Separated out the stats draw for each type of stat in to its own function. This makes the displaying simpler. Plus it will be ready for customisable stats screen if someone does that. - There is room for 3 more stats on WTF and 5 on analogue. --- src/main/io/osd.c | 591 ++++++++++++++++++++++++++++------------------ 1 file changed, 358 insertions(+), 233 deletions(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 22e11250963..8a6b21779be 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -177,6 +177,8 @@ typedef struct statistic_s { int16_t min_rssi_dbm; // for CRSF int32_t max_altitude; uint32_t max_distance; + uint8_t min_sats; + uint8_t max_sats; } statistic_t; static statistic_t stats; @@ -4263,11 +4265,13 @@ static void osdResetStats(void) stats.max_speed = 0; stats.max_3D_speed = 0; stats.max_air_speed = 0; - stats.min_voltage = 5000; + stats.min_voltage = 12000; stats.min_rssi = 99; stats.min_lq = 300; stats.min_rssi_dbm = 0; stats.max_altitude = 0; + stats.min_sats = 255; + stats.max_sats = 0; } static void osdUpdateStats(void) @@ -4289,6 +4293,12 @@ static void osdUpdateStats(void) if (stats.max_distance < GPS_distanceToHome) stats.max_distance = GPS_distanceToHome; + + if (stats.min_sats > gpsSol.numSat) + stats.min_sats = gpsSol.numSat; + + if (stats.max_sats < gpsSol.numSat) + stats.max_sats = gpsSol.numSat; } value = getBatteryVoltage(); @@ -4321,264 +4331,379 @@ static void osdUpdateStats(void) stats.max_altitude = MAX(stats.max_altitude, osdGetAltitude()); } -static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page) -{ - const char * disarmReasonStr[DISARM_REASON_COUNT] = { "UNKNOWN", "TIMEOUT", "STICKS", "SWITCH", "SWITCH", "KILLSW", "FAILSAFE", "NAV SYS", "LANDING"}; - uint8_t top = 1; // Start one line down leaving space at the top of the screen. - size_t multiValueLengthOffset = 0; +uint8_t drawStat_FlightTime(uint8_t col, uint8_t row, uint8_t statValX) { + char buff[12]; + displayWrite(osdDisplayPort, col, row, "FLIGHT TIME"); + uint16_t flySeconds = getFlightTime(); + uint16_t flyMinutes = flySeconds / 60; + flySeconds %= 60; + uint16_t flyHours = flyMinutes / 60; + flyMinutes %= 60; + tfp_sprintf(buff, ": %02u:%02u:%02u", flyHours, flyMinutes, flySeconds); + displayWrite(osdDisplayPort, statValX, row++, buff); - const uint8_t statNameX = osdDisplayIsHD() ? 11 : 1; - const uint8_t statValuesX = osdDisplayIsHD() ? 30 : 20; - char buff[10]; + return row; +} - if (page > 1) - page = 0; +uint8_t drawStat_FlightDistance(uint8_t col, uint8_t row, uint8_t statValX) { + char buff[12]; + displayWrite(osdDisplayPort, col, row, "FLIGHT DISTANCE"); + tfp_sprintf(buff, ": "); + osdFormatDistanceStr(buff + 2, getTotalTravelDistance()); + displayWrite(osdDisplayPort, statValX, row++, buff); - displayBeginTransaction(osdDisplayPort, DISPLAY_TRANSACTION_OPT_RESET_DRAWING); - displayClearScreen(osdDisplayPort); + return row; +} - if (isSinglePageStatsCompatible) { - displayWrite(osdDisplayPort, statNameX, top++, "--- STATS ---"); - } else if (page == 0) { - displayWrite(osdDisplayPort, statNameX, top++, "--- STATS --- 1/2 ->"); - } else if (page == 1) { - displayWrite(osdDisplayPort, statNameX, top++, "--- STATS --- <- 2/2"); - } - - if (isSinglePageStatsCompatible || page == 0) { - if (feature(FEATURE_GPS)) { - if (isSinglePageStatsCompatible) { - displayWrite(osdDisplayPort, statNameX, top, "MAX/AVG SPEED :"); - osdFormatVelocityStr(buff, stats.max_3D_speed, true, false); - osdLeftAlignString(buff); - strcat(osdFormatTrimWhiteSpace(buff),"/"); - multiValueLengthOffset = strlen(buff); - displayWrite(osdDisplayPort, statValuesX, top, buff); - osdGenerateAverageVelocityStr(buff); - osdLeftAlignString(buff); - displayWrite(osdDisplayPort, statValuesX + multiValueLengthOffset, top++, buff); - } else { - displayWrite(osdDisplayPort, statNameX, top, "MAX SPEED :"); - osdFormatVelocityStr(buff, stats.max_3D_speed, true, false); - osdLeftAlignString(buff); - displayWrite(osdDisplayPort, statValuesX, top++, buff); - - displayWrite(osdDisplayPort, statNameX, top, "AVG SPEED :"); - osdGenerateAverageVelocityStr(buff); - osdLeftAlignString(buff); - displayWrite(osdDisplayPort, statValuesX, top++, buff); - } +uint8_t drawStat_MaxDistanceFromHome(uint8_t col, uint8_t row, uint8_t statValX) { + char buff[12]; + displayWrite(osdDisplayPort, col, row, "DISTANCE FROM "); + displayWriteChar(osdDisplayPort, col + 14, row, SYM_HOME); + tfp_sprintf(buff, ": "); + osdFormatDistanceStr(buff + 2, stats.max_distance * 100); + displayWrite(osdDisplayPort, statValX, row++, buff); - displayWrite(osdDisplayPort, statNameX, top, "MAX DISTANCE :"); - osdFormatDistanceStr(buff, stats.max_distance*100); - displayWrite(osdDisplayPort, statValuesX, top++, buff); - - displayWrite(osdDisplayPort, statNameX, top, "TRAVELED DISTANCE:"); - osdFormatDistanceStr(buff, getTotalTravelDistance()); - displayWrite(osdDisplayPort, statValuesX, top++, buff); - } - - displayWrite(osdDisplayPort, statNameX, top, "MAX ALTITUDE :"); - osdFormatAltitudeStr(buff, stats.max_altitude); - displayWrite(osdDisplayPort, statValuesX, top++, buff); - - switch (rxConfig()->serialrx_provider) { - case SERIALRX_CRSF: - if (isSinglePageStatsCompatible) { - displayWrite(osdDisplayPort, statNameX, top, "MIN RSSI %/DBM :"); - itoa(stats.min_rssi, buff, 10); - osdLeftAlignString(buff); - strcat(osdFormatTrimWhiteSpace(buff), "%/"); - multiValueLengthOffset = strlen(buff); - displayWrite(osdDisplayPort, statValuesX, top, buff); - itoa(stats.min_rssi_dbm, buff, 10); - tfp_sprintf(buff, "%s%c", buff, SYM_DBM); - osdLeftAlignString(buff); - displayWrite(osdDisplayPort, statValuesX + multiValueLengthOffset, top++, buff); - } else { - displayWrite(osdDisplayPort, statNameX, top, "MIN RSSI % :"); - itoa(stats.min_rssi, buff, 10); - strcat(buff, "%"); - displayWrite(osdDisplayPort, statValuesX, top++, buff); - - displayWrite(osdDisplayPort, statNameX, top, "MIN RSSI DBM :"); - itoa(stats.min_rssi_dbm, buff, 10); - tfp_sprintf(buff, "%s%c", buff, SYM_DBM); - displayWrite(osdDisplayPort, statValuesX, top++, buff); - } - - displayWrite(osdDisplayPort, statNameX, top, "MIN LQ :"); - itoa(stats.min_lq, buff, 10); - strcat(buff, "%"); - displayWrite(osdDisplayPort, statValuesX, top++, buff); - break; - default: - displayWrite(osdDisplayPort, statNameX, top, "MIN RSSI :"); - itoa(stats.min_rssi, buff, 10); - strcat(buff, "%"); - displayWrite(osdDisplayPort, statValuesX, top++, buff); - } + return row; +} - displayWrite(osdDisplayPort, statNameX, top, "FLY TIME :"); - uint16_t flySeconds = getFlightTime(); - uint16_t flyMinutes = flySeconds / 60; - flySeconds %= 60; - uint16_t flyHours = flyMinutes / 60; - flyMinutes %= 60; - tfp_sprintf(buff, "%02u:%02u:%02u", flyHours, flyMinutes, flySeconds); - displayWrite(osdDisplayPort, statValuesX, top++, buff); +uint8_t drawStat_Speed(uint8_t col, uint8_t row, uint8_t statValX) { + char buff[12]; + uint8_t multiValueXOffset = 0; - displayWrite(osdDisplayPort, statNameX, top, "DISARMED BY :"); - displayWrite(osdDisplayPort, statValuesX, top++, disarmReasonStr[getDisarmReason()]); - } + displayWrite(osdDisplayPort, col, row, "MAX/AVG SPEED"); + tfp_sprintf(buff, ": "); + osdFormatVelocityStr(buff + 2, stats.max_3D_speed, true, false); + osdLeftAlignString(buff); + strcat(osdFormatTrimWhiteSpace(buff), "/"); + multiValueXOffset = strlen(buff); + displayWrite(osdDisplayPort, statValX, row, buff); - if (isSinglePageStatsCompatible || page == 1) { - if (osdConfig()->stats_min_voltage_unit == OSD_STATS_MIN_VOLTAGE_UNIT_BATTERY) { - displayWrite(osdDisplayPort, statNameX, top, "MIN BATTERY VOLT :"); - osdFormatCentiNumber(buff, stats.min_voltage, 0, osdConfig()->main_voltage_decimals, 0, osdConfig()->main_voltage_decimals + 2, false); - } else { - displayWrite(osdDisplayPort, statNameX, top, "MIN CELL VOLTAGE :"); - osdFormatCentiNumber(buff, stats.min_voltage/getBatteryCellCount(), 0, 2, 0, 3, false); - } - tfp_sprintf(buff, "%s%c", buff, SYM_VOLT); - displayWrite(osdDisplayPort, statValuesX, top++, buff); + osdGenerateAverageVelocityStr(buff); + osdLeftAlignString(buff); + displayWrite(osdDisplayPort, statValX + multiValueXOffset, row++, buff); - if (feature(FEATURE_CURRENT_METER)) { - displayWrite(osdDisplayPort, statNameX, top, "MAX CURRENT :"); - osdFormatCentiNumber(buff, stats.max_current, 0, 2, 0, 3, false); - tfp_sprintf(buff, "%s%c", buff, SYM_AMP); - displayWrite(osdDisplayPort, statValuesX, top++, buff); + return row; +} - displayWrite(osdDisplayPort, statNameX, top, "MAX POWER :"); - bool kiloWatt = osdFormatCentiNumber(buff, stats.max_power, 1000, 2, 2, 3, false); - buff[3] = kiloWatt ? SYM_KILOWATT : SYM_WATT; - buff[4] = '\0'; - displayWrite(osdDisplayPort, statValuesX, top++, buff); +uint8_t drawStat_MaximumAltitude(uint8_t col, uint8_t row, uint8_t statValX) { + char buff[12]; + displayWrite(osdDisplayPort, col, row, "MAX ALTITUDE"); + tfp_sprintf(buff, ": "); + osdFormatAltitudeStr(buff + 2, stats.max_altitude); + displayWrite(osdDisplayPort, statValX, row++, buff); + + return row; +} + +uint8_t drawStat_BatteryVoltage(uint8_t col, uint8_t row, uint8_t statValX) { + char buff[12]; + uint8_t multiValueXOffset = 0; + displayWrite(osdDisplayPort, col, row, "MIN VOLTS P/C"); + + // Pack voltage + tfp_sprintf(buff, ": "); + osdFormatCentiNumber(buff + 2, stats.min_voltage, 0, osdConfig()->main_voltage_decimals, 0, osdConfig()->main_voltage_decimals + 2, false); + strcat(osdFormatTrimWhiteSpace(buff), "/"); + multiValueXOffset = strlen(buff); + // AverageCell + osdFormatCentiNumber(buff + multiValueXOffset, stats.min_voltage / getBatteryCellCount(), 0, 2, 0, 3, false); + tfp_sprintf(buff, "%s%c", buff, SYM_VOLT); + + displayWrite(osdDisplayPort, statValX, row++, buff); + + return row; +} - displayWrite(osdDisplayPort, statNameX, top, "USED CAPACITY :"); +uint8_t drawStat_MaximumCurrent(uint8_t col, uint8_t row, uint8_t statValX) { + char buff[12]; + displayWrite(osdDisplayPort, col, row, "MAX CURRENT"); + tfp_sprintf(buff, ": "); + osdFormatCentiNumber(buff + 2, stats.max_current, 0, 2, 0, 3, false); + tfp_sprintf(buff, "%s%c", buff, SYM_AMP); + displayWrite(osdDisplayPort, statValX, row++, buff); + + return row; +} + +uint8_t drawStat_MaximumPower(uint8_t col, uint8_t row, uint8_t statValX) { + char buff[12]; + displayWrite(osdDisplayPort, col, row, "MAX POWER"); + tfp_sprintf(buff, ": "); + bool kiloWatt = osdFormatCentiNumber(buff + 2, stats.max_power, 1000, 2, 2, 3, false); + strcat(osdFormatTrimWhiteSpace(buff), (char*)(kiloWatt ? SYM_KILOWATT : SYM_WATT)); + displayWrite(osdDisplayPort, statValX, row++, buff); + + return row; +} + +uint8_t drawStat_UsedEnergy(uint8_t col, uint8_t row, uint8_t statValX) { + char buff[12]; + displayWrite(osdDisplayPort, col, row, "USED ENERGY"); + tfp_sprintf(buff, ": "); + if (osdConfig()->stats_energy_unit == OSD_STATS_ENERGY_UNIT_MAH) { + tfp_sprintf(buff + 2, "%d%c", (int)getMAhDrawn(), SYM_MAH); + } else { + osdFormatCentiNumber(buff + 2, getMWhDrawn() / 10, 0, 2, 0, 3, false); + tfp_sprintf(buff, "%s%c", buff, SYM_WH); + } + displayWrite(osdDisplayPort, statValX, row++, buff); + + return row; +} + +uint8_t drawStat_AverageEfficiency(uint8_t col, uint8_t row, uint8_t statValX) { + char buff[15]; + uint8_t buffOffset = 2; + int32_t totalDistance = getTotalTravelDistance(); + bool moreThanAh = false; + bool efficiencyValid = totalDistance >= 10000; + + displayWrite(osdDisplayPort, col, row, "AVG EFFICIENCY"); + + tfp_sprintf(buff, ": "); + uint8_t digits = 3U; // Total number of digits (including decimal point) +#ifndef DISABLE_MSP_BF_COMPAT // IF BFCOMPAT is not supported, there's no need to check for it and change the values + if (isBfCompatibleVideoSystem(osdConfig())) { + // Add one digit so no switch to scaled decimal occurs above 99 + digits = 4U; + } +#endif + switch (osdConfig()->units) { + case OSD_UNIT_UK: + FALLTHROUGH; + case OSD_UNIT_IMPERIAL: if (osdConfig()->stats_energy_unit == OSD_STATS_ENERGY_UNIT_MAH) { - tfp_sprintf(buff, "%d%c", (int)getMAhDrawn(), SYM_MAH); + moreThanAh = osdFormatCentiNumber(buff + buffOffset, (int32_t)(getMAhDrawn() * 10000.0f * METERS_PER_MILE / totalDistance), 1000, 0, 2, digits, false); + if (!moreThanAh) { + tfp_sprintf(buff, "%s%c%c", buff, SYM_MAH_MI_0, SYM_MAH_MI_1); + } else { + tfp_sprintf(buff, "%s%c", buff, SYM_AH_MI); + } + if (!efficiencyValid) { + buff[0+buffOffset] = buff[1+buffOffset] = buff[2+buffOffset] = '-'; + buff[3+buffOffset] = SYM_MAH_MI_0; + buff[4+buffOffset] = SYM_MAH_MI_1; + buff[5+buffOffset] = '\0'; + } } else { - osdFormatCentiNumber(buff, getMWhDrawn() / 10, 0, 2, 0, 3, false); - tfp_sprintf(buff, "%s%c", buff, SYM_WH); + osdFormatCentiNumber(buff + buffOffset, (int32_t)(getMWhDrawn() * 10.0f * METERS_PER_MILE / totalDistance), 0, 2, 0, digits, false); + tfp_sprintf(buff, "%s%c", buff, SYM_WH_MI); + if (!efficiencyValid) { + buff[0+buffOffset] = buff[1+buffOffset] = buff[2+buffOffset] = '-'; + } } - displayWrite(osdDisplayPort, statValuesX, top++, buff); - - int32_t totalDistance = getTotalTravelDistance(); - bool moreThanAh = false; - bool efficiencyValid = totalDistance >= 10000; - if (feature(FEATURE_GPS)) { - displayWrite(osdDisplayPort, statNameX, top, "AVG EFFICIENCY :"); - uint8_t digits = 3U; // Total number of digits (including decimal point) - #ifndef DISABLE_MSP_BF_COMPAT // IF BFCOMPAT is not supported, there's no need to check for it and change the values - if (isBfCompatibleVideoSystem(osdConfig())) { - // Add one digit so no switch to scaled decimal occurs above 99 - digits = 4U; - } - #endif - switch (osdConfig()->units) { - case OSD_UNIT_UK: - FALLTHROUGH; - case OSD_UNIT_IMPERIAL: - if (osdConfig()->stats_energy_unit == OSD_STATS_ENERGY_UNIT_MAH) { - moreThanAh = osdFormatCentiNumber(buff, (int32_t)(getMAhDrawn() * 10000.0f * METERS_PER_MILE / totalDistance), 1000, 0, 2, digits, false); - if (!moreThanAh) { - tfp_sprintf(buff, "%s%c%c", buff, SYM_MAH_MI_0, SYM_MAH_MI_1); - } else { - tfp_sprintf(buff, "%s%c", buff, SYM_AH_MI); - } - if (!efficiencyValid) { - buff[0] = buff[1] = buff[2] = '-'; - buff[3] = SYM_MAH_MI_0; - buff[4] = SYM_MAH_MI_1; - buff[5] = '\0'; - } - } else { - osdFormatCentiNumber(buff, (int32_t)(getMWhDrawn() * 10.0f * METERS_PER_MILE / totalDistance), 0, 2, 0, digits, false); - tfp_sprintf(buff, "%s%c", buff, SYM_WH_MI); - if (!efficiencyValid) { - buff[0] = buff[1] = buff[2] = '-'; - } - } - break; - case OSD_UNIT_GA: - if (osdConfig()->stats_energy_unit == OSD_STATS_ENERGY_UNIT_MAH) { - moreThanAh = osdFormatCentiNumber(buff, (int32_t)(getMAhDrawn() * 10000.0f * METERS_PER_NAUTICALMILE / totalDistance), 1000, 0, 2, digits, false); - if (!moreThanAh) { - tfp_sprintf(buff, "%s%c%c", buff, SYM_MAH_NM_0, SYM_MAH_NM_1); - } else { - tfp_sprintf(buff, "%s%c", buff, SYM_AH_NM); - } - if (!efficiencyValid) { - buff[0] = buff[1] = buff[2] = '-'; - buff[3] = SYM_MAH_NM_0; - buff[4] = SYM_MAH_NM_1; - buff[5] = '\0'; - } - } else { - osdFormatCentiNumber(buff, (int32_t)(getMWhDrawn() * 10.0f * METERS_PER_NAUTICALMILE / totalDistance), 0, 2, 0, digits, false); - tfp_sprintf(buff, "%s%c", buff, SYM_WH_NM); - if (!efficiencyValid) { - buff[0] = buff[1] = buff[2] = '-'; - } - } - break; - case OSD_UNIT_METRIC_MPH: - FALLTHROUGH; - case OSD_UNIT_METRIC: - if (osdConfig()->stats_energy_unit == OSD_STATS_ENERGY_UNIT_MAH) { - moreThanAh = osdFormatCentiNumber(buff, (int32_t)(getMAhDrawn() * 10000000.0f / totalDistance), 1000, 0, 2, digits, false); - if (!moreThanAh) { - tfp_sprintf(buff, "%s%c%c", buff, SYM_MAH_KM_0, SYM_MAH_KM_1); - } else { - tfp_sprintf(buff, "%s%c", buff, SYM_AH_KM); - } - if (!efficiencyValid) { - buff[0] = buff[1] = buff[2] = '-'; - buff[3] = SYM_MAH_KM_0; - buff[4] = SYM_MAH_KM_1; - buff[5] = '\0'; - } - } else { - osdFormatCentiNumber(buff, (int32_t)(getMWhDrawn() * 10000.0f / totalDistance), 0, 2, 0, digits, false); - tfp_sprintf(buff, "%s%c", buff, SYM_WH_KM); - if (!efficiencyValid) { - buff[0] = buff[1] = buff[2] = '-'; - } - } - break; + break; + case OSD_UNIT_GA: + if (osdConfig()->stats_energy_unit == OSD_STATS_ENERGY_UNIT_MAH) { + moreThanAh = osdFormatCentiNumber(buff + buffOffset, (int32_t)(getMAhDrawn() * 10000.0f * METERS_PER_NAUTICALMILE / totalDistance), 1000, 0, 2, digits, false); + if (!moreThanAh) { + tfp_sprintf(buff, "%s%c%c", buff, SYM_MAH_NM_0, SYM_MAH_NM_1); + } else { + tfp_sprintf(buff, "%s%c", buff, SYM_AH_NM); } - osdLeftAlignString(buff); - displayWrite(osdDisplayPort, statValuesX, top++, buff); + if (!efficiencyValid) { + buff[0+buffOffset] = buff[1+buffOffset] = buff[2+buffOffset] = '-'; + buff[3+buffOffset] = SYM_MAH_NM_0; + buff[4+buffOffset] = SYM_MAH_NM_1; + buff[5+buffOffset] = '\0'; + } + } else { + osdFormatCentiNumber(buff + buffOffset, (int32_t)(getMWhDrawn() * 10.0f * METERS_PER_NAUTICALMILE / totalDistance), 0, 2, 0, digits, false); + tfp_sprintf(buff, "%s%c", buff, SYM_WH_NM); + if (!efficiencyValid) { + buff[0+buffOffset] = buff[1+buffOffset] = buff[2+buffOffset] = '-'; + } + } + break; + } + + if (statValX > 20 && osdConfig()->units != OSD_UNIT_METRIC_MPH && osdConfig()->units != OSD_UNIT_METRIC) { + strcat(osdFormatTrimWhiteSpace(buff), "/"); + buffOffset = strlen(buff); + } + + if (statValX > 20 || (osdConfig()->units != OSD_UNIT_METRIC_MPH || osdConfig()->units != OSD_UNIT_METRIC)) { + if (osdConfig()->stats_energy_unit == OSD_STATS_ENERGY_UNIT_MAH) { + moreThanAh = osdFormatCentiNumber(buff + buffOffset, (int32_t)(getMAhDrawn() * 10000000.0f / totalDistance), 1000, 0, 2, digits, false); + if (!moreThanAh) { + tfp_sprintf(buff, "%s%c%c", buff, SYM_MAH_KM_0, SYM_MAH_KM_1); + } else { + tfp_sprintf(buff, "%s%c", buff, SYM_AH_KM); + } + if (!efficiencyValid) { + buff[0+buffOffset] = buff[1+buffOffset] = buff[2+buffOffset] = '-'; + buff[3+buffOffset] = SYM_MAH_KM_0; + buff[4+buffOffset] = SYM_MAH_KM_1; + buff[5+buffOffset] = '\0'; + } + } else { + osdFormatCentiNumber(buff + buffOffset, (int32_t)(getMWhDrawn() * 10000.0f / totalDistance), 0, 2, 0, digits, false); + tfp_sprintf(buff, "%s%c", buff, SYM_WH_KM); + if (!efficiencyValid) { + buff[0+buffOffset] = buff[1+buffOffset] = buff[2+buffOffset] = '-'; } } + } + + osdLeftAlignString(buff); + displayWrite(osdDisplayPort, statValX, row++, buff); + + return row; +} + +uint8_t drawStat_RXStats(uint8_t col, uint8_t row, uint8_t statValX) { + char buff[20]; + uint8_t multiValueXOffset = 0; + + tfp_sprintf(buff, "MIN RSSI"); + if (rxConfig()->serialrx_provider == SERIALRX_CRSF) + strcat(buff, "/LQ"); + displayWrite(osdDisplayPort, col, row, buff); + + memset(buff, '\0', strlen(buff)); + tfp_sprintf(buff, ": "); + itoa(stats.min_rssi, buff + 2, 10); + strcat(osdFormatTrimWhiteSpace(buff), "%"); + + if (rxConfig()->serialrx_provider == SERIALRX_CRSF) { + multiValueXOffset = strlen(buff); + itoa(stats.min_lq, buff + multiValueXOffset, 10); + strcat(osdFormatTrimWhiteSpace(buff), "%"); + } + + displayWrite(osdDisplayPort, statValX, row, buff); + + if (rxConfig()->serialrx_provider == SERIALRX_CRSF) { + displayWrite(osdDisplayPort, col, row, "MIN RX DBM"); + memset(buff, '\0', strlen(buff)); + tfp_sprintf(buff, ": "); + itoa(stats.min_rssi_dbm, buff + 2, 10); + tfp_sprintf(buff, "%s%c", buff, SYM_DBM); + displayWrite(osdDisplayPort, statValX, row++, buff); + } + + return row; +} + +uint8_t drawStat_GPS(uint8_t col, uint8_t row, uint8_t statValX) { + char buff[12]; + displayWrite(osdDisplayPort, col, row, "MIN/MAX GPS SATS"); + tfp_sprintf(buff, ": %u/%u", stats.min_sats, stats.max_sats); + displayWrite(osdDisplayPort, statValX, row++, buff); + + return row; +} + +uint8_t drawStat_GForce(uint8_t col, uint8_t row, uint8_t statValX) { + char buff[12]; + uint8_t multiValueXOffset = 0; + + const float max_gforce = accGetMeasuredMaxG(); + displayWrite(osdDisplayPort, col, row, "MAX G-FORCE"); + tfp_sprintf(buff, ": "); + osdFormatCentiNumber(buff + 2, max_gforce * 100, 0, 2, 0, 3, false); + displayWrite(osdDisplayPort, statValX, row++, buff); + + const acc_extremes_t *acc_extremes = accGetMeasuredExtremes(); + const float acc_extremes_min = acc_extremes[Z].min; + const float acc_extremes_max = acc_extremes[Z].max; + displayWrite(osdDisplayPort, col, row, "MIN/MAX Z G-FORCE"); + memset(buff, '\0', strlen(buff)); + tfp_sprintf(buff, ": "); + osdFormatCentiNumber(buff + 2, acc_extremes_min * 100, 0, 2, 0, 4, false); + osdLeftAlignString(buff); + strcat(osdFormatTrimWhiteSpace(buff),"/"); + + multiValueXOffset = strlen(buff); + osdFormatCentiNumber(buff + multiValueXOffset, acc_extremes_max * 100, 0, 2, 0, 3, false); + osdLeftAlignString(buff); + displayWrite(osdDisplayPort, statValX + multiValueXOffset, row++, buff); + + return row; +} + +uint8_t drawStat_DisarmMethod(uint8_t col, uint8_t row, uint8_t statValX) { + const char * disarmReasonStr[DISARM_REASON_COUNT] = { "UNKNOWN", "TIMEOUT", "STICKS", "SWITCH", "SWITCH", "KILLSW", "FAILSAFE", "NAV SYS", "LANDING"}; + + displayWrite(osdDisplayPort, col, row, "DISARMED BY"); + displayWrite(osdDisplayPort, statValX, row, ": "); + displayWrite(osdDisplayPort, statValX + 2, row++, disarmReasonStr[getDisarmReason()]); + + return row; +} + +static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page) +{ + const char * statsHeader[3] = {"*** STATS ***", "*** STATS (1/2 ->) ***", "*** STATS (<- 2/2) ***"}; + uint8_t row = 1; // Start one line down leaving space at the top of the screen. - const float max_gforce = accGetMeasuredMaxG(); - displayWrite(osdDisplayPort, statNameX, top, "MAX G-FORCE :"); - osdFormatCentiNumber(buff, max_gforce * 100, 0, 2, 0, 3, false); - displayWrite(osdDisplayPort, statValuesX, top++, buff); + const uint8_t statNameX = osdDisplayIsHD() ? 11 : 1; + const uint8_t statValuesX = osdDisplayIsHD() ? 30 : 18; + + if (page > 1) + page = 0; - const acc_extremes_t *acc_extremes = accGetMeasuredExtremes(); - const float acc_extremes_min = acc_extremes[Z].min; - const float acc_extremes_max = acc_extremes[Z].max; - displayWrite(osdDisplayPort, statNameX, top, "MIN/MAX Z G-FORCE:"); - osdFormatCentiNumber(buff, acc_extremes_min * 100, 0, 2, 0, 4, false); - osdLeftAlignString(buff); - strcat(osdFormatTrimWhiteSpace(buff),"/"); - multiValueLengthOffset = strlen(buff); - displayWrite(osdDisplayPort, statValuesX, top, buff); - osdFormatCentiNumber(buff, acc_extremes_max * 100, 0, 2, 0, 3, false); - osdLeftAlignString(buff); - displayWrite(osdDisplayPort, statValuesX + multiValueLengthOffset, top++, buff); + displayBeginTransaction(osdDisplayPort, DISPLAY_TRANSACTION_OPT_RESET_DRAWING); + displayClearScreen(osdDisplayPort); + + if (isSinglePageStatsCompatible) { + displayWrite(osdDisplayPort, (osdDisplayPort->cols - strlen( statsHeader[0])) / 2, row++, statsHeader[0]); + } else { + displayWrite(osdDisplayPort, (osdDisplayPort->cols - strlen( statsHeader[page + 1])) / 2, row++, statsHeader[page + 1]); + } + + if (isSinglePageStatsCompatible) { + row = drawStat_FlightTime(statNameX, row, statValuesX); + row = drawStat_FlightDistance(statNameX, row, statValuesX); + row = drawStat_MaxDistanceFromHome(statNameX, row, statValuesX); + if (feature(FEATURE_GPS)) row = drawStat_Speed(statNameX, row, statValuesX); + row = drawStat_MaximumAltitude(statNameX, row, statValuesX); + row = drawStat_BatteryVoltage(statNameX, row, statValuesX); + if (feature(FEATURE_CURRENT_METER)) row = drawStat_MaximumCurrent(statNameX, row, statValuesX); + if (feature(FEATURE_CURRENT_METER))row = drawStat_MaximumPower(statNameX, row, statValuesX); + if (feature(FEATURE_CURRENT_METER))row = drawStat_UsedEnergy(statNameX, row, statValuesX); + if (feature(FEATURE_CURRENT_METER) && feature(FEATURE_GPS)) row = drawStat_AverageEfficiency(statNameX, row, statValuesX); + row = drawStat_RXStats(statNameX, row, statValuesX); + if (feature(FEATURE_GPS))row = drawStat_GPS(statNameX, row, statValuesX); + + if (row < (osdDisplayPort->cols-3)) row = drawStat_GForce(statNameX, row, statValuesX); + // if (row < (osdDisplayPort->cols-2)) row = drawStat_FlightTime(statNameX, row, statValuesX); + } else { + switch (page) { + case 0: + row = drawStat_FlightTime(statNameX, row, statValuesX); + row = drawStat_FlightDistance(statNameX, row, statValuesX); + row = drawStat_Speed(statNameX, row, statValuesX); + row = drawStat_MaximumAltitude(statNameX, row, statValuesX); + row = drawStat_BatteryVoltage(statNameX, row, statValuesX); + if (feature(FEATURE_CURRENT_METER)) row = drawStat_MaximumCurrent(statNameX, row, statValuesX); + if (feature(FEATURE_CURRENT_METER))row = drawStat_MaximumPower(statNameX, row, statValuesX); + if (feature(FEATURE_CURRENT_METER))row = drawStat_UsedEnergy(statNameX, row, statValuesX); + if (feature(FEATURE_CURRENT_METER) && feature(FEATURE_GPS)) row = drawStat_AverageEfficiency(statNameX, row, statValuesX); + break; + case 1: + row = drawStat_MaxDistanceFromHome(statNameX, row, statValuesX); + row = drawStat_RXStats(statNameX, row, statValuesX); + if (feature(FEATURE_GPS))row = drawStat_GPS(statNameX, row, statValuesX); + row = drawStat_GForce(statNameX, row, statValuesX); + //row = drawStat_FlightTime(statNameX, row, statValuesX); + //row = drawStat_FlightTime(statNameX, row, statValuesX); + //row = drawStat_FlightTime(statNameX, row, statValuesX); + //row = drawStat_FlightTime(statNameX, row, statValuesX); + //row = drawStat_FlightTime(statNameX, row, statValuesX); + break; + } } + + row = drawStat_DisarmMethod(statNameX, row, statValuesX); if (savingSettings == true) { - displayWrite(osdDisplayPort, statNameX, top++, OSD_MESSAGE_STR(OSD_MSG_SAVING_SETTNGS)); + displayWrite(osdDisplayPort, statNameX, row++, OSD_MESSAGE_STR(OSD_MSG_SAVING_SETTNGS)); } else if (notify_settings_saved > 0) { if (millis() > notify_settings_saved) { notify_settings_saved = 0; } else { - displayWrite(osdDisplayPort, statNameX, top++, OSD_MESSAGE_STR(OSD_MSG_SETTINGS_SAVED)); + displayWrite(osdDisplayPort, statNameX, row++, OSD_MESSAGE_STR(OSD_MSG_SETTINGS_SAVED)); } } From b1cbfaa838fb72dcc11ea186bfd318673813e7bb Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Sun, 24 Dec 2023 11:56:43 +0000 Subject: [PATCH 030/241] Added ESC temperature stat --- src/main/io/osd.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 8a6b21779be..3d50fd58d01 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -179,6 +179,8 @@ typedef struct statistic_s { uint32_t max_distance; uint8_t min_sats; uint8_t max_sats; + int16_t max_esc_temp; + int16_t min_esc_temp; } statistic_t; static statistic_t stats; @@ -4301,6 +4303,19 @@ static void osdUpdateStats(void) stats.max_sats = gpsSol.numSat; } + if (STATE(ESC_SENSOR_ENABLED)) { + escSensorData_t * escSensor = escSensorGetData(); + bool escTemperatureValid = escSensor && escSensor->dataAge <= ESC_DATA_MAX_AGE; + + if (escTemperatureValid) { + if (stats.min_esc_temp > escSensor->temperature) + stats.min_esc_temp = escSensor->temperature; + + if (stats.max_esc_temp < escSensor->temperature) + stats.max_esc_temp = escSensor->temperature; + } + } + value = getBatteryVoltage(); if (stats.min_voltage > value) stats.min_voltage = value; @@ -4594,6 +4609,18 @@ uint8_t drawStat_GPS(uint8_t col, uint8_t row, uint8_t statValX) { return row; } +uint8_t drawStat_ESCTemperature(uint8_t col, uint8_t row, uint8_t statValX) { + char buff[12]; + displayWrite(osdDisplayPort, col, row, "MIN/MAX ESC TEMP"); + tfp_sprintf(buff, ": %3d/%3d%c", + ((osdConfig()->units == OSD_UNIT_IMPERIAL) ? (int16_t)(stats.min_esc_temp * 9 / 5.0f + 320) : stats.min_esc_temp), + ((osdConfig()->units == OSD_UNIT_IMPERIAL) ? (int16_t)(stats.max_esc_temp * 9 / 5.0f + 320) : stats.max_esc_temp), + ((osdConfig()->units == OSD_UNIT_IMPERIAL) ? SYM_TEMP_F : SYM_TEMP_C)); + displayWrite(osdDisplayPort, statValX, row++, buff); + + return row; +} + uint8_t drawStat_GForce(uint8_t col, uint8_t row, uint8_t statValX) { char buff[12]; uint8_t multiValueXOffset = 0; @@ -4664,7 +4691,8 @@ static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page) if (feature(FEATURE_CURRENT_METER))row = drawStat_UsedEnergy(statNameX, row, statValuesX); if (feature(FEATURE_CURRENT_METER) && feature(FEATURE_GPS)) row = drawStat_AverageEfficiency(statNameX, row, statValuesX); row = drawStat_RXStats(statNameX, row, statValuesX); - if (feature(FEATURE_GPS))row = drawStat_GPS(statNameX, row, statValuesX); + if (feature(FEATURE_GPS)) row = drawStat_GPS(statNameX, row, statValuesX); + if (STATE(ESC_SENSOR_ENABLED)) row = drawStat_ESCTemperature(statNameX, row, statValuesX); if (row < (osdDisplayPort->cols-3)) row = drawStat_GForce(statNameX, row, statValuesX); // if (row < (osdDisplayPort->cols-2)) row = drawStat_FlightTime(statNameX, row, statValuesX); @@ -4685,12 +4713,12 @@ static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page) row = drawStat_MaxDistanceFromHome(statNameX, row, statValuesX); row = drawStat_RXStats(statNameX, row, statValuesX); if (feature(FEATURE_GPS))row = drawStat_GPS(statNameX, row, statValuesX); + if (STATE(ESC_SENSOR_ENABLED)) row = drawStat_ESCTemperature(statNameX, row, statValuesX); row = drawStat_GForce(statNameX, row, statValuesX); //row = drawStat_FlightTime(statNameX, row, statValuesX); //row = drawStat_FlightTime(statNameX, row, statValuesX); //row = drawStat_FlightTime(statNameX, row, statValuesX); //row = drawStat_FlightTime(statNameX, row, statValuesX); - //row = drawStat_FlightTime(statNameX, row, statValuesX); break; } } From 952c8338c7c1cdd972271d4dd577889eb24d56be Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Sun, 24 Dec 2023 12:15:01 +0000 Subject: [PATCH 031/241] Centred the settings saved message --- src/main/io/osd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 3d50fd58d01..ea8e550b3f9 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -4674,9 +4674,9 @@ static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page) displayClearScreen(osdDisplayPort); if (isSinglePageStatsCompatible) { - displayWrite(osdDisplayPort, (osdDisplayPort->cols - strlen( statsHeader[0])) / 2, row++, statsHeader[0]); + displayWrite(osdDisplayPort, (osdDisplayPort->cols - strlen(statsHeader[0])) / 2, row++, statsHeader[0]); } else { - displayWrite(osdDisplayPort, (osdDisplayPort->cols - strlen( statsHeader[page + 1])) / 2, row++, statsHeader[page + 1]); + displayWrite(osdDisplayPort, (osdDisplayPort->cols - strlen(statsHeader[page + 1])) / 2, row++, statsHeader[page + 1]); } if (isSinglePageStatsCompatible) { @@ -4726,12 +4726,12 @@ static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page) row = drawStat_DisarmMethod(statNameX, row, statValuesX); if (savingSettings == true) { - displayWrite(osdDisplayPort, statNameX, row++, OSD_MESSAGE_STR(OSD_MSG_SAVING_SETTNGS)); + displayWrite(osdDisplayPort, (osdDisplayPort->cols - strlen(OSD_MESSAGE_STR(OSD_MSG_SAVING_SETTNGS))) / 2, row++, OSD_MESSAGE_STR(OSD_MSG_SAVING_SETTNGS)); } else if (notify_settings_saved > 0) { if (millis() > notify_settings_saved) { notify_settings_saved = 0; } else { - displayWrite(osdDisplayPort, statNameX, row++, OSD_MESSAGE_STR(OSD_MSG_SETTINGS_SAVED)); + displayWrite(osdDisplayPort, (osdDisplayPort->cols - strlen(OSD_MESSAGE_STR(OSD_MSG_SETTINGS_SAVED))) / 2, row++, OSD_MESSAGE_STR(OSD_MSG_SETTINGS_SAVED)); } } From d22c039f929c2e24dc43faa4c78d222e36e13472 Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Tue, 26 Dec 2023 07:47:54 +0000 Subject: [PATCH 032/241] Some re-arrangement for HD not tested --- src/main/io/osd.c | 59 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 15 deletions(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index ea8e550b3f9..80624d4abea 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -4372,7 +4372,10 @@ uint8_t drawStat_FlightDistance(uint8_t col, uint8_t row, uint8_t statValX) { uint8_t drawStat_MaxDistanceFromHome(uint8_t col, uint8_t row, uint8_t statValX) { char buff[12]; - displayWrite(osdDisplayPort, col, row, "DISTANCE FROM "); + if (!osdDisplayIsHD()) + displayWrite(osdDisplayPort, col, row, "DISTANCE FROM "); + else + displayWrite(osdDisplayPort, col, row, "MAX DISTANCE FROM "); displayWriteChar(osdDisplayPort, col + 14, row, SYM_HOME); tfp_sprintf(buff, ": "); osdFormatDistanceStr(buff + 2, stats.max_distance * 100); @@ -4413,7 +4416,10 @@ uint8_t drawStat_MaximumAltitude(uint8_t col, uint8_t row, uint8_t statValX) { uint8_t drawStat_BatteryVoltage(uint8_t col, uint8_t row, uint8_t statValX) { char buff[12]; uint8_t multiValueXOffset = 0; - displayWrite(osdDisplayPort, col, row, "MIN VOLTS P/C"); + if (!osdDisplayIsHD()) + displayWrite(osdDisplayPort, col, row, "MIN VOLTS P/C"); + else + displayWrite(osdDisplayPort, col, row, "MIN VOLTS PACK/CELL"); // Pack voltage tfp_sprintf(buff, ": "); @@ -4571,8 +4577,12 @@ uint8_t drawStat_RXStats(uint8_t col, uint8_t row, uint8_t statValX) { uint8_t multiValueXOffset = 0; tfp_sprintf(buff, "MIN RSSI"); - if (rxConfig()->serialrx_provider == SERIALRX_CRSF) + if (rxConfig()->serialrx_provider == SERIALRX_CRSF) { strcat(buff, "/LQ"); + + if (osdDisplayIsHD()) + strcat(buff, "/DBM"); + } displayWrite(osdDisplayPort, col, row, buff); memset(buff, '\0', strlen(buff)); @@ -4581,14 +4591,22 @@ uint8_t drawStat_RXStats(uint8_t col, uint8_t row, uint8_t statValX) { strcat(osdFormatTrimWhiteSpace(buff), "%"); if (rxConfig()->serialrx_provider == SERIALRX_CRSF) { + strcat(osdFormatTrimWhiteSpace(buff), "/"); multiValueXOffset = strlen(buff); itoa(stats.min_lq, buff + multiValueXOffset, 10); strcat(osdFormatTrimWhiteSpace(buff), "%"); + + if (osdDisplayIsHD()) { + strcat(osdFormatTrimWhiteSpace(buff), "/"); + itoa(stats.min_rssi_dbm, buff + 2, 10); + tfp_sprintf(buff, "%s%c", buff, SYM_DBM); + displayWrite(osdDisplayPort, statValX, row++, buff); + } } - displayWrite(osdDisplayPort, statValX, row, buff); + displayWrite(osdDisplayPort, statValX, row++, buff); - if (rxConfig()->serialrx_provider == SERIALRX_CRSF) { + if (!osdDisplayIsHD() && rxConfig()->serialrx_provider == SERIALRX_CRSF) { displayWrite(osdDisplayPort, col, row, "MIN RX DBM"); memset(buff, '\0', strlen(buff)); tfp_sprintf(buff, ": "); @@ -4626,18 +4644,29 @@ uint8_t drawStat_GForce(uint8_t col, uint8_t row, uint8_t statValX) { uint8_t multiValueXOffset = 0; const float max_gforce = accGetMeasuredMaxG(); - displayWrite(osdDisplayPort, col, row, "MAX G-FORCE"); - tfp_sprintf(buff, ": "); - osdFormatCentiNumber(buff + 2, max_gforce * 100, 0, 2, 0, 3, false); - displayWrite(osdDisplayPort, statValX, row++, buff); - const acc_extremes_t *acc_extremes = accGetMeasuredExtremes(); const float acc_extremes_min = acc_extremes[Z].min; const float acc_extremes_max = acc_extremes[Z].max; - displayWrite(osdDisplayPort, col, row, "MIN/MAX Z G-FORCE"); - memset(buff, '\0', strlen(buff)); + + if (!osdDisplayIsHD()) + displayWrite(osdDisplayPort, col, row, "MAX G-FORCE"); + else + displayWrite(osdDisplayPort, col, row, "MAX/MIN Z/MAX Z G-FORCE"); + tfp_sprintf(buff, ": "); - osdFormatCentiNumber(buff + 2, acc_extremes_min * 100, 0, 2, 0, 4, false); + osdFormatCentiNumber(buff + 2, max_gforce * 100, 0, 2, 0, 3, false); + + if (!osdDisplayIsHD()) { + displayWrite(osdDisplayPort, statValX, row++, buff); + + displayWrite(osdDisplayPort, col, row, "MIN/MAX Z G-FORCE"); + memset(buff, '\0', strlen(buff)); + tfp_sprintf(buff, ": "); + } else { + strcat(osdFormatTrimWhiteSpace(buff),"/"); + } + multiValueXOffset = strlen(buff); + osdFormatCentiNumber(buff + multiValueXOffset, acc_extremes_min * 100, 0, 2, 0, 4, false); osdLeftAlignString(buff); strcat(osdFormatTrimWhiteSpace(buff),"/"); @@ -4664,8 +4693,8 @@ static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page) const char * statsHeader[3] = {"*** STATS ***", "*** STATS (1/2 ->) ***", "*** STATS (<- 2/2) ***"}; uint8_t row = 1; // Start one line down leaving space at the top of the screen. - const uint8_t statNameX = osdDisplayIsHD() ? 11 : 1; - const uint8_t statValuesX = osdDisplayIsHD() ? 30 : 18; + const uint8_t statNameX = (osdDisplayPort->cols - (osdDisplayIsHD() ? 41 : 28)) / 2; + const uint8_t statValuesX = osdDisplayPort->cols - statNameX - (osdDisplayIsHD() ? 15 : 11); if (page > 1) page = 0; From 2632abbbd2204da035340b8a037950adcb94da9a Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Wed, 27 Dec 2023 16:48:59 +0000 Subject: [PATCH 033/241] Added Blackbox stuff - Added blackbox file number to stats title (HD) - Added blackbox OSD element --- src/main/blackbox/blackbox_io.c | 34 +++++++++++++++++++++ src/main/blackbox/blackbox_io.h | 2 ++ src/main/drivers/osd_symbols.h | 2 ++ src/main/io/osd.c | 53 +++++++++++++++++++++++++++++---- src/main/io/osd.h | 1 + 5 files changed, 87 insertions(+), 5 deletions(-) diff --git a/src/main/blackbox/blackbox_io.c b/src/main/blackbox/blackbox_io.c index 7a6f04149d3..3e6adb719b7 100644 --- a/src/main/blackbox/blackbox_io.c +++ b/src/main/blackbox/blackbox_io.c @@ -35,6 +35,10 @@ #include "config/parameter_group.h" #include "config/parameter_group_ids.h" +#ifdef USE_SDCARD +#include "drivers/sdcard/sdcard.h" +#endif + #include "io/asyncfatfs/asyncfatfs.h" #include "io/flashfs.h" #include "io/serial.h" @@ -507,6 +511,36 @@ bool isBlackboxDeviceFull(void) } } +bool isBlackboxDeviceWorking(void) +{ + switch (blackboxConfig()->device) { + case BLACKBOX_DEVICE_SERIAL: + return blackboxPort != NULL; +#ifdef USE_SDCARD + case BLACKBOX_DEVICE_SDCARD: + return sdcard_isInserted() && sdcard_isFunctional() && (afatfs_getFilesystemState() == AFATFS_FILESYSTEM_STATE_READY); +#endif +#ifdef USE_FLASHFS + case BLACKBOX_DEVICE_FLASH: + return flashfsIsReady(); +#endif + default: + return false; + } +} + +int32_t blackboxGetLogNumber(void) +{ + switch (blackboxConfig()->device) { +#ifdef USE_SDCARD + case BLACKBOX_DEVICE_SDCARD: + return blackboxSDCard.largestLogFileNumber; +#endif + default: + return -1; + } +} + /** * Call once every loop iteration in order to maintain the global blackboxHeaderBudget with the number of bytes we can * transmit this iteration. diff --git a/src/main/blackbox/blackbox_io.h b/src/main/blackbox/blackbox_io.h index e71fdadca30..d143b72098d 100644 --- a/src/main/blackbox/blackbox_io.h +++ b/src/main/blackbox/blackbox_io.h @@ -67,6 +67,8 @@ bool blackboxDeviceBeginLog(void); bool blackboxDeviceEndLog(bool retainLog); bool isBlackboxDeviceFull(void); +bool isBlackboxDeviceWorking(void); +int32_t blackboxGetLogNumber(void); void blackboxReplenishHeaderBudget(void); blackboxBufferReserveStatus_e blackboxDeviceReserveBufferSpace(int32_t bytes); diff --git a/src/main/drivers/osd_symbols.h b/src/main/drivers/osd_symbols.h index d645184e5b4..47e8032b05f 100644 --- a/src/main/drivers/osd_symbols.h +++ b/src/main/drivers/osd_symbols.h @@ -178,6 +178,8 @@ #define SYM_ALERT 0xDD // 221 General alert symbol #define SYM_TERRAIN_FOLLOWING 0xFB // 251 Terrain following (also Alt adjust) #define SYM_CROSS_TRACK_ERROR 0xFC // 252 Cross track error +#define SYM_ADSB 0xFD // 253 ADBS +#define SYM_BLACKBOX 0xFE // 254 Blackbox #define SYM_LOGO_START 0x101 // 257 to 297, INAV logo diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 80624d4abea..98873dfaf0a 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -111,6 +111,10 @@ #include "programming/logic_condition.h" #include "programming/global_variables.h" +#ifdef USE_BLACKBOX +#include "blackbox/blackbox_io.h" +#endif + #ifdef USE_HARDWARE_REVISION_DETECTION #include "hardware_revision.h" #endif @@ -1971,6 +1975,27 @@ static bool osdDrawSingleElement(uint8_t item) osdFormatDistanceSymbol(buff + 1, getTotalTravelDistance(), 0); break; + case OSD_BLACKBOX: + { +#ifdef USE_BLACKBOX + if (IS_RC_MODE_ACTIVE(BOXBLACKBOX)) { + if (!isBlackboxDeviceWorking()) { + tfp_sprintf(buff, "%c%c", SYM_BLACKBOX, SYM_ALERT); + } else if (isBlackboxDeviceFull()) { + tfp_sprintf(buff, "%cFULL", SYM_BLACKBOX); + } else { + int32_t logNumber = blackboxGetLogNumber(); + if (logNumber >= 0) { + tfp_sprintf(buff, "%c%5ld", SYM_BLACKBOX, logNumber); + } else { + tfp_sprintf(buff, "%c", SYM_BLACKBOX); + } + } + } +#endif // USE_BLACKBOX + } + break; + case OSD_ODOMETER: { displayWriteChar(osdDisplayPort, elemPosX, elemPosY, SYM_ODOMETER); @@ -4025,6 +4050,10 @@ void pgResetFn_osdLayoutsConfig(osdLayoutsConfig_t *osdLayoutsConfig) osdLayoutsConfig->item_pos[0][OSD_PLIMIT_ACTIVE_POWER_LIMIT] = OSD_POS(3, 6); #endif +#ifdef USE_BLACKBOX + osdLayoutsConfig->item_pos[0][OSD_BLACKBOX] = OSD_POS(2, 10); +#endif + // Under OSD_FLYMODE. TODO: Might not be visible on NTSC? osdLayoutsConfig->item_pos[0][OSD_MESSAGES] = OSD_POS(1, 13) | OSD_VISIBLE_FLAG; @@ -4690,7 +4719,7 @@ uint8_t drawStat_DisarmMethod(uint8_t col, uint8_t row, uint8_t statValX) { static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page) { - const char * statsHeader[3] = {"*** STATS ***", "*** STATS (1/2 ->) ***", "*** STATS (<- 2/2) ***"}; + const char * statsHeader[2] = {"*** STATS (1/2 ->) ***", "*** STATS (<- 2/2) ***"}; uint8_t row = 1; // Start one line down leaving space at the top of the screen. const uint8_t statNameX = (osdDisplayPort->cols - (osdDisplayIsHD() ? 41 : 28)) / 2; @@ -4703,10 +4732,24 @@ static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page) displayClearScreen(osdDisplayPort); if (isSinglePageStatsCompatible) { - displayWrite(osdDisplayPort, (osdDisplayPort->cols - strlen(statsHeader[0])) / 2, row++, statsHeader[0]); - } else { - displayWrite(osdDisplayPort, (osdDisplayPort->cols - strlen(statsHeader[page + 1])) / 2, row++, statsHeader[page + 1]); - } + char buff[20]; + tfp_sprintf(buff, "*** STATS "); +#ifdef USE_BLACKBOX +#ifdef USE_SDCARD + if (feature(FEATURE_BLACKBOX)) { + int32_t logNumber = blackboxGetLogNumber(); + if (logNumber >= 0) + tfp_sprintf(buff, "%s %c%5ld ", buff, SYM_BLACKBOX, logNumber); + else + tfp_sprintf(buff, "%s %c ", buff, SYM_BLACKBOX); + } +#endif +#endif + tfp_sprintf(buff, "%s***", buff); + + displayWrite(osdDisplayPort, (osdDisplayPort->cols - strlen(buff)) / 2, row++, buff); + } else + displayWrite(osdDisplayPort, (osdDisplayPort->cols - strlen(statsHeader[page + 1])) / 2, row++, statsHeader[page]); if (isSinglePageStatsCompatible) { row = drawStat_FlightTime(statNameX, row, statValuesX); diff --git a/src/main/io/osd.h b/src/main/io/osd.h index 5bcf6d34740..0c4050066a4 100644 --- a/src/main/io/osd.h +++ b/src/main/io/osd.h @@ -280,6 +280,7 @@ typedef enum { OSD_MULTI_FUNCTION, OSD_ODOMETER, OSD_PILOT_LOGO, + OSD_BLACKBOX, OSD_ITEM_COUNT // MUST BE LAST } osd_items_e; From 1753ed13833df23ec6d2d54720a3b899c891b848 Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Fri, 29 Dec 2023 21:41:12 +0000 Subject: [PATCH 034/241] Added blackbox to multipage stats --- src/main/io/osd.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 98873dfaf0a..af4b9ce700c 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -1986,7 +1986,7 @@ static bool osdDrawSingleElement(uint8_t item) } else { int32_t logNumber = blackboxGetLogNumber(); if (logNumber >= 0) { - tfp_sprintf(buff, "%c%5ld", SYM_BLACKBOX, logNumber); + tfp_sprintf(buff, "%c%05ld", SYM_BLACKBOX, logNumber); } else { tfp_sprintf(buff, "%c", SYM_BLACKBOX); } @@ -4739,7 +4739,7 @@ static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page) if (feature(FEATURE_BLACKBOX)) { int32_t logNumber = blackboxGetLogNumber(); if (logNumber >= 0) - tfp_sprintf(buff, "%s %c%5ld ", buff, SYM_BLACKBOX, logNumber); + tfp_sprintf(buff, "%s %c%05ld ", buff, SYM_BLACKBOX, logNumber); else tfp_sprintf(buff, "%s %c ", buff, SYM_BLACKBOX); } @@ -4790,7 +4790,25 @@ static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page) //row = drawStat_FlightTime(statNameX, row, statValuesX); //row = drawStat_FlightTime(statNameX, row, statValuesX); //row = drawStat_FlightTime(statNameX, row, statValuesX); - //row = drawStat_FlightTime(statNameX, row, statValuesX); +#ifdef USE_BLACKBOX +#ifdef USE_SDCARD + if (feature(FEATURE_BLACKBOX)) { + char buff[12]; + displayWrite(osdDisplayPort, statNameX, row, "BLACKBOX FILE"); + + tfp_sprintf(buff, ": %u/%u", stats.min_sats, stats.max_sats); + + int32_t logNumber = blackboxGetLogNumber(); + if (logNumber >= 0) + tfp_sprintf(buff, ": %05ld ", logNumber); + else + tfp_sprintf(buff, ": %s", "INVALID"); + + displayWrite(osdDisplayPort, statValuesX, row++, buff); + } +#endif +#endif + break; } } From 1efec56b8e69a82507e52ded481eb53b298f16e4 Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Sun, 31 Dec 2023 16:44:55 +0000 Subject: [PATCH 035/241] Update osd.c --- src/main/io/osd.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index af4b9ce700c..5e591509974 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -4401,11 +4401,15 @@ uint8_t drawStat_FlightDistance(uint8_t col, uint8_t row, uint8_t statValX) { uint8_t drawStat_MaxDistanceFromHome(uint8_t col, uint8_t row, uint8_t statValX) { char buff[12]; - if (!osdDisplayIsHD()) + uint8_t valueXOffset = 0; + if (!osdDisplayIsHD()) { displayWrite(osdDisplayPort, col, row, "DISTANCE FROM "); - else + valueXOffset = 14; + } else { displayWrite(osdDisplayPort, col, row, "MAX DISTANCE FROM "); - displayWriteChar(osdDisplayPort, col + 14, row, SYM_HOME); + valueXOffset = 18; + } + displayWriteChar(osdDisplayPort, col + valueXOffset, row, SYM_HOME); tfp_sprintf(buff, ": "); osdFormatDistanceStr(buff + 2, stats.max_distance * 100); displayWrite(osdDisplayPort, statValX, row++, buff); @@ -4505,6 +4509,7 @@ uint8_t drawStat_AverageEfficiency(uint8_t col, uint8_t row, uint8_t statValX) { char buff[15]; uint8_t buffOffset = 2; int32_t totalDistance = getTotalTravelDistance(); + bool isDJI = false; bool moreThanAh = false; bool efficiencyValid = totalDistance >= 10000; @@ -4516,6 +4521,7 @@ uint8_t drawStat_AverageEfficiency(uint8_t col, uint8_t row, uint8_t statValX) { if (isBfCompatibleVideoSystem(osdConfig())) { // Add one digit so no switch to scaled decimal occurs above 99 digits = 4U; + isDJI = true; } #endif switch (osdConfig()->units) { @@ -4567,12 +4573,12 @@ uint8_t drawStat_AverageEfficiency(uint8_t col, uint8_t row, uint8_t statValX) { break; } - if (statValX > 20 && osdConfig()->units != OSD_UNIT_METRIC_MPH && osdConfig()->units != OSD_UNIT_METRIC) { + if (!isDJI && osdConfig()->units != OSD_UNIT_METRIC_MPH && osdConfig()->units != OSD_UNIT_METRIC) { strcat(osdFormatTrimWhiteSpace(buff), "/"); buffOffset = strlen(buff); } - if (statValX > 20 || (osdConfig()->units != OSD_UNIT_METRIC_MPH || osdConfig()->units != OSD_UNIT_METRIC)) { + if (!isDJI || osdConfig()->units == OSD_UNIT_METRIC_MPH || osdConfig()->units == OSD_UNIT_METRIC) { if (osdConfig()->stats_energy_unit == OSD_STATS_ENERGY_UNIT_MAH) { moreThanAh = osdFormatCentiNumber(buff + buffOffset, (int32_t)(getMAhDrawn() * 10000000.0f / totalDistance), 1000, 0, 2, digits, false); if (!moreThanAh) { @@ -4702,7 +4708,7 @@ uint8_t drawStat_GForce(uint8_t col, uint8_t row, uint8_t statValX) { multiValueXOffset = strlen(buff); osdFormatCentiNumber(buff + multiValueXOffset, acc_extremes_max * 100, 0, 2, 0, 3, false); osdLeftAlignString(buff); - displayWrite(osdDisplayPort, statValX + multiValueXOffset, row++, buff); + displayWrite(osdDisplayPort, statValX, row++, buff); return row; } From 46512f436a6c2184eac956090dea8170e126bdef Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Thu, 4 Jan 2024 08:41:46 +0000 Subject: [PATCH 036/241] Updates - Updated OSD.md. - Added setting for also displaying metric efficiency. - Removed setting for `osd_stats_min_voltage_unit` as both are now shown. - Added reset methods for stats not held in the OSD. - Fixed issue where all stats would not reset on arm. Battery used maintains pack usage, as well as flight usage. - Added missing FEATURE(GPS) on distance from home and speed (analogue). - OSD stats only update while armed. --- docs/OSD.md | 339 ++++++++++++++++++-------------- docs/Settings.md | 12 +- src/main/fc/fc_core.c | 4 + src/main/fc/fc_core.h | 1 + src/main/fc/settings.yaml | 14 +- src/main/io/osd.c | 230 +++++++++++++--------- src/main/io/osd.h | 7 +- src/main/sensors/acceleration.c | 9 + src/main/sensors/acceleration.h | 1 + 9 files changed, 354 insertions(+), 263 deletions(-) diff --git a/docs/OSD.md b/docs/OSD.md index b3526d0d761..eb8564bbe82 100644 --- a/docs/OSD.md +++ b/docs/OSD.md @@ -19,155 +19,156 @@ Not all OSDs are created equally. This table shows the differences between the d ## OSD Elements Here are the OSD Elements provided by INAV. -| ID | Element | Added | -|-----|--------------------------------------------------|--------| -| 0 | OSD_RSSI_VALUE | 1.0.0 | -| 1 | OSD_MAIN_BATT_VOLTAGE | 1.0.0 | -| 2 | OSD_CROSSHAIRS | 1.0.0 | -| 3 | OSD_ARTIFICIAL_HORIZON | 1.0.0 | -| 4 | OSD_HORIZON_SIDEBARS | 1.0.0 | -| 5 | OSD_ONTIME | 1.0.0 | -| 6 | OSD_FLYTIME | 1.0.0 | -| 7 | OSD_FLYMODE | 1.0.0 | -| 8 | OSD_CRAFT_NAME | 1.0.0 | -| 9 | OSD_THROTTLE_POS | 1.0.0 | -| 10 | OSD_VTX_CHANNEL | 1.0.0 | -| 11 | OSD_CURRENT_DRAW | 1.0.0 | -| 12 | OSD_MAH_DRAWN | 1.0.0 | -| 13 | OSD_GPS_SPEED | 1.0.0 | -| 14 | OSD_GPS_SATS | 1.0.0 | -| 15 | OSD_ALTITUDE | 1.0.0 | -| 16 | OSD_ROLL_PIDS | 1.6.0 | -| 17 | OSD_PITCH_PIDS | 1.6.0 | -| 18 | OSD_YAW_PIDS | 1.6.0 | -| 19 | OSD_POWER | 1.6.0 | -| 20 | OSD_GPS_LON | 1.6.0 | -| 21 | OSD_GPS_LAT | 1.6.0 | -| 22 | OSD_HOME_DIR | 1.6.0 | -| 23 | OSD_HOME_DIST | 1.6.0 | -| 24 | OSD_HEADING | 1.6.0 | -| 25 | OSD_VARIO | 1.6.0 | -| 26 | OSD_VARIO_NUM | 1.6.0 | -| 27 | OSD_AIR_SPEED | 1.7.3 | -| 28 | OSD_ONTIME_FLYTIME | 1.8.0 | -| 29 | OSD_RTC_TIME | 1.8.0 | -| 30 | OSD_MESSAGES | 1.8.0 | -| 31 | OSD_GPS_HDOP | 1.8.0 | -| 32 | OSD_MAIN_BATT_CELL_VOLTAGE | 1.8.0 | -| 33 | OSD_SCALED_THROTTLE_POS | 1.8.0 | -| 34 | OSD_HEADING_GRAPH | 1.8.0 | -| 35 | OSD_EFFICIENCY_MAH_PER_KM | 1.9.0 | -| 36 | OSD_WH_DRAWN | 1.9.0 | -| 37 | OSD_BATTERY_REMAINING_CAPACITY | 1.9.0 | -| 38 | OSD_BATTERY_REMAINING_PERCENT | 1.9.0 | -| 39 | OSD_EFFICIENCY_WH_PER_KM | 1.9.0 | -| 40 | OSD_TRIP_DIST | 1.9.1 | -| 41 | OSD_ATTITUDE_PITCH | 2.0.0 | -| 42 | OSD_ATTITUDE_ROLL | 2.0.0 | -| 43 | OSD_MAP_NORTH | 2.0.0 | -| 44 | OSD_MAP_TAKEOFF | 2.0.0 | -| 45 | OSD_RADAR | 2.0.0 | -| 46 | OSD_WIND_SPEED_HORIZONTAL | 2.0.0 | -| 47 | OSD_WIND_SPEED_VERTICAL | 2.0.0 | -| 48 | OSD_REMAINING_FLIGHT_TIME_BEFORE_RTH | 2.0.0 | -| 49 | OSD_REMAINING_DISTANCE_BEFORE_RTH | 2.0.0 | -| 50 | OSD_HOME_HEADING_ERROR | 2.0.0 | -| 51 | OSD_COURSE_HOLD_ERROR | 2.0.0 | -| 52 | OSD_COURSE_HOLD_ADJUSTMENT | 2.0.0 | -| 53 | OSD_SAG_COMPENSATED_MAIN_BATT_VOLTAGE | 2.0.0 | -| 54 | OSD_MAIN_BATT_SAG_COMPENSATED_CELL_VOLTAGE | 2.0.0 | -| 55 | OSD_POWER_SUPPLY_IMPEDANCE | 2.0.0 | -| 56 | OSD_LEVEL_PIDS | 2.0.0 | -| 57 | OSD_POS_XY_PIDS | 2.0.0 | -| 58 | OSD_POS_Z_PIDS | 2.0.0 | -| 59 | OSD_VEL_XY_PIDS | 2.0.0 | -| 60 | OSD_VEL_Z_PIDS | 2.0.0 | -| 61 | OSD_HEADING_P | 2.0.0 | -| 62 | OSD_BOARD_ALIGN_ROLL | 2.0.0 | -| 63 | OSD_BOARD_ALIGN_PITCH | 2.0.0 | -| 64 | OSD_RC_EXPO | 2.0.0 | -| 65 | OSD_RC_YAW_EXPO | 2.0.0 | -| 66 | OSD_THROTTLE_EXPO | 2.0.0 | -| 67 | OSD_PITCH_RATE | 2.0.0 | -| 68 | OSD_ROLL_RATE | 2.0.0 | -| 69 | OSD_YAW_RATE | 2.0.0 | -| 70 | OSD_MANUAL_RC_EXPO | 2.0.0 | -| 71 | OSD_MANUAL_RC_YAW_EXPO | 2.0.0 | -| 72 | OSD_MANUAL_PITCH_RATE | 2.0.0 | -| 73 | OSD_MANUAL_ROLL_RATE | 2.0.0 | -| 74 | OSD_MANUAL_YAW_RATE | 2.0.0 | -| 75 | OSD_NAV_FW_CRUISE_THR | 2.0.0 | -| 76 | OSD_NAV_FW_PITCH2THR | 2.0.0 | -| 77 | OSD_FW_MIN_THROTTLE_DOWN_PITCH_ANGLE | 2.0.0 | -| 78 | OSD_DEBUG | 2.0.0 | -| 79 | OSD_FW_ALT_PID_OUTPUTS | 2.0.0 | -| 80 | OSD_FW_POS_PID_OUTPUTS | 2.0.0 | -| 81 | OSD_MC_VEL_X_PID_OUTPUTS | 2.0.0 | -| 82 | OSD_MC_VEL_Y_PID_OUTPUTS | 2.0.0 | -| 83 | OSD_MC_VEL_Z_PID_OUTPUTS | 2.0.0 | -| 84 | OSD_MC_POS_XYZ_P_OUTPUTS | 2.0.0 | -| 85 | OSD_3D_SPEED | 2.1.0 | -| 86 | OSD_IMU_TEMPERATURE | 2.1.0 | -| 87 | OSD_BARO_TEMPERATURE | 2.1.0 | -| 88 | OSD_TEMP_SENSOR_0_TEMPERATURE | 2.1.0 | -| 89 | OSD_TEMP_SENSOR_1_TEMPERATURE | 2.1.0 | -| 90 | OSD_TEMP_SENSOR_2_TEMPERATURE | 2.1.0 | -| 91 | OSD_TEMP_SENSOR_3_TEMPERATURE | 2.1.0 | -| 92 | OSD_TEMP_SENSOR_4_TEMPERATURE | 2.1.0 | -| 93 | OSD_TEMP_SENSOR_5_TEMPERATURE | 2.1.0 | -| 94 | OSD_TEMP_SENSOR_6_TEMPERATURE | 2.1.0 | -| 95 | OSD_TEMP_SENSOR_7_TEMPERATURE | 2.1.0 | -| 96 | OSD_ALTITUDE_MSL | 2.1.0 | -| 97 | OSD_PLUS_CODE | 2.1.0 | -| 98 | OSD_MAP_SCALE | 2.2.0 | -| 99 | OSD_MAP_REFERENCE | 2.2.0 | -| 100 | OSD_GFORCE | 2.2.0 | -| 101 | OSD_GFORCE_X | 2.2.0 | -| 102 | OSD_GFORCE_Y | 2.2.0 | -| 103 | OSD_GFORCE_Z | 2.2.0 | -| 104 | OSD_RC_SOURCE | 2.2.0 | -| 105 | OSD_VTX_POWER | 2.2.0 | -| 106 | OSD_ESC_RPM | 2.3.0 | -| 107 | OSD_ESC_TEMPERATURE | 2.5.0 | -| 108 | OSD_AZIMUTH | 2.6.0 | -| 109 | OSD_CRSF_RSSI_DBM | 2.6.0 | -| 110 | OSD_CRSF_LQ | 2.6.0 | -| 111 | OSD_CRSF_SNR_DB | 2.6.0 | -| 112 | OSD_CRSF_TX_POWER | 2.6.0 | -| 113 | OSD_GVAR_0 | 2.6.0 | -| 114 | OSD_GVAR_1 | 2.6.0 | -| 115 | OSD_GVAR_2 | 2.6.0 | -| 116 | OSD_GVAR_3 | 2.6.0 | -| 117 | OSD_TPA | 2.6.0 | -| 118 | OSD_NAV_FW_CONTROL_SMOOTHNESS | 2.6.0 | -| 119 | OSD_VERSION | 3.0.0 | -| 120 | OSD_RANGEFINDER | 3.0.0 | -| 121 | OSD_PLIMIT_REMAINING_BURST_TIME | 3.0.0 | -| 122 | OSD_PLIMIT_ACTIVE_CURRENT_LIMIT | 3.0.0 | -| 123 | OSD_PLIMIT_ACTIVE_POWER_LIMIT | 3.0.0 | -| 124 | OSD_GLIDESLOPE | 3.0.1 | -| 125 | OSD_GPS_MAX_SPEED | 4.0.0 | -| 126 | OSD_3D_MAX_SPEED | 4.0.0 | -| 127 | OSD_AIR_MAX_SPEED | 4.0.0 | -| 128 | OSD_ACTIVE_PROFILE | 4.0.0 | -| 129 | OSD_MISSION | 4.0.0 | -| 130 | OSD_SWITCH_INDICATOR_0 | 5.0.0 | -| 131 | OSD_SWITCH_INDICATOR_1 | 5.0.0 | -| 132 | OSD_SWITCH_INDICATOR_2 | 5.0.0 | -| 133 | OSD_SWITCH_INDICATOR_3 | 5.0.0 | -| 134 | OSD_TPA_TIME_CONSTANT | 5.0.0 | -| 135 | OSD_FW_LEVEL_TRIM | 5.0.0 | -| 136 | OSD_GLIDE_TIME_REMAINING | 6.0.0 | -| 137 | OSD_GLIDE_RANGE | 6.0.0 | -| 138 | OSD_CLIMB_EFFICIENCY | 6.0.0 | -| 139 | OSD_NAV_WP_MULTI_MISSION_INDEX | 6.0.0 | -| 140 | OSD_GROUND_COURSE | 6.0.0 | -| 141 | OSD_CROSS_TRACK_ERROR | 6.0.0 | -| 142 | OSD_PILOT_NAME | 6.0.0 | -| 143 | OSD_PAN_SERVO_CENTRED | 6.0.0 | -| 144 | OSD_MULTI_FUNCTION | 7.0.0 | -| 145 | OSD_ODOMETER | 7.0.0 | -| 146 | OSD_PILOT_LOGO | 7.0.0 | +| ID | Element | Added | Notes | +|-----|--------------------------------------------------|--------|-------| +| 0 | OSD_RSSI_VALUE | 1.0.0 | | +| 1 | OSD_MAIN_BATT_VOLTAGE | 1.0.0 | | +| 2 | OSD_CROSSHAIRS | 1.0.0 | | +| 3 | OSD_ARTIFICIAL_HORIZON | 1.0.0 | | +| 4 | OSD_HORIZON_SIDEBARS | 1.0.0 | | +| 5 | OSD_ONTIME | 1.0.0 | | +| 6 | OSD_FLYTIME | 1.0.0 | | +| 7 | OSD_FLYMODE | 1.0.0 | | +| 8 | OSD_CRAFT_NAME | 1.0.0 | | +| 9 | OSD_THROTTLE_POS | 1.0.0 | | +| 10 | OSD_VTX_CHANNEL | 1.0.0 | | +| 11 | OSD_CURRENT_DRAW | 1.0.0 | | +| 12 | OSD_MAH_DRAWN | 1.0.0 | | +| 13 | OSD_GPS_SPEED | 1.0.0 | | +| 14 | OSD_GPS_SATS | 1.0.0 | | +| 15 | OSD_ALTITUDE | 1.0.0 | | +| 16 | OSD_ROLL_PIDS | 1.6.0 | | +| 17 | OSD_PITCH_PIDS | 1.6.0 | | +| 18 | OSD_YAW_PIDS | 1.6.0 | | +| 19 | OSD_POWER | 1.6.0 | | +| 20 | OSD_GPS_LON | 1.6.0 | | +| 21 | OSD_GPS_LAT | 1.6.0 | | +| 22 | OSD_HOME_DIR | 1.6.0 | | +| 23 | OSD_HOME_DIST | 1.6.0 | | +| 24 | OSD_HEADING | 1.6.0 | | +| 25 | OSD_VARIO | 1.6.0 | | +| 26 | OSD_VARIO_NUM | 1.6.0 | | +| 27 | OSD_AIR_SPEED | 1.7.3 | | +| 28 | OSD_ONTIME_FLYTIME | 1.8.0 | | +| 29 | OSD_RTC_TIME | 1.8.0 | | +| 30 | OSD_MESSAGES | 1.8.0 | | +| 31 | OSD_GPS_HDOP | 1.8.0 | | +| 32 | OSD_MAIN_BATT_CELL_VOLTAGE | 1.8.0 | | +| 33 | OSD_SCALED_THROTTLE_POS | 1.8.0 | | +| 34 | OSD_HEADING_GRAPH | 1.8.0 | | +| 35 | OSD_EFFICIENCY_MAH_PER_KM | 1.9.0 | | +| 36 | OSD_WH_DRAWN | 1.9.0 | | +| 37 | OSD_BATTERY_REMAINING_CAPACITY | 1.9.0 | | +| 38 | OSD_BATTERY_REMAINING_PERCENT | 1.9.0 | | +| 39 | OSD_EFFICIENCY_WH_PER_KM | 1.9.0 | | +| 40 | OSD_TRIP_DIST | 1.9.1 | | +| 41 | OSD_ATTITUDE_PITCH | 2.0.0 | | +| 42 | OSD_ATTITUDE_ROLL | 2.0.0 | | +| 43 | OSD_MAP_NORTH | 2.0.0 | | +| 44 | OSD_MAP_TAKEOFF | 2.0.0 | | +| 45 | OSD_RADAR | 2.0.0 | | +| 46 | OSD_WIND_SPEED_HORIZONTAL | 2.0.0 | | +| 47 | OSD_WIND_SPEED_VERTICAL | 2.0.0 | | +| 48 | OSD_REMAINING_FLIGHT_TIME_BEFORE_RTH | 2.0.0 | | +| 49 | OSD_REMAINING_DISTANCE_BEFORE_RTH | 2.0.0 | | +| 50 | OSD_HOME_HEADING_ERROR | 2.0.0 | | +| 51 | OSD_COURSE_HOLD_ERROR | 2.0.0 | | +| 52 | OSD_COURSE_HOLD_ADJUSTMENT | 2.0.0 | | +| 53 | OSD_SAG_COMPENSATED_MAIN_BATT_VOLTAGE | 2.0.0 | | +| 54 | OSD_MAIN_BATT_SAG_COMPENSATED_CELL_VOLTAGE | 2.0.0 | | +| 55 | OSD_POWER_SUPPLY_IMPEDANCE | 2.0.0 | | +| 56 | OSD_LEVEL_PIDS | 2.0.0 | | +| 57 | OSD_POS_XY_PIDS | 2.0.0 | | +| 58 | OSD_POS_Z_PIDS | 2.0.0 | | +| 59 | OSD_VEL_XY_PIDS | 2.0.0 | | +| 60 | OSD_VEL_Z_PIDS | 2.0.0 | | +| 61 | OSD_HEADING_P | 2.0.0 | | +| 62 | OSD_BOARD_ALIGN_ROLL | 2.0.0 | | +| 63 | OSD_BOARD_ALIGN_PITCH | 2.0.0 | | +| 64 | OSD_RC_EXPO | 2.0.0 | | +| 65 | OSD_RC_YAW_EXPO | 2.0.0 | | +| 66 | OSD_THROTTLE_EXPO | 2.0.0 | | +| 67 | OSD_PITCH_RATE | 2.0.0 | | +| 68 | OSD_ROLL_RATE | 2.0.0 | | +| 69 | OSD_YAW_RATE | 2.0.0 | | +| 70 | OSD_MANUAL_RC_EXPO | 2.0.0 | | +| 71 | OSD_MANUAL_RC_YAW_EXPO | 2.0.0 | | +| 72 | OSD_MANUAL_PITCH_RATE | 2.0.0 | | +| 73 | OSD_MANUAL_ROLL_RATE | 2.0.0 | | +| 74 | OSD_MANUAL_YAW_RATE | 2.0.0 | | +| 75 | OSD_NAV_FW_CRUISE_THR | 2.0.0 | | +| 76 | OSD_NAV_FW_PITCH2THR | 2.0.0 | | +| 77 | OSD_FW_MIN_THROTTLE_DOWN_PITCH_ANGLE | 2.0.0 | | +| 78 | OSD_DEBUG | 2.0.0 | | +| 79 | OSD_FW_ALT_PID_OUTPUTS | 2.0.0 | | +| 80 | OSD_FW_POS_PID_OUTPUTS | 2.0.0 | | +| 81 | OSD_MC_VEL_X_PID_OUTPUTS | 2.0.0 | | +| 82 | OSD_MC_VEL_Y_PID_OUTPUTS | 2.0.0 | | +| 83 | OSD_MC_VEL_Z_PID_OUTPUTS | 2.0.0 | | +| 84 | OSD_MC_POS_XYZ_P_OUTPUTS | 2.0.0 | | +| 85 | OSD_3D_SPEED | 2.1.0 | | +| 86 | OSD_IMU_TEMPERATURE | 2.1.0 | | +| 87 | OSD_BARO_TEMPERATURE | 2.1.0 | | +| 88 | OSD_TEMP_SENSOR_0_TEMPERATURE | 2.1.0 | | +| 89 | OSD_TEMP_SENSOR_1_TEMPERATURE | 2.1.0 | | +| 90 | OSD_TEMP_SENSOR_2_TEMPERATURE | 2.1.0 | | +| 91 | OSD_TEMP_SENSOR_3_TEMPERATURE | 2.1.0 | | +| 92 | OSD_TEMP_SENSOR_4_TEMPERATURE | 2.1.0 | | +| 93 | OSD_TEMP_SENSOR_5_TEMPERATURE | 2.1.0 | | +| 94 | OSD_TEMP_SENSOR_6_TEMPERATURE | 2.1.0 | | +| 95 | OSD_TEMP_SENSOR_7_TEMPERATURE | 2.1.0 | | +| 96 | OSD_ALTITUDE_MSL | 2.1.0 | | +| 97 | OSD_PLUS_CODE | 2.1.0 | | +| 98 | OSD_MAP_SCALE | 2.2.0 | | +| 99 | OSD_MAP_REFERENCE | 2.2.0 | | +| 100 | OSD_GFORCE | 2.2.0 | | +| 101 | OSD_GFORCE_X | 2.2.0 | | +| 102 | OSD_GFORCE_Y | 2.2.0 | | +| 103 | OSD_GFORCE_Z | 2.2.0 | | +| 104 | OSD_RC_SOURCE | 2.2.0 | | +| 105 | OSD_VTX_POWER | 2.2.0 | | +| 106 | OSD_ESC_RPM | 2.3.0 | | +| 107 | OSD_ESC_TEMPERATURE | 2.5.0 | | +| 108 | OSD_AZIMUTH | 2.6.0 | | +| 109 | OSD_CRSF_RSSI_DBM | 2.6.0 | | +| 110 | OSD_CRSF_LQ | 2.6.0 | | +| 111 | OSD_CRSF_SNR_DB | 2.6.0 | | +| 112 | OSD_CRSF_TX_POWER | 2.6.0 | | +| 113 | OSD_GVAR_0 | 2.6.0 | | +| 114 | OSD_GVAR_1 | 2.6.0 | | +| 115 | OSD_GVAR_2 | 2.6.0 | | +| 116 | OSD_GVAR_3 | 2.6.0 | | +| 117 | OSD_TPA | 2.6.0 | | +| 118 | OSD_NAV_FW_CONTROL_SMOOTHNESS | 2.6.0 | | +| 119 | OSD_VERSION | 3.0.0 | | +| 120 | OSD_RANGEFINDER | 3.0.0 | | +| 121 | OSD_PLIMIT_REMAINING_BURST_TIME | 3.0.0 | | +| 122 | OSD_PLIMIT_ACTIVE_CURRENT_LIMIT | 3.0.0 | | +| 123 | OSD_PLIMIT_ACTIVE_POWER_LIMIT | 3.0.0 | | +| 124 | OSD_GLIDESLOPE | 3.0.1 | | +| 125 | OSD_GPS_MAX_SPEED | 4.0.0 | | +| 126 | OSD_3D_MAX_SPEED | 4.0.0 | | +| 127 | OSD_AIR_MAX_SPEED | 4.0.0 | | +| 128 | OSD_ACTIVE_PROFILE | 4.0.0 | | +| 129 | OSD_MISSION | 4.0.0 | | +| 130 | OSD_SWITCH_INDICATOR_0 | 5.0.0 | | +| 131 | OSD_SWITCH_INDICATOR_1 | 5.0.0 | | +| 132 | OSD_SWITCH_INDICATOR_2 | 5.0.0 | | +| 133 | OSD_SWITCH_INDICATOR_3 | 5.0.0 | | +| 134 | OSD_TPA_TIME_CONSTANT | 5.0.0 | | +| 135 | OSD_FW_LEVEL_TRIM | 5.0.0 | | +| 136 | OSD_GLIDE_TIME_REMAINING | 6.0.0 | | +| 137 | OSD_GLIDE_RANGE | 6.0.0 | | +| 138 | OSD_CLIMB_EFFICIENCY | 6.0.0 | | +| 139 | OSD_NAV_WP_MULTI_MISSION_INDEX | 6.0.0 | | +| 140 | OSD_GROUND_COURSE | 6.0.0 | | +| 141 | OSD_CROSS_TRACK_ERROR | 6.0.0 | | +| 142 | OSD_PILOT_NAME | 6.0.0 | | +| 143 | OSD_PAN_SERVO_CENTRED | 6.0.0 | | +| 144 | OSD_MULTI_FUNCTION | 7.0.0 | | +| 145 | OSD_ODOMETER | 7.0.0 | For this to work correctly, stats must be enabled (`set stats=ON`). Otherwise, this will show the total flight distance. | +| 146 | OSD_PILOT_LOGO | 7.0.0 | | +| 147 | OSD_BLACKBOX | 7.1.0 | The element will be hidden unless blackbox recording is attempted. | # Pilot Logos @@ -192,3 +193,43 @@ This is an example of the arming screen with the pilot logo enabled. This is usi This is an example of setting the `osd_inav_to_pilot_logo_spacing` to 0. This will allow a larger, single logo. ![Power on screen example with 0 spacing between logos](https://user-images.githubusercontent.com/17590174/271817352-6206402c-9da4-4682-9d83-790cc2396b00.png) + +# Post Flight Statistics +The post flight statistcs are set in the firmware. Statistics are only hidden if the supporting hardware is not present. Due to size contraints. The post flight statistics are spread over 2 pages on analogue systems. + +## Statistics shown +| Statistic | Requirement | Page | | +|-------------------------------|-----------------------|-------|-| +| Flight Time | | 1 | The total time from arm to disarm. | +| Flight Distance | | 1 | | +| Maximum Distance From Home | GPS | 1 | | +| Maximum Speed | GPS | 1 | | +| Average Speed | GPS | 1 | | +| Maximum Altitude | Baro/GPS | 1 | | +| Minimum Average Cell Voltage | | 1 | | +| Minimum Pack Voltage | | 1 | | +| Maximum Current | Current Sensor | 1 | | +| Maximum Power | Current Sensor | 1 | | +| Energy Used (Flight) | Current Sensor | 1 | | +| Energy Used (Battery Total) | Current Sensor | 1 | This data is not reset on arming. | +| Average Efficiency | Current Sensor & GPS | 1 | | +| Minimum RSSI | | 2 | | +| Minimum LQ | CRSF | 2 | | +| Minmum dBm | CRSF | 2 | | +| Minimum Satellites | GPS | 2 | | +| Maximum Satellites | GPS | 2 | | +| Minimum ESC Temperature | ESC Telemetry | 2 | | +| Maximum ESC Temperature | ESC Telemetry | 2 | | +| Maximum G-Force | | 2 | | +| Minimum Z axis G-Force | | 2 | | +| Maximum Z axis G-Force | | 2 | | +| Blackbox file number | Blackbox recording | 2 | | +| Disarm method | | 1 & 2 | | +| Settings save status | | 1 & 2 | Shows a message if the settings are being saved or have been saved on disarm. | + +## Configuration +There are a couple of settings that allow you to adjust parts of the post flights statistics. + +- `osd_stats_page_auto_swap_time` allows you to specify how long each stats page is displayed [seconds]. Reverts to manual control when Roll stick used to change pages. Disabled when set to 0. +- `osd_stats_energy_unit` allows you to choose the unit used for the drawn energy in the OSD stats [MAH/WH] (milliAmpere hour/ Watt hour). Default is MAH. +- `osd_stats_show_metric_efficiency` if you use non-metric units on your OSD. Enabling this option will also show the efficiency in metric. \ No newline at end of file diff --git a/docs/Settings.md b/docs/Settings.md index 308c5fd783b..fcca637268c 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -4822,23 +4822,23 @@ Unit used for the drawn energy in the OSD stats [MAH/WH] (milliAmpere hour/ Watt --- -### osd_stats_min_voltage_unit +### osd_stats_page_auto_swap_time -Display minimum voltage of the `BATTERY` or the average per `CELL` in the OSD stats. +Auto swap display time interval between disarm stats pages (seconds). Reverts to manual control when Roll stick used to change pages. Disabled when set to 0. | Default | Min | Max | | --- | --- | --- | -| BATTERY | | | +| 3 | 0 | 10 | --- -### osd_stats_page_auto_swap_time +### osd_stats_show_metric_efficiency -Auto swap display time interval between disarm stats pages (seconds). Reverts to manual control when Roll stick used to change pages. Disabled when set to 0. +Enabling this option will show metric efficiency statistics on the post flight stats screen. In addition to the efficiency statistics in your chosen units. | Default | Min | Max | | --- | --- | --- | -| 3 | 0 | 10 | +| OFF | OFF | ON | --- diff --git a/src/main/fc/fc_core.c b/src/main/fc/fc_core.c index a61204dee90..493652d5c5f 100644 --- a/src/main/fc/fc_core.c +++ b/src/main/fc/fc_core.c @@ -1021,6 +1021,10 @@ float getFlightTime(void) return US2S(flightTime); } +void resetFlightTime(void) { + flightTime = 0; +} + float getArmTime(void) { return US2S(armTime); diff --git a/src/main/fc/fc_core.h b/src/main/fc/fc_core.h index c66a0050ba2..a9198e8ce45 100644 --- a/src/main/fc/fc_core.h +++ b/src/main/fc/fc_core.h @@ -46,6 +46,7 @@ bool emergencyArmingUpdate(bool armingSwitchIsOn, bool forceArm); bool areSensorsCalibrating(void); float getFlightTime(void); +void resetFlightTime(void); float getArmTime(void); void fcReboot(bool bootLoader); \ No newline at end of file diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index c68c611b052..f94d734d8d3 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -68,9 +68,6 @@ tables: - name: osd_stats_energy_unit values: ["MAH", "WH"] enum: osd_stats_energy_unit_e - - name: osd_stats_min_voltage_unit - values: ["BATTERY", "CELL"] - enum: osd_stats_min_voltage_unit_e - name: osd_video_system values: ["AUTO", "PAL", "NTSC", "HDZERO", "DJIWTF", "AVATAR", "BF43COMPAT", "BFHDCOMPAT"] enum: videoSystem_e @@ -3165,18 +3162,17 @@ groups: field: stats_energy_unit table: osd_stats_energy_unit type: uint8_t - - name: osd_stats_min_voltage_unit - description: "Display minimum voltage of the `BATTERY` or the average per `CELL` in the OSD stats." - default_value: "BATTERY" - field: stats_min_voltage_unit - table: osd_stats_min_voltage_unit - type: uint8_t - name: osd_stats_page_auto_swap_time description: "Auto swap display time interval between disarm stats pages (seconds). Reverts to manual control when Roll stick used to change pages. Disabled when set to 0." default_value: 3 field: stats_page_auto_swap_time min: 0 max: 10 + - name: osd_stats_show_metric_efficiency + description: "Enabling this option will show metric efficiency statistics on the post flight stats screen. In addition to the efficiency statistics in your chosen units." + default_value: OFF + type: bool + field: stats_show_metric_efficiency - name: osd_rssi_alarm description: "Value below which to make the OSD RSSI indicator blink" default_value: 20 diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 5e591509974..90eeafa6450 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -185,6 +185,8 @@ typedef struct statistic_s { uint8_t max_sats; int16_t max_esc_temp; int16_t min_esc_temp; + int32_t flightStartMAh; + int32_t flightStartMWh; } statistic_t; static statistic_t stats; @@ -229,8 +231,6 @@ void osdShowEEPROMSavedNotification(void) { notify_settings_saved = millis() + 5000; } - - bool osdDisplayIsPAL(void) { return displayScreenSize(osdDisplayPort) == VIDEO_BUFFER_CHARS_PAL; @@ -245,7 +245,9 @@ bool osdDisplayIsHD(void) return false; } - +bool osdIsNotMetric(void) { + return !(osdConfig()->units == OSD_UNIT_METRIC || osdConfig()->units == OSD_UNIT_METRIC_MPH); +} /* * Aligns text to the left side. Adds spaces at the end to keep string length unchanged. @@ -3885,8 +3887,8 @@ PG_RESET_TEMPLATE(osdConfig_t, osdConfig, .force_grid = SETTING_OSD_FORCE_GRID_DEFAULT, .stats_energy_unit = SETTING_OSD_STATS_ENERGY_UNIT_DEFAULT, - .stats_min_voltage_unit = SETTING_OSD_STATS_MIN_VOLTAGE_UNIT_DEFAULT, - .stats_page_auto_swap_time = SETTING_OSD_STATS_PAGE_AUTO_SWAP_TIME_DEFAULT + .stats_page_auto_swap_time = SETTING_OSD_STATS_PAGE_AUTO_SWAP_TIME_DEFAULT, + .stats_show_metric_efficiency = SETTING_OSD_STATS_SHOW_METRIC_EFFICIENCY_DEFAULT ); void pgResetFn_osdLayoutsConfig(osdLayoutsConfig_t *osdLayoutsConfig) @@ -4291,6 +4293,8 @@ void osdInit(displayPort_t *osdDisplayPortToUse) static void osdResetStats(void) { + // Reset internal OSD stats + stats.max_distance = 0; stats.max_current = 0; stats.max_power = 0; stats.max_speed = 0; @@ -4303,6 +4307,15 @@ static void osdResetStats(void) stats.max_altitude = 0; stats.min_sats = 255; stats.max_sats = 0; + stats.min_esc_temp = 300; + stats.max_esc_temp = 0; + stats.flightStartMAh = getMAhDrawn(); + stats.flightStartMWh = getMWhDrawn(); + + // Reset external stats + posControl.totalTripDistance = 0.0f; + resetFlightTime(); + resetGForceStats(); } static void osdUpdateStats(void) @@ -4391,6 +4404,7 @@ uint8_t drawStat_FlightTime(uint8_t col, uint8_t row, uint8_t statValX) { uint8_t drawStat_FlightDistance(uint8_t col, uint8_t row, uint8_t statValX) { char buff[12]; + displayWrite(osdDisplayPort, col, row, "FLIGHT DISTANCE"); tfp_sprintf(buff, ": "); osdFormatDistanceStr(buff + 2, getTotalTravelDistance()); @@ -4491,13 +4505,21 @@ uint8_t drawStat_MaximumPower(uint8_t col, uint8_t row, uint8_t statValX) { } uint8_t drawStat_UsedEnergy(uint8_t col, uint8_t row, uint8_t statValX) { - char buff[12]; - displayWrite(osdDisplayPort, col, row, "USED ENERGY"); + char buff[12]; + uint8_t buffOffset = 0; + + if (osdDisplayIsHD()) + displayWrite(osdDisplayPort, col, row, "USED ENERGY FLT/TOT"); + else + displayWrite(osdDisplayPort, col, row, "USED ENERGY F/T"); tfp_sprintf(buff, ": "); if (osdConfig()->stats_energy_unit == OSD_STATS_ENERGY_UNIT_MAH) { - tfp_sprintf(buff + 2, "%d%c", (int)getMAhDrawn(), SYM_MAH); + tfp_sprintf(buff + 2, "%d/%d%c", (int)(getMAhDrawn() - stats.flightStartMAh), (int)getMAhDrawn(), SYM_MAH); } else { - osdFormatCentiNumber(buff + 2, getMWhDrawn() / 10, 0, 2, 0, 3, false); + osdFormatCentiNumber(buff + 2, (getMWhDrawn() - stats.flightStartMWh) / 10, 0, 2, 0, 3, false); + tfp_sprintf(buff, "%s/", buff); + buffOffset = strlen(buff); + osdFormatCentiNumber(buff + buffOffset, getMWhDrawn() / 10, 0, 2, 0, 3, false); tfp_sprintf(buff, "%s%c", buff, SYM_WH); } displayWrite(osdDisplayPort, statValX, row++, buff); @@ -4505,15 +4527,17 @@ uint8_t drawStat_UsedEnergy(uint8_t col, uint8_t row, uint8_t statValX) { return row; } -uint8_t drawStat_AverageEfficiency(uint8_t col, uint8_t row, uint8_t statValX) { +uint8_t drawStat_AverageEfficiency(uint8_t col, uint8_t row, uint8_t statValX, bool forceMetric) { char buff[15]; uint8_t buffOffset = 2; int32_t totalDistance = getTotalTravelDistance(); - bool isDJI = false; bool moreThanAh = false; bool efficiencyValid = totalDistance >= 10000; - displayWrite(osdDisplayPort, col, row, "AVG EFFICIENCY"); + if (osdDisplayIsHD()) + displayWrite(osdDisplayPort, col, row, "AVG EFFICIENCY FLT/TOT"); + else + displayWrite(osdDisplayPort, col, row, "AVG EFFICIENCY F/T"); tfp_sprintf(buff, ": "); uint8_t digits = 3U; // Total number of digits (including decimal point) @@ -4521,83 +4545,99 @@ uint8_t drawStat_AverageEfficiency(uint8_t col, uint8_t row, uint8_t statValX) { if (isBfCompatibleVideoSystem(osdConfig())) { // Add one digit so no switch to scaled decimal occurs above 99 digits = 4U; - isDJI = true; } #endif - switch (osdConfig()->units) { - case OSD_UNIT_UK: - FALLTHROUGH; - case OSD_UNIT_IMPERIAL: - if (osdConfig()->stats_energy_unit == OSD_STATS_ENERGY_UNIT_MAH) { - moreThanAh = osdFormatCentiNumber(buff + buffOffset, (int32_t)(getMAhDrawn() * 10000.0f * METERS_PER_MILE / totalDistance), 1000, 0, 2, digits, false); - if (!moreThanAh) { - tfp_sprintf(buff, "%s%c%c", buff, SYM_MAH_MI_0, SYM_MAH_MI_1); + if (!forceMetric) { + switch (osdConfig()->units) { + case OSD_UNIT_UK: + FALLTHROUGH; + case OSD_UNIT_IMPERIAL: + if (osdConfig()->stats_energy_unit == OSD_STATS_ENERGY_UNIT_MAH) { + if (efficiencyValid) { + moreThanAh = osdFormatCentiNumber(buff + buffOffset, (int32_t)((getMAhDrawn() - stats.flightStartMAh) * 10000.0f * METERS_PER_MILE / totalDistance), 1000, 0, 2, digits, false); + strcat(buff, "/"); + buffOffset = strlen(buff); + moreThanAh = osdFormatCentiNumber(buff + buffOffset, (int32_t)(getMAhDrawn() * 10000.0f * METERS_PER_MILE / totalDistance), 1000, 0, 2, digits, false); + + if (!moreThanAh) { + tfp_sprintf(buff, "%s%c%c", buff, SYM_MAH_MI_0, SYM_MAH_MI_1); + } else { + tfp_sprintf(buff, "%s%c", buff, SYM_AH_MI); + } + } else { + tfp_sprintf(buff + buffOffset, "---/---%c%c", SYM_MAH_MI_0, SYM_MAH_MI_1); + } } else { - tfp_sprintf(buff, "%s%c", buff, SYM_AH_MI); - } - if (!efficiencyValid) { - buff[0+buffOffset] = buff[1+buffOffset] = buff[2+buffOffset] = '-'; - buff[3+buffOffset] = SYM_MAH_MI_0; - buff[4+buffOffset] = SYM_MAH_MI_1; - buff[5+buffOffset] = '\0'; - } - } else { - osdFormatCentiNumber(buff + buffOffset, (int32_t)(getMWhDrawn() * 10.0f * METERS_PER_MILE / totalDistance), 0, 2, 0, digits, false); - tfp_sprintf(buff, "%s%c", buff, SYM_WH_MI); - if (!efficiencyValid) { - buff[0+buffOffset] = buff[1+buffOffset] = buff[2+buffOffset] = '-'; + if (efficiencyValid) { + osdFormatCentiNumber(buff + buffOffset, (int32_t)((getMWhDrawn() - stats.flightStartMWh) * 10.0f * METERS_PER_MILE / totalDistance), 0, 2, 0, digits, false); + strcat(buff, "/"); + buffOffset = strlen(buff); + osdFormatCentiNumber(buff + buffOffset, (int32_t)(getMWhDrawn() * 10.0f * METERS_PER_MILE / totalDistance), 0, 2, 0, digits, false); + } else { + strcat(buff, "---/---"); + } + tfp_sprintf(buff, "%s%c", buff, SYM_WH_MI); } - } - break; - case OSD_UNIT_GA: - if (osdConfig()->stats_energy_unit == OSD_STATS_ENERGY_UNIT_MAH) { - moreThanAh = osdFormatCentiNumber(buff + buffOffset, (int32_t)(getMAhDrawn() * 10000.0f * METERS_PER_NAUTICALMILE / totalDistance), 1000, 0, 2, digits, false); - if (!moreThanAh) { - tfp_sprintf(buff, "%s%c%c", buff, SYM_MAH_NM_0, SYM_MAH_NM_1); + break; + case OSD_UNIT_GA: + if (osdConfig()->stats_energy_unit == OSD_STATS_ENERGY_UNIT_MAH) { + if (efficiencyValid) { + moreThanAh = osdFormatCentiNumber(buff + buffOffset, (int32_t)((getMAhDrawn()-stats.flightStartMAh) * 10000.0f * METERS_PER_NAUTICALMILE / totalDistance), 1000, 0, 2, digits, false); + strcat(buff, "/"); + buffOffset = strlen(buff); + moreThanAh = osdFormatCentiNumber(buff + buffOffset, (int32_t)(getMAhDrawn() * 10000.0f * METERS_PER_NAUTICALMILE / totalDistance), 1000, 0, 2, digits, false); + if (!moreThanAh) { + tfp_sprintf(buff, "%s%c%c", buff, SYM_MAH_NM_0, SYM_MAH_NM_1); + } else { + tfp_sprintf(buff, "%s%c", buff, SYM_AH_NM); + } + } else { + tfp_sprintf(buff + buffOffset, "---/---%c%c", SYM_MAH_NM_0, SYM_MAH_NM_1); + } } else { - tfp_sprintf(buff, "%s%c", buff, SYM_AH_NM); - } - if (!efficiencyValid) { - buff[0+buffOffset] = buff[1+buffOffset] = buff[2+buffOffset] = '-'; - buff[3+buffOffset] = SYM_MAH_NM_0; - buff[4+buffOffset] = SYM_MAH_NM_1; - buff[5+buffOffset] = '\0'; - } - } else { - osdFormatCentiNumber(buff + buffOffset, (int32_t)(getMWhDrawn() * 10.0f * METERS_PER_NAUTICALMILE / totalDistance), 0, 2, 0, digits, false); - tfp_sprintf(buff, "%s%c", buff, SYM_WH_NM); - if (!efficiencyValid) { - buff[0+buffOffset] = buff[1+buffOffset] = buff[2+buffOffset] = '-'; + if (efficiencyValid) { + osdFormatCentiNumber(buff + buffOffset, (int32_t)((getMWhDrawn()-stats.flightStartMWh) * 10.0f * METERS_PER_NAUTICALMILE / totalDistance), 0, 2, 0, digits, false); + strcat(buff, "/"); + buffOffset = strlen(buff); + osdFormatCentiNumber(buff + buffOffset, (int32_t)(getMWhDrawn() * 10.0f * METERS_PER_NAUTICALMILE / totalDistance), 0, 2, 0, digits, false); + } else { + strcat(buff, "---/---"); + } + tfp_sprintf(buff, "%s%c", buff, SYM_WH_NM); } - } - break; - } - - if (!isDJI && osdConfig()->units != OSD_UNIT_METRIC_MPH && osdConfig()->units != OSD_UNIT_METRIC) { - strcat(osdFormatTrimWhiteSpace(buff), "/"); - buffOffset = strlen(buff); + break; + case OSD_UNIT_METRIC_MPH: + case OSD_UNIT_METRIC: + forceMetric = true; + break; + } } - if (!isDJI || osdConfig()->units == OSD_UNIT_METRIC_MPH || osdConfig()->units == OSD_UNIT_METRIC) { + if (forceMetric) { if (osdConfig()->stats_energy_unit == OSD_STATS_ENERGY_UNIT_MAH) { - moreThanAh = osdFormatCentiNumber(buff + buffOffset, (int32_t)(getMAhDrawn() * 10000000.0f / totalDistance), 1000, 0, 2, digits, false); - if (!moreThanAh) { - tfp_sprintf(buff, "%s%c%c", buff, SYM_MAH_KM_0, SYM_MAH_KM_1); + if (efficiencyValid) { + moreThanAh = osdFormatCentiNumber(buff + buffOffset, (int32_t)((getMAhDrawn() - stats.flightStartMAh) * 10000000.0f / totalDistance), 1000, 0, 2, digits, false); + strcat(buff, "/"); + buffOffset = strlen(buff); + moreThanAh = osdFormatCentiNumber(buff + buffOffset, (int32_t)(getMAhDrawn() * 10000000.0f / totalDistance), 1000, 0, 2, digits, false); + if (!moreThanAh) { + tfp_sprintf(buff, "%s%c%c", buff, SYM_MAH_KM_0, SYM_MAH_KM_1); + } else { + tfp_sprintf(buff, "%s%c", buff, SYM_AH_KM); + } } else { - tfp_sprintf(buff, "%s%c", buff, SYM_AH_KM); - } - if (!efficiencyValid) { - buff[0+buffOffset] = buff[1+buffOffset] = buff[2+buffOffset] = '-'; - buff[3+buffOffset] = SYM_MAH_KM_0; - buff[4+buffOffset] = SYM_MAH_KM_1; - buff[5+buffOffset] = '\0'; + tfp_sprintf(buff + buffOffset, "---/---%c%c", SYM_MAH_KM_0, SYM_MAH_KM_1); } } else { - osdFormatCentiNumber(buff + buffOffset, (int32_t)(getMWhDrawn() * 10000.0f / totalDistance), 0, 2, 0, digits, false); - tfp_sprintf(buff, "%s%c", buff, SYM_WH_KM); - if (!efficiencyValid) { - buff[0+buffOffset] = buff[1+buffOffset] = buff[2+buffOffset] = '-'; + if (efficiencyValid) { + osdFormatCentiNumber(buff + buffOffset, (int32_t)((getMWhDrawn() - stats.flightStartMWh) * 10000.0f / totalDistance), 0, 2, 0, digits, false); + strcat(buff, "/"); + buffOffset = strlen(buff); + osdFormatCentiNumber(buff + buffOffset, (int32_t)(getMWhDrawn() * 10000.0f / totalDistance), 0, 2, 0, digits, false); + } else { + strcat(buff, "---/---"); } + tfp_sprintf(buff, "%s%c", buff, SYM_WH_KM); } } @@ -4758,42 +4798,46 @@ static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page) displayWrite(osdDisplayPort, (osdDisplayPort->cols - strlen(statsHeader[page + 1])) / 2, row++, statsHeader[page]); if (isSinglePageStatsCompatible) { + // Top 15 rows for most important stats. Max 19 rows row = drawStat_FlightTime(statNameX, row, statValuesX); row = drawStat_FlightDistance(statNameX, row, statValuesX); - row = drawStat_MaxDistanceFromHome(statNameX, row, statValuesX); + if (feature(FEATURE_GPS)) row = drawStat_MaxDistanceFromHome(statNameX, row, statValuesX); if (feature(FEATURE_GPS)) row = drawStat_Speed(statNameX, row, statValuesX); row = drawStat_MaximumAltitude(statNameX, row, statValuesX); row = drawStat_BatteryVoltage(statNameX, row, statValuesX); if (feature(FEATURE_CURRENT_METER)) row = drawStat_MaximumCurrent(statNameX, row, statValuesX); - if (feature(FEATURE_CURRENT_METER))row = drawStat_MaximumPower(statNameX, row, statValuesX); - if (feature(FEATURE_CURRENT_METER))row = drawStat_UsedEnergy(statNameX, row, statValuesX); - if (feature(FEATURE_CURRENT_METER) && feature(FEATURE_GPS)) row = drawStat_AverageEfficiency(statNameX, row, statValuesX); + if (feature(FEATURE_CURRENT_METER)) row = drawStat_MaximumPower(statNameX, row, statValuesX); + if (feature(FEATURE_CURRENT_METER)) row = drawStat_UsedEnergy(statNameX, row, statValuesX); + if (feature(FEATURE_CURRENT_METER) && feature(FEATURE_GPS)) row = drawStat_AverageEfficiency(statNameX, row, statValuesX, false); + if (osdConfig()->stats_show_metric_efficiency && osdIsNotMetric() && feature(FEATURE_CURRENT_METER) && feature(FEATURE_GPS)) row = drawStat_AverageEfficiency(statNameX, row, statValuesX, true); row = drawStat_RXStats(statNameX, row, statValuesX); if (feature(FEATURE_GPS)) row = drawStat_GPS(statNameX, row, statValuesX); if (STATE(ESC_SENSOR_ENABLED)) row = drawStat_ESCTemperature(statNameX, row, statValuesX); + // Draw these if there is space space if (row < (osdDisplayPort->cols-3)) row = drawStat_GForce(statNameX, row, statValuesX); - // if (row < (osdDisplayPort->cols-2)) row = drawStat_FlightTime(statNameX, row, statValuesX); } else { switch (page) { case 0: + // Max 10 rows row = drawStat_FlightTime(statNameX, row, statValuesX); row = drawStat_FlightDistance(statNameX, row, statValuesX); - row = drawStat_Speed(statNameX, row, statValuesX); + if (feature(FEATURE_GPS)) row = drawStat_MaxDistanceFromHome(statNameX, row, statValuesX); + if (feature(FEATURE_GPS)) row = drawStat_Speed(statNameX, row, statValuesX); row = drawStat_MaximumAltitude(statNameX, row, statValuesX); row = drawStat_BatteryVoltage(statNameX, row, statValuesX); if (feature(FEATURE_CURRENT_METER)) row = drawStat_MaximumCurrent(statNameX, row, statValuesX); if (feature(FEATURE_CURRENT_METER))row = drawStat_MaximumPower(statNameX, row, statValuesX); if (feature(FEATURE_CURRENT_METER))row = drawStat_UsedEnergy(statNameX, row, statValuesX); - if (feature(FEATURE_CURRENT_METER) && feature(FEATURE_GPS)) row = drawStat_AverageEfficiency(statNameX, row, statValuesX); + if (feature(FEATURE_CURRENT_METER) && feature(FEATURE_GPS)) row = drawStat_AverageEfficiency(statNameX, row, statValuesX, false); break; case 1: - row = drawStat_MaxDistanceFromHome(statNameX, row, statValuesX); - row = drawStat_RXStats(statNameX, row, statValuesX); + // Max 10 rows + row = drawStat_RXStats(statNameX, row, statValuesX); // 2 rows if (feature(FEATURE_GPS))row = drawStat_GPS(statNameX, row, statValuesX); if (STATE(ESC_SENSOR_ENABLED)) row = drawStat_ESCTemperature(statNameX, row, statValuesX); - row = drawStat_GForce(statNameX, row, statValuesX); - //row = drawStat_FlightTime(statNameX, row, statValuesX); + row = drawStat_GForce(statNameX, row, statValuesX); // 2 rows + if (osdConfig()->stats_show_metric_efficiency && osdIsNotMetric() && feature(FEATURE_CURRENT_METER) && feature(FEATURE_GPS)) row = drawStat_AverageEfficiency(statNameX, row, statValuesX, true); //row = drawStat_FlightTime(statNameX, row, statValuesX); //row = drawStat_FlightTime(statNameX, row, statValuesX); #ifdef USE_BLACKBOX @@ -5131,16 +5175,16 @@ static void osdRefresh(timeUs_t currentTimeUs) if (ARMING_FLAG(ARMED)) { // Display the "Arming" screen statsDisplayed = false; - osdResetStats(); + if (!STATE(IN_FLIGHT_EMERG_REARM)) + osdResetStats(); + osdShowArmed(); uint16_t delay = osdConfig()->arm_screen_display_time; - if (STATE(IN_FLIGHT_EMERG_REARM)) { + if (STATE(IN_FLIGHT_EMERG_REARM)) delay = 500; - } #if defined(USE_SAFE_HOME) - else if (posControl.safehomeState.distance) { + else if (posControl.safehomeState.distance) delay += 3000; - } #endif osdSetNextRefreshIn(delay); } else { @@ -5309,7 +5353,7 @@ void osdUpdate(timeUs_t currentTimeUs) #define STATS_FREQ_DENOM 50 counter++; - if ((counter % STATS_FREQ_DENOM) == 0) { + if ((counter % STATS_FREQ_DENOM) == 0 && ARMING_FLAG(ARMED)) { osdUpdateStats(); } diff --git a/src/main/io/osd.h b/src/main/io/osd.h index 0c4050066a4..6fd85f94f0a 100644 --- a/src/main/io/osd.h +++ b/src/main/io/osd.h @@ -299,11 +299,6 @@ typedef enum { OSD_STATS_ENERGY_UNIT_WH, } osd_stats_energy_unit_e; -typedef enum { - OSD_STATS_MIN_VOLTAGE_UNIT_BATTERY, - OSD_STATS_MIN_VOLTAGE_UNIT_CELL, -} osd_stats_min_voltage_unit_e; - typedef enum { OSD_CROSSHAIRS_STYLE_DEFAULT, OSD_CROSSHAIRS_STYLE_AIRCRAFT, @@ -413,8 +408,8 @@ typedef struct osdConfig_s { uint8_t units; // from osd_unit_e uint8_t stats_energy_unit; // from osd_stats_energy_unit_e - uint8_t stats_min_voltage_unit; // from osd_stats_min_voltage_unit_e uint8_t stats_page_auto_swap_time; // stats page auto swap interval time (seconds) + bool stats_show_metric_efficiency; // If true, show metric efficiency as well as for the selected units #ifdef USE_WIND_ESTIMATOR bool estimations_wind_compensation; // use wind compensation for estimated remaining flight/distance diff --git a/src/main/sensors/acceleration.c b/src/main/sensors/acceleration.c index 695f49b00b2..4e46f178843 100644 --- a/src/main/sensors/acceleration.c +++ b/src/main/sensors/acceleration.c @@ -529,6 +529,15 @@ float accGetMeasuredMaxG(void) return acc.maxG; } +void resetGForceStats(void) { + acc.maxG = 0.0f; + + for (int axis = 0; axis < XYZ_AXIS_COUNT; axis++) { + acc.extremes[axis].min = 100; + acc.extremes[axis].max = -100; + } +} + void accUpdate(void) { #ifdef USE_SIMULATOR diff --git a/src/main/sensors/acceleration.h b/src/main/sensors/acceleration.h index f3385edc6d5..a25063ec4fd 100644 --- a/src/main/sensors/acceleration.h +++ b/src/main/sensors/acceleration.h @@ -86,6 +86,7 @@ void accGetMeasuredAcceleration(fpVector3_t *measuredAcc); const acc_extremes_t* accGetMeasuredExtremes(void); float accGetMeasuredMaxG(void); void updateAccExtremes(void); +void resetGForceStats(void); void accGetVibrationLevels(fpVector3_t *accVibeLevels); float accGetVibrationLevel(void); uint32_t accGetClipCount(void); From ed26058c2cfef24475bb1ff74000176de0bbb0b8 Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Thu, 4 Jan 2024 21:10:39 +0000 Subject: [PATCH 037/241] Fix issues on GitHib compilers --- src/main/io/osd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 90eeafa6450..027b359f013 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -1988,7 +1988,7 @@ static bool osdDrawSingleElement(uint8_t item) } else { int32_t logNumber = blackboxGetLogNumber(); if (logNumber >= 0) { - tfp_sprintf(buff, "%c%05ld", SYM_BLACKBOX, logNumber); + tfp_sprintf(buff, "%c%05d", SYM_BLACKBOX, logNumber); } else { tfp_sprintf(buff, "%c", SYM_BLACKBOX); } @@ -4498,7 +4498,7 @@ uint8_t drawStat_MaximumPower(uint8_t col, uint8_t row, uint8_t statValX) { displayWrite(osdDisplayPort, col, row, "MAX POWER"); tfp_sprintf(buff, ": "); bool kiloWatt = osdFormatCentiNumber(buff + 2, stats.max_power, 1000, 2, 2, 3, false); - strcat(osdFormatTrimWhiteSpace(buff), (char*)(kiloWatt ? SYM_KILOWATT : SYM_WATT)); + tfp_sprintf(buff, "%s%c", osdFormatTrimWhiteSpace(buff), (char)(kiloWatt ? SYM_KILOWATT : SYM_WATT)); displayWrite(osdDisplayPort, statValX, row++, buff); return row; From ea17875244a8d1d2f9efdb8568af0d9549a77f85 Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Thu, 4 Jan 2024 21:18:16 +0000 Subject: [PATCH 038/241] Set back to ld. Builds without issues on my system --- src/main/io/osd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 027b359f013..901be66af7c 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -1988,7 +1988,7 @@ static bool osdDrawSingleElement(uint8_t item) } else { int32_t logNumber = blackboxGetLogNumber(); if (logNumber >= 0) { - tfp_sprintf(buff, "%c%05d", SYM_BLACKBOX, logNumber); + tfp_sprintf(buff, "%c%05ld", SYM_BLACKBOX, logNumber); } else { tfp_sprintf(buff, "%c", SYM_BLACKBOX); } From b35cb0eefbe23db07075ca53c8dfa79d446bc92c Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Thu, 4 Jan 2024 21:23:15 +0000 Subject: [PATCH 039/241] Missed #if defined(USE_ESC_SENSOR) --- src/main/io/osd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 901be66af7c..874d9129d0b 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -4344,7 +4344,7 @@ static void osdUpdateStats(void) if (stats.max_sats < gpsSol.numSat) stats.max_sats = gpsSol.numSat; } - +#if defined(USE_ESC_SENSOR) if (STATE(ESC_SENSOR_ENABLED)) { escSensorData_t * escSensor = escSensorGetData(); bool escTemperatureValid = escSensor && escSensor->dataAge <= ESC_DATA_MAX_AGE; @@ -4357,6 +4357,7 @@ static void osdUpdateStats(void) stats.max_esc_temp = escSensor->temperature; } } +#endif value = getBatteryVoltage(); if (stats.min_voltage > value) From 31cbfde18013ba7e629b59c14715d7e225ad14aa Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Fri, 5 Jan 2024 21:54:57 +0000 Subject: [PATCH 040/241] Fix Mac SITL test --- src/main/io/osd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 874d9129d0b..d230ae1e0eb 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "platform.h" @@ -1988,7 +1989,7 @@ static bool osdDrawSingleElement(uint8_t item) } else { int32_t logNumber = blackboxGetLogNumber(); if (logNumber >= 0) { - tfp_sprintf(buff, "%c%05ld", SYM_BLACKBOX, logNumber); + tfp_sprintf(buff, "%c%05" PRId32, SYM_BLACKBOX, logNumber); } else { tfp_sprintf(buff, "%c", SYM_BLACKBOX); } @@ -4786,7 +4787,7 @@ static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page) if (feature(FEATURE_BLACKBOX)) { int32_t logNumber = blackboxGetLogNumber(); if (logNumber >= 0) - tfp_sprintf(buff, "%s %c%05ld ", buff, SYM_BLACKBOX, logNumber); + tfp_sprintf(buff, "%s %c%05 " PRId32, buff, SYM_BLACKBOX, logNumber); else tfp_sprintf(buff, "%s %c ", buff, SYM_BLACKBOX); } From 1419e9aedd7716ee666a89968ec7f27e87e65d71 Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Fri, 5 Jan 2024 22:05:08 +0000 Subject: [PATCH 041/241] Another one! Bloody Macs!! --- src/main/io/osd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index d230ae1e0eb..e9fb04596df 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -4787,7 +4787,7 @@ static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page) if (feature(FEATURE_BLACKBOX)) { int32_t logNumber = blackboxGetLogNumber(); if (logNumber >= 0) - tfp_sprintf(buff, "%s %c%05 " PRId32, buff, SYM_BLACKBOX, logNumber); + tfp_sprintf(buff, "%s %c%05" PRId32 " ", buff, SYM_BLACKBOX, logNumber); else tfp_sprintf(buff, "%s %c ", buff, SYM_BLACKBOX); } From be9da9ac7d48bcf7103a86a709ffa71fda55b700 Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Sun, 7 Jan 2024 21:04:00 +0000 Subject: [PATCH 042/241] Updates - Small update for analogue - Removed all instances of tfp_sprintf overwriting the buffer with itself. --- src/main/io/osd.c | 56 +++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index e9fb04596df..335d5fd9600 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -2665,7 +2665,7 @@ static bool osdDrawSingleElement(uint8_t item) // mAh/foot if (efficiencyValid) { osdFormatCentiNumber(buff, (value * METERS_PER_FOOT), 1, 2, 2, 3, false); - tfp_sprintf(buff, "%s%c%c", buff, SYM_AH_V_FT_0, SYM_AH_V_FT_1); + tfp_sprintf(buff + strlen(buff), "%c%c", SYM_AH_V_FT_0, SYM_AH_V_FT_1); } else { buff[0] = buff[1] = buff[2] = '-'; buff[3] = SYM_AH_V_FT_0; @@ -2679,7 +2679,7 @@ static bool osdDrawSingleElement(uint8_t item) // mAh/metre if (efficiencyValid) { osdFormatCentiNumber(buff, value, 1, 2, 2, 3, false); - tfp_sprintf(buff, "%s%c%c", buff, SYM_AH_V_M_0, SYM_AH_V_M_1); + tfp_sprintf(buff + strlen(buff), "%c%c", SYM_AH_V_M_0, SYM_AH_V_M_1); } else { buff[0] = buff[1] = buff[2] = '-'; buff[3] = SYM_AH_V_M_0; @@ -3142,9 +3142,9 @@ static bool osdDrawSingleElement(uint8_t item) case OSD_UNIT_IMPERIAL: moreThanAh = osdFormatCentiNumber(buff, value * METERS_PER_MILE / 10, 1000, 0, 2, digits, false); if (!moreThanAh) { - tfp_sprintf(buff, "%s%c%c", buff, SYM_MAH_MI_0, SYM_MAH_MI_1); + tfp_sprintf(buff + strlen(buff), "%c%c", SYM_MAH_MI_0, SYM_MAH_MI_1); } else { - tfp_sprintf(buff, "%s%c", buff, SYM_AH_MI); + tfp_sprintf(buff + strlen(buff), "%c", SYM_AH_MI); } if (!efficiencyValid) { buff[0] = buff[1] = buff[2] = buff[3] = '-'; @@ -3156,9 +3156,9 @@ static bool osdDrawSingleElement(uint8_t item) case OSD_UNIT_GA: moreThanAh = osdFormatCentiNumber(buff, value * METERS_PER_NAUTICALMILE / 10, 1000, 0, 2, digits, false); if (!moreThanAh) { - tfp_sprintf(buff, "%s%c%c", buff, SYM_MAH_NM_0, SYM_MAH_NM_1); + tfp_sprintf(buff + strlen(buff), "%c%c", SYM_MAH_NM_0, SYM_MAH_NM_1); } else { - tfp_sprintf(buff, "%s%c", buff, SYM_AH_NM); + tfp_sprintf(buff + strlen(buff), "%c", SYM_AH_NM); } if (!efficiencyValid) { buff[0] = buff[1] = buff[2] = buff[3] = '-'; @@ -3172,9 +3172,9 @@ static bool osdDrawSingleElement(uint8_t item) case OSD_UNIT_METRIC: moreThanAh = osdFormatCentiNumber(buff, value * 100, 1000, 0, 2, digits, false); if (!moreThanAh) { - tfp_sprintf(buff, "%s%c%c", buff, SYM_MAH_KM_0, SYM_MAH_KM_1); + tfp_sprintf(buff + strlen(buff), "%c%c", SYM_MAH_KM_0, SYM_MAH_KM_1); } else { - tfp_sprintf(buff, "%s%c", buff, SYM_AH_KM); + tfp_sprintf(buff + strlen(buff), "%c", SYM_AH_KM); } if (!efficiencyValid) { buff[0] = buff[1] = buff[2] = buff[3] = '-'; @@ -4477,7 +4477,7 @@ uint8_t drawStat_BatteryVoltage(uint8_t col, uint8_t row, uint8_t statValX) { multiValueXOffset = strlen(buff); // AverageCell osdFormatCentiNumber(buff + multiValueXOffset, stats.min_voltage / getBatteryCellCount(), 0, 2, 0, 3, false); - tfp_sprintf(buff, "%s%c", buff, SYM_VOLT); + tfp_sprintf(buff + strlen(buff), "%c", SYM_VOLT); displayWrite(osdDisplayPort, statValX, row++, buff); @@ -4489,7 +4489,7 @@ uint8_t drawStat_MaximumCurrent(uint8_t col, uint8_t row, uint8_t statValX) { displayWrite(osdDisplayPort, col, row, "MAX CURRENT"); tfp_sprintf(buff, ": "); osdFormatCentiNumber(buff + 2, stats.max_current, 0, 2, 0, 3, false); - tfp_sprintf(buff, "%s%c", buff, SYM_AMP); + tfp_sprintf(buff + strlen(buff), "%c", SYM_AMP); displayWrite(osdDisplayPort, statValX, row++, buff); return row; @@ -4500,7 +4500,7 @@ uint8_t drawStat_MaximumPower(uint8_t col, uint8_t row, uint8_t statValX) { displayWrite(osdDisplayPort, col, row, "MAX POWER"); tfp_sprintf(buff, ": "); bool kiloWatt = osdFormatCentiNumber(buff + 2, stats.max_power, 1000, 2, 2, 3, false); - tfp_sprintf(buff, "%s%c", osdFormatTrimWhiteSpace(buff), (char)(kiloWatt ? SYM_KILOWATT : SYM_WATT)); + tfp_sprintf(buff + strlen(osdFormatTrimWhiteSpace(buff)), "%c", (char)(kiloWatt ? SYM_KILOWATT : SYM_WATT)); displayWrite(osdDisplayPort, statValX, row++, buff); return row; @@ -4539,7 +4539,7 @@ uint8_t drawStat_AverageEfficiency(uint8_t col, uint8_t row, uint8_t statValX, b if (osdDisplayIsHD()) displayWrite(osdDisplayPort, col, row, "AVG EFFICIENCY FLT/TOT"); else - displayWrite(osdDisplayPort, col, row, "AVG EFFICIENCY F/T"); + displayWrite(osdDisplayPort, col, row, "AV EFFICIENCY F/T"); tfp_sprintf(buff, ": "); uint8_t digits = 3U; // Total number of digits (including decimal point) @@ -4562,9 +4562,9 @@ uint8_t drawStat_AverageEfficiency(uint8_t col, uint8_t row, uint8_t statValX, b moreThanAh = osdFormatCentiNumber(buff + buffOffset, (int32_t)(getMAhDrawn() * 10000.0f * METERS_PER_MILE / totalDistance), 1000, 0, 2, digits, false); if (!moreThanAh) { - tfp_sprintf(buff, "%s%c%c", buff, SYM_MAH_MI_0, SYM_MAH_MI_1); + tfp_sprintf(buff + strlen(buff), "%c%c", SYM_MAH_MI_0, SYM_MAH_MI_1); } else { - tfp_sprintf(buff, "%s%c", buff, SYM_AH_MI); + tfp_sprintf(buff + strlen(buff), "%c", SYM_AH_MI); } } else { tfp_sprintf(buff + buffOffset, "---/---%c%c", SYM_MAH_MI_0, SYM_MAH_MI_1); @@ -4578,7 +4578,7 @@ uint8_t drawStat_AverageEfficiency(uint8_t col, uint8_t row, uint8_t statValX, b } else { strcat(buff, "---/---"); } - tfp_sprintf(buff, "%s%c", buff, SYM_WH_MI); + tfp_sprintf(buff + strlen(buff), "%c", SYM_WH_MI); } break; case OSD_UNIT_GA: @@ -4589,9 +4589,9 @@ uint8_t drawStat_AverageEfficiency(uint8_t col, uint8_t row, uint8_t statValX, b buffOffset = strlen(buff); moreThanAh = osdFormatCentiNumber(buff + buffOffset, (int32_t)(getMAhDrawn() * 10000.0f * METERS_PER_NAUTICALMILE / totalDistance), 1000, 0, 2, digits, false); if (!moreThanAh) { - tfp_sprintf(buff, "%s%c%c", buff, SYM_MAH_NM_0, SYM_MAH_NM_1); + tfp_sprintf(buff + strlen(buff), "%c%c", SYM_MAH_NM_0, SYM_MAH_NM_1); } else { - tfp_sprintf(buff, "%s%c", buff, SYM_AH_NM); + tfp_sprintf(buff + strlen(buff), "%c", SYM_AH_NM); } } else { tfp_sprintf(buff + buffOffset, "---/---%c%c", SYM_MAH_NM_0, SYM_MAH_NM_1); @@ -4605,7 +4605,7 @@ uint8_t drawStat_AverageEfficiency(uint8_t col, uint8_t row, uint8_t statValX, b } else { strcat(buff, "---/---"); } - tfp_sprintf(buff, "%s%c", buff, SYM_WH_NM); + tfp_sprintf(buff + strlen(buff), "%c", SYM_WH_NM); } break; case OSD_UNIT_METRIC_MPH: @@ -4623,9 +4623,9 @@ uint8_t drawStat_AverageEfficiency(uint8_t col, uint8_t row, uint8_t statValX, b buffOffset = strlen(buff); moreThanAh = osdFormatCentiNumber(buff + buffOffset, (int32_t)(getMAhDrawn() * 10000000.0f / totalDistance), 1000, 0, 2, digits, false); if (!moreThanAh) { - tfp_sprintf(buff, "%s%c%c", buff, SYM_MAH_KM_0, SYM_MAH_KM_1); + tfp_sprintf(buff + strlen(buff), "%c%c", SYM_MAH_KM_0, SYM_MAH_KM_1); } else { - tfp_sprintf(buff, "%s%c", buff, SYM_AH_KM); + tfp_sprintf(buff + strlen(buff), "%c", SYM_AH_KM); } } else { tfp_sprintf(buff + buffOffset, "---/---%c%c", SYM_MAH_KM_0, SYM_MAH_KM_1); @@ -4639,7 +4639,7 @@ uint8_t drawStat_AverageEfficiency(uint8_t col, uint8_t row, uint8_t statValX, b } else { strcat(buff, "---/---"); } - tfp_sprintf(buff, "%s%c", buff, SYM_WH_KM); + tfp_sprintf(buff + strlen(buff), "%c", SYM_WH_KM); } } @@ -4676,7 +4676,7 @@ uint8_t drawStat_RXStats(uint8_t col, uint8_t row, uint8_t statValX) { if (osdDisplayIsHD()) { strcat(osdFormatTrimWhiteSpace(buff), "/"); itoa(stats.min_rssi_dbm, buff + 2, 10); - tfp_sprintf(buff, "%s%c", buff, SYM_DBM); + tfp_sprintf(buff + strlen(buff), "%c", SYM_DBM); displayWrite(osdDisplayPort, statValX, row++, buff); } } @@ -4688,7 +4688,7 @@ uint8_t drawStat_RXStats(uint8_t col, uint8_t row, uint8_t statValX) { memset(buff, '\0', strlen(buff)); tfp_sprintf(buff, ": "); itoa(stats.min_rssi_dbm, buff + 2, 10); - tfp_sprintf(buff, "%s%c", buff, SYM_DBM); + tfp_sprintf(buff + strlen(buff), "%c", SYM_DBM); displayWrite(osdDisplayPort, statValX, row++, buff); } @@ -4740,12 +4740,12 @@ uint8_t drawStat_GForce(uint8_t col, uint8_t row, uint8_t statValX) { memset(buff, '\0', strlen(buff)); tfp_sprintf(buff, ": "); } else { - strcat(osdFormatTrimWhiteSpace(buff),"/"); + strcat(osdFormatTrimWhiteSpace(buff), "/"); } multiValueXOffset = strlen(buff); osdFormatCentiNumber(buff + multiValueXOffset, acc_extremes_min * 100, 0, 2, 0, 4, false); osdLeftAlignString(buff); - strcat(osdFormatTrimWhiteSpace(buff),"/"); + strcat(osdFormatTrimWhiteSpace(buff), "/"); multiValueXOffset = strlen(buff); osdFormatCentiNumber(buff + multiValueXOffset, acc_extremes_max * 100, 0, 2, 0, 3, false); @@ -4787,13 +4787,13 @@ static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page) if (feature(FEATURE_BLACKBOX)) { int32_t logNumber = blackboxGetLogNumber(); if (logNumber >= 0) - tfp_sprintf(buff, "%s %c%05" PRId32 " ", buff, SYM_BLACKBOX, logNumber); + tfp_sprintf(buff + strlen(buff), " %c%05" PRId32 " ", SYM_BLACKBOX, logNumber); else - tfp_sprintf(buff, "%s %c ", buff, SYM_BLACKBOX); + tfp_sprintf(buff + strlen(buff), " %c ", SYM_BLACKBOX); } #endif #endif - tfp_sprintf(buff, "%s***", buff); + strcat(buff, "***"); displayWrite(osdDisplayPort, (osdDisplayPort->cols - strlen(buff)) / 2, row++, buff); } else From c48f51445b2e7f61133e62cc26ad2e8eacdfcc3e Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Sun, 7 Jan 2024 21:39:52 +0000 Subject: [PATCH 043/241] Removed round brackets from analogue stats headers --- src/main/io/osd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 335d5fd9600..2fac67a6919 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -4767,7 +4767,7 @@ uint8_t drawStat_DisarmMethod(uint8_t col, uint8_t row, uint8_t statValX) { static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page) { - const char * statsHeader[2] = {"*** STATS (1/2 ->) ***", "*** STATS (<- 2/2) ***"}; + const char * statsHeader[2] = {"*** STATS 1/2 -> ***", "*** STATS <- 2/2 ***"}; uint8_t row = 1; // Start one line down leaving space at the top of the screen. const uint8_t statNameX = (osdDisplayPort->cols - (osdDisplayIsHD() ? 41 : 28)) / 2; From ac748788e633fcccf047d63acff2f3058e6f3215 Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Mon, 8 Jan 2024 20:13:57 +0000 Subject: [PATCH 044/241] Update osd.c - fixed buffer issue - agreed to pedantry ;) --- src/main/io/osd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 2fac67a6919..13c50af160b 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -4780,7 +4780,7 @@ static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page) displayClearScreen(osdDisplayPort); if (isSinglePageStatsCompatible) { - char buff[20]; + char buff[25]; tfp_sprintf(buff, "*** STATS "); #ifdef USE_BLACKBOX #ifdef USE_SDCARD @@ -4854,7 +4854,7 @@ static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page) if (logNumber >= 0) tfp_sprintf(buff, ": %05ld ", logNumber); else - tfp_sprintf(buff, ": %s", "INVALID"); + strcat(buff, ": INVALID"); displayWrite(osdDisplayPort, statValuesX, row++, buff); } From 1e6a20f5924279197f1b923aad0a095cdc7a8d6c Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Sat, 13 Jan 2024 09:50:17 +0000 Subject: [PATCH 045/241] Unfuck rebase --- docs/MixerProfile.md | 3 -- docs/Settings.md | 10 ----- .../Class/MSC/Src/usbd_msc_scsi.c | 10 ----- .../Class/MSC/Src/usbd_msc_scsi.c | 10 ----- .../Class/MSC/Src/usbd_msc_scsi.c | 10 ----- src/main/fc/settings.yaml | 8 ---- src/main/flight/imu.c | 28 ------------- src/main/flight/mixer.c | 7 ---- src/main/flight/mixer_profile.c | 1 - src/main/flight/mixer_profile.h | 1 - src/main/flight/pid.c | 10 +---- src/main/io/displayport_msp_bf_compat.c | 42 ------------------- src/main/sensors/boardalignment.c | 40 +++++++----------- src/main/sensors/boardalignment.h | 4 +- src/main/sensors/compass.c | 1 - 15 files changed, 17 insertions(+), 168 deletions(-) diff --git a/docs/MixerProfile.md b/docs/MixerProfile.md index 55aedd3a30b..ec8685d0d4e 100644 --- a/docs/MixerProfile.md +++ b/docs/MixerProfile.md @@ -104,9 +104,6 @@ TailSitter is supported by add a 90deg offset to the board alignment. Set the bo - Rate Settings - ······· -### TailSitter support -TailSitter is supported by add a 90deg offset to the board alignment. Set the board aliment normally in the mixer_profile for FW mode(`set platform_type = AIRPLANE`), The motor trust axis should be same direction as the airplane nose. Then, in the mixer_profile for takeoff and landing `set platform_type = TAILSITTER`. The `TAILSITTER` platform type is same as `MULTIROTOR` platform type, expect for a 90 deg board alignment offset. In `TAILSITTER` mixer_profile, when motor trust/airplane nose is pointing to the sky, 'airplane bottom'/'multi rotor front' should facing forward in model preview. Set the motor/servo mixer according to multirotor orientation, Model should roll around geography's longitudinal axis, the roll axis of `TAILSITTER` will be yaw axis of `AIRPLANE`. In addition, When `MIXER TRANSITION` input is activated, a 45deg offset will be add to the target angle for angle mode. - ## Happy flying Remember that this is currently an emerging capability: diff --git a/docs/Settings.md b/docs/Settings.md index fcca637268c..1216aaba5f6 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -5812,16 +5812,6 @@ Delay before disarming when requested by switch (ms) [0-1000] --- -### tailsitter_orientation_offset - -Apply a 90 deg pitch offset in sensor aliment for tailsitter flying mode - -| Default | Min | Max | -| --- | --- | --- | -| OFF | OFF | ON | - ---- - ### telemetry_halfduplex S.Port telemetry only: Turn UART into UNIDIR for usage on F1 and F4 target. See Telemetry.md for details diff --git a/lib/main/STM32F4/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c b/lib/main/STM32F4/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c index 3c63a978f2c..2b84130c11b 100644 --- a/lib/main/STM32F4/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c +++ b/lib/main/STM32F4/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c @@ -344,11 +344,6 @@ static int8_t SCSI_ModeSense6 (USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t * hmsc->bot_data[len] = MSC_Mode_Sense6_data[len]; } - // set bit 7 of the device configuration byte to indicate write protection - if (((USBD_StorageTypeDef *)pdev->pMSC_UserData)->IsWriteProtected(lun) != 0) { - hmsc->bot_data[2] = hmsc->bot_data[2] | (1 << 7); - } - return 0; } @@ -372,11 +367,6 @@ static int8_t SCSI_ModeSense10 (USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t hmsc->bot_data[len] = MSC_Mode_Sense10_data[len]; } - // set bit 7 of the device configuration byte to indicate write protection - if (((USBD_StorageTypeDef *)pdev->pMSC_UserData)->IsWriteProtected(lun) != 0) { - hmsc->bot_data[3] = hmsc->bot_data[3] | (1 << 7); - } - return 0; } diff --git a/lib/main/STM32F7/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c b/lib/main/STM32F7/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c index b1d76cc25da..9e0334995d6 100644 --- a/lib/main/STM32F7/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c +++ b/lib/main/STM32F7/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c @@ -348,11 +348,6 @@ static int8_t SCSI_ModeSense6 (USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t * hmsc->bot_data[len] = MSC_Mode_Sense6_data[len]; } - // set bit 7 of the device configuration byte to indicate write protection - if (((USBD_StorageTypeDef *)pdev->pMSC_UserData)->IsWriteProtected(lun) != 0) { - hmsc->bot_data[2] = hmsc->bot_data[2] | (1 << 7); - } - return 0; } @@ -377,11 +372,6 @@ static int8_t SCSI_ModeSense10 (USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t hmsc->bot_data[len] = MSC_Mode_Sense10_data[len]; } - // set bit 7 of the device configuration byte to indicate write protection - if (((USBD_StorageTypeDef *)pdev->pMSC_UserData)->IsWriteProtected(lun) != 0) { - hmsc->bot_data[3] = hmsc->bot_data[3] | (1 << 7); - } - return 0; } diff --git a/lib/main/STM32H7/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c b/lib/main/STM32H7/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c index ffc615dac5a..195cf8df2dd 100644 --- a/lib/main/STM32H7/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c +++ b/lib/main/STM32H7/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c @@ -347,11 +347,6 @@ static int8_t SCSI_ModeSense6(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *p hmsc->bot_data[len] = MSC_Mode_Sense6_data[len]; } - // set bit 7 of the device configuration byte to indicate write protection - if (((USBD_StorageTypeDef *)pdev->pMSC_UserData)->IsWriteProtected(lun) != 0) { - hmsc->bot_data[2] = hmsc->bot_data[2] | (1 << 7); - } - return 0; } @@ -377,11 +372,6 @@ static int8_t SCSI_ModeSense10(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t * hmsc->bot_data[len] = MSC_Mode_Sense10_data[len]; } - // set bit 7 of the device configuration byte to indicate write protection - if (((USBD_StorageTypeDef *)pdev->pMSC_UserData)->IsWriteProtected(lun) != 0) { - hmsc->bot_data[3] = hmsc->bot_data[3] | (1 << 7); - } - return 0; } diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index f94d734d8d3..f76abdba558 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -1188,14 +1188,6 @@ groups: field: mixer_config.switchTransitionTimer min: 0 max: 200 - - name: tailsitter_orientation_offset - description: "Apply a 90 deg pitch offset in sensor aliment for tailsitter flying mode" - default_value: OFF - field: mixer_config.tailsitterOrientationOffset - type: bool - - - - name: PG_REVERSIBLE_MOTORS_CONFIG type: reversibleMotorsConfig_t members: diff --git a/src/main/flight/imu.c b/src/main/flight/imu.c index d3f9d90d7db..a99520a36b2 100644 --- a/src/main/flight/imu.c +++ b/src/main/flight/imu.c @@ -704,33 +704,6 @@ static void imuCalculateTurnRateacceleration(fpVector3_t *vEstcentrifugalAccelBF lastspeed = currentspeed; } -fpQuaternion_t* getTailSitterQuaternion(bool normal2tail){ - static bool firstRun = true; - static fpQuaternion_t qNormal2Tail; - static fpQuaternion_t qTail2Normal; - if(firstRun){ - fpAxisAngle_t axisAngle; - axisAngle.axis.x = 0; - axisAngle.axis.y = 1; - axisAngle.axis.z = 0; - axisAngle.angle = DEGREES_TO_RADIANS(-90); - axisAngleToQuaternion(&qNormal2Tail, &axisAngle); - quaternionConjugate(&qTail2Normal, &qNormal2Tail); - firstRun = false; - } - return normal2tail ? &qNormal2Tail : &qTail2Normal; -} - -void imuUpdateTailSitter(void) -{ - static bool lastTailSitter=false; - if (((bool)STATE(TAILSITTER)) != lastTailSitter){ - fpQuaternion_t* rotation_for_tailsitter= getTailSitterQuaternion(STATE(TAILSITTER)); - quaternionMultiply(&orientation, &orientation, rotation_for_tailsitter); - } - lastTailSitter = STATE(TAILSITTER); -} - static void imuCalculateEstimatedAttitude(float dT) { #if defined(USE_MAG) @@ -827,7 +800,6 @@ static void imuCalculateEstimatedAttitude(float dT) useCOG, courseOverGround, accWeight, magWeight); - imuUpdateTailSitter(); imuUpdateEulerAngles(); } diff --git a/src/main/flight/mixer.c b/src/main/flight/mixer.c index 834841e6580..35674c1f5dc 100644 --- a/src/main/flight/mixer.c +++ b/src/main/flight/mixer.c @@ -161,7 +161,6 @@ void mixerUpdateStateFlags(void) DISABLE_STATE(BOAT); DISABLE_STATE(AIRPLANE); DISABLE_STATE(MOVE_FORWARD_ONLY); - DISABLE_STATE(TAILSITTER); if (currentMixerConfig.platformType == PLATFORM_AIRPLANE) { ENABLE_STATE(FIXED_WING_LEGACY); @@ -187,12 +186,6 @@ void mixerUpdateStateFlags(void) ENABLE_STATE(ALTITUDE_CONTROL); } - if (currentMixerConfig.tailsitterOrientationOffset) { - ENABLE_STATE(TAILSITTER); - } else { - DISABLE_STATE(TAILSITTER); - } - if (currentMixerConfig.hasFlaps) { ENABLE_STATE(FLAPERON_AVAILABLE); } else { diff --git a/src/main/flight/mixer_profile.c b/src/main/flight/mixer_profile.c index 7b2590ff70b..64a6c39380d 100644 --- a/src/main/flight/mixer_profile.c +++ b/src/main/flight/mixer_profile.c @@ -53,7 +53,6 @@ void pgResetFn_mixerProfiles(mixerProfile_t *instance) .PIDProfileLinking = SETTING_MIXER_PID_PROFILE_LINKING_DEFAULT, .automated_switch = SETTING_MIXER_AUTOMATED_SWITCH_DEFAULT, .switchTransitionTimer = SETTING_MIXER_SWITCH_TRANS_TIMER_DEFAULT, - .tailsitterOrientationOffset = SETTING_TAILSITTER_ORIENTATION_OFFSET_DEFAULT, }); for (int j = 0; j < MAX_SUPPORTED_MOTORS; j++) { diff --git a/src/main/flight/mixer_profile.h b/src/main/flight/mixer_profile.h index 947ca701553..50fbb4a82f1 100644 --- a/src/main/flight/mixer_profile.h +++ b/src/main/flight/mixer_profile.h @@ -18,7 +18,6 @@ typedef struct mixerConfig_s { bool PIDProfileLinking; bool automated_switch; int16_t switchTransitionTimer; - bool tailsitterOrientationOffset; } mixerConfig_t; typedef struct mixerProfile_s { mixerConfig_t mixer_config; diff --git a/src/main/flight/pid.c b/src/main/flight/pid.c index 16ad2bc431d..351399bc508 100644 --- a/src/main/flight/pid.c +++ b/src/main/flight/pid.c @@ -586,11 +586,7 @@ int16_t angleFreefloatDeadband(int16_t deadband, flight_dynamics_index_t axis) static float computePidLevelTarget(flight_dynamics_index_t axis) { // This is ROLL/PITCH, run ANGLE/HORIZON controllers -#ifdef USE_PROGRAMMING_FRAMEWORK - float angleTarget = pidRcCommandToAngle(getRcCommandOverride(rcCommand, axis), pidProfile()->max_angle_inclination[axis]); -#else float angleTarget = pidRcCommandToAngle(rcCommand[axis], pidProfile()->max_angle_inclination[axis]); -#endif // Automatically pitch down if the throttle is manually controlled and reduced bellow cruise throttle if ((axis == FD_PITCH) && STATE(AIRPLANE) && FLIGHT_MODE(ANGLE_MODE) && !navigationIsControllingThrottle()) { @@ -1146,6 +1142,7 @@ void FAST_CODE pidController(float dT) } for (int axis = 0; axis < 3; axis++) { + // Step 1: Calculate gyro rates pidState[axis].gyroRate = gyro.gyroADCf[axis]; // Step 2: Read target @@ -1183,11 +1180,6 @@ void FAST_CODE pidController(float dT) // If axis angle override, get the correct angle from Logic Conditions float angleTarget = getFlightAxisAngleOverride(axis, computePidLevelTarget(axis)); - //apply 45 deg offset for tailsitter when isMixerTransitionMixing is activated - if (STATE(TAILSITTER) && isMixerTransitionMixing && axis == FD_PITCH){ - angleTarget += DEGREES_TO_DECIDEGREES(45); - } - if (STATE(AIRPLANE)) { // update anglehold mode updateAngleHold(&angleTarget, axis); } diff --git a/src/main/io/displayport_msp_bf_compat.c b/src/main/io/displayport_msp_bf_compat.c index dd120a2295d..4229e035b03 100644 --- a/src/main/io/displayport_msp_bf_compat.c +++ b/src/main/io/displayport_msp_bf_compat.c @@ -578,48 +578,6 @@ uint8_t getBfCharacter(uint8_t ch, uint8_t page) case (SYM_AH_V_START+4): case (SYM_AH_V_START+5): return BF_SYM_AH_BAR9_4; - - // BF for ESP_RADAR Symbols - case SYM_HUD_CARDINAL: - return BF_SYM_ARROW_SOUTH; - case SYM_HUD_CARDINAL + 1: - return BF_SYM_ARROW_16; - case SYM_HUD_CARDINAL + 2: - return BF_SYM_ARROW_15; - case SYM_HUD_CARDINAL + 3: - return BF_SYM_ARROW_WEST; - case SYM_HUD_CARDINAL + 4: - return BF_SYM_ARROW_12; - case SYM_HUD_CARDINAL + 5: - return BF_SYM_ARROW_11; - case SYM_HUD_CARDINAL + 6: - return BF_SYM_ARROW_NORTH; - case SYM_HUD_CARDINAL + 7: - return BF_SYM_ARROW_7; - case SYM_HUD_CARDINAL + 8: - return BF_SYM_ARROW_6; - case SYM_HUD_CARDINAL + 9: - return BF_SYM_ARROW_EAST; - case SYM_HUD_CARDINAL + 10: - return BF_SYM_ARROW_3; - case SYM_HUD_CARDINAL + 11: - return BF_SYM_ARROW_2; - - case SYM_HUD_ARROWS_R3: - return BF_SYM_AH_RIGHT; - case SYM_HUD_ARROWS_L3: - return BF_SYM_AH_LEFT; - - case SYM_HUD_SIGNAL_0: - return BF_SYM_AH_BAR9_1; - case SYM_HUD_SIGNAL_1: - return BF_SYM_AH_BAR9_3; - case SYM_HUD_SIGNAL_2: - return BF_SYM_AH_BAR9_4; - case SYM_HUD_SIGNAL_3: - return BF_SYM_AH_BAR9_5; - case SYM_HUD_SIGNAL_4: - return BF_SYM_AH_BAR9_7; /* case SYM_VARIO_UP_2A: return BF_SYM_VARIO_UP_2A; diff --git a/src/main/sensors/boardalignment.c b/src/main/sensors/boardalignment.c index 1f149faeff6..86e41880f89 100644 --- a/src/main/sensors/boardalignment.c +++ b/src/main/sensors/boardalignment.c @@ -28,7 +28,6 @@ #include "config/parameter_group.h" #include "config/parameter_group_ids.h" -#include "fc/runtime_config.h" #include "drivers/sensor.h" @@ -46,7 +45,6 @@ static bool standardBoardAlignment = true; // board orientation correction static fpMat3_t boardRotMatrix; -static fpMat3_t tailRotMatrix; // no template required since defaults are zero PG_REGISTER(boardAlignment_t, boardAlignment, PG_BOARD_ALIGNMENT, 0); @@ -58,19 +56,19 @@ static bool isBoardAlignmentStandard(const boardAlignment_t *boardAlignment) void initBoardAlignment(void) { - standardBoardAlignment=isBoardAlignmentStandard(boardAlignment()); - fp_angles_t rotationAngles; - - rotationAngles.angles.roll = DECIDEGREES_TO_RADIANS(boardAlignment()->rollDeciDegrees ); - rotationAngles.angles.pitch = DECIDEGREES_TO_RADIANS(boardAlignment()->pitchDeciDegrees); - rotationAngles.angles.yaw = DECIDEGREES_TO_RADIANS(boardAlignment()->yawDeciDegrees ); - - rotationMatrixFromAngles(&boardRotMatrix, &rotationAngles); - fp_angles_t tailSitter_rotationAngles; - tailSitter_rotationAngles.angles.roll = DECIDEGREES_TO_RADIANS(0); - tailSitter_rotationAngles.angles.pitch = DECIDEGREES_TO_RADIANS(900); - tailSitter_rotationAngles.angles.yaw = DECIDEGREES_TO_RADIANS(0); - rotationMatrixFromAngles(&tailRotMatrix, &tailSitter_rotationAngles); + if (isBoardAlignmentStandard(boardAlignment())) { + standardBoardAlignment = true; + } else { + fp_angles_t rotationAngles; + + standardBoardAlignment = false; + + rotationAngles.angles.roll = DECIDEGREES_TO_RADIANS(boardAlignment()->rollDeciDegrees ); + rotationAngles.angles.pitch = DECIDEGREES_TO_RADIANS(boardAlignment()->pitchDeciDegrees); + rotationAngles.angles.yaw = DECIDEGREES_TO_RADIANS(boardAlignment()->yawDeciDegrees ); + + rotationMatrixFromAngles(&boardRotMatrix, &rotationAngles); + } } void updateBoardAlignment(int16_t roll, int16_t pitch) @@ -87,23 +85,15 @@ void updateBoardAlignment(int16_t roll, int16_t pitch) initBoardAlignment(); } -void applyTailSitterAlignment(fpVector3_t *fpVec) -{ - if (!STATE(TAILSITTER)) { - return; - } - rotationMatrixRotateVector(fpVec, fpVec, &tailRotMatrix); -} - void applyBoardAlignment(float *vec) { - if (standardBoardAlignment && (!STATE(TAILSITTER))) { + if (standardBoardAlignment) { return; } fpVector3_t fpVec = { .v = { vec[X], vec[Y], vec[Z] } }; rotationMatrixRotateVector(&fpVec, &fpVec, &boardRotMatrix); - applyTailSitterAlignment(&fpVec); + vec[X] = lrintf(fpVec.x); vec[Y] = lrintf(fpVec.y); vec[Z] = lrintf(fpVec.z); diff --git a/src/main/sensors/boardalignment.h b/src/main/sensors/boardalignment.h index 17cd08e5ff3..6bf01272650 100644 --- a/src/main/sensors/boardalignment.h +++ b/src/main/sensors/boardalignment.h @@ -18,7 +18,6 @@ #pragma once #include "config/parameter_group.h" -#include "common/vector.h" typedef struct boardAlignment_s { int16_t rollDeciDegrees; @@ -31,5 +30,4 @@ PG_DECLARE(boardAlignment_t, boardAlignment); void initBoardAlignment(void); void updateBoardAlignment(int16_t roll, int16_t pitch); void applySensorAlignment(float * dest, float * src, uint8_t rotation); -void applyBoardAlignment(float *vec); -void applyTailSitterAlignment(fpVector3_t *vec); \ No newline at end of file +void applyBoardAlignment(float *vec); \ No newline at end of file diff --git a/src/main/sensors/compass.c b/src/main/sensors/compass.c index 02a9df69c44..86a394cfca1 100644 --- a/src/main/sensors/compass.c +++ b/src/main/sensors/compass.c @@ -472,7 +472,6 @@ void compassUpdate(timeUs_t currentTimeUs) fpVector3_t rotated; rotationMatrixRotateVector(&rotated, &v, &mag.dev.magAlign.externalRotation); - applyTailSitterAlignment(&rotated); mag.magADC[X] = rotated.x; mag.magADC[Y] = rotated.y; mag.magADC[Z] = rotated.z; From 4f4e86171b511edd7d63f5e922488955e69d65c0 Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Sat, 13 Jan 2024 09:56:27 +0000 Subject: [PATCH 046/241] More rebase fixes --- .../STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c | 2 -- .../STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c | 2 -- .../STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c | 2 -- src/main/flight/pid.c | 2 +- src/main/sensors/compass.c | 7 ++++--- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/main/STM32F4/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c b/lib/main/STM32F4/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c index 2b84130c11b..5d4d2521693 100644 --- a/lib/main/STM32F4/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c +++ b/lib/main/STM32F4/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c @@ -343,7 +343,6 @@ static int8_t SCSI_ModeSense6 (USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t * len--; hmsc->bot_data[len] = MSC_Mode_Sense6_data[len]; } - return 0; } @@ -366,7 +365,6 @@ static int8_t SCSI_ModeSense10 (USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t len--; hmsc->bot_data[len] = MSC_Mode_Sense10_data[len]; } - return 0; } diff --git a/lib/main/STM32F7/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c b/lib/main/STM32F7/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c index 9e0334995d6..ed3deef5959 100644 --- a/lib/main/STM32F7/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c +++ b/lib/main/STM32F7/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c @@ -347,7 +347,6 @@ static int8_t SCSI_ModeSense6 (USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t * len--; hmsc->bot_data[len] = MSC_Mode_Sense6_data[len]; } - return 0; } @@ -371,7 +370,6 @@ static int8_t SCSI_ModeSense10 (USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t len--; hmsc->bot_data[len] = MSC_Mode_Sense10_data[len]; } - return 0; } diff --git a/lib/main/STM32H7/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c b/lib/main/STM32H7/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c index 195cf8df2dd..c65f8ef16c2 100644 --- a/lib/main/STM32H7/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c +++ b/lib/main/STM32H7/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c @@ -346,7 +346,6 @@ static int8_t SCSI_ModeSense6(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *p len--; hmsc->bot_data[len] = MSC_Mode_Sense6_data[len]; } - return 0; } @@ -371,7 +370,6 @@ static int8_t SCSI_ModeSense10(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t * len--; hmsc->bot_data[len] = MSC_Mode_Sense10_data[len]; } - return 0; } diff --git a/src/main/flight/pid.c b/src/main/flight/pid.c index 351399bc508..bc794735eb2 100644 --- a/src/main/flight/pid.c +++ b/src/main/flight/pid.c @@ -1179,7 +1179,7 @@ void FAST_CODE pidController(float dT) if (FLIGHT_MODE(ANGLE_MODE) || FLIGHT_MODE(HORIZON_MODE) || FLIGHT_MODE(ANGLEHOLD_MODE) || isFlightAxisAngleOverrideActive(axis)) { // If axis angle override, get the correct angle from Logic Conditions float angleTarget = getFlightAxisAngleOverride(axis, computePidLevelTarget(axis)); - + if (STATE(AIRPLANE)) { // update anglehold mode updateAngleHold(&angleTarget, axis); } diff --git a/src/main/sensors/compass.c b/src/main/sensors/compass.c index 86a394cfca1..79af76845ba 100644 --- a/src/main/sensors/compass.c +++ b/src/main/sensors/compass.c @@ -472,9 +472,10 @@ void compassUpdate(timeUs_t currentTimeUs) fpVector3_t rotated; rotationMatrixRotateVector(&rotated, &v, &mag.dev.magAlign.externalRotation); - mag.magADC[X] = rotated.x; - mag.magADC[Y] = rotated.y; - mag.magADC[Z] = rotated.z; + + mag.magADC[X] = rotated.x; + mag.magADC[Y] = rotated.y; + mag.magADC[Z] = rotated.z; } else { // On-board compass From 5001272824766d80d7dfdc28f16eae5a4369ce1f Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Sat, 13 Jan 2024 10:41:54 +0000 Subject: [PATCH 047/241] Changed OSD_BLACKBOX introduction version number --- docs/OSD.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/OSD.md b/docs/OSD.md index eb8564bbe82..d57da7e25f3 100644 --- a/docs/OSD.md +++ b/docs/OSD.md @@ -168,7 +168,7 @@ Here are the OSD Elements provided by INAV. | 144 | OSD_MULTI_FUNCTION | 7.0.0 | | | 145 | OSD_ODOMETER | 7.0.0 | For this to work correctly, stats must be enabled (`set stats=ON`). Otherwise, this will show the total flight distance. | | 146 | OSD_PILOT_LOGO | 7.0.0 | | -| 147 | OSD_BLACKBOX | 7.1.0 | The element will be hidden unless blackbox recording is attempted. | +| 147 | OSD_BLACKBOX | 8.0.0 | The element will be hidden unless blackbox recording is attempted. | # Pilot Logos @@ -232,4 +232,4 @@ There are a couple of settings that allow you to adjust parts of the post flight - `osd_stats_page_auto_swap_time` allows you to specify how long each stats page is displayed [seconds]. Reverts to manual control when Roll stick used to change pages. Disabled when set to 0. - `osd_stats_energy_unit` allows you to choose the unit used for the drawn energy in the OSD stats [MAH/WH] (milliAmpere hour/ Watt hour). Default is MAH. -- `osd_stats_show_metric_efficiency` if you use non-metric units on your OSD. Enabling this option will also show the efficiency in metric. \ No newline at end of file +- `osd_stats_show_metric_efficiency` if you use non-metric units on your OSD. Enabling this option will also show the efficiency in metric. From a3308fbd47f4318592c2d55a9d3fb736e655d617 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Wed, 17 Jan 2024 15:14:08 +0100 Subject: [PATCH 048/241] Revert "Target update" This reverts commit dde9aabfc69cc46875dce08b98056e5fe06ac786. --- src/main/target/IFLIGHT_2RAW_H743/CMakeLists.txt | 1 + .../{IFLIGHT_BLITZ_H7_PRO => IFLIGHT_2RAW_H743}/config.c | 0 .../{IFLIGHT_BLITZ_H7_PRO => IFLIGHT_2RAW_H743}/target.c | 0 .../{IFLIGHT_BLITZ_H7_PRO => IFLIGHT_2RAW_H743}/target.h | 4 ++-- src/main/target/IFLIGHT_BLITZ_H7_PRO/CMakeLists.txt | 1 - 5 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 src/main/target/IFLIGHT_2RAW_H743/CMakeLists.txt rename src/main/target/{IFLIGHT_BLITZ_H7_PRO => IFLIGHT_2RAW_H743}/config.c (100%) rename src/main/target/{IFLIGHT_BLITZ_H7_PRO => IFLIGHT_2RAW_H743}/target.c (100%) rename src/main/target/{IFLIGHT_BLITZ_H7_PRO => IFLIGHT_2RAW_H743}/target.h (97%) delete mode 100644 src/main/target/IFLIGHT_BLITZ_H7_PRO/CMakeLists.txt diff --git a/src/main/target/IFLIGHT_2RAW_H743/CMakeLists.txt b/src/main/target/IFLIGHT_2RAW_H743/CMakeLists.txt new file mode 100644 index 00000000000..6a430dc6758 --- /dev/null +++ b/src/main/target/IFLIGHT_2RAW_H743/CMakeLists.txt @@ -0,0 +1 @@ +target_stm32h743xi(IFLIGHT_2RAW_H743) diff --git a/src/main/target/IFLIGHT_BLITZ_H7_PRO/config.c b/src/main/target/IFLIGHT_2RAW_H743/config.c similarity index 100% rename from src/main/target/IFLIGHT_BLITZ_H7_PRO/config.c rename to src/main/target/IFLIGHT_2RAW_H743/config.c diff --git a/src/main/target/IFLIGHT_BLITZ_H7_PRO/target.c b/src/main/target/IFLIGHT_2RAW_H743/target.c similarity index 100% rename from src/main/target/IFLIGHT_BLITZ_H7_PRO/target.c rename to src/main/target/IFLIGHT_2RAW_H743/target.c diff --git a/src/main/target/IFLIGHT_BLITZ_H7_PRO/target.h b/src/main/target/IFLIGHT_2RAW_H743/target.h similarity index 97% rename from src/main/target/IFLIGHT_BLITZ_H7_PRO/target.h rename to src/main/target/IFLIGHT_2RAW_H743/target.h index cc3205fd68d..d8a33a12ee1 100644 --- a/src/main/target/IFLIGHT_BLITZ_H7_PRO/target.h +++ b/src/main/target/IFLIGHT_2RAW_H743/target.h @@ -18,9 +18,9 @@ #pragma once -#define TARGET_BOARD_IDENTIFIER "IH7P" +#define TARGET_BOARD_IDENTIFIER "2RH7" -#define USBD_PRODUCT_STRING "IFLIGHT_BLITZ_H7_PRO" +#define USBD_PRODUCT_STRING "IFLIGHT_2RAW_H743" #define LED0 PE3 #define LED1 PE4 diff --git a/src/main/target/IFLIGHT_BLITZ_H7_PRO/CMakeLists.txt b/src/main/target/IFLIGHT_BLITZ_H7_PRO/CMakeLists.txt deleted file mode 100644 index acea488c750..00000000000 --- a/src/main/target/IFLIGHT_BLITZ_H7_PRO/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -target_stm32h743xi(IFLIGHT_BLITZ_H7_PRO) From 2729b6d52a1bd913fb4f546f42639722e3e37501 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Wed, 17 Jan 2024 15:28:15 +0100 Subject: [PATCH 049/241] Revert "Target updates for iFlight Blitz H7 Pro" This reverts commit 363d071c34b688189a13afcbe1b2bd38956b1b76. --- src/main/target/IFLIGHT_2RAW_H743/target.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/target/IFLIGHT_2RAW_H743/target.h b/src/main/target/IFLIGHT_2RAW_H743/target.h index d8a33a12ee1..f0cf03e33da 100644 --- a/src/main/target/IFLIGHT_2RAW_H743/target.h +++ b/src/main/target/IFLIGHT_2RAW_H743/target.h @@ -58,7 +58,7 @@ // Gyro #define USE_IMU_ICM42605 -#define IMU_ICM42605_ALIGN CW0_DEG +#define IMU_ICM42605_ALIGN CW90_DEG #define ICM42605_SPI_BUS BUS_SPI1 #define ICM42605_CS_PIN PC15 @@ -138,8 +138,6 @@ #define RSSI_ADC_CHANNEL ADC_CHN_3 #define AIRSPEED_ADC_CHANNEL ADC_CHN_4 -#define VBAT_SCALE_DEFAULT 2100 - // PINIO #define USE_PINIO #define USE_PINIOBOX From 68412e68ee21af5d9e09946e8674a57646113229 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Wed, 17 Jan 2024 15:36:57 +0100 Subject: [PATCH 050/241] Revert "Revert "Target updates for iFlight Blitz H7 Pro"" This reverts commit 2729b6d52a1bd913fb4f546f42639722e3e37501. --- src/main/target/IFLIGHT_2RAW_H743/target.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/target/IFLIGHT_2RAW_H743/target.h b/src/main/target/IFLIGHT_2RAW_H743/target.h index f0cf03e33da..d8a33a12ee1 100644 --- a/src/main/target/IFLIGHT_2RAW_H743/target.h +++ b/src/main/target/IFLIGHT_2RAW_H743/target.h @@ -58,7 +58,7 @@ // Gyro #define USE_IMU_ICM42605 -#define IMU_ICM42605_ALIGN CW90_DEG +#define IMU_ICM42605_ALIGN CW0_DEG #define ICM42605_SPI_BUS BUS_SPI1 #define ICM42605_CS_PIN PC15 @@ -138,6 +138,8 @@ #define RSSI_ADC_CHANNEL ADC_CHN_3 #define AIRSPEED_ADC_CHANNEL ADC_CHN_4 +#define VBAT_SCALE_DEFAULT 2100 + // PINIO #define USE_PINIO #define USE_PINIOBOX From 73765bba584bc6451b6f87a03073e5b3bed4c413 Mon Sep 17 00:00:00 2001 From: Yury MonZon Date: Fri, 19 Jan 2024 13:53:16 +0100 Subject: [PATCH 051/241] OSD Wind speed in m/s --- docs/Settings.md | 10 ++++++++++ src/main/fc/settings.yaml | 6 ++++++ src/main/io/osd.c | 12 ++++++++++-- src/main/io/osd.h | 1 + 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/docs/Settings.md b/docs/Settings.md index 5befa0aeffe..3e9d3fc12f1 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -4302,6 +4302,16 @@ Use wind estimation for remaining flight time/distance estimation --- +### osd_estimations_wind_mps + +Wind speed estimation in m/s + +| Default | Min | Max | +| --- | --- | --- | +| OFF | OFF | ON | + +--- + ### osd_failsafe_switch_layout If enabled the OSD automatically switches to the first layout during failsafe diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index 3df7beebb1e..1dfae3d35c8 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -3463,6 +3463,12 @@ groups: condition: USE_WIND_ESTIMATOR field: estimations_wind_compensation type: bool + - name: osd_estimations_wind_mps + description: "Wind speed estimation in m/s" + default_value: OFF + condition: USE_WIND_ESTIMATOR + field: estimations_wind_mps + type: bool - name: osd_failsafe_switch_layout description: "If enabled the OSD automatically switches to the first layout during failsafe" diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 22e11250963..3f07ef0370b 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -484,8 +484,16 @@ static void osdFormatWindSpeedStr(char *buff, int32_t ws, bool isValid) break; default: case OSD_UNIT_METRIC: - centivalue = CMSEC_TO_CENTIKPH(ws); - suffix = SYM_KMH; + if (osdConfig()->estimations_wind_mps) + { + centivalue = ws; + suffix = SYM_MS; + } + else + { + centivalue = CMSEC_TO_CENTIKPH(ws); + suffix = SYM_KMH; + } break; } diff --git a/src/main/io/osd.h b/src/main/io/osd.h index 5bcf6d34740..444970757c5 100644 --- a/src/main/io/osd.h +++ b/src/main/io/osd.h @@ -417,6 +417,7 @@ typedef struct osdConfig_s { #ifdef USE_WIND_ESTIMATOR bool estimations_wind_compensation; // use wind compensation for estimated remaining flight/distance + bool estimations_wind_mps; // wind speed estimation in m/s #endif uint8_t coordinate_digits; bool osd_failsafe_switch_layout; From 77c30438d22f490e0f75b099b61a9156534fbca2 Mon Sep 17 00:00:00 2001 From: 634296207 <57173107+634296207@users.noreply.github.com> Date: Tue, 19 Dec 2023 10:09:26 +0800 Subject: [PATCH 052/241] Add AocodaF4V3 target Add AocodaF4V3 target --- src/main/target/AOCODARCF4V3/CMakeLists | 1 + src/main/target/AOCODARCF4V3/config.c | 60 ++++++++ src/main/target/AOCODARCF4V3/target.c | 46 +++++++ src/main/target/AOCODARCF4V3/target.h | 176 ++++++++++++++++++++++++ 4 files changed, 283 insertions(+) create mode 100644 src/main/target/AOCODARCF4V3/CMakeLists create mode 100644 src/main/target/AOCODARCF4V3/config.c create mode 100644 src/main/target/AOCODARCF4V3/target.c create mode 100644 src/main/target/AOCODARCF4V3/target.h diff --git a/src/main/target/AOCODARCF4V3/CMakeLists b/src/main/target/AOCODARCF4V3/CMakeLists new file mode 100644 index 00000000000..419ffedea87 --- /dev/null +++ b/src/main/target/AOCODARCF4V3/CMakeLists @@ -0,0 +1 @@ +target_stm32f405xg(AOCODARCF4V3) diff --git a/src/main/target/AOCODARCF4V3/config.c b/src/main/target/AOCODARCF4V3/config.c new file mode 100644 index 00000000000..a46866ac4c5 --- /dev/null +++ b/src/main/target/AOCODARCF4V3/config.c @@ -0,0 +1,60 @@ +/* + * 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 "config/config_master.h" +#include "config/feature.h" + +#include "drivers/sensor.h" +#include "drivers/pwm_esc_detect.h" +#include "drivers/pwm_output.h" +#include "drivers/pwm_mapping.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 "sensors/battery.h" +#include "sensors/sensors.h" + +#include "telemetry/telemetry.h" +#include "fc/fc_msp_box.h" +#include "io/piniobox.h" +void targetConfiguration(void) +{ + pinioBoxConfigMutable()->permanentId[0] = BOX_PERMANENT_ID_USER1; + pinioBoxConfigMutable()->permanentId[1] = BOX_PERMANENT_ID_USER2; + beeperConfigMutable()->pwmMode = true; + serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART5)].functionMask = FUNCTION_MSP; + serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART5)].msp_baudrateIndex = BAUD_115200; + serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART2)].functionMask = FUNCTION_RX_SERIAL; + serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART3)].functionMask = FUNCTION_ESCSERIAL; + serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART1)].functionMask = FUNCTION_GPS; +} diff --git a/src/main/target/AOCODARCF4V3/target.c b/src/main/target/AOCODARCF4V3/target.c new file mode 100644 index 00000000000..8581cc5bf11 --- /dev/null +++ b/src/main/target/AOCODARCF4V3/target.c @@ -0,0 +1,46 @@ +/* + * This file is part of INAV. + * + * INAV 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. + * + * INAV 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 INAV. If not, see . + */ + + +#include + +#include "platform.h" +#include "drivers/io.h" +#include "drivers/timer.h" +#include "drivers/pwm_mapping.h" +#include "drivers/bus.h" + +timerHardware_t timerHardware[] = { + DEF_TIM(TIM5, CH4, PA3, TIM_USE_PPM, 0, 0 ), // PPM IN + + DEF_TIM(TIM8, CH1, PC6, TIM_USE_OUTPUT_AUTO, 0, 1 ), // S1 + DEF_TIM(TIM8, CH2, PC7, TIM_USE_OUTPUT_AUTO, 0, 1 ), // S2 + DEF_TIM(TIM8, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 1 ), // S3 + DEF_TIM(TIM8, CH4, PC9, TIM_USE_OUTPUT_AUTO, 0, 0 ), // S4 + + DEF_TIM(TIM2, CH1, PA15, TIM_USE_OUTPUT_AUTO, 0, 0 ), // S5 + DEF_TIM(TIM1, CH1, PA8, TIM_USE_OUTPUT_AUTO, 0, 1 ), // S6 + + DEF_TIM(TIM2, CH3, PB10, TIM_USE_OUTPUT_AUTO, 0, 0 ), // S7 + DEF_TIM(TIM2, CH4, PB11, TIM_USE_OUTPUT_AUTO, 0, 0 ), // S8 + + DEF_TIM(TIM3, CH4, PB1, TIM_USE_LED, 0, 0 ), // LED_STRIP + + +}; + +const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]); diff --git a/src/main/target/AOCODARCF4V3/target.h b/src/main/target/AOCODARCF4V3/target.h new file mode 100644 index 00000000000..048b0e790a1 --- /dev/null +++ b/src/main/target/AOCODARCF4V3/target.h @@ -0,0 +1,176 @@ +/* + * This file is part of INAV. + * + * INAV 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. + * + * INAV 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 INAV. If not, see . + */ + +#pragma once + +#define USE_TARGET_CONFIG + +#define TARGET_BOARD_IDENTIFIER "AOF4V3" +#define USBD_PRODUCT_STRING "AocodaRCF4V3" + +// ******** Board LEDs ********************** +#define LED0 PC13 + +// ******* Beeper *********** +#define BEEPER PB8 +#define BEEPER_INVERTED + + +// ******* GYRO and ACC ******** +#define USE_IMU_MPU6500 +#define IMU_MPU6500_ALIGN CW90_DEG +#define MPU6500_SPI_BUS BUS_SPI1 +#define MPU6500_CS_PIN PA4 + +#define USE_IMU_MPU6000 +#define IMU_MPU6000_ALIGN CW90_DEG +#define MPU6000_SPI_BUS BUS_SPI1 +#define MPU6000_CS_PIN PA4 + +#define USE_IMU_ICM42605 +#define IMU_ICM42605_ALIGN CW90_DEG +#define ICM42605_SPI_BUS BUS_SPI1 +#define ICM42605_CS_PIN PA4 + + +// *************** Baro ************************** +#define USE_I2C +#define USE_I2C_DEVICE_1 + +#define I2C1_SCL PB6 // SCL +#define I2C1_SDA PB7 // SDA +#define DEFAULT_I2C_BUS BUS_I2C1 + +#define USE_BARO +#define BARO_I2C_BUS DEFAULT_I2C_BUS + +#define USE_BARO_BMP280 +#define USE_BARO_MS5611 +#define USE_BARO_DPS310 + +//*********** Magnetometer / Compass ************* +#define USE_MAG +#define MAG_I2C_BUS DEFAULT_I2C_BUS +#define USE_MAG_ALL + +// ******* SERIAL ******** +#define USE_VCP +#define VBUS_SENSING_PIN PB12 +#define VBUS_SENSING_ENABLED + +#define USE_UART1 +#define UART1_TX_PIN PA9 +#define UART1_RX_PIN PA10 + +#define USE_UART2 +#define UART2_TX_PIN PA2 +#define UART2_RX_PIN PA3 + +#define USE_UART3 +#define UART3_TX_PIN PC11 +#define UART3_RX_PIN PC10 + +#define USE_UART4 +#define UART4_TX_PIN PA0 +#define UART4_RX_PIN PA1 + +#define USE_UART5 +#define UART5_TX_PIN PC12 +#define UART5_RX_PIN PD2 + + +#define SERIAL_PORT_COUNT 6 + + +// ******* SPI ******** +#define USE_SPI + +#define USE_SPI_DEVICE_1 +#define SPI1_NSS_PIN PA4 +#define SPI1_SCK_PIN PA5 +#define SPI1_MISO_PIN PA6 +#define SPI1_MOSI_PIN PA7 + +#define USE_SPI_DEVICE_2 +#define SPI2_NSS_PIN PA13 +#define SPI2_SCK_PIN PB13 +#define SPI2_MISO_PIN PB14 +#define SPI2_MOSI_PIN PB15 + +#define USE_SPI_DEVICE_3 +#define SPI3_NSS_PIN PC0 +#define SPI3_SCK_PIN PB3 +#define SPI3_MISO_PIN PB4 +#define SPI3_MOSI_PIN PB5 + +// ******* ADC ******** +#define USE_ADC +#define ADC_CHANNEL_1_PIN PC1 +#define ADC_CHANNEL_2_PIN PC2 +#define ADC_CHANNEL_3_PIN PC3 + +#define VBAT_ADC_CHANNEL ADC_CHN_2 +#define RSSI_ADC_CHANNEL ADC_CHN_3 +#define CURRENT_METER_ADC_CHANNEL ADC_CHN_1 + +#define VBAT_SCALE_DEFAULT 1100 + +// ******* OSD ******** +#define USE_OSD +#define USE_MAX7456 +#define MAX7456_SPI_BUS BUS_SPI2 +#define MAX7456_CS_PIN PA13 + +//******* FLASH ******** +#define USE_FLASHFS +#define USE_FLASH_M25P16 +#define M25P16_SPI_BUS BUS_SPI3 +#define M25P16_CS_PIN PC0 + +#define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT + +// *************** PINIO *************************** +#define USE_PINIO +#define USE_PINIOBOX +#define PINIO1_PIN PC5 // VTX power switcher +#define PINIO2_PIN PA14 //bluetooth +#define PINIO1_FLAGS PINIO_FLAGS_INVERTED +#define PINIO2_FLAGS PINIO_FLAGS_INVERTED + +//************ LEDSTRIP ***************** +#define USE_LED_STRIP +#define WS2811_PIN PB1 + +// ******* FEATURES ******** +#define DEFAULT_RX_TYPE RX_TYPE_SERIAL +#define SERIALRX_UART SERIAL_PORT_USART2 +#define SERIALRX_PROVIDER SERIALRX_CRSF + +#define DEFAULT_FEATURES (FEATURE_OSD | FEATURE_TELEMETRY | FEATURE_CURRENT_METER | FEATURE_VBAT | FEATURE_TX_PROF_SEL | FEATURE_GPS | FEATURE_BLACKBOX | FEATURE_LED_STRIP) + +#define TARGET_IO_PORTA 0xffff +#define TARGET_IO_PORTB 0xffff +#define TARGET_IO_PORTC 0xffff +#define TARGET_IO_PORTD 0xffff + +#define MAX_PWM_OUTPUT_PORTS 10 + +// ESC-related features +#define USE_DSHOT +#define USE_SERIALSHOT +#define USE_ESC_SENSOR +#define USE_SERIAL_4WAY_BLHELI_INTERFACE From 69b1c400257ac262ef6f411ca6cd761da36e752b Mon Sep 17 00:00:00 2001 From: 634296207 <57173107+634296207@users.noreply.github.com> Date: Wed, 10 Jan 2024 12:07:41 +0800 Subject: [PATCH 053/241] Modify AOCORCF4V3 target 1. Add SPL06 support 2. CAM1/CAM2 support --- src/main/target/AOCODARCF4V3/CMakeLists | 1 + src/main/target/AOCODARCF4V3/config.c | 1 + src/main/target/AOCODARCF4V3/target.h | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/target/AOCODARCF4V3/CMakeLists b/src/main/target/AOCODARCF4V3/CMakeLists index 419ffedea87..459aded8f16 100644 --- a/src/main/target/AOCODARCF4V3/CMakeLists +++ b/src/main/target/AOCODARCF4V3/CMakeLists @@ -1 +1,2 @@ target_stm32f405xg(AOCODARCF4V3) + diff --git a/src/main/target/AOCODARCF4V3/config.c b/src/main/target/AOCODARCF4V3/config.c index a46866ac4c5..e48045fb4de 100644 --- a/src/main/target/AOCODARCF4V3/config.c +++ b/src/main/target/AOCODARCF4V3/config.c @@ -51,6 +51,7 @@ void targetConfiguration(void) { pinioBoxConfigMutable()->permanentId[0] = BOX_PERMANENT_ID_USER1; pinioBoxConfigMutable()->permanentId[1] = BOX_PERMANENT_ID_USER2; + pinioBoxConfigMutable()->permanentId[2] = BOX_PERMANENT_ID_USER3; beeperConfigMutable()->pwmMode = true; serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART5)].functionMask = FUNCTION_MSP; serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART5)].msp_baudrateIndex = BAUD_115200; diff --git a/src/main/target/AOCODARCF4V3/target.h b/src/main/target/AOCODARCF4V3/target.h index 048b0e790a1..2c0a57fcc66 100644 --- a/src/main/target/AOCODARCF4V3/target.h +++ b/src/main/target/AOCODARCF4V3/target.h @@ -61,6 +61,7 @@ #define USE_BARO_BMP280 #define USE_BARO_MS5611 #define USE_BARO_DPS310 +#define USE_BARO_SPL06 //*********** Magnetometer / Compass ************* #define USE_MAG @@ -136,11 +137,11 @@ #define MAX7456_CS_PIN PA13 //******* FLASH ******** + #define USE_FLASHFS #define USE_FLASH_M25P16 #define M25P16_SPI_BUS BUS_SPI3 #define M25P16_CS_PIN PC0 - #define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT // *************** PINIO *************************** @@ -148,6 +149,7 @@ #define USE_PINIOBOX #define PINIO1_PIN PC5 // VTX power switcher #define PINIO2_PIN PA14 //bluetooth +#define PINIO3_PIN PC15 //Camera control #define PINIO1_FLAGS PINIO_FLAGS_INVERTED #define PINIO2_FLAGS PINIO_FLAGS_INVERTED From 24f263cd861e21683f6a986585ce219e420d33d9 Mon Sep 17 00:00:00 2001 From: "daniel.li" Date: Wed, 10 Jan 2024 18:43:52 +0800 Subject: [PATCH 054/241] Fix AOCODARCF4V3 CMakeLists issue --- src/main/target/AOCODARCF4V3/{CMakeLists => CMakeLists.txt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/target/AOCODARCF4V3/{CMakeLists => CMakeLists.txt} (100%) diff --git a/src/main/target/AOCODARCF4V3/CMakeLists b/src/main/target/AOCODARCF4V3/CMakeLists.txt similarity index 100% rename from src/main/target/AOCODARCF4V3/CMakeLists rename to src/main/target/AOCODARCF4V3/CMakeLists.txt From bcd526f78393b2848d4a88ccb08ae400ef872ea7 Mon Sep 17 00:00:00 2001 From: 634296207 <57173107+634296207@users.noreply.github.com> Date: Thu, 11 Jan 2024 20:42:18 +0800 Subject: [PATCH 055/241] Add AOCODAF4V3-SDCard target --- src/main/target/AOCODARCF4V3/CMakeLists.txt | 1 + src/main/target/AOCODARCF4V3/target.h | 23 ++++++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/main/target/AOCODARCF4V3/CMakeLists.txt b/src/main/target/AOCODARCF4V3/CMakeLists.txt index 459aded8f16..706b818e2b8 100644 --- a/src/main/target/AOCODARCF4V3/CMakeLists.txt +++ b/src/main/target/AOCODARCF4V3/CMakeLists.txt @@ -1,2 +1,3 @@ +target_stm32f405xg(AOCODARCF4V3_SD) target_stm32f405xg(AOCODARCF4V3) diff --git a/src/main/target/AOCODARCF4V3/target.h b/src/main/target/AOCODARCF4V3/target.h index 2c0a57fcc66..6b76ab97287 100644 --- a/src/main/target/AOCODARCF4V3/target.h +++ b/src/main/target/AOCODARCF4V3/target.h @@ -16,11 +16,16 @@ */ #pragma once - + #define USE_TARGET_CONFIG -#define TARGET_BOARD_IDENTIFIER "AOF4V3" -#define USBD_PRODUCT_STRING "AocodaRCF4V3" +#ifdef AOCODARCF4V3 +#define TARGET_BOARD_IDENTIFIER "AOF4V3" +#define USBD_PRODUCT_STRING "AOCODARCF4V3" +#else +#define TARGET_BOARD_IDENTIFIER "AOF4V3SD" +#define USBD_PRODUCT_STRING "AOCODARCF4V3_SD" +#endif // ******** Board LEDs ********************** #define LED0 PC13 @@ -137,13 +142,21 @@ #define MAX7456_CS_PIN PA13 //******* FLASH ******** - +#if defined(AOCODARCF4V3_SD) +#define USE_SDCARD +#define USE_SDCARD_SPI +#define SDCARD_SPI_BUS BUS_SPI3 +#define SDCARD_CS_PIN PC0 +#define SDCARD_DETECT_INVERTED +#define SDCARD_DETECT_PIN PC14 +#define ENABLE_BLACKBOX_LOGGING_ON_SDCARD_BY_DEFAULT +#else #define USE_FLASHFS #define USE_FLASH_M25P16 #define M25P16_SPI_BUS BUS_SPI3 #define M25P16_CS_PIN PC0 #define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT - +#endif // *************** PINIO *************************** #define USE_PINIO #define USE_PINIOBOX From 38f1c7e0ae1c48198079537ab5958a51590bb12f Mon Sep 17 00:00:00 2001 From: 634296207 <57173107+634296207@users.noreply.github.com> Date: Fri, 19 Jan 2024 08:59:58 +0800 Subject: [PATCH 056/241] Fixed ESC telemetry and buzzer issue 1. Fix buzzer no sound issue 2. Fix ESC telemtry pin definition 3. Adjust current scaler --- src/main/target/AOCODARCF4V3/config.c | 36 ++++++--------------------- src/main/target/AOCODARCF4V3/target.h | 5 ++-- 2 files changed, 10 insertions(+), 31 deletions(-) diff --git a/src/main/target/AOCODARCF4V3/config.c b/src/main/target/AOCODARCF4V3/config.c index e48045fb4de..31f33d83528 100644 --- a/src/main/target/AOCODARCF4V3/config.c +++ b/src/main/target/AOCODARCF4V3/config.c @@ -1,4 +1,3 @@ -/* * This file is part of Cleanflight. * * Cleanflight is free software: you can redistribute it and/or modify @@ -14,47 +13,26 @@ * 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 "platform.h" -#include "config/config_master.h" -#include "config/feature.h" +#include "fc/fc_msp_box.h" +//#include "fc/config.h" -#include "drivers/sensor.h" -#include "drivers/pwm_esc_detect.h" -#include "drivers/pwm_output.h" -#include "drivers/pwm_mapping.h" +#include "io/piniobox.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 "sensors/battery.h" -#include "sensors/sensors.h" - -#include "telemetry/telemetry.h" -#include "fc/fc_msp_box.h" -#include "io/piniobox.h" void targetConfiguration(void) { pinioBoxConfigMutable()->permanentId[0] = BOX_PERMANENT_ID_USER1; pinioBoxConfigMutable()->permanentId[1] = BOX_PERMANENT_ID_USER2; pinioBoxConfigMutable()->permanentId[2] = BOX_PERMANENT_ID_USER3; - beeperConfigMutable()->pwmMode = true; + // beeperConfigMutable()->pwmMode = true; serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART5)].functionMask = FUNCTION_MSP; serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART5)].msp_baudrateIndex = BAUD_115200; + serialConfigMutable()->portConfigs[4].functionMask = FUNCTION_VTX_TRAMP; + serialConfigMutable()->portConfigs[4].peripheral_baudrateIndex = BAUD_115200; serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART2)].functionMask = FUNCTION_RX_SERIAL; serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART3)].functionMask = FUNCTION_ESCSERIAL; serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART1)].functionMask = FUNCTION_GPS; diff --git a/src/main/target/AOCODARCF4V3/target.h b/src/main/target/AOCODARCF4V3/target.h index 6b76ab97287..0c95564162e 100644 --- a/src/main/target/AOCODARCF4V3/target.h +++ b/src/main/target/AOCODARCF4V3/target.h @@ -87,8 +87,8 @@ #define UART2_RX_PIN PA3 #define USE_UART3 -#define UART3_TX_PIN PC11 -#define UART3_RX_PIN PC10 +#define UART3_TX_PIN PC10 +#define UART3_RX_PIN PC11 #define USE_UART4 #define UART4_TX_PIN PA0 @@ -134,6 +134,7 @@ #define CURRENT_METER_ADC_CHANNEL ADC_CHN_1 #define VBAT_SCALE_DEFAULT 1100 +#define CURRENT_METER_SCALE 206 // ******* OSD ******** #define USE_OSD From 43e542e08a5b60547d290f4486df3f59542f3d21 Mon Sep 17 00:00:00 2001 From: "daniel.li" Date: Fri, 19 Jan 2024 09:18:05 +0800 Subject: [PATCH 057/241] Fix AOCODARCF4V3 compile issue --- src/main/target/AOCODARCF4V3/config.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/target/AOCODARCF4V3/config.c b/src/main/target/AOCODARCF4V3/config.c index 31f33d83528..c80a92940a9 100644 --- a/src/main/target/AOCODARCF4V3/config.c +++ b/src/main/target/AOCODARCF4V3/config.c @@ -1,3 +1,4 @@ +/* * This file is part of Cleanflight. * * Cleanflight is free software: you can redistribute it and/or modify From 5111280ab9c95bf3373212955ee15c5fc74b3fb6 Mon Sep 17 00:00:00 2001 From: Martin Luessi Date: Sat, 10 Feb 2024 14:19:15 -0800 Subject: [PATCH 058/241] Fix motor output glitch by initializing IO after timer --- src/main/drivers/pwm_output.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/drivers/pwm_output.c b/src/main/drivers/pwm_output.c index d898b1595f1..d48f38679e9 100644 --- a/src/main/drivers/pwm_output.c +++ b/src/main/drivers/pwm_output.c @@ -172,6 +172,8 @@ static pwmOutputPort_t *pwmOutConfig(const timerHardware_t *timHw, resourceOwner const IO_t io = IOGetByTag(timHw->tag); IOInit(io, owner, RESOURCE_OUTPUT, allocatedOutputPortCount); + pwmOutConfigTimer(p, tch, hz, period, value); + if (enableOutput) { IOConfigGPIOAF(io, IOCFG_AF_PP, timHw->alternateFunction); } @@ -181,7 +183,6 @@ static pwmOutputPort_t *pwmOutConfig(const timerHardware_t *timHw, resourceOwner IOLo(io); } - pwmOutConfigTimer(p, tch, hz, period, value); return p; } From 57d84fc40434299d780428bd7d295bd20ec58cb5 Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Sat, 17 Feb 2024 22:14:39 +0000 Subject: [PATCH 059/241] Show stats if space & improve formatting - Show `stats` if enabled and space allows on the post flight statistics - Improve the layout of some elements --- src/main/common/maths.h | 3 + src/main/io/osd.c | 231 ++++++++++++++++++++++++++++------------ 2 files changed, 163 insertions(+), 71 deletions(-) diff --git a/src/main/common/maths.h b/src/main/common/maths.h index 0f5b6d021a7..1cbecbc3db6 100644 --- a/src/main/common/maths.h +++ b/src/main/common/maths.h @@ -61,6 +61,9 @@ #define CENTIMETERS_TO_METERS(cm) (cm * 0.01f) #define METERS_TO_CENTIMETERS(m) (m * 100) +#define METERS_TO_KILOMETERS(m) (m / 1000.0f) + +#define MWH_TO_WH(mWh) (mWh / 1000.0f) #define CMSEC_TO_CENTIMPH(cms) (cms * 2.2369363f) #define CMSEC_TO_CENTIKPH(cms) (cms * 3.6f) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index cfaa66261bb..715f2d4eecf 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -4205,83 +4205,154 @@ uint8_t drawLogos(bool singular, uint8_t row) { return logoRow; } -uint8_t drawStats(uint8_t row) { #ifdef USE_STATS - char string_buffer[30]; - uint8_t statNameX = (osdDisplayPort->cols - 22) / 2; - uint8_t statValueX = statNameX + 21; +uint8_t drawStat_Stats(uint8_t statNameX, uint8_t row, uint8_t statValueX, bool isBootStats) +{ + uint8_t buffLen = 0; + char string_buffer[osdDisplayPort->cols - statValueX]; if (statsConfig()->stats_enabled) { - displayWrite(osdDisplayPort, statNameX, row, "ODOMETER:"); + if (isBootStats) + displayWrite(osdDisplayPort, statNameX, row, "ODOMETER:"); + else + displayWrite(osdDisplayPort, statNameX, row, "ODOMETER"); + switch (osdConfig()->units) { case OSD_UNIT_UK: FALLTHROUGH; case OSD_UNIT_IMPERIAL: - tfp_sprintf(string_buffer, "%5d", (int)(statsConfig()->stats_total_dist / METERS_PER_MILE)); - string_buffer[5] = SYM_MI; + if (isBootStats) { + tfp_sprintf(string_buffer, "%5d", (uint16_t)(statsConfig()->stats_total_dist / METERS_PER_MILE)); + buffLen = 5; + } else { + uint16_t statTotalDist = (uint16_t)(statsConfig()->stats_total_dist / METERS_PER_MILE); + tfp_sprintf(string_buffer, ": %d", statTotalDist); + buffLen = 3 + sizeof(statTotalDist); + } + + string_buffer[buffLen++] = SYM_MI; break; default: case OSD_UNIT_GA: - tfp_sprintf(string_buffer, "%5d", (int)(statsConfig()->stats_total_dist / METERS_PER_NAUTICALMILE)); - string_buffer[5] = SYM_NM; + if (isBootStats) { + tfp_sprintf(string_buffer, "%5d", (uint16_t)(statsConfig()->stats_total_dist / METERS_PER_NAUTICALMILE)); + buffLen = 5; + } else { + uint16_t statTotalDist = (uint16_t)(statsConfig()->stats_total_dist / METERS_PER_NAUTICALMILE); + tfp_sprintf(string_buffer, ": %d", statTotalDist); + buffLen = 3 + sizeof(statTotalDist); + } + + string_buffer[buffLen++] = SYM_NM; break; case OSD_UNIT_METRIC_MPH: FALLTHROUGH; case OSD_UNIT_METRIC: - tfp_sprintf(string_buffer, "%5d", (int)(statsConfig()->stats_total_dist / METERS_PER_KILOMETER)); - string_buffer[5] = SYM_KM; + if (isBootStats) { + tfp_sprintf(string_buffer, "%5d", (uint16_t)(statsConfig()->stats_total_dist / METERS_PER_KILOMETER)); + buffLen = 5; + } else { + uint16_t statTotalDist = (uint16_t)(statsConfig()->stats_total_dist / METERS_PER_KILOMETER); + tfp_sprintf(string_buffer, ": %d", statTotalDist); + buffLen = 3 + sizeof(statTotalDist); + } + + string_buffer[buffLen++] = SYM_KM; break; } - string_buffer[6] = '\0'; - displayWrite(osdDisplayPort, statValueX-5, row, string_buffer); + string_buffer[buffLen] = '\0'; + displayWrite(osdDisplayPort, statValueX-(isBootStats ? 5 : 0), row, string_buffer); - displayWrite(osdDisplayPort, statNameX, ++row, "TOTAL TIME:"); + if (isBootStats) + displayWrite(osdDisplayPort, statNameX, ++row, "TOTAL TIME:"); + else + displayWrite(osdDisplayPort, statNameX, ++row, "TOTAL TIME"); + uint32_t tot_mins = statsConfig()->stats_total_time / 60; - tfp_sprintf(string_buffer, "%2d:%02dH:M", (int)(tot_mins / 60), (int)(tot_mins % 60)); - displayWrite(osdDisplayPort, statValueX-7, row, string_buffer); + if (isBootStats) + tfp_sprintf(string_buffer, "%d:%02dH:M%c", (int)(tot_mins / 60), (int)(tot_mins % 60), '\0'); + else + tfp_sprintf(string_buffer, ": %d:%02dH:M%c", (int)(tot_mins / 60), (int)(tot_mins % 60), '\0'); + + displayWrite(osdDisplayPort, statValueX-(isBootStats ? 7 : 0), row, string_buffer); #ifdef USE_ADC - if (feature(FEATURE_VBAT) && feature(FEATURE_CURRENT_METER)) { - displayWrite(osdDisplayPort, statNameX, ++row, "TOTAL ENERGY:"); - osdFormatCentiNumber(string_buffer, statsConfig()->stats_total_energy / 10, 0, 2, 0, 4, false); - displayWrite(osdDisplayPort, statValueX-4, row, string_buffer); - displayWriteChar(osdDisplayPort, statValueX, row, SYM_WH); + if (feature(FEATURE_VBAT) && feature(FEATURE_CURRENT_METER) && statsConfig()->stats_total_energy) { + uint8_t buffOffset = 0; + if (isBootStats) + displayWrite(osdDisplayPort, statNameX, ++row, "TOTAL ENERGY:"); + else { + displayWrite(osdDisplayPort, statNameX, ++row, "TOTAL ENERGY"); + string_buffer[0] = ':'; + buffOffset = 2; + } + + osdFormatCentiNumber(string_buffer + buffOffset, statsConfig()->stats_total_energy / 10, 0, 2, 0, 6, true); + displayWrite(osdDisplayPort, statValueX - (isBootStats ? 6 : 0), row, string_buffer); + displayWriteChar(osdDisplayPort, statValueX + (isBootStats ? 0 : 8), row, SYM_WH); + + char avgEffBuff[osdDisplayPort->cols - statValueX]; + + for (uint8_t i = 0; i < osdDisplayPort->cols - statValueX; i++) { + avgEffBuff[i] = '\0'; + string_buffer[i] = '\0'; + } - displayWrite(osdDisplayPort, statNameX, ++row, "AVG EFFICIENCY:"); if (statsConfig()->stats_total_dist) { - uint32_t avg_efficiency = statsConfig()->stats_total_energy / (statsConfig()->stats_total_dist / METERS_PER_KILOMETER); // mWh/km + if (isBootStats) + displayWrite(osdDisplayPort, statNameX, ++row, "AVG EFFICIENCY:"); + else { + displayWrite(osdDisplayPort, statNameX, ++row, "AVG EFFICIENCY"); + strcat(avgEffBuff, ": "); + } + + float_t avg_efficiency = MWH_TO_WH(statsConfig()->stats_total_energy) / METERS_TO_KILOMETERS(statsConfig()->stats_total_dist); // Wh/km switch (osdConfig()->units) { case OSD_UNIT_UK: FALLTHROUGH; case OSD_UNIT_IMPERIAL: - osdFormatCentiNumber(string_buffer, avg_efficiency / 10, 0, 2, 0, 3, false); - string_buffer[3] = SYM_WH_MI; + osdFormatCentiNumber(string_buffer, (int32_t)(avg_efficiency * METERS_PER_MILE / 10), 0, 2, 2, 4, false); + string_buffer[4] = SYM_WH_MI; break; case OSD_UNIT_GA: - osdFormatCentiNumber(string_buffer, avg_efficiency / 10, 0, 2, 0, 3, false); - string_buffer[3] = SYM_WH_NM; + osdFormatCentiNumber(string_buffer, (int32_t)(avg_efficiency * METERS_PER_NAUTICALMILE / 10), 0, 2, 2, 4, false); + string_buffer[4] = SYM_WH_NM; break; default: case OSD_UNIT_METRIC_MPH: FALLTHROUGH; case OSD_UNIT_METRIC: - osdFormatCentiNumber(string_buffer, avg_efficiency / 10000 * METERS_PER_MILE, 0, 2, 0, 3, false); - string_buffer[3] = SYM_WH_KM; + osdFormatCentiNumber(string_buffer, (int32_t)(avg_efficiency * 100), 0, 2, 2, 4, false); + string_buffer[4] = SYM_WH_KM; break; } + + if (isBootStats) + strcat(avgEffBuff, string_buffer); + else + strcat(avgEffBuff, osdFormatTrimWhiteSpace(string_buffer)); } else { - string_buffer[0] = string_buffer[1] = string_buffer[2] = '-'; + strcat(avgEffBuff, "----"); } - string_buffer[4] = '\0'; - displayWrite(osdDisplayPort, statValueX-3, row++, string_buffer); + + displayWrite(osdDisplayPort, statValueX-(isBootStats ? 4 : 0), row++, avgEffBuff); } #endif // USE_ADC } -#endif // USE_STATS return row; } -static void osdSetNextRefreshIn(uint32_t timeMs) { +uint8_t drawStats(uint8_t row) +{ + uint8_t statNameX = (osdDisplayPort->cols - 22) / 2; + uint8_t statValueX = statNameX + 21; + + return drawStat_Stats(statNameX, row, statValueX, true); +} +#endif // USE STATS + +static void osdSetNextRefreshIn(uint32_t timeMs) +{ resumeRefreshAt = micros() + timeMs * 1000; refreshWaitForResumeCmdRelease = true; } @@ -4464,7 +4535,8 @@ static void osdUpdateStats(void) stats.max_altitude = MAX(stats.max_altitude, osdGetAltitude()); } -uint8_t drawStat_FlightTime(uint8_t col, uint8_t row, uint8_t statValX) { +uint8_t drawStat_FlightTime(uint8_t col, uint8_t row, uint8_t statValX) +{ char buff[12]; displayWrite(osdDisplayPort, col, row, "FLIGHT TIME"); uint16_t flySeconds = getFlightTime(); @@ -4478,7 +4550,8 @@ uint8_t drawStat_FlightTime(uint8_t col, uint8_t row, uint8_t statValX) { return row; } -uint8_t drawStat_FlightDistance(uint8_t col, uint8_t row, uint8_t statValX) { +uint8_t drawStat_FlightDistance(uint8_t col, uint8_t row, uint8_t statValX) +{ char buff[12]; displayWrite(osdDisplayPort, col, row, "FLIGHT DISTANCE"); @@ -4489,7 +4562,8 @@ uint8_t drawStat_FlightDistance(uint8_t col, uint8_t row, uint8_t statValX) { return row; } -uint8_t drawStat_MaxDistanceFromHome(uint8_t col, uint8_t row, uint8_t statValX) { +uint8_t drawStat_MaxDistanceFromHome(uint8_t col, uint8_t row, uint8_t statValX) +{ char buff[12]; uint8_t valueXOffset = 0; if (!osdDisplayIsHD()) { @@ -4507,26 +4581,27 @@ uint8_t drawStat_MaxDistanceFromHome(uint8_t col, uint8_t row, uint8_t statValX) return row; } -uint8_t drawStat_Speed(uint8_t col, uint8_t row, uint8_t statValX) { +uint8_t drawStat_Speed(uint8_t col, uint8_t row, uint8_t statValX) +{ char buff[12]; + char buff2[12]; uint8_t multiValueXOffset = 0; displayWrite(osdDisplayPort, col, row, "MAX/AVG SPEED"); - tfp_sprintf(buff, ": "); - osdFormatVelocityStr(buff + 2, stats.max_3D_speed, true, false); - osdLeftAlignString(buff); - strcat(osdFormatTrimWhiteSpace(buff), "/"); + + osdFormatVelocityStr(buff2, stats.max_3D_speed, true, false); + tfp_sprintf(buff, ": %s/", osdFormatTrimWhiteSpace(buff2)); multiValueXOffset = strlen(buff); displayWrite(osdDisplayPort, statValX, row, buff); - osdGenerateAverageVelocityStr(buff); - osdLeftAlignString(buff); - displayWrite(osdDisplayPort, statValX + multiValueXOffset, row++, buff); + osdGenerateAverageVelocityStr(buff2); + displayWrite(osdDisplayPort, statValX + multiValueXOffset, row++, osdFormatTrimWhiteSpace(buff2)); return row; } -uint8_t drawStat_MaximumAltitude(uint8_t col, uint8_t row, uint8_t statValX) { +uint8_t drawStat_MaximumAltitude(uint8_t col, uint8_t row, uint8_t statValX) +{ char buff[12]; displayWrite(osdDisplayPort, col, row, "MAX ALTITUDE"); tfp_sprintf(buff, ": "); @@ -4536,7 +4611,8 @@ uint8_t drawStat_MaximumAltitude(uint8_t col, uint8_t row, uint8_t statValX) { return row; } -uint8_t drawStat_BatteryVoltage(uint8_t col, uint8_t row, uint8_t statValX) { +uint8_t drawStat_BatteryVoltage(uint8_t col, uint8_t row, uint8_t statValX) +{ char buff[12]; uint8_t multiValueXOffset = 0; if (!osdDisplayIsHD()) @@ -4558,7 +4634,8 @@ uint8_t drawStat_BatteryVoltage(uint8_t col, uint8_t row, uint8_t statValX) { return row; } -uint8_t drawStat_MaximumCurrent(uint8_t col, uint8_t row, uint8_t statValX) { +uint8_t drawStat_MaximumCurrent(uint8_t col, uint8_t row, uint8_t statValX) +{ char buff[12]; displayWrite(osdDisplayPort, col, row, "MAX CURRENT"); tfp_sprintf(buff, ": "); @@ -4569,7 +4646,8 @@ uint8_t drawStat_MaximumCurrent(uint8_t col, uint8_t row, uint8_t statValX) { return row; } -uint8_t drawStat_MaximumPower(uint8_t col, uint8_t row, uint8_t statValX) { +uint8_t drawStat_MaximumPower(uint8_t col, uint8_t row, uint8_t statValX) +{ char buff[12]; displayWrite(osdDisplayPort, col, row, "MAX POWER"); tfp_sprintf(buff, ": "); @@ -4580,7 +4658,8 @@ uint8_t drawStat_MaximumPower(uint8_t col, uint8_t row, uint8_t statValX) { return row; } -uint8_t drawStat_UsedEnergy(uint8_t col, uint8_t row, uint8_t statValX) { +uint8_t drawStat_UsedEnergy(uint8_t col, uint8_t row, uint8_t statValX) +{ char buff[12]; uint8_t buffOffset = 0; @@ -4603,7 +4682,8 @@ uint8_t drawStat_UsedEnergy(uint8_t col, uint8_t row, uint8_t statValX) { return row; } -uint8_t drawStat_AverageEfficiency(uint8_t col, uint8_t row, uint8_t statValX, bool forceMetric) { +uint8_t drawStat_AverageEfficiency(uint8_t col, uint8_t row, uint8_t statValX, bool forceMetric) +{ char buff[15]; uint8_t buffOffset = 2; int32_t totalDistance = getTotalTravelDistance(); @@ -4723,7 +4803,8 @@ uint8_t drawStat_AverageEfficiency(uint8_t col, uint8_t row, uint8_t statValX, b return row; } -uint8_t drawStat_RXStats(uint8_t col, uint8_t row, uint8_t statValX) { +uint8_t drawStat_RXStats(uint8_t col, uint8_t row, uint8_t statValX) +{ char buff[20]; uint8_t multiValueXOffset = 0; @@ -4769,7 +4850,8 @@ uint8_t drawStat_RXStats(uint8_t col, uint8_t row, uint8_t statValX) { return row; } -uint8_t drawStat_GPS(uint8_t col, uint8_t row, uint8_t statValX) { +uint8_t drawStat_GPS(uint8_t col, uint8_t row, uint8_t statValX) +{ char buff[12]; displayWrite(osdDisplayPort, col, row, "MIN/MAX GPS SATS"); tfp_sprintf(buff, ": %u/%u", stats.min_sats, stats.max_sats); @@ -4778,7 +4860,8 @@ uint8_t drawStat_GPS(uint8_t col, uint8_t row, uint8_t statValX) { return row; } -uint8_t drawStat_ESCTemperature(uint8_t col, uint8_t row, uint8_t statValX) { +uint8_t drawStat_ESCTemperature(uint8_t col, uint8_t row, uint8_t statValX) +{ char buff[12]; displayWrite(osdDisplayPort, col, row, "MIN/MAX ESC TEMP"); tfp_sprintf(buff, ": %3d/%3d%c", @@ -4790,7 +4873,8 @@ uint8_t drawStat_ESCTemperature(uint8_t col, uint8_t row, uint8_t statValX) { return row; } -uint8_t drawStat_GForce(uint8_t col, uint8_t row, uint8_t statValX) { +uint8_t drawStat_GForce(uint8_t col, uint8_t row, uint8_t statValX) +{ char buff[12]; uint8_t multiValueXOffset = 0; @@ -4829,7 +4913,8 @@ uint8_t drawStat_GForce(uint8_t col, uint8_t row, uint8_t statValX) { return row; } -uint8_t drawStat_DisarmMethod(uint8_t col, uint8_t row, uint8_t statValX) { +uint8_t drawStat_DisarmMethod(uint8_t col, uint8_t row, uint8_t statValX) +{ const char * disarmReasonStr[DISARM_REASON_COUNT] = { "UNKNOWN", "TIMEOUT", "STICKS", "SWITCH", "SWITCH", "KILLSW", "FAILSAFE", "NAV SYS", "LANDING"}; displayWrite(osdDisplayPort, col, row, "DISARMED BY"); @@ -4892,6 +4977,9 @@ static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page) // Draw these if there is space space if (row < (osdDisplayPort->cols-3)) row = drawStat_GForce(statNameX, row, statValuesX); +#ifdef USE_STATS + if (row < (osdDisplayPort->cols-6) && statsConfig()->stats_enabled) row = drawStat_Stats(statNameX, row, statValuesX, false); +#endif } else { switch (page) { case 0: @@ -4914,25 +5002,26 @@ static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page) if (STATE(ESC_SENSOR_ENABLED)) row = drawStat_ESCTemperature(statNameX, row, statValuesX); row = drawStat_GForce(statNameX, row, statValuesX); // 2 rows if (osdConfig()->stats_show_metric_efficiency && osdIsNotMetric() && feature(FEATURE_CURRENT_METER) && feature(FEATURE_GPS)) row = drawStat_AverageEfficiency(statNameX, row, statValuesX, true); - //row = drawStat_FlightTime(statNameX, row, statValuesX); - //row = drawStat_FlightTime(statNameX, row, statValuesX); #ifdef USE_BLACKBOX #ifdef USE_SDCARD - if (feature(FEATURE_BLACKBOX)) { - char buff[12]; - displayWrite(osdDisplayPort, statNameX, row, "BLACKBOX FILE"); - - tfp_sprintf(buff, ": %u/%u", stats.min_sats, stats.max_sats); - - int32_t logNumber = blackboxGetLogNumber(); - if (logNumber >= 0) - tfp_sprintf(buff, ": %05ld ", logNumber); - else - strcat(buff, ": INVALID"); + if (feature(FEATURE_BLACKBOX)) { + char buff[12]; + displayWrite(osdDisplayPort, statNameX, row, "BLACKBOX FILE"); + + tfp_sprintf(buff, ": %u/%u", stats.min_sats, stats.max_sats); + + int32_t logNumber = blackboxGetLogNumber(); + if (logNumber >= 0) + tfp_sprintf(buff, ": %05ld ", logNumber); + else + strcat(buff, ": INVALID"); - displayWrite(osdDisplayPort, statValuesX, row++, buff); - } + displayWrite(osdDisplayPort, statValuesX, row++, buff); + } #endif +#endif +#ifdef USE_STATS + if (row < (osdDisplayPort->cols-6) && statsConfig()->stats_enabled) row = drawStat_Stats(statNameX, row, statValuesX, false); #endif break; From 014942a48d725c47d43e2f34ef0db6e074965d3a Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Sat, 17 Feb 2024 22:17:51 +0000 Subject: [PATCH 060/241] Corrected required remaining rows for stats check --- src/main/io/osd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 715f2d4eecf..a4767cd15d6 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -4978,7 +4978,7 @@ static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page) // Draw these if there is space space if (row < (osdDisplayPort->cols-3)) row = drawStat_GForce(statNameX, row, statValuesX); #ifdef USE_STATS - if (row < (osdDisplayPort->cols-6) && statsConfig()->stats_enabled) row = drawStat_Stats(statNameX, row, statValuesX, false); + if (row < (osdDisplayPort->cols-7) && statsConfig()->stats_enabled) row = drawStat_Stats(statNameX, row, statValuesX, false); #endif } else { switch (page) { @@ -5021,7 +5021,7 @@ static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page) #endif #endif #ifdef USE_STATS - if (row < (osdDisplayPort->cols-6) && statsConfig()->stats_enabled) row = drawStat_Stats(statNameX, row, statValuesX, false); + if (row < (osdDisplayPort->cols-7) && statsConfig()->stats_enabled) row = drawStat_Stats(statNameX, row, statValuesX, false); #endif break; From dd9e459131fa815dd1030f88e1f8caaa7cfc8645 Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Tue, 20 Feb 2024 08:12:24 +0000 Subject: [PATCH 061/241] Formatting changes - Removed blank spaces from data, to make it look neater - Current and Power are now on a single row --- src/main/io/osd.c | 269 +++++++++++++++++++++++++--------------------- 1 file changed, 148 insertions(+), 121 deletions(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index a4767cd15d6..dad011956d7 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -4272,7 +4272,7 @@ uint8_t drawStat_Stats(uint8_t statNameX, uint8_t row, uint8_t statValueX, bool if (isBootStats) tfp_sprintf(string_buffer, "%d:%02dH:M%c", (int)(tot_mins / 60), (int)(tot_mins % 60), '\0'); else - tfp_sprintf(string_buffer, ": %d:%02dH:M%c", (int)(tot_mins / 60), (int)(tot_mins % 60), '\0'); + tfp_sprintf(string_buffer, ": %d:%02d H:M%c", (int)(tot_mins / 60), (int)(tot_mins % 60), '\0'); displayWrite(osdDisplayPort, statValueX-(isBootStats ? 7 : 0), row, string_buffer); @@ -4634,34 +4634,29 @@ uint8_t drawStat_BatteryVoltage(uint8_t col, uint8_t row, uint8_t statValX) return row; } -uint8_t drawStat_MaximumCurrent(uint8_t col, uint8_t row, uint8_t statValX) +uint8_t drawStat_MaximumPowerAndCurrent(uint8_t col, uint8_t row, uint8_t statValX) { char buff[12]; - displayWrite(osdDisplayPort, col, row, "MAX CURRENT"); - tfp_sprintf(buff, ": "); - osdFormatCentiNumber(buff + 2, stats.max_current, 0, 2, 0, 3, false); - tfp_sprintf(buff + strlen(buff), "%c", SYM_AMP); - displayWrite(osdDisplayPort, statValX, row++, buff); - - return row; -} - -uint8_t drawStat_MaximumPower(uint8_t col, uint8_t row, uint8_t statValX) -{ - char buff[12]; - displayWrite(osdDisplayPort, col, row, "MAX POWER"); - tfp_sprintf(buff, ": "); - bool kiloWatt = osdFormatCentiNumber(buff + 2, stats.max_power, 1000, 2, 2, 3, false); - tfp_sprintf(buff + strlen(osdFormatTrimWhiteSpace(buff)), "%c", (char)(kiloWatt ? SYM_KILOWATT : SYM_WATT)); - displayWrite(osdDisplayPort, statValX, row++, buff); + char outBuff[12]; + tfp_sprintf(outBuff, ": "); + osdFormatCentiNumber(buff, stats.max_current, 0, 2, 0, 3, false); + strcat(outBuff, osdFormatTrimWhiteSpace(buff)); + strcat(outBuff, "/"); + bool kiloWatt = osdFormatCentiNumber(buff, stats.max_power, 1000, 2, 2, 3, false); + strcat(outBuff, osdFormatTrimWhiteSpace(buff)); + displayWrite(osdDisplayPort, statValX, row, outBuff); + + if (kiloWatt) + displayWrite(osdDisplayPort, col, row, "MAX AMPS/K WATTS"); + else + displayWrite(osdDisplayPort, col, row, "MAX AMPS/WATTS"); - return row; + return ++row; } uint8_t drawStat_UsedEnergy(uint8_t col, uint8_t row, uint8_t statValX) { char buff[12]; - uint8_t buffOffset = 0; if (osdDisplayIsHD()) displayWrite(osdDisplayPort, col, row, "USED ENERGY FLT/TOT"); @@ -4671,11 +4666,13 @@ uint8_t drawStat_UsedEnergy(uint8_t col, uint8_t row, uint8_t statValX) if (osdConfig()->stats_energy_unit == OSD_STATS_ENERGY_UNIT_MAH) { tfp_sprintf(buff + 2, "%d/%d%c", (int)(getMAhDrawn() - stats.flightStartMAh), (int)getMAhDrawn(), SYM_MAH); } else { - osdFormatCentiNumber(buff + 2, (getMWhDrawn() - stats.flightStartMWh) / 10, 0, 2, 0, 3, false); - tfp_sprintf(buff, "%s/", buff); - buffOffset = strlen(buff); - osdFormatCentiNumber(buff + buffOffset, getMWhDrawn() / 10, 0, 2, 0, 3, false); - tfp_sprintf(buff, "%s%c", buff, SYM_WH); + char preBuff[12]; + osdFormatCentiNumber(preBuff, (getMWhDrawn() - stats.flightStartMWh) / 10, 0, 2, 0, 3, false); + strcat(buff, osdFormatTrimWhiteSpace(preBuff)); + strcat(buff, "/"); + osdFormatCentiNumber(preBuff, getMWhDrawn() / 10, 0, 2, 0, 3, false); + strcat(buff, osdFormatTrimWhiteSpace(preBuff)); + tfp_sprintf(buff + strlen(buff), "%s%c", buff, SYM_WH); } displayWrite(osdDisplayPort, statValX, row++, buff); @@ -4685,7 +4682,7 @@ uint8_t drawStat_UsedEnergy(uint8_t col, uint8_t row, uint8_t statValX) uint8_t drawStat_AverageEfficiency(uint8_t col, uint8_t row, uint8_t statValX, bool forceMetric) { char buff[15]; - uint8_t buffOffset = 2; + char outBuff[15]; int32_t totalDistance = getTotalTravelDistance(); bool moreThanAh = false; bool efficiencyValid = totalDistance >= 10000; @@ -4695,7 +4692,7 @@ uint8_t drawStat_AverageEfficiency(uint8_t col, uint8_t row, uint8_t statValX, b else displayWrite(osdDisplayPort, col, row, "AV EFFICIENCY F/T"); - tfp_sprintf(buff, ": "); + tfp_sprintf(outBuff, ": "); uint8_t digits = 3U; // Total number of digits (including decimal point) #ifndef DISABLE_MSP_BF_COMPAT // IF BFCOMPAT is not supported, there's no need to check for it and change the values if (isBfCompatibleVideoSystem(osdConfig())) { @@ -4710,56 +4707,77 @@ uint8_t drawStat_AverageEfficiency(uint8_t col, uint8_t row, uint8_t statValX, b case OSD_UNIT_IMPERIAL: if (osdConfig()->stats_energy_unit == OSD_STATS_ENERGY_UNIT_MAH) { if (efficiencyValid) { - moreThanAh = osdFormatCentiNumber(buff + buffOffset, (int32_t)((getMAhDrawn() - stats.flightStartMAh) * 10000.0f * METERS_PER_MILE / totalDistance), 1000, 0, 2, digits, false); - strcat(buff, "/"); - buffOffset = strlen(buff); - moreThanAh = osdFormatCentiNumber(buff + buffOffset, (int32_t)(getMAhDrawn() * 10000.0f * METERS_PER_MILE / totalDistance), 1000, 0, 2, digits, false); - - if (!moreThanAh) { - tfp_sprintf(buff + strlen(buff), "%c%c", SYM_MAH_MI_0, SYM_MAH_MI_1); - } else { - tfp_sprintf(buff + strlen(buff), "%c", SYM_AH_MI); + moreThanAh = osdFormatCentiNumber(buff, (int32_t)((getMAhDrawn() - stats.flightStartMAh) * 10000.0f * METERS_PER_MILE / totalDistance), 1000, 0, 2, digits, false); + strcat(outBuff, osdFormatTrimWhiteSpace(buff)); + if (osdDisplayIsHD()) { + if (!moreThanAh) + tfp_sprintf(outBuff + strlen(outBuff), "%c%c", SYM_MAH_MI_0, SYM_MAH_MI_1); + else + tfp_sprintf(outBuff + strlen(outBuff), "%c", SYM_AH_MI); + + moreThanAh = false; } + + strcat(outBuff, "/"); + moreThanAh = moreThanAh || osdFormatCentiNumber(buff, (int32_t)(getMAhDrawn() * 10000.0f * METERS_PER_MILE / totalDistance), 1000, 0, 2, digits, false); + strcat(outBuff, osdFormatTrimWhiteSpace(buff)); + + if (!moreThanAh) + tfp_sprintf(outBuff + strlen(outBuff), "%c%c", SYM_MAH_MI_0, SYM_MAH_MI_1); + else + tfp_sprintf(outBuff + strlen(outBuff), "%c", SYM_AH_MI); } else { - tfp_sprintf(buff + buffOffset, "---/---%c%c", SYM_MAH_MI_0, SYM_MAH_MI_1); + tfp_sprintf(outBuff + strlen(outBuff), "---/---%c%c", SYM_MAH_MI_0, SYM_MAH_MI_1); } } else { if (efficiencyValid) { - osdFormatCentiNumber(buff + buffOffset, (int32_t)((getMWhDrawn() - stats.flightStartMWh) * 10.0f * METERS_PER_MILE / totalDistance), 0, 2, 0, digits, false); - strcat(buff, "/"); - buffOffset = strlen(buff); - osdFormatCentiNumber(buff + buffOffset, (int32_t)(getMWhDrawn() * 10.0f * METERS_PER_MILE / totalDistance), 0, 2, 0, digits, false); + osdFormatCentiNumber(buff, (int32_t)((getMWhDrawn() - stats.flightStartMWh) * 10.0f * METERS_PER_MILE / totalDistance), 0, 2, 0, digits, false); + strcat(outBuff, osdFormatTrimWhiteSpace(buff)); + strcat(outBuff, "/"); + osdFormatCentiNumber(buff + strlen(buff), (int32_t)(getMWhDrawn() * 10.0f * METERS_PER_MILE / totalDistance), 0, 2, 0, digits, false); + strcat(outBuff, osdFormatTrimWhiteSpace(buff)); } else { - strcat(buff, "---/---"); + strcat(outBuff, "---/---"); } - tfp_sprintf(buff + strlen(buff), "%c", SYM_WH_MI); + tfp_sprintf(outBuff + strlen(outBuff), "%c", SYM_WH_MI); } break; case OSD_UNIT_GA: if (osdConfig()->stats_energy_unit == OSD_STATS_ENERGY_UNIT_MAH) { if (efficiencyValid) { - moreThanAh = osdFormatCentiNumber(buff + buffOffset, (int32_t)((getMAhDrawn()-stats.flightStartMAh) * 10000.0f * METERS_PER_NAUTICALMILE / totalDistance), 1000, 0, 2, digits, false); - strcat(buff, "/"); - buffOffset = strlen(buff); - moreThanAh = osdFormatCentiNumber(buff + buffOffset, (int32_t)(getMAhDrawn() * 10000.0f * METERS_PER_NAUTICALMILE / totalDistance), 1000, 0, 2, digits, false); + moreThanAh = osdFormatCentiNumber(buff, (int32_t)((getMAhDrawn()-stats.flightStartMAh) * 10000.0f * METERS_PER_NAUTICALMILE / totalDistance), 1000, 0, 2, digits, false); + strcat(outBuff, osdFormatTrimWhiteSpace(buff)); + if (osdDisplayIsHD()) { + if (!moreThanAh) + tfp_sprintf(outBuff + strlen(outBuff), "%c%c", SYM_MAH_NM_0, SYM_MAH_NM_1); + else + tfp_sprintf(outBuff + strlen(outBuff), "%c", SYM_AH_NM); + + moreThanAh = false; + } + + strcat(outBuff, "/"); + moreThanAh = moreThanAh || osdFormatCentiNumber(buff, (int32_t)(getMAhDrawn() * 10000.0f * METERS_PER_NAUTICALMILE / totalDistance), 1000, 0, 2, digits, false); + strcat(outBuff, osdFormatTrimWhiteSpace(buff)); if (!moreThanAh) { - tfp_sprintf(buff + strlen(buff), "%c%c", SYM_MAH_NM_0, SYM_MAH_NM_1); + tfp_sprintf(outBuff + strlen(outBuff), "%c%c", SYM_MAH_NM_0, SYM_MAH_NM_1); } else { - tfp_sprintf(buff + strlen(buff), "%c", SYM_AH_NM); + tfp_sprintf(outBuff + strlen(outBuff), "%c", SYM_AH_NM); } } else { - tfp_sprintf(buff + buffOffset, "---/---%c%c", SYM_MAH_NM_0, SYM_MAH_NM_1); + tfp_sprintf(outBuff + strlen(outBuff), "---/---%c%c", SYM_MAH_NM_0, SYM_MAH_NM_1); } } else { if (efficiencyValid) { - osdFormatCentiNumber(buff + buffOffset, (int32_t)((getMWhDrawn()-stats.flightStartMWh) * 10.0f * METERS_PER_NAUTICALMILE / totalDistance), 0, 2, 0, digits, false); - strcat(buff, "/"); - buffOffset = strlen(buff); - osdFormatCentiNumber(buff + buffOffset, (int32_t)(getMWhDrawn() * 10.0f * METERS_PER_NAUTICALMILE / totalDistance), 0, 2, 0, digits, false); + osdFormatCentiNumber(buff, (int32_t)((getMWhDrawn()-stats.flightStartMWh) * 10.0f * METERS_PER_NAUTICALMILE / totalDistance), 0, 2, 0, digits, false); + strcat(outBuff, osdFormatTrimWhiteSpace(buff)); + strcat(outBuff, "/"); + osdFormatCentiNumber(buff, (int32_t)(getMWhDrawn() * 10.0f * METERS_PER_NAUTICALMILE / totalDistance), 0, 2, 0, digits, false); + strcat(outBuff, osdFormatTrimWhiteSpace(buff)); } else { - strcat(buff, "---/---"); + strcat(outBuff, "---/---"); } - tfp_sprintf(buff + strlen(buff), "%c", SYM_WH_NM); + tfp_sprintf(outBuff + strlen(outBuff), "%c", SYM_WH_NM); } break; case OSD_UNIT_METRIC_MPH: @@ -4772,33 +4790,44 @@ uint8_t drawStat_AverageEfficiency(uint8_t col, uint8_t row, uint8_t statValX, b if (forceMetric) { if (osdConfig()->stats_energy_unit == OSD_STATS_ENERGY_UNIT_MAH) { if (efficiencyValid) { - moreThanAh = osdFormatCentiNumber(buff + buffOffset, (int32_t)((getMAhDrawn() - stats.flightStartMAh) * 10000000.0f / totalDistance), 1000, 0, 2, digits, false); - strcat(buff, "/"); - buffOffset = strlen(buff); - moreThanAh = osdFormatCentiNumber(buff + buffOffset, (int32_t)(getMAhDrawn() * 10000000.0f / totalDistance), 1000, 0, 2, digits, false); + moreThanAh = osdFormatCentiNumber(buff, (int32_t)((getMAhDrawn() - stats.flightStartMAh) * 10000000.0f / totalDistance), 1000, 0, 2, digits, false); + strcat(outBuff, osdFormatTrimWhiteSpace(buff)); + if (osdDisplayIsHD()) { + if (!moreThanAh) + tfp_sprintf(outBuff + strlen(outBuff), "%c%c", SYM_MAH_KM_0, SYM_MAH_KM_1); + else + tfp_sprintf(outBuff + strlen(outBuff), "%c", SYM_AH_KM); + + moreThanAh = false; + } + + strcat(outBuff, "/"); + moreThanAh = moreThanAh || osdFormatCentiNumber(buff, (int32_t)(getMAhDrawn() * 10000000.0f / totalDistance), 1000, 0, 2, digits, false); + strcat(outBuff, osdFormatTrimWhiteSpace(buff)); if (!moreThanAh) { - tfp_sprintf(buff + strlen(buff), "%c%c", SYM_MAH_KM_0, SYM_MAH_KM_1); + tfp_sprintf(outBuff + strlen(outBuff), "%c%c", SYM_MAH_KM_0, SYM_MAH_KM_1); } else { - tfp_sprintf(buff + strlen(buff), "%c", SYM_AH_KM); + tfp_sprintf(outBuff + strlen(outBuff), "%c", SYM_AH_KM); } } else { - tfp_sprintf(buff + buffOffset, "---/---%c%c", SYM_MAH_KM_0, SYM_MAH_KM_1); + tfp_sprintf(outBuff + strlen(outBuff), "---/---%c%c", SYM_MAH_KM_0, SYM_MAH_KM_1); } } else { if (efficiencyValid) { - osdFormatCentiNumber(buff + buffOffset, (int32_t)((getMWhDrawn() - stats.flightStartMWh) * 10000.0f / totalDistance), 0, 2, 0, digits, false); - strcat(buff, "/"); - buffOffset = strlen(buff); - osdFormatCentiNumber(buff + buffOffset, (int32_t)(getMWhDrawn() * 10000.0f / totalDistance), 0, 2, 0, digits, false); + osdFormatCentiNumber(buff, (int32_t)((getMWhDrawn() - stats.flightStartMWh) * 10000.0f / totalDistance), 0, 2, 0, digits, false); + strcat(outBuff, osdFormatTrimWhiteSpace(buff)); + strcat(outBuff, "/"); + osdFormatCentiNumber(buff, (int32_t)(getMWhDrawn() * 10000.0f / totalDistance), 0, 2, 0, digits, false); + strcat(outBuff, osdFormatTrimWhiteSpace(buff)); } else { - strcat(buff, "---/---"); + strcat(outBuff, "---/---"); } - tfp_sprintf(buff + strlen(buff), "%c", SYM_WH_KM); + tfp_sprintf(outBuff + strlen(outBuff), "%c", SYM_WH_KM); } } - osdLeftAlignString(buff); - displayWrite(osdDisplayPort, statValX, row++, buff); + tfp_sprintf(outBuff + strlen(outBuff), "%c", '\0'); + displayWrite(osdDisplayPort, statValX, row++, outBuff); return row; } @@ -4876,7 +4905,7 @@ uint8_t drawStat_ESCTemperature(uint8_t col, uint8_t row, uint8_t statValX) uint8_t drawStat_GForce(uint8_t col, uint8_t row, uint8_t statValX) { char buff[12]; - uint8_t multiValueXOffset = 0; + char outBuff[12]; const float max_gforce = accGetMeasuredMaxG(); const acc_extremes_t *acc_extremes = accGetMeasuredExtremes(); @@ -4888,27 +4917,27 @@ uint8_t drawStat_GForce(uint8_t col, uint8_t row, uint8_t statValX) else displayWrite(osdDisplayPort, col, row, "MAX/MIN Z/MAX Z G-FORCE"); - tfp_sprintf(buff, ": "); - osdFormatCentiNumber(buff + 2, max_gforce * 100, 0, 2, 0, 3, false); + tfp_sprintf(outBuff, ": "); + osdFormatCentiNumber(buff, max_gforce * 100, 0, 2, 0, 3, false); if (!osdDisplayIsHD()) { - displayWrite(osdDisplayPort, statValX, row++, buff); + strcat(outBuff, osdFormatTrimWhiteSpace(buff)); + displayWrite(osdDisplayPort, statValX, row++, outBuff); displayWrite(osdDisplayPort, col, row, "MIN/MAX Z G-FORCE"); - memset(buff, '\0', strlen(buff)); - tfp_sprintf(buff, ": "); + memset(outBuff, '\0', strlen(outBuff)); + tfp_sprintf(outBuff, ": "); } else { - strcat(osdFormatTrimWhiteSpace(buff), "/"); + strcat(outBuff, osdFormatTrimWhiteSpace(buff)); + strcat(outBuff, "/"); } - multiValueXOffset = strlen(buff); - osdFormatCentiNumber(buff + multiValueXOffset, acc_extremes_min * 100, 0, 2, 0, 4, false); - osdLeftAlignString(buff); - strcat(osdFormatTrimWhiteSpace(buff), "/"); + osdFormatCentiNumber(buff, acc_extremes_min * 100, 0, 2, 0, 4, false); + strcat(outBuff, osdFormatTrimWhiteSpace(buff)); + strcat(outBuff, "/"); - multiValueXOffset = strlen(buff); - osdFormatCentiNumber(buff + multiValueXOffset, acc_extremes_max * 100, 0, 2, 0, 3, false); - osdLeftAlignString(buff); - displayWrite(osdDisplayPort, statValX, row++, buff); + osdFormatCentiNumber(buff, acc_extremes_max * 100, 0, 2, 0, 3, false); + strcat(outBuff, osdFormatTrimWhiteSpace(buff)); + displayWrite(osdDisplayPort, statValX, row++, outBuff); return row; } @@ -4959,49 +4988,47 @@ static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page) displayWrite(osdDisplayPort, (osdDisplayPort->cols - strlen(statsHeader[page + 1])) / 2, row++, statsHeader[page]); if (isSinglePageStatsCompatible) { - // Top 15 rows for most important stats. Max 19 rows - row = drawStat_FlightTime(statNameX, row, statValuesX); - row = drawStat_FlightDistance(statNameX, row, statValuesX); - if (feature(FEATURE_GPS)) row = drawStat_MaxDistanceFromHome(statNameX, row, statValuesX); - if (feature(FEATURE_GPS)) row = drawStat_Speed(statNameX, row, statValuesX); - row = drawStat_MaximumAltitude(statNameX, row, statValuesX); - row = drawStat_BatteryVoltage(statNameX, row, statValuesX); - if (feature(FEATURE_CURRENT_METER)) row = drawStat_MaximumCurrent(statNameX, row, statValuesX); - if (feature(FEATURE_CURRENT_METER)) row = drawStat_MaximumPower(statNameX, row, statValuesX); - if (feature(FEATURE_CURRENT_METER)) row = drawStat_UsedEnergy(statNameX, row, statValuesX); - if (feature(FEATURE_CURRENT_METER) && feature(FEATURE_GPS)) row = drawStat_AverageEfficiency(statNameX, row, statValuesX, false); - if (osdConfig()->stats_show_metric_efficiency && osdIsNotMetric() && feature(FEATURE_CURRENT_METER) && feature(FEATURE_GPS)) row = drawStat_AverageEfficiency(statNameX, row, statValuesX, true); - row = drawStat_RXStats(statNameX, row, statValuesX); - if (feature(FEATURE_GPS)) row = drawStat_GPS(statNameX, row, statValuesX); - if (STATE(ESC_SENSOR_ENABLED)) row = drawStat_ESCTemperature(statNameX, row, statValuesX); + // Top 15 rows for most important stats. Max 19 rows (WTF) + row = drawStat_FlightTime(statNameX, row, statValuesX); // 1 row + row = drawStat_FlightDistance(statNameX, row, statValuesX); // 1 row + if (feature(FEATURE_GPS)) row = drawStat_MaxDistanceFromHome(statNameX, row, statValuesX); // 1 row + if (feature(FEATURE_GPS)) row = drawStat_Speed(statNameX, row, statValuesX); // 1 row + row = drawStat_MaximumAltitude(statNameX, row, statValuesX); // 1 row + row = drawStat_BatteryVoltage(statNameX, row, statValuesX); // 1 row + if (feature(FEATURE_CURRENT_METER)) row = drawStat_MaximumPowerAndCurrent(statNameX, row, statValuesX); // 1 row + if (feature(FEATURE_CURRENT_METER)) row = drawStat_UsedEnergy(statNameX, row, statValuesX); // 1 row + if (feature(FEATURE_CURRENT_METER) && feature(FEATURE_GPS)) row = drawStat_AverageEfficiency(statNameX, row, statValuesX, false); // 1 row + if (osdConfig()->stats_show_metric_efficiency && osdIsNotMetric() && feature(FEATURE_CURRENT_METER) && feature(FEATURE_GPS)) row = drawStat_AverageEfficiency(statNameX, row, statValuesX, true); // 1 row + row = drawStat_RXStats(statNameX, row, statValuesX); // 1 row if non-CRSF else 2 rows + if (feature(FEATURE_GPS)) row = drawStat_GPS(statNameX, row, statValuesX); // 1 row + if (STATE(ESC_SENSOR_ENABLED)) row = drawStat_ESCTemperature(statNameX, row, statValuesX); // 1 row // Draw these if there is space space - if (row < (osdDisplayPort->cols-3)) row = drawStat_GForce(statNameX, row, statValuesX); + if (row < (osdDisplayPort->cols-3)) row = drawStat_GForce(statNameX, row, statValuesX); // 1 row HD or 2 rows SD #ifdef USE_STATS - if (row < (osdDisplayPort->cols-7) && statsConfig()->stats_enabled) row = drawStat_Stats(statNameX, row, statValuesX, false); + if (row < (osdDisplayPort->cols-7) && statsConfig()->stats_enabled) row = drawStat_Stats(statNameX, row, statValuesX, false); // 4 rows #endif } else { switch (page) { case 0: // Max 10 rows - row = drawStat_FlightTime(statNameX, row, statValuesX); - row = drawStat_FlightDistance(statNameX, row, statValuesX); - if (feature(FEATURE_GPS)) row = drawStat_MaxDistanceFromHome(statNameX, row, statValuesX); - if (feature(FEATURE_GPS)) row = drawStat_Speed(statNameX, row, statValuesX); - row = drawStat_MaximumAltitude(statNameX, row, statValuesX); - row = drawStat_BatteryVoltage(statNameX, row, statValuesX); - if (feature(FEATURE_CURRENT_METER)) row = drawStat_MaximumCurrent(statNameX, row, statValuesX); - if (feature(FEATURE_CURRENT_METER))row = drawStat_MaximumPower(statNameX, row, statValuesX); - if (feature(FEATURE_CURRENT_METER))row = drawStat_UsedEnergy(statNameX, row, statValuesX); - if (feature(FEATURE_CURRENT_METER) && feature(FEATURE_GPS)) row = drawStat_AverageEfficiency(statNameX, row, statValuesX, false); + row = drawStat_FlightTime(statNameX, row, statValuesX); // 1 row + row = drawStat_FlightDistance(statNameX, row, statValuesX); // 1 row + if (feature(FEATURE_GPS)) row = drawStat_MaxDistanceFromHome(statNameX, row, statValuesX); // 1 row + if (feature(FEATURE_GPS)) row = drawStat_Speed(statNameX, row, statValuesX); // 1 row + row = drawStat_MaximumAltitude(statNameX, row, statValuesX); // 1 row + row = drawStat_BatteryVoltage(statNameX, row, statValuesX); // 1 row + if (feature(FEATURE_CURRENT_METER)) row = drawStat_MaximumPowerAndCurrent(statNameX, row, statValuesX); // 1 row + if (feature(FEATURE_CURRENT_METER))row = drawStat_UsedEnergy(statNameX, row, statValuesX); // 1 row + if (feature(FEATURE_CURRENT_METER) && feature(FEATURE_GPS)) row = drawStat_AverageEfficiency(statNameX, row, statValuesX, false); // 1 row + if (feature(FEATURE_GPS))row = drawStat_GPS(statNameX, row, statValuesX); // 1 row break; case 1: // Max 10 rows - row = drawStat_RXStats(statNameX, row, statValuesX); // 2 rows - if (feature(FEATURE_GPS))row = drawStat_GPS(statNameX, row, statValuesX); - if (STATE(ESC_SENSOR_ENABLED)) row = drawStat_ESCTemperature(statNameX, row, statValuesX); - row = drawStat_GForce(statNameX, row, statValuesX); // 2 rows - if (osdConfig()->stats_show_metric_efficiency && osdIsNotMetric() && feature(FEATURE_CURRENT_METER) && feature(FEATURE_GPS)) row = drawStat_AverageEfficiency(statNameX, row, statValuesX, true); + row = drawStat_RXStats(statNameX, row, statValuesX); // 1 row if non-CRSF else 2 rows + if (STATE(ESC_SENSOR_ENABLED)) row = drawStat_ESCTemperature(statNameX, row, statValuesX); // 1 row + row = drawStat_GForce(statNameX, row, statValuesX); // 1 row HD or 2 rows SD + if (osdConfig()->stats_show_metric_efficiency && osdIsNotMetric() && feature(FEATURE_CURRENT_METER) && feature(FEATURE_GPS)) row = drawStat_AverageEfficiency(statNameX, row, statValuesX, true); // 1 row #ifdef USE_BLACKBOX #ifdef USE_SDCARD if (feature(FEATURE_BLACKBOX)) { @@ -5016,12 +5043,12 @@ static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page) else strcat(buff, ": INVALID"); - displayWrite(osdDisplayPort, statValuesX, row++, buff); + displayWrite(osdDisplayPort, statValuesX, row++, buff); // 1 row } #endif #endif #ifdef USE_STATS - if (row < (osdDisplayPort->cols-7) && statsConfig()->stats_enabled) row = drawStat_Stats(statNameX, row, statValuesX, false); + if (row < (osdDisplayPort->cols-7) && statsConfig()->stats_enabled) row = drawStat_Stats(statNameX, row, statValuesX, false); // 4 rows #endif break; From 5aa15a50e181d0dc9cff5cdc5ef297d0ef491477 Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Tue, 20 Feb 2024 08:13:39 +0000 Subject: [PATCH 062/241] Commented out currently unused function --- src/main/io/osd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index dad011956d7..33d125d5f37 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -254,6 +254,7 @@ bool osdIsNotMetric(void) { /* * Aligns text to the left side. Adds spaces at the end to keep string length unchanged. */ +/* -- Currently unused -- static void osdLeftAlignString(char *buff) { uint8_t sp = 0, ch = 0; @@ -261,7 +262,7 @@ static void osdLeftAlignString(char *buff) while (buff[sp] == ' ') sp++; for (ch = 0; ch < (len - sp); ch++) buff[ch] = buff[ch + sp]; for (sp = ch; sp < len; sp++) buff[sp] = ' '; -} +}*/ /* * This is a simplified distance conversion code that does not use any scaling From 8e32b44c02c3e8bcddb2fac16d846480a2bc4758 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=99=A8yc?= <89179705+YangChen1234@users.noreply.github.com> Date: Fri, 23 Feb 2024 19:06:22 +0800 Subject: [PATCH 063/241] Optimize the current meter scale and offset for AOCODARCF405AIO --- src/main/target/AOCODARCF405AIO/target.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/target/AOCODARCF405AIO/target.h b/src/main/target/AOCODARCF405AIO/target.h index a45205fbc5a..d732ebdd042 100644 --- a/src/main/target/AOCODARCF405AIO/target.h +++ b/src/main/target/AOCODARCF405AIO/target.h @@ -142,7 +142,8 @@ #define SERIALRX_UART SERIAL_PORT_USART2 #define DEFAULT_RX_TYPE RX_TYPE_SERIAL #define SERIALRX_PROVIDER SERIALRX_CRSF -#define CURRENT_METER_SCALE 500 +#define CURRENT_METER_SCALE 589 +#define CURRENT_METER_OFFSET -204 /*** Optical Flow & Lidar ***/ #define USE_RANGEFINDER From f60b301a281fa1f387e625c6c367d7c9cfe11d78 Mon Sep 17 00:00:00 2001 From: Roman Lut <11955117+RomanLut@users.noreply.github.com> Date: Wed, 28 Feb 2024 20:26:43 +0100 Subject: [PATCH 064/241] fixed "Set LED Pin PWM" functionality in programming framework --- src/main/programming/logic_condition.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/programming/logic_condition.c b/src/main/programming/logic_condition.c index b31b4e305d8..0871181e555 100644 --- a/src/main/programming/logic_condition.c +++ b/src/main/programming/logic_condition.c @@ -483,7 +483,7 @@ static int logicConditionCompute( } break; -#ifdef LED_PIN +#ifdef USE_LED_STRIP case LOGIC_CONDITION_LED_PIN_PWM: if (operandA >=0 && operandA <= 100) { ledPinStartPWM((uint8_t)operandA); From bf06412e15a1b36c6045de746b1df87baca0a052 Mon Sep 17 00:00:00 2001 From: Oleksandr Kubrak Date: Sat, 2 Mar 2024 17:47:22 +0100 Subject: [PATCH 065/241] Fix compiler existence checking in case if PATH contains tilde --- src/utils/compiler.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/compiler.rb b/src/utils/compiler.rb index 29b8f10418b..fe2868acd15 100644 --- a/src/utils/compiler.rb +++ b/src/utils/compiler.rb @@ -47,7 +47,7 @@ def initialize(use_host_gcc) dirs.each do |dir| p = File.join(dir, bin) ['', '.exe'].each do |suffix| - f = p + suffix + f = File.expand_path(p + suffix) if File.executable?(f) if @verbose puts "Found #{bin} at #{f}" From ae8192a59922eda2e629c4b1941c5ffbea0ff24e Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Sat, 2 Mar 2024 18:56:25 +0100 Subject: [PATCH 066/241] initial commit --- .../IFLIGHT_BLITZ_F722_X1/CMakeLists.txt | 3 + .../target/IFLIGHT_BLITZ_F722_X1/config.c | 27 +++ .../target/IFLIGHT_BLITZ_F722_X1/target.c | 37 ++++ .../target/IFLIGHT_BLITZ_F722_X1/target.h | 161 ++++++++++++++++++ 4 files changed, 228 insertions(+) create mode 100644 src/main/target/IFLIGHT_BLITZ_F722_X1/CMakeLists.txt create mode 100644 src/main/target/IFLIGHT_BLITZ_F722_X1/config.c create mode 100644 src/main/target/IFLIGHT_BLITZ_F722_X1/target.c create mode 100644 src/main/target/IFLIGHT_BLITZ_F722_X1/target.h diff --git a/src/main/target/IFLIGHT_BLITZ_F722_X1/CMakeLists.txt b/src/main/target/IFLIGHT_BLITZ_F722_X1/CMakeLists.txt new file mode 100644 index 00000000000..2d52bdb52e0 --- /dev/null +++ b/src/main/target/IFLIGHT_BLITZ_F722_X1/CMakeLists.txt @@ -0,0 +1,3 @@ +target_stm32f722xe(IFLIGHT_BLITZ_F722_X1) +target_stm32f722xe(IFLIGHT_BLITZ_F722_X1_OSD) + diff --git a/src/main/target/IFLIGHT_BLITZ_F722_X1/config.c b/src/main/target/IFLIGHT_BLITZ_F722_X1/config.c new file mode 100644 index 00000000000..77d259bbe94 --- /dev/null +++ b/src/main/target/IFLIGHT_BLITZ_F722_X1/config.c @@ -0,0 +1,27 @@ +/* + * 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/config_master.h" +#include "config/feature.h" + +void targetConfiguration(void) +{ + +} diff --git a/src/main/target/IFLIGHT_BLITZ_F722_X1/target.c b/src/main/target/IFLIGHT_BLITZ_F722_X1/target.c new file mode 100644 index 00000000000..5a20c88ff22 --- /dev/null +++ b/src/main/target/IFLIGHT_BLITZ_F722_X1/target.c @@ -0,0 +1,37 @@ +/* + * This file is part of INAV. + * + * INAV 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. + * + * INAV 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 INAV. If not, see . + */ + +#include +#include "platform.h" +#include "drivers/bus.h" +#include "drivers/io.h" +#include "drivers/pwm_mapping.h" +#include "drivers/timer.h" + +timerHardware_t timerHardware[] = { + DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 0), // S1 DMA1_S2_CH5 + DEF_TIM(TIM3, CH3, PB0, TIM_USE_OUTPUT_AUTO, 0, 0), // S2 DMA1_S7_CH5 + + DEF_TIM(TIM8, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 1), // S3 DMA2_S4_CH7 + DEF_TIM(TIM8, CH4, PC9, TIM_USE_OUTPUT_AUTO, 0, 0), // S4 DMA2_S7_CH7 + DEF_TIM(TIM4, CH1, PB6, TIM_USE_OUTPUT_AUTO, 0, 0), // S5 DMA1_S0_CH2 + DEF_TIM(TIM4, CH2, PB7, TIM_USE_OUTPUT_AUTO, 0, 0), // S6 DMA1_S3_CH2 + + DEF_TIM(TIM1, CH1, PA8, TIM_USE_LED, 0, 0), // WS2812B +}; + +const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]); diff --git a/src/main/target/IFLIGHT_BLITZ_F722_X1/target.h b/src/main/target/IFLIGHT_BLITZ_F722_X1/target.h new file mode 100644 index 00000000000..b5ddefbe481 --- /dev/null +++ b/src/main/target/IFLIGHT_BLITZ_F722_X1/target.h @@ -0,0 +1,161 @@ +/* + * This file is part of INAV. + * + * INAV 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. + * + * INAV 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 INAV. If not, see . + */ + + +#pragma once + +#define TARGET_BOARD_IDENTIFIER "I7X1" +#define USBD_PRODUCT_STRING "IFLIGHT_BLITZ_F722_X1" + +#define LED0 PC15 +#define BEEPER PC13 +#define BEEPER_INVERTED + +// *************** SPI1 Gyro & ACC ******************* +#define USE_SPI +#define USE_SPI_DEVICE_1 +#define SPI1_SCK_PIN PA5 +#define SPI1_MISO_PIN PA6 +#define SPI1_MOSI_PIN PA7 + +#define USE_IMU_BMI270 +#define IMU_BMI270_ALIGN CW90_DEG_FLIP +#define BMI270_CS_PIN PA4 +#define BMI270_SPI_BUS BUS_SPI1 + +// ICM42605 +#define USE_IMU_ICM42605 +#define IMU_ICM42605_ALIGN CW90_DEG_FLIP +#define ICM42605_SPI_BUS BUS_SPI1 +#define ICM42605_CS_PIN PA4 + +// *************** I2C /Baro/Mag ********************* +#define USE_I2C +#define USE_I2C_DEVICE_1 +#define I2C1_SCL PB8 +#define I2C1_SDA PB9 + +#define USE_I2C_DEVICE_2 +#define I2C2_SCL PB10 +#define I2C2_SDA PB11 + +#define USE_BARO +#define BARO_I2C_BUS BUS_I2C1 +#define USE_BARO_ALL + +#define USE_MAG +#define MAG_I2C_BUS BUS_I2C2 +#define USE_MAG_ALL + +#define TEMPERATURE_I2C_BUS BUS_I2C2 + +#define PITOT_I2C_BUS BUS_I2C2 + +#define RANGEFINDER_I2C_BUS BUS_I2C2 + +// *************** SPI2 OSD*********************** +#define USE_SPI_DEVICE_2 +#define SPI2_SCK_PIN PB13 +#define SPI2_MISO_PIN PB14 +#define SPI2_MOSI_PIN PB15 + +#define USE_OSD + +#ifdef IFLIGHT_BLITZ_F722_X1_OSD + #define USE_MAX7456 + #define MAX7456_SPI_BUS BUS_SPI2 + #define MAX7456_CS_PIN PB12 +#endif + +// *************** SPI3 Flash *********************** +#define USE_SPI_DEVICE_3 +#define SPI3_SCK_PIN PB3 +#define SPI3_MISO_PIN PB4 +#define SPI3_MOSI_PIN PB5 + +#define USE_FLASHFS + +#define USE_FLASH_W25N01G +#define W25N01G_SPI_BUS BUS_SPI3 +#define W25N01G_CS_PIN PA15 + +#define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT + +// *************** UART ***************************** +#define USE_VCP +#define USB_DETECT_PIN PB2 +#define USE_USB_DETECT + +#define USE_UART1 +#define UART1_RX_PIN PA10 +#define UART1_TX_PIN PA9 + +#define USE_UART2 +#define UART2_RX_PIN PA3 +#define UART2_TX_PIN PA2 + +#define USE_UART3 +#define UART3_RX_PIN PC11 +#define UART3_TX_PIN PC10 + +#define USE_UART4 +#define UART4_RX_PIN PA1 +#define UART4_TX_PIN PA0 + +#define USE_UART5 +#define UART5_RX_PIN PD2 +#define UART5_TX_PIN PC12 + +#define USE_UART6 +#define UART6_RX_PIN PC7 +#define UART6_TX_PIN PC6 + +#define SERIAL_PORT_COUNT 7 + +#define DEFAULT_RX_TYPE RX_TYPE_SERIAL +#define SERIALRX_PROVIDER SERIALRX_CRSF +#define SERIALRX_UART SERIAL_PORT_USART2 + +// *************** ADC ***************************** +#define USE_ADC +#define ADC_INSTANCE ADC1 +#define ADC1_DMA_STREAM DMA2_Stream0 + +#define ADC_CHANNEL_1_PIN PC2 +#define ADC_CHANNEL_2_PIN PC1 + +#define VBAT_ADC_CHANNEL ADC_CHN_1 +#define CURRENT_METER_ADC_CHANNEL ADC_CHN_2 + +// *************** LEDSTRIP ************************ +#define USE_LED_STRIP +#define WS2811_PIN PA8 + +#define DEFAULT_FEATURES (FEATURE_OSD | FEATURE_TELEMETRY | FEATURE_CURRENT_METER | FEATURE_VBAT | FEATURE_TX_PROF_SEL) +#define CURRENT_METER_SCALE 200 + +#define USE_SERIAL_4WAY_BLHELI_INTERFACE + +#define TARGET_IO_PORTA 0xffff +#define TARGET_IO_PORTB 0xffff +#define TARGET_IO_PORTC 0xffff +#define TARGET_IO_PORTD 0xffff + +#define MAX_PWM_OUTPUT_PORTS 7 +#define USE_DSHOT +#define USE_SERIALSHOT +#define USE_ESC_SENSOR \ No newline at end of file From ec4a1962b3ec510442e570b893394a060d022fc2 Mon Sep 17 00:00:00 2001 From: Roman Lut <11955117+RomanLut@users.noreply.github.com> Date: Wed, 28 Feb 2024 20:24:54 +0100 Subject: [PATCH 067/241] fixed led_pin_pwm programming framework functionality --- src/main/programming/logic_condition.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/programming/logic_condition.c b/src/main/programming/logic_condition.c index 1fa6cb0c7b8..8fcca4dabcd 100644 --- a/src/main/programming/logic_condition.c +++ b/src/main/programming/logic_condition.c @@ -476,8 +476,9 @@ static int logicConditionCompute( } break; -#ifdef LED_PIN +#ifdef USE_LED_STRIP case LOGIC_CONDITION_LED_PIN_PWM: + if (operandA >=0 && operandA <= 100) { ledPinStartPWM((uint8_t)operandA); } else { From 9a942a5e9735e5a00f3e12d7a28248623c305e00 Mon Sep 17 00:00:00 2001 From: breadoven <56191411+breadoven@users.noreply.github.com> Date: Sun, 3 Mar 2024 21:00:21 +0000 Subject: [PATCH 068/241] Update navigation.c --- src/main/navigation/navigation.c | 58 ++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/src/main/navigation/navigation.c b/src/main/navigation/navigation.c index a4a0224e7d2..46090ff24d0 100644 --- a/src/main/navigation/navigation.c +++ b/src/main/navigation/navigation.c @@ -4322,22 +4322,6 @@ static navigationFSMEvent_t selectNavEventFromBoxModeInput(void) } posControl.rthSanityChecker.rthSanityOK = true; - /* WP mission activation control: - * canActivateWaypoint & waypointWasActivated are used to prevent WP mission - * auto restarting after interruption by Manual or RTH modes. - * WP mode must be deselected before it can be reactivated again. */ - static bool waypointWasActivated = false; - const bool isWpMissionLoaded = isWaypointMissionValid(); - bool canActivateWaypoint = isWpMissionLoaded && !posControl.flags.wpMissionPlannerActive; // Block activation if using WP Mission Planner - - if (waypointWasActivated && !FLIGHT_MODE(NAV_WP_MODE)) { - canActivateWaypoint = false; - if (!IS_RC_MODE_ACTIVE(BOXNAVWP)) { - canActivateWaypoint = true; - waypointWasActivated = false; - } - } - /* Airplane specific modes */ if (STATE(AIRPLANE)) { // LAUNCH mode has priority over any other NAV mode @@ -4377,14 +4361,36 @@ static navigationFSMEvent_t selectNavEventFromBoxModeInput(void) return NAV_FSM_EVENT_SWITCH_TO_RTH; } - /* Pilot-triggered RTH, also fall-back for WP if there is no mission loaded. - * WP prevented from falling back to RTH if WP mission planner is active */ - const bool wpRthFallbackIsActive = IS_RC_MODE_ACTIVE(BOXNAVWP) && !isWpMissionLoaded && !posControl.flags.wpMissionPlannerActive; + /* WP mission activation control: + * canActivateWaypoint & waypointWasActivated are used to prevent WP mission + * auto restarting after interruption by Manual or RTH modes. + * WP mode must be deselected before it can be reactivated again + * WP Mode also inhibited when Mission Planner is active */ + static bool waypointWasActivated = false; + bool canActivateWaypoint = isWaypointMissionValid(); + bool wpRthFallbackIsActive = false; + + if (IS_RC_MODE_ACTIVE(BOXMANUAL) || posControl.flags.wpMissionPlannerActive) { + canActivateWaypoint = false; + } else { + if (waypointWasActivated && !FLIGHT_MODE(NAV_WP_MODE)) { + canActivateWaypoint = false; + + if (!IS_RC_MODE_ACTIVE(BOXNAVWP)) { + canActivateWaypoint = true; + waypointWasActivated = false; + } + } + + wpRthFallbackIsActive = IS_RC_MODE_ACTIVE(BOXNAVWP) && !canActivateWaypoint; + } + + /* Pilot-triggered RTH, also fall-back for WP if no mission is loaded. + * Check for isExecutingRTH to prevent switching our from RTH in case of a brief GPS loss + * Without this loss of any of the canActivateNavigation && canActivateAltHold + * will kick us out of RTH state machine via NAV_FSM_EVENT_SWITCH_TO_IDLE and will prevent any of the fall-back + * logic kicking in (waiting for GPS on airplanes, switch to emergency landing etc) */ if (IS_RC_MODE_ACTIVE(BOXNAVRTH) || wpRthFallbackIsActive) { - // Check for isExecutingRTH to prevent switching our from RTH in case of a brief GPS loss - // Without this loss of any of the canActivateNavigation && canActivateAltHold - // will kick us out of RTH state machine via NAV_FSM_EVENT_SWITCH_TO_IDLE and will prevent any of the fall-back - // logic kicking in (waiting for GPS on airplanes, switch to emergency landing etc) if (isExecutingRTH || (canActivateNavigation && canActivateAltHold && STATE(GPS_FIX_HOME))) { return NAV_FSM_EVENT_SWITCH_TO_RTH; } @@ -4398,11 +4404,11 @@ static navigationFSMEvent_t selectNavEventFromBoxModeInput(void) // Pilot-activated waypoint mission. Fall-back to RTH if no mission loaded. // Also check multimission mission change status before activating WP mode. #ifdef USE_MULTI_MISSION - if (updateWpMissionChange() && IS_RC_MODE_ACTIVE(BOXNAVWP) && canActivateWaypoint) { + if (updateWpMissionChange() && IS_RC_MODE_ACTIVE(BOXNAVWP)) { #else - if (IS_RC_MODE_ACTIVE(BOXNAVWP) && canActivateWaypoint) { + if (IS_RC_MODE_ACTIVE(BOXNAVWP)) { #endif - if (FLIGHT_MODE(NAV_WP_MODE) || (canActivateNavigation && canActivateAltHold && STATE(GPS_FIX_HOME))) { + if (FLIGHT_MODE(NAV_WP_MODE) || (canActivateWaypoint && canActivateNavigation && canActivateAltHold && STATE(GPS_FIX_HOME))) { waypointWasActivated = true; return NAV_FSM_EVENT_SWITCH_TO_WAYPOINT; } From e852b74fbdac0f4a035f43c9cdb697e3f4fa9d19 Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Tue, 5 Mar 2024 12:30:50 +0000 Subject: [PATCH 069/241] Show a timeout for in flight rearming If possible, this will show a countdown time for how long the pilot has to rearm in flight. This was a part of #9688, which wasn't working as expected. This part should work, and give the pilots useful information. Currently not tested. Will test in HITL, then in flight asap. --- src/main/fc/fc_core.c | 16 ++++++++++++-- src/main/fc/fc_core.h | 2 ++ src/main/io/osd.c | 49 ++++++++++++++++++++++++++++++------------- 3 files changed, 51 insertions(+), 16 deletions(-) diff --git a/src/main/fc/fc_core.c b/src/main/fc/fc_core.c index 0d0863760de..c51519927b2 100644 --- a/src/main/fc/fc_core.c +++ b/src/main/fc/fc_core.c @@ -507,6 +507,18 @@ bool emergencyArmingUpdate(bool armingSwitchIsOn, bool forceArm) return counter >= EMERGENCY_ARMING_MIN_ARM_COUNT; } +uint16_t emergencyInFlightRearmTimeMS(void) +{ + uint16_t rearmMS = 0; + + if (STATE(IN_FLIGHT_EMERG_REARM)) { + timeMs_t currentTimeMs = millis(); + rearmMS = (uint16_t)((US2MS(lastDisarmTimeUs) + EMERGENCY_INFLIGHT_REARM_TIME_WINDOW_MS) - currentTimeMs); + } + + return rearmMS; +} + bool emergInflightRearmEnabled(void) { /* Emergency rearm allowed within 5s timeout period after disarm if craft still flying */ @@ -880,7 +892,6 @@ static void applyThrottleTiltCompensation(void) void taskMainPidLoop(timeUs_t currentTimeUs) { - cycleTime = getTaskDeltaTime(TASK_SELF); dT = (float)cycleTime * 0.000001f; @@ -899,7 +910,8 @@ void taskMainPidLoop(timeUs_t currentTimeUs) } } - if (armTime > 1 * USECS_PER_SEC) { // reset in flight emerg rearm flag 1 sec after arming once it's served its purpose + if (armTime > 1 * USECS_PER_SEC) { + // reset in flight emerg rearm flag 1 sec after arming once it's served its purpose DISABLE_STATE(IN_FLIGHT_EMERG_REARM); } diff --git a/src/main/fc/fc_core.h b/src/main/fc/fc_core.h index c66a0050ba2..455e5b3849e 100644 --- a/src/main/fc/fc_core.h +++ b/src/main/fc/fc_core.h @@ -42,7 +42,9 @@ timeUs_t getLastDisarmTimeUs(void); void tryArm(void); disarmReason_t getDisarmReason(void); +uint16_t emergencyInFlightRearmTimeMS(void); bool emergencyArmingUpdate(bool armingSwitchIsOn, bool forceArm); +bool emergInflightRearmEnabled(void); bool areSensorsCalibrating(void); float getFlightTime(void); diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 7e67faef01f..0fccaffc5ef 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "platform.h" @@ -4560,6 +4561,17 @@ static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page) displayWrite(osdDisplayPort, statValuesX + multiValueLengthOffset, top++, buff); } + if (emergInflightRearmEnabled()) { + uint16_t rearmMs = emergencyInFlightRearmTimeMS(); + if (rearmMs > 0) { + char emReArmMsg[23]; + tfp_sprintf(emReArmMsg, "** REARM PERIOD: "); + tfp_sprintf(emReArmMsg + strlen(emReArmMsg), "%02d", (uint8_t)MS2S(rearmMs)); + strcat(emReArmMsg, " **\0"); + displayWrite(osdDisplayPort, statNameX, top++, OSD_MESSAGE_STR(emReArmMsg)); + } + } + if (savingSettings == true) { displayWrite(osdDisplayPort, statNameX, top++, OSD_MESSAGE_STR(OSD_MSG_SAVING_SETTNGS)); } else if (notify_settings_saved > 0) { @@ -4861,9 +4873,10 @@ static void osdRefresh(timeUs_t currentTimeUs) } bool statsSinglePageCompatible = (osdDisplayPort->rows >= OSD_STATS_SINGLE_PAGE_MIN_ROWS); - static uint8_t statsCurrentPage = 0; - static bool statsDisplayed = false; - static bool statsAutoPagingEnabled = true; + static uint8_t statsCurrentPage = 0; + static timeMs_t statsRefreshTime = 0; + static bool statsDisplayed = false; + static bool statsAutoPagingEnabled = true; // Detect arm/disarm if (armState != ARMING_FLAG(ARMED)) { @@ -4931,25 +4944,24 @@ static void osdRefresh(timeUs_t currentTimeUs) // Alternate screens for multi-page stats. // Also, refreshes screen at swap interval for single-page stats. if (OSD_ALTERNATING_CHOICES((osdConfig()->stats_page_auto_swap_time * 1000), 2)) { - if (statsCurrentPage == 0) { - osdShowStats(statsSinglePageCompatible, statsCurrentPage); + if (statsCurrentPage == 0) statsCurrentPage = 1; - } } else { - if (statsCurrentPage == 1) { - osdShowStats(statsSinglePageCompatible, statsCurrentPage); + if (statsCurrentPage == 1) statsCurrentPage = 0; - } } } else { // Process manual page change events for multi-page stats. - if (manualPageUpRequested) { - osdShowStats(statsSinglePageCompatible, 1); + if (manualPageUpRequested) statsCurrentPage = 1; - } else if (manualPageDownRequested) { - osdShowStats(statsSinglePageCompatible, 0); + else if (manualPageDownRequested) statsCurrentPage = 0; - } + } + + // Only refresh the stats every 1/4 of a second. + if (statsRefreshTime <= millis()) { + statsRefreshTime = millis() + 250; + osdShowStats(statsSinglePageCompatible, statsCurrentPage); } } @@ -5317,6 +5329,15 @@ textAttributes_t osdGetSystemMessage(char *buff, size_t buff_size, bool isCenter } } + uint16_t rearmMs = emergencyInFlightRearmTimeMS(); + if (rearmMs > 0) { + char emReArmMsg[23]; + tfp_sprintf(emReArmMsg, "** REARM PERIOD: "); + tfp_sprintf(emReArmMsg + strlen(emReArmMsg), "%02d", (uint8_t)MS2S(rearmMs)); + strcat(emReArmMsg, " **\0"); + messages[messageCount++] = OSD_MESSAGE_STR(emReArmMsg); + } + if (messageCount > 0) { message = messages[OSD_ALTERNATING_CHOICES(systemMessageCycleTime(messageCount, messages), messageCount)]; if (message == failsafeInfoMessage) { From 792983868ffb349c85f0e54084c25ce08874ca49 Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Wed, 6 Mar 2024 07:33:52 +0000 Subject: [PATCH 070/241] Only show rearm message when not saving If the save is happening, writing to EEPROM locks up the FC. This change will only show the rearm message if the FC is not currently saving. If rearm is available, the `** SETTINGS SAVED**` message will not appear, to maximise time for rearm. If rearm is not available. The save messages display as normal. --- src/main/io/osd.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 0fccaffc5ef..d8214474bf3 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -4561,19 +4561,16 @@ static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page) displayWrite(osdDisplayPort, statValuesX + multiValueLengthOffset, top++, buff); } - if (emergInflightRearmEnabled()) { - uint16_t rearmMs = emergencyInFlightRearmTimeMS(); - if (rearmMs > 0) { - char emReArmMsg[23]; - tfp_sprintf(emReArmMsg, "** REARM PERIOD: "); - tfp_sprintf(emReArmMsg + strlen(emReArmMsg), "%02d", (uint8_t)MS2S(rearmMs)); - strcat(emReArmMsg, " **\0"); - displayWrite(osdDisplayPort, statNameX, top++, OSD_MESSAGE_STR(emReArmMsg)); - } - } + uint16_t rearmMs = (emergInflightRearmEnabled()) ? emergencyInFlightRearmTimeMS() : 0; if (savingSettings == true) { displayWrite(osdDisplayPort, statNameX, top++, OSD_MESSAGE_STR(OSD_MSG_SAVING_SETTNGS)); + } else if (rearmMs > 0) { // Show rearming time if settings not actively being saved. Ignore the settings saved message if rearm available. + char emReArmMsg[23]; + tfp_sprintf(emReArmMsg, "** REARM PERIOD: "); + tfp_sprintf(emReArmMsg + strlen(emReArmMsg), "%02d", (uint8_t)MS2S(rearmMs)); + strcat(emReArmMsg, " **\0"); + displayWrite(osdDisplayPort, statNameX, top++, OSD_MESSAGE_STR(emReArmMsg)); } else if (notify_settings_saved > 0) { if (millis() > notify_settings_saved) { notify_settings_saved = 0; @@ -5318,9 +5315,16 @@ textAttributes_t osdGetSystemMessage(char *buff, size_t buff_size, bool isCenter } /* Messages that are shown regardless of Arming state */ + uint16_t rearmMs = (emergInflightRearmEnabled()) ? emergencyInFlightRearmTimeMS() : 0; if (savingSettings == true) { messages[messageCount++] = OSD_MESSAGE_STR(OSD_MSG_SAVING_SETTNGS); + } else if (rearmMs > 0) { // Show rearming time if settings not actively being saved. Ignore the settings saved message if rearm available. + char emReArmMsg[23]; + tfp_sprintf(emReArmMsg, "** REARM PERIOD: "); + tfp_sprintf(emReArmMsg + strlen(emReArmMsg), "%02d", (uint8_t)MS2S(rearmMs)); + strcat(emReArmMsg, " **\0"); + messages[messageCount++] = OSD_MESSAGE_STR(emReArmMsg); } else if (notify_settings_saved > 0) { if (millis() > notify_settings_saved) { notify_settings_saved = 0; @@ -5329,14 +5333,6 @@ textAttributes_t osdGetSystemMessage(char *buff, size_t buff_size, bool isCenter } } - uint16_t rearmMs = emergencyInFlightRearmTimeMS(); - if (rearmMs > 0) { - char emReArmMsg[23]; - tfp_sprintf(emReArmMsg, "** REARM PERIOD: "); - tfp_sprintf(emReArmMsg + strlen(emReArmMsg), "%02d", (uint8_t)MS2S(rearmMs)); - strcat(emReArmMsg, " **\0"); - messages[messageCount++] = OSD_MESSAGE_STR(emReArmMsg); - } if (messageCount > 0) { message = messages[OSD_ALTERNATING_CHOICES(systemMessageCycleTime(messageCount, messages), messageCount)]; From 230095b473f089a40821fa5c3c9b25e251d3f3ba Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Wed, 6 Mar 2024 09:11:47 +0100 Subject: [PATCH 071/241] Add PINIO support for IFLIGHT_BLITZ_F722_X1 --- src/main/target/IFLIGHT_BLITZ_F722_X1/config.c | 4 +++- src/main/target/IFLIGHT_BLITZ_F722_X1/target.h | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/target/IFLIGHT_BLITZ_F722_X1/config.c b/src/main/target/IFLIGHT_BLITZ_F722_X1/config.c index 77d259bbe94..b8796a0d2f3 100644 --- a/src/main/target/IFLIGHT_BLITZ_F722_X1/config.c +++ b/src/main/target/IFLIGHT_BLITZ_F722_X1/config.c @@ -20,8 +20,10 @@ #include "config/config_master.h" #include "config/feature.h" +#include "io/piniobox.h" void targetConfiguration(void) { - + pinioBoxConfigMutable()->permanentId[0] = BOX_PERMANENT_ID_USER1; + pinioBoxConfigMutable()->permanentId[1] = BOX_PERMANENT_ID_USER2; } diff --git a/src/main/target/IFLIGHT_BLITZ_F722_X1/target.h b/src/main/target/IFLIGHT_BLITZ_F722_X1/target.h index b5ddefbe481..03196254420 100644 --- a/src/main/target/IFLIGHT_BLITZ_F722_X1/target.h +++ b/src/main/target/IFLIGHT_BLITZ_F722_X1/target.h @@ -158,4 +158,10 @@ #define MAX_PWM_OUTPUT_PORTS 7 #define USE_DSHOT #define USE_SERIALSHOT -#define USE_ESC_SENSOR \ No newline at end of file +#define USE_ESC_SENSOR + +#define USE_PINIO +#define USE_PINIOBOX +#define PINIO1_PIN PC0 +#define PINIO1_FLAGS PINIO_FLAGS_INVERTED +#define PINIO2_PIN PC14 \ No newline at end of file From a287e88b687a64592b50291d9ecad63c8f7fa824 Mon Sep 17 00:00:00 2001 From: Marcelo Bezerra <23555060+mmosca@users.noreply.github.com> Date: Thu, 7 Mar 2024 11:19:16 +0100 Subject: [PATCH 072/241] Add temp units to DJI mapping --- src/main/io/displayport_msp_bf_compat.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/io/displayport_msp_bf_compat.c b/src/main/io/displayport_msp_bf_compat.c index dd120a2295d..7067ac140f5 100644 --- a/src/main/io/displayport_msp_bf_compat.c +++ b/src/main/io/displayport_msp_bf_compat.c @@ -293,13 +293,12 @@ uint8_t getBfCharacter(uint8_t ch, uint8_t page) case SYM_THR: return BF_SYM_THR; -/* case SYM_TEMP_F: - return BF_SYM_TEMP_F; + return BF_SYM_F; case SYM_TEMP_C: - return BF_SYM_TEMP_C; -*/ + return BF_SYM_C; + case SYM_BLANK: return BF_SYM_BLANK; /* From 93f98a089f3855752a287f40b5acc7f27e7289dc Mon Sep 17 00:00:00 2001 From: breadoven <56191411+breadoven@users.noreply.github.com> Date: Sun, 10 Mar 2024 23:55:10 +0000 Subject: [PATCH 073/241] update --- docs/Settings.md | 10 ++++++ src/main/cms/cms_menu_imu.c | 2 ++ src/main/fc/fc_msp.c | 44 +++++++++++++----------- src/main/fc/settings.yaml | 10 ++++-- src/main/navigation/navigation.c | 9 ++--- src/main/navigation/navigation.h | 5 +-- src/main/navigation/navigation_private.h | 3 +- 7 files changed, 54 insertions(+), 29 deletions(-) diff --git a/docs/Settings.md b/docs/Settings.md index 740a7d0914f..0efeaf8de15 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -2862,6 +2862,16 @@ Adjusts the deceleration response of fixed wing altitude control as the target a --- +### nav_fw_auto_climb_rate + +Maximum climb/descent rate that UAV is allowed to reach during navigation modes. [cm/s] + +| Default | Min | Max | +| --- | --- | --- | +| 500 | 10 | 2000 | + +--- + ### nav_fw_bank_angle Max roll angle when rolling / turning in GPS assisted modes, is also restrained by global max_angle_inclination_rll diff --git a/src/main/cms/cms_menu_imu.c b/src/main/cms/cms_menu_imu.c index 7612ec44181..45e9b34b94b 100644 --- a/src/main/cms/cms_menu_imu.c +++ b/src/main/cms/cms_menu_imu.c @@ -198,6 +198,8 @@ static const OSD_Entry cmsx_menuPidAltMagEntries[] = { OSD_LABEL_DATA_ENTRY("-- ALT&MAG --", profileIndexString), + OSD_SETTING_ENTRY("FW ALT RESPONSE", SETTING_NAV_FW_ALT_CONTROL_RESPONSE), + OTHER_PIDFF_ENTRY("ALT P", &cmsx_pidPosZ.P), OTHER_PIDFF_ENTRY("ALT I", &cmsx_pidPosZ.I), OTHER_PIDFF_ENTRY("ALT D", &cmsx_pidPosZ.D), diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index 2c3f40dfe45..5e9b498874c 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -1113,7 +1113,7 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF legacyLedConfig |= ledConfig->led_function << shiftCount; shiftCount += 4; legacyLedConfig |= (ledConfig->led_overlay & 0x3F) << (shiftCount); - shiftCount += 6; + shiftCount += 6; legacyLedConfig |= (ledConfig->led_color) << (shiftCount); shiftCount += 4; legacyLedConfig |= (ledConfig->led_direction) << (shiftCount); @@ -1340,9 +1340,9 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF case MSP_NAV_POSHOLD: sbufWriteU8(dst, navConfig()->general.flags.user_control_mode); sbufWriteU16(dst, navConfig()->general.max_auto_speed); - sbufWriteU16(dst, navConfig()->mc.max_auto_climb_rate); + sbufWriteU16(dst, mixerConfig()->platformType == PLATFORM_AIRPLANE ? navConfig()->fw.max_auto_climb_rate : navConfig()->mc.max_auto_climb_rate); sbufWriteU16(dst, navConfig()->general.max_manual_speed); - sbufWriteU16(dst, mixerConfig()->platformType != PLATFORM_AIRPLANE ? navConfig()->mc.max_manual_climb_rate:navConfig()->fw.max_manual_climb_rate); + sbufWriteU16(dst, mixerConfig()->platformType == PLATFORM_AIRPLANE ? navConfig()->fw.max_manual_climb_rate : navConfig()->mc.max_manual_climb_rate); sbufWriteU8(dst, navConfig()->mc.max_bank_angle); sbufWriteU8(dst, navConfig()->mc.althold_throttle_type); sbufWriteU16(dst, currentBatteryProfile->nav.mc.hover_throttle); @@ -1590,7 +1590,7 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF sbufWriteU8(dst, timerHardware[i].usageFlags); } break; - + case MSP2_INAV_MC_BRAKING: #ifdef USE_MR_BRAKING_MODE sbufWriteU16(dst, navConfig()->mc.braking_speed_threshold); @@ -2394,12 +2394,16 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) if (dataSize == 13) { navConfigMutable()->general.flags.user_control_mode = sbufReadU8(src); navConfigMutable()->general.max_auto_speed = sbufReadU16(src); - navConfigMutable()->mc.max_auto_climb_rate = sbufReadU16(src); + if (mixerConfig()->platformType == PLATFORM_AIRPLANE) { + navConfigMutable()->fw.max_auto_climb_rate = sbufReadU16(src); + } else { + navConfigMutable()->mc.max_auto_climb_rate = sbufReadU16(src); + } navConfigMutable()->general.max_manual_speed = sbufReadU16(src); - if (mixerConfig()->platformType != PLATFORM_AIRPLANE) { - navConfigMutable()->mc.max_manual_climb_rate = sbufReadU16(src); - }else{ + if (mixerConfig()->platformType == PLATFORM_AIRPLANE) { navConfigMutable()->fw.max_manual_climb_rate = sbufReadU16(src); + } else { + navConfigMutable()->mc.max_manual_climb_rate = sbufReadU16(src); } navConfigMutable()->mc.max_bank_angle = sbufReadU8(src); navConfigMutable()->mc.althold_throttle_type = sbufReadU8(src); @@ -2729,7 +2733,7 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) case MSP_SET_WP: if (dataSize == 21) { - + const uint8_t msp_wp_no = sbufReadU8(src); // get the waypoint number navWaypoint_t msp_wp; msp_wp.action = sbufReadU8(src); // action @@ -2943,7 +2947,7 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) ledConfig->led_position = legacyConfig & 0xFF; ledConfig->led_function = (legacyConfig >> 8) & 0xF; ledConfig->led_overlay = (legacyConfig >> 12) & 0x3F; - ledConfig->led_color = (legacyConfig >> 18) & 0xF; + ledConfig->led_color = (legacyConfig >> 18) & 0xF; ledConfig->led_direction = (legacyConfig >> 22) & 0x3F; ledConfig->led_params = (legacyConfig >> 28) & 0xF; @@ -3233,7 +3237,7 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) fwAutolandApproachConfigMutable(i)->approachAlt = sbufReadU32(src); fwAutolandApproachConfigMutable(i)->landAlt = sbufReadU32(src); fwAutolandApproachConfigMutable(i)->approachDirection = sbufReadU8(src); - + int16_t head1 = 0, head2 = 0; if (sbufReadI16Safe(&head1, src)) { fwAutolandApproachConfigMutable(i)->landApproachHeading1 = head1; @@ -3283,12 +3287,12 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) ((controlRateConfig_t*)currentControlRateProfile)->rateDynamics.correctionEnd = sbufReadU8(src); ((controlRateConfig_t*)currentControlRateProfile)->rateDynamics.weightCenter = sbufReadU8(src); ((controlRateConfig_t*)currentControlRateProfile)->rateDynamics.weightEnd = sbufReadU8(src); - + } else { return MSP_RESULT_ERROR; } - break; + break; #endif #ifdef USE_PROGRAMMING_FRAMEWORK @@ -3582,7 +3586,7 @@ void mspWriteSimulatorOSD(sbuf_t *dst) static uint8_t osdPos_x = 0; //indicate new format hitl 1.4.0 - sbufWriteU8(dst, 255); + sbufWriteU8(dst, 255); if (isOSDTypeSupportedBySimulator()) { @@ -3788,7 +3792,7 @@ bool mspFCProcessInOutCommand(uint16_t cmdMSP, sbuf_t *dst, sbuf_t *src, mspResu #ifdef USE_SIMULATOR case MSP_SIMULATOR: tmp_u8 = sbufReadU8(src); // Get the Simulator MSP version - + // Check the MSP version of simulator if (tmp_u8 != SIMULATOR_MSP_VERSION) { break; @@ -3883,7 +3887,7 @@ bool mspFCProcessInOutCommand(uint16_t cmdMSP, sbuf_t *dst, sbuf_t *src, mspResu } else { sbufAdvance(src, sizeof(uint16_t) * XYZ_AXIS_COUNT); } - + // Get the acceleration in 1G units acc.accADCf[X] = ((int16_t)sbufReadU16(src)) / 1000.0f; acc.accADCf[Y] = ((int16_t)sbufReadU16(src)) / 1000.0f; @@ -3891,7 +3895,7 @@ bool mspFCProcessInOutCommand(uint16_t cmdMSP, sbuf_t *dst, sbuf_t *src, mspResu acc.accVibeSq[X] = 0.0f; acc.accVibeSq[Y] = 0.0f; acc.accVibeSq[Z] = 0.0f; - + // Get the angular velocity in DPS gyro.gyroADCf[X] = ((int16_t)sbufReadU16(src)) / 16.0f; gyro.gyroADCf[Y] = ((int16_t)sbufReadU16(src)) / 16.0f; @@ -3922,7 +3926,7 @@ bool mspFCProcessInOutCommand(uint16_t cmdMSP, sbuf_t *dst, sbuf_t *src, mspResu simulatorData.airSpeed = sbufReadU16(src); } else { if (SIMULATOR_HAS_OPTION(HITL_EXTENDED_FLAGS)) { - sbufReadU16(src); + sbufReadU16(src); } } @@ -3997,8 +4001,8 @@ bool mspFCProcessInOutCommand(uint16_t cmdMSP, sbuf_t *dst, sbuf_t *src, mspResu *ret = MSP_RESULT_ERROR; } break; -#endif - +#endif + default: // Not handled return false; diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index 61b0c23bbe4..c215f402a7d 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -2334,7 +2334,7 @@ groups: field: w_z_surface_p min: 0 max: 100 - default_value: 3.5 + default_value: 3.5 - name: inav_w_z_surface_v field: w_z_surface_v min: 0 @@ -2801,6 +2801,12 @@ groups: field: fw.max_bank_angle min: 5 max: 80 + - name: nav_fw_auto_climb_rate + description: "Maximum climb/descent rate that UAV is allowed to reach during navigation modes. [cm/s]" + default_value: 500 + field: fw.max_auto_climb_rate + min: 10 + max: 2000 - name: nav_fw_manual_climb_rate description: "Maximum climb/descent rate firmware is allowed when processing pilot input for ALTHOLD control mode [cm/s]" default_value: 300 @@ -4143,7 +4149,7 @@ groups: type: navFwAutolandConfig_t headers: ["navigation/navigation.h"] condition: USE_FW_AUTOLAND - members: + members: - name: nav_fw_land_approach_length description: "Length of the final approach" default_value: 35000 diff --git a/src/main/navigation/navigation.c b/src/main/navigation/navigation.c index b721ee4817d..51047974ca8 100644 --- a/src/main/navigation/navigation.c +++ b/src/main/navigation/navigation.c @@ -204,6 +204,7 @@ PG_RESET_TEMPLATE(navConfig_t, navConfig, // Fixed wing .fw = { .max_bank_angle = SETTING_NAV_FW_BANK_ANGLE_DEFAULT, // degrees + .max_auto_climb_rate = SETTING_NAV_FW_AUTO_CLIMB_RATE_DEFAULT, // 5 m/s .max_manual_climb_rate = SETTING_NAV_FW_MANUAL_CLIMB_RATE_DEFAULT, // 3 m/s .max_climb_angle = SETTING_NAV_FW_CLIMB_ANGLE_DEFAULT, // degrees .max_dive_angle = SETTING_NAV_FW_DIVE_ANGLE_DEFAULT, // degrees @@ -1891,7 +1892,7 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_WAYPOINT_IN_PROGRESS(na (posControl.wpDistance - 0.1f * posControl.wpInitialDistance); } - if (fabsf(climbRate) >= navConfig()->general.max_auto_climb_rate) { + if (fabsf(climbRate) >= (STATE(AIRPLANE) ? navConfig()->fw.max_auto_climb_rate : navConfig()->mc.max_auto_climb_rate)) { climbRate = 0; } updateClimbRateToAltitudeController(climbRate, posControl.activeWaypoint.pos.z, ROC_TO_ALT_TARGET); @@ -2212,7 +2213,7 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_FW_LANDING_CLIMB_TO_LOI } if (ABS(getEstimatedActualPosition(Z) - posControl.fwLandState.landAproachAltAgl) < (navConfig()->general.waypoint_enforce_altitude > 0 ? navConfig()->general.waypoint_enforce_altitude : FW_LAND_LOITER_ALT_TOLERANCE)) { - updateClimbRateToAltitudeController(0, 0, ROC_TO_ALT_RESET); + updateClimbRateToAltitudeController(0, 0, ROC_TO_ALT_CURRENT); posControl.fwLandState.landState = FW_AUTOLAND_STATE_LOITER; return NAV_FSM_EVENT_SUCCESS; } @@ -3379,13 +3380,13 @@ float getDesiredClimbRate(float targetAltitude, timeDelta_t deltaMicros) { const bool emergLandingIsActive = navigationIsExecutingAnEmergencyLanding(); - float maxClimbRate = navConfig()->general.max_auto_climb_rate; + float maxClimbRate = STATE(MULTIROTOR) ? navConfig()->mc.max_auto_climb_rate : navConfig()->fw.max_auto_climb_rate; if (posControl.desiredState.climbRateDemand) { maxClimbRate = ABS(posControl.desiredState.climbRateDemand); } else if (emergLandingIsActive) { maxClimbRate = navConfig()->general.emerg_descent_rate; } else if (posControl.flags.isAdjustingAltitude) { - maxClimbRate = navConfig()->general.max_manual_climb_rate; + maxClimbRate = STATE(MULTIROTOR) ? navConfig()->mc.max_manual_climb_rate : navConfig()->fw.max_manual_climb_rate; } const float targetAltitudeError = targetAltitude - navGetCurrentActualPositionAndVelocity()->pos.z; diff --git a/src/main/navigation/navigation.h b/src/main/navigation/navigation.h index 84e5390d43e..d02a69d060c 100644 --- a/src/main/navigation/navigation.h +++ b/src/main/navigation/navigation.h @@ -265,7 +265,7 @@ typedef struct positionEstimationConfig_s { #ifdef USE_GPS_FIX_ESTIMATION uint8_t allow_gps_fix_estimation; -#endif +#endif } positionEstimationConfig_t; PG_DECLARE(positionEstimationConfig_t, positionEstimationConfig); @@ -329,7 +329,7 @@ typedef struct navConfig_s { struct { uint8_t max_bank_angle; // multicopter max banking angle (deg) - uint16_t max_auto_climb_rate; // max vertical speed limitation cm/sec + uint16_t max_auto_climb_rate; // max vertical speed limitation nav modes cm/sec uint16_t max_manual_climb_rate; // manual velocity control max vertical speed #ifdef USE_MR_BRAKING_MODE @@ -351,6 +351,7 @@ typedef struct navConfig_s { struct { uint8_t max_bank_angle; // Fixed wing max banking angle (deg) + uint16_t max_auto_climb_rate; // max vertical speed limitation nav modes cm/sec uint16_t max_manual_climb_rate; // manual velocity control max vertical speed uint8_t max_climb_angle; // Fixed wing max banking angle (deg) uint8_t max_dive_angle; // Fixed wing max banking angle (deg) diff --git a/src/main/navigation/navigation_private.h b/src/main/navigation/navigation_private.h index f0d6a5c7068..95953c948cf 100644 --- a/src/main/navigation/navigation_private.h +++ b/src/main/navigation/navigation_private.h @@ -288,7 +288,7 @@ typedef enum { NAV_STATE_CRUISE_INITIALIZE, NAV_STATE_CRUISE_IN_PROGRESS, NAV_STATE_CRUISE_ADJUSTING, - + NAV_STATE_FW_LANDING_CLIMB_TO_LOITER, NAV_STATE_FW_LANDING_LOITER, NAV_STATE_FW_LANDING_APPROACH, @@ -462,6 +462,7 @@ typedef struct { #endif navWaypointPosition_t activeWaypoint; // Local position, current bearing and turn angle to next WP, filled on waypoint activation int8_t activeWaypointIndex; + float wpInitialAltitude; // Altitude at start of WP float wpInitialDistance; // Distance when starting flight to WP float wpDistance; // Distance to active WP timeMs_t wpReachedTime; // Time the waypoint was reached From bc45aa74ff898b2dabe12d9bd824c9bad907f8cb Mon Sep 17 00:00:00 2001 From: Jonathan Hudson Date: Mon, 11 Mar 2024 11:28:51 +0000 Subject: [PATCH 074/241] fix cygwin/sitl build with cmake 3.28.3 (#9787) (#9788) --- cmake/sitl.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/sitl.cmake b/cmake/sitl.cmake index 78697f98a9d..ee43aa9a93a 100644 --- a/cmake/sitl.cmake +++ b/cmake/sitl.cmake @@ -34,7 +34,7 @@ set(SITL_LINK_OPTIONS -Wl,-L${STM32_LINKER_DIR} ) -if(${WIN32} OR ${CYGWIN}) +if(${CYGWIN}) set(SITL_LINK_OPTIONS ${SITL_LINK_OPTIONS} "-static-libgcc") endif() @@ -131,7 +131,7 @@ function (target_sitl name) target_link_options(${exe_target} PRIVATE -T${script_path}) endif() - if(${WIN32} OR ${CYGWIN}) + if(${CYGWIN}) set(exe_filename ${CMAKE_BINARY_DIR}/${binary_name}.exe) else() set(exe_filename ${CMAKE_BINARY_DIR}/${binary_name}) From a29d0a464b8d7ec571f0543701fd6eb8130cad13 Mon Sep 17 00:00:00 2001 From: breadoven <56191411+breadoven@users.noreply.github.com> Date: Mon, 11 Mar 2024 12:03:57 +0000 Subject: [PATCH 075/241] Update sitl.cmake --- cmake/sitl.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/sitl.cmake b/cmake/sitl.cmake index 78697f98a9d..ee43aa9a93a 100644 --- a/cmake/sitl.cmake +++ b/cmake/sitl.cmake @@ -34,7 +34,7 @@ set(SITL_LINK_OPTIONS -Wl,-L${STM32_LINKER_DIR} ) -if(${WIN32} OR ${CYGWIN}) +if(${CYGWIN}) set(SITL_LINK_OPTIONS ${SITL_LINK_OPTIONS} "-static-libgcc") endif() @@ -131,7 +131,7 @@ function (target_sitl name) target_link_options(${exe_target} PRIVATE -T${script_path}) endif() - if(${WIN32} OR ${CYGWIN}) + if(${CYGWIN}) set(exe_filename ${CMAKE_BINARY_DIR}/${binary_name}.exe) else() set(exe_filename ${CMAKE_BINARY_DIR}/${binary_name}) From 2fa82a33e794febb575be8981e08885bacb9ec0a Mon Sep 17 00:00:00 2001 From: Scavanger Date: Wed, 13 Mar 2024 17:01:49 -0300 Subject: [PATCH 076/241] 7.1-RC1-Autoland-Fix --- src/main/fc/runtime_config.h | 1 + src/main/flight/failsafe.c | 4 + src/main/flight/pid.c | 2 +- src/main/io/osd.c | 8 +- src/main/io/osd_dji_hd.c | 4 + src/main/navigation/navigation.c | 94 +++++++++++++--------- src/main/navigation/navigation.h | 1 - src/main/navigation/navigation_fixedwing.c | 12 +-- src/main/programming/logic_condition.c | 2 +- src/main/telemetry/crsf.c | 5 ++ src/main/telemetry/ltm.c | 5 ++ 11 files changed, 87 insertions(+), 51 deletions(-) diff --git a/src/main/fc/runtime_config.h b/src/main/fc/runtime_config.h index ed5caf49548..8772c090e04 100644 --- a/src/main/fc/runtime_config.h +++ b/src/main/fc/runtime_config.h @@ -105,6 +105,7 @@ typedef enum { TURTLE_MODE = (1 << 15), SOARING_MODE = (1 << 16), ANGLEHOLD_MODE = (1 << 17), + NAV_FW_AUTOLAND = (1 << 18), } flightModeFlags_e; extern uint32_t flightModeFlags; diff --git a/src/main/flight/failsafe.c b/src/main/flight/failsafe.c index 36f4d86f8e2..9f60dd83a36 100644 --- a/src/main/flight/failsafe.c +++ b/src/main/flight/failsafe.c @@ -239,6 +239,10 @@ static void failsafeActivate(failsafePhase_e newPhase) ENABLE_FLIGHT_MODE(FAILSAFE_MODE); failsafeState.landingShouldBeFinishedAt = millis() + failsafeConfig()->failsafe_off_delay * MILLIS_PER_TENTH_SECOND; +#ifdef USE_FW_AUTOLAND + posControl.fwLandState.landAborted = false; +#endif + failsafeState.events++; } diff --git a/src/main/flight/pid.c b/src/main/flight/pid.c index d913802d559..3da150e39dc 100644 --- a/src/main/flight/pid.c +++ b/src/main/flight/pid.c @@ -594,7 +594,7 @@ static float computePidLevelTarget(flight_dynamics_index_t axis) { // Automatically pitch down if the throttle is manually controlled and reduced bellow cruise throttle #ifdef USE_FW_AUTOLAND - if ((axis == FD_PITCH) && STATE(AIRPLANE) && FLIGHT_MODE(ANGLE_MODE) && !navigationIsControllingThrottle() && !isFwLandInProgess()) { + if ((axis == FD_PITCH) && STATE(AIRPLANE) && FLIGHT_MODE(ANGLE_MODE) && !navigationIsControllingThrottle() && !FLIGHT_MODE(NAV_FW_AUTOLAND)) { #else if ((axis == FD_PITCH) && STATE(AIRPLANE) && FLIGHT_MODE(ANGLE_MODE) && !navigationIsControllingThrottle()) { #endif diff --git a/src/main/io/osd.c b/src/main/io/osd.c index d8214474bf3..201f3efb7b8 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -986,7 +986,7 @@ static const char * osdFailsafePhaseMessage(void) static const char * osdFailsafeInfoMessage(void) { - if (failsafeIsReceivingRxData()) { + if (failsafeIsReceivingRxData() && !FLIGHT_MODE(NAV_FW_AUTOLAND)) { // User must move sticks to exit FS mode return OSD_MESSAGE_STR(OSD_MSG_MOVE_EXIT_FS); } @@ -2278,7 +2278,7 @@ static bool osdDrawSingleElement(uint8_t item) { char *p = "ACRO"; #ifdef USE_FW_AUTOLAND - if (isFwLandInProgess()) + if (FLIGHT_MODE(NAV_FW_AUTOLAND)) p = "LAND"; else #endif @@ -5151,7 +5151,7 @@ textAttributes_t osdGetSystemMessage(char *buff, size_t buff_size, bool isCenter if (ARMING_FLAG(ARMED)) { #ifdef USE_FW_AUTOLAND - if (FLIGHT_MODE(FAILSAFE_MODE) || FLIGHT_MODE(NAV_RTH_MODE) || FLIGHT_MODE(NAV_WP_MODE) || navigationIsExecutingAnEmergencyLanding() || isFwLandInProgess()) { + if (FLIGHT_MODE(FAILSAFE_MODE) || FLIGHT_MODE(NAV_RTH_MODE) || FLIGHT_MODE(NAV_WP_MODE) || navigationIsExecutingAnEmergencyLanding() || FLIGHT_MODE(NAV_FW_AUTOLAND)) { if (isWaypointMissionRTHActive() && !posControl.fwLandState.landWp) { #else if (FLIGHT_MODE(FAILSAFE_MODE) || FLIGHT_MODE(NAV_RTH_MODE) || FLIGHT_MODE(NAV_WP_MODE) || navigationIsExecutingAnEmergencyLanding()) { @@ -5192,7 +5192,7 @@ textAttributes_t osdGetSystemMessage(char *buff, size_t buff_size, bool isCenter #ifdef USE_FW_AUTOLAND if (canFwLandCanceld()) { messages[messageCount++] = OSD_MESSAGE_STR(OSD_MSG_MOVE_STICKS); - } else if (!isFwLandInProgess()) { + } else if (!FLIGHT_MODE(NAV_FW_AUTOLAND)) { #endif const char *navStateMessage = navigationStateMessage(); if (navStateMessage) { diff --git a/src/main/io/osd_dji_hd.c b/src/main/io/osd_dji_hd.c index c040b7b762f..8edf8288d03 100644 --- a/src/main/io/osd_dji_hd.c +++ b/src/main/io/osd_dji_hd.c @@ -1059,6 +1059,10 @@ static bool djiFormatMessages(char *buff) if (FLIGHT_MODE(MANUAL_MODE)) { messages[messageCount++] = "(MANUAL)"; } + + if (FLIGHT_MODE(NAV_FW_AUTOLAND)) { + messages[messageCount++] = "(LAND)"; + } } } // Pick one of the available messages. Each message lasts diff --git a/src/main/navigation/navigation.c b/src/main/navigation/navigation.c index 46090ff24d0..9e81024c3af 100644 --- a/src/main/navigation/navigation.c +++ b/src/main/navigation/navigation.c @@ -64,6 +64,7 @@ #include "sensors/boardalignment.h" #include "sensors/battery.h" #include "sensors/gyro.h" +#include "sensors/diagnostics.h" #include "programming/global_variables.h" #include "sensors/rangefinder.h" @@ -1045,13 +1046,14 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { } }, +/** Advanced Fixed Wing Autoland **/ #ifdef USE_FW_AUTOLAND [NAV_STATE_FW_LANDING_CLIMB_TO_LOITER] = { .persistentId = NAV_PERSISTENT_ID_FW_LANDING_CLIMB_TO_LOITER, .onEntry = navOnEnteringState_NAV_STATE_FW_LANDING_CLIMB_TO_LOITER, .timeoutMs = 10, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_RTH, - .mapToFlightModes = NAV_RTH_MODE | NAV_ALTHOLD_MODE, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_REQUIRE_ANGLE | NAV_AUTO_RTH, + .mapToFlightModes = NAV_FW_AUTOLAND, .mwState = MW_NAV_STATE_LAND_IN_PROGRESS, .mwError = MW_NAV_ERROR_NONE, .onEvent = { @@ -1071,8 +1073,8 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_FW_LANDING_LOITER, .onEntry = navOnEnteringState_NAV_STATE_FW_LANDING_LOITER, .timeoutMs = 10, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_RTH, - .mapToFlightModes = NAV_RTH_MODE | NAV_ALTHOLD_MODE, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_REQUIRE_ANGLE | NAV_AUTO_RTH, + .mapToFlightModes = NAV_FW_AUTOLAND, .mwState = MW_NAV_STATE_LAND_IN_PROGRESS, .mwError = MW_NAV_ERROR_NONE, .onEvent = { @@ -1092,8 +1094,8 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_FW_LANDING_APPROACH, .onEntry = navOnEnteringState_NAV_STATE_FW_LANDING_APPROACH, .timeoutMs = 10, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_WP, - .mapToFlightModes = NAV_WP_MODE | NAV_ALTHOLD_MODE, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_REQUIRE_ANGLE | NAV_AUTO_WP, + .mapToFlightModes = NAV_FW_AUTOLAND, .mwState = MW_NAV_STATE_LAND_IN_PROGRESS, .mwError = MW_NAV_ERROR_NONE, .onEvent = { @@ -1114,7 +1116,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .onEntry = navOnEnteringState_NAV_STATE_FW_LANDING_GLIDE, .timeoutMs = 10, .stateFlags = NAV_CTL_POS | NAV_CTL_YAW | NAV_REQUIRE_ANGLE | NAV_RC_POS | NAV_RC_YAW, - .mapToFlightModes = NAV_COURSE_HOLD_MODE, + .mapToFlightModes = NAV_FW_AUTOLAND, .mwState = MW_NAV_STATE_LAND_IN_PROGRESS, .mwError = MW_NAV_ERROR_NONE, .onEvent = { @@ -1135,7 +1137,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .onEntry = navOnEnteringState_NAV_STATE_FW_LANDING_FLARE, .timeoutMs = 10, .stateFlags = NAV_CTL_POS | NAV_CTL_YAW | NAV_REQUIRE_ANGLE | NAV_RC_POS | NAV_RC_YAW, - .mapToFlightModes = NAV_COURSE_HOLD_MODE, + .mapToFlightModes = NAV_FW_AUTOLAND, .mwState = MW_NAV_STATE_LAND_IN_PROGRESS, .mwError = MW_NAV_ERROR_NONE, .onEvent = { @@ -1148,8 +1150,8 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_FW_LANDING_ABORT, .onEntry = navOnEnteringState_NAV_STATE_FW_LANDING_ABORT, .timeoutMs = 10, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_RTH | NAV_RC_POS | NAV_RC_YAW, - .mapToFlightModes = NAV_WP_MODE | NAV_ALTHOLD_MODE, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_REQUIRE_ANGLE | NAV_AUTO_RTH | NAV_RC_POS | NAV_RC_YAW, + .mapToFlightModes = NAV_FW_AUTOLAND, .mwState = MW_NAV_STATE_LAND_IN_PROGRESS, .mwError = MW_NAV_ERROR_NONE, .onEvent = { @@ -1711,7 +1713,7 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_LANDING(navigationF /* If position sensors unavailable - land immediately (wait for timeout on GPS) * Continue to check for RTH sanity during landing */ - if (posControl.flags.estHeadingStatus == EST_NONE || checkForPositionSensorTimeout() || !validateRTHSanityChecker()) { + if (posControl.flags.estHeadingStatus == EST_NONE || checkForPositionSensorTimeout() || (previousState != NAV_STATE_WAYPOINT_REACHED && !validateRTHSanityChecker())) { return NAV_FSM_EVENT_SWITCH_TO_EMERGENCY_LANDING; } @@ -1721,7 +1723,7 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_LANDING(navigationF #ifdef USE_FW_AUTOLAND if (STATE(AIRPLANE)) { - int8_t missionIdx = -1, shIdx = -1, missionFwLandConfigStartIdx = 8; + int8_t missionIdx = -1, shIdx = -1, missionFwLandConfigStartIdx = 8, approachSettingIdx = -1; #ifdef USE_MULTI_MISSION missionIdx = posControl.loadedMultiMissionIndex - 1; #endif @@ -1730,18 +1732,23 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_LANDING(navigationF shIdx = posControl.safehomeState.index; missionFwLandConfigStartIdx = MAX_SAFE_HOMES; #endif - if (!posControl.fwLandState.landAborted && (shIdx >= 0 || missionIdx >= 0) && (fwAutolandApproachConfig(shIdx)->landApproachHeading1 != 0 || fwAutolandApproachConfig(shIdx)->landApproachHeading2 != 0)) { + if (previousState == NAV_STATE_WAYPOINT_REACHED && missionIdx >= 0) { + approachSettingIdx = missionFwLandConfigStartIdx + missionIdx; + } else if (shIdx >= 0) { + approachSettingIdx = shIdx; + } + + if (!posControl.fwLandState.landAborted && approachSettingIdx >= 0 && (fwAutolandApproachConfig(approachSettingIdx)->landApproachHeading1 != 0 || fwAutolandApproachConfig(approachSettingIdx)->landApproachHeading2 != 0)) { if (previousState == NAV_STATE_WAYPOINT_REACHED) { posControl.fwLandState.landPos = posControl.activeWaypoint.pos; - posControl.fwLandState.approachSettingIdx = missionFwLandConfigStartIdx + missionIdx; posControl.fwLandState.landWp = true; } else { posControl.fwLandState.landPos = posControl.safehomeState.nearestSafeHome; - posControl.fwLandState.approachSettingIdx = shIdx; posControl.fwLandState.landWp = false; } + posControl.fwLandState.approachSettingIdx = approachSettingIdx; posControl.fwLandState.landAltAgl = fwAutolandApproachConfig(posControl.fwLandState.approachSettingIdx)->isSeaLevelRef ? fwAutolandApproachConfig(posControl.fwLandState.approachSettingIdx)->landAlt - GPS_home.alt : fwAutolandApproachConfig(posControl.fwLandState.approachSettingIdx)->landAlt; posControl.fwLandState.landAproachAltAgl = fwAutolandApproachConfig(posControl.fwLandState.approachSettingIdx)->isSeaLevelRef ? fwAutolandApproachConfig(posControl.fwLandState.approachSettingIdx)->approachAlt - GPS_home.alt : fwAutolandApproachConfig(posControl.fwLandState.approachSettingIdx)->approachAlt; return NAV_FSM_EVENT_SWITCH_TO_NAV_STATE_FW_LANDING; @@ -1813,6 +1820,12 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_WAYPOINT_INITIALIZE(nav resetPositionController(); resetAltitudeController(false); // Make sure surface tracking is not enabled - WP uses global altitude, not AGL +#ifdef USE_FW_AUTOLAND + if (previousState != NAV_STATE_FW_LANDING_ABORT) { + posControl.fwLandState.landAborted = false; + } +#endif + if (posControl.activeWaypointIndex == posControl.startWpIndex || posControl.wpMissionRestart) { /* Use p3 as the volatile jump counter, allowing embedded, rearmed jumps Using p3 minimises the risk of saving an invalid counter if a mission is aborted */ @@ -2022,11 +2035,20 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_WAYPOINT_RTH_LAND(navig { UNUSED(previousState); +#ifdef USE_FW_AUTOLAND + if (posControl.fwLandState.landAborted) { + return NAV_FSM_EVENT_SWITCH_TO_WAYPOINT_FINISHED; + } +#endif + const navigationFSMEvent_t landEvent = navOnEnteringState_NAV_STATE_RTH_LANDING(previousState); +#ifdef USE_FW_AUTOLAND if (landEvent == NAV_FSM_EVENT_SWITCH_TO_NAV_STATE_FW_LANDING) { return NAV_FSM_EVENT_SWITCH_TO_NAV_STATE_FW_LANDING; - } else if (landEvent == NAV_FSM_EVENT_SWITCH_TO_RTH_HOVER_ABOVE_HOME) { + } else +#endif + if (landEvent == NAV_FSM_EVENT_SWITCH_TO_RTH_HOVER_ABOVE_HOME) { return NAV_FSM_EVENT_SWITCH_TO_WAYPOINT_FINISHED; } else if (landEvent == NAV_FSM_EVENT_SUCCESS) { // Landing controller returned success - invoke RTH finishing state and finish the waypoint @@ -2356,7 +2378,7 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_FW_LANDING_APPROACH(nav if (isLandingDetected()) { posControl.fwLandState.landState = FW_AUTOLAND_STATE_IDLE; - disarm(DISARM_LANDING); + //disarm(DISARM_LANDING); return NAV_FSM_EVENT_SWITCH_TO_IDLE; } @@ -2400,14 +2422,14 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_FW_LANDING_GLIDE(naviga return NAV_FSM_EVENT_SWITCH_TO_NAV_STATE_FW_LANDING_ABORT; } - if (getLandAltitude() <= posControl.fwLandState.landAltAgl + navFwAutolandConfig()->flareAltitude) { + if (getHwRangefinderStatus() == HW_SENSOR_OK && getLandAltitude() <= posControl.fwLandState.landAltAgl + navFwAutolandConfig()->flareAltitude) { posControl.fwLandState.landState = FW_AUTOLAND_STATE_FLARE; return NAV_FSM_EVENT_SUCCESS; } if (isLandingDetected()) { posControl.fwLandState.landState = FW_AUTOLAND_STATE_IDLE; - disarm(DISARM_LANDING); + //disarm(DISARM_LANDING); return NAV_FSM_EVENT_SWITCH_TO_IDLE; } @@ -2421,7 +2443,7 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_FW_LANDING_FLARE(naviga if (isLandingDetected()) { posControl.fwLandState.landState = FW_AUTOLAND_STATE_IDLE; - disarm(DISARM_LANDING); + //disarm(DISARM_LANDING); return NAV_FSM_EVENT_SUCCESS; } setDesiredPosition(NULL, posControl.cruise.course, NAV_POS_UPDATE_HEADING); @@ -3016,7 +3038,7 @@ void setHomePosition(const fpVector3_t * pos, int32_t heading, navSetWaypointFla updateDesiredRTHAltitude(); // Reset RTH sanity checker for new home position if RTH active - if (FLIGHT_MODE(NAV_RTH_MODE)) { + if (FLIGHT_MODE(NAV_RTH_MODE) || FLIGHT_MODE(NAV_FW_AUTOLAND) ) { initializeRTHSanityChecker(); } @@ -3138,7 +3160,7 @@ void updateHomePosition(void) static bool isHomeResetAllowed = false; // If pilot so desires he may reset home position to current position if (IS_RC_MODE_ACTIVE(BOXHOMERESET)) { - if (isHomeResetAllowed && !FLIGHT_MODE(FAILSAFE_MODE) && !FLIGHT_MODE(NAV_RTH_MODE) && !FLIGHT_MODE(NAV_WP_MODE) && (posControl.flags.estPosStatus >= EST_USABLE)) { + if (isHomeResetAllowed && !FLIGHT_MODE(FAILSAFE_MODE) && !FLIGHT_MODE(NAV_RTH_MODE) && !FLIGHT_MODE(NAV_FW_AUTOLAND) && !FLIGHT_MODE(NAV_WP_MODE) && (posControl.flags.estPosStatus >= EST_USABLE)) { homeUpdateFlags = 0; homeUpdateFlags = STATE(GPS_FIX_HOME) ? (NAV_POS_UPDATE_XY | NAV_POS_UPDATE_HEADING) : (NAV_POS_UPDATE_XY | NAV_POS_UPDATE_Z | NAV_POS_UPDATE_HEADING); setHome = true; @@ -3243,7 +3265,7 @@ static bool rthAltControlStickOverrideCheck(unsigned axis) suspendTracking = false; } - if (navConfig()->general.flags.rth_trackback_mode == RTH_TRACKBACK_OFF || FLIGHT_MODE(NAV_RTH_MODE) || !ARMING_FLAG(ARMED) || suspendTracking) { + if (navConfig()->general.flags.rth_trackback_mode == RTH_TRACKBACK_OFF || FLIGHT_MODE(NAV_RTH_MODE) || FLIGHT_MODE(NAV_FW_AUTOLAND) || !ARMING_FLAG(ARMED) || suspendTracking) { return; } @@ -4061,6 +4083,7 @@ bool isNavHoldPositionActive(void) // Also hold position during emergency landing if position valid return (FLIGHT_MODE(NAV_RTH_MODE) && !posControl.flags.rthTrackbackActive) || FLIGHT_MODE(NAV_POSHOLD_MODE) || + (posControl.navState == NAV_STATE_FW_LANDING_CLIMB_TO_LOITER || posControl.navState == NAV_STATE_FW_LANDING_LOITER) || navigationIsExecutingAnEmergencyLanding(); } @@ -4100,7 +4123,9 @@ bool isWaypointNavTrackingActive(void) // is set from current position not previous WP. Works for WP Restart intermediate WP as well as first mission WP. // (NAV_WP_MODE flag isn't set until WP initialisation is finished, i.e. after calculateAndSetActiveWaypoint called) - return FLIGHT_MODE(NAV_WP_MODE) || (posControl.flags.rthTrackbackActive && posControl.activeRthTBPointIndex != posControl.rthTBLastSavedIndex); + return FLIGHT_MODE(NAV_WP_MODE) + || posControl.navState == NAV_STATE_FW_LANDING_APPROACH + || (posControl.flags.rthTrackbackActive && posControl.activeRthTBPointIndex != posControl.rthTBLastSavedIndex); } /*----------------------------------------------------------- @@ -4169,7 +4194,7 @@ void applyWaypointNavigationAndAltitudeHold(void) posControl.flags.verticalPositionDataConsumed = false; #ifdef USE_FW_AUTOLAND - if (!isFwLandInProgess()) { + if (!FLIGHT_MODE(NAV_FW_AUTOLAND)) { posControl.fwLandState.landState = FW_AUTOLAND_STATE_IDLE; } #endif @@ -4210,7 +4235,7 @@ void applyWaypointNavigationAndAltitudeHold(void) void switchNavigationFlightModes(void) { const flightModeFlags_e enabledNavFlightModes = navGetMappedFlightModes(posControl.navState); - const flightModeFlags_e disabledFlightModes = (NAV_ALTHOLD_MODE | NAV_RTH_MODE | NAV_POSHOLD_MODE | NAV_WP_MODE | NAV_LAUNCH_MODE | NAV_COURSE_HOLD_MODE) & (~enabledNavFlightModes); + const flightModeFlags_e disabledFlightModes = (NAV_ALTHOLD_MODE | NAV_RTH_MODE | NAV_FW_AUTOLAND | NAV_POSHOLD_MODE | NAV_WP_MODE | NAV_LAUNCH_MODE | NAV_COURSE_HOLD_MODE) & (~enabledNavFlightModes); DISABLE_FLIGHT_MODE(disabledFlightModes); ENABLE_FLIGHT_MODE(enabledNavFlightModes); } @@ -4899,7 +4924,7 @@ void abortForcedRTH(void) rthState_e getStateOfForcedRTH(void) { /* If forced RTH activated and in AUTO_RTH or EMERG state */ - if (posControl.flags.forcedRTHActivated && (navGetStateFlags(posControl.navState) & (NAV_AUTO_RTH | NAV_CTL_EMERG | NAV_MIXERAT))) { + if (posControl.flags.forcedRTHActivated && ((navGetStateFlags(posControl.navState) & (NAV_AUTO_RTH | NAV_CTL_EMERG | NAV_MIXERAT)) || FLIGHT_MODE(NAV_FW_AUTOLAND))) { if (posControl.navState == NAV_STATE_RTH_FINISHED || posControl.navState == NAV_STATE_EMERGENCY_LANDING_FINISHED) { return RTH_HAS_LANDED; } @@ -4981,6 +5006,12 @@ bool navigationIsFlyingAutonomousMode(void) bool navigationRTHAllowsLanding(void) { +#ifdef USE_FW_AUTOLAND + if (posControl.fwLandState.landAborted) { + return false; + } +#endif + // WP mission RTH landing setting if (isWaypointMissionRTHActive() && isWaypointMissionValid()) { return posControl.waypointList[posControl.startWpIndex + posControl.waypointCount - 1].p1 > 0; @@ -5138,15 +5169,6 @@ void resetFwAutolandApproach(int8_t idx) } } -bool isFwLandInProgess(void) -{ - return posControl.navState == NAV_STATE_FW_LANDING_CLIMB_TO_LOITER - || posControl.navState == NAV_STATE_FW_LANDING_LOITER - || posControl.navState == NAV_STATE_FW_LANDING_APPROACH - || posControl.navState == NAV_STATE_FW_LANDING_GLIDE - || posControl.navState == NAV_STATE_FW_LANDING_FLARE; -} - bool canFwLandCanceld(void) { return posControl.navState == NAV_STATE_FW_LANDING_CLIMB_TO_LOITER diff --git a/src/main/navigation/navigation.h b/src/main/navigation/navigation.h index 884f1726388..6ebdaeccead 100644 --- a/src/main/navigation/navigation.h +++ b/src/main/navigation/navigation.h @@ -693,7 +693,6 @@ uint8_t getActiveWpNumber(void); int32_t navigationGetHomeHeading(void); #ifdef USE_FW_AUTOLAND -bool isFwLandInProgess(void); bool canFwLandCanceld(void); #endif diff --git a/src/main/navigation/navigation_fixedwing.c b/src/main/navigation/navigation_fixedwing.c index da5d5f70c09..2dfebdf8d98 100755 --- a/src/main/navigation/navigation_fixedwing.c +++ b/src/main/navigation/navigation_fixedwing.c @@ -271,7 +271,7 @@ static int8_t loiterDirection(void) { static void calculateVirtualPositionTarget_FW(float trackingPeriod) { - if (FLIGHT_MODE(NAV_COURSE_HOLD_MODE)) { + if (FLIGHT_MODE(NAV_COURSE_HOLD_MODE) || posControl.navState == NAV_STATE_FW_LANDING_GLIDE || posControl.navState == NAV_STATE_FW_LANDING_FLARE) { return; } @@ -405,7 +405,7 @@ static void updatePositionHeadingController_FW(timeUs_t currentTimeUs, timeDelta static bool forceTurnDirection = false; int32_t virtualTargetBearing; - if (FLIGHT_MODE(NAV_COURSE_HOLD_MODE)) { + if (FLIGHT_MODE(NAV_COURSE_HOLD_MODE) || posControl.navState == NAV_STATE_FW_LANDING_GLIDE || posControl.navState == NAV_STATE_FW_LANDING_FLARE) { virtualTargetBearing = posControl.desiredState.yaw; } else { // We have virtual position target, calculate heading error @@ -643,11 +643,7 @@ void applyFixedWingPitchRollThrottleController(navigationFSMStateFlags_t navStat uint16_t correctedThrottleValue = constrain(currentBatteryProfile->nav.fw.cruise_throttle + throttleCorrection, currentBatteryProfile->nav.fw.min_throttle, currentBatteryProfile->nav.fw.max_throttle); // Manual throttle increase -#ifdef USE_FW_AUTOLAND - if (navConfig()->fw.allow_manual_thr_increase && !FLIGHT_MODE(FAILSAFE_MODE) && !isFwLandInProgess()) { -#else - if (navConfig()->fw.allow_manual_thr_increase && !FLIGHT_MODE(FAILSAFE_MODE)) { -#endif + if (navConfig()->fw.allow_manual_thr_increase && !FLIGHT_MODE(FAILSAFE_MODE) && !FLIGHT_MODE(NAV_FW_AUTOLAND)) { if (rcCommand[THROTTLE] < PWM_RANGE_MIN + (PWM_RANGE_MAX - PWM_RANGE_MIN) * 0.95){ correctedThrottleValue += MAX(0, rcCommand[THROTTLE] - currentBatteryProfile->nav.fw.cruise_throttle); } else { @@ -665,7 +661,6 @@ void applyFixedWingPitchRollThrottleController(navigationFSMStateFlags_t navStat // Advanced autoland if (posControl.navState == NAV_STATE_FW_LANDING_GLIDE || posControl.navState == NAV_STATE_FW_LANDING_FLARE || STATE(LANDING_DETECTED)) { // Set motor to min. throttle and stop it when MOTOR_STOP feature is enabled - rcCommand[THROTTLE] = getThrottleIdleValue(); ENABLE_STATE(NAV_MOTOR_STOP_OR_IDLE); if (posControl.navState == NAV_STATE_FW_LANDING_GLIDE) { @@ -727,6 +722,7 @@ bool isFixedWingLandingDetected(void) // Basic condition to start looking for landing bool startCondition = (navGetCurrentStateFlags() & (NAV_CTL_LAND | NAV_CTL_EMERG)) || FLIGHT_MODE(FAILSAFE_MODE) + || FLIGHT_MODE(NAV_FW_AUTOLAND) || (!navigationIsControllingThrottle() && throttleStickIsLow()); if (!startCondition || posControl.flags.resetLandingDetector) { diff --git a/src/main/programming/logic_condition.c b/src/main/programming/logic_condition.c index 8fcca4dabcd..2b10896b718 100644 --- a/src/main/programming/logic_condition.c +++ b/src/main/programming/logic_condition.c @@ -746,7 +746,7 @@ static int logicConditionGetFlightOperandValue(int operand) { case LOGIC_CONDITION_OPERAND_FLIGHT_IS_LANDING: // 0/1 #ifdef USE_FW_AUTOLAND - return ((navGetCurrentStateFlags() & NAV_CTL_LAND) || isFwLandInProgess()) ? 1 : 0; + return ((navGetCurrentStateFlags() & NAV_CTL_LAND) || FLIGHT_MODE(NAV_FW_AUTOLAND)) ? 1 : 0; #else return ((navGetCurrentStateFlags() & NAV_CTL_LAND)) ? 1 : 0; #endif diff --git a/src/main/telemetry/crsf.c b/src/main/telemetry/crsf.c index af9f278659f..aee7e5d3037 100755 --- a/src/main/telemetry/crsf.c +++ b/src/main/telemetry/crsf.c @@ -371,6 +371,11 @@ static void crsfFrameFlightMode(sbuf_t *dst) } else if (FLIGHT_MODE(ANGLEHOLD_MODE)) { flightMode = "ANGH"; } +#ifdef USE_FW_AUTOLAND + } else if (FLIGHT_MODE(NAV_FW_AUTOLAND)) { + flightMode = "LAND" + } +#endif #ifdef USE_GPS } else if (feature(FEATURE_GPS) && navConfig()->general.flags.extra_arming_safety && (!STATE(GPS_FIX) || !STATE(GPS_FIX_HOME))) { flightMode = "WAIT"; // Waiting for GPS lock diff --git a/src/main/telemetry/ltm.c b/src/main/telemetry/ltm.c index 00e99a80472..c8cefd87257 100644 --- a/src/main/telemetry/ltm.c +++ b/src/main/telemetry/ltm.c @@ -71,6 +71,7 @@ #include "sensors/gyro.h" #include "sensors/sensors.h" #include "sensors/pitotmeter.h" +#include "sensors/diagnostics.h" #include "telemetry/ltm.h" #include "telemetry/telemetry.h" @@ -178,6 +179,10 @@ void ltm_sframe(sbuf_t *dst) lt_flightmode = LTM_MODE_ANGLE; else if (FLIGHT_MODE(HORIZON_MODE)) lt_flightmode = LTM_MODE_HORIZON; +#ifdef USE_FW_AUTOLAND + else if (FLIGHT_MODE(NAV_FW_AUTOLAND)) + lt_flightmode = LTM_MODE_LAND; +#endif else lt_flightmode = LTM_MODE_RATE; // Rate mode From 56f9a7a000cf79312fdec2c1dfc2a8a17dd77916 Mon Sep 17 00:00:00 2001 From: Scavanger Date: Wed, 13 Mar 2024 17:11:03 -0300 Subject: [PATCH 077/241] Add forgotten ; and add a } --- src/main/telemetry/crsf.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/telemetry/crsf.c b/src/main/telemetry/crsf.c index aee7e5d3037..fd461003879 100755 --- a/src/main/telemetry/crsf.c +++ b/src/main/telemetry/crsf.c @@ -373,8 +373,7 @@ static void crsfFrameFlightMode(sbuf_t *dst) } #ifdef USE_FW_AUTOLAND } else if (FLIGHT_MODE(NAV_FW_AUTOLAND)) { - flightMode = "LAND" - } + flightMode = "LAND"; #endif #ifdef USE_GPS } else if (feature(FEATURE_GPS) && navConfig()->general.flags.extra_arming_safety && (!STATE(GPS_FIX) || !STATE(GPS_FIX_HOME))) { From 7fda8c62fdb60cdb2db878c6cfcfdaa4c281cb34 Mon Sep 17 00:00:00 2001 From: Marcelo Bezerra <23555060+mmosca@users.noreply.github.com> Date: Fri, 15 Mar 2024 09:37:52 +0100 Subject: [PATCH 078/241] Add ICM42688P driver to the target --- src/main/target/IFLIGHT_BLITZ_ATF435/target.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/target/IFLIGHT_BLITZ_ATF435/target.h b/src/main/target/IFLIGHT_BLITZ_ATF435/target.h index 7518bbe13e2..b29112d5256 100644 --- a/src/main/target/IFLIGHT_BLITZ_ATF435/target.h +++ b/src/main/target/IFLIGHT_BLITZ_ATF435/target.h @@ -69,6 +69,13 @@ #define BMI270_SPI_BUS BUS_SPI1 #define BMI270_CS_PIN PA4 +// ICM42605/ICM42688P +#define USE_IMU_ICM42605 +#define IMU_ICM42605_ALIGN CW0_DEG +#define ICM42605_SPI_BUS BUS_SPI1 +#define ICM42605_CS_PIN PA4 + + // Other sensors #define USE_BARO From 90a2920da0b9d64b4f30bfd921c5cdd593c13894 Mon Sep 17 00:00:00 2001 From: Ray Morris Date: Fri, 15 Mar 2024 23:29:16 -0500 Subject: [PATCH 079/241] Servo.md: correct tab name --- docs/Servo.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Servo.md b/docs/Servo.md index 42acfaa3c9b..d3322b02f02 100644 --- a/docs/Servo.md +++ b/docs/Servo.md @@ -1,6 +1,6 @@ # Servo configuration -Servos can be configured from the graphical user interface's `Servos` tab. +Servos can be configured from the graphical user interface's `Outputs` tab. * MID: middle/neutral point of the servo * MIN: the minimum value that can be sent to the servo is MIN * Rate From 4dcf6ed41ac58b127c7401a26b56a5e581b07352 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Mon, 18 Mar 2024 09:49:05 +0100 Subject: [PATCH 080/241] Remove unused USE_UNDERCLOCK define and related code --- src/main/drivers/system.h | 1 - src/main/drivers/system_at32f43x.c | 6 ------ src/main/drivers/system_stm32f4xx.c | 6 ------ src/main/drivers/system_stm32f7xx.c | 6 ------ src/main/drivers/system_stm32h7xx.c | 6 ------ src/main/fc/config.c | 3 --- src/main/fc/config.h | 3 --- src/main/fc/fc_init.c | 7 ------- src/main/fc/settings.yaml | 6 ------ src/main/target/SITL/target.c | 5 ----- 10 files changed, 49 deletions(-) diff --git a/src/main/drivers/system.h b/src/main/drivers/system.h index 10c0a1e717d..539a4ea93fb 100644 --- a/src/main/drivers/system.h +++ b/src/main/drivers/system.h @@ -21,7 +21,6 @@ #include void systemInit(void); -void systemClockSetup(uint8_t cpuUnderclock); typedef enum { FAILURE_DEVELOPER = 0, diff --git a/src/main/drivers/system_at32f43x.c b/src/main/drivers/system_at32f43x.c index fadcfe239a4..340058e183b 100644 --- a/src/main/drivers/system_at32f43x.c +++ b/src/main/drivers/system_at32f43x.c @@ -114,12 +114,6 @@ uint32_t systemBootloaderAddress(void) //return system_isr_vector_table_base; } -void systemClockSetup(uint8_t cpuUnderclock) -{ - (void)cpuUnderclock; - // This is a stub -} - void systemInit(void) { //config system clock to 288mhz usb 48mhz diff --git a/src/main/drivers/system_stm32f4xx.c b/src/main/drivers/system_stm32f4xx.c index 5cb9ccfd206..9863fa3c8c6 100644 --- a/src/main/drivers/system_stm32f4xx.c +++ b/src/main/drivers/system_stm32f4xx.c @@ -143,12 +143,6 @@ uint32_t systemBootloaderAddress(void) return 0x1FFF0000; } -void systemClockSetup(uint8_t cpuUnderclock) -{ - (void)cpuUnderclock; - // This is a stub -} - void systemInit(void) { SetSysClock(); diff --git a/src/main/drivers/system_stm32f7xx.c b/src/main/drivers/system_stm32f7xx.c index 9c39be23e84..da58cf24b52 100644 --- a/src/main/drivers/system_stm32f7xx.c +++ b/src/main/drivers/system_stm32f7xx.c @@ -66,12 +66,6 @@ uint32_t systemBootloaderAddress(void) return 0x1FF00000; } -void systemClockSetup(uint8_t cpuUnderclock) -{ - (void)cpuUnderclock; - // This is a stub -} - void systemInit(void) { checkForBootLoaderRequest(); diff --git a/src/main/drivers/system_stm32h7xx.c b/src/main/drivers/system_stm32h7xx.c index a1de36f2c2d..af3ea72e2a2 100644 --- a/src/main/drivers/system_stm32h7xx.c +++ b/src/main/drivers/system_stm32h7xx.c @@ -60,12 +60,6 @@ uint32_t systemBootloaderAddress(void) #endif } -void systemClockSetup(uint8_t cpuUnderclock) -{ - (void)cpuUnderclock; - // This is a stub -} - void systemInit(void) { checkForBootLoaderRequest(); diff --git a/src/main/fc/config.c b/src/main/fc/config.c index 52cb06f81a6..c9a50c60a25 100755 --- a/src/main/fc/config.c +++ b/src/main/fc/config.c @@ -115,9 +115,6 @@ PG_RESET_TEMPLATE(systemConfig_t, systemConfig, #endif #ifdef USE_I2C .i2c_speed = SETTING_I2C_SPEED_DEFAULT, -#endif -#ifdef USE_UNDERCLOCK - .cpuUnderclock = SETTING_CPU_UNDERCLOCK_DEFAULT, #endif .throttle_tilt_compensation_strength = SETTING_THROTTLE_TILT_COMP_STR_DEFAULT, // 0-100, 0 - disabled .craftName = SETTING_NAME_DEFAULT, diff --git a/src/main/fc/config.h b/src/main/fc/config.h index bafa5c0cbe0..ddb6a826b83 100644 --- a/src/main/fc/config.h +++ b/src/main/fc/config.h @@ -76,9 +76,6 @@ typedef struct systemConfig_s { #endif #ifdef USE_I2C uint8_t i2c_speed; -#endif -#ifdef USE_UNDERCLOCK - uint8_t cpuUnderclock; #endif uint8_t throttle_tilt_compensation_strength; // the correction that will be applied at throttle_correction_angle. char craftName[MAX_NAME_LENGTH + 1]; diff --git a/src/main/fc/fc_init.c b/src/main/fc/fc_init.c index 849cdc2b7c0..154b231291f 100644 --- a/src/main/fc/fc_init.c +++ b/src/main/fc/fc_init.c @@ -229,13 +229,6 @@ void init(void) readEEPROM(); resumeRxSignal(); -#ifdef USE_UNDERCLOCK - // Re-initialize system clock to their final values (if necessary) - systemClockSetup(systemConfig()->cpuUnderclock); -#else - systemClockSetup(false); -#endif - #ifdef USE_I2C i2cSetSpeed(systemConfig()->i2c_speed); #endif diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index 0afd4c8baef..18b74cb4d11 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -3735,12 +3735,6 @@ groups: default_value: "400KHZ" condition: USE_I2C table: i2c_speed - - name: cpu_underclock - description: "This option is only available on certain architectures (F3 CPUs at the moment). It makes CPU clock lower to reduce interference to long-range RC systems working at 433MHz" - default_value: OFF - field: cpuUnderclock - condition: USE_UNDERCLOCK - type: bool - name: debug_mode description: "Defines debug values exposed in debug variables (developer / debugging setting)" default_value: "NONE" diff --git a/src/main/target/SITL/target.c b/src/main/target/SITL/target.c index 0a686f60619..e8861eec56d 100644 --- a/src/main/target/SITL/target.c +++ b/src/main/target/SITL/target.c @@ -342,11 +342,6 @@ void IOConfigGPIO(IO_t io, ioConfig_t cfg) UNUSED(cfg); } -void systemClockSetup(uint8_t cpuUnderclock) -{ - UNUSED(cpuUnderclock); -} - void timerInit(void) { // NOP } From e08b8f62dd67d3ecee27b758042b2fb1df16d77b Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Mon, 18 Mar 2024 09:54:10 +0100 Subject: [PATCH 081/241] Remove setting a use local VELNED instead of GPS provided. INAV will default to use GPS provided VELNED if is available --- docs/Settings.md | 10 ---------- src/main/fc/fc_msp.c | 4 ++-- src/main/fc/settings.yaml | 5 ----- src/main/navigation/navigation.h | 1 - src/main/navigation/navigation_pos_estimator.c | 7 +++---- 5 files changed, 5 insertions(+), 22 deletions(-) diff --git a/docs/Settings.md b/docs/Settings.md index 79278af68f3..db8180ed43b 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -1872,16 +1872,6 @@ _// TODO_ --- -### inav_use_gps_velned - -Defined if INAV should use velocity data provided by GPS module for doing position and speed estimation. If set to OFF INAV will fallback to calculating velocity from GPS coordinates. Using native velocity data may improve performance on some GPS modules. Some GPS modules introduce significant delay and using native velocity may actually result in much worse performance. - -| Default | Min | Max | -| --- | --- | --- | -| ON | OFF | ON | - ---- - ### inav_w_acc_bias Weight for accelerometer drift estimation diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index 2c3f40dfe45..c076fa88c42 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -1420,7 +1420,7 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF sbufWriteU16(dst, positionEstimationConfig()->w_xy_gps_p * 100); // 2 inav_w_xy_gps_p float as value * 100 sbufWriteU16(dst, positionEstimationConfig()->w_xy_gps_v * 100); // 2 inav_w_xy_gps_v float as value * 100 sbufWriteU8(dst, gpsConfigMutable()->gpsMinSats); // 1 - sbufWriteU8(dst, positionEstimationConfig()->use_gps_velned); // 1 inav_use_gps_velned ON/OFF + sbufWriteU8(dst, 1); // 1 inav_use_gps_velned ON/OFF break; @@ -2489,7 +2489,7 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) positionEstimationConfigMutable()->w_xy_gps_p = constrainf(sbufReadU16(src) / 100.0f, 0.0f, 10.0f); positionEstimationConfigMutable()->w_xy_gps_v = constrainf(sbufReadU16(src) / 100.0f, 0.0f, 10.0f); gpsConfigMutable()->gpsMinSats = constrain(sbufReadU8(src), 5, 10); - positionEstimationConfigMutable()->use_gps_velned = constrain(sbufReadU8(src), 0, 1); + sbufReadU8(src); // was positionEstimationConfigMutable()->use_gps_velned } else return MSP_RESULT_ERROR; break; diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index 0afd4c8baef..cf37f208a21 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -2288,11 +2288,6 @@ groups: field: gravity_calibration_tolerance min: 0 max: 255 - - name: inav_use_gps_velned - description: "Defined if INAV should use velocity data provided by GPS module for doing position and speed estimation. If set to OFF INAV will fallback to calculating velocity from GPS coordinates. Using native velocity data may improve performance on some GPS modules. Some GPS modules introduce significant delay and using native velocity may actually result in much worse performance." - default_value: ON - field: use_gps_velned - type: bool - name: inav_use_gps_no_baro field: use_gps_no_baro type: bool diff --git a/src/main/navigation/navigation.h b/src/main/navigation/navigation.h index 84e5390d43e..0e63998f880 100644 --- a/src/main/navigation/navigation.h +++ b/src/main/navigation/navigation.h @@ -234,7 +234,6 @@ typedef struct positionEstimationConfig_s { uint8_t reset_altitude_type; // from nav_reset_type_e uint8_t reset_home_type; // nav_reset_type_e uint8_t gravity_calibration_tolerance; // Tolerance of gravity calibration (cm/s/s) - uint8_t use_gps_velned; uint8_t allow_dead_reckoning; uint16_t max_surface_altitude; diff --git a/src/main/navigation/navigation_pos_estimator.c b/src/main/navigation/navigation_pos_estimator.c index 3453c75c92b..19018983cc5 100755 --- a/src/main/navigation/navigation_pos_estimator.c +++ b/src/main/navigation/navigation_pos_estimator.c @@ -56,7 +56,7 @@ navigationPosEstimator_t posEstimator; static float initialBaroAltitudeOffset = 0.0f; -PG_REGISTER_WITH_RESET_TEMPLATE(positionEstimationConfig_t, positionEstimationConfig, PG_POSITION_ESTIMATION_CONFIG, 5); +PG_REGISTER_WITH_RESET_TEMPLATE(positionEstimationConfig_t, positionEstimationConfig, PG_POSITION_ESTIMATION_CONFIG, 6); PG_RESET_TEMPLATE(positionEstimationConfig_t, positionEstimationConfig, // Inertial position estimator parameters @@ -64,7 +64,6 @@ PG_RESET_TEMPLATE(positionEstimationConfig_t, positionEstimationConfig, .reset_altitude_type = SETTING_INAV_RESET_ALTITUDE_DEFAULT, .reset_home_type = SETTING_INAV_RESET_HOME_DEFAULT, .gravity_calibration_tolerance = SETTING_INAV_GRAVITY_CAL_TOLERANCE_DEFAULT, // 5 cm/s/s calibration error accepted (0.5% of gravity) - .use_gps_velned = SETTING_INAV_USE_GPS_VELNED_DEFAULT, // "Disabled" is mandatory with gps_dyn_model = Pedestrian .use_gps_no_baro = SETTING_INAV_USE_GPS_NO_BARO_DEFAULT, // Use GPS altitude if no baro is available on all aircrafts .allow_dead_reckoning = SETTING_INAV_ALLOW_DEAD_RECKONING_DEFAULT, @@ -229,7 +228,7 @@ void onNewGPSData(void) /* Use VELNED provided by GPS if available, calculate from coordinates otherwise */ float gpsScaleLonDown = constrainf(cos_approx((ABS(gpsSol.llh.lat) / 10000000.0f) * 0.0174532925f), 0.01f, 1.0f); - if (!ARMING_FLAG(SIMULATOR_MODE_SITL) && positionEstimationConfig()->use_gps_velned && gpsSol.flags.validVelNE) { + if (!ARMING_FLAG(SIMULATOR_MODE_SITL) && gpsSol.flags.validVelNE) { posEstimator.gps.vel.x = gpsSol.velNED[X]; posEstimator.gps.vel.y = gpsSol.velNED[Y]; } @@ -238,7 +237,7 @@ void onNewGPSData(void) posEstimator.gps.vel.y = (posEstimator.gps.vel.y + (gpsScaleLonDown * DISTANCE_BETWEEN_TWO_LONGITUDE_POINTS_AT_EQUATOR * (gpsSol.llh.lon - previousLon) / dT)) / 2.0f; } - if (positionEstimationConfig()->use_gps_velned && gpsSol.flags.validVelD) { + if (gpsSol.flags.validVelD) { posEstimator.gps.vel.z = -gpsSol.velNED[Z]; // NEU } else { From 17f4b254873c2b0ae9a356890c6d1e56084e51e2 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Mon, 18 Mar 2024 09:55:09 +0100 Subject: [PATCH 082/241] Docs update --- docs/Settings.md | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/docs/Settings.md b/docs/Settings.md index 79278af68f3..53b39e3a1b4 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -572,16 +572,6 @@ Control rate profile to switch to when the battery profile is selected, 0 to dis --- -### cpu_underclock - -This option is only available on certain architectures (F3 CPUs at the moment). It makes CPU clock lower to reduce interference to long-range RC systems working at 433MHz - -| Default | Min | Max | -| --- | --- | --- | -| OFF | OFF | ON | - ---- - ### cruise_power Power draw at cruise throttle used for remaining flight time/distance estimation in 0.01W unit From b3f1bd3788994ed1d6c368417fccd96fc64a3ca4 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Mon, 18 Mar 2024 13:34:13 +0100 Subject: [PATCH 083/241] Drop control_deadband setting --- docs/Settings.md | 10 ---------- src/main/fc/fc_core.c | 2 +- src/main/fc/rc_controls.c | 5 ++--- src/main/fc/rc_controls.h | 3 +-- src/main/fc/settings.yaml | 5 ----- 5 files changed, 4 insertions(+), 21 deletions(-) diff --git a/docs/Settings.md b/docs/Settings.md index 79278af68f3..5235dce43a7 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -552,16 +552,6 @@ Blackbox logging rate numerator. Use num/denom settings to decide if a frame sho --- -### control_deadband - -Stick deadband in [r/c points], applied after r/c deadband and expo. Used to check if sticks are centered. - -| Default | Min | Max | -| --- | --- | --- | -| 10 | 2 | 250 | - ---- - ### controlrate_profile Control rate profile to switch to when the battery profile is selected, 0 to disable and keep the currently selected control rate profile diff --git a/src/main/fc/fc_core.c b/src/main/fc/fc_core.c index 0d0863760de..68df26dcde5 100644 --- a/src/main/fc/fc_core.c +++ b/src/main/fc/fc_core.c @@ -237,7 +237,7 @@ static void updateArmingStatus(void) /* CHECK: pitch / roll sticks centered when NAV_LAUNCH_MODE enabled */ if (isNavLaunchEnabled()) { - if (isRollPitchStickDeflected(rcControlsConfig()->control_deadband)) { + if (isRollPitchStickDeflected(CONTROL_DEADBAND)) { ENABLE_ARMING_FLAG(ARMING_DISABLED_ROLLPITCH_NOT_CENTERED); } else { DISABLE_ARMING_FLAG(ARMING_DISABLED_ROLLPITCH_NOT_CENTERED); diff --git a/src/main/fc/rc_controls.c b/src/main/fc/rc_controls.c index 9cce60a2a38..6c65736dbe5 100644 --- a/src/main/fc/rc_controls.c +++ b/src/main/fc/rc_controls.c @@ -75,13 +75,12 @@ stickPositions_e rcStickPositions; FASTRAM int16_t rcCommand[4]; // interval [1000;2000] for THROTTLE and [-500;+500] for ROLL/PITCH/YAW -PG_REGISTER_WITH_RESET_TEMPLATE(rcControlsConfig_t, rcControlsConfig, PG_RC_CONTROLS_CONFIG, 3); +PG_REGISTER_WITH_RESET_TEMPLATE(rcControlsConfig_t, rcControlsConfig, PG_RC_CONTROLS_CONFIG, 4); PG_RESET_TEMPLATE(rcControlsConfig_t, rcControlsConfig, .deadband = SETTING_DEADBAND_DEFAULT, .yaw_deadband = SETTING_YAW_DEADBAND_DEFAULT, .pos_hold_deadband = SETTING_POS_HOLD_DEADBAND_DEFAULT, - .control_deadband = SETTING_CONTROL_DEADBAND_DEFAULT, .alt_hold_deadband = SETTING_ALT_HOLD_DEADBAND_DEFAULT, .mid_throttle_deadband = SETTING_3D_DEADBAND_THROTTLE_DEFAULT, .airmodeHandlingType = SETTING_AIRMODE_TYPE_DEFAULT, @@ -104,7 +103,7 @@ bool areSticksInApModePosition(uint16_t ap_mode) bool areSticksDeflected(void) { - return (ABS(rcCommand[ROLL]) > rcControlsConfig()->control_deadband) || (ABS(rcCommand[PITCH]) > rcControlsConfig()->control_deadband) || (ABS(rcCommand[YAW]) > rcControlsConfig()->control_deadband); + return (ABS(rcCommand[ROLL]) > CONTROL_DEADBAND) || (ABS(rcCommand[PITCH]) > CONTROL_DEADBAND) || (ABS(rcCommand[YAW]) > CONTROL_DEADBAND); } bool isRollPitchStickDeflected(uint8_t deadband) diff --git a/src/main/fc/rc_controls.h b/src/main/fc/rc_controls.h index ea23eae9075..0c9bcb199d3 100644 --- a/src/main/fc/rc_controls.h +++ b/src/main/fc/rc_controls.h @@ -19,7 +19,7 @@ #include "config/parameter_group.h" -#define AIRMODE_THROTTLE_THRESHOLD 1300 +#define CONTROL_DEADBAND 10 // Used to check if sticks are centered typedef enum rc_alias { ROLL = 0, @@ -85,7 +85,6 @@ typedef struct rcControlsConfig_s { uint8_t deadband; // introduce a deadband around the stick center for pitch and roll axis. Must be greater than zero. uint8_t yaw_deadband; // introduce a deadband around the stick center for yaw axis. Must be greater than zero. uint8_t pos_hold_deadband; // Deadband for position hold - uint8_t control_deadband; // General deadband to check if sticks are deflected, us PWM. uint8_t alt_hold_deadband; // Defines the neutral zone of throttle stick during altitude hold uint16_t mid_throttle_deadband; // default throttle deadband from MIDRC uint8_t airmodeHandlingType; // Defaults to ANTI_WINDUP triggered at sticks centered diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index 0afd4c8baef..49cdbdf2ad7 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -1695,11 +1695,6 @@ groups: default_value: 10 min: 2 max: 250 - - name: control_deadband - description: "Stick deadband in [r/c points], applied after r/c deadband and expo. Used to check if sticks are centered." - default_value: 10 - min: 2 - max: 250 - name: alt_hold_deadband description: "Defines the deadband of throttle during alt_hold [r/c points]" default_value: 50 From 26b876191604912427d0b47ace2deeda14d7a602 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Wed, 20 Mar 2024 19:50:13 +0100 Subject: [PATCH 084/241] Update settings descriptions --- docs/Settings.md | 64 +++++++++++++++++++-------------------- src/main/fc/settings.yaml | 33 +++++++++++++++++++- 2 files changed, 64 insertions(+), 33 deletions(-) diff --git a/docs/Settings.md b/docs/Settings.md index 79278af68f3..9a8630accbe 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -104,7 +104,7 @@ Specifies the type of the software LPF of the acc signals. BIQUAD gives better f ### acc_notch_cutoff -_// TODO_ +Frequency of the software notch filter to remove mechanical vibrations from the accelerometer measurements. Value is cutoff frequency (Hz) | Default | Min | Max | | --- | --- | --- | @@ -114,7 +114,7 @@ _// TODO_ ### acc_notch_hz -_// TODO_ +Frequency of the software notch filter to remove mechanical vibrations from the accelerometer measurements. Value is center frequency (Hz) | Default | Min | Max | | --- | --- | --- | @@ -394,7 +394,7 @@ Defines the deadband of throttle during alt_hold [r/c points] ### antigravity_accelerator -_// TODO_ +Multiplier for Antigravity gain. The bigger is the difference between actual and filtered throttle input, the bigger Antigravity gain | Default | Min | Max | | --- | --- | --- | @@ -634,7 +634,7 @@ ADC , VIRTUAL, NONE. The virtual current sensor, once calibrated, estimates the ### d_boost_gyro_delta_lpf_hz -_// TODO_ +Cutoff frequency for the low pass filter applied to the gyro delta signal used for D-term boost. Lower value will produce a smoother D-term boost signal, but it will be more delayed. | Default | Min | Max | | --- | --- | --- | @@ -644,7 +644,7 @@ _// TODO_ ### d_boost_max -_// TODO_ +D-term multiplier when rapid external conditions are detected. Lower values give sharper response to stick input, higher values give smoother response by scaling D-gains up. | Default | Min | Max | | --- | --- | --- | @@ -654,7 +654,7 @@ _// TODO_ ### d_boost_max_at_acceleration -_// TODO_ +Acceleration threshold for D-term multiplier. When acceleration is above this value, D-term multiplier is set to `d_boost_max` | Default | Min | Max | | --- | --- | --- | @@ -664,7 +664,7 @@ _// TODO_ ### d_boost_min -_// TODO_ +D-term multiplier when pilot provides rapid stick input. Lower values give sharper response to stick input, higher values give smoother response. | Default | Min | Max | | --- | --- | --- | @@ -1164,7 +1164,7 @@ Defines throw range in us for both ailerons that will be passed to servo mixer v ### fpv_mix_degrees -_// TODO_ +The tilt angle of the FPV camera in degrees, used by the FPV ANGLE MIX mode | Default | Min | Max | | --- | --- | --- | @@ -1664,7 +1664,7 @@ Defines the type of the main gyro LPF filter. Possible values: `PT1`, `BIQUAD`. ### gyro_to_use -_// TODO_ +On multi-gyro targets, allows to choose which gyro to use. 0 = first gyro, 1 = second gyro | Default | Min | Max | | --- | --- | --- | @@ -1894,7 +1894,7 @@ Weight for accelerometer drift estimation ### inav_w_xy_flow_p -_// TODO_ +Weight of optical flow measurements in estimated UAV position. | Default | Min | Max | | --- | --- | --- | @@ -1904,7 +1904,7 @@ _// TODO_ ### inav_w_xy_flow_v -_// TODO_ +Weight of optical flow measurements in estimated UAV speed. | Default | Min | Max | | --- | --- | --- | @@ -1984,7 +1984,7 @@ Decay coefficient for estimated climb rate when baro/GPS reference for altitude ### inav_w_z_surface_p -_// TODO_ +Weight of rangefinder measurements in estimated altitude. Setting is used on both airplanes and multirotors when rangefinder is present and Surface mode enabled | Default | Min | Max | | --- | --- | --- | @@ -1994,7 +1994,7 @@ _// TODO_ ### inav_w_z_surface_v -_// TODO_ +Weight of rangefinder measurements in estimated climb rate. Setting is used on both airplanes and multirotors when rangefinder is present and Surface mode enabled | Default | Min | Max | | --- | --- | --- | @@ -2354,7 +2354,7 @@ Servo travel multiplier for the YAW axis in `MANUAL` flight mode [0-100]% ### mavlink_ext_status_rate -_// TODO_ +Rate of the extended status message for MAVLink telemetry | Default | Min | Max | | --- | --- | --- | @@ -2364,7 +2364,7 @@ _// TODO_ ### mavlink_extra1_rate -_// TODO_ +Rate of the extra1 message for MAVLink telemetry | Default | Min | Max | | --- | --- | --- | @@ -2374,7 +2374,7 @@ _// TODO_ ### mavlink_extra2_rate -_// TODO_ +Rate of the extra2 message for MAVLink telemetry | Default | Min | Max | | --- | --- | --- | @@ -2384,7 +2384,7 @@ _// TODO_ ### mavlink_extra3_rate -_// TODO_ +Rate of the extra3 message for MAVLink telemetry | Default | Min | Max | | --- | --- | --- | @@ -2394,7 +2394,7 @@ _// TODO_ ### mavlink_pos_rate -_// TODO_ +Rate of the position message for MAVLink telemetry | Default | Min | Max | | --- | --- | --- | @@ -2404,7 +2404,7 @@ _// TODO_ ### mavlink_rc_chan_rate -_// TODO_ +Rate of the RC channels message for MAVLink telemetry | Default | Min | Max | | --- | --- | --- | @@ -2584,7 +2584,7 @@ Multicopter rate stabilisation I-gain for YAW ### mc_iterm_relax -_// TODO_ +Iterm relax type. When enabled, Iterm will be relaxed when stick is centered. This will help to reduce bounceback and followthrough on multirotors. It is recommended to enable this feature on all multirotors. | Default | Min | Max | | --- | --- | --- | @@ -2594,7 +2594,7 @@ _// TODO_ ### mc_iterm_relax_cutoff -_// TODO_ +Iterm relax cutoff frequency. | Default | Min | Max | | --- | --- | --- | @@ -3714,7 +3714,7 @@ A point (in percent of both target and current horizontal velocity) where nav_mc ### nav_mc_vel_xy_dterm_lpf_hz -_// TODO_ +D-term low pass filter cutoff frequency for horizontal velocity PID controller (Multirotor). It allows to smooth the PosHold CRUISE, WP and RTH when Multirotor is traveling at full speed. Dterm is not attenuated at low speeds, breaking and accelerating. | Default | Min | Max | | --- | --- | --- | @@ -3724,7 +3724,7 @@ _// TODO_ ### nav_mc_vel_xy_ff -_// TODO_ +FF gain of Position-Rate (Velocity to Acceleration) | Default | Min | Max | | --- | --- | --- | @@ -4094,7 +4094,7 @@ Selection of OPFLOW hardware. ### opflow_scale -_// TODO_ +Optical flow module scale factor | Default | Min | Max | | --- | --- | --- | @@ -4314,7 +4314,7 @@ Set the camera uptilt for the FPV camera in degres, positive is up, negative is ### osd_coordinate_digits -_// TODO_ +Number of digits for the coordinates displayed in the OSD [8-11]. | Default | Min | Max | | --- | --- | --- | @@ -4664,7 +4664,7 @@ PWM value for UP key ### osd_left_sidebar_scroll -_// TODO_ +Scroll type for the left sidebar | Default | Min | Max | | --- | --- | --- | @@ -4794,7 +4794,7 @@ Number of leading digits removed from plus code. Removing 2, 4 and 6 digits requ ### osd_right_sidebar_scroll -_// TODO_ +Scroll type for the right sidebar | Default | Min | Max | | --- | --- | --- | @@ -4884,7 +4884,7 @@ Sidebar horizontal offset from default position. Positive values move the sideba ### osd_sidebar_scroll_arrows -_// TODO_ +Show arrows for scrolling the sidebars | Default | Min | Max | | --- | --- | --- | @@ -5214,7 +5214,7 @@ Selection of pitot hardware. ### pitot_lpf_milli_hz -_// TODO_ +Pitot tube lowpass filter cutoff frequency. Lower cutoff frequencies result in smoother response at expense of command control delay | Default | Min | Max | | --- | --- | --- | @@ -5224,7 +5224,7 @@ _// TODO_ ### pitot_scale -_// TODO_ +Pitot tube scale factor | Default | Min | Max | | --- | --- | --- | @@ -5594,7 +5594,7 @@ Used to control when safehomes will be used. Possible values are `OFF`, `RTH` an ### sbus_sync_interval -_// TODO_ +SBUS sync interval in us. Default value is 3000us. Lower values may cause issues with some receivers. | Default | Min | Max | | --- | --- | --- | @@ -6214,7 +6214,7 @@ Some VTXes may report max power incorrectly (i.e. 200mW for a 600mW VTX). Use th ### vtx_pit_mode_chan -_// TODO_ +Pit mode channel. | Default | Min | Max | | --- | --- | --- | diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index 0afd4c8baef..0a3b7278dc9 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -303,6 +303,7 @@ groups: min: 1 max: 1000 - name: gyro_to_use + description: "On multi-gyro targets, allows to choose which gyro to use. 0 = first gyro, 1 = second gyro" condition: USE_DUAL_GYRO min: 0 max: 2 @@ -385,10 +386,12 @@ groups: headers: ["sensors/acceleration.h"] members: - name: acc_notch_hz + description: "Frequency of the software notch filter to remove mechanical vibrations from the accelerometer measurements. Value is center frequency (Hz)" min: 0 max: 255 default_value: 0 - name: acc_notch_cutoff + description: "Frequency of the software notch filter to remove mechanical vibrations from the accelerometer measurements. Value is cutoff frequency (Hz)" min: 1 max: 255 default_value: 1 @@ -468,6 +471,7 @@ groups: default_value: NONE table: opflow_hardware - name: opflow_scale + description: "Optical flow module scale factor" min: 0 max: 10000 default_value: 10.5 @@ -591,10 +595,12 @@ groups: default_value: "NONE" table: pitot_hardware - name: pitot_lpf_milli_hz + description: "Pitot tube lowpass filter cutoff frequency. Lower cutoff frequencies result in smoother response at expense of command control delay" min: 0 max: 10000 default_value: 350 - name: pitot_scale + description: "Pitot tube scale factor" min: 0 max: 100 default_value: 1.0 @@ -644,6 +650,7 @@ groups: max: RSSI_VISIBLE_VALUE_MAX - name: sbus_sync_interval field: sbusSyncInterval + description: "SBUS sync interval in us. Default value is 3000us. Lower values may cause issues with some receivers." min: 500 max: 10000 default_value: 3000 @@ -1366,6 +1373,7 @@ groups: min: MANUAL_RATE_MIN max: MANUAL_RATE_MAX - name: fpv_mix_degrees + description: "The tilt angle of the FPV camera in degrees, used by the FPV ANGLE MIX mode" field: misc.fpvCamAngleDegrees min: 0 max: 50 @@ -2053,6 +2061,7 @@ groups: max: 255 default_value: 100 - name: nav_mc_vel_xy_ff + description: "FF gain of Position-Rate (Velocity to Acceleration)" field: bank_mc.pid[PID_VEL_XY].FF min: 0 max: 255 @@ -2064,6 +2073,7 @@ groups: min: 0 max: 255 - name: nav_mc_vel_xy_dterm_lpf_hz + description: "D-term low pass filter cutoff frequency for horizontal velocity PID controller (Multirotor). It allows to smooth the PosHold CRUISE, WP and RTH when Multirotor is traveling at full speed. Dterm is not attenuated at low speeds, breaking and accelerating." field: navVelXyDTermLpfHz min: 0 max: 100 @@ -2153,33 +2163,39 @@ groups: min: PID_SUM_LIMIT_MIN max: PID_SUM_LIMIT_MAX - name: mc_iterm_relax + description: "Iterm relax type. When enabled, Iterm will be relaxed when stick is centered. This will help to reduce bounceback and followthrough on multirotors. It is recommended to enable this feature on all multirotors." field: iterm_relax table: iterm_relax default_value: RP - name: mc_iterm_relax_cutoff + description: "Iterm relax cutoff frequency." field: iterm_relax_cutoff min: 1 max: 100 default_value: 15 - name: d_boost_min + description: "D-term multiplier when pilot provides rapid stick input. Lower values give sharper response to stick input, higher values give smoother response." field: dBoostMin condition: USE_D_BOOST min: 0 max: 1 default_value: 0.5 - name: d_boost_max + description: "D-term multiplier when rapid external conditions are detected. Lower values give sharper response to stick input, higher values give smoother response by scaling D-gains up." field: dBoostMax condition: USE_D_BOOST min: 1 max: 3 default_value: 1.25 - name: d_boost_max_at_acceleration + description: "Acceleration threshold for D-term multiplier. When acceleration is above this value, D-term multiplier is set to `d_boost_max`" field: dBoostMaxAtAlleceleration condition: USE_D_BOOST min: 1000 max: 16000 default_value: 7500 - name: d_boost_gyro_delta_lpf_hz + description: "Cutoff frequency for the low pass filter applied to the gyro delta signal used for D-term boost. Lower value will produce a smoother D-term boost signal, but it will be more delayed." field: dBoostGyroDeltaLpfHz condition: USE_D_BOOST min: 10 @@ -2193,7 +2209,7 @@ groups: min: 1 max: 20 - name: antigravity_accelerator - description: "" + description: "Multiplier for Antigravity gain. The bigger is the difference between actual and filtered throttle input, the bigger Antigravity gain" default_value: 1 field: antigravityAccelerator condition: USE_ANTIGRAVITY @@ -2325,21 +2341,25 @@ groups: min: 0 max: 1000 - name: inav_w_z_surface_p + description: "Weight of rangefinder measurements in estimated altitude. Setting is used on both airplanes and multirotors when rangefinder is present and Surface mode enabled" field: w_z_surface_p min: 0 max: 100 default_value: 3.5 - name: inav_w_z_surface_v + description: "Weight of rangefinder measurements in estimated climb rate. Setting is used on both airplanes and multirotors when rangefinder is present and Surface mode enabled" field: w_z_surface_v min: 0 max: 100 default_value: 6.1 - name: inav_w_xy_flow_p + description: "Weight of optical flow measurements in estimated UAV position." field: w_xy_flow_p min: 0 max: 100 default_value: 1.0 - name: inav_w_xy_flow_v + description: "Weight of optical flow measurements in estimated UAV speed." field: w_xy_flow_v min: 0 max: 100 @@ -3068,35 +3088,41 @@ groups: max: INT16_MAX - name: mavlink_ext_status_rate field: mavlink.extended_status_rate + description: "Rate of the extended status message for MAVLink telemetry" type: uint8_t min: 0 max: 255 default_value: 2 - name: mavlink_rc_chan_rate + description: "Rate of the RC channels message for MAVLink telemetry" field: mavlink.rc_channels_rate type: uint8_t min: 0 max: 255 default_value: 5 - name: mavlink_pos_rate + description: "Rate of the position message for MAVLink telemetry" field: mavlink.position_rate type: uint8_t min: 0 max: 255 default_value: 2 - name: mavlink_extra1_rate + description: "Rate of the extra1 message for MAVLink telemetry" field: mavlink.extra1_rate type: uint8_t min: 0 max: 255 default_value: 10 - name: mavlink_extra2_rate + description: "Rate of the extra2 message for MAVLink telemetry" field: mavlink.extra2_rate type: uint8_t min: 0 max: 255 default_value: 2 - name: mavlink_extra3_rate + description: "Rate of the extra3 message for MAVLink telemetry" field: mavlink.extra3_rate type: uint8_t min: 0 @@ -3434,16 +3460,19 @@ groups: min: 0 max: 3 - name: osd_left_sidebar_scroll + description: "Scroll type for the left sidebar" field: left_sidebar_scroll table: osd_sidebar_scroll type: uint8_t default_value: NONE - name: osd_right_sidebar_scroll + description: "Scroll type for the right sidebar" field: right_sidebar_scroll table: osd_sidebar_scroll type: uint8_t default_value: NONE - name: osd_sidebar_scroll_arrows + description: "Show arrows for scrolling the sidebars" field: sidebar_scroll_arrows type: bool default_value: OFF @@ -3454,6 +3483,7 @@ groups: min: 1 max: 2 - name: osd_coordinate_digits + description: "Number of digits for the coordinates displayed in the OSD [8-11]." field: coordinate_digits min: 8 max: 11 @@ -3892,6 +3922,7 @@ groups: table: vtx_low_power_disarm type: uint8_t - name: vtx_pit_mode_chan + description: "Pit mode channel." field: pitModeChan min: VTX_SETTINGS_MIN_CHANNEL max: VTX_SETTINGS_MAX_CHANNEL From 244dd8337f648ffaf663b69339911688a2210e6c Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Wed, 20 Mar 2024 19:52:30 +0100 Subject: [PATCH 085/241] Drop ledstrip_visual_beeper as not used --- docs/Settings.md | 10 ---------- src/main/fc/settings.yaml | 10 ---------- src/main/io/ledstrip.c | 2 +- src/main/io/ledstrip.h | 1 - 4 files changed, 1 insertion(+), 22 deletions(-) diff --git a/docs/Settings.md b/docs/Settings.md index 79278af68f3..9b4644973c5 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -2042,16 +2042,6 @@ PWM mode of LED pin. --- -### ledstrip_visual_beeper - -_// TODO_ - -| Default | Min | Max | -| --- | --- | --- | -| OFF | OFF | ON | - ---- - ### limit_attn_filter_cutoff Throttle attenuation PI control output filter cutoff frequency diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index 0afd4c8baef..430473e2390 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -3110,16 +3110,6 @@ groups: max: 2 default_value: 2 - - name: PG_LED_STRIP_CONFIG - type: ledStripConfig_t - headers: ["common/color.h", "io/ledstrip.h"] - condition: USE_LED_STRIP - members: - - name: ledstrip_visual_beeper - description: "" - default_value: OFF - type: bool - - name: PG_OSD_CONFIG type: osdConfig_t headers: ["io/osd.h", "drivers/osd.h"] diff --git a/src/main/io/ledstrip.c b/src/main/io/ledstrip.c index 71c537b4c70..62c41683f02 100644 --- a/src/main/io/ledstrip.c +++ b/src/main/io/ledstrip.c @@ -73,7 +73,7 @@ #include "telemetry/telemetry.h" -PG_REGISTER_WITH_RESET_FN(ledStripConfig_t, ledStripConfig, PG_LED_STRIP_CONFIG, 1); +PG_REGISTER_WITH_RESET_FN(ledStripConfig_t, ledStripConfig, PG_LED_STRIP_CONFIG, 2); static bool ledStripInitialised = false; static bool ledStripEnabled = true; diff --git a/src/main/io/ledstrip.h b/src/main/io/ledstrip.h index 644409b9e0a..204a4661d17 100644 --- a/src/main/io/ledstrip.h +++ b/src/main/io/ledstrip.h @@ -153,7 +153,6 @@ typedef struct ledStripConfig_s { hsvColor_t colors[LED_CONFIGURABLE_COLOR_COUNT]; modeColorIndexes_t modeColors[LED_MODE_COUNT]; specialColorIndexes_t specialColors; - uint8_t ledstrip_visual_beeper; // suppress LEDLOW mode if beeper is on } ledStripConfig_t; PG_DECLARE(ledStripConfig_t, ledStripConfig); From 9a207966255a356240d7a4116851205bee1e5eff Mon Sep 17 00:00:00 2001 From: Marcelo Bezerra <23555060+mmosca@users.noreply.github.com> Date: Thu, 21 Mar 2024 12:30:14 +0100 Subject: [PATCH 086/241] Add ICM42688P to TMOTORF7V2 --- src/main/target/TMOTORF7V2/target.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/target/TMOTORF7V2/target.h b/src/main/target/TMOTORF7V2/target.h index 2691812f2fc..f5def98a403 100644 --- a/src/main/target/TMOTORF7V2/target.h +++ b/src/main/target/TMOTORF7V2/target.h @@ -67,6 +67,11 @@ #define USE_IMU_MPU6000 #define IMU_MPU6000_ALIGN CW0_DEG +#define USE_IMU_ICM42605 +#define IMU_ICM42605_ALIGN CW0_DEG +#define ICM42605_CS_PIN PA4 +#define ICM42605_SPI_BUS BUS_SPI1 + // OSD -- SPI2 #define USE_SPI_DEVICE_2 #define SPI2_SCK_PIN PB13 From 681168b7c02b5afa5825554f6571579aba5321ab Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Thu, 21 Mar 2024 13:18:41 +0100 Subject: [PATCH 087/241] Add EzTune to CMS menu --- src/main/cms/cms_menu_imu.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/main/cms/cms_menu_imu.c b/src/main/cms/cms_menu_imu.c index 7612ec44181..ce40d320c4e 100644 --- a/src/main/cms/cms_menu_imu.c +++ b/src/main/cms/cms_menu_imu.c @@ -137,6 +137,30 @@ static long cmsx_PidWriteback(const OSD_Entry *self) return 0; } +static const OSD_Entry cmsx_menuEzTuneEntries[] = +{ + OSD_LABEL_DATA_ENTRY("-- EZTUNE --", profileIndexString), + + OSD_SETTING_ENTRY("ENABLED", SETTING_EZ_ENABLED), + OSD_SETTING_ENTRY("FILTER HZ", SETTING_EZ_FILTER_HZ), + OSD_SETTING_ENTRY("RATIO", SETTING_EZ_AXIS_RATIO), + OSD_SETTING_ENTRY("RESP.", SETTING_EZ_RESPONSE), + OSD_SETTING_ENTRY("DAMP.", SETTING_EZ_DAMPING), + OSD_SETTING_ENTRY("STAB.", SETTING_EZ_STABILITY), + OSD_SETTING_ENTRY("AGGR.", SETTING_EZ_AGGRESSIVENESS), + OSD_SETTING_ENTRY("RATE", SETTING_EZ_RATE), + OSD_SETTING_ENTRY("EXPO", SETTING_EZ_EXPO), + + OSD_BACK_AND_END_ENTRY, +}; + +static const CMS_Menu cmsx_menuEzTune = { + .onEnter = NULL, + .onExit = NULL, + .onGlobalExit = NULL, + .entries = cmsx_menuEzTuneEntries +}; + static const OSD_Entry cmsx_menuPidEntries[] = { OSD_LABEL_DATA_ENTRY("-- PID --", profileIndexString), @@ -458,6 +482,7 @@ static const OSD_Entry cmsx_menuImuEntries[] = // Profile dependent OSD_UINT8_CALLBACK_ENTRY("PID PROF", cmsx_profileIndexOnChange, (&(const OSD_UINT8_t){ &tmpProfileIndex, 1, MAX_PROFILE_COUNT, 1})), + OSD_SUBMENU_ENTRY("EZTUNE", &cmsx_menuEzTune), OSD_SUBMENU_ENTRY("PID", &cmsx_menuPid), OSD_SUBMENU_ENTRY("PID ALTMAG", &cmsx_menuPidAltMag), OSD_SUBMENU_ENTRY("PID GPSNAV", &cmsx_menuPidGpsnav), From 193d988e0e18886b3224a0c4e35330aac30e831c Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Thu, 21 Mar 2024 13:27:08 +0100 Subject: [PATCH 088/241] Fix missing EzTune settings in dump and diff --- src/main/fc/cli.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/fc/cli.c b/src/main/fc/cli.c index ea09c5776d6..48345583412 100644 --- a/src/main/fc/cli.c +++ b/src/main/fc/cli.c @@ -3359,6 +3359,7 @@ static void cliDumpProfile(uint8_t profileIndex, uint8_t dumpMask) cliPrintLinef("profile %d\r\n", getConfigProfile() + 1); dumpAllValues(PROFILE_VALUE, dumpMask); dumpAllValues(CONTROL_RATE_VALUE, dumpMask); + dumpAllValues(EZ_TUNE_VALUE, dumpMask); } static void cliBatteryProfile(char *cmdline) From f4462452696a35b4523ab1d275422c3b77297f88 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Thu, 21 Mar 2024 13:27:08 +0100 Subject: [PATCH 089/241] Fix missing EzTune settings in dump and diff --- src/main/fc/cli.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/fc/cli.c b/src/main/fc/cli.c index 7b9445c5baa..6c5d2709e7a 100644 --- a/src/main/fc/cli.c +++ b/src/main/fc/cli.c @@ -3354,6 +3354,7 @@ static void cliDumpProfile(uint8_t profileIndex, uint8_t dumpMask) cliPrintLinef("profile %d\r\n", getConfigProfile() + 1); dumpAllValues(PROFILE_VALUE, dumpMask); dumpAllValues(CONTROL_RATE_VALUE, dumpMask); + dumpAllValues(EZ_TUNE_VALUE, dumpMask); } static void cliBatteryProfile(char *cmdline) From e8f1e917ccaf58c2c666064ea320657dfb5d5f9c Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Thu, 21 Mar 2024 15:21:46 +0100 Subject: [PATCH 090/241] BETAFPVF411 --- src/main/target/BETAFPVF411/CMakeLists.txt | 1 + src/main/target/BETAFPVF411/target.c | 34 ++++++ src/main/target/BETAFPVF411/target.h | 128 +++++++++++++++++++++ 3 files changed, 163 insertions(+) create mode 100644 src/main/target/BETAFPVF411/CMakeLists.txt create mode 100644 src/main/target/BETAFPVF411/target.c create mode 100644 src/main/target/BETAFPVF411/target.h diff --git a/src/main/target/BETAFPVF411/CMakeLists.txt b/src/main/target/BETAFPVF411/CMakeLists.txt new file mode 100644 index 00000000000..087194803cc --- /dev/null +++ b/src/main/target/BETAFPVF411/CMakeLists.txt @@ -0,0 +1 @@ +target_stm32f411xe(BETAFPVF411 SKIP_RELEASES) \ No newline at end of file diff --git a/src/main/target/BETAFPVF411/target.c b/src/main/target/BETAFPVF411/target.c new file mode 100644 index 00000000000..58e44f9780f --- /dev/null +++ b/src/main/target/BETAFPVF411/target.c @@ -0,0 +1,34 @@ +/* + * 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 "drivers/io.h" +#include "drivers/dma.h" +#include "drivers/timer.h" +#include "drivers/bus.h" +#include "drivers/pwm_mapping.h" + + +timerHardware_t timerHardware[] = { + DEF_TIM(TIM3, CH1, PB4, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM3, CH2, PB5, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM4, CH1, PB6, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM4, CH2, PB7, TIM_USE_OUTPUT_AUTO, 0, 0), +}; + +const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]); diff --git a/src/main/target/BETAFPVF411/target.h b/src/main/target/BETAFPVF411/target.h new file mode 100644 index 00000000000..6d2255b74be --- /dev/null +++ b/src/main/target/BETAFPVF411/target.h @@ -0,0 +1,128 @@ +/* + * 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 . + */ + +#pragma once + +#define TARGET_BOARD_IDENTIFIER "B411" +#define USBD_PRODUCT_STRING "BETAFPVF411" + +#define LED0 PC13 + +#define BEEPER PB2 +#define BEEPER_INVERTED + +// *************** SPI ********************** +#define USE_SPI +#define USE_SPI_DEVICE_1 +#define SPI1_SCK_PIN PA5 +#define SPI1_MISO_PIN PA6 +#define SPI1_MOSI_PIN PA7 + +#define USE_SPI_DEVICE_2 +#define SPI2_SCK_PIN PB13 +#define SPI2_MISO_PIN PB14 +#define SPI2_MOSI_PIN PB15 + +// *************** SPI Gyro & ACC ********************** +#define USE_IMU_MPU6000 +#define MPU6000_CS_PIN PA4 +#define MPU6000_SPI_BUS BUS_SPI1 +#define IMU_MPU6000_ALIGN CW180_DEG + +#define USE_IMU_BMI270 +#define IMU_BMI270_ALIGN CW180_DEG +#define BMI270_SPI_BUS BUS_SPI1 +#define BMI270_CS_PIN PA4 + +// *************** Baro ***************************** + +#define USE_I2C +#define USE_I2C_DEVICE_1 +#define I2C1_SCL PB8 +#define I2C1_SDA PB9 + +#define USE_BARO +#define BARO_I2C_BUS BUS_I2C1 +#define USE_BARO_ALL + +#define USE_MAG +#define MAG_I2C_BUS BUS_I2C1 +#define USE_MAG_ALL + +// *************** SPI OSD ***************************** +#define USE_MAX7456 +#define MAX7456_SPI_BUS BUS_SPI2 +#define MAX7456_CS_PIN PB12 + +// *************** SPI FLASH ************************** +#define USE_FLASHFS +#define USE_FLASH_M25P16 +#define M25P16_CS_PIN PB2 +#define M25P16_SPI_BUS BUS_SPI2 +#define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT + +// *************** UART ***************************** +#define USE_VCP + +#define USE_UART1 +#define UART1_TX_PIN PA9 +#define UART1_RX_PIN PA10 + +#define USE_UART2 +#define UART2_TX_PIN PA2 +#define UART2_RX_PIN PA3 + +#define USE_SOFTSERIAL1 +#define SOFTSERIAL_1_TX_PIN PB3 +#define SOFTSERIAL_1_RX_PIN PB3 + +#define USE_SOFTSERIAL2 +#define SOFTSERIAL_2_TX_PIN PB10 +#define SOFTSERIAL_2_RX_PIN PB10 + +#define SERIAL_PORT_COUNT 5 + +#define DEFAULT_RX_TYPE RX_TYPE_SERIAL +#define SERIALRX_PROVIDER SERIALRX_CRSF +#define SERIALRX_UART SERIAL_PORT_USART1 + +// *************** ADC ***************************** +#define USE_ADC +#define ADC_INSTANCE ADC1 +#define ADC_CHANNEL_1_PIN PA0 +#define ADC_CHANNEL_2_PIN PB1 + +#define CURRENT_METER_ADC_CHANNEL ADC_CHN_2 +#define VBAT_ADC_CHANNEL ADC_CHN_1 + +// *************** LED2812 ************************ +#define USE_LED_STRIP +#define WS2811_PIN PA8 + +// *************** OTHERS ************************* +#define DEFAULT_FEATURES (FEATURE_TX_PROF_SEL | FEATURE_OSD | FEATURE_VBAT | FEATURE_TELEMETRY | FEATURE_BLACKBOX) + +#define USE_DSHOT +#define USE_ESC_SENSOR +#define USE_SERIAL_4WAY_BLHELI_INTERFACE + +#define TARGET_IO_PORTA 0xffff +#define TARGET_IO_PORTB 0xffff +#define TARGET_IO_PORTC 0xffff +#define TARGET_IO_PORTD (BIT(2)) + +#define MAX_PWM_OUTPUT_PORTS 4 From 5fc77ceda677f94f44422d9552d2d05470d59a78 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Thu, 21 Mar 2024 16:01:39 +0100 Subject: [PATCH 091/241] Target update --- src/main/target/BETAFPVF411/target.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/target/BETAFPVF411/target.h b/src/main/target/BETAFPVF411/target.h index 6d2255b74be..55542082bfa 100644 --- a/src/main/target/BETAFPVF411/target.h +++ b/src/main/target/BETAFPVF411/target.h @@ -123,6 +123,6 @@ #define TARGET_IO_PORTA 0xffff #define TARGET_IO_PORTB 0xffff #define TARGET_IO_PORTC 0xffff -#define TARGET_IO_PORTD (BIT(2)) +#define TARGET_IO_PORTD 0xffff #define MAX_PWM_OUTPUT_PORTS 4 From c3a7cbe17c20ac676ed9fc97901fd55cfacb7d83 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Thu, 21 Mar 2024 21:08:20 +0100 Subject: [PATCH 092/241] Target fixes --- src/main/target/BETAFPVF411/target.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/target/BETAFPVF411/target.h b/src/main/target/BETAFPVF411/target.h index 55542082bfa..1f57281d2f4 100644 --- a/src/main/target/BETAFPVF411/target.h +++ b/src/main/target/BETAFPVF411/target.h @@ -44,7 +44,7 @@ #define IMU_MPU6000_ALIGN CW180_DEG #define USE_IMU_BMI270 -#define IMU_BMI270_ALIGN CW180_DEG +#define IMU_BMI270_ALIGN CW90_DEG #define BMI270_SPI_BUS BUS_SPI1 #define BMI270_CS_PIN PA4 @@ -103,11 +103,13 @@ // *************** ADC ***************************** #define USE_ADC #define ADC_INSTANCE ADC1 -#define ADC_CHANNEL_1_PIN PA0 +#define ADC_CHANNEL_1_PIN PB0 #define ADC_CHANNEL_2_PIN PB1 -#define CURRENT_METER_ADC_CHANNEL ADC_CHN_2 #define VBAT_ADC_CHANNEL ADC_CHN_1 +#define CURRENT_METER_ADC_CHANNEL ADC_CHN_2 + +#define VBAT_SCALE_DEFAULT 1100 // *************** LED2812 ************************ #define USE_LED_STRIP From 12f6ee7f97e530f2141a7d85a8aac7ac13203c88 Mon Sep 17 00:00:00 2001 From: b14ckyy <33039058+b14ckyy@users.noreply.github.com> Date: Fri, 22 Mar 2024 10:41:01 +0100 Subject: [PATCH 093/241] Fixes ADC for RSSI and Aspd swapped --- src/main/target/SPEEDYBEEF405WING/target.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/target/SPEEDYBEEF405WING/target.h b/src/main/target/SPEEDYBEEF405WING/target.h index 1684faabce1..9da5b115824 100644 --- a/src/main/target/SPEEDYBEEF405WING/target.h +++ b/src/main/target/SPEEDYBEEF405WING/target.h @@ -148,8 +148,8 @@ #define ADC_CHANNEL_4_PIN PC4 #define VBAT_ADC_CHANNEL ADC_CHN_1 #define CURRENT_METER_ADC_CHANNEL ADC_CHN_2 -#define RSSI_ADC_CHANNEL ADC_CHN_4 -#define AIRSPEED_ADC_CHANNEL ADC_CHN_3 +#define RSSI_ADC_CHANNEL ADC_CHN_3 +#define AIRSPEED_ADC_CHANNEL ADC_CHN_4 // *************** LED2812 ************************ #define USE_LED_STRIP @@ -172,4 +172,4 @@ #define USE_PINIO #define USE_PINIOBOX -#define PINIO1_PIN PC13 \ No newline at end of file +#define PINIO1_PIN PC13 From c9e0fc4ce3b0ac59082849fe543aa336ebd03252 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Spychalski?= Date: Fri, 22 Mar 2024 11:15:08 +0100 Subject: [PATCH 094/241] Merge pull request #9815 from iNavFlight/dzikuvx-betafpvf411 Betafpvf411 unofficial --- src/main/target/BETAFPVF411/CMakeLists.txt | 1 + src/main/target/BETAFPVF411/target.c | 34 ++++++ src/main/target/BETAFPVF411/target.h | 130 +++++++++++++++++++++ 3 files changed, 165 insertions(+) create mode 100644 src/main/target/BETAFPVF411/CMakeLists.txt create mode 100644 src/main/target/BETAFPVF411/target.c create mode 100644 src/main/target/BETAFPVF411/target.h diff --git a/src/main/target/BETAFPVF411/CMakeLists.txt b/src/main/target/BETAFPVF411/CMakeLists.txt new file mode 100644 index 00000000000..087194803cc --- /dev/null +++ b/src/main/target/BETAFPVF411/CMakeLists.txt @@ -0,0 +1 @@ +target_stm32f411xe(BETAFPVF411 SKIP_RELEASES) \ No newline at end of file diff --git a/src/main/target/BETAFPVF411/target.c b/src/main/target/BETAFPVF411/target.c new file mode 100644 index 00000000000..58e44f9780f --- /dev/null +++ b/src/main/target/BETAFPVF411/target.c @@ -0,0 +1,34 @@ +/* + * 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 "drivers/io.h" +#include "drivers/dma.h" +#include "drivers/timer.h" +#include "drivers/bus.h" +#include "drivers/pwm_mapping.h" + + +timerHardware_t timerHardware[] = { + DEF_TIM(TIM3, CH1, PB4, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM3, CH2, PB5, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM4, CH1, PB6, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM4, CH2, PB7, TIM_USE_OUTPUT_AUTO, 0, 0), +}; + +const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]); diff --git a/src/main/target/BETAFPVF411/target.h b/src/main/target/BETAFPVF411/target.h new file mode 100644 index 00000000000..1f57281d2f4 --- /dev/null +++ b/src/main/target/BETAFPVF411/target.h @@ -0,0 +1,130 @@ +/* + * 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 . + */ + +#pragma once + +#define TARGET_BOARD_IDENTIFIER "B411" +#define USBD_PRODUCT_STRING "BETAFPVF411" + +#define LED0 PC13 + +#define BEEPER PB2 +#define BEEPER_INVERTED + +// *************** SPI ********************** +#define USE_SPI +#define USE_SPI_DEVICE_1 +#define SPI1_SCK_PIN PA5 +#define SPI1_MISO_PIN PA6 +#define SPI1_MOSI_PIN PA7 + +#define USE_SPI_DEVICE_2 +#define SPI2_SCK_PIN PB13 +#define SPI2_MISO_PIN PB14 +#define SPI2_MOSI_PIN PB15 + +// *************** SPI Gyro & ACC ********************** +#define USE_IMU_MPU6000 +#define MPU6000_CS_PIN PA4 +#define MPU6000_SPI_BUS BUS_SPI1 +#define IMU_MPU6000_ALIGN CW180_DEG + +#define USE_IMU_BMI270 +#define IMU_BMI270_ALIGN CW90_DEG +#define BMI270_SPI_BUS BUS_SPI1 +#define BMI270_CS_PIN PA4 + +// *************** Baro ***************************** + +#define USE_I2C +#define USE_I2C_DEVICE_1 +#define I2C1_SCL PB8 +#define I2C1_SDA PB9 + +#define USE_BARO +#define BARO_I2C_BUS BUS_I2C1 +#define USE_BARO_ALL + +#define USE_MAG +#define MAG_I2C_BUS BUS_I2C1 +#define USE_MAG_ALL + +// *************** SPI OSD ***************************** +#define USE_MAX7456 +#define MAX7456_SPI_BUS BUS_SPI2 +#define MAX7456_CS_PIN PB12 + +// *************** SPI FLASH ************************** +#define USE_FLASHFS +#define USE_FLASH_M25P16 +#define M25P16_CS_PIN PB2 +#define M25P16_SPI_BUS BUS_SPI2 +#define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT + +// *************** UART ***************************** +#define USE_VCP + +#define USE_UART1 +#define UART1_TX_PIN PA9 +#define UART1_RX_PIN PA10 + +#define USE_UART2 +#define UART2_TX_PIN PA2 +#define UART2_RX_PIN PA3 + +#define USE_SOFTSERIAL1 +#define SOFTSERIAL_1_TX_PIN PB3 +#define SOFTSERIAL_1_RX_PIN PB3 + +#define USE_SOFTSERIAL2 +#define SOFTSERIAL_2_TX_PIN PB10 +#define SOFTSERIAL_2_RX_PIN PB10 + +#define SERIAL_PORT_COUNT 5 + +#define DEFAULT_RX_TYPE RX_TYPE_SERIAL +#define SERIALRX_PROVIDER SERIALRX_CRSF +#define SERIALRX_UART SERIAL_PORT_USART1 + +// *************** ADC ***************************** +#define USE_ADC +#define ADC_INSTANCE ADC1 +#define ADC_CHANNEL_1_PIN PB0 +#define ADC_CHANNEL_2_PIN PB1 + +#define VBAT_ADC_CHANNEL ADC_CHN_1 +#define CURRENT_METER_ADC_CHANNEL ADC_CHN_2 + +#define VBAT_SCALE_DEFAULT 1100 + +// *************** LED2812 ************************ +#define USE_LED_STRIP +#define WS2811_PIN PA8 + +// *************** OTHERS ************************* +#define DEFAULT_FEATURES (FEATURE_TX_PROF_SEL | FEATURE_OSD | FEATURE_VBAT | FEATURE_TELEMETRY | FEATURE_BLACKBOX) + +#define USE_DSHOT +#define USE_ESC_SENSOR +#define USE_SERIAL_4WAY_BLHELI_INTERFACE + +#define TARGET_IO_PORTA 0xffff +#define TARGET_IO_PORTB 0xffff +#define TARGET_IO_PORTC 0xffff +#define TARGET_IO_PORTD 0xffff + +#define MAX_PWM_OUTPUT_PORTS 4 From 6ba1a1402ad1995cad449b0b447e52180ab8198f Mon Sep 17 00:00:00 2001 From: TUNERC-Aria <71423100+TUNERC-Aria@users.noreply.github.com> Date: Fri, 22 Mar 2024 18:23:59 +0800 Subject: [PATCH 095/241] Create TUNERCF405 CMakeLists.txt --- src/main/target/TUNERCF405/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/main/target/TUNERCF405/CMakeLists.txt diff --git a/src/main/target/TUNERCF405/CMakeLists.txt b/src/main/target/TUNERCF405/CMakeLists.txt new file mode 100644 index 00000000000..ba4e9fd3cd3 --- /dev/null +++ b/src/main/target/TUNERCF405/CMakeLists.txt @@ -0,0 +1 @@ +target_stm32f405xg(TUNERCF405) From 755a26f28b6120ed88384621650e2217a416786d Mon Sep 17 00:00:00 2001 From: TUNERC-Aria <71423100+TUNERC-Aria@users.noreply.github.com> Date: Fri, 22 Mar 2024 18:24:36 +0800 Subject: [PATCH 096/241] add TUNERCF405 define file --- src/main/target/TUNERCF405/target.c | 39 ++++++++ src/main/target/TUNERCF405/target.h | 137 ++++++++++++++++++++++++++++ 2 files changed, 176 insertions(+) create mode 100644 src/main/target/TUNERCF405/target.c create mode 100644 src/main/target/TUNERCF405/target.h diff --git a/src/main/target/TUNERCF405/target.c b/src/main/target/TUNERCF405/target.c new file mode 100644 index 00000000000..bc0b4e86f65 --- /dev/null +++ b/src/main/target/TUNERCF405/target.c @@ -0,0 +1,39 @@ +/* + * This file is part of INAV Project. + * + * 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 "drivers/io.h" +#include "drivers/pwm_mapping.h" +#include "drivers/timer.h" + +timerHardware_t timerHardware[] = { + DEF_TIM(TIM1, CH2N, PB0, TIM_USE_MOTOR, 0, 0), //D2s6 + DEF_TIM(TIM1, CH1, PA8, TIM_USE_MOTOR, 0, 0), //D2s6 + DEF_TIM(TIM4, CH3, PB8, TIM_USE_MOTOR, 0, 0), //D1s7 + DEF_TIM(TIM2, CH1, PA15, TIM_USE_MOTOR, 0, 0), //D1s5 + + DEF_TIM(TIM8, CH4, PC9, TIM_USE_OUTPUT_AUTO, 0, 0), //D2s7 + DEF_TIM(TIM8, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 0), //D2s2 / D2s4 + DEF_TIM(TIM8, CH2, PC7, TIM_USE_OUTPUT_AUTO, 0, 0), //D2s2 + DEF_TIM(TIM8, CH1, PC6, TIM_USE_OUTPUT_AUTO, 0, 0), //D2s2 + + DEF_TIM(TIM3, CH4, PB1, TIM_USE_LED, 0, 0), +}; + +const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]); diff --git a/src/main/target/TUNERCF405/target.h b/src/main/target/TUNERCF405/target.h new file mode 100644 index 00000000000..f193377c6ea --- /dev/null +++ b/src/main/target/TUNERCF405/target.h @@ -0,0 +1,137 @@ +/* + * This file is part of INAV Project. + * + * 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 . + */ + +#pragma once + +#define TARGET_BOARD_IDENTIFIER "TURC" + +#define USBD_PRODUCT_STRING "TUNERCF405" + +// Indicators +#define LED0 PB9 + +#define BEEPER PB2 +#define BEEPER_INVERTED + +// WS2812 +#define USE_LED_STRIP +#define WS2811_PIN PB1 + +// Gyro & ACC +#define USE_SPI +#define USE_SPI_DEVICE_1 + +#define SPI1_NSS_PIN PA4 +#define SPI1_SCK_PIN PA5 +#define SPI1_MISO_PIN PA6 +#define SPI1_MOSI_PIN PA7 + +#define USE_IMU_BMI270 +#define IMU_BMI270_ALIGN CW180_DEG +#define BMI270_CS_PIN SPI1_NSS_PIN +#define BMI270_SPI_BUS BUS_SPI1 + +// OSD +#define USE_SPI_DEVICE_2 +#define SPI2_NSS_PIN PB12 +#define SPI2_SCK_PIN PB13 +#define SPI2_MISO_PIN PB14 +#define SPI2_MOSI_PIN PB15 + +#define USE_MAX7456 +#define MAX7456_SPI_BUS BUS_SPI2 +#define MAX7456_CS_PIN SPI2_NSS_PIN + +// Onboard Flash +#define USE_SPI_DEVICE_3 +#define SPI3_SCK_PIN PB3 +#define SPI3_MISO_PIN PB4 +#define SPI3_MOSI_PIN PB5 + +#define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT +#define USE_FLASHFS +#define USE_FLASH_M25P16 //W25Q32JVXGIQ TR +#define M25P16_SPI_BUS BUS_SPI3 +#define M25P16_CS_PIN PB6 + +// IIC +#define USE_I2C +#define USE_I2C_DEVICE_2 +#define I2C1_SCL PB10 +#define I2C1_SDA PB11 + +#define USE_BARO +#define BARO_I2C_BUS BUS_I2C2 +#define USE_BARO_BMP280 +#define USE_BARO_DPS310 + +#define USE_MAG +#define MAG_I2C_BUS BUS_I2C2 +#define USE_MAG_ALL + +// Serial ports +#define USE_VCP +#define VBUS_SENSING_PIN PB7 +#define VBUS_SENSING_ENABLED + +#define USE_UART1 +#define UART1_RX_PIN PA10 +#define UART1_TX_PIN PA9 + +#define USE_UART2 +#define UART2_RX_PIN PA3 +#define UART2_TX_PIN PA2 + +#define USE_UART3 +#define UART3_RX_PIN PC11 +#define UART3_TX_PIN PC10 + +#define USE_UART4 +#define UART4_RX_PIN PA1 +#define UART4_TX_PIN PA0 + +#define USE_UART5 +#define UART5_RX_PIN PD2 +#define UART5_TX_PIN PC12 + +#define SERIAL_PORT_COUNT 6 + +#define DEFAULT_RX_TYPE RX_TYPE_SERIAL +#define SERIALRX_PROVIDER SERIALRX_CRSF + +// ADC +#define USE_ADC +#define ADC_CHANNEL_1_PIN PC0 +#define ADC_CHANNEL_2_PIN PC1 + +#define VBAT_ADC_CHANNEL ADC_CHN_1 +#define CURRENT_METER_ADC_CHANNEL ADC_CHN_2 +#define CURRENT_METER_SCALE 453 + +// SET +#define DEFAULT_FEATURES (FEATURE_OSD | FEATURE_CURRENT_METER | FEATURE_VBAT ) +#define USE_DSHOT +#define USE_DSHOT_DMAR +#define USE_SERIAL_4WAY_BLHELI_INTERFACE + +#define MAX_PWM_OUTPUT_PORTS 8 +#define TARGET_MOTOR_COUNT 8 + +#define TARGET_IO_PORTA 0xffff +#define TARGET_IO_PORTB 0xffff +#define TARGET_IO_PORTC 0xffff +#define TARGET_IO_PORTD 0xffff From 7bd1f279432df05d411b9d37c1662c4c0a2f9aa5 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Fri, 22 Mar 2024 15:26:16 +0100 Subject: [PATCH 097/241] Minor readme update --- readme.md | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/readme.md b/readme.md index 724f1a88c14..e30d2fcc8d1 100644 --- a/readme.md +++ b/readme.md @@ -12,24 +12,23 @@ * [INAV Discord Server](https://discord.gg/peg2hhbYwN) * [INAV Official on Facebook](https://www.facebook.com/groups/INAVOfficial) -* [INAV Official on Telegram](https://t.me/INAVFlight) ## Features * Runs on the most popular F4, F7 and H7 flight controllers -* On Screen Display (OSD) - both character and pixel style -* DJI OSD integration: all elements, system messages and warnings +* MSP Displayport for all the HD Digital FPV systems: DJI, Walksnail and HDZero * Outstanding performance out of the box * Position Hold, Altitude Hold, Return To Home and Waypoint Missions * Excellent support for fixed wing UAVs: airplanes, flying wings +* Blackbox flight recorder logging +* Advanced gyro filtering * Fully configurable mixer that allows to run any hardware you want: multirotor, fixed wing, rovers, boats and other experimental devices * Multiple sensor support: GPS, Pitot tube, sonar, lidar, temperature, ESC with BlHeli_32 telemetry +* Logic Conditions, Global Functions and Global Variables: you can program INAV with a GUI * SmartAudio and IRC Tramp VTX support -* Blackbox flight recorder logging * Telemetry: SmartPort, FPort, MAVlink, LTM, CRSF * Multi-color RGB LED Strip support -* Advanced gyro filtering -* Logic Conditions, Global Functions and Global Variables: you can program INAV with a GUI +* On Screen Display (OSD) - both character and pixel style * And many more! For a list of features, changes and some discussion please review consult the releases [page](https://github.com/iNavFlight/inav/releases) and the documentation. @@ -52,10 +51,6 @@ Command line tools (`blackbox_decode`, `blackbox_render`) for Blackbox log conve Users of EdgeTX and OpenTX radios (Taranis, Horus, Jumper, Radiomaster, Nirvana) can use INAV OpenTX Telemetry Widget screen. Software and installation instruction are available here: [https://github.com/iNavFlight/OpenTX-Telemetry-Widget](https://github.com/iNavFlight/OpenTX-Telemetry-Widget) -### INAV magnetometer alignment helper - -[INAV Magnetometer Alignment helper](https://kernel-machine.github.io/INavMagAlignHelper/) allows to align INAV magnetometer despite position and orientation. This simplifies the process of INAV setup on multirotors with tilted GPS modules. - ### OSD layout Copy, Move, or Replace helper tool [Easy INAV OSD switcher tool](https://www.mrd-rc.com/tutorials-tools-and-testing/useful-tools/inav-osd-switcher-tool/) allows you to easily switch your OSD layouts around in INAV. Choose the from and to OSD layouts, and the method of transfering the layouts. From ce79c3dbb4ee33221acad35751dc4a409c5b3dbe Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Fri, 22 Mar 2024 15:41:14 +0100 Subject: [PATCH 098/241] Fix compilation error in osd.c --- src/main/io/osd.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 3436de93ed1..f5f9e1f815b 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -5073,7 +5073,6 @@ static void osdRefresh(timeUs_t currentTimeUs) osdShowStats(statsSinglePageCompatible, statsCurrentPage); } } - } // Handle events when either "Splash", "Armed" or "Stats" screens are displayed. if ((currentTimeUs > resumeRefreshAt) || OSD_RESUME_UPDATES_STICK_COMMAND) { From 130d0cf725e8fc2f9360ecbb0f759d5d769a6969 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Fri, 22 Mar 2024 15:51:32 +0100 Subject: [PATCH 099/241] Fix compilation error in navigation.c --- src/main/navigation/navigation.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/navigation/navigation.c b/src/main/navigation/navigation.c index 4bc4cece477..9d629f1a09d 100644 --- a/src/main/navigation/navigation.c +++ b/src/main/navigation/navigation.c @@ -3999,7 +3999,7 @@ bool isWaypointNavTrackingActive(void) return FLIGHT_MODE(NAV_WP_MODE) || posControl.navState == NAV_STATE_FW_LANDING_APPROACH - || (posControl.flags.rthTrackbackActive && posControl.activeRthTBPointIndex != posControl.rthTBLastSavedIndex); + || (posControl.flags.rthTrackbackActive && rth_trackback.activePointIndex != rth_trackback.lastSavedIndex); } /*----------------------------------------------------------- From 447cc8f89c7ce6f08989845272c9d76b27c8d41a Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Fri, 22 Mar 2024 16:25:25 +0100 Subject: [PATCH 100/241] Disable CLI help -> saves 3kB of flash --- src/main/target/common.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/target/common.h b/src/main/target/common.h index 8bbaadef718..99139eb4c40 100644 --- a/src/main/target/common.h +++ b/src/main/target/common.h @@ -202,4 +202,9 @@ #elif !defined(STM32F7) #define MAX_MIXER_PROFILE_COUNT 1 #endif + +#if (MCU_FLASH_SIZE <= 512) + #define SKIP_CLI_COMMAND_HELP +#endif + #define USE_EZ_TUNE From 0be5a0db8c29395035eb0945a3076de50ede5d49 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Fri, 22 Mar 2024 16:56:39 +0100 Subject: [PATCH 101/241] Enable spektrum bind only if spektrum is enabled --- src/main/fc/fc_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/fc/fc_init.c b/src/main/fc/fc_init.c index 154b231291f..2839a338f22 100644 --- a/src/main/fc/fc_init.c +++ b/src/main/fc/fc_init.c @@ -249,7 +249,7 @@ void init(void) EXTIInit(); #endif -#ifdef USE_SPEKTRUM_BIND +#if defined(USE_SPEKTRUM_BIND) && defined(USE_SERIALRX_SPEKTRUM) if (rxConfig()->receiverType == RX_TYPE_SERIAL) { switch (rxConfig()->serialrx_provider) { case SERIALRX_SPEKTRUM1024: From 061d76aff7d8ce3cbb3b2ad54e9a816c818dfbe9 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Fri, 22 Mar 2024 19:49:33 +0100 Subject: [PATCH 102/241] Remove SPEKTRUM and SRLX telemetry from F411 and F722 targets --- src/main/target/common.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/target/common.h b/src/main/target/common.h index 99139eb4c40..ec05d1e145e 100644 --- a/src/main/target/common.h +++ b/src/main/target/common.h @@ -205,6 +205,8 @@ #if (MCU_FLASH_SIZE <= 512) #define SKIP_CLI_COMMAND_HELP + #undef USE_SERIALRX_SPEKTRUM + #undef USE_TELEMETRY_SRXL #endif #define USE_EZ_TUNE From f9d12a230a036c3d6796c2aa733801d12586878e Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Fri, 22 Mar 2024 20:01:09 +0100 Subject: [PATCH 103/241] No longer require MAG to unlock GPS related flight modes --- src/main/fc/fc_msp_box.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/fc/fc_msp_box.c b/src/main/fc/fc_msp_box.c index c61c2aa19e9..f1c72458bff 100644 --- a/src/main/fc/fc_msp_box.c +++ b/src/main/fc/fc_msp_box.c @@ -220,9 +220,6 @@ void initActiveBoxIds(void) const bool navFlowDeadReckoning = sensors(SENSOR_OPFLOW) && sensors(SENSOR_ACC) && positionEstimationConfig()->allow_dead_reckoning; bool navReadyPosControl = sensors(SENSOR_ACC) && feature(FEATURE_GPS); - if (STATE(MULTIROTOR)) { - navReadyPosControl = navReadyPosControl && getHwCompassStatus() != HW_SENSOR_NONE; - } if (STATE(ALTITUDE_CONTROL) && navReadyAltControl && (navReadyPosControl || navFlowDeadReckoning)) { ADD_ACTIVE_BOX(BOXNAVPOSHOLD); From 839f7c0fd05af05fbd74ef17fb86368e5d890dd2 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Sat, 23 Mar 2024 12:33:04 +0100 Subject: [PATCH 104/241] Some updates to development docs --- docs/development/Building in Docker.md | 2 ++ docs/development/Building in Vagrant.md | 2 ++ docs/development/Building in Windows 10 or 11 with MSYS2.md | 3 +++ ...ows light.md => [Deprecated] Building in Windows light.md} | 4 ++++ 4 files changed, 11 insertions(+) rename docs/development/{Building in Windows light.md => [Deprecated] Building in Windows light.md} (96%) diff --git a/docs/development/Building in Docker.md b/docs/development/Building in Docker.md index 575614a95d1..fe3723359f4 100755 --- a/docs/development/Building in Docker.md +++ b/docs/development/Building in Docker.md @@ -1,5 +1,7 @@ # Building with Docker +> **On Windows building with this method is not advised and should be used only if Windows Linux Subsystem can not be used. In all other cases all Windows users should be using Linux Subsystem (WSL) instead** + Building with [Docker](https://www.docker.com/) is remarkably easy: an isolated container will hold all the needed compilation tools so that they won't interfere with your system and you won't need to install and manage them by yourself. You'll only need to have Docker itself [installed](https://docs.docker.com/install/). The first time that you'll run a build it will take a little more time than following executions since it will be building its base image first. Once this initial process is completed, the firmware will be always built immediately. diff --git a/docs/development/Building in Vagrant.md b/docs/development/Building in Vagrant.md index 99d479b7c19..c931f2ffcca 100644 --- a/docs/development/Building in Vagrant.md +++ b/docs/development/Building in Vagrant.md @@ -1,5 +1,7 @@ # Building with Vagrant +> **On Windows building with this method is not advised and should be used only if Windows Linux Subsystem can not be used. In all other cases all Windows users should be using Linux Subsystem (WSL) instead** + Setting up build environment with Vagrant is remarkably simple, but you still need to have some basic knowlage of your OS. ## Installing Vagrant diff --git a/docs/development/Building in Windows 10 or 11 with MSYS2.md b/docs/development/Building in Windows 10 or 11 with MSYS2.md index 2d7f967b505..bc55be7410d 100644 --- a/docs/development/Building in Windows 10 or 11 with MSYS2.md +++ b/docs/development/Building in Windows 10 or 11 with MSYS2.md @@ -1,4 +1,7 @@ # Building in Windows with MSYS2 + +> **Building with this method is not advised and should be used only if Windows Linux Subsystem can not be used. In all other cases all Windows users should be using Linux Subsystem (WSL) instead** + - This environment does not require installing WSL, which may not be available or would get in the way of other virtualization and/or anti-cheat software - It is also much faster to install and get set up because of its small size(~3.65 GB total after building hex file as of 6.0.0) ## Setting up the environment diff --git a/docs/development/Building in Windows light.md b/docs/development/[Deprecated] Building in Windows light.md similarity index 96% rename from docs/development/Building in Windows light.md rename to docs/development/[Deprecated] Building in Windows light.md index e05b2c92f3b..de4659e7455 100644 --- a/docs/development/Building in Windows light.md +++ b/docs/development/[Deprecated] Building in Windows light.md @@ -1,4 +1,8 @@ # Building in windows light [Deprecated] + +> **Building with this method is deprecated and not advised. All Windows users should be using +Linux Subsystem (WSL) instead** + no cygwin and no path changes ## Install Git for windows From cf402d4eca05d826292143c5200f83628394ff2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Spychalski?= Date: Sat, 23 Mar 2024 12:42:41 +0100 Subject: [PATCH 105/241] Merge pull request #9818 from TUNERC-Aria/add-TUNERCF405 Add new target TUNERC405 --- src/main/target/TUNERCF405/CMakeLists.txt | 1 + src/main/target/TUNERCF405/target.c | 39 ++++++ src/main/target/TUNERCF405/target.h | 137 ++++++++++++++++++++++ 3 files changed, 177 insertions(+) create mode 100644 src/main/target/TUNERCF405/CMakeLists.txt create mode 100644 src/main/target/TUNERCF405/target.c create mode 100644 src/main/target/TUNERCF405/target.h diff --git a/src/main/target/TUNERCF405/CMakeLists.txt b/src/main/target/TUNERCF405/CMakeLists.txt new file mode 100644 index 00000000000..ba4e9fd3cd3 --- /dev/null +++ b/src/main/target/TUNERCF405/CMakeLists.txt @@ -0,0 +1 @@ +target_stm32f405xg(TUNERCF405) diff --git a/src/main/target/TUNERCF405/target.c b/src/main/target/TUNERCF405/target.c new file mode 100644 index 00000000000..bc0b4e86f65 --- /dev/null +++ b/src/main/target/TUNERCF405/target.c @@ -0,0 +1,39 @@ +/* + * This file is part of INAV Project. + * + * 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 "drivers/io.h" +#include "drivers/pwm_mapping.h" +#include "drivers/timer.h" + +timerHardware_t timerHardware[] = { + DEF_TIM(TIM1, CH2N, PB0, TIM_USE_MOTOR, 0, 0), //D2s6 + DEF_TIM(TIM1, CH1, PA8, TIM_USE_MOTOR, 0, 0), //D2s6 + DEF_TIM(TIM4, CH3, PB8, TIM_USE_MOTOR, 0, 0), //D1s7 + DEF_TIM(TIM2, CH1, PA15, TIM_USE_MOTOR, 0, 0), //D1s5 + + DEF_TIM(TIM8, CH4, PC9, TIM_USE_OUTPUT_AUTO, 0, 0), //D2s7 + DEF_TIM(TIM8, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 0), //D2s2 / D2s4 + DEF_TIM(TIM8, CH2, PC7, TIM_USE_OUTPUT_AUTO, 0, 0), //D2s2 + DEF_TIM(TIM8, CH1, PC6, TIM_USE_OUTPUT_AUTO, 0, 0), //D2s2 + + DEF_TIM(TIM3, CH4, PB1, TIM_USE_LED, 0, 0), +}; + +const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]); diff --git a/src/main/target/TUNERCF405/target.h b/src/main/target/TUNERCF405/target.h new file mode 100644 index 00000000000..f193377c6ea --- /dev/null +++ b/src/main/target/TUNERCF405/target.h @@ -0,0 +1,137 @@ +/* + * This file is part of INAV Project. + * + * 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 . + */ + +#pragma once + +#define TARGET_BOARD_IDENTIFIER "TURC" + +#define USBD_PRODUCT_STRING "TUNERCF405" + +// Indicators +#define LED0 PB9 + +#define BEEPER PB2 +#define BEEPER_INVERTED + +// WS2812 +#define USE_LED_STRIP +#define WS2811_PIN PB1 + +// Gyro & ACC +#define USE_SPI +#define USE_SPI_DEVICE_1 + +#define SPI1_NSS_PIN PA4 +#define SPI1_SCK_PIN PA5 +#define SPI1_MISO_PIN PA6 +#define SPI1_MOSI_PIN PA7 + +#define USE_IMU_BMI270 +#define IMU_BMI270_ALIGN CW180_DEG +#define BMI270_CS_PIN SPI1_NSS_PIN +#define BMI270_SPI_BUS BUS_SPI1 + +// OSD +#define USE_SPI_DEVICE_2 +#define SPI2_NSS_PIN PB12 +#define SPI2_SCK_PIN PB13 +#define SPI2_MISO_PIN PB14 +#define SPI2_MOSI_PIN PB15 + +#define USE_MAX7456 +#define MAX7456_SPI_BUS BUS_SPI2 +#define MAX7456_CS_PIN SPI2_NSS_PIN + +// Onboard Flash +#define USE_SPI_DEVICE_3 +#define SPI3_SCK_PIN PB3 +#define SPI3_MISO_PIN PB4 +#define SPI3_MOSI_PIN PB5 + +#define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT +#define USE_FLASHFS +#define USE_FLASH_M25P16 //W25Q32JVXGIQ TR +#define M25P16_SPI_BUS BUS_SPI3 +#define M25P16_CS_PIN PB6 + +// IIC +#define USE_I2C +#define USE_I2C_DEVICE_2 +#define I2C1_SCL PB10 +#define I2C1_SDA PB11 + +#define USE_BARO +#define BARO_I2C_BUS BUS_I2C2 +#define USE_BARO_BMP280 +#define USE_BARO_DPS310 + +#define USE_MAG +#define MAG_I2C_BUS BUS_I2C2 +#define USE_MAG_ALL + +// Serial ports +#define USE_VCP +#define VBUS_SENSING_PIN PB7 +#define VBUS_SENSING_ENABLED + +#define USE_UART1 +#define UART1_RX_PIN PA10 +#define UART1_TX_PIN PA9 + +#define USE_UART2 +#define UART2_RX_PIN PA3 +#define UART2_TX_PIN PA2 + +#define USE_UART3 +#define UART3_RX_PIN PC11 +#define UART3_TX_PIN PC10 + +#define USE_UART4 +#define UART4_RX_PIN PA1 +#define UART4_TX_PIN PA0 + +#define USE_UART5 +#define UART5_RX_PIN PD2 +#define UART5_TX_PIN PC12 + +#define SERIAL_PORT_COUNT 6 + +#define DEFAULT_RX_TYPE RX_TYPE_SERIAL +#define SERIALRX_PROVIDER SERIALRX_CRSF + +// ADC +#define USE_ADC +#define ADC_CHANNEL_1_PIN PC0 +#define ADC_CHANNEL_2_PIN PC1 + +#define VBAT_ADC_CHANNEL ADC_CHN_1 +#define CURRENT_METER_ADC_CHANNEL ADC_CHN_2 +#define CURRENT_METER_SCALE 453 + +// SET +#define DEFAULT_FEATURES (FEATURE_OSD | FEATURE_CURRENT_METER | FEATURE_VBAT ) +#define USE_DSHOT +#define USE_DSHOT_DMAR +#define USE_SERIAL_4WAY_BLHELI_INTERFACE + +#define MAX_PWM_OUTPUT_PORTS 8 +#define TARGET_MOTOR_COUNT 8 + +#define TARGET_IO_PORTA 0xffff +#define TARGET_IO_PORTB 0xffff +#define TARGET_IO_PORTC 0xffff +#define TARGET_IO_PORTD 0xffff From 07706c5a3d9179565671ecfd4f7eb99962b93131 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Sat, 23 Mar 2024 13:09:18 +0100 Subject: [PATCH 106/241] magless navigation PSA --- readme.md | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index e30d2fcc8d1..53b8046be32 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,6 @@ # INAV - navigation capable flight controller -# PSA +# F411 PSA > INAV no longer accepts targets based on STM32 F411 MCU. @@ -8,6 +8,28 @@ ![INAV](http://static.rcgroups.net/forums/attachments/6/1/0/3/7/6/a9088858-102-inav.png) +# PosHold, Navigation and RTH without compass PSA + +Attention all drone pilots and enthusiasts, + +Are you ready to take your flights to new heights with INAV 7.1? We've got some important information to share with you. + +INAV 7.1 brings an exciting update to navigation capabilities. Now, you can soar through the skies, navigate waypoints, and even return to home without relying on a compass. Yes, you heard that right! But before you launch into the air, there's something crucial to consider. + +While INAV 7.1 may not require a compass for basic navigation functions, we strongly advise you to install one for optimal flight performance. Here's why: + +🛰️ Better Flight Precision: A compass provides essential data for accurate navigation, ensuring smoother and more precise flight paths. + +🌐 Enhanced Reliability: With a compass onboard, your drone can maintain stability even in challenging environments, low speeds and strong wind. + +🚀 Minimize Risks: Although INAV 7.1 can get you where you need to go without a compass, flying without one may result in a bumpier ride and increased risk of drift or inaccurate positioning. + +Remember, safety and efficiency are paramount when operating drones. By installing a compass, you're not just enhancing your flight experience, but also prioritizing safety for yourself and those around you. + +So, before you take off on your next adventure, make sure to equip your drone with a compass. It's the smart choice for smoother flights and better navigation. + +Fly safe, fly smart with INAV 7.1 and a compass by your side! + # INAV Community * [INAV Discord Server](https://discord.gg/peg2hhbYwN) From 5bfcc7c3ef9d1a8d8f5730635b403a7ad385df44 Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Sun, 24 Mar 2024 07:06:45 +0000 Subject: [PATCH 107/241] Revert "Show a timeout for in flight rearming" --- src/main/fc/fc_core.c | 16 ++------------- src/main/fc/fc_core.h | 2 -- src/main/io/osd.c | 45 ++++++++++++++----------------------------- 3 files changed, 16 insertions(+), 47 deletions(-) diff --git a/src/main/fc/fc_core.c b/src/main/fc/fc_core.c index c51519927b2..0d0863760de 100644 --- a/src/main/fc/fc_core.c +++ b/src/main/fc/fc_core.c @@ -507,18 +507,6 @@ bool emergencyArmingUpdate(bool armingSwitchIsOn, bool forceArm) return counter >= EMERGENCY_ARMING_MIN_ARM_COUNT; } -uint16_t emergencyInFlightRearmTimeMS(void) -{ - uint16_t rearmMS = 0; - - if (STATE(IN_FLIGHT_EMERG_REARM)) { - timeMs_t currentTimeMs = millis(); - rearmMS = (uint16_t)((US2MS(lastDisarmTimeUs) + EMERGENCY_INFLIGHT_REARM_TIME_WINDOW_MS) - currentTimeMs); - } - - return rearmMS; -} - bool emergInflightRearmEnabled(void) { /* Emergency rearm allowed within 5s timeout period after disarm if craft still flying */ @@ -892,6 +880,7 @@ static void applyThrottleTiltCompensation(void) void taskMainPidLoop(timeUs_t currentTimeUs) { + cycleTime = getTaskDeltaTime(TASK_SELF); dT = (float)cycleTime * 0.000001f; @@ -910,8 +899,7 @@ void taskMainPidLoop(timeUs_t currentTimeUs) } } - if (armTime > 1 * USECS_PER_SEC) { - // reset in flight emerg rearm flag 1 sec after arming once it's served its purpose + if (armTime > 1 * USECS_PER_SEC) { // reset in flight emerg rearm flag 1 sec after arming once it's served its purpose DISABLE_STATE(IN_FLIGHT_EMERG_REARM); } diff --git a/src/main/fc/fc_core.h b/src/main/fc/fc_core.h index 455e5b3849e..c66a0050ba2 100644 --- a/src/main/fc/fc_core.h +++ b/src/main/fc/fc_core.h @@ -42,9 +42,7 @@ timeUs_t getLastDisarmTimeUs(void); void tryArm(void); disarmReason_t getDisarmReason(void); -uint16_t emergencyInFlightRearmTimeMS(void); bool emergencyArmingUpdate(bool armingSwitchIsOn, bool forceArm); -bool emergInflightRearmEnabled(void); bool areSensorsCalibrating(void); float getFlightTime(void); diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 201f3efb7b8..f0cc50bbaa1 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -28,7 +28,6 @@ #include #include #include -#include #include "platform.h" @@ -4561,16 +4560,8 @@ static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page) displayWrite(osdDisplayPort, statValuesX + multiValueLengthOffset, top++, buff); } - uint16_t rearmMs = (emergInflightRearmEnabled()) ? emergencyInFlightRearmTimeMS() : 0; - if (savingSettings == true) { displayWrite(osdDisplayPort, statNameX, top++, OSD_MESSAGE_STR(OSD_MSG_SAVING_SETTNGS)); - } else if (rearmMs > 0) { // Show rearming time if settings not actively being saved. Ignore the settings saved message if rearm available. - char emReArmMsg[23]; - tfp_sprintf(emReArmMsg, "** REARM PERIOD: "); - tfp_sprintf(emReArmMsg + strlen(emReArmMsg), "%02d", (uint8_t)MS2S(rearmMs)); - strcat(emReArmMsg, " **\0"); - displayWrite(osdDisplayPort, statNameX, top++, OSD_MESSAGE_STR(emReArmMsg)); } else if (notify_settings_saved > 0) { if (millis() > notify_settings_saved) { notify_settings_saved = 0; @@ -4870,10 +4861,9 @@ static void osdRefresh(timeUs_t currentTimeUs) } bool statsSinglePageCompatible = (osdDisplayPort->rows >= OSD_STATS_SINGLE_PAGE_MIN_ROWS); - static uint8_t statsCurrentPage = 0; - static timeMs_t statsRefreshTime = 0; - static bool statsDisplayed = false; - static bool statsAutoPagingEnabled = true; + static uint8_t statsCurrentPage = 0; + static bool statsDisplayed = false; + static bool statsAutoPagingEnabled = true; // Detect arm/disarm if (armState != ARMING_FLAG(ARMED)) { @@ -4941,24 +4931,25 @@ static void osdRefresh(timeUs_t currentTimeUs) // Alternate screens for multi-page stats. // Also, refreshes screen at swap interval for single-page stats. if (OSD_ALTERNATING_CHOICES((osdConfig()->stats_page_auto_swap_time * 1000), 2)) { - if (statsCurrentPage == 0) + if (statsCurrentPage == 0) { + osdShowStats(statsSinglePageCompatible, statsCurrentPage); statsCurrentPage = 1; + } } else { - if (statsCurrentPage == 1) + if (statsCurrentPage == 1) { + osdShowStats(statsSinglePageCompatible, statsCurrentPage); statsCurrentPage = 0; + } } } else { // Process manual page change events for multi-page stats. - if (manualPageUpRequested) + if (manualPageUpRequested) { + osdShowStats(statsSinglePageCompatible, 1); statsCurrentPage = 1; - else if (manualPageDownRequested) + } else if (manualPageDownRequested) { + osdShowStats(statsSinglePageCompatible, 0); statsCurrentPage = 0; - } - - // Only refresh the stats every 1/4 of a second. - if (statsRefreshTime <= millis()) { - statsRefreshTime = millis() + 250; - osdShowStats(statsSinglePageCompatible, statsCurrentPage); + } } } @@ -5315,16 +5306,9 @@ textAttributes_t osdGetSystemMessage(char *buff, size_t buff_size, bool isCenter } /* Messages that are shown regardless of Arming state */ - uint16_t rearmMs = (emergInflightRearmEnabled()) ? emergencyInFlightRearmTimeMS() : 0; if (savingSettings == true) { messages[messageCount++] = OSD_MESSAGE_STR(OSD_MSG_SAVING_SETTNGS); - } else if (rearmMs > 0) { // Show rearming time if settings not actively being saved. Ignore the settings saved message if rearm available. - char emReArmMsg[23]; - tfp_sprintf(emReArmMsg, "** REARM PERIOD: "); - tfp_sprintf(emReArmMsg + strlen(emReArmMsg), "%02d", (uint8_t)MS2S(rearmMs)); - strcat(emReArmMsg, " **\0"); - messages[messageCount++] = OSD_MESSAGE_STR(emReArmMsg); } else if (notify_settings_saved > 0) { if (millis() > notify_settings_saved) { notify_settings_saved = 0; @@ -5333,7 +5317,6 @@ textAttributes_t osdGetSystemMessage(char *buff, size_t buff_size, bool isCenter } } - if (messageCount > 0) { message = messages[OSD_ALTERNATING_CHOICES(systemMessageCycleTime(messageCount, messages), messageCount)]; if (message == failsafeInfoMessage) { From 4a24018bde3acbb3bbbd569274836abfd2ed6892 Mon Sep 17 00:00:00 2001 From: Marcelo Bezerra <23555060+mmosca@users.noreply.github.com> Date: Sun, 24 Mar 2024 12:07:05 +0100 Subject: [PATCH 108/241] Add target to use second gyro, instead of first gyro --- docs/boards/MAMBAH743_2022B.md | 4 ++++ src/main/target/MAMBAH743/CMakeLists.txt | 3 ++- src/main/target/MAMBAH743/target.c | 2 +- src/main/target/MAMBAH743/target.h | 22 ++++++++++++++++++---- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/docs/boards/MAMBAH743_2022B.md b/docs/boards/MAMBAH743_2022B.md index 688c630cb84..d3d91e14c14 100644 --- a/docs/boards/MAMBAH743_2022B.md +++ b/docs/boards/MAMBAH743_2022B.md @@ -2,4 +2,8 @@ Contrary to what the documentation suggests, VTX power is actually on USER2. +# Dual Gyros + +INAV 7.1 changed the default gyro of the board from the gyro on SPI4 back to the one on SPI1. A new tagrt ```MAMBAH743_2022B_GYRO2``` was added to use gyro on SPI4, in case you suspect an issue with the gyro on SPI1, you can switch to the gyro on SPI4 by using the new target. + diff --git a/src/main/target/MAMBAH743/CMakeLists.txt b/src/main/target/MAMBAH743/CMakeLists.txt index 61b073da931..801467cdb86 100644 --- a/src/main/target/MAMBAH743/CMakeLists.txt +++ b/src/main/target/MAMBAH743/CMakeLists.txt @@ -1,2 +1,3 @@ target_stm32h743xi(MAMBAH743) -target_stm32h743xi(MAMBAH743_2022B) \ No newline at end of file +target_stm32h743xi(MAMBAH743_2022B) +target_stm32h743xi(MAMBAH743_2022B_GYRO2) diff --git a/src/main/target/MAMBAH743/target.c b/src/main/target/MAMBAH743/target.c index 46231fdbd79..1e4f8fe246b 100644 --- a/src/main/target/MAMBAH743/target.c +++ b/src/main/target/MAMBAH743/target.c @@ -29,7 +29,7 @@ BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); BUSDEV_REGISTER_SPI_TAG(busdev_bmi270, DEVHW_BMI270, BMI270_SPI_BUS, BMI270_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_BMI270_ALIGN); -#ifdef MAMBAH743_2022B +#ifdef USE_IMU_ICM42605 BUSDEV_REGISTER_SPI_TAG(busdev_icm42605, DEVHW_ICM42605, ICM42605_SPI_BUS, ICM42605_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_ICM42605_ALIGN); #endif diff --git a/src/main/target/MAMBAH743/target.h b/src/main/target/MAMBAH743/target.h index 7fcea85f48b..bc4a73979ee 100644 --- a/src/main/target/MAMBAH743/target.h +++ b/src/main/target/MAMBAH743/target.h @@ -22,6 +22,11 @@ #define TARGET_BOARD_IDENTIFIER "M743" #define USBD_PRODUCT_STRING "MAMBAH743_2022B" +#elif defined(MAMBAH743_2022B_GYRO2) + +#define TARGET_BOARD_IDENTIFIER "M743" +#define USBD_PRODUCT_STRING "MAMBAH743_2022B_GYRO2" + #else #define TARGET_BOARD_IDENTIFIER "M743" @@ -58,13 +63,22 @@ #define BMI270_SPI_BUS BUS_SPI1 #define BMI270_CS_PIN PA4 -#ifdef MAMBAH743_2022B - #define USE_SPI_DEVICE_4 #define SPI4_SCK_PIN PE12 #define SPI4_MISO_PIN PE13 #define SPI4_MOSI_PIN PE14 +#ifdef MAMBAH743_2022B + +#define USE_IMU_ICM42605 +#define IMU_ICM42605_ALIGN CW0_DEG +#define ICM42605_SPI_BUS BUS_SPI1 +#define ICM42605_CS_PIN PA4 + +#endif + +#ifdef MAMBAH743_2022B_GYRO2 + #define USE_IMU_ICM42605 #define IMU_ICM42605_ALIGN CW270_DEG #define ICM42605_SPI_BUS BUS_SPI4 @@ -175,7 +189,7 @@ #define USE_ADC #define ADC_INSTANCE ADC3 -#ifdef MAMBAH743_2022B +#if defined(MAMBAH743_2022B) || defined(MAMBAH743_2022B_GYRO2) #define ADC_CHANNEL_1_PIN PC1 #define ADC_CHANNEL_2_PIN PC3 @@ -203,7 +217,7 @@ #define USE_PINIO #define USE_PINIOBOX -#ifdef MAMBAH743_2022B +#if defined(MAMBAH743_2022B) || defined(MAMBAH743_2022B_GYRO2) #define PINIO1_PIN PC2 #define PINIO2_PIN PC5 From f84f2edd9d77b36d7711eec4feab8a293dfaceb4 Mon Sep 17 00:00:00 2001 From: Marcelo Bezerra <23555060+mmosca@users.noreply.github.com> Date: Sun, 24 Mar 2024 12:12:56 +0100 Subject: [PATCH 109/241] Fix gyro alignment --- src/main/target/MAMBAH743/target.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/target/MAMBAH743/target.h b/src/main/target/MAMBAH743/target.h index bc4a73979ee..387893402e9 100644 --- a/src/main/target/MAMBAH743/target.h +++ b/src/main/target/MAMBAH743/target.h @@ -71,7 +71,7 @@ #ifdef MAMBAH743_2022B #define USE_IMU_ICM42605 -#define IMU_ICM42605_ALIGN CW0_DEG +#define IMU_ICM42605_ALIGN CW180_DEG #define ICM42605_SPI_BUS BUS_SPI1 #define ICM42605_CS_PIN PA4 From 79cd891daa921ec98b3b0e2f48162a976cdc1255 Mon Sep 17 00:00:00 2001 From: Marcelo Bezerra <23555060+mmosca@users.noreply.github.com> Date: Sun, 24 Mar 2024 12:28:14 +0100 Subject: [PATCH 110/241] Oops... My board was flipped, not the gyro. --- src/main/target/MAMBAH743/target.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/target/MAMBAH743/target.h b/src/main/target/MAMBAH743/target.h index 387893402e9..bc4a73979ee 100644 --- a/src/main/target/MAMBAH743/target.h +++ b/src/main/target/MAMBAH743/target.h @@ -71,7 +71,7 @@ #ifdef MAMBAH743_2022B #define USE_IMU_ICM42605 -#define IMU_ICM42605_ALIGN CW180_DEG +#define IMU_ICM42605_ALIGN CW0_DEG #define ICM42605_SPI_BUS BUS_SPI1 #define ICM42605_CS_PIN PA4 From 7312c53ab7f373475361bcaf4a4fc64106bd94dd Mon Sep 17 00:00:00 2001 From: Roman Lut <11955117+RomanLut@users.noreply.github.com> Date: Sun, 24 Mar 2024 14:53:53 +0100 Subject: [PATCH 111/241] fixed: garbage is displayed (f.e. single char "+" ) instead of "FIRST WP IS TOO FAR" OSD message --- src/main/io/osd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index f5f9e1f815b..b48edb9e0ae 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -828,7 +828,7 @@ void osdFormatPilotName(char *buff) static const char * osdArmingDisabledReasonMessage(void) { const char *message = NULL; - char messageBuf[MAX(SETTING_MAX_NAME_LENGTH, OSD_MESSAGE_LENGTH+1)]; + static char messageBuf[OSD_MESSAGE_LENGTH+1]; switch (isArmingDisabledReason()) { case ARMING_DISABLED_FAILSAFE_SYSTEM: @@ -5254,7 +5254,7 @@ textAttributes_t osdGetSystemMessage(char *buff, size_t buff_size, bool isCenter if (buff != NULL) { const char *message = NULL; - char messageBuf[MAX(SETTING_MAX_NAME_LENGTH, OSD_MESSAGE_LENGTH+1)]; + char messageBuf[MAX(SETTING_MAX_NAME_LENGTH, OSD_MESSAGE_LENGTH+1)]; //warning: shared buffer. Make sure it is used by single message in code below! // We might have up to 5 messages to show. const char *messages[5]; unsigned messageCount = 0; From 2f6c56a7f12f580781cbcda2efbebc3cc1561a8b Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Sun, 24 Mar 2024 18:01:34 +0000 Subject: [PATCH 112/241] Add missing outputs for SKYSTARSHD2 --- src/main/target/SKYSTARSF405HD/CMakeLists.txt | 1 + src/main/target/SKYSTARSF405HD/target.c | 4 ++++ src/main/target/SKYSTARSF405HD/target.h | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/src/main/target/SKYSTARSF405HD/CMakeLists.txt b/src/main/target/SKYSTARSF405HD/CMakeLists.txt index cc9515d9e0c..b097558284c 100644 --- a/src/main/target/SKYSTARSF405HD/CMakeLists.txt +++ b/src/main/target/SKYSTARSF405HD/CMakeLists.txt @@ -1 +1,2 @@ target_stm32f405xg(SKYSTARSF405HD) +target_stm32f405xg(SKYSTARSF405HD2) \ No newline at end of file diff --git a/src/main/target/SKYSTARSF405HD/target.c b/src/main/target/SKYSTARSF405HD/target.c index 3da0f45db92..cc4ff1c5a88 100644 --- a/src/main/target/SKYSTARSF405HD/target.c +++ b/src/main/target/SKYSTARSF405HD/target.c @@ -28,6 +28,10 @@ timerHardware_t timerHardware[] = { DEF_TIM(TIM4, CH1, PB6, TIM_USE_OUTPUT_AUTO, 0, 0), DEF_TIM(TIM3, CH1, PB4, TIM_USE_OUTPUT_AUTO, 0, 0), DEF_TIM(TIM2, CH2, PB3, TIM_USE_OUTPUT_AUTO, 0, 0), +#if defined(SKYSTARSF405HD2) + DEF_TIM(TIM3, CH3, PB0, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 0), +#endif DEF_TIM(TIM8, CH3, PC8, TIM_USE_LED, 0, 0), }; diff --git a/src/main/target/SKYSTARSF405HD/target.h b/src/main/target/SKYSTARSF405HD/target.h index c5ab2d49fe2..9b9805084f2 100644 --- a/src/main/target/SKYSTARSF405HD/target.h +++ b/src/main/target/SKYSTARSF405HD/target.h @@ -156,4 +156,8 @@ #define USE_DSHOT #define USE_ESC_SENSOR +#if defined(SKYSTARSF405HD2) +#define MAX_PWM_OUTPUT_PORTS 6 +#else #define MAX_PWM_OUTPUT_PORTS 4 +#endif From 83939ea20db0edfefd1f0174357f4b40658e2b1c Mon Sep 17 00:00:00 2001 From: Marcelo Bezerra <23555060+mmosca@users.noreply.github.com> Date: Mon, 25 Mar 2024 13:00:20 +0100 Subject: [PATCH 113/241] Update NEW_HARDWARE_POLICY.md Update RAM requirements (128K, F405) and serial ports. Bump serial ports requirement to 3, unless there is an onboard serial rx. --- docs/policies/NEW_HARDWARE_POLICY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/policies/NEW_HARDWARE_POLICY.md b/docs/policies/NEW_HARDWARE_POLICY.md index 1e974134808..f11601b8380 100644 --- a/docs/policies/NEW_HARDWARE_POLICY.md +++ b/docs/policies/NEW_HARDWARE_POLICY.md @@ -23,8 +23,8 @@ New targets are accepted into INAV code if any of the following conditions is sa 3. The new target must meet the following minimal requirements: * On-board sensors include at least the IMU (gyroscope + accelerometer) - * At least 2 hardware serial ports are available with both TX and RX pins - * At least 512K of firmware flash memory and at least of 64K of RAM available + * At least 3 hardware serial ports are available with both TX and RX pads. 2 serial ports may be accepted if there is an onboard serial RX. + * At least 512K of firmware flash memory and at least of 128K of RAM available * At least one I2C bus broken out (SCL and SDA pins) and not shared with other functions ## New hardware support From 46ae6ff7453d68502e1321288b6d003c27dabf0f Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Mon, 25 Mar 2024 21:34:19 +0100 Subject: [PATCH 114/241] Remove killswitch --- docs/development/Blackbox Internals.md | 1 - src/main/fc/fc_core.c | 10 +--- src/main/fc/fc_core.h | 1 - src/main/fc/fc_msp.c | 13 ----- src/main/fc/fc_msp_box.c | 3 - src/main/fc/rc_controls.c | 12 +--- src/main/fc/rc_controls.h | 1 - src/main/fc/rc_modes.h | 1 - src/main/fc/runtime_config.c | 3 +- src/main/fc/runtime_config.h | 4 +- src/main/fc/settings.yaml | 4 -- src/main/io/osd.c | 4 +- src/main/io/osd.h | 1 - src/main/io/osd_dji_hd.c | 2 - src/main/msp/msp_protocol.h | 3 - src/test/unit/flight_failsafe_unittest.cc.txt | 56 ------------------- 16 files changed, 7 insertions(+), 112 deletions(-) diff --git a/docs/development/Blackbox Internals.md b/docs/development/Blackbox Internals.md index bf7991c7041..5e82979bcad 100644 --- a/docs/development/Blackbox Internals.md +++ b/docs/development/Blackbox Internals.md @@ -566,7 +566,6 @@ The log end marker is an optional Event ("E") frame of type 0xFF whose payload i
  • Sticks
  • Switch_3D
  • Switch
  • -
  • Killswitch
  • Failsafe
  • Navigation
  • diff --git a/src/main/fc/fc_core.c b/src/main/fc/fc_core.c index 6bee30e572b..9986b8e934d 100644 --- a/src/main/fc/fc_core.c +++ b/src/main/fc/fc_core.c @@ -307,14 +307,6 @@ static void updateArmingStatus(void) DISABLE_ARMING_FLAG(ARMING_DISABLED_BOXFAILSAFE); } - /* CHECK: BOXKILLSWITCH */ - if (IS_RC_MODE_ACTIVE(BOXKILLSWITCH)) { - ENABLE_ARMING_FLAG(ARMING_DISABLED_BOXKILLSWITCH); - } - else { - DISABLE_ARMING_FLAG(ARMING_DISABLED_BOXKILLSWITCH); - } - /* CHECK: Do not allow arming if Servo AutoTrim is enabled */ if (IS_RC_MODE_ACTIVE(BOXAUTOTRIM)) { ENABLE_ARMING_FLAG(ARMING_DISABLED_SERVO_AUTOTRIM); @@ -525,7 +517,7 @@ bool emergInflightRearmEnabled(void) timeMs_t currentTimeMs = millis(); emergRearmStabiliseTimeout = 0; - if ((lastDisarmReason != DISARM_SWITCH && lastDisarmReason != DISARM_KILLSWITCH) || + if ((lastDisarmReason != DISARM_SWITCH) || (currentTimeMs > US2MS(lastDisarmTimeUs) + EMERGENCY_INFLIGHT_REARM_TIME_WINDOW_MS)) { return false; } diff --git a/src/main/fc/fc_core.h b/src/main/fc/fc_core.h index 455e5b3849e..0e83ef7a467 100644 --- a/src/main/fc/fc_core.h +++ b/src/main/fc/fc_core.h @@ -27,7 +27,6 @@ typedef enum disarmReason_e { DISARM_STICKS = 2, DISARM_SWITCH_3D = 3, DISARM_SWITCH = 4, - DISARM_KILLSWITCH = 5, DISARM_FAILSAFE = 6, DISARM_NAVIGATION = 7, DISARM_LANDING = 8, diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index c076fa88c42..2d47d0ec2e9 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -670,11 +670,6 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF sbufWriteU16(dst, getRSSI()); break; - case MSP_ARMING_CONFIG: - sbufWriteU8(dst, 0); - sbufWriteU8(dst, armingConfig()->disarm_kill_switch); - break; - case MSP_LOOP_TIME: sbufWriteU16(dst, gyroConfig()->looptime); break; @@ -1828,14 +1823,6 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) break; #endif - case MSP_SET_ARMING_CONFIG: - if (dataSize == 2) { - sbufReadU8(src); //Swallow the first byte, used to be auto_disarm_delay - armingConfigMutable()->disarm_kill_switch = !!sbufReadU8(src); - } else - return MSP_RESULT_ERROR; - break; - case MSP_SET_LOOP_TIME: if (sbufReadU16Safe(&tmp_u16, src)) gyroConfigMutable()->looptime = tmp_u16; diff --git a/src/main/fc/fc_msp_box.c b/src/main/fc/fc_msp_box.c index c61c2aa19e9..8cc0e948bde 100644 --- a/src/main/fc/fc_msp_box.c +++ b/src/main/fc/fc_msp_box.c @@ -76,7 +76,6 @@ static const box_t boxes[CHECKBOX_ITEM_COUNT + 1] = { { .boxId = BOXTURNASSIST, .boxName = "TURN ASSIST", .permanentId = 35 }, { .boxId = BOXNAVLAUNCH, .boxName = "NAV LAUNCH", .permanentId = 36 }, { .boxId = BOXAUTOTRIM, .boxName = "SERVO AUTOTRIM", .permanentId = 37 }, - { .boxId = BOXKILLSWITCH, .boxName = "KILLSWITCH", .permanentId = 38 }, { .boxId = BOXCAMERA1, .boxName = "CAMERA CONTROL 1", .permanentId = 39 }, { .boxId = BOXCAMERA2, .boxName = "CAMERA CONTROL 2", .permanentId = 40 }, { .boxId = BOXCAMERA3, .boxName = "CAMERA CONTROL 3", .permanentId = 41 }, @@ -320,7 +319,6 @@ void initActiveBoxIds(void) } #endif - ADD_ACTIVE_BOX(BOXKILLSWITCH); ADD_ACTIVE_BOX(BOXFAILSAFE); #if defined(USE_RCDEVICE) || defined(USE_MSP_DISPLAYPORT) @@ -405,7 +403,6 @@ void packBoxModeFlags(boxBitmask_t * mspBoxModeFlags) CHECK_ACTIVE_BOX(IS_ENABLED(FLIGHT_MODE(NAV_LAUNCH_MODE)), BOXNAVLAUNCH); CHECK_ACTIVE_BOX(IS_ENABLED(FLIGHT_MODE(AUTO_TUNE)), BOXAUTOTUNE); CHECK_ACTIVE_BOX(IS_ENABLED(IS_RC_MODE_ACTIVE(BOXAUTOTRIM)), BOXAUTOTRIM); - CHECK_ACTIVE_BOX(IS_ENABLED(IS_RC_MODE_ACTIVE(BOXKILLSWITCH)), BOXKILLSWITCH); CHECK_ACTIVE_BOX(IS_ENABLED(IS_RC_MODE_ACTIVE(BOXHOMERESET)), BOXHOMERESET); CHECK_ACTIVE_BOX(IS_ENABLED(IS_RC_MODE_ACTIVE(BOXCAMERA1)), BOXCAMERA1); CHECK_ACTIVE_BOX(IS_ENABLED(IS_RC_MODE_ACTIVE(BOXCAMERA2)), BOXCAMERA2); diff --git a/src/main/fc/rc_controls.c b/src/main/fc/rc_controls.c index 6c65736dbe5..b06b4bf51fe 100644 --- a/src/main/fc/rc_controls.c +++ b/src/main/fc/rc_controls.c @@ -87,11 +87,10 @@ PG_RESET_TEMPLATE(rcControlsConfig_t, rcControlsConfig, .airmodeThrottleThreshold = SETTING_AIRMODE_THROTTLE_THRESHOLD_DEFAULT, ); -PG_REGISTER_WITH_RESET_TEMPLATE(armingConfig_t, armingConfig, PG_ARMING_CONFIG, 2); +PG_REGISTER_WITH_RESET_TEMPLATE(armingConfig_t, armingConfig, PG_ARMING_CONFIG, 3); PG_RESET_TEMPLATE(armingConfig_t, armingConfig, .fixed_wing_auto_arm = SETTING_FIXED_WING_AUTO_ARM_DEFAULT, - .disarm_kill_switch = SETTING_DISARM_KILL_SWITCH_DEFAULT, .switchDisarmDelayMs = SETTING_SWITCH_DISARM_DELAY_DEFAULT, .prearmTimeoutMs = SETTING_PREARM_TIMEOUT_DEFAULT, ); @@ -231,20 +230,13 @@ void processRcStickPositions(bool isThrottleLow) if (ARMING_FLAG(ARMED) && !IS_RC_MODE_ACTIVE(BOXFAILSAFE) && rxIsReceivingSignal() && !failsafeIsActive()) { const timeMs_t disarmDelay = currentTimeMs - rcDisarmTimeMs; if (disarmDelay > armingConfig()->switchDisarmDelayMs) { - if (armingConfig()->disarm_kill_switch || isThrottleLow) { - disarm(DISARM_SWITCH); - } + disarm(DISARM_SWITCH); } } else { rcDisarmTimeMs = currentTimeMs; } } - - // KILLSWITCH disarms instantly - if (IS_RC_MODE_ACTIVE(BOXKILLSWITCH)) { - disarm(DISARM_KILLSWITCH); - } } if (rcDelayCommand != 20) { diff --git a/src/main/fc/rc_controls.h b/src/main/fc/rc_controls.h index 0c9bcb199d3..4ea5b9f3f50 100644 --- a/src/main/fc/rc_controls.h +++ b/src/main/fc/rc_controls.h @@ -95,7 +95,6 @@ PG_DECLARE(rcControlsConfig_t, rcControlsConfig); typedef struct armingConfig_s { bool fixed_wing_auto_arm; // Auto-arm fixed wing aircraft on throttle up and never disarm - bool disarm_kill_switch; // allow disarm via AUX switch regardless of throttle value uint16_t switchDisarmDelayMs; // additional delay between ARM box going off and actual disarm uint16_t prearmTimeoutMs; // duration for which Prearm being activated is valid. after this, Prearm needs to be reset. 0 means Prearm does not timeout. } armingConfig_t; diff --git a/src/main/fc/rc_modes.h b/src/main/fc/rc_modes.h index fa1827a6ad0..04aea681bc9 100644 --- a/src/main/fc/rc_modes.h +++ b/src/main/fc/rc_modes.h @@ -49,7 +49,6 @@ typedef enum { BOXAIRMODE = 20, BOXHOMERESET = 21, BOXGCSNAV = 22, - BOXKILLSWITCH = 23, // old HEADING LOCK BOXSURFACE = 24, BOXFLAPERON = 25, BOXTURNASSIST = 26, diff --git a/src/main/fc/runtime_config.c b/src/main/fc/runtime_config.c index daeb9cbbcde..44118ef54b9 100644 --- a/src/main/fc/runtime_config.c +++ b/src/main/fc/runtime_config.c @@ -34,7 +34,7 @@ static EXTENDED_FASTRAM uint32_t enabledSensors = 0; #if !defined(CLI_MINIMAL_VERBOSITY) const char *armingDisableFlagNames[]= { "FS", "ANGLE", "CAL", "OVRLD", "NAV", "COMPASS", - "ACC", "ARMSW", "HWFAIL", "BOXFS", "KILLSW", "RX", + "ACC", "ARMSW", "HWFAIL", "BOXFS", "RX", "THR", "CLI", "CMS", "OSD", "ROLL/PITCH", "AUTOTRIM", "OOM", "SETTINGFAIL", "PWMOUT", "NOPREARM", "DSHOTBEEPER", "LANDED" }; @@ -50,7 +50,6 @@ const armingFlag_e armDisableReasonsChecklist[] = { ARMING_DISABLED_NAVIGATION_UNSAFE, ARMING_DISABLED_ARM_SWITCH, ARMING_DISABLED_BOXFAILSAFE, - ARMING_DISABLED_BOXKILLSWITCH, ARMING_DISABLED_THROTTLE, ARMING_DISABLED_CLI, ARMING_DISABLED_CMS_MENU, diff --git a/src/main/fc/runtime_config.h b/src/main/fc/runtime_config.h index bda9321b6b6..974f90f8c4d 100644 --- a/src/main/fc/runtime_config.h +++ b/src/main/fc/runtime_config.h @@ -34,7 +34,7 @@ typedef enum { ARMING_DISABLED_ARM_SWITCH = (1 << 14), ARMING_DISABLED_HARDWARE_FAILURE = (1 << 15), ARMING_DISABLED_BOXFAILSAFE = (1 << 16), - ARMING_DISABLED_BOXKILLSWITCH = (1 << 17), + ARMING_DISABLED_RC_LINK = (1 << 18), ARMING_DISABLED_THROTTLE = (1 << 19), ARMING_DISABLED_CLI = (1 << 20), @@ -53,7 +53,7 @@ typedef enum { ARMING_DISABLED_SYSTEM_OVERLOADED | ARMING_DISABLED_NAVIGATION_UNSAFE | ARMING_DISABLED_COMPASS_NOT_CALIBRATED | ARMING_DISABLED_ACCELEROMETER_NOT_CALIBRATED | ARMING_DISABLED_ARM_SWITCH | ARMING_DISABLED_HARDWARE_FAILURE | ARMING_DISABLED_BOXFAILSAFE | - ARMING_DISABLED_BOXKILLSWITCH | ARMING_DISABLED_RC_LINK | ARMING_DISABLED_THROTTLE | ARMING_DISABLED_CLI | + ARMING_DISABLED_RC_LINK | ARMING_DISABLED_THROTTLE | ARMING_DISABLED_CLI | ARMING_DISABLED_CMS_MENU | ARMING_DISABLED_OSD_MENU | ARMING_DISABLED_ROLLPITCH_NOT_CENTERED | ARMING_DISABLED_SERVO_AUTOTRIM | ARMING_DISABLED_OOM | ARMING_DISABLED_INVALID_SETTING | ARMING_DISABLED_PWM_OUTPUT_ERROR | ARMING_DISABLED_NO_PREARM | ARMING_DISABLED_DSHOT_BEEPER | diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index e3e69c7487f..abab04fbc5d 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -1496,10 +1496,6 @@ groups: description: "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." default_value: OFF type: bool - - name: disarm_kill_switch - description: "Disarms the motors independently of throttle value. Setting to OFF reverts to the old behaviour of disarming only when the throttle is low. Only applies when arming and disarming with an AUX channel." - default_value: ON - type: bool - name: switch_disarm_delay description: "Delay before disarming when requested by switch (ms) [0-1000]" default_value: 250 diff --git a/src/main/io/osd.c b/src/main/io/osd.c index f5f9e1f815b..df59d02228b 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -902,8 +902,6 @@ static const char * osdArmingDisabledReasonMessage(void) return OSD_MESSAGE_STR(OSD_MSG_HW_FAIL); case ARMING_DISABLED_BOXFAILSAFE: return OSD_MESSAGE_STR(OSD_MSG_FS_EN); - case ARMING_DISABLED_BOXKILLSWITCH: - return OSD_MESSAGE_STR(OSD_MSG_KILL_SW_EN); case ARMING_DISABLED_RC_LINK: return OSD_MESSAGE_STR(OSD_MSG_NO_RC_LINK); case ARMING_DISABLED_THROTTLE: @@ -4424,7 +4422,7 @@ static void osdUpdateStats(void) static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page) { - const char * disarmReasonStr[DISARM_REASON_COUNT] = { "UNKNOWN", "TIMEOUT", "STICKS", "SWITCH", "SWITCH", "KILLSW", "FAILSAFE", "NAV SYS", "LANDING"}; + const char * disarmReasonStr[DISARM_REASON_COUNT] = { "UNKNOWN", "TIMEOUT", "STICKS", "SWITCH", "SWITCH", "", "FAILSAFE", "NAV SYS", "LANDING"}; uint8_t top = 1; // Start one line down leaving space at the top of the screen. size_t multiValueLengthOffset = 0; diff --git a/src/main/io/osd.h b/src/main/io/osd.h index 503f7dd0e09..454b7160420 100644 --- a/src/main/io/osd.h +++ b/src/main/io/osd.h @@ -75,7 +75,6 @@ #define OSD_MSG_PITOT_FAIL "PITOT METER FAILURE" #define OSD_MSG_HW_FAIL "HARDWARE FAILURE" #define OSD_MSG_FS_EN "FAILSAFE MODE ENABLED" -#define OSD_MSG_KILL_SW_EN "KILLSWITCH MODE ENABLED" #define OSD_MSG_NO_RC_LINK "NO RC LINK" #define OSD_MSG_THROTTLE_NOT_LOW "THROTTLE IS NOT LOW" #define OSD_MSG_ROLLPITCH_OFFCENTER "ROLLPITCH NOT CENTERED" diff --git a/src/main/io/osd_dji_hd.c b/src/main/io/osd_dji_hd.c index 78edf45370b..29dfe0b809e 100644 --- a/src/main/io/osd_dji_hd.c +++ b/src/main/io/osd_dji_hd.c @@ -505,8 +505,6 @@ static char * osdArmingDisabledReasonMessage(void) // return OSD_MESSAGE_STR("HARDWARE FAILURE"); case ARMING_DISABLED_BOXFAILSAFE: return OSD_MESSAGE_STR("FAILSAFE ENABLED"); - case ARMING_DISABLED_BOXKILLSWITCH: - return OSD_MESSAGE_STR("KILLSWITCH ENABLED"); case ARMING_DISABLED_RC_LINK: return OSD_MESSAGE_STR("NO RC LINK"); case ARMING_DISABLED_THROTTLE: diff --git a/src/main/msp/msp_protocol.h b/src/main/msp/msp_protocol.h index b44037f2f88..f3a925828e7 100644 --- a/src/main/msp/msp_protocol.h +++ b/src/main/msp/msp_protocol.h @@ -163,9 +163,6 @@ #define MSP_SONAR_ALTITUDE 58 //out message get surface altitude [cm] -#define MSP_ARMING_CONFIG 61 //out message Returns auto_disarm_delay and disarm_kill_switch parameters -#define MSP_SET_ARMING_CONFIG 62 //in message Sets auto_disarm_delay and disarm_kill_switch parameters - // // Baseflight MSP commands (if enabled they exist in Cleanflight) // diff --git a/src/test/unit/flight_failsafe_unittest.cc.txt b/src/test/unit/flight_failsafe_unittest.cc.txt index eb4aacef72c..895cbd15d76 100644 --- a/src/test/unit/flight_failsafe_unittest.cc.txt +++ b/src/test/unit/flight_failsafe_unittest.cc.txt @@ -297,62 +297,6 @@ TEST(FlightFailsafeTest, TestFailsafeDetectsRxLossAndJustDisarms) EXPECT_FALSE(ARMING_FLAG(PREVENT_ARMING)); } -/****************************************************************************************/ -TEST(FlightFailsafeTest, TestFailsafeDetectsKillswitchEvent) -{ - // given - ENABLE_ARMING_FLAG(ARMED); - resetCallCounters(); - failsafeStartMonitoring(); - - // and - throttleStatus = THROTTLE_HIGH; // throttle HIGH to go for a failsafe landing procedure - failsafeConfig.failsafe_kill_switch = 1; // configure AUX switch as kill switch - ACTIVATE_RC_MODE(BOXFAILSAFE); // and activate it - sysTickUptime = 0; // restart time from 0 - failsafeOnValidDataReceived(); // set last valid sample at current time - sysTickUptime = PERIOD_RXDATA_FAILURE + 1; // adjust time to point just past the failure time to - failsafeOnValidDataFailed(); // cause a lost link - - // when - failsafeUpdateState(); // kill switch handling should come first - - // then - EXPECT_EQ(true, failsafeIsActive()); - EXPECT_TRUE(ARMING_FLAG(PREVENT_ARMING)); - EXPECT_EQ(1, CALL_COUNTER(COUNTER_MW_DISARM)); - EXPECT_EQ(FAILSAFE_RX_LOSS_MONITORING, failsafePhase()); - - // given - failsafeOnValidDataFailed(); // set last invalid sample at current time - sysTickUptime += PERIOD_RXDATA_RECOVERY + 1; // adjust time to point just past the recovery time to - failsafeOnValidDataReceived(); // cause a recovered link - - rcModeActivationMask = DE_ACTIVATE_ALL_BOXES; // BOXFAILSAFE must be off (kill switch) - - // when - failsafeUpdateState(); - - // then - EXPECT_EQ(true, failsafeIsActive()); - EXPECT_TRUE(ARMING_FLAG(PREVENT_ARMING)); - EXPECT_EQ(1, CALL_COUNTER(COUNTER_MW_DISARM)); - EXPECT_EQ(FAILSAFE_RX_LOSS_MONITORING, failsafePhase()); - - // given - sysTickUptime += PERIOD_OF_1_SECONDS + 1; // adjust time to point just past the required additional recovery time - failsafeOnValidDataReceived(); - - // when - failsafeUpdateState(); - - // then - EXPECT_EQ(false, failsafeIsActive()); - EXPECT_EQ(FAILSAFE_IDLE, failsafePhase()); - EXPECT_EQ(1, CALL_COUNTER(COUNTER_MW_DISARM)); // disarm not called repeatedly. - EXPECT_FALSE(ARMING_FLAG(PREVENT_ARMING)); -} - /****************************************************************************************/ // // Additional non-stepwise tests From 048ad2b2734ec883b7a10a70a8e730867f008630 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Mon, 25 Mar 2024 21:38:36 +0100 Subject: [PATCH 115/241] Add a comment --- src/main/io/osd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index df59d02228b..11b0ac60608 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -4422,6 +4422,7 @@ static void osdUpdateStats(void) static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page) { + //We keep "" for backward compatibility with the Blackbox explorer and other potential usages const char * disarmReasonStr[DISARM_REASON_COUNT] = { "UNKNOWN", "TIMEOUT", "STICKS", "SWITCH", "SWITCH", "", "FAILSAFE", "NAV SYS", "LANDING"}; uint8_t top = 1; // Start one line down leaving space at the top of the screen. size_t multiValueLengthOffset = 0; From 1ebefcd67b28529ef633688a19e88375e203ea4c Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Mon, 25 Mar 2024 21:39:18 +0100 Subject: [PATCH 116/241] Docs update --- docs/Settings.md | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/docs/Settings.md b/docs/Settings.md index 61195109625..a157f56010e 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -672,16 +672,6 @@ Defines debug values exposed in debug variables (developer / debugging setting) --- -### disarm_kill_switch - -Disarms the motors independently of throttle value. Setting to OFF reverts to the old behaviour of disarming only when the throttle is low. Only applies when arming and disarming with an AUX channel. - -| Default | Min | Max | -| --- | --- | --- | -| ON | OFF | ON | - ---- - ### display_force_sw_blink OFF = OSD hardware blink / ON = OSD software blink. If OSD warning text/values are invisible, try setting this to ON From 491680a0fb5741b252ba460e7969e9b35083133a Mon Sep 17 00:00:00 2001 From: b14ckyy <33039058+b14ckyy@users.noreply.github.com> Date: Tue, 26 Mar 2024 10:09:56 +0100 Subject: [PATCH 117/241] Update Fixed Wing Landing.md Added some tuning tips and general parameter info that influence autoland. --- docs/Fixed Wing Landing.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/Fixed Wing Landing.md b/docs/Fixed Wing Landing.md index 4ccb3249536..8e1a3ef6fc1 100644 --- a/docs/Fixed Wing Landing.md +++ b/docs/Fixed Wing Landing.md @@ -80,6 +80,23 @@ In degrees. Min: 0, Max: 45, Default: 0 * `nav_fw_land_max_tailwind`: Max. tailwind if no landing direction with downwind is available. Wind strengths below this value are ignored (error tolerance in the wind measurement). Landing then takes place in the main direction. If, for example, 90 degrees is configured, landing takes place in this direction, NOT in 270 degrees (see above). In cm/s. Min: 0; Max: 3000, Default: 140 +### General paramters and tuning tips + +* `nav_fw_wp_tracking_accuracy`: Its highly recommended that this parameter is used and tuned well. Only with WP-Tracking enabled, the Aircraft will try to precisely align with the runway during approach. +If WP-Tracking is not used, the Plane will head straight to the landiung location without flying in line with the intended landing strip. Wind can intensively alter the final landing heading. + +* `nav_fw_pitch2thr`: The navigation throttle modifier has to be tuned well to allow stable navigation during climbs and descents to prevent a stall. Make sure your plane maintains Ground or Airspeed, when climbing in any navigation mode. +The Craft should not get slower and not speed ub significantly during a navigation climb, if P2T is tuned properly. + +* `nav_wp_radius`: This parameter might be too high if you have set up your craft with INAV 6 or INAV 7. With a too high value, the turning points for the Crosswind-Leg and Final Approach are hit too early and make it difficult for the plane to align to the runway or cut short the approach. +Make sure this parameter is not set greater than 1000 (cm). The better your craft and navigation system is tuned, the lower this value can be. We recommend to start with 1000 for flying wings and 800 for a Plane with Tail. + +* Test your Navigation-Tuning: A better Navigation-Tune will reward you with smoother and more reliable landings. To test your nav systems limit, we recommend to create a waypoint missions with many 90° turn angles with shorter and shorter tracks. +With this Method, you can find out how well your plane can follow a navigation path and how long it takes to align to a waypoint track. A well tuned plane should be able to pull of a WP Mission that looks like this, where the distance between WP6 and WP7 si recommended to be the minimum approach length: + +![Test Waypoint Track](https://github.com/iNavFlight/inav/assets/33039058/a929cd0c-80b1-42d6-815d-89a90e9daa1b) + + ## Waypoint missions Only one landing waypoint per mission can be active and saved and the landing waypoint must be the last waypoint of the mission. From 85ec0a9dc942ee59c2b2428e942ae82dfff55421 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Tue, 26 Mar 2024 11:01:14 +0100 Subject: [PATCH 118/241] Revert "Merge pull request #9438 from dronecontrol-ru/baro_alt_vario" This reverts commit 5d77d07cec9d30d0146bfe51e8fe0ff9089f46d4, reversing changes made to 3b218b6f9fcdf6a8d7850dc6bfaa0164815ba428. --- src/main/rx/crsf.h | 2 -- src/main/telemetry/crsf.c | 49 ++++++--------------------------------- 2 files changed, 7 insertions(+), 44 deletions(-) diff --git a/src/main/rx/crsf.h b/src/main/rx/crsf.h index 80e356223fb..f3bc7933494 100755 --- a/src/main/rx/crsf.h +++ b/src/main/rx/crsf.h @@ -45,7 +45,6 @@ enum { CRSF_FRAME_GPS_PAYLOAD_SIZE = 15, CRSF_FRAME_VARIO_SENSOR_PAYLOAD_SIZE = 2, CRSF_FRAME_BATTERY_SENSOR_PAYLOAD_SIZE = 8, - CRSF_FRAME_BAROVARIO_SENSOR_PAYLOAD_SIZE = 4, CRSF_FRAME_LINK_STATISTICS_PAYLOAD_SIZE = 10, CRSF_FRAME_RC_CHANNELS_PAYLOAD_SIZE = 22, // 11 bits per channel * 16 channels = 22 bytes. CRSF_FRAME_ATTITUDE_PAYLOAD_SIZE = 6, @@ -87,7 +86,6 @@ typedef enum { CRSF_FRAMETYPE_GPS = 0x02, CRSF_FRAMETYPE_VARIO_SENSOR = 0x07, CRSF_FRAMETYPE_BATTERY_SENSOR = 0x08, - CRSF_FRAMETYPE_BAROVARIO_SENSOR = 0x09, CRSF_FRAMETYPE_LINK_STATISTICS = 0x14, CRSF_FRAMETYPE_RC_CHANNELS_PACKED = 0x16, CRSF_FRAMETYPE_ATTITUDE = 0x1E, diff --git a/src/main/telemetry/crsf.c b/src/main/telemetry/crsf.c index fd461003879..5ed25de73be 100755 --- a/src/main/telemetry/crsf.c +++ b/src/main/telemetry/crsf.c @@ -57,7 +57,7 @@ #include "sensors/battery.h" #include "sensors/sensors.h" -#include "sensors/barometer.h" + #include "telemetry/crsf.h" #include "telemetry/telemetry.h" #include "telemetry/msp_shared.h" @@ -258,22 +258,6 @@ static void crsfFrameBatterySensor(sbuf_t *dst) crsfSerialize8(dst, batteryRemainingPercentage); } -/* -0x09 Baro+Vario sensor -Payload: -uint16 Altitude -int16 Vertical speed ( cm/s ) -*/ -static void crsfFrameBaroVarioSensor(sbuf_t *dst) -{ - // use sbufWrite since CRC does not include frame length - sbufWriteU8(dst, CRSF_FRAME_BAROVARIO_SENSOR_PAYLOAD_SIZE + CRSF_FRAME_LENGTH_TYPE_CRC); - crsfSerialize8(dst, CRSF_FRAMETYPE_BAROVARIO_SENSOR); - int32_t altitude = baroGetLatestAltitude() / 10; // Altitude in decimeters - crsfSerialize16(dst, altitude + 10000 < 0x8000 ? altitude + 10000 : 0x8000 + altitude / 10); - crsfSerialize16(dst, lrintf(getEstimatedActualVelocity(Z))); -} - typedef enum { CRSF_ACTIVE_ANTENNA1 = 0, CRSF_ACTIVE_ANTENNA2 = 1 @@ -431,7 +415,6 @@ typedef enum { CRSF_FRAME_FLIGHT_MODE_INDEX, CRSF_FRAME_GPS_INDEX, CRSF_FRAME_VARIO_SENSOR_INDEX, - CRSF_FRAME_BAROVARIO_SENSOR_INDEX, CRSF_SCHEDULE_COUNT_MAX } crsfFrameTypeIndex_e; @@ -491,18 +474,13 @@ static void processCrsf(void) crsfFrameGps(dst); crsfFinalize(dst); } +#endif +#if defined(USE_BARO) || defined(USE_GPS) if (currentSchedule & BV(CRSF_FRAME_VARIO_SENSOR_INDEX)) { crsfInitializeFrame(dst); crsfFrameVarioSensor(dst); crsfFinalize(dst); } -#endif -#if defined(USE_BARO) - if (currentSchedule & BV(CRSF_FRAME_BAROVARIO_SENSOR_INDEX)) { - crsfInitializeFrame(dst); - crsfFrameBaroVarioSensor(dst); - crsfFinalize(dst); - } #endif crsfScheduleIndex = (crsfScheduleIndex + 1) % crsfScheduleCount; } @@ -527,23 +505,14 @@ void initCrsfTelemetry(void) crsfSchedule[index++] = BV(CRSF_FRAME_ATTITUDE_INDEX); crsfSchedule[index++] = BV(CRSF_FRAME_BATTERY_SENSOR_INDEX); crsfSchedule[index++] = BV(CRSF_FRAME_FLIGHT_MODE_INDEX); -#if defined(USE_GPS) +#ifdef USE_GPS if (feature(FEATURE_GPS)) { crsfSchedule[index++] = BV(CRSF_FRAME_GPS_INDEX); - #if !defined(USE_BARO) - crsfSchedule[index++] = BV(CRSF_FRAME_VARIO_SENSOR_INDEX); - #endif } #endif -#if defined(USE_BARO) - if (sensors(SENSOR_BARO)) { - crsfSchedule[index++] = BV(CRSF_FRAME_BAROVARIO_SENSOR_INDEX); - } else { - #if defined(USE_GPS) - if (feature(FEATURE_GPS)) { - crsfSchedule[index++] = BV(CRSF_FRAME_VARIO_SENSOR_INDEX); - } - #endif +#if defined(USE_BARO) || defined(USE_GPS) + if (sensors(SENSOR_BARO) || (STATE(FIXED_WING_LEGACY) && feature(FEATURE_GPS))) { + crsfSchedule[index++] = BV(CRSF_FRAME_VARIO_SENSOR_INDEX); } #endif crsfScheduleCount = (uint8_t)index; @@ -622,11 +591,7 @@ int getCrsfFrame(uint8_t *frame, crsfFrameType_e frameType) case CRSF_FRAMETYPE_VARIO_SENSOR: crsfFrameVarioSensor(sbuf); break; - case CRSF_FRAMETYPE_BAROVARIO_SENSOR: - crsfFrameBaroVarioSensor(sbuf); - break; } - const int frameSize = crsfFinalizeBuf(sbuf, frame); return frameSize; } From 9c01b83440ea305f4be27c96a38ce6869b6c71b3 Mon Sep 17 00:00:00 2001 From: Ray Morris Date: Tue, 26 Mar 2024 16:51:55 -0500 Subject: [PATCH 119/241] FOXEERF722DUAL enable 5V power by default --- src/main/target/FOXEERF722DUAL/config.c | 31 +++++++++++++++++++++++++ src/main/target/FOXEERF722DUAL/target.c | 1 + src/main/target/FOXEERF722DUAL/target.h | 10 ++++++++ 3 files changed, 42 insertions(+) create mode 100644 src/main/target/FOXEERF722DUAL/config.c diff --git a/src/main/target/FOXEERF722DUAL/config.c b/src/main/target/FOXEERF722DUAL/config.c new file mode 100644 index 00000000000..38763948c3f --- /dev/null +++ b/src/main/target/FOXEERF722DUAL/config.c @@ -0,0 +1,31 @@ +/* + * 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 "fc/fc_msp_box.h" + +#if defined(FOXEERF722V2) +#include "io/piniobox.h" + +void targetConfiguration(void) +{ + pinioBoxConfigMutable()->permanentId[0] = BOX_PERMANENT_ID_USER1; +} +#endif diff --git a/src/main/target/FOXEERF722DUAL/target.c b/src/main/target/FOXEERF722DUAL/target.c index fe34e0a45d4..e81731651e3 100644 --- a/src/main/target/FOXEERF722DUAL/target.c +++ b/src/main/target/FOXEERF722DUAL/target.c @@ -22,6 +22,7 @@ #include "drivers/timer.h" #include "drivers/sensor.h" #include "drivers/pwm_mapping.h" +#include "drivers/pinio.h" BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); #if defined(FOXEERF722DUAL) diff --git a/src/main/target/FOXEERF722DUAL/target.h b/src/main/target/FOXEERF722DUAL/target.h index 250a88a307f..1eafd86af9f 100644 --- a/src/main/target/FOXEERF722DUAL/target.h +++ b/src/main/target/FOXEERF722DUAL/target.h @@ -147,3 +147,13 @@ #define TARGET_IO_PORTC 0xffff #define TARGET_IO_PORTD (BIT(2)) + +// *************** PINIO *************************** +#if defined(FOXEERF722V2) +#define USE_PINIO +#define USE_PINIOBOX +#define PINIO1_PIN PC6 // Enable GPS power +#define PINIO1_FLAGS PINIO_FLAGS_INVERTED +#endif + + From 695bd4002dca83b89e8c0861b0407871b41d52ee Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Wed, 27 Mar 2024 20:38:19 +0100 Subject: [PATCH 120/241] Drop MSP_OSD_CONFIG from MSP protocol --- src/main/fc/fc_msp.c | 50 ------------------------------------- src/main/msp/msp_protocol.h | 3 --- 2 files changed, 53 deletions(-) diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index c076fa88c42..393c31e5578 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -1198,26 +1198,6 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF break; #endif - case MSP_OSD_CONFIG: -#ifdef USE_OSD - sbufWriteU8(dst, OSD_DRIVER_MAX7456); // OSD supported - // send video system (AUTO/PAL/NTSC) - sbufWriteU8(dst, osdConfig()->video_system); - sbufWriteU8(dst, osdConfig()->units); - sbufWriteU8(dst, osdConfig()->rssi_alarm); - sbufWriteU16(dst, currentBatteryProfile->capacity.warning); - sbufWriteU16(dst, osdConfig()->time_alarm); - sbufWriteU16(dst, osdConfig()->alt_alarm); - sbufWriteU16(dst, osdConfig()->dist_alarm); - sbufWriteU16(dst, osdConfig()->neg_alt_alarm); - for (int i = 0; i < OSD_ITEM_COUNT; i++) { - sbufWriteU16(dst, osdLayoutsConfig()->item_pos[0][i]); - } -#else - sbufWriteU8(dst, OSD_DRIVER_NONE); // OSD not supported -#endif - break; - case MSP_3D: sbufWriteU16(dst, reversibleMotorsConfig()->deadband_low); sbufWriteU16(dst, reversibleMotorsConfig()->deadband_high); @@ -2552,36 +2532,6 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) #endif #ifdef USE_OSD - case MSP_SET_OSD_CONFIG: - sbufReadU8Safe(&tmp_u8, src); - // set all the other settings - if ((int8_t)tmp_u8 == -1) { - if (dataSize >= 10) { - osdConfigMutable()->video_system = sbufReadU8(src); - osdConfigMutable()->units = sbufReadU8(src); - osdConfigMutable()->rssi_alarm = sbufReadU8(src); - currentBatteryProfileMutable->capacity.warning = sbufReadU16(src); - osdConfigMutable()->time_alarm = sbufReadU16(src); - osdConfigMutable()->alt_alarm = sbufReadU16(src); - // Won't be read if they weren't provided - sbufReadU16Safe(&osdConfigMutable()->dist_alarm, src); - sbufReadU16Safe(&osdConfigMutable()->neg_alt_alarm, src); - } else - return MSP_RESULT_ERROR; - } else { - // set a position setting - if ((dataSize >= 3) && (tmp_u8 < OSD_ITEM_COUNT)) // tmp_u8 == addr - osdLayoutsConfigMutable()->item_pos[0][tmp_u8] = sbufReadU16(src); - else - return MSP_RESULT_ERROR; - } - // Either a element position change or a units change needs - // a full redraw, since an element can change size significantly - // and the old position or the now unused space due to the - // size change need to be erased. - osdStartFullRedraw(); - break; - case MSP_OSD_CHAR_WRITE: if (dataSize >= 55) { osdCharacter_t chr; diff --git a/src/main/msp/msp_protocol.h b/src/main/msp/msp_protocol.h index b44037f2f88..27180027a6a 100644 --- a/src/main/msp/msp_protocol.h +++ b/src/main/msp/msp_protocol.h @@ -192,9 +192,6 @@ #define MSP_TRANSPONDER_CONFIG 82 //out message Get transponder settings #define MSP_SET_TRANSPONDER_CONFIG 83 //in message Set transponder settings -#define MSP_OSD_CONFIG 84 //out message Get osd settings - betaflight -#define MSP_SET_OSD_CONFIG 85 //in message Set osd settings - betaflight - #define MSP_OSD_CHAR_READ 86 //out message Get osd settings - betaflight #define MSP_OSD_CHAR_WRITE 87 //in message Set osd settings - betaflight From 661ba24de9a8b52b40c2113aa9933ef9ed29c14c Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Wed, 27 Mar 2024 20:41:39 +0100 Subject: [PATCH 121/241] Drop MSP_POSITION_ESTIMATION_CONFIG --- src/main/fc/fc_msp.c | 25 ------------------------- src/main/msp/msp_protocol.h | 3 --- 2 files changed, 28 deletions(-) diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index c076fa88c42..0e2b614bde5 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -1412,18 +1412,6 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF break; - case MSP_POSITION_ESTIMATION_CONFIG: - - sbufWriteU16(dst, positionEstimationConfig()->w_z_baro_p * 100); // inav_w_z_baro_p float as value * 100 - sbufWriteU16(dst, positionEstimationConfig()->w_z_gps_p * 100); // 2 inav_w_z_gps_p float as value * 100 - sbufWriteU16(dst, positionEstimationConfig()->w_z_gps_v * 100); // 2 inav_w_z_gps_v float as value * 100 - sbufWriteU16(dst, positionEstimationConfig()->w_xy_gps_p * 100); // 2 inav_w_xy_gps_p float as value * 100 - sbufWriteU16(dst, positionEstimationConfig()->w_xy_gps_v * 100); // 2 inav_w_xy_gps_v float as value * 100 - sbufWriteU8(dst, gpsConfigMutable()->gpsMinSats); // 1 - sbufWriteU8(dst, 1); // 1 inav_use_gps_velned ON/OFF - - break; - case MSP_REBOOT: if (!ARMING_FLAG(ARMED)) { if (mspPostProcessFn) { @@ -2481,19 +2469,6 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) return MSP_RESULT_ERROR; break; - case MSP_SET_POSITION_ESTIMATION_CONFIG: - if (dataSize == 12) { - positionEstimationConfigMutable()->w_z_baro_p = constrainf(sbufReadU16(src) / 100.0f, 0.0f, 10.0f); - positionEstimationConfigMutable()->w_z_gps_p = constrainf(sbufReadU16(src) / 100.0f, 0.0f, 10.0f); - positionEstimationConfigMutable()->w_z_gps_v = constrainf(sbufReadU16(src) / 100.0f, 0.0f, 10.0f); - positionEstimationConfigMutable()->w_xy_gps_p = constrainf(sbufReadU16(src) / 100.0f, 0.0f, 10.0f); - positionEstimationConfigMutable()->w_xy_gps_v = constrainf(sbufReadU16(src) / 100.0f, 0.0f, 10.0f); - gpsConfigMutable()->gpsMinSats = constrain(sbufReadU8(src), 5, 10); - sbufReadU8(src); // was positionEstimationConfigMutable()->use_gps_velned - } else - return MSP_RESULT_ERROR; - break; - case MSP_RESET_CONF: if (!ARMING_FLAG(ARMED)) { suspendRxSignal(); diff --git a/src/main/msp/msp_protocol.h b/src/main/msp/msp_protocol.h index b44037f2f88..bd2c864cf00 100644 --- a/src/main/msp/msp_protocol.h +++ b/src/main/msp/msp_protocol.h @@ -110,9 +110,6 @@ #define MSP_CALIBRATION_DATA 14 #define MSP_SET_CALIBRATION_DATA 15 -#define MSP_POSITION_ESTIMATION_CONFIG 16 -#define MSP_SET_POSITION_ESTIMATION_CONFIG 17 - #define MSP_WP_MISSION_LOAD 18 // Load mission from NVRAM #define MSP_WP_MISSION_SAVE 19 // Save mission to NVRAM #define MSP_WP_GETINFO 20 From 2fb1b51c670cd21df824dbe982b01ba36dd66c18 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Thu, 28 Mar 2024 14:33:38 +0100 Subject: [PATCH 122/241] Remove USE_SMARTPORT_MASTER --- src/main/target/common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/target/common.h b/src/main/target/common.h index ec05d1e145e..60953d87884 100644 --- a/src/main/target/common.h +++ b/src/main/target/common.h @@ -111,7 +111,6 @@ #define USE_FRSKYOSD #define USE_DJI_HD_OSD #define USE_MSP_OSD -#define USE_SMARTPORT_MASTER #define NAV_NON_VOLATILE_WAYPOINT_CLI @@ -199,6 +198,7 @@ #define USE_HOTT_TEXTMODE #define USE_24CHANNELS #define MAX_MIXER_PROFILE_COUNT 2 +#define USE_SMARTPORT_MASTER #elif !defined(STM32F7) #define MAX_MIXER_PROFILE_COUNT 1 #endif From 9b94b4c07831d371351f4ef2f6fb683a506c611c Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Fri, 29 Mar 2024 12:00:59 +0000 Subject: [PATCH 123/241] Temporarily remove the rearm period This is causing problems with MSP DisplayPort. I hope to fix the issue and reinstate it in #9688 --- src/main/io/osd.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 255b3d3d4c1..d385bd05928 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -5084,16 +5084,17 @@ static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page) row = drawStat_DisarmMethod(statNameX, row, statValuesX); - uint16_t rearmMs = (emergInflightRearmEnabled()) ? emergencyInFlightRearmTimeMS() : 0; + // The following has been commented out as it will be added in #9688 + // uint16_t rearmMs = (emergInflightRearmEnabled()) ? emergencyInFlightRearmTimeMS() : 0; if (savingSettings == true) { displayWrite(osdDisplayPort, (osdDisplayPort->cols - strlen(OSD_MESSAGE_STR(OSD_MSG_SAVING_SETTNGS))) / 2, row++, OSD_MESSAGE_STR(OSD_MSG_SAVING_SETTNGS)); - } else if (rearmMs > 0) { // Show rearming time if settings not actively being saved. Ignore the settings saved message if rearm available. + /*} else if (rearmMs > 0) { // Show rearming time if settings not actively being saved. Ignore the settings saved message if rearm available. char emReArmMsg[23]; tfp_sprintf(emReArmMsg, "** REARM PERIOD: "); tfp_sprintf(emReArmMsg + strlen(emReArmMsg), "%02d", (uint8_t)MS2S(rearmMs)); strcat(emReArmMsg, " **\0"); - displayWrite(osdDisplayPort, statNameX, top++, OSD_MESSAGE_STR(emReArmMsg)); + displayWrite(osdDisplayPort, statNameX, top++, OSD_MESSAGE_STR(emReArmMsg));*/ } else if (notify_settings_saved > 0) { if (millis() > notify_settings_saved) { notify_settings_saved = 0; @@ -5838,16 +5839,18 @@ textAttributes_t osdGetSystemMessage(char *buff, size_t buff_size, bool isCenter } /* Messages that are shown regardless of Arming state */ - uint16_t rearmMs = (emergInflightRearmEnabled()) ? emergencyInFlightRearmTimeMS() : 0; + + // The following has been commented out as it will be added in #9688 + // uint16_t rearmMs = (emergInflightRearmEnabled()) ? emergencyInFlightRearmTimeMS() : 0; if (savingSettings == true) { messages[messageCount++] = OSD_MESSAGE_STR(OSD_MSG_SAVING_SETTNGS); - } else if (rearmMs > 0) { // Show rearming time if settings not actively being saved. Ignore the settings saved message if rearm available. + /*} else if (rearmMs > 0) { // Show rearming time if settings not actively being saved. Ignore the settings saved message if rearm available. char emReArmMsg[23]; tfp_sprintf(emReArmMsg, "** REARM PERIOD: "); tfp_sprintf(emReArmMsg + strlen(emReArmMsg), "%02d", (uint8_t)MS2S(rearmMs)); strcat(emReArmMsg, " **\0"); - messages[messageCount++] = OSD_MESSAGE_STR(emReArmMsg); + messages[messageCount++] = OSD_MESSAGE_STR(emReArmMsg);*/ } else if (notify_settings_saved > 0) { if (millis() > notify_settings_saved) { notify_settings_saved = 0; From 36f859a46e3649bce9a6d520fd968a064fec93c8 Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Fri, 29 Mar 2024 12:10:39 +0000 Subject: [PATCH 124/241] Fixed error introduced when updating from master --- src/main/navigation/navigation.c | 52 ++++++++++++++++---------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/main/navigation/navigation.c b/src/main/navigation/navigation.c index 309ba03b89a..e7261b068cf 100644 --- a/src/main/navigation/navigation.c +++ b/src/main/navigation/navigation.c @@ -204,44 +204,44 @@ PG_RESET_TEMPLATE(navConfig_t, navConfig, // Fixed wing .fw = { - .max_bank_angle = SETTING_NAV_FW_BANK_ANGLE_DEFAULT, // degrees - .max_manual_climb_rate = SETTING_NAV_FW_MANUAL_CLIMB_RATE_DEFAULT, // 3 m/s - .max_climb_angle = SETTING_NAV_FW_CLIMB_ANGLE_DEFAULT, // degrees - .max_dive_angle = SETTING_NAV_FW_DIVE_ANGLE_DEFAULT, // degrees - .cruise_speed = SETTING_NAV_FW_CRUISE_SPEED_DEFAULT, // cm/s + .max_bank_angle = SETTING_NAV_FW_BANK_ANGLE_DEFAULT, // degrees + .max_manual_climb_rate = SETTING_NAV_FW_MANUAL_CLIMB_RATE_DEFAULT, // 3 m/s + .max_climb_angle = SETTING_NAV_FW_CLIMB_ANGLE_DEFAULT, // degrees + .max_dive_angle = SETTING_NAV_FW_DIVE_ANGLE_DEFAULT, // degrees + .cruise_speed = SETTING_NAV_FW_CRUISE_SPEED_DEFAULT, // cm/s .control_smoothness = SETTING_NAV_FW_CONTROL_SMOOTHNESS_DEFAULT, .pitch_to_throttle_smooth = SETTING_NAV_FW_PITCH2THR_SMOOTHING_DEFAULT, .pitch_to_throttle_thresh = SETTING_NAV_FW_PITCH2THR_THRESHOLD_DEFAULT, .minThrottleDownPitchAngle = SETTING_FW_MIN_THROTTLE_DOWN_PITCH_DEFAULT, - .loiter_radius = SETTING_NAV_FW_LOITER_RADIUS_DEFAULT, // 75m + .loiter_radius = SETTING_NAV_FW_LOITER_RADIUS_DEFAULT, // 75m .loiter_direction = SETTING_FW_LOITER_DIRECTION_DEFAULT, //Fixed wing landing - .land_dive_angle = SETTING_NAV_FW_LAND_DIVE_ANGLE_DEFAULT, // 2 degrees dive by default + .land_dive_angle = SETTING_NAV_FW_LAND_DIVE_ANGLE_DEFAULT, // 2 degrees dive by default // Fixed wing launch - .launch_velocity_thresh = SETTING_NAV_FW_LAUNCH_VELOCITY_DEFAULT, // 3 m/s - .launch_accel_thresh = SETTING_NAV_FW_LAUNCH_ACCEL_DEFAULT, // cm/s/s (1.9*G) - .launch_time_thresh = SETTING_NAV_FW_LAUNCH_DETECT_TIME_DEFAULT, // 40ms - .launch_motor_timer = SETTING_NAV_FW_LAUNCH_MOTOR_DELAY_DEFAULT, // ms - .launch_idle_motor_timer = SETTING_NAV_FW_LAUNCH_IDLE_MOTOR_DELAY_DEFAULT, // ms - .launch_wiggle_wake_idle = SETTING_NAV_FW_LAUNCH_WIGGLE_TO_WAKE_IDLE_DEFAULT, // uint8_t - .launch_motor_spinup_time = SETTING_NAV_FW_LAUNCH_SPINUP_TIME_DEFAULT, // ms, time to greaually increase throttle from idle to launch - .launch_end_time = SETTING_NAV_FW_LAUNCH_END_TIME_DEFAULT, // ms, time to gradually decrease/increase throttle and decrease pitch angle from launch to the current flight mode - .launch_min_time = SETTING_NAV_FW_LAUNCH_MIN_TIME_DEFAULT, // ms, min time in launch mode - .launch_timeout = SETTING_NAV_FW_LAUNCH_TIMEOUT_DEFAULT, // ms, timeout for launch procedure - .launch_max_altitude = SETTING_NAV_FW_LAUNCH_MAX_ALTITUDE_DEFAULT, // cm, altitude where to consider launch ended - .launch_climb_angle = SETTING_NAV_FW_LAUNCH_CLIMB_ANGLE_DEFAULT, // 18 degrees - .launch_max_angle = SETTING_NAV_FW_LAUNCH_MAX_ANGLE_DEFAULT, // 45 deg - .launch_manual_throttle = SETTING_NAV_FW_LAUNCH_MANUAL_THROTTLE_DEFAULT, // OFF - .launch_abort_deadband = SETTING_NAV_FW_LAUNCH_ABORT_DEADBAND_DEFAULT, // 100 us + .launch_velocity_thresh = SETTING_NAV_FW_LAUNCH_VELOCITY_DEFAULT, // 3 m/s + .launch_accel_thresh = SETTING_NAV_FW_LAUNCH_ACCEL_DEFAULT, // cm/s/s (1.9*G) + .launch_time_thresh = SETTING_NAV_FW_LAUNCH_DETECT_TIME_DEFAULT, // 40ms + .launch_motor_timer = SETTING_NAV_FW_LAUNCH_MOTOR_DELAY_DEFAULT, // ms + .launch_idle_motor_timer = SETTING_NAV_FW_LAUNCH_IDLE_MOTOR_DELAY_DEFAULT, // ms + .launch_wiggle_wake_idle = SETTING_NAV_FW_LAUNCH_WIGGLE_TO_WAKE_IDLE_DEFAULT, // uint8_t + .launch_motor_spinup_time = SETTING_NAV_FW_LAUNCH_SPINUP_TIME_DEFAULT, // ms, time to greaually increase throttle from idle to launch + .launch_end_time = SETTING_NAV_FW_LAUNCH_END_TIME_DEFAULT, // ms, time to gradually decrease/increase throttle and decrease pitch angle from launch to the current flight mode + .launch_min_time = SETTING_NAV_FW_LAUNCH_MIN_TIME_DEFAULT, // ms, min time in launch mode + .launch_timeout = SETTING_NAV_FW_LAUNCH_TIMEOUT_DEFAULT, // ms, timeout for launch procedure + .launch_max_altitude = SETTING_NAV_FW_LAUNCH_MAX_ALTITUDE_DEFAULT, // cm, altitude where to consider launch ended + .launch_climb_angle = SETTING_NAV_FW_LAUNCH_CLIMB_ANGLE_DEFAULT, // 18 degrees + .launch_max_angle = SETTING_NAV_FW_LAUNCH_MAX_ANGLE_DEFAULT, // 45 deg + .launch_manual_throttle = SETTING_NAV_FW_LAUNCH_MANUAL_THROTTLE_DEFAULT, // OFF + .launch_land_abort_deadband = SETTING_NAV_FW_LAUNCH_LAND_ABORT_DEADBAND_DEFAULT, // 100 us .allow_manual_thr_increase = SETTING_NAV_FW_ALLOW_MANUAL_THR_INCREASE_DEFAULT, .useFwNavYawControl = SETTING_NAV_USE_FW_YAW_CONTROL_DEFAULT, .yawControlDeadband = SETTING_NAV_FW_YAW_DEADBAND_DEFAULT, - .soaring_pitch_deadband = SETTING_NAV_FW_SOARING_PITCH_DEADBAND_DEFAULT, // pitch angle mode deadband when Saoring mode enabled - .wp_tracking_accuracy = SETTING_NAV_FW_WP_TRACKING_ACCURACY_DEFAULT, // 0, improves course tracking accuracy during FW WP missions - .wp_tracking_max_angle = SETTING_NAV_FW_WP_TRACKING_MAX_ANGLE_DEFAULT, // 60 degs - .wp_turn_smoothing = SETTING_NAV_FW_WP_TURN_SMOOTHING_DEFAULT, // 0, smooths turns during FW WP mode missions + .soaring_pitch_deadband = SETTING_NAV_FW_SOARING_PITCH_DEADBAND_DEFAULT, // pitch angle mode deadband when Saoring mode enabled + .wp_tracking_accuracy = SETTING_NAV_FW_WP_TRACKING_ACCURACY_DEFAULT, // 0, improves course tracking accuracy during FW WP missions + .wp_tracking_max_angle = SETTING_NAV_FW_WP_TRACKING_MAX_ANGLE_DEFAULT, // 60 degs + .wp_turn_smoothing = SETTING_NAV_FW_WP_TURN_SMOOTHING_DEFAULT, // 0, smooths turns during FW WP mode missions } ); From 22a6922297264abd4d439dc5079efa76f1721a64 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Fri, 29 Mar 2024 15:09:10 +0100 Subject: [PATCH 125/241] Bring back setting to disarm regardless of throttle position --- src/main/fc/rc_controls.c | 5 ++++- src/main/fc/rc_controls.h | 1 + src/main/fc/settings.yaml | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/fc/rc_controls.c b/src/main/fc/rc_controls.c index b06b4bf51fe..d03bd466a49 100644 --- a/src/main/fc/rc_controls.c +++ b/src/main/fc/rc_controls.c @@ -91,6 +91,7 @@ PG_REGISTER_WITH_RESET_TEMPLATE(armingConfig_t, armingConfig, PG_ARMING_CONFIG, PG_RESET_TEMPLATE(armingConfig_t, armingConfig, .fixed_wing_auto_arm = SETTING_FIXED_WING_AUTO_ARM_DEFAULT, + .disarm_always = SETTING_DISARM_ALWAYS_DEFAULT, .switchDisarmDelayMs = SETTING_SWITCH_DISARM_DELAY_DEFAULT, .prearmTimeoutMs = SETTING_PREARM_TIMEOUT_DEFAULT, ); @@ -230,7 +231,9 @@ void processRcStickPositions(bool isThrottleLow) if (ARMING_FLAG(ARMED) && !IS_RC_MODE_ACTIVE(BOXFAILSAFE) && rxIsReceivingSignal() && !failsafeIsActive()) { const timeMs_t disarmDelay = currentTimeMs - rcDisarmTimeMs; if (disarmDelay > armingConfig()->switchDisarmDelayMs) { - disarm(DISARM_SWITCH); + if (armingConfig()->disarm_always || isThrottleLow) { + disarm(DISARM_SWITCH); + } } } else { diff --git a/src/main/fc/rc_controls.h b/src/main/fc/rc_controls.h index 4ea5b9f3f50..8d5ee66bd73 100644 --- a/src/main/fc/rc_controls.h +++ b/src/main/fc/rc_controls.h @@ -95,6 +95,7 @@ PG_DECLARE(rcControlsConfig_t, rcControlsConfig); typedef struct armingConfig_s { bool fixed_wing_auto_arm; // Auto-arm fixed wing aircraft on throttle up and never disarm + bool disarm_always; // Disarm motors regardless of throttle value uint16_t switchDisarmDelayMs; // additional delay between ARM box going off and actual disarm uint16_t prearmTimeoutMs; // duration for which Prearm being activated is valid. after this, Prearm needs to be reset. 0 means Prearm does not timeout. } armingConfig_t; diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index abab04fbc5d..106a830decc 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -1496,6 +1496,10 @@ groups: description: "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." default_value: OFF type: bool + - name: disarm_always + description: "Disarms the motors independently of throttle value. Setting to OFF reverts to the old behaviour of disarming only when the throttle is low." + default_value: ON + type: bool - name: switch_disarm_delay description: "Delay before disarming when requested by switch (ms) [0-1000]" default_value: 250 From 68b88ccb97a0179ed9c9079af5902994648f8133 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Fri, 29 Mar 2024 16:45:05 +0100 Subject: [PATCH 126/241] Docs update --- docs/Settings.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/Settings.md b/docs/Settings.md index a157f56010e..fefcc927f20 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -672,6 +672,16 @@ Defines debug values exposed in debug variables (developer / debugging setting) --- +### disarm_always + +Disarms the motors independently of throttle value. Setting to OFF reverts to the old behaviour of disarming only when the throttle is low. + +| Default | Min | Max | +| --- | --- | --- | +| ON | OFF | ON | + +--- + ### display_force_sw_blink OFF = OSD hardware blink / ON = OSD software blink. If OSD warning text/values are invisible, try setting this to ON From fda19e78b8ce1062f7d1afaf074cdaebcede42d4 Mon Sep 17 00:00:00 2001 From: error414 Date: Fri, 1 Dec 2023 22:05:43 +0100 Subject: [PATCH 127/241] * terarange evo lidar --- docs/Rangefinder.md | 1 + src/main/CMakeLists.txt | 2 + src/main/common/maths.h | 2 + src/main/drivers/bus.h | 1 + .../rangefinder/rangefinder_teraranger_evo.c | 128 ++++++++++++++++++ .../rangefinder/rangefinder_teraranger_evo.h | 29 ++++ src/main/fc/settings.yaml | 2 +- src/main/sensors/rangefinder.c | 9 ++ src/main/sensors/rangefinder.h | 19 +-- src/main/target/common.h | 1 + src/main/target/common_hardware.c | 9 ++ 11 files changed, 193 insertions(+), 10 deletions(-) create mode 100644 src/main/drivers/rangefinder/rangefinder_teraranger_evo.c create mode 100644 src/main/drivers/rangefinder/rangefinder_teraranger_evo.h diff --git a/docs/Rangefinder.md b/docs/Rangefinder.md index b7910b0fa6c..095a6f0df33 100644 --- a/docs/Rangefinder.md +++ b/docs/Rangefinder.md @@ -20,6 +20,7 @@ Following rangefinders are supported: * UIB - experimental * MSP - experimental * TOF10120 - small & lightweight laser range sensor, usable up to 200cm +* TERARANGER EVO - 30cm to 600cm, depends on version https://www.terabee.com/sensors-modules/lidar-tof-range-finders/#individual-distance-measurement-sensors ## Connections diff --git a/src/main/CMakeLists.txt b/src/main/CMakeLists.txt index 98a43854cf2..cba13db687e 100755 --- a/src/main/CMakeLists.txt +++ b/src/main/CMakeLists.txt @@ -237,6 +237,8 @@ main_sources(COMMON_SRC drivers/rangefinder/rangefinder_us42.h drivers/rangefinder/rangefinder_tof10120_i2c.c drivers/rangefinder/rangefinder_tof10120_i2c.h + drivers/rangefinder/rangefinder_teraranger_evo.c + drivers/rangefinder/rangefinder_teraranger_evo.h drivers/resource.c drivers/resource.h diff --git a/src/main/common/maths.h b/src/main/common/maths.h index c681080500f..0e72d90e50e 100644 --- a/src/main/common/maths.h +++ b/src/main/common/maths.h @@ -56,6 +56,8 @@ #define RADIANS_TO_CENTIDEGREES(angle) (((angle) * 100.0f) / RAD) #define CENTIDEGREES_TO_RADIANS(angle) (((angle) * 0.01f) * RAD) +#define MILLIMETERS_TO_CENTIMETERS(mm) (mm / 10.0f) + #define CENTIMETERS_TO_CENTIFEET(cm) (cm / 0.3048f) #define CENTIMETERS_TO_FEET(cm) (cm / 30.48f) #define CENTIMETERS_TO_METERS(cm) (cm * 0.01f) diff --git a/src/main/drivers/bus.h b/src/main/drivers/bus.h index eca213b7218..6c2cedaff02 100644 --- a/src/main/drivers/bus.h +++ b/src/main/drivers/bus.h @@ -135,6 +135,7 @@ typedef enum { DEVHW_VL53L1X, DEVHW_US42, DEVHW_TOF10120_I2C, + DEVHW_TERARANGER_EVO_I2C, /* Other hardware */ DEVHW_MS4525, // Pitot meter diff --git a/src/main/drivers/rangefinder/rangefinder_teraranger_evo.c b/src/main/drivers/rangefinder/rangefinder_teraranger_evo.c new file mode 100644 index 00000000000..1c397f5a381 --- /dev/null +++ b/src/main/drivers/rangefinder/rangefinder_teraranger_evo.c @@ -0,0 +1,128 @@ +/* + * 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 "platform.h" + +#include "common/maths.h" + +#if defined(USE_RANGEFINDER) && defined(USE_RANGEFINDER_TERARANGER_EVO_I2C) + +#include "build/build_config.h" + +#include "common/crc.h" + +#include "drivers/time.h" +#include "drivers/bus_i2c.h" + +#include "drivers/rangefinder/rangefinder.h" +#include "drivers/rangefinder/rangefinder_teraranger_evo.h" + +#include "build/debug.h" + +#define TERARANGER_EVO_DETECTION_CONE_DECIDEGREES 900 +#define TERARANGER_EVO_DETECTION_CONE_EXTENDED_DECIDEGREES 900 + +#define TERARANGER_EVO_I2C_ADDRESS 0x31 +#define TERARANGER_EVO_I2C_REGISTRY_TRIGGER_READING 0x00 // Write this command to the TeraRanger Evo and after a wait of approximately 500us read the 3 byte distance response +#define TERARANGER_EVO_I2C_REGISTRY_WHO_AM_I 0x01 // Write this value to TeraRanger Evo via I2C and the device responds with 0xA +#define TERARANGER_EVO_I2C_REGISTRY_CHANGE_BASE_ADDR 0xA2 // This command assigns a base address that will be memorised by the TerRanger Evo ie. power cycling the Evo will not restore the default I2C address. + +#define TERARANGER_EVO_I2C_ANSWER_WHO_AM_I 0xA1 + +#define TERARANGER_EVO_VALUE_TOO_CLOSE 0x0000 +#define TERARANGER_EVO_VALUE_OUT_OF_RANGE 0xffff + +static int16_t minimumReadingIntervalMs = 50; + uint8_t triggerValue[0]; +volatile int32_t teraRangerMeasurementCm; +static uint32_t timeOfLastMeasurementMs; +static uint8_t dataBuff[3]; + +static void teraRangerInit(rangefinderDev_t *rangefinder){ + busWriteBuf(rangefinder->busDev, TERARANGER_EVO_I2C_REGISTRY_TRIGGER_READING, triggerValue, 1); +} + +void teraRangerUpdate(rangefinderDev_t *rangefinder){ + if (busReadBuf(rangefinder->busDev, TERARANGER_EVO_I2C_REGISTRY_TRIGGER_READING, dataBuff, 3)) { + teraRangerMeasurementCm = MILLIMETERS_TO_CENTIMETERS(((int32_t)dataBuff[0] << 8 | (int32_t)dataBuff[1])); + + if(dataBuff[2] == crc8_update(0, &dataBuff, 2)){ + if (teraRangerMeasurementCm == TERARANGER_EVO_VALUE_TOO_CLOSE || teraRangerMeasurementCm == TERARANGER_EVO_VALUE_OUT_OF_RANGE) { + teraRangerMeasurementCm = RANGEFINDER_OUT_OF_RANGE; + } + } + } else { + teraRangerMeasurementCm = RANGEFINDER_HARDWARE_FAILURE; + } + + const timeMs_t timeNowMs = millis(); + if (timeNowMs > timeOfLastMeasurementMs + minimumReadingIntervalMs) { + // measurement repeat interval should be greater than minimumReadingIntervalMs + // to avoid interference between connective measurements. + timeOfLastMeasurementMs = timeNowMs; + busWriteBuf(rangefinder->busDev, TERARANGER_EVO_I2C_ADDRESS, triggerValue, 1); + } +} + + +int32_t teraRangerGetDistance(rangefinderDev_t *rangefinder){ + UNUSED(rangefinder); + return teraRangerMeasurementCm; +} + +static bool deviceDetect(busDevice_t * busDev){ + for (int retry = 0; retry < 5; retry++) { + uint8_t whoIamResult; + + delay(150); + + bool ack = busRead(busDev, TERARANGER_EVO_I2C_REGISTRY_WHO_AM_I, &whoIamResult); + if (ack && whoIamResult == TERARANGER_EVO_I2C_ANSWER_WHO_AM_I) { + return true; + } + }; + + return false; +} + +bool teraRangerDetect(rangefinderDev_t *rangefinder){ + rangefinder->busDev = busDeviceInit(BUSTYPE_I2C, DEVHW_TERARANGER_EVO_I2C, 0, OWNER_RANGEFINDER); + if (rangefinder->busDev == NULL) { + return false; + } + + if (!deviceDetect(rangefinder->busDev)) { + busDeviceDeInit(rangefinder->busDev); + return false; + } + + rangefinder->delayMs = RANGEFINDER_TERA_EVO_TASK_PERIOD_MS; + rangefinder->maxRangeCm = RANGEFINDER_TERA_EVO_MAX_RANGE_CM; + rangefinder->detectionConeDeciDegrees = TERARANGER_EVO_DETECTION_CONE_DECIDEGREES; + rangefinder->detectionConeExtendedDeciDegrees = TERARANGER_EVO_DETECTION_CONE_EXTENDED_DECIDEGREES; + + rangefinder->init = &teraRangerInit; + rangefinder->update = &teraRangerUpdate; + rangefinder->read = &teraRangerGetDistance; + + return true; +} + +#endif \ No newline at end of file diff --git a/src/main/drivers/rangefinder/rangefinder_teraranger_evo.h b/src/main/drivers/rangefinder/rangefinder_teraranger_evo.h new file mode 100644 index 00000000000..be7618eca95 --- /dev/null +++ b/src/main/drivers/rangefinder/rangefinder_teraranger_evo.h @@ -0,0 +1,29 @@ +/* + * This file is part of INAV. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * Alternatively, the contents of this file may be used under the terms + * of the GNU General Public License Version 3, as described below: + * + * This file is free software: you may copy, redistribute 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. + * + * This file 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 this program. If not, see http://www.gnu.org/licenses/. + */ +#pragma once + +#define RANGEFINDER_TERA_EVO_TASK_PERIOD_MS 70 +#define RANGEFINDER_TERA_EVO_MAX_RANGE_CM 600 // max distance depends on model https://www.terabee.com/sensors-modules/lidar-tof-range-finders/#individual-distance-measurement-sensors + +bool teraRangerDetect(rangefinderDev_t *dev); diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index 0afd4c8baef..d7a317c5308 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -7,7 +7,7 @@ tables: values: ["NONE", "AUTO", "MPU6000", "MPU6500", "MPU9250", "BMI160", "ICM20689", "BMI088", "ICM42605", "BMI270","LSM6DXX", "FAKE"] enum: accelerationSensor_e - name: rangefinder_hardware - values: ["NONE", "SRF10", "VL53L0X", "MSP", "BENEWAKE", "VL53L1X", "US42", "TOF10120_I2C", "FAKE"] + values: ["NONE", "SRF10", "VL53L0X", "MSP", "BENEWAKE", "VL53L1X", "US42", "TOF10120_I2C", "FAKE", "TERARANGER_EVO"] enum: rangefinderType_e - name: mag_hardware values: ["NONE", "AUTO", "HMC5883", "AK8975", "MAG3110", "AK8963", "IST8310", "QMC5883", "MPU9250", "IST8308", "LIS3MDL", "MSP", "RM3100", "VCM5883", "MLX90393", "FAKE"] diff --git a/src/main/sensors/rangefinder.c b/src/main/sensors/rangefinder.c index a4af166cfe9..88f027f1545 100644 --- a/src/main/sensors/rangefinder.c +++ b/src/main/sensors/rangefinder.c @@ -41,6 +41,7 @@ #include "drivers/rangefinder/rangefinder_vl53l1x.h" #include "drivers/rangefinder/rangefinder_virtual.h" #include "drivers/rangefinder/rangefinder_us42.h" +#include "drivers/rangefinder/rangefinder_teraranger_evo.h" #include "drivers/rangefinder/rangefinder_tof10120_i2c.h" #include "fc/config.h" @@ -88,6 +89,14 @@ static bool rangefinderDetect(rangefinderDev_t * dev, uint8_t rangefinderHardwar #endif break; + case RANGEFINDER_TERARANGER_EVO: +#if defined(USE_RANGEFINDER_TERARANGER_EVO_I2C) + if (teraRangerDetect(dev)) { + rangefinderHardware = RANGEFINDER_TERARANGER_EVO; + rescheduleTask(TASK_RANGEFINDER, TASK_PERIOD_MS(RANGEFINDER_TERA_EVO_TASK_PERIOD_MS)); + } +#endif + break; case RANGEFINDER_VL53L0X: #if defined(USE_RANGEFINDER_VL53L0X) if (vl53l0xDetect(dev)) { diff --git a/src/main/sensors/rangefinder.h b/src/main/sensors/rangefinder.h index a57253bd3f5..2888e7838af 100644 --- a/src/main/sensors/rangefinder.h +++ b/src/main/sensors/rangefinder.h @@ -22,15 +22,16 @@ #include "drivers/rangefinder/rangefinder.h" typedef enum { - RANGEFINDER_NONE = 0, - RANGEFINDER_SRF10 = 1, - RANGEFINDER_VL53L0X = 2, - RANGEFINDER_MSP = 3, - RANGEFINDER_BENEWAKE = 4, - RANGEFINDER_VL53L1X = 5, - RANGEFINDER_US42 = 6, - RANGEFINDER_TOF10102I2C = 7, - RANGEFINDER_FAKE = 8, + RANGEFINDER_NONE = 0, + RANGEFINDER_SRF10 = 1, + RANGEFINDER_VL53L0X = 2, + RANGEFINDER_MSP = 3, + RANGEFINDER_BENEWAKE = 4, + RANGEFINDER_VL53L1X = 5, + RANGEFINDER_US42 = 6, + RANGEFINDER_TOF10102I2C = 7, + RANGEFINDER_FAKE = 8, + RANGEFINDER_TERARANGER_EVO = 9, } rangefinderType_e; typedef struct rangefinderConfig_s { diff --git a/src/main/target/common.h b/src/main/target/common.h index 8bbaadef718..d2f83fab038 100644 --- a/src/main/target/common.h +++ b/src/main/target/common.h @@ -83,6 +83,7 @@ #define USE_RANGEFINDER_VL53L1X #define USE_RANGEFINDER_US42 #define USE_RANGEFINDER_TOF10120_I2C +#define USE_RANGEFINDER_TERARANGER_EVO_I2C // Allow default optic flow boards #define USE_OPFLOW diff --git a/src/main/target/common_hardware.c b/src/main/target/common_hardware.c index 76ffbf19420..3346bb92515 100755 --- a/src/main/target/common_hardware.c +++ b/src/main/target/common_hardware.c @@ -341,6 +341,15 @@ #endif #endif +#if defined(USE_RANGEFINDER_TERARANGER_EVO_I2C) + #if !defined(TERARANGER_EVO_I2C_BUS) && defined(RANGEFINDER_I2C_BUS) + #define TERARANGER_EVO_I2C_BUS RANGEFINDER_I2C_BUS + #endif + #if defined(TERARANGER_EVO_I2C_BUS) + BUSDEV_REGISTER_I2C(busdev_teraranger_evo, DEVHW_TERARANGER_EVO_I2C, TERARANGER_EVO_I2C_BUS, 0x31, NONE, DEVFLAGS_NONE, 0); + #endif +#endif + #if defined(USE_RANGEFINDER_TOF10120_I2C) && (defined(TOF10120_I2C_BUS) || defined(RANGEFINDER_I2C_BUS)) #if !defined(TOF10120_I2C_BUS) #define TOF10120_I2C_BUS RANGEFINDER_I2C_BUS From c333f97ccbd0997eb4db007c26a62f8fc5b70510 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Fri, 29 Mar 2024 19:22:45 +0100 Subject: [PATCH 128/241] Drop MSP_SERVO_MIX_RULES --- src/main/fc/fc_msp.c | 25 ------------------------- src/main/msp/msp_protocol.h | 2 -- src/main/msp/msp_protocol_v2_common.h | 1 - 3 files changed, 28 deletions(-) diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index 2d47d0ec2e9..d23537a75bf 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -504,17 +504,6 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF sbufWriteU32(dst, 0); //Input reversing is not required since it can be done on mixer level } break; - case MSP_SERVO_MIX_RULES: - for (int i = 0; i < MAX_SERVO_RULES; i++) { - sbufWriteU8(dst, customServoMixers(i)->targetChannel); - sbufWriteU8(dst, customServoMixers(i)->inputSource); - sbufWriteU16(dst, customServoMixers(i)->rate); - sbufWriteU8(dst, customServoMixers(i)->speed); - sbufWriteU8(dst, 0); - sbufWriteU8(dst, 100); - sbufWriteU8(dst, 0); - } - break; case MSP2_INAV_SERVO_MIXER: for (int i = 0; i < MAX_SERVO_RULES; i++) { sbufWriteU8(dst, customServoMixers(i)->targetChannel); @@ -2136,20 +2125,6 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) } break; - case MSP_SET_SERVO_MIX_RULE: - sbufReadU8Safe(&tmp_u8, src); - if ((dataSize == 9) && (tmp_u8 < MAX_SERVO_RULES)) { - customServoMixersMutable(tmp_u8)->targetChannel = sbufReadU8(src); - customServoMixersMutable(tmp_u8)->inputSource = sbufReadU8(src); - customServoMixersMutable(tmp_u8)->rate = sbufReadU16(src); - customServoMixersMutable(tmp_u8)->speed = sbufReadU8(src); - sbufReadU16(src); //Read 2bytes for min/max and ignore it - sbufReadU8(src); //Read 1 byte for `box` and ignore it - loadCustomServoMixer(); - } else - return MSP_RESULT_ERROR; - break; - case MSP2_INAV_SET_SERVO_MIXER: sbufReadU8Safe(&tmp_u8, src); if ((dataSize == 7) && (tmp_u8 < MAX_SERVO_RULES)) { diff --git a/src/main/msp/msp_protocol.h b/src/main/msp/msp_protocol.h index f3a925828e7..a04b6d645d7 100644 --- a/src/main/msp/msp_protocol.h +++ b/src/main/msp/msp_protocol.h @@ -297,8 +297,6 @@ #define MSP_GPSSTATISTICS 166 //out message get GPS debugging data #define MSP_ACC_TRIM 240 //out message get acc angle trim values #define MSP_SET_ACC_TRIM 239 //in message set acc angle trim values -#define MSP_SERVO_MIX_RULES 241 //out message Returns servo mixer configuration -#define MSP_SET_SERVO_MIX_RULE 242 //in message Sets servo mixer configuration #define MSP_SET_PASSTHROUGH 245 //in message Sets up passthrough to different peripherals (4way interface, uart, etc...) #define MSP_RTC 246 //out message Gets the RTC clock (returns: secs(i32) millis(u16) - (0,0) if time is not known) #define MSP_SET_RTC 247 //in message Sets the RTC clock (args: secs(i32) millis(u16)) diff --git a/src/main/msp/msp_protocol_v2_common.h b/src/main/msp/msp_protocol_v2_common.h index 82b7f754079..2d87219ac6b 100644 --- a/src/main/msp/msp_protocol_v2_common.h +++ b/src/main/msp/msp_protocol_v2_common.h @@ -32,4 +32,3 @@ // radar commands #define MSP2_COMMON_SET_RADAR_POS 0x100B //SET radar position information #define MSP2_COMMON_SET_RADAR_ITD 0x100C //SET radar information to display - From c29208051e87cc708a517c9e4d75508d881cfe58 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Fri, 29 Mar 2024 19:34:50 +0100 Subject: [PATCH 129/241] MSP2_INAV_SERVO_CONFIG frame --- src/main/fc/fc_msp.c | 16 +++++----------- src/main/msp/msp_protocol_v2_inav.h | 2 ++ 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index d23537a75bf..4097617f893 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -492,18 +492,16 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF case MSP_SERVO: sbufWriteData(dst, &servo, MAX_SUPPORTED_SERVOS * 2); break; - case MSP_SERVO_CONFIGURATIONS: + + case MSP2_INAV_SERVO_CONFIG: for (int i = 0; i < MAX_SUPPORTED_SERVOS; i++) { sbufWriteU16(dst, servoParams(i)->min); sbufWriteU16(dst, servoParams(i)->max); sbufWriteU16(dst, servoParams(i)->middle); sbufWriteU8(dst, servoParams(i)->rate); - sbufWriteU8(dst, 0); - sbufWriteU8(dst, 0); - sbufWriteU8(dst, 255); // used to be forwardFromChannel, not used anymore, send 0xff for compatibility reasons - sbufWriteU32(dst, 0); //Input reversing is not required since it can be done on mixer level } break; + case MSP2_INAV_SERVO_MIXER: for (int i = 0; i < MAX_SERVO_RULES; i++) { sbufWriteU8(dst, customServoMixers(i)->targetChannel); @@ -2105,8 +2103,8 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) return MSP_RESULT_ERROR; break; - case MSP_SET_SERVO_CONFIGURATION: - if (dataSize != (1 + 14)) { + case MSP2_INAV_SET_SERVO_CONFIG: + if (dataSize != 8) { return MSP_RESULT_ERROR; } tmp_u8 = sbufReadU8(src); @@ -2117,10 +2115,6 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) servoParamsMutable(tmp_u8)->max = sbufReadU16(src); servoParamsMutable(tmp_u8)->middle = sbufReadU16(src); servoParamsMutable(tmp_u8)->rate = sbufReadU8(src); - sbufReadU8(src); - sbufReadU8(src); - sbufReadU8(src); // used to be forwardFromChannel, ignored - sbufReadU32(src); // used to be reversedSources servoComputeScalingFactors(tmp_u8); } break; diff --git a/src/main/msp/msp_protocol_v2_inav.h b/src/main/msp/msp_protocol_v2_inav.h index 66e883ab8c7..3312e5bc25d 100755 --- a/src/main/msp/msp_protocol_v2_inav.h +++ b/src/main/msp/msp_protocol_v2_inav.h @@ -108,3 +108,5 @@ #define MSP2_INAV_CUSTOM_OSD_ELEMENTS 0x2100 #define MSP2_INAV_SET_CUSTOM_OSD_ELEMENTS 0x2101 +#define MSP2_INAV_SERVO_CONFIG 0x2200 +#define MSP2_INAV_SET_SERVO_CONFIG 0x2201 \ No newline at end of file From 91460013c2c56fa9b35efe1434b353a78962f21f Mon Sep 17 00:00:00 2001 From: Ray Morris Date: Sun, 31 Mar 2024 23:53:16 -0500 Subject: [PATCH 130/241] fix broken links to modes.md --- build_docs.sh | 3 +-- docs/API/MSP_extensions.md | 6 +++--- docs/Getting Started.md | 2 +- docs/Safety.md | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/build_docs.sh b/build_docs.sh index 70c2cc45cfb..9711d8775cf 100755 --- a/build_docs.sh +++ b/build_docs.sh @@ -21,7 +21,6 @@ doc_files=( 'Buzzer.md' 'Sonar.md' 'Profiles.md' - 'Modes.md' 'Inflight Adjustments.md' 'Controls.md' 'Gtune.md' @@ -49,7 +48,7 @@ if which gimli >/dev/null; then done rm -f ${filename}.pdf gimli -f ${filename}.md -stylesheet override.css \ - -w '--toc --title "Cleanflight Manual" --footer-right "[page]" --toc-depth 1' + -w '--toc --title "INAV Manual" --footer-right "[page]" --toc-depth 1' rm ${filename}.md popd >/dev/null else diff --git a/docs/API/MSP_extensions.md b/docs/API/MSP_extensions.md index 357c6239e87..2ac8dd989f9 100644 --- a/docs/API/MSP_extensions.md +++ b/docs/API/MSP_extensions.md @@ -23,7 +23,7 @@ Unassigned slots have rangeStartStep == rangeEndStep. Each element contains the | Data | Type | Notes | |------|------|-------| -| permanentId | uint8 | See Modes.md for a definition of the permanent ids | +| permanentId | uint8 | See [Modes in the wiki](https://github.com/iNavFlight/inav/wiki/Modes) for a definition of the permanent ids | | auxChannelIndex | uint8 | The Aux switch number (indexed from 0) | | rangeStartStep | uint8 | The start value for this element in 'blocks' of 25 where 0 == 900 and 48 == 2100 | | rangeEndStep | uint8 | The end value for this element in 'blocks' of 25 where 0 == 900 and 48 == 2100 | @@ -45,7 +45,7 @@ sending this message for all auxiliary slots. | Data | Type | Notes | |------|------|-------| | sequence id | uint8 | A monotonically increasing ID, from 0 to the number of slots -1 | -| permanentId | uint8 | See Modes.md for a definition of the permanent ids | +| permanentId | uint8 | See [Modes in the wiki](https://github.com/iNavFlight/inav/wiki/Modes) for a definition of the permanent ids | | auxChannelIndex | uint8 | The Aux channel number (indexed from 0) | | rangeStartStep | uint8 | The start value for this element in 'blocks' of 25 where 0 == 900 and 48 == 2100 | | rangeEndStep | uint8 | The end value for this element in 'blocks' of 25 where 0 == 900 and 48 == 2100 | @@ -157,5 +157,5 @@ INAV. See also -------- -Modes.md describes the user visible implementation for the INAV +[The wiki](https://github.com/iNavFlight/inav/wiki/Modes) describes the user visible implementation for the INAV modes extension. diff --git a/docs/Getting Started.md b/docs/Getting Started.md index 2faa8e33234..f49ca32cc44 100644 --- a/docs/Getting Started.md +++ b/docs/Getting Started.md @@ -70,7 +70,7 @@ Now, there are two ways to [configure CF](Configuration.md); via the Configurat * Verify the range of each channel goes from ~1000 to ~2000. See also [controls](Controls.md). and `rx_min_usec` and `rx_max_usec`. * You can also set EXPO here instead of your Tx. * Click Save! -* Modes tab: Setup the desired modes. See the [modes](Modes.md) chapter for what each mode does, but for the beginning you mainly need HORIZON, if any. +* Modes tab: Setup the desired modes. See the [Modes in the wiki](https://github.com/iNavFlight/inav/wiki/Modes) for what each mode does. * Before finishing this section, you should calibrate the ESCs, install the FC to the frame, and connect the RSSI cable, buzzer and battery if you have chosen to use those. diff --git a/docs/Safety.md b/docs/Safety.md index e0b969a78ab..ea21424391f 100644 --- a/docs/Safety.md +++ b/docs/Safety.md @@ -6,7 +6,7 @@ As many can attest, multirotors and RC models in general can be very dangerous, ## Before Installing -Please consult the [Cli](Cli.md), [Controls](Controls.md), [Failsafe](Failsafe.md) and [Modes](Modes.md) +Please consult the [Cli](Cli.md), [Controls](Controls.md), [Failsafe](Failsafe.md) and [Modes](https://github.com/iNavFlight/inav/wiki/Modes) pages for further important information. You are highly advised to use the Receiver tab in the INAV Configurator, making sure your Rx channel From 601bcfecbb3a3ca94de93a7cd8bf65b6cd093915 Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Mon, 1 Apr 2024 12:14:09 +0100 Subject: [PATCH 131/241] Added missing include. Thought it was already there --- src/main/io/osd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 468ac039c25..4d2fb29d459 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "platform.h" From 1e09f0d075d2c75a4023b8cd897e3863bf32512f Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Tue, 2 Apr 2024 11:23:07 +0200 Subject: [PATCH 132/241] Potential fix for GCC 13 VCP broken on H7 --- src/main/drivers/nvic.h | 5 ++++- src/main/vcp_hal/usbd_cdc_interface.c | 17 +++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main/drivers/nvic.h b/src/main/drivers/nvic.h index 5a501fbc5ec..774bbc1c58f 100644 --- a/src/main/drivers/nvic.h +++ b/src/main/drivers/nvic.h @@ -23,7 +23,10 @@ // Use all available bits for priority and zero bits to sub-priority #ifdef USE_HAL_DRIVER #define NVIC_PRIORITY_GROUPING NVIC_PRIORITYGROUP_4 + + #define NVIC_BUILD_PRIORITY(base,sub) (((((base)<<(4-(7-(NVIC_PRIORITY_GROUPING))))|((sub)&(0x0f>>(7-(NVIC_PRIORITY_GROUPING)))))<<4)&0xf0) + #else #define NVIC_PRIORITY_GROUPING NVIC_PriorityGroup_4 #endif -#endif +#endif \ No newline at end of file diff --git a/src/main/vcp_hal/usbd_cdc_interface.c b/src/main/vcp_hal/usbd_cdc_interface.c index 8fd3abc6556..ef111e15e9f 100644 --- a/src/main/vcp_hal/usbd_cdc_interface.c +++ b/src/main/vcp_hal/usbd_cdc_interface.c @@ -54,6 +54,8 @@ #include "usbd_cdc_interface.h" #include "stdbool.h" #include "drivers/time.h" +#include "drivers/nvic.h" +#include "build/atomic.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ @@ -366,14 +368,13 @@ uint32_t CDC_Receive_BytesAvailable(void) uint32_t CDC_Send_FreeBytes(void) { - /* - return the bytes free in the circular buffer - - functionally equivalent to: - (APP_Rx_ptr_out > APP_Rx_ptr_in ? APP_Rx_ptr_out - APP_Rx_ptr_in : APP_RX_DATA_SIZE - APP_Rx_ptr_in + APP_Rx_ptr_in) - but without the impact of the condition check. - */ - return ((UserTxBufPtrOut - UserTxBufPtrIn) + (-((int)(UserTxBufPtrOut <= UserTxBufPtrIn)) & APP_TX_DATA_SIZE)) - 1; + uint32_t freeBytes; + + ATOMIC_BLOCK(NVIC_BUILD_PRIORITY(6, 0)) { + freeBytes = ((UserTxBufPtrOut - UserTxBufPtrIn) + (-((int)(UserTxBufPtrOut <= UserTxBufPtrIn)) & APP_TX_DATA_SIZE)) - 1; + } + + return freeBytes; } /** From 68bf64ae729a74cfa8a2be21ca6812e9a34897df Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Tue, 2 Apr 2024 11:30:54 +0200 Subject: [PATCH 133/241] Formatting fix --- src/main/vcp_hal/usbd_cdc_interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/vcp_hal/usbd_cdc_interface.c b/src/main/vcp_hal/usbd_cdc_interface.c index ef111e15e9f..cfb65471d63 100644 --- a/src/main/vcp_hal/usbd_cdc_interface.c +++ b/src/main/vcp_hal/usbd_cdc_interface.c @@ -368,7 +368,7 @@ uint32_t CDC_Receive_BytesAvailable(void) uint32_t CDC_Send_FreeBytes(void) { - uint32_t freeBytes; + uint32_t freeBytes; ATOMIC_BLOCK(NVIC_BUILD_PRIORITY(6, 0)) { freeBytes = ((UserTxBufPtrOut - UserTxBufPtrIn) + (-((int)(UserTxBufPtrOut <= UserTxBufPtrIn)) & APP_TX_DATA_SIZE)) - 1; From b199bea068df28d402fb9640f9d4be3d816f78bf Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Tue, 2 Apr 2024 11:41:04 +0200 Subject: [PATCH 134/241] Ignore overflow warning in atomic.h --- src/main/build/atomic.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/build/atomic.h b/src/main/build/atomic.h index 80ec70f55dd..73b592b493a 100644 --- a/src/main/build/atomic.h +++ b/src/main/build/atomic.h @@ -47,6 +47,7 @@ static inline uint8_t __basepriSetMemRetVal(uint8_t prio) #ifdef UNIT_TEST #define ATOMIC_BLOCK(prio) {} #else +#pragma GCC diagnostic ignored "-Woverflow" #define ATOMIC_BLOCK(prio) for ( uint8_t __basepri_save __attribute__((__cleanup__(__basepriRestoreMem))) = __get_BASEPRI(), \ __ToDo = __basepriSetMemRetVal((prio) << (8U - __NVIC_PRIO_BITS)); __ToDo ; __ToDo = 0 ) From 49f0f7c707afd41a6acc7eec8ea1dccefd3bc320 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Tue, 2 Apr 2024 13:13:26 +0200 Subject: [PATCH 135/241] Simplify matrix filter and drop all partial versions --- src/main/fc/settings.yaml | 2 +- .../flight/secondary_dynamic_gyro_notch.c | 27 +++---------------- src/main/sensors/gyro.c | 2 +- src/main/sensors/gyro.h | 6 ----- 4 files changed, 5 insertions(+), 32 deletions(-) diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index ff33c295fcd..6746e822686 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -179,7 +179,7 @@ tables: values: ["OFF", "ON", "FS"] enum: rthTrackbackMode_e - name: dynamic_gyro_notch_mode - values: ["2D", "3D_R", "3D_P", "3D_Y", "3D_RP", "3D_RY", "3D_PY", "3D"] + values: ["2D", "3D"] enum: dynamicGyroNotchMode_e - name: nav_fw_wp_turn_smoothing values: ["OFF", "ON", "ON-CUT"] diff --git a/src/main/flight/secondary_dynamic_gyro_notch.c b/src/main/flight/secondary_dynamic_gyro_notch.c index e3cfdced374..75d28bfc0f4 100644 --- a/src/main/flight/secondary_dynamic_gyro_notch.c +++ b/src/main/flight/secondary_dynamic_gyro_notch.c @@ -44,46 +44,25 @@ void secondaryDynamicGyroNotchFiltersInit(secondaryDynamicGyroNotchState_t *stat state->enabled = gyroConfig()->dynamicGyroNotchMode != DYNAMIC_NOTCH_MODE_2D; state->looptime = getLooptime(); - if ( - gyroConfig()->dynamicGyroNotchMode == DYNAMIC_NOTCH_MODE_R || - gyroConfig()->dynamicGyroNotchMode == DYNAMIC_NOTCH_MODE_RP || - gyroConfig()->dynamicGyroNotchMode == DYNAMIC_NOTCH_MODE_RY || - gyroConfig()->dynamicGyroNotchMode == DYNAMIC_NOTCH_MODE_3D - ) { + if (gyroConfig()->dynamicGyroNotchMode == DYNAMIC_NOTCH_MODE_3D) { /* * Enable ROLL filter */ biquadFilterInit(&state->filters[FD_ROLL], SECONDARY_DYNAMIC_NOTCH_DEFAULT_CENTER_HZ, state->looptime, 1.0f, FILTER_NOTCH); state->filtersApplyFn[FD_ROLL] = (filterApplyFnPtr)biquadFilterApplyDF1; - } - - if ( - gyroConfig()->dynamicGyroNotchMode == DYNAMIC_NOTCH_MODE_P || - gyroConfig()->dynamicGyroNotchMode == DYNAMIC_NOTCH_MODE_RP || - gyroConfig()->dynamicGyroNotchMode == DYNAMIC_NOTCH_MODE_PY || - gyroConfig()->dynamicGyroNotchMode == DYNAMIC_NOTCH_MODE_3D - ) { + /* * Enable PITCH filter */ biquadFilterInit(&state->filters[FD_PITCH], SECONDARY_DYNAMIC_NOTCH_DEFAULT_CENTER_HZ, state->looptime, 1.0f, FILTER_NOTCH); state->filtersApplyFn[FD_PITCH] = (filterApplyFnPtr)biquadFilterApplyDF1; - } - - if ( - gyroConfig()->dynamicGyroNotchMode == DYNAMIC_NOTCH_MODE_Y || - gyroConfig()->dynamicGyroNotchMode == DYNAMIC_NOTCH_MODE_PY || - gyroConfig()->dynamicGyroNotchMode == DYNAMIC_NOTCH_MODE_RY || - gyroConfig()->dynamicGyroNotchMode == DYNAMIC_NOTCH_MODE_3D - ) { + /* * Enable YAW filter */ biquadFilterInit(&state->filters[FD_YAW], SECONDARY_DYNAMIC_NOTCH_DEFAULT_CENTER_HZ, state->looptime, 1.0f, FILTER_NOTCH); state->filtersApplyFn[FD_YAW] = (filterApplyFnPtr)biquadFilterApplyDF1; } - - } void secondaryDynamicGyroNotchFiltersUpdate(secondaryDynamicGyroNotchState_t *state, int axis, float frequency[]) { diff --git a/src/main/sensors/gyro.c b/src/main/sensors/gyro.c index a586ce6df6b..6966d78899a 100644 --- a/src/main/sensors/gyro.c +++ b/src/main/sensors/gyro.c @@ -95,7 +95,7 @@ EXTENDED_FASTRAM secondaryDynamicGyroNotchState_t secondaryDynamicGyroNotchState #endif -PG_REGISTER_WITH_RESET_TEMPLATE(gyroConfig_t, gyroConfig, PG_GYRO_CONFIG, 6); +PG_REGISTER_WITH_RESET_TEMPLATE(gyroConfig_t, gyroConfig, PG_GYRO_CONFIG, 7); PG_RESET_TEMPLATE(gyroConfig_t, gyroConfig, .gyro_lpf = SETTING_GYRO_HARDWARE_LPF_DEFAULT, diff --git a/src/main/sensors/gyro.h b/src/main/sensors/gyro.h index 669f8fbee46..f21fc6a42c3 100644 --- a/src/main/sensors/gyro.h +++ b/src/main/sensors/gyro.h @@ -49,12 +49,6 @@ typedef enum { typedef enum { DYNAMIC_NOTCH_MODE_2D = 0, - DYNAMIC_NOTCH_MODE_R, - DYNAMIC_NOTCH_MODE_P, - DYNAMIC_NOTCH_MODE_Y, - DYNAMIC_NOTCH_MODE_RP, - DYNAMIC_NOTCH_MODE_RY, - DYNAMIC_NOTCH_MODE_PY, DYNAMIC_NOTCH_MODE_3D } dynamicGyroNotchMode_e; From 708695ff87fff1c3257872c9c682db74d303e64b Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Tue, 2 Apr 2024 13:25:41 +0200 Subject: [PATCH 136/241] Use static NVIC_PRIO_VCP for VCP free bytes --- src/main/drivers/nvic.h | 3 --- src/main/vcp_hal/usbd_cdc_interface.c | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/drivers/nvic.h b/src/main/drivers/nvic.h index 774bbc1c58f..cb484937d3d 100644 --- a/src/main/drivers/nvic.h +++ b/src/main/drivers/nvic.h @@ -23,9 +23,6 @@ // Use all available bits for priority and zero bits to sub-priority #ifdef USE_HAL_DRIVER #define NVIC_PRIORITY_GROUPING NVIC_PRIORITYGROUP_4 - - #define NVIC_BUILD_PRIORITY(base,sub) (((((base)<<(4-(7-(NVIC_PRIORITY_GROUPING))))|((sub)&(0x0f>>(7-(NVIC_PRIORITY_GROUPING)))))<<4)&0xf0) - #else #define NVIC_PRIORITY_GROUPING NVIC_PriorityGroup_4 #endif diff --git a/src/main/vcp_hal/usbd_cdc_interface.c b/src/main/vcp_hal/usbd_cdc_interface.c index cfb65471d63..2489d74fb26 100644 --- a/src/main/vcp_hal/usbd_cdc_interface.c +++ b/src/main/vcp_hal/usbd_cdc_interface.c @@ -370,7 +370,7 @@ uint32_t CDC_Send_FreeBytes(void) { uint32_t freeBytes; - ATOMIC_BLOCK(NVIC_BUILD_PRIORITY(6, 0)) { + ATOMIC_BLOCK(NVIC_PRIO_VCP) { freeBytes = ((UserTxBufPtrOut - UserTxBufPtrIn) + (-((int)(UserTxBufPtrOut <= UserTxBufPtrIn)) & APP_TX_DATA_SIZE)) - 1; } From 41366b3e0d7048508d145cf589f275abea4a13aa Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Tue, 2 Apr 2024 12:46:38 +0100 Subject: [PATCH 137/241] Update Building in Windows 10 or 11 with Linux Subsystem.md Update WSL docs to include Ninja. Some typos fixed too --- ...n Windows 10 or 11 with Linux Subsystem.md | 44 ++++++++++++++++--- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/docs/development/Building in Windows 10 or 11 with Linux Subsystem.md b/docs/development/Building in Windows 10 or 11 with Linux Subsystem.md index 9cee0ede253..217b0a05a4d 100644 --- a/docs/development/Building in Windows 10 or 11 with Linux Subsystem.md +++ b/docs/development/Building in Windows 10 or 11 with Linux Subsystem.md @@ -1,6 +1,6 @@ -# Building in Windows 10 with Linux subsystem [Recommended] +# Building in Windows 10/11 with Linux subsystem (WSL) [Recommended] -Linux subsystem for Windows 10 is probably the simplest way of building INAV under Windows 10. +Linux subsystem for Windows (WSL) 10/11 is probably the simplest way of building INAV under Windows. ## Setting up the environment @@ -9,7 +9,6 @@ run `windows features` enable `windows subsytem for linux` reboot - Install Ubuntu: 1. Go to Microsoft store https://www.microsoft.com/en-gb/store/b/home 1. Search and install most recent Ubuntu LTS version @@ -56,12 +55,12 @@ You can fix this with by remounting the drive using the following commands 1. `sudo umount /mnt/c` 2. `sudo mount -t drvfs C: /mnt/c -o metadata` -## Building (example): +## Building with Make (example): -For detailed build instrusctions see [Building in Linux](Building%20in%20Linux.md) +For detailed build instructions see [Building in Linux](Building%20in%20Linux.md) Launch Ubuntu: -Click Windows Start button then scroll and lauch "Ubuntu" +Click Windows Start button then scroll and launch "Ubuntu" Building from Ubuntu command line @@ -80,6 +79,39 @@ cd build make MATEKF722 ``` +## Building with Ninja (example): + +[Ninja](https://ninja-build.org/) is a popular cross-platform tool. It is both lightweight and executes parallel builds by default. It is advantageous to use this over the old _make_ method. There are detailed instructions for building with Ninja in [Building in Linux](Building%20in%20Linux.md#building-with-ninja). + +Launch Ubuntu: +Click Windows Start button. Then scroll and launch **Ubuntu**. + +> [!TIP] +> Before using Ninja, you will need to install it. From the Ubuntu command prompt type `sudo apt-get install ninja-build -y` and press enter. + +Building from the command line: + +First, change to the INAV directory with +```cd /mnt/c/inav``` + +Before building, you will need to prepare the build environment. You only need to do this once, unless you reinstall WSL or cmake. + +``` +mkdir build +cd build +cmake -GNinja .. +``` + +From then on, you can build your target by calling the following from inside the build directory. +``` +ninja MATEKF722 +``` + +If you want to build multiple targets. You can use: +``` +ninja MATEKF722 MATEKF405SE SPEEDYBEEF405 +``` + ## Updating the documents ``` cd /mnt/c/inav From 19597ea4337e294b94617bbdc4d9c7660c633cae Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Tue, 2 Apr 2024 14:14:55 +0200 Subject: [PATCH 138/241] Remove not needed warning supression --- src/main/build/atomic.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/build/atomic.h b/src/main/build/atomic.h index 73b592b493a..80ec70f55dd 100644 --- a/src/main/build/atomic.h +++ b/src/main/build/atomic.h @@ -47,7 +47,6 @@ static inline uint8_t __basepriSetMemRetVal(uint8_t prio) #ifdef UNIT_TEST #define ATOMIC_BLOCK(prio) {} #else -#pragma GCC diagnostic ignored "-Woverflow" #define ATOMIC_BLOCK(prio) for ( uint8_t __basepri_save __attribute__((__cleanup__(__basepriRestoreMem))) = __get_BASEPRI(), \ __ToDo = __basepriSetMemRetVal((prio) << (8U - __NVIC_PRIO_BITS)); __ToDo ; __ToDo = 0 ) From 68c8009170ce1687b37cb1dd55588cc6206a56cb Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Wed, 3 Apr 2024 12:37:08 +0100 Subject: [PATCH 139/241] Add extra description to nav_min_ground_speed parameter Add extra description to `nav_min_ground_speed` parameter. --- docs/Settings.md | 2 +- src/main/fc/settings.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Settings.md b/docs/Settings.md index a736bd4699d..4d2d1bf94e6 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -3764,7 +3764,7 @@ When ON, NAV engine will slow down when switching to the next waypoint. This pri ### nav_min_ground_speed -Minimum ground speed for navigation flight modes [m/s]. Default 7 m/s. +Minimum ground speed for navigation flight modes [m/s]. Currently, this only affects fixed wing. Default 7 m/s. | Default | Min | Max | | --- | --- | --- | diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index b5809e118d6..462aa225fd4 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -2510,7 +2510,7 @@ groups: min: 10 max: 2000 - name: nav_min_ground_speed - description: "Minimum ground speed for navigation flight modes [m/s]. Default 7 m/s." + description: "Minimum ground speed for navigation flight modes [m/s]. Currently, this only affects fixed wing. Default 7 m/s." default_value: 7 field: general.min_ground_speed min: 6 From 5233d2550737b210c4fa19e91bbcb8d33b007445 Mon Sep 17 00:00:00 2001 From: jhemcu <1553061986@qq.com> Date: Wed, 3 Apr 2024 22:05:18 +0800 Subject: [PATCH 140/241] Target: Add JHEMCUF405WING, JHEMCUF745, JHEMCUH743HD board --- src/main/target/JHEMCUF405WING/CMakeLists.txt | 1 + src/main/target/JHEMCUF405WING/config.c | 42 ++++ src/main/target/JHEMCUF405WING/target.c | 47 ++++ src/main/target/JHEMCUF405WING/target.h | 163 ++++++++++++++ src/main/target/JHEMCUF745/CMakeLists.txt | 1 + src/main/target/JHEMCUF745/target.c | 46 ++++ src/main/target/JHEMCUF745/target.h | 156 +++++++++++++ src/main/target/JHEMCUH743HD/CMakeLists.txt | 1 + src/main/target/JHEMCUH743HD/config.c | 66 ++++++ src/main/target/JHEMCUH743HD/target.c | 49 +++++ src/main/target/JHEMCUH743HD/target.h | 205 ++++++++++++++++++ 11 files changed, 777 insertions(+) create mode 100644 src/main/target/JHEMCUF405WING/CMakeLists.txt create mode 100644 src/main/target/JHEMCUF405WING/config.c create mode 100644 src/main/target/JHEMCUF405WING/target.c create mode 100644 src/main/target/JHEMCUF405WING/target.h create mode 100644 src/main/target/JHEMCUF745/CMakeLists.txt create mode 100644 src/main/target/JHEMCUF745/target.c create mode 100644 src/main/target/JHEMCUF745/target.h create mode 100644 src/main/target/JHEMCUH743HD/CMakeLists.txt create mode 100644 src/main/target/JHEMCUH743HD/config.c create mode 100644 src/main/target/JHEMCUH743HD/target.c create mode 100644 src/main/target/JHEMCUH743HD/target.h diff --git a/src/main/target/JHEMCUF405WING/CMakeLists.txt b/src/main/target/JHEMCUF405WING/CMakeLists.txt new file mode 100644 index 00000000000..fb99881c9bd --- /dev/null +++ b/src/main/target/JHEMCUF405WING/CMakeLists.txt @@ -0,0 +1 @@ +target_stm32f405xg(JHEMCUF405WING) diff --git a/src/main/target/JHEMCUF405WING/config.c b/src/main/target/JHEMCUF405WING/config.c new file mode 100644 index 00000000000..07f44ab29f7 --- /dev/null +++ b/src/main/target/JHEMCUF405WING/config.c @@ -0,0 +1,42 @@ +/* + * This file is part of INAV Project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * Alternatively, the contents of this file may be used under the terms + * of the GNU General Public License Version 3, as described below: + * + * This file is free software: you may copy, redistribute 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. + * + * This file 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 this program. If not, see http://www.gnu.org/licenses/. + */ + +#include +#include + +#include "platform.h" + +#include "fc/fc_msp_box.h" +#include "fc/config.h" +#include "io/serial.h" +#include "io/piniobox.h" + +void targetConfiguration(void) +{ + serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART1)].functionMask = FUNCTION_RX_SERIAL; + serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART3)].functionMask = FUNCTION_GPS; + serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART6)].functionMask = FUNCTION_MSP; + + pinioBoxConfigMutable()->permanentId[0] = BOX_PERMANENT_ID_USER1; +} diff --git a/src/main/target/JHEMCUF405WING/target.c b/src/main/target/JHEMCUF405WING/target.c new file mode 100644 index 00000000000..8dd1df5e1e7 --- /dev/null +++ b/src/main/target/JHEMCUF405WING/target.c @@ -0,0 +1,47 @@ +/* + * This file is part of INAV. + * + * INAV 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. + * + * INAV 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 INAV. If not, see . + */ +#include +#include +#include + +#include "drivers/bus.h" +#include "drivers/io.h" +#include "drivers/pwm_mapping.h" +#include "drivers/timer.h" +#include "drivers/pinio.h" +#include "drivers/sensor.h" + +timerHardware_t timerHardware[] = { + DEF_TIM(TIM4, CH2, PB7, TIM_USE_OUTPUT_AUTO, 1, 0), // S1 D(1,3,2) + DEF_TIM(TIM4, CH1, PB6, TIM_USE_OUTPUT_AUTO, 1, 0), // S2 D(1,0,2) + + DEF_TIM(TIM3, CH3, PB0, TIM_USE_OUTPUT_AUTO, 1, 0), // S3 D(1,7,5) + DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 1, 0), // S4 D(1,2,5) + DEF_TIM(TIM8, CH3, PC8, TIM_USE_OUTPUT_AUTO, 1, 0), // S5 D(2,4,7) + DEF_TIM(TIM8, CH4, PC9, TIM_USE_OUTPUT_AUTO, 1, 0), // S6 D(2,7,7) + + DEF_TIM(TIM8, CH2N,PB14, TIM_USE_OUTPUT_AUTO, 1, 0), // S7 + DEF_TIM(TIM2, CH1, PA15, TIM_USE_OUTPUT_AUTO, 1, 0), // S8 + DEF_TIM(TIM2, CH3, PB10, TIM_USE_OUTPUT_AUTO, 1, 0), // S9 + DEF_TIM(TIM2, CH4, PB11, TIM_USE_OUTPUT_AUTO, 1, 0), // S10 + DEF_TIM(TIM1, CH3N,PB15, TIM_USE_OUTPUT_AUTO, 1, 0), // S11 + + DEF_TIM(TIM1, CH1, PA8, TIM_USE_LED, 0, 0), //2812LED D(1,5,3) + DEF_TIM(TIM5, CH3, PA2, TIM_USE_ANY, 0, 0), //TX2 softserial1_Tx +}; + +const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]); diff --git a/src/main/target/JHEMCUF405WING/target.h b/src/main/target/JHEMCUF405WING/target.h new file mode 100644 index 00000000000..fd64ff153d6 --- /dev/null +++ b/src/main/target/JHEMCUF405WING/target.h @@ -0,0 +1,163 @@ +/* + * This file is part of INAV. + * + * INAV 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. + * + * INAV 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 INAV. If not, see . + */ + +#pragma once + +#define USE_TARGET_CONFIG + +#define TARGET_BOARD_IDENTIFIER "JH45" +#define USBD_PRODUCT_STRING "JHEMCUF405WING" + +// LEDs +#define LED0 PA14 //Blue +#define LED1 PA13 //Green + +// Beeper +#define BEEPER PC15 +#define BEEPER_INVERTED + +// SPI1 +#define USE_SPI +#define USE_SPI_DEVICE_1 +#define SPI1_SCK_PIN PA5 +#define SPI1_MISO_PIN PA6 +#define SPI1_MOSI_PIN PA7 + +// SPI2 +#define USE_SPI_DEVICE_2 +#define SPI2_SCK_PIN PB13 +#define SPI2_MISO_PIN PC2 +#define SPI2_MOSI_PIN PC3 + +// SPI3 +#define USE_SPI_DEVICE_3 +#define SPI3_SCK_PIN PB3 +#define SPI3_MISO_PIN PB4 +#define SPI3_MOSI_PIN PB5 + +// Serial ports +#define USE_VCP + +#define USE_UART1 +#define UART1_TX_PIN PA9 +#define UART1_RX_PIN PA10 + +#define USE_UART2 +#define UART2_TX_PIN PA2 +#define UART2_RX_PIN PA3 + +#define USE_UART3 +#define UART3_TX_PIN PC10 +#define UART3_RX_PIN PC11 + +#define USE_UART4 +#define UART4_TX_PIN PA0 +#define UART4_RX_PIN PA1 + +#define USE_UART5 +#define UART5_TX_PIN PC12 +#define UART5_RX_PIN PD2 + +#define USE_UART6 +#define UART6_TX_PIN PC6 +#define UART6_RX_PIN PC7 + +// Optional Softserial on UART2 TX Pin PA2 +#define USE_SOFTSERIAL1 +#define SOFTSERIAL_1_TX_PIN PA2 +#define SOFTSERIAL_1_RX_PIN PA2 + +#define SERIAL_PORT_COUNT 8 + +#define USE_I2C +#define USE_I2C_DEVICE_1 +#define I2C1_SCL PB8 +#define I2C1_SDA PB9 + +// ICM42605/ICM42688P +#define USE_IMU_ICM42605 +#define IMU_ICM42605_ALIGN CW270_DEG +#define ICM42605_CS_PIN PA4 +#define ICM42605_SPI_BUS BUS_SPI1 + +// Baro +#define USE_BARO +#define BARO_I2C_BUS BUS_I2C1 +#define USE_BARO_ALL + +// Mag +#define USE_MAG +#define MAG_I2C_BUS BUS_I2C1 +#define USE_MAG_ALL + +#define RANGEFINDER_I2C_BUS BUS_I2C1 +#define PITOT_I2C_BUS BUS_I2C1 +#define TEMPERATURE_I2C_BUS BUS_I2C1 + +// OSD +#define USE_MAX7456 +#define MAX7456_CS_PIN PB12 +#define MAX7456_SPI_BUS BUS_SPI2 + +// SD Card +#define USE_SDCARD +#define USE_SDCARD_SPI +#define SDCARD_SPI_BUS BUS_SPI3 +#define SDCARD_CS_PIN PC14 + +#define ENABLE_BLACKBOX_LOGGING_ON_SDCARD_BY_DEFAULT + +#define DEFAULT_RX_TYPE RX_TYPE_SERIAL +#define SERIALRX_PROVIDER SERIALRX_CRSF +#define SERIALRX_UART SERIAL_PORT_USART1 + +// ADC +#define USE_ADC +#define ADC_INSTANCE ADC1 +#define ADC1_DMA_STREAM DMA2_Stream0 +#define ADC_CHANNEL_1_PIN PC0 +#define ADC_CHANNEL_2_PIN PC1 +#define ADC_CHANNEL_3_PIN PC5 +#define ADC_CHANNEL_4_PIN PC4 +#define VBAT_ADC_CHANNEL ADC_CHN_1 +#define CURRENT_METER_ADC_CHANNEL ADC_CHN_2 +#define RSSI_ADC_CHANNEL ADC_CHN_4 +#define AIRSPEED_ADC_CHANNEL ADC_CHN_3 + +// LED2812 +#define USE_LED_STRIP +#define WS2811_PIN PA8 + +// PINIO +#define USE_PINIO +#define USE_PINIOBOX +#define PINIO1_PIN PC13 // 2xCamera switcher + +// OTHERS +#define DEFAULT_FEATURES (FEATURE_TX_PROF_SEL | FEATURE_OSD | FEATURE_CURRENT_METER | FEATURE_VBAT | FEATURE_TELEMETRY | FEATURE_BLACKBOX | FEATURE_AIRMODE) +#define CURRENT_METER_SCALE 175 + +#define USE_DSHOT +#define USE_ESC_SENSOR +#define USE_SERIAL_4WAY_BLHELI_INTERFACE + +#define TARGET_IO_PORTA 0xffff +#define TARGET_IO_PORTB 0xffff +#define TARGET_IO_PORTC 0xffff +#define TARGET_IO_PORTD (BIT(2)) + +#define MAX_PWM_OUTPUT_PORTS 11 \ No newline at end of file diff --git a/src/main/target/JHEMCUF745/CMakeLists.txt b/src/main/target/JHEMCUF745/CMakeLists.txt new file mode 100644 index 00000000000..5f5a85e7c5d --- /dev/null +++ b/src/main/target/JHEMCUF745/CMakeLists.txt @@ -0,0 +1 @@ +target_stm32f745xg(JHEMCUF745) diff --git a/src/main/target/JHEMCUF745/target.c b/src/main/target/JHEMCUF745/target.c new file mode 100644 index 00000000000..20c97d40cf4 --- /dev/null +++ b/src/main/target/JHEMCUF745/target.c @@ -0,0 +1,46 @@ +/* + * This file is part of INAV. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * Alternatively, the contents of this file may be used under the terms + * of the GNU General Public License Version 3, as described below: + * + * This file is free software: you may copy, redistribute 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. + * + * This file 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 this program. If not, see http://www.gnu.org/licenses/. + */ + +#include +#include "drivers/io.h" +#include "drivers/pwm_mapping.h" +#include "drivers/timer.h" +#include "drivers/bus.h" +#include "drivers/pinio.h" + +timerHardware_t timerHardware[] = { + DEF_TIM(TIM1, CH3, PE13, TIM_USE_PPM, 0, 1), // PPM, DMA2_ST6 + + DEF_TIM(TIM3, CH3, PB0, TIM_USE_OUTPUT_AUTO, 0, 0), // M1, DMA1_ST7 + DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 0), // M2, DMA1_ST2 + DEF_TIM(TIM1, CH1, PE9, TIM_USE_OUTPUT_AUTO, 0, 2), // M3, DMA2_ST2 + DEF_TIM(TIM1, CH2, PE11, TIM_USE_OUTPUT_AUTO, 0, 1), // M4, DMA2_ST4 + DEF_TIM(TIM8, CH4, PC9, TIM_USE_OUTPUT_AUTO, 0, 0), // M5, DMA2_ST7 + DEF_TIM(TIM5, CH4, PA3, TIM_USE_OUTPUT_AUTO, 0, 0), // M6, DMA1_ST1 + DEF_TIM(TIM3, CH1, PB4, TIM_USE_OUTPUT_AUTO, 0, 0), // S7 + DEF_TIM(TIM3, CH2, PB5, TIM_USE_OUTPUT_AUTO, 0, 0), // S8 + DEF_TIM(TIM4, CH1, PD12, TIM_USE_LED, 0, 0), // LED_STRIP, DMA1_ST0 +}; + +const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]); diff --git a/src/main/target/JHEMCUF745/target.h b/src/main/target/JHEMCUF745/target.h new file mode 100644 index 00000000000..6b325ecbebb --- /dev/null +++ b/src/main/target/JHEMCUF745/target.h @@ -0,0 +1,156 @@ +/* + * This file is part of INAV. + * + * Cleanflight and Betaflight are free software. You can redistribute + * this software and/or modify this software 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 and Betaflight are distributed in the hope that they + * 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 this software. + * + * If not, see . + */ + +#pragma once + +#define TARGET_BOARD_IDENTIFIER "JHF7" +#define USBD_PRODUCT_STRING "JHEMCUF745" + +#define LED0 PA2 + +#define BEEPER PD15 +#define BEEPER_INVERTED + +#define USE_DSHOT +#define USE_ESC_SENSOR + +#define USE_IMU_MPU6000 +#define IMU_MPU6000_ALIGN CW270_DEG +#define GYRO_INT_EXTI PE1 +#define MPU6000_CS_PIN SPI4_NSS_PIN +#define MPU6000_SPI_BUS BUS_SPI4 + +#define USE_IMU_ICM42605 +#define IMU_ICM42605_ALIGN CW270_DEG +#define ICM42605_CS_PIN SPI4_NSS_PIN +#define ICM42605_SPI_BUS BUS_SPI4 +#define ICM42605_EXTI_PIN PE1 + +#define USB_IO +#define USE_VCP +#define VBUS_SENSING_ENABLED +#define VBUS_SENSING_PIN PA8 + +#define USE_UART1 +#define UART1_TX_PIN PA9 +#define UART1_RX_PIN PA10 + +#define USE_UART2 +#define UART2_TX_PIN PD5 +#define UART2_RX_PIN PD6 + +#define USE_UART3 +#define UART3_TX_PIN PB10 +#define UART3_RX_PIN PB11 + +#define USE_UART4 +#define UART4_TX_PIN PA0 +#define UART4_RX_PIN PA1 + +#define USE_UART5 +#define UART5_TX_PIN PC12 +#define UART5_RX_PIN PD2 + +#define USE_UART6 +#define UART6_TX_PIN PC6 +#define UART6_RX_PIN PC7 + +#define USE_UART7 +#define UART7_RX_PIN PE7 +#define UART7_TX_PIN PE8 + +#define SERIAL_PORT_COUNT 8 // VCP,UART1,UART2,UART3,UART4,UART5,UART6 + +#define USE_SPI +#define USE_SPI_DEVICE_1 // FLASH +#define USE_SPI_DEVICE_2 // OSD +#define USE_SPI_DEVICE_4 // ICM20689 + +#define SPI1_NSS_PIN PA4 +#define SPI1_SCK_PIN PA5 +#define SPI1_MISO_PIN PA6 +#define SPI1_MOSI_PIN PA7 + +#define SPI2_NSS_PIN PB12 +#define SPI2_SCK_PIN PB13 +#define SPI2_MISO_PIN PB14 +#define SPI2_MOSI_PIN PB15 + +#define SPI4_NSS_PIN PE4 +#define SPI4_SCK_PIN PE2 +#define SPI4_MISO_PIN PE5 +#define SPI4_MOSI_PIN PE6 + +#define USE_MAX7456 +#define MAX7456_SPI_BUS BUS_SPI2 +#define MAX7456_CS_PIN SPI2_NSS_PIN + +#define M25P16_CS_PIN SPI1_NSS_PIN +#define M25P16_SPI_BUS BUS_SPI1 +#define USE_FLASHFS +#define USE_FLASH_M25P16 +#define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT + +#define USE_I2C +#define USE_I2C_DEVICE_1 +#define I2C1_SCL PB6 +#define I2C1_SDA PB7 + +// External I2C bus is the same as interal one +#define MAG_I2C_BUS BUS_I2C1 +#define TEMPERATURE_I2C_BUS BUS_I2C1 +#define RANGEFINDER_I2C_BUS BUS_I2C1 +#define DEFAULT_I2C_BUS BUS_I2C1 + +#define USE_BARO +#define USE_BARO_ALL +#define BARO_I2C_BUS BUS_I2C1 + +#define USE_MAG +#define USE_MAG_ALL + +#define USE_ADC +#define ADC_CHANNEL_1_PIN PC2 +#define ADC_CHANNEL_2_PIN PC3 +#define ADC_CHANNEL_3_PIN PC5 + +#define CURRENT_METER_ADC_CHANNEL ADC_CHN_1 +#define VBAT_ADC_CHANNEL ADC_CHN_2 +#define RSSI_ADC_CHANNEL ADC_CHN_3 + +#define ENABLE_BLACKBOX_LOGGING_ON_SDCARD_BY_DEFAULT + +#define DEFAULT_FEATURES (FEATURE_TX_PROF_SEL | FEATURE_TELEMETRY | FEATURE_OSD | FEATURE_VBAT | FEATURE_BLACKBOX) +#define DEFAULT_RX_TYPE RX_TYPE_SERIAL +#define SERIALRX_UART SERIAL_PORT_USART1 +#define SERIALRX_PROVIDER SERIALRX_SBUS + +#define USE_LED_STRIP +#define WS2811_PIN PD12 + +#define USE_SERIAL_4WAY_BLHELI_INTERFACE + +#define TARGET_IO_PORTA 0xffff +#define TARGET_IO_PORTB 0xffff +#define TARGET_IO_PORTC 0xffff +#define TARGET_IO_PORTD 0xffff +#define TARGET_IO_PORTE 0xffff + +#define MAX_PWM_OUTPUT_PORTS 6 diff --git a/src/main/target/JHEMCUH743HD/CMakeLists.txt b/src/main/target/JHEMCUH743HD/CMakeLists.txt new file mode 100644 index 00000000000..b0192886d6c --- /dev/null +++ b/src/main/target/JHEMCUH743HD/CMakeLists.txt @@ -0,0 +1 @@ +target_stm32h743xi(JHEMCUH743HD) \ No newline at end of file diff --git a/src/main/target/JHEMCUH743HD/config.c b/src/main/target/JHEMCUH743HD/config.c new file mode 100644 index 00000000000..4f0aea919e7 --- /dev/null +++ b/src/main/target/JHEMCUH743HD/config.c @@ -0,0 +1,66 @@ +/* + * 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 "config/config_master.h" +#include "config/feature.h" + +#include "drivers/sensor.h" +#include "drivers/pwm_esc_detect.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 "sensors/battery.h" +#include "sensors/sensors.h" + +#include "telemetry/telemetry.h" + +#include "io/piniobox.h" + +void targetConfiguration(void) +{ + pinioBoxConfigMutable()->permanentId[0] = BOX_PERMANENT_ID_USER1; + pinioBoxConfigMutable()->permanentId[1] = BOX_PERMANENT_ID_USER2; + + + /* + * UART1 is SerialRX + */ + serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART1)].functionMask = FUNCTION_RX_SERIAL; + + /* + * Enable MSP at 115200 at UART4 + */ + serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART4)].functionMask = FUNCTION_MSP; + serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART4)].msp_baudrateIndex = BAUD_115200; +} diff --git a/src/main/target/JHEMCUH743HD/target.c b/src/main/target/JHEMCUH743HD/target.c new file mode 100644 index 00000000000..adb753b9d17 --- /dev/null +++ b/src/main/target/JHEMCUH743HD/target.c @@ -0,0 +1,49 @@ +/* + * This file is part of INAV. + * + * INAV 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. + * + * INAV 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 INAV. If not, see . + */ + +#include + +#include "platform.h" + +#include "drivers/bus.h" +#include "drivers/io.h" +#include "drivers/pwm_mapping.h" +#include "drivers/timer.h" +#include "drivers/pinio.h" +#include "drivers/sensor.h" + +BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_bmi270, DEVHW_BMI270, BMI270_SPI_BUS, BMI270_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_BMI270_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_icm42605, DEVHW_ICM42605, ICM42605_SPI_BUS, ICM42605_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_ICM42605_ALIGN); + + +timerHardware_t timerHardware[] = { + + DEF_TIM(TIM5, CH1, PA0, TIM_USE_OUTPUT_AUTO, 0, 0), // S1 + DEF_TIM(TIM5, CH2, PA1, TIM_USE_OUTPUT_AUTO, 0, 1), // S2 + DEF_TIM(TIM5, CH3, PA2, TIM_USE_OUTPUT_AUTO, 0, 2), // S3 + DEF_TIM(TIM5, CH4, PA3, TIM_USE_OUTPUT_AUTO, 0, 3), // S4 + + DEF_TIM(TIM3, CH3, PB0, TIM_USE_OUTPUT_AUTO, 0, 4), // S5 + DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 5), // S6 + DEF_TIM(TIM8, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 6), // S7 + DEF_TIM(TIM8, CH4, PC9, TIM_USE_OUTPUT_AUTO, 0, 7), // S8 + + DEF_TIM(TIM1, CH1, PA8, TIM_USE_LED, 0, 9), // LED_2812 +}; + +const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]); diff --git a/src/main/target/JHEMCUH743HD/target.h b/src/main/target/JHEMCUH743HD/target.h new file mode 100644 index 00000000000..92300b52564 --- /dev/null +++ b/src/main/target/JHEMCUH743HD/target.h @@ -0,0 +1,205 @@ +/* + * This file is part of INAV. + * + * INAV 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. + * + * INAV 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 INAV. If not, see . + */ + +#pragma once + +#define TARGET_BOARD_IDENTIFIER "JHEH743HD" +#define USBD_PRODUCT_STRING "JHEMCUH743HD" + +#define USE_TARGET_CONFIG + +#define LED0 PE5 +#define LED1 PE4 + +#define BEEPER PE3 +#define BEEPER_INVERTED + +// *************** IMU generic *********************** +#define USE_DUAL_GYRO +#define USE_TARGET_IMU_HARDWARE_DESCRIPTORS + +// *************** SPI1 IMU0 MPU6000 **************** +#define USE_SPI +#define USE_SPI_DEVICE_1 +#define SPI1_SCK_PIN PA5 +#define SPI1_MISO_PIN PA6 +#define SPI1_MOSI_PIN PA7 + +#define USE_IMU_MPU6000 +#define IMU_MPU6000_ALIGN CW180_DEG +#define MPU6000_SPI_BUS BUS_SPI1 +#define MPU6000_CS_PIN PA4 + +#define USE_IMU_BMI270 +#define IMU_BMI270_ALIGN CW180_DEG +#define BMI270_SPI_BUS BUS_SPI1 +#define BMI270_CS_PIN PA4 + +#define USE_IMU_ICM42605 +#define IMU_ICM42605_ALIGN CW180_DEG +#define ICM42605_SPI_BUS BUS_SPI1 +#define ICM42605_CS_PIN PA4 + +// *************** SPI2 OSD *********************** +#define USE_SPI_DEVICE_2 +#define SPI2_SCK_PIN PB13 +#define SPI2_MISO_PIN PB14 +#define SPI2_MOSI_PIN PB15 + +#define USE_MAX7456 +#define MAX7456_SPI_BUS BUS_SPI2 +#define MAX7456_CS_PIN PB12 + +// *************** SPI3 FLASH *********************** +#define USE_SPI_DEVICE_3 +#define SPI3_SCK_PIN PC10 +#define SPI3_MISO_PIN PC11 +#define SPI3_MOSI_PIN PB2 +#define SPI3_NSS_PIN PA15 +#define SPI3_SCK_AF GPIO_AF6_SPI3 +#define SPI3_MISO_AF GPIO_AF6_SPI3 +#define SPI3_MOSI_AF GPIO_AF7_SPI3 + +#define M25P16_SPI_BUS BUS_SPI3 +#define M25P16_CS_PIN SPI3_NSS_PIN + +#define W25N01G_SPI_BUS BUS_SPI3 +#define W25N01G_CS_PIN SPI3_NSS_PIN + +#define USE_BLACKBOX +#define USE_FLASHFS +#define USE_FLASH_M25P16 +#define USE_FLASH_W25N01G +#define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT + +// *************** I2C /Baro/Mag ********************* +#define USE_I2C +#define USE_I2C_DEVICE_1 +#define I2C1_SCL PB6 +#define I2C1_SDA PB7 + +#define USE_I2C_DEVICE_2 +#define I2C2_SCL PB10 +#define I2C2_SDA PB11 + +#define USE_BARO +#define BARO_I2C_BUS BUS_I2C1 +#define USE_BARO_ALL + +#define USE_MAG +#define MAG_I2C_BUS BUS_I2C1 +#define USE_MAG_ALL + +#define TEMPERATURE_I2C_BUS BUS_I2C1 +#define PITOT_I2C_BUS BUS_I2C1 + +#define USE_RANGEFINDER +#define RANGEFINDER_I2C_BUS BUS_I2C1 + +// *************** UART ***************************** +#define USE_VCP + +#define USE_UART1 +#define UART1_TX_PIN PA9 +#define UART1_RX_PIN PA10 + +#define USE_UART2 +#define UART2_TX_PIN PD5 +#define UART2_RX_PIN PD6 + +#define USE_UART3 +#define UART3_TX_PIN PD8 +#define UART3_RX_PIN PD9 + +#define USE_UART4 +#define UART4_TX_PIN PD1 +#define UART4_RX_PIN PD0 + +#define USE_UART5 +#define UART5_TX_PIN PC12 +#define UART5_RX_PIN PD2 + +#define USE_UART6 +#define UART6_TX_PIN PC6 +#define UART6_RX_PIN PC7 + +#define USE_UART7 +#define UART7_TX_PIN PE8 +#define UART7_RX_PIN PE7 + +#define USE_UART8 +#define UART8_TX_PIN PE1 +#define UART8_RX_PIN PE0 + +#define SERIAL_PORT_COUNT 9 + +#define DEFAULT_RX_TYPE RX_TYPE_SERIAL +#define SERIALRX_PROVIDER SERIALRX_SBUS + +// *************** ADC ***************************** +#define USE_ADC +#define ADC_INSTANCE ADC3 + +#ifdef MAMBAH743_2022B + +#define ADC_CHANNEL_1_PIN PC1 +#define ADC_CHANNEL_2_PIN PC3 +#define ADC_CHANNEL_3_PIN PC0 + +#define VBAT_ADC_CHANNEL ADC_CHN_1 +#define CURRENT_METER_ADC_CHANNEL ADC_CHN_2 +#define AIRSPEED_ADC_CHANNEL ADC_CHN_3 + +#else + +#define ADC_CHANNEL_1_PIN PC1 +#define ADC_CHANNEL_2_PIN PC3 +#define ADC_CHANNEL_3_PIN PC2 +#define ADC_CHANNEL_4_PIN PC0 + +#define VBAT_ADC_CHANNEL ADC_CHN_1 +#define CURRENT_METER_ADC_CHANNEL ADC_CHN_2 +#define RSSI_ADC_CHANNEL ADC_CHN_3 +#define AIRSPEED_ADC_CHANNEL ADC_CHN_4 + +#endif + +// *************** PINIO *************************** +#define USE_PINIO +#define USE_PINIOBOX + +#define PINIO1_PIN PC2 +#define PINIO2_PIN PC5 + +// *************** LEDSTRIP ************************ +#define USE_LED_STRIP +#define WS2811_PIN PA8 + +#define DEFAULT_FEATURES (FEATURE_OSD | FEATURE_TELEMETRY | FEATURE_CURRENT_METER | FEATURE_VBAT | FEATURE_TX_PROF_SEL) +#define CURRENT_METER_SCALE 250 + +#define USE_SERIAL_4WAY_BLHELI_INTERFACE + +#define TARGET_IO_PORTA 0xffff +#define TARGET_IO_PORTB 0xffff +#define TARGET_IO_PORTC 0xffff +#define TARGET_IO_PORTD 0xffff +#define TARGET_IO_PORTE 0xffff + +#define MAX_PWM_OUTPUT_PORTS 8 +#define USE_DSHOT +#define USE_ESC_SENSOR \ No newline at end of file From 03e8b62337db6df17ddee2697cb6e2ef5c1f38f6 Mon Sep 17 00:00:00 2001 From: Marcelo Bezerra <23555060+mmosca@users.noreply.github.com> Date: Wed, 3 Apr 2024 23:03:11 -0400 Subject: [PATCH 141/241] Fix gcc download for mac silicon macos --- cmake/arm-none-eabi-checks.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/arm-none-eabi-checks.cmake b/cmake/arm-none-eabi-checks.cmake index 200065fdd41..f31a26c3e3a 100644 --- a/cmake/arm-none-eabi-checks.cmake +++ b/cmake/arm-none-eabi-checks.cmake @@ -47,7 +47,7 @@ function(arm_none_eabi_gcc_install) host_uname_machine(machine) if(machine STREQUAL "x86_64" OR machine STREQUAL "amd64") set(dist ${arm_none_eabi_darwin_amd64}) - elseif(machine STREQUAL "aarch64") + elseif(machine STREQUAL "aarch64" OR machine STREQUAL "arm64") set(dist ${arm_none_eabi_darwin_aarch64}) else() message("-- no precompiled ${arm_none_eabi_triplet} toolchain for machine ${machine}") From c0ac660413d67cb0c305a9a0579b558b4621db32 Mon Sep 17 00:00:00 2001 From: Yury MonZon Date: Thu, 4 Apr 2024 09:52:52 +0200 Subject: [PATCH 142/241] Updated osd parameter version --- src/main/io/osd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 3f07ef0370b..831d104b0be 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -209,7 +209,7 @@ static bool osdDisplayHasCanvas; #define AH_MAX_PITCH_DEFAULT 20 // Specify default maximum AHI pitch value displayed (degrees) -PG_REGISTER_WITH_RESET_TEMPLATE(osdConfig_t, osdConfig, PG_OSD_CONFIG, 9); +PG_REGISTER_WITH_RESET_TEMPLATE(osdConfig_t, osdConfig, PG_OSD_CONFIG, 10); PG_REGISTER_WITH_RESET_FN(osdLayoutsConfig_t, osdLayoutsConfig, PG_OSD_LAYOUTS_CONFIG, 1); void osdStartedSaveProcess(void) { From 3ba096f71719ecb935c0a236fe869f0b102f84ad Mon Sep 17 00:00:00 2001 From: b14ckyy <33039058+b14ckyy@users.noreply.github.com> Date: Thu, 4 Apr 2024 11:58:25 +0200 Subject: [PATCH 143/241] Update Fixed Wing Landing.md Added info about approach headings in the Introduction for clarification. --- docs/Fixed Wing Landing.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/Fixed Wing Landing.md b/docs/Fixed Wing Landing.md index 8e1a3ef6fc1..15a89e86800 100644 --- a/docs/Fixed Wing Landing.md +++ b/docs/Fixed Wing Landing.md @@ -5,6 +5,8 @@ INAV supports advanced automatic landings for fixed wing aircraft from version 7.1. The procedure is based on landings for man-carrying aircraft, so that safe landings at a specific location are possible. Supported are landings at safehome after "Return to Home" or at a defined LAND waypoint for missions. +Every landing locations can be defined with a target point and 2 different approach headings (colinear to the landing strips) with exclusive direction or opposite directions allowed. +This enables up to 4 different approach directions, based on the landing site and surrounding area. ## General procedure: From 8cb012af465595ceb7fe473c8b4e958e05f320e5 Mon Sep 17 00:00:00 2001 From: b14ckyy <33039058+b14ckyy@users.noreply.github.com> Date: Thu, 4 Apr 2024 15:40:52 +0200 Subject: [PATCH 144/241] Update Fixed Wing Landing.md --- docs/Fixed Wing Landing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Fixed Wing Landing.md b/docs/Fixed Wing Landing.md index 15a89e86800..0af0a2d4eec 100644 --- a/docs/Fixed Wing Landing.md +++ b/docs/Fixed Wing Landing.md @@ -36,7 +36,7 @@ The following graphics illustrate the process: ### The following parameters are set for each landing site (Safefome/LAND waypoint): -All settings can also be conveniently made in the Configurator via Missionplanner. +All settings can also be conveniently made in the Configurator via Mission Control. CLI command `fwapproach`: `fwapproach ` From 3c32dcb720f21f7fc91c30eac88b705ac83cd589 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Fri, 5 Apr 2024 12:30:19 +0200 Subject: [PATCH 145/241] Simplify filtering by removing gyro filter types and always use PT1 as sufficient for all use cases. --- docs/Settings.md | 20 ------------------- src/main/blackbox/blackbox.c | 1 - src/main/fc/settings.yaml | 10 ---------- src/main/flight/ez_tune.c | 2 -- src/main/sensors/gyro.c | 37 +++++++++--------------------------- src/main/sensors/gyro.h | 2 -- 6 files changed, 9 insertions(+), 63 deletions(-) diff --git a/docs/Settings.md b/docs/Settings.md index 1a07b67bf22..a6feb48b569 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -1572,16 +1572,6 @@ Gyro processing anti-aliasing filter cutoff frequency. In normal operation this --- -### gyro_anti_aliasing_lpf_type - -Specifies the type of the software LPF of the gyro signals. - -| Default | Min | Max | -| --- | --- | --- | -| PT1 | | | - ---- - ### gyro_dyn_lpf_curve_expo Expo value for the throttle-to-frequency mapping for Dynamic LPF @@ -1632,16 +1622,6 @@ Software based gyro main lowpass filter. Value is cutoff frequency (Hz) --- -### gyro_main_lpf_type - -Defines the type of the main gyro LPF filter. Possible values: `PT1`, `BIQUAD`. `PT1` offers faster filter response while `BIQUAD` better attenuation. - -| Default | Min | Max | -| --- | --- | --- | -| BIQUAD | | | - ---- - ### gyro_to_use On multi-gyro targets, allows to choose which gyro to use. 0 = first gyro, 1 = second gyro diff --git a/src/main/blackbox/blackbox.c b/src/main/blackbox/blackbox.c index 453b8fda0cc..8d1314ca7da 100644 --- a/src/main/blackbox/blackbox.c +++ b/src/main/blackbox/blackbox.c @@ -1917,7 +1917,6 @@ static bool blackboxWriteSysinfo(void) BLACKBOX_PRINT_HEADER_LINE("yaw_deadband", "%d", rcControlsConfig()->yaw_deadband); BLACKBOX_PRINT_HEADER_LINE("gyro_lpf", "%d", gyroConfig()->gyro_lpf); BLACKBOX_PRINT_HEADER_LINE("gyro_lpf_hz", "%d", gyroConfig()->gyro_main_lpf_hz); - BLACKBOX_PRINT_HEADER_LINE("gyro_lpf_type", "%d", gyroConfig()->gyro_main_lpf_type); #ifdef USE_DYNAMIC_FILTERS BLACKBOX_PRINT_HEADER_LINE("dynamicGyroNotchQ", "%d", gyroConfig()->dynamicGyroNotchQ); BLACKBOX_PRINT_HEADER_LINE("dynamicGyroNotchMinHz", "%d", gyroConfig()->dynamicGyroNotchMinHz); diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index 2ea0921ef02..21f4e33fee4 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -227,22 +227,12 @@ groups: default_value: 250 field: gyro_anti_aliasing_lpf_hz max: 1000 - - name: gyro_anti_aliasing_lpf_type - description: "Specifies the type of the software LPF of the gyro signals." - default_value: "PT1" - field: gyro_anti_aliasing_lpf_type - table: filter_type - name: gyro_main_lpf_hz description: "Software based gyro main lowpass filter. Value is cutoff frequency (Hz)" default_value: 60 field: gyro_main_lpf_hz min: 0 max: 500 - - name: gyro_main_lpf_type - description: "Defines the type of the main gyro LPF filter. Possible values: `PT1`, `BIQUAD`. `PT1` offers faster filter response while `BIQUAD` better attenuation." - default_value: BIQUAD - field: gyro_main_lpf_type - table: filter_type - name: gyro_use_dyn_lpf description: "Use Dynamic LPF instead of static gyro stage1 LPF. Dynamic Gyro LPF updates gyro LPF based on the throttle position." default_value: OFF diff --git a/src/main/flight/ez_tune.c b/src/main/flight/ez_tune.c index c6c57afbfe5..128a108ccb0 100644 --- a/src/main/flight/ez_tune.c +++ b/src/main/flight/ez_tune.c @@ -77,11 +77,9 @@ void ezTuneUpdate(void) { //Set main gyro filter gyroConfigMutable()->gyro_main_lpf_hz = ezTune()->filterHz; - gyroConfigMutable()->gyro_main_lpf_type = FILTER_PT1; //Set anti-aliasing filter gyroConfigMutable()->gyro_anti_aliasing_lpf_hz = SETTING_GYRO_ANTI_ALIASING_LPF_HZ_DEFAULT; - gyroConfigMutable()->gyro_anti_aliasing_lpf_type = FILTER_PT1; //Enable Smith predictor pidProfileMutable()->smithPredictorDelay = computePt1FilterDelayMs(ezTune()->filterHz); diff --git a/src/main/sensors/gyro.c b/src/main/sensors/gyro.c index 6966d78899a..7e8c9742e06 100644 --- a/src/main/sensors/gyro.c +++ b/src/main/sensors/gyro.c @@ -95,18 +95,16 @@ EXTENDED_FASTRAM secondaryDynamicGyroNotchState_t secondaryDynamicGyroNotchState #endif -PG_REGISTER_WITH_RESET_TEMPLATE(gyroConfig_t, gyroConfig, PG_GYRO_CONFIG, 7); +PG_REGISTER_WITH_RESET_TEMPLATE(gyroConfig_t, gyroConfig, PG_GYRO_CONFIG, 8); PG_RESET_TEMPLATE(gyroConfig_t, gyroConfig, .gyro_lpf = SETTING_GYRO_HARDWARE_LPF_DEFAULT, .gyro_anti_aliasing_lpf_hz = SETTING_GYRO_ANTI_ALIASING_LPF_HZ_DEFAULT, - .gyro_anti_aliasing_lpf_type = SETTING_GYRO_ANTI_ALIASING_LPF_TYPE_DEFAULT, .looptime = SETTING_LOOPTIME_DEFAULT, #ifdef USE_DUAL_GYRO .gyro_to_use = SETTING_GYRO_TO_USE_DEFAULT, #endif .gyro_main_lpf_hz = SETTING_GYRO_MAIN_LPF_HZ_DEFAULT, - .gyro_main_lpf_type = SETTING_GYRO_MAIN_LPF_TYPE_DEFAULT, .useDynamicLpf = SETTING_GYRO_USE_DYN_LPF_DEFAULT, .gyroDynamicLpfMinHz = SETTING_GYRO_DYN_LPF_MIN_HZ_DEFAULT, .gyroDynamicLpfMaxHz = SETTING_GYRO_DYN_LPF_MAX_HZ_DEFAULT, @@ -233,24 +231,13 @@ STATIC_UNIT_TESTED gyroSensor_e gyroDetect(gyroDev_t *dev, gyroSensor_e gyroHard return gyroHardware; } -static void initGyroFilter(filterApplyFnPtr *applyFn, filter_t state[], uint8_t type, uint16_t cutoff, uint32_t looptime) +static void initGyroFilter(filterApplyFnPtr *applyFn, filter_t state[], uint16_t cutoff, uint32_t looptime) { *applyFn = nullFilterApply; if (cutoff > 0) { - switch (type) - { - case FILTER_PT1: - *applyFn = (filterApplyFnPtr)pt1FilterApply; - for (int axis = 0; axis < 3; axis++) { - pt1FilterInit(&state[axis].pt1, cutoff, US2S(looptime)); - } - break; - case FILTER_BIQUAD: - *applyFn = (filterApplyFnPtr)biquadFilterApply; - for (int axis = 0; axis < 3; axis++) { - biquadFilterInitLPF(&state[axis].biquad, cutoff, looptime); - } - break; + *applyFn = (filterApplyFnPtr)pt1FilterApply; + for (int axis = 0; axis < 3; axis++) { + pt1FilterInit(&state[axis].pt1, cutoff, US2S(looptime)); } } } @@ -258,10 +245,10 @@ static void initGyroFilter(filterApplyFnPtr *applyFn, filter_t state[], uint8_t static void gyroInitFilters(void) { //First gyro LPF running at full gyro frequency 8kHz - initGyroFilter(&gyroLpfApplyFn, gyroLpfState, gyroConfig()->gyro_anti_aliasing_lpf_type, gyroConfig()->gyro_anti_aliasing_lpf_hz, getGyroLooptime()); + initGyroFilter(&gyroLpfApplyFn, gyroLpfState, gyroConfig()->gyro_anti_aliasing_lpf_hz, getGyroLooptime()); //Second gyro LPF runnig and PID frequency - this filter is dynamic when gyro_use_dyn_lpf = ON - initGyroFilter(&gyroLpf2ApplyFn, gyroLpf2State, gyroConfig()->gyro_main_lpf_type, gyroConfig()->gyro_main_lpf_hz, getLooptime()); + initGyroFilter(&gyroLpf2ApplyFn, gyroLpf2State, gyroConfig()->gyro_main_lpf_hz, getLooptime()); #ifdef USE_GYRO_KALMAN if (gyroConfig()->kalmanEnabled) { @@ -566,14 +553,8 @@ int16_t gyroRateDps(int axis) } void gyroUpdateDynamicLpf(float cutoffFreq) { - if (gyroConfig()->gyro_main_lpf_type == FILTER_PT1) { - for (int axis = 0; axis < XYZ_AXIS_COUNT; axis++) { - pt1FilterUpdateCutoff(&gyroLpf2State[axis].pt1, cutoffFreq); - } - } else if (gyroConfig()->gyro_main_lpf_type == FILTER_BIQUAD) { - for (int axis = 0; axis < XYZ_AXIS_COUNT; axis++) { - biquadFilterUpdate(&gyroLpf2State[axis].biquad, cutoffFreq, getLooptime(), BIQUAD_Q, FILTER_LPF); - } + for (int axis = 0; axis < XYZ_AXIS_COUNT; axis++) { + pt1FilterUpdateCutoff(&gyroLpf2State[axis].pt1, cutoffFreq); } } diff --git a/src/main/sensors/gyro.h b/src/main/sensors/gyro.h index f21fc6a42c3..c1a9d324dc7 100644 --- a/src/main/sensors/gyro.h +++ b/src/main/sensors/gyro.h @@ -66,12 +66,10 @@ typedef struct gyroConfig_s { uint16_t looptime; // imu loop time in us uint8_t gyro_lpf; // gyro LPF setting - values are driver specific, in case of invalid number, a reasonable default ~30-40HZ is chosen. uint16_t gyro_anti_aliasing_lpf_hz; - uint8_t gyro_anti_aliasing_lpf_type; #ifdef USE_DUAL_GYRO uint8_t gyro_to_use; #endif uint16_t gyro_main_lpf_hz; - uint8_t gyro_main_lpf_type; uint8_t useDynamicLpf; uint16_t gyroDynamicLpfMinHz; uint16_t gyroDynamicLpfMaxHz; From a19a16bb031aca4d11a4a10bd5b7b8b11f3591ed Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Fri, 5 Apr 2024 13:12:24 +0200 Subject: [PATCH 146/241] Use only highest hardware LPF as it's de factor standard for a few years now. --- src/main/blackbox/blackbox.c | 2 +- src/main/cms/cms_menu_imu.c | 1 - src/main/drivers/accgyro/accgyro_bmi160.c | 9 --------- src/main/drivers/accgyro/accgyro_bmi270.c | 9 --------- src/main/drivers/accgyro/accgyro_icm42605.c | 15 --------------- src/main/drivers/accgyro/accgyro_mpu.c | 15 --------------- src/main/fc/fc_msp.c | 4 ++-- src/main/fc/settings.yaml | 7 ------- src/main/io/osd_dji_hd.c | 2 +- src/main/sensors/gyro.c | 3 +-- src/main/sensors/gyro.h | 1 - 11 files changed, 5 insertions(+), 63 deletions(-) diff --git a/src/main/blackbox/blackbox.c b/src/main/blackbox/blackbox.c index 8d1314ca7da..4606e8a1787 100644 --- a/src/main/blackbox/blackbox.c +++ b/src/main/blackbox/blackbox.c @@ -1915,7 +1915,7 @@ static bool blackboxWriteSysinfo(void) BLACKBOX_PRINT_HEADER_LINE("dterm_lpf_type", "%d", pidProfile()->dterm_lpf_type); BLACKBOX_PRINT_HEADER_LINE("deadband", "%d", rcControlsConfig()->deadband); BLACKBOX_PRINT_HEADER_LINE("yaw_deadband", "%d", rcControlsConfig()->yaw_deadband); - BLACKBOX_PRINT_HEADER_LINE("gyro_lpf", "%d", gyroConfig()->gyro_lpf); + BLACKBOX_PRINT_HEADER_LINE("gyro_lpf", "%d", GYRO_LPF_256HZ); BLACKBOX_PRINT_HEADER_LINE("gyro_lpf_hz", "%d", gyroConfig()->gyro_main_lpf_hz); #ifdef USE_DYNAMIC_FILTERS BLACKBOX_PRINT_HEADER_LINE("dynamicGyroNotchQ", "%d", gyroConfig()->dynamicGyroNotchQ); diff --git a/src/main/cms/cms_menu_imu.c b/src/main/cms/cms_menu_imu.c index ce40d320c4e..f8c75ab4801 100644 --- a/src/main/cms/cms_menu_imu.c +++ b/src/main/cms/cms_menu_imu.c @@ -422,7 +422,6 @@ static const CMS_Menu cmsx_menuProfileOther = { static const OSD_Entry cmsx_menuFilterPerProfileEntries[] = { OSD_LABEL_DATA_ENTRY("-- FILTERING --", profileIndexString), - OSD_SETTING_ENTRY("HARDWARE LPF", SETTING_GYRO_HARDWARE_LPF), OSD_SETTING_ENTRY("GYRO MAIN", SETTING_GYRO_MAIN_LPF_HZ), OSD_SETTING_ENTRY("DTERM LPF", SETTING_DTERM_LPF_HZ), #ifdef USE_DYNAMIC_FILTERS diff --git a/src/main/drivers/accgyro/accgyro_bmi160.c b/src/main/drivers/accgyro/accgyro_bmi160.c index cadaeb22da5..fc7fb472b52 100644 --- a/src/main/drivers/accgyro/accgyro_bmi160.c +++ b/src/main/drivers/accgyro/accgyro_bmi160.c @@ -108,15 +108,6 @@ static const gyroFilterAndRateConfig_t gyroConfigs[] = { { GYRO_LPF_256HZ, 3200, { BMI160_BWP_OSR4 | BMI160_ODR_3200_Hz} }, { GYRO_LPF_256HZ, 1600, { BMI160_BWP_OSR2 | BMI160_ODR_1600_Hz} }, { GYRO_LPF_256HZ, 800, { BMI160_BWP_NORMAL | BMI160_ODR_800_Hz } }, - - { GYRO_LPF_188HZ, 800, { BMI160_BWP_OSR2 | BMI160_ODR_800_Hz } }, // ODR = 800 Hz, LPF = 128 Hz - { GYRO_LPF_188HZ, 400, { BMI160_BWP_NORMAL | BMI160_ODR_400_Hz } }, // ODR = 400 Hz, LPF = 137 Hz - - { GYRO_LPF_98HZ, 800, { BMI160_BWP_OSR4 | BMI160_ODR_800_Hz } }, // ODR = 800 Hz, LPF = 63 Hz - { GYRO_LPF_98HZ, 400, { BMI160_BWP_OSR2 | BMI160_ODR_400_Hz } }, // ODR = 400 Hz, LPF = 68 Hz - - { GYRO_LPF_42HZ, 800, { BMI160_BWP_OSR4 | BMI160_ODR_800_Hz } }, // ODR = 800 Hz, LPF = 63 Hz - { GYRO_LPF_42HZ, 400, { BMI160_BWP_OSR4 | BMI160_ODR_400_Hz } }, // ODR = 400 Hz, LPF = 34 Hz }; static void bmi160AccAndGyroInit(gyroDev_t *gyro) diff --git a/src/main/drivers/accgyro/accgyro_bmi270.c b/src/main/drivers/accgyro/accgyro_bmi270.c index 3e1db222536..1dc4d3fc590 100644 --- a/src/main/drivers/accgyro/accgyro_bmi270.c +++ b/src/main/drivers/accgyro/accgyro_bmi270.c @@ -134,15 +134,6 @@ static const gyroFilterAndRateConfig_t gyroConfigs[] = { { GYRO_LPF_256HZ, 3200, { BMI270_BWP_OSR4 | BMI270_ODR_3200} }, { GYRO_LPF_256HZ, 1600, { BMI270_BWP_OSR2 | BMI270_ODR_1600} }, { GYRO_LPF_256HZ, 800, { BMI270_BWP_NORM | BMI270_ODR_800 } }, - - { GYRO_LPF_188HZ, 800, { BMI270_BWP_OSR2 | BMI270_ODR_800 } }, - { GYRO_LPF_188HZ, 400, { BMI270_BWP_NORM | BMI270_ODR_400 } }, - - { GYRO_LPF_98HZ, 800, { BMI270_BWP_OSR4 | BMI270_ODR_800 } }, - { GYRO_LPF_98HZ, 400, { BMI270_BWP_OSR2 | BMI270_ODR_400 } }, - - { GYRO_LPF_42HZ, 800, { BMI270_BWP_OSR4 | BMI270_ODR_800 } }, - { GYRO_LPF_42HZ, 400, { BMI270_BWP_OSR4 | BMI270_ODR_400 } }, }; // Toggle the CS to switch the device into SPI mode. diff --git a/src/main/drivers/accgyro/accgyro_icm42605.c b/src/main/drivers/accgyro/accgyro_icm42605.c index 082b31540eb..13bc22fcee7 100644 --- a/src/main/drivers/accgyro/accgyro_icm42605.c +++ b/src/main/drivers/accgyro/accgyro_icm42605.c @@ -198,21 +198,6 @@ static const gyroFilterAndRateConfig_t icm42605GyroConfigs[] = { { GYRO_LPF_256HZ, 2000, { 3, 5 } }, /* 250 Hz LPF */ { GYRO_LPF_256HZ, 1000, { 1, 6 } }, /* 250 Hz LPF */ { GYRO_LPF_256HZ, 500, { 0, 15 } }, /* 250 Hz LPF */ - - { GYRO_LPF_188HZ, 1000, { 3, 6 } }, /* 125 HZ */ - { GYRO_LPF_188HZ, 500, { 1, 15 } }, /* 125 HZ */ - - { GYRO_LPF_98HZ, 1000, { 4, 6 } }, /* 100 HZ*/ - { GYRO_LPF_98HZ, 500, { 2, 15 } }, /* 100 HZ*/ - - { GYRO_LPF_42HZ, 1000, { 6, 6 } }, /* 50 HZ */ - { GYRO_LPF_42HZ, 500, { 4, 15 } }, - - { GYRO_LPF_20HZ, 1000, { 7, 6 } }, /* 25 HZ */ - { GYRO_LPF_20HZ, 500, { 6, 15 } }, - - { GYRO_LPF_10HZ, 1000, { 7, 6 } }, /* 25 HZ */ - { GYRO_LPF_10HZ, 500, { 7, 15 } } /* 12.5 HZ */ }; static void icm42605AccAndGyroInit(gyroDev_t *gyro) diff --git a/src/main/drivers/accgyro/accgyro_mpu.c b/src/main/drivers/accgyro/accgyro_mpu.c index 710865436bd..a52606946b1 100644 --- a/src/main/drivers/accgyro/accgyro_mpu.c +++ b/src/main/drivers/accgyro/accgyro_mpu.c @@ -50,21 +50,6 @@ static const gyroFilterAndRateConfig_t mpuGyroConfigs[] = { { GYRO_LPF_256HZ, 1000, { MPU_DLPF_256HZ, 7 } }, { GYRO_LPF_256HZ, 666, { MPU_DLPF_256HZ, 11 } }, { GYRO_LPF_256HZ, 500, { MPU_DLPF_256HZ, 15 } }, - - { GYRO_LPF_188HZ, 1000, { MPU_DLPF_188HZ, 0 } }, - { GYRO_LPF_188HZ, 500, { MPU_DLPF_188HZ, 1 } }, - - { GYRO_LPF_98HZ, 1000, { MPU_DLPF_98HZ, 0 } }, - { GYRO_LPF_98HZ, 500, { MPU_DLPF_98HZ, 1 } }, - - { GYRO_LPF_42HZ, 1000, { MPU_DLPF_42HZ, 0 } }, - { GYRO_LPF_42HZ, 500, { MPU_DLPF_42HZ, 1 } }, - - { GYRO_LPF_20HZ, 1000, { MPU_DLPF_20HZ, 0 } }, - { GYRO_LPF_20HZ, 500, { MPU_DLPF_20HZ, 1 } }, - - { GYRO_LPF_10HZ, 1000, { MPU_DLPF_10HZ, 0 } }, - { GYRO_LPF_10HZ, 500, { MPU_DLPF_10HZ, 1 } } }; const gyroFilterAndRateConfig_t * mpuChooseGyroConfig(uint8_t desiredLpf, uint16_t desiredRateHz) diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index 2d47d0ec2e9..61ce9f7d8e3 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -1295,7 +1295,7 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF sbufWriteU8(dst, pidProfile()->heading_hold_rate_limit); sbufWriteU8(dst, HEADING_HOLD_ERROR_LPF_FREQ); sbufWriteU16(dst, 0); - sbufWriteU8(dst, gyroConfig()->gyro_lpf); + sbufWriteU8(dst, GYRO_LPF_256HZ); sbufWriteU8(dst, accelerometerConfig()->acc_lpf_hz); sbufWriteU8(dst, 0); //reserved sbufWriteU8(dst, 0); //reserved @@ -2335,7 +2335,7 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) pidProfileMutable()->heading_hold_rate_limit = sbufReadU8(src); sbufReadU8(src); //HEADING_HOLD_ERROR_LPF_FREQ sbufReadU16(src); //Legacy yaw_jump_prevention_limit - gyroConfigMutable()->gyro_lpf = sbufReadU8(src); + sbufReadU8(src); // was gyro lpf accelerometerConfigMutable()->acc_lpf_hz = sbufReadU8(src); sbufReadU8(src); //reserved sbufReadU8(src); //reserved diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index 21f4e33fee4..8d1006c285b 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -1,8 +1,6 @@ tables: - name: alignment values: ["DEFAULT", "CW0", "CW90", "CW180", "CW270", "CW0FLIP", "CW90FLIP", "CW180FLIP", "CW270FLIP"] - - name: gyro_lpf - values: ["256HZ", "188HZ", "98HZ", "42HZ", "20HZ", "10HZ"] - name: acc_hardware values: ["NONE", "AUTO", "MPU6000", "MPU6500", "MPU9250", "BMI160", "ICM20689", "BMI088", "ICM42605", "BMI270","LSM6DXX", "FAKE"] enum: accelerationSensor_e @@ -217,11 +215,6 @@ groups: description: "This is the main loop time (in us). Changing this affects PID effect with some PID controllers (see PID section for details). A very conservative value of 3500us/285Hz should work for everyone. Setting it to zero does not limit loop time, so it will go as fast as possible." default_value: 1000 max: 9000 - - name: gyro_hardware_lpf - description: "Hardware lowpass filter for gyro. This value should never be changed without a very strong reason! If you have to set gyro lpf below 256HZ, it means the frame is vibrating too much, and that should be fixed first." - default_value: "256HZ" - field: gyro_lpf - table: gyro_lpf - name: gyro_anti_aliasing_lpf_hz description: "Gyro processing anti-aliasing filter cutoff frequency. In normal operation this filter setting should never be changed. In Hz" default_value: 250 diff --git a/src/main/io/osd_dji_hd.c b/src/main/io/osd_dji_hd.c index 29dfe0b809e..ada5b8501c7 100644 --- a/src/main/io/osd_dji_hd.c +++ b/src/main/io/osd_dji_hd.c @@ -1454,7 +1454,7 @@ static mspResult_e djiProcessMspCommand(mspPacket_t *cmd, mspPacket_t *reply, ms sbufWriteU16(dst, 0); // BF: gyroConfig()->gyro_soft_notch_hz_2 sbufWriteU16(dst, 1); // BF: gyroConfig()->gyro_soft_notch_cutoff_2 sbufWriteU8(dst, 0); // BF: currentPidProfile->dterm_filter_type - sbufWriteU8(dst, gyroConfig()->gyro_lpf); // BF: gyroConfig()->gyro_hardware_lpf); + sbufWriteU8(dst, GYRO_LPF_256HZ); // BF: gyroConfig()->gyro_hardware_lpf); sbufWriteU8(dst, 0); // BF: DEPRECATED: gyro_32khz_hardware_lpf sbufWriteU16(dst, gyroConfig()->gyro_main_lpf_hz); // BF: gyroConfig()->gyro_lowpass_hz); sbufWriteU16(dst, 0); // BF: gyroConfig()->gyro_lowpass2_hz); diff --git a/src/main/sensors/gyro.c b/src/main/sensors/gyro.c index 7e8c9742e06..97e3f3be436 100644 --- a/src/main/sensors/gyro.c +++ b/src/main/sensors/gyro.c @@ -98,7 +98,6 @@ EXTENDED_FASTRAM secondaryDynamicGyroNotchState_t secondaryDynamicGyroNotchState PG_REGISTER_WITH_RESET_TEMPLATE(gyroConfig_t, gyroConfig, PG_GYRO_CONFIG, 8); PG_RESET_TEMPLATE(gyroConfig_t, gyroConfig, - .gyro_lpf = SETTING_GYRO_HARDWARE_LPF_DEFAULT, .gyro_anti_aliasing_lpf_hz = SETTING_GYRO_ANTI_ALIASING_LPF_HZ_DEFAULT, .looptime = SETTING_LOOPTIME_DEFAULT, #ifdef USE_DUAL_GYRO @@ -282,7 +281,7 @@ bool gyroInit(void) sensorsSet(SENSOR_GYRO); // Driver initialisation - gyroDev[0].lpf = gyroConfig()->gyro_lpf; + gyroDev[0].lpf = GYRO_LPF_256HZ; gyroDev[0].requestedSampleIntervalUs = TASK_GYRO_LOOPTIME; gyroDev[0].sampleRateIntervalUs = TASK_GYRO_LOOPTIME; gyroDev[0].initFn(&gyroDev[0]); diff --git a/src/main/sensors/gyro.h b/src/main/sensors/gyro.h index c1a9d324dc7..2ea70c589da 100644 --- a/src/main/sensors/gyro.h +++ b/src/main/sensors/gyro.h @@ -64,7 +64,6 @@ extern dynamicGyroNotchState_t dynamicGyroNotchState; typedef struct gyroConfig_s { uint16_t looptime; // imu loop time in us - uint8_t gyro_lpf; // gyro LPF setting - values are driver specific, in case of invalid number, a reasonable default ~30-40HZ is chosen. uint16_t gyro_anti_aliasing_lpf_hz; #ifdef USE_DUAL_GYRO uint8_t gyro_to_use; From 86adbebdb38a66202f393b51209b08a96a35cbb6 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Fri, 5 Apr 2024 13:26:18 +0200 Subject: [PATCH 147/241] Docs update --- docs/Settings.md | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/docs/Settings.md b/docs/Settings.md index a6feb48b569..c374ff4b00c 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -1602,16 +1602,6 @@ Minimum frequency of the gyro Dynamic LPF --- -### gyro_hardware_lpf - -Hardware lowpass filter for gyro. This value should never be changed without a very strong reason! If you have to set gyro lpf below 256HZ, it means the frame is vibrating too much, and that should be fixed first. - -| Default | Min | Max | -| --- | --- | --- | -| 256HZ | | | - ---- - ### gyro_main_lpf_hz Software based gyro main lowpass filter. Value is cutoff frequency (Hz) From 47f83f71a2e9291cef9b9eb89cc1f989f169f57f Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Fri, 5 Apr 2024 13:43:56 +0200 Subject: [PATCH 148/241] Remove workarounds as not used and obsolete --- docs/Settings.md | 10 ---- src/main/fc/settings.yaml | 6 -- src/main/io/osd_dji_hd.c | 112 ++++++++++++-------------------------- src/main/io/osd_dji_hd.h | 1 - 4 files changed, 34 insertions(+), 95 deletions(-) diff --git a/docs/Settings.md b/docs/Settings.md index 1a07b67bf22..02ea396e307 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -752,16 +752,6 @@ Re-purpose the craft name field for messages. --- -### dji_workarounds - -Enables workarounds for different versions of MSP protocol used - -| Default | Min | Max | -| --- | --- | --- | -| 1 | 0 | 255 | - ---- - ### dshot_beeper_enabled Whether using DShot motors as beepers is enabled diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index 2ea0921ef02..4e2b097204b 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -4008,12 +4008,6 @@ groups: headers: ["io/osd_dji_hd.h"] condition: USE_DJI_HD_OSD members: - - name: dji_workarounds - description: "Enables workarounds for different versions of MSP protocol used" - field: proto_workarounds - min: 0 - max: UINT8_MAX - default_value: 1 - name: dji_use_name_for_messages description: "Re-purpose the craft name field for messages." default_value: ON diff --git a/src/main/io/osd_dji_hd.c b/src/main/io/osd_dji_hd.c index 29dfe0b809e..26cf1df9e91 100644 --- a/src/main/io/osd_dji_hd.c +++ b/src/main/io/osd_dji_hd.c @@ -122,11 +122,10 @@ * but reuse the packet decoder to minimize code duplication */ -PG_REGISTER_WITH_RESET_TEMPLATE(djiOsdConfig_t, djiOsdConfig, PG_DJI_OSD_CONFIG, 2); +PG_REGISTER_WITH_RESET_TEMPLATE(djiOsdConfig_t, djiOsdConfig, PG_DJI_OSD_CONFIG, 3); PG_RESET_TEMPLATE(djiOsdConfig_t, djiOsdConfig, .use_name_for_messages = SETTING_DJI_USE_NAME_FOR_MESSAGES_DEFAULT, .esc_temperature_source = SETTING_DJI_ESC_TEMP_SOURCE_DEFAULT, - .proto_workarounds = SETTING_DJI_WORKAROUNDS_DEFAULT, .messageSpeedSource = SETTING_DJI_MESSAGE_SPEED_SOURCE_DEFAULT, .rssi_source = SETTING_DJI_RSSI_SOURCE_DEFAULT, .useAdjustments = SETTING_DJI_USE_ADJUSTMENTS_DEFAULT, @@ -1347,91 +1346,48 @@ static mspResult_e djiProcessMspCommand(mspPacket_t *cmd, mspPacket_t *reply, ms break; case DJI_MSP_ESC_SENSOR_DATA: - if (djiOsdConfig()->proto_workarounds & DJI_OSD_USE_NON_STANDARD_MSP_ESC_SENSOR_DATA) { - // Version 1.00.06 of DJI firmware is not using the standard MSP_ESC_SENSOR_DATA - uint16_t protoRpm = 0; - int16_t protoTemp = 0; + uint16_t protoRpm = 0; + int16_t protoTemp = 0; #if defined(USE_ESC_SENSOR) - if (STATE(ESC_SENSOR_ENABLED) && getMotorCount() > 0) { - uint32_t motorRpmAcc = 0; - int32_t motorTempAcc = 0; - - for (int i = 0; i < getMotorCount(); i++) { - const escSensorData_t * escSensor = getEscTelemetry(i); - motorRpmAcc += escSensor->rpm; - motorTempAcc += escSensor->temperature; - } - - protoRpm = motorRpmAcc / getMotorCount(); - protoTemp = motorTempAcc / getMotorCount(); - } -#endif + if (STATE(ESC_SENSOR_ENABLED) && getMotorCount() > 0) { + uint32_t motorRpmAcc = 0; + int32_t motorTempAcc = 0; - switch (djiOsdConfig()->esc_temperature_source) { - // This is ESC temperature (as intended) - case DJI_OSD_TEMP_ESC: - // No-op, temperature is already set to ESC - break; - - // Re-purpose the field for core temperature - case DJI_OSD_TEMP_CORE: - getIMUTemperature(&protoTemp); - protoTemp = protoTemp / 10; - break; - - // Re-purpose the field for baro temperature - case DJI_OSD_TEMP_BARO: - getBaroTemperature(&protoTemp); - protoTemp = protoTemp / 10; - break; + for (int i = 0; i < getMotorCount(); i++) { + const escSensorData_t * escSensor = getEscTelemetry(i); + motorRpmAcc += escSensor->rpm; + motorTempAcc += escSensor->temperature; } - // No motor count, just raw temp and RPM data - sbufWriteU8(dst, protoTemp); - sbufWriteU16(dst, protoRpm); + protoRpm = motorRpmAcc / getMotorCount(); + protoTemp = motorTempAcc / getMotorCount(); } - else { - // Use standard MSP_ESC_SENSOR_DATA message - sbufWriteU8(dst, getMotorCount()); - for (int i = 0; i < getMotorCount(); i++) { - uint16_t motorRpm = 0; - int16_t motorTemp = 0; - - // If ESC_SENSOR is enabled, pull the telemetry data and get motor RPM -#if defined(USE_ESC_SENSOR) - if (STATE(ESC_SENSOR_ENABLED)) { - const escSensorData_t * escSensor = getEscTelemetry(i); - motorRpm = escSensor->rpm; - motorTemp = escSensor->temperature; - } #endif - // Now populate temperature field (which we may override for different purposes) - switch (djiOsdConfig()->esc_temperature_source) { - // This is ESC temperature (as intended) - case DJI_OSD_TEMP_ESC: - // No-op, temperature is already set to ESC - break; - - // Re-purpose the field for core temperature - case DJI_OSD_TEMP_CORE: - getIMUTemperature(&motorTemp); - motorTemp = motorTemp / 10; - break; - - // Re-purpose the field for baro temperature - case DJI_OSD_TEMP_BARO: - getBaroTemperature(&motorTemp); - motorTemp = motorTemp / 10; - break; - } - - // Add data for this motor to the packet - sbufWriteU8(dst, motorTemp); - sbufWriteU16(dst, motorRpm); - } + switch (djiOsdConfig()->esc_temperature_source) { + // This is ESC temperature (as intended) + case DJI_OSD_TEMP_ESC: + // No-op, temperature is already set to ESC + break; + + // Re-purpose the field for core temperature + case DJI_OSD_TEMP_CORE: + getIMUTemperature(&protoTemp); + protoTemp = protoTemp / 10; + break; + + // Re-purpose the field for baro temperature + case DJI_OSD_TEMP_BARO: + getBaroTemperature(&protoTemp); + protoTemp = protoTemp / 10; + break; } + + // No motor count, just raw temp and RPM data + sbufWriteU8(dst, protoTemp); + sbufWriteU16(dst, protoRpm); + break; case DJI_MSP_OSD_CONFIG: diff --git a/src/main/io/osd_dji_hd.h b/src/main/io/osd_dji_hd.h index 4b3e0a14796..f109f84fb1b 100644 --- a/src/main/io/osd_dji_hd.h +++ b/src/main/io/osd_dji_hd.h @@ -84,7 +84,6 @@ enum djiOsdProtoWorkarounds_e { typedef struct djiOsdConfig_s { uint8_t use_name_for_messages; uint8_t esc_temperature_source; - uint8_t proto_workarounds; uint8_t messageSpeedSource; uint8_t rssi_source; uint8_t useAdjustments; From 133698119f676605c47d45c4300a935bdb180f41 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Fri, 5 Apr 2024 14:43:35 +0200 Subject: [PATCH 149/241] Compilation fix --- src/main/io/osd_dji_hd.c | 79 ++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/src/main/io/osd_dji_hd.c b/src/main/io/osd_dji_hd.c index 26cf1df9e91..d07a153b3dd 100644 --- a/src/main/io/osd_dji_hd.c +++ b/src/main/io/osd_dji_hd.c @@ -1346,48 +1346,49 @@ static mspResult_e djiProcessMspCommand(mspPacket_t *cmd, mspPacket_t *reply, ms break; case DJI_MSP_ESC_SENSOR_DATA: - uint16_t protoRpm = 0; - int16_t protoTemp = 0; - -#if defined(USE_ESC_SENSOR) - if (STATE(ESC_SENSOR_ENABLED) && getMotorCount() > 0) { - uint32_t motorRpmAcc = 0; - int32_t motorTempAcc = 0; - - for (int i = 0; i < getMotorCount(); i++) { - const escSensorData_t * escSensor = getEscTelemetry(i); - motorRpmAcc += escSensor->rpm; - motorTempAcc += escSensor->temperature; + { + uint16_t protoRpm = 0; + int16_t protoTemp = 0; + + #if defined(USE_ESC_SENSOR) + if (STATE(ESC_SENSOR_ENABLED) && getMotorCount() > 0) { + uint32_t motorRpmAcc = 0; + int32_t motorTempAcc = 0; + + for (int i = 0; i < getMotorCount(); i++) { + const escSensorData_t * escSensor = getEscTelemetry(i); + motorRpmAcc += escSensor->rpm; + motorTempAcc += escSensor->temperature; + } + + protoRpm = motorRpmAcc / getMotorCount(); + protoTemp = motorTempAcc / getMotorCount(); + } + #endif + + switch (djiOsdConfig()->esc_temperature_source) { + // This is ESC temperature (as intended) + case DJI_OSD_TEMP_ESC: + // No-op, temperature is already set to ESC + break; + + // Re-purpose the field for core temperature + case DJI_OSD_TEMP_CORE: + getIMUTemperature(&protoTemp); + protoTemp = protoTemp / 10; + break; + + // Re-purpose the field for baro temperature + case DJI_OSD_TEMP_BARO: + getBaroTemperature(&protoTemp); + protoTemp = protoTemp / 10; + break; } - protoRpm = motorRpmAcc / getMotorCount(); - protoTemp = motorTempAcc / getMotorCount(); - } -#endif - - switch (djiOsdConfig()->esc_temperature_source) { - // This is ESC temperature (as intended) - case DJI_OSD_TEMP_ESC: - // No-op, temperature is already set to ESC - break; - - // Re-purpose the field for core temperature - case DJI_OSD_TEMP_CORE: - getIMUTemperature(&protoTemp); - protoTemp = protoTemp / 10; - break; - - // Re-purpose the field for baro temperature - case DJI_OSD_TEMP_BARO: - getBaroTemperature(&protoTemp); - protoTemp = protoTemp / 10; - break; + // No motor count, just raw temp and RPM data + sbufWriteU8(dst, protoTemp); + sbufWriteU16(dst, protoRpm); } - - // No motor count, just raw temp and RPM data - sbufWriteU8(dst, protoTemp); - sbufWriteU16(dst, protoRpm); - break; case DJI_MSP_OSD_CONFIG: From 933e2d53d2a9e1ec734d27154483e0d36d33e965 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Sat, 6 Apr 2024 10:33:47 +0200 Subject: [PATCH 150/241] Drop not needed definitions --- src/main/msp/msp_protocol.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/msp/msp_protocol.h b/src/main/msp/msp_protocol.h index 43e47e6542c..ea7902fccbe 100644 --- a/src/main/msp/msp_protocol.h +++ b/src/main/msp/msp_protocol.h @@ -244,7 +244,6 @@ #define MSP_PIDNAMES 117 //out message the PID names #define MSP_WP 118 //out message get a WP, WP# is in the payload, returns (WP#, lat, lon, alt, flags) WP#0-home, WP#16-poshold #define MSP_BOXIDS 119 //out message get the permanent IDs associated to BOXes -#define MSP_SERVO_CONFIGURATIONS 120 //out message All servo configurations. #define MSP_NAV_STATUS 121 //out message Returns navigation status #define MSP_NAV_CONFIG 122 //out message Returns navigation parameters #define MSP_3D 124 //out message Settings needed for reversible ESCs @@ -264,7 +263,6 @@ #define MSP_SET_WP 209 //in message sets a given WP (WP#,lat, lon, alt, flags) #define MSP_SELECT_SETTING 210 //in message Select Setting Number (0-2) #define MSP_SET_HEAD 211 //in message define a new heading hold direction -#define MSP_SET_SERVO_CONFIGURATION 212 //in message Servo settings #define MSP_SET_MOTOR 214 //in message PropBalance function #define MSP_SET_NAV_CONFIG 215 //in message Sets nav config parameters - write to the eeprom #define MSP_SET_3D 217 //in message Settings needed for reversible ESCs From b55358ff5a5f8a053c116b6f93aadd06ab16c1ea Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Sat, 6 Apr 2024 20:30:01 +0200 Subject: [PATCH 151/241] Drop MSP_PIDNAMES frame as outdated --- src/main/fc/fc_msp.c | 18 ------------------ src/main/msp/msp_protocol.h | 1 - 2 files changed, 19 deletions(-) diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index c1360fcce63..872c8f51d30 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -140,18 +140,6 @@ static const char * const boardIdentifier = TARGET_BOARD_IDENTIFIER; // from mixer.c extern int16_t motor_disarmed[MAX_SUPPORTED_MOTORS]; -static const char pidnames[] = - "ROLL;" - "PITCH;" - "YAW;" - "ALT;" - "Pos;" - "PosR;" - "NavR;" - "LEVEL;" - "MAG;" - "VEL;"; - typedef enum { MSP_SDCARD_STATE_NOT_PRESENT = 0, MSP_SDCARD_STATE_FATAL = 1, @@ -708,12 +696,6 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF #endif break; - case MSP_PIDNAMES: - for (const char *c = pidnames; *c; c++) { - sbufWriteU8(dst, *c); - } - break; - case MSP_MODE_RANGES: for (int i = 0; i < MAX_MODE_ACTIVATION_CONDITION_COUNT; i++) { const modeActivationCondition_t *mac = modeActivationConditions(i); diff --git a/src/main/msp/msp_protocol.h b/src/main/msp/msp_protocol.h index ea7902fccbe..1eddc81c1c2 100644 --- a/src/main/msp/msp_protocol.h +++ b/src/main/msp/msp_protocol.h @@ -241,7 +241,6 @@ #define MSP_MISC 114 //out message powermeter trig #define MSP_MOTOR_PINS 115 //out message which pins are in use for motors & servos, for GUI #define MSP_BOXNAMES 116 //out message the aux switch names -#define MSP_PIDNAMES 117 //out message the PID names #define MSP_WP 118 //out message get a WP, WP# is in the payload, returns (WP#, lat, lon, alt, flags) WP#0-home, WP#16-poshold #define MSP_BOXIDS 119 //out message get the permanent IDs associated to BOXes #define MSP_NAV_STATUS 121 //out message Returns navigation status From 72f622afbe987a762024cb7bf7a4eae12cc04b58 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Sat, 6 Apr 2024 20:46:54 +0200 Subject: [PATCH 152/241] Drop MSP_PID_ADVANCED and MSP_SET_PID_ADVANCED from MSP protocol --- src/main/fc/fc_msp.c | 42 ------------------------------------- src/main/msp/msp_protocol.h | 3 --- 2 files changed, 45 deletions(-) diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index c1360fcce63..2bf9ea70515 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -1236,25 +1236,6 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF sbufWriteU16(dst, 0); //Was gyroConfig()->gyro_stage2_lowpass_hz break; - case MSP_PID_ADVANCED: - sbufWriteU16(dst, 0); // pidProfile()->rollPitchItermIgnoreRate - sbufWriteU16(dst, 0); // pidProfile()->yawItermIgnoreRate - sbufWriteU16(dst, 0); //pidProfile()->yaw_p_limit - sbufWriteU8(dst, 0); //BF: pidProfile()->deltaMethod - sbufWriteU8(dst, 0); //BF: pidProfile()->vbatPidCompensation - sbufWriteU8(dst, 0); //BF: pidProfile()->setpointRelaxRatio - sbufWriteU8(dst, 0); - sbufWriteU16(dst, pidProfile()->pidSumLimit); - sbufWriteU8(dst, 0); //BF: pidProfile()->itermThrottleGain - - /* - * To keep compatibility on MSP frame length level with Betaflight, axis axisAccelerationLimitYaw - * limit will be sent and received in [dps / 10] - */ - sbufWriteU16(dst, constrain(pidProfile()->axisAccelerationLimitRollPitch / 10, 0, 65535)); - sbufWriteU16(dst, constrain(pidProfile()->axisAccelerationLimitYaw / 10, 0, 65535)); - break; - case MSP_INAV_PID: sbufWriteU8(dst, 0); //Legacy, no longer in use async processing value sbufWriteU16(dst, 0); //Legacy, no longer in use async processing value @@ -2241,29 +2222,6 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) return MSP_RESULT_ERROR; break; - case MSP_SET_PID_ADVANCED: - if (dataSize == 17) { - sbufReadU16(src); // pidProfileMutable()->rollPitchItermIgnoreRate - sbufReadU16(src); // pidProfileMutable()->yawItermIgnoreRate - sbufReadU16(src); //pidProfile()->yaw_p_limit - - sbufReadU8(src); //BF: pidProfileMutable()->deltaMethod - sbufReadU8(src); //BF: pidProfileMutable()->vbatPidCompensation - sbufReadU8(src); //BF: pidProfileMutable()->setpointRelaxRatio - sbufReadU8(src); - pidProfileMutable()->pidSumLimit = sbufReadU16(src); - sbufReadU8(src); //BF: pidProfileMutable()->itermThrottleGain - - /* - * To keep compatibility on MSP frame length level with Betaflight, axis axisAccelerationLimitYaw - * limit will be sent and received in [dps / 10] - */ - pidProfileMutable()->axisAccelerationLimitRollPitch = sbufReadU16(src) * 10; - pidProfileMutable()->axisAccelerationLimitYaw = sbufReadU16(src) * 10; - } else - return MSP_RESULT_ERROR; - break; - case MSP_SET_INAV_PID: if (dataSize == 15) { sbufReadU8(src); //Legacy, no longer in use async processing value diff --git a/src/main/msp/msp_protocol.h b/src/main/msp/msp_protocol.h index ea7902fccbe..245b24a3ade 100644 --- a/src/main/msp/msp_protocol.h +++ b/src/main/msp/msp_protocol.h @@ -199,9 +199,6 @@ #define MSP_FILTER_CONFIG 92 #define MSP_SET_FILTER_CONFIG 93 -#define MSP_PID_ADVANCED 94 -#define MSP_SET_PID_ADVANCED 95 - #define MSP_SENSOR_CONFIG 96 #define MSP_SET_SENSOR_CONFIG 97 From e999bca0a709f11280531316b028f4749bc159d2 Mon Sep 17 00:00:00 2001 From: Hristian Todorov Date: Sat, 6 Apr 2024 19:50:35 +0100 Subject: [PATCH 153/241] Configuration symbol for barometer address Signed-off-by: Hristian Todorov --- src/main/target/common_hardware.c | 37 ++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/src/main/target/common_hardware.c b/src/main/target/common_hardware.c index 3346bb92515..0169e8099bf 100755 --- a/src/main/target/common_hardware.c +++ b/src/main/target/common_hardware.c @@ -91,7 +91,10 @@ #if !defined(BMP085_I2C_BUS) #define BMP085_I2C_BUS BARO_I2C_BUS #endif - BUSDEV_REGISTER_I2C(busdev_bmp085, DEVHW_BMP085, BMP085_I2C_BUS, 0x77, NONE, DEVFLAGS_NONE, 0); + #if !defined(BMP085_I2C_ADDR) + #define BMP085_I2C_ADDR (0x77) + #endif + BUSDEV_REGISTER_I2C(busdev_bmp085, DEVHW_BMP085, BMP085_I2C_BUS, BMP085_I2C_ADDR, NONE, DEVFLAGS_NONE, 0); #endif #if defined(USE_BARO_BMP280) @@ -115,7 +118,10 @@ #if !defined(BMP388_I2C_BUS) #define BMP388_I2C_BUS BARO_I2C_BUS #endif - BUSDEV_REGISTER_I2C(busdev_bmp388, DEVHW_BMP388, BMP388_I2C_BUS, 0x76, NONE, DEVFLAGS_NONE, 0); + #if !defined(BMP388_I2C_ADDR) + #define BMP388_I2C_ADDR (0x76) + #endif + BUSDEV_REGISTER_I2C(busdev_bmp388, DEVHW_BMP388, BMP388_I2C_BUS, BMP388_I2C_ADDR, NONE, DEVFLAGS_NONE, 0); #endif #endif @@ -126,7 +132,10 @@ #if !defined(SPL06_I2C_BUS) #define SPL06_I2C_BUS BARO_I2C_BUS #endif - BUSDEV_REGISTER_I2C(busdev_spl06, DEVHW_SPL06, SPL06_I2C_BUS, 0x76, NONE, DEVFLAGS_NONE, 0); + #if !defined(SPL06_I2C_ADDR) + #define SPL06_I2C_ADDR (0x76) + #endif + BUSDEV_REGISTER_I2C(busdev_spl06, DEVHW_SPL06, SPL06_I2C_BUS, SPL06_I2C_ADDR, NONE, DEVFLAGS_NONE, 0); #endif #endif @@ -140,7 +149,10 @@ #if !defined(MS5607_I2C_BUS) #define MS5607_I2C_BUS BARO_I2C_BUS #endif - BUSDEV_REGISTER_I2C(busdev_ms5607, DEVHW_MS5607, MS5607_I2C_BUS, 0x77, NONE, DEVFLAGS_USE_RAW_REGISTERS, 0); + #if !defined(MS5607_I2C_ADDR) + #define MS5607_I2C_ADDR (0x77) + #endif + BUSDEV_REGISTER_I2C(busdev_ms5607, DEVHW_MS5607, MS5607_I2C_BUS, MS5607_I2C_ADDR, NONE, DEVFLAGS_USE_RAW_REGISTERS, 0); #endif #if defined(USE_BARO_MS5611) @@ -150,7 +162,10 @@ #if !defined(MS5611_I2C_BUS) #define MS5611_I2C_BUS BARO_I2C_BUS #endif - BUSDEV_REGISTER_I2C(busdev_ms5611, DEVHW_MS5611, MS5611_I2C_BUS, 0x77, NONE, DEVFLAGS_USE_RAW_REGISTERS, 0); + #if !defined(MS5611_I2C_ADDR) + #define MS5611_I2C_ADDR (0x77) + #endif + BUSDEV_REGISTER_I2C(busdev_ms5611, DEVHW_MS5611, MS5611_I2C_BUS, MS5611_I2C_ADDR, NONE, DEVFLAGS_USE_RAW_REGISTERS, 0); #endif #endif @@ -161,18 +176,24 @@ #if !defined(DPS310_I2C_BUS) #define DPS310_I2C_BUS BARO_I2C_BUS #endif - BUSDEV_REGISTER_I2C(busdev_dps310, DEVHW_DPS310, DPS310_I2C_BUS, 0x76, NONE, DEVFLAGS_NONE, 0); + #if !defined(DPS310_I2C_ADDR) + #define DPS310_I2C_ADDR (0x76) + #endif + BUSDEV_REGISTER_I2C(busdev_dps310, DEVHW_DPS310, DPS310_I2C_BUS, DPS310_I2C_ADDR, NONE, DEVFLAGS_NONE, 0); #endif #endif #if defined(USE_BARO_B2SMPB) #if defined(B2SMPB_SPI_BUS) - BUSDEV_REGISTER_SPI(busdev_b2smpb, DEVHW_B2SMPB, B2SMPB_SPI_BUS, B2SMPB_CS_PIN, NONE, DEVFLAGS_NONE, 0); + BUSDEV_REGISTER_SPI(busdev_b2smpb, DEVHW_B2SMPB, B2SMPB_SPI_BUS, B2SMPB_CS_PIN, NONE, DEVFLAGS_NONE, 0); #elif defined(B2SMPB_I2C_BUS) || defined(BARO_I2C_BUS) #if !defined(B2SMPB_I2C_BUS) #define B2SMPB_I2C_BUS BARO_I2C_BUS #endif - BUSDEV_REGISTER_I2C(busdev_b2smpb, DEVHW_B2SMPB, B2SMPB_I2C_BUS, 0x70, NONE, DEVFLAGS_NONE, 0); + #if !defined(B2SMPB_I2C_ADDR) + #define B2SMPB_I2C_ADDR (0x70) + #endif + BUSDEV_REGISTER_I2C(busdev_b2smpb, DEVHW_B2SMPB, B2SMPB_I2C_BUS, B2SMPB_I2C_ADDR, NONE, DEVFLAGS_NONE, 0); #endif #endif From 78ef85ace5854839cbec77968d60975f44328b7b Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Sat, 6 Apr 2024 20:58:44 +0200 Subject: [PATCH 154/241] Drop MSP_FILTER_CONFIG and MSP_SET_FILTER_CONFIG commands --- src/main/fc/fc_msp.c | 59 ------------------------------------- src/main/msp/msp_protocol.h | 3 -- 2 files changed, 62 deletions(-) diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index c1360fcce63..8244922e202 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -1218,24 +1218,6 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF sbufWriteU8(dst, 0); break; - case MSP_FILTER_CONFIG : - sbufWriteU8(dst, gyroConfig()->gyro_main_lpf_hz); - sbufWriteU16(dst, pidProfile()->dterm_lpf_hz); - sbufWriteU16(dst, pidProfile()->yaw_lpf_hz); - sbufWriteU16(dst, 0); //Was gyroConfig()->gyro_notch_hz - sbufWriteU16(dst, 1); //Was gyroConfig()->gyro_notch_cutoff - sbufWriteU16(dst, 0); //BF: pidProfile()->dterm_notch_hz - sbufWriteU16(dst, 1); //pidProfile()->dterm_notch_cutoff - - sbufWriteU16(dst, 0); //BF: masterConfig.gyro_soft_notch_hz_2 - sbufWriteU16(dst, 1); //BF: masterConfig.gyro_soft_notch_cutoff_2 - - sbufWriteU16(dst, accelerometerConfig()->acc_notch_hz); - sbufWriteU16(dst, accelerometerConfig()->acc_notch_cutoff); - - sbufWriteU16(dst, 0); //Was gyroConfig()->gyro_stage2_lowpass_hz - break; - case MSP_PID_ADVANCED: sbufWriteU16(dst, 0); // pidProfile()->rollPitchItermIgnoreRate sbufWriteU16(dst, 0); // pidProfile()->yawItermIgnoreRate @@ -2200,47 +2182,6 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) return MSP_RESULT_ERROR; break; - case MSP_SET_FILTER_CONFIG : - if (dataSize >= 5) { - gyroConfigMutable()->gyro_main_lpf_hz = sbufReadU8(src); - pidProfileMutable()->dterm_lpf_hz = constrain(sbufReadU16(src), 0, 500); - pidProfileMutable()->yaw_lpf_hz = constrain(sbufReadU16(src), 0, 255); - if (dataSize >= 9) { - sbufReadU16(src); //Was gyroConfigMutable()->gyro_notch_hz - sbufReadU16(src); //Was gyroConfigMutable()->gyro_notch_cutoff - } else { - return MSP_RESULT_ERROR; - } - if (dataSize >= 13) { - sbufReadU16(src); - sbufReadU16(src); - pidInitFilters(); - } else { - return MSP_RESULT_ERROR; - } - if (dataSize >= 17) { - sbufReadU16(src); // Was gyroConfigMutable()->gyro_soft_notch_hz_2 - sbufReadU16(src); // Was gyroConfigMutable()->gyro_soft_notch_cutoff_2 - } else { - return MSP_RESULT_ERROR; - } - - if (dataSize >= 21) { - accelerometerConfigMutable()->acc_notch_hz = constrain(sbufReadU16(src), 0, 255); - accelerometerConfigMutable()->acc_notch_cutoff = constrain(sbufReadU16(src), 1, 255); - } else { - return MSP_RESULT_ERROR; - } - - if (dataSize >= 22) { - sbufReadU16(src); //Was gyro_stage2_lowpass_hz - } else { - return MSP_RESULT_ERROR; - } - } else - return MSP_RESULT_ERROR; - break; - case MSP_SET_PID_ADVANCED: if (dataSize == 17) { sbufReadU16(src); // pidProfileMutable()->rollPitchItermIgnoreRate diff --git a/src/main/msp/msp_protocol.h b/src/main/msp/msp_protocol.h index ea7902fccbe..d8b84c5f8ea 100644 --- a/src/main/msp/msp_protocol.h +++ b/src/main/msp/msp_protocol.h @@ -196,9 +196,6 @@ #define MSP_ADVANCED_CONFIG 90 #define MSP_SET_ADVANCED_CONFIG 91 -#define MSP_FILTER_CONFIG 92 -#define MSP_SET_FILTER_CONFIG 93 - #define MSP_PID_ADVANCED 94 #define MSP_SET_PID_ADVANCED 95 From 7f831ce8fc1b5529ab85813fcf329731e10a30e1 Mon Sep 17 00:00:00 2001 From: 0crap <31951195+0crap@users.noreply.github.com> Date: Mon, 8 Apr 2024 12:54:16 +0200 Subject: [PATCH 155/241] Update Fixed Wing Landing.md Simple typo fix. --- docs/Fixed Wing Landing.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Fixed Wing Landing.md b/docs/Fixed Wing Landing.md index 8e1a3ef6fc1..9a4c3a5b4ad 100644 --- a/docs/Fixed Wing Landing.md +++ b/docs/Fixed Wing Landing.md @@ -54,7 +54,7 @@ This means that practically 4 landing directions can be saved. > [!CAUTION] > The Configuator automatically determines the ground altitude based on databases on the Internet, which may be inaccurate. Please always compare with the measured GPS altitude at the landing site to avoid crashes. -### Global paramters +### Global parameters All settings are available via “Advanced Tuning” in the Configurator. @@ -104,7 +104,7 @@ If the altitude of the waypoint and the "Approach Altitude" are different, the a ## Logic Conditions -The current landing state can be retrieved via ID 41 in "Flight" (FW Land State). This allows additional actions to be executed according to the landing phases, e.g. deplyoment of the landing flaps. +The current landing state can be retrieved via ID 41 in "Flight" (FW Land State). This allows additional actions to be executed according to the landing phases, e.g. deployment of the landing flaps. | Returned value | State | | --- | --- | From 9bbf699d1d24ad4d63a0abd6d9496be73f69c5e4 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Mon, 8 Apr 2024 18:13:02 +0200 Subject: [PATCH 156/241] Drop pidsum limit settings and replace with hardcoded values --- src/main/blackbox/blackbox.c | 2 -- src/main/fc/fc_msp.c | 4 ++-- src/main/fc/settings.yaml | 12 ------------ src/main/flight/pid.c | 29 ++++++++++++++++++----------- src/main/flight/pid.h | 3 +-- src/main/flight/pid_autotune.c | 2 +- 6 files changed, 22 insertions(+), 30 deletions(-) diff --git a/src/main/blackbox/blackbox.c b/src/main/blackbox/blackbox.c index 4606e8a1787..c69a33b5cf9 100644 --- a/src/main/blackbox/blackbox.c +++ b/src/main/blackbox/blackbox.c @@ -1939,8 +1939,6 @@ static bool blackboxWriteSysinfo(void) BLACKBOX_PRINT_HEADER_LINE("waypoints", "%d,%d", getWaypointCount(),isWaypointListValid()); BLACKBOX_PRINT_HEADER_LINE("acc_notch_hz", "%d", accelerometerConfig()->acc_notch_hz); BLACKBOX_PRINT_HEADER_LINE("acc_notch_cutoff", "%d", accelerometerConfig()->acc_notch_cutoff); - BLACKBOX_PRINT_HEADER_LINE("pidSumLimit", "%d", pidProfile()->pidSumLimit); - BLACKBOX_PRINT_HEADER_LINE("pidSumLimitYaw", "%d", pidProfile()->pidSumLimitYaw); BLACKBOX_PRINT_HEADER_LINE("axisAccelerationLimitYaw", "%d", pidProfile()->axisAccelerationLimitYaw); BLACKBOX_PRINT_HEADER_LINE("axisAccelerationLimitRollPitch", "%d", pidProfile()->axisAccelerationLimitRollPitch); #ifdef USE_RPM_FILTER diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index 872c8f51d30..98640193c3e 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -1226,7 +1226,7 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF sbufWriteU8(dst, 0); //BF: pidProfile()->vbatPidCompensation sbufWriteU8(dst, 0); //BF: pidProfile()->setpointRelaxRatio sbufWriteU8(dst, 0); - sbufWriteU16(dst, pidProfile()->pidSumLimit); + sbufWriteU16(dst, 0); //Was pidsum limit sbufWriteU8(dst, 0); //BF: pidProfile()->itermThrottleGain /* @@ -2233,7 +2233,7 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) sbufReadU8(src); //BF: pidProfileMutable()->vbatPidCompensation sbufReadU8(src); //BF: pidProfileMutable()->setpointRelaxRatio sbufReadU8(src); - pidProfileMutable()->pidSumLimit = sbufReadU16(src); + sbufReadU16(src); // Was pidsumLimit sbufReadU8(src); //BF: pidProfileMutable()->itermThrottleGain /* diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index cb586eacf06..f60d7a8cd89 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -1946,18 +1946,6 @@ groups: field: fixedWingYawItermBankFreeze min: 0 max: 90 - - name: pidsum_limit - description: "A limitation to overall amount of correction Flight PID can request on each axis (Roll/Pitch). If when doing a hard maneuver on one axis machine looses orientation on other axis - reducing this parameter may help" - default_value: 500 - field: pidSumLimit - min: PID_SUM_LIMIT_MIN - max: PID_SUM_LIMIT_MAX - - name: pidsum_limit_yaw - description: "A limitation to overall amount of correction Flight PID can request on each axis (Yaw). If when doing a hard maneuver on one axis machine looses orientation on other axis - reducing this parameter may help" - default_value: 350 - field: pidSumLimitYaw - min: PID_SUM_LIMIT_MIN - max: PID_SUM_LIMIT_MAX - name: iterm_windup description: "Used to prevent Iterm accumulation on during maneuvers. Iterm will be dampened when motors are reaching it's limit (when requested motor correction range is above percentage specified by this parameter)" default_value: 50 diff --git a/src/main/flight/pid.c b/src/main/flight/pid.c index 3da150e39dc..c61fe5353f7 100644 --- a/src/main/flight/pid.c +++ b/src/main/flight/pid.c @@ -99,7 +99,6 @@ typedef struct { biquadFilter_t dBoostGyroLpf; float dBoostTargetAcceleration; #endif - uint16_t pidSumLimit; filterApply4FnPtr ptermFilterApplyFn; bool itermLimitActive; bool itermFreezeActive; @@ -170,7 +169,7 @@ static EXTENDED_FASTRAM bool angleHoldIsLevel = false; static EXTENDED_FASTRAM float fixedWingLevelTrim; static EXTENDED_FASTRAM pidController_t fixedWingLevelTrimController; -PG_REGISTER_PROFILE_WITH_RESET_TEMPLATE(pidProfile_t, pidProfile, PG_PID_PROFILE, 6); +PG_REGISTER_PROFILE_WITH_RESET_TEMPLATE(pidProfile_t, pidProfile, PG_PID_PROFILE, 7); PG_RESET_TEMPLATE(pidProfile_t, pidProfile, .bank_mc = { @@ -264,8 +263,6 @@ PG_RESET_TEMPLATE(pidProfile_t, pidProfile, .max_angle_inclination[FD_ROLL] = SETTING_MAX_ANGLE_INCLINATION_RLL_DEFAULT, .max_angle_inclination[FD_PITCH] = SETTING_MAX_ANGLE_INCLINATION_PIT_DEFAULT, - .pidSumLimit = SETTING_PIDSUM_LIMIT_DEFAULT, - .pidSumLimitYaw = SETTING_PIDSUM_LIMIT_YAW_DEFAULT, .pidItermLimitPercent = SETTING_PID_ITERM_LIMIT_PERCENT_DEFAULT, .fixedWingReferenceAirspeed = SETTING_FW_REFERENCE_AIRSPEED_DEFAULT, @@ -772,12 +769,14 @@ static void NOINLINE pidApplyFixedWingRateController(pidState_t *pidState, fligh applyItermLimiting(pidState); + const uint16_t limit = getPidSumLimit(axis); + if (pidProfile()->pidItermLimitPercent != 0){ - float itermLimit = pidState->pidSumLimit * pidProfile()->pidItermLimitPercent * 0.01f; + float itermLimit = limit * pidProfile()->pidItermLimitPercent * 0.01f; pidState->errorGyroIf = constrainf(pidState->errorGyroIf, -itermLimit, +itermLimit); } - axisPID[axis] = constrainf(newPTerm + newFFTerm + pidState->errorGyroIf + newDTerm, -pidState->pidSumLimit, +pidState->pidSumLimit); + axisPID[axis] = constrainf(newPTerm + newFFTerm + pidState->errorGyroIf + newDTerm, -limit, +limit); if (FLIGHT_MODE(SOARING_MODE) && axis == FD_PITCH && calculateRollPitchCenterStatus() == CENTERED) { if (!angleFreefloatDeadband(DEGREES_TO_DECIDEGREES(navConfig()->fw.soaring_pitch_deadband), FD_PITCH)) { @@ -787,7 +786,7 @@ static void NOINLINE pidApplyFixedWingRateController(pidState_t *pidState, fligh #ifdef USE_AUTOTUNE_FIXED_WING if (FLIGHT_MODE(AUTO_TUNE) && !FLIGHT_MODE(MANUAL_MODE)) { - autotuneFixedWingUpdate(axis, rateTarget, pidState->gyroRate, constrainf(newPTerm + newFFTerm, -pidState->pidSumLimit, +pidState->pidSumLimit)); + autotuneFixedWingUpdate(axis, rateTarget, pidState->gyroRate, constrainf(newPTerm + newFFTerm, -limit, +limit)); } #endif @@ -836,9 +835,11 @@ static void FAST_CODE NOINLINE pidApplyMulticopterRateController(pidState_t *pid */ const float newCDTerm = rateTargetDeltaFiltered * pidState->kCD; + const uint16_t limit = getPidSumLimit(axis); + // TODO: Get feedback from mixer on available correction range for each axis const float newOutput = newPTerm + newDTerm + pidState->errorGyroIf + newCDTerm; - const float newOutputLimited = constrainf(newOutput, -pidState->pidSumLimit, +pidState->pidSumLimit); + const float newOutputLimited = constrainf(newOutput, -limit, +limit); float itermErrorRate = applyItermRelax(axis, rateTarget, rateError); @@ -850,7 +851,7 @@ static void FAST_CODE NOINLINE pidApplyMulticopterRateController(pidState_t *pid + ((newOutputLimited - newOutput) * pidState->kT * antiWindupScaler * dT); if (pidProfile()->pidItermLimitPercent != 0){ - float itermLimit = pidState->pidSumLimit * pidProfile()->pidItermLimitPercent * 0.01f; + float itermLimit = limit * pidProfile()->pidItermLimitPercent * 0.01f; pidState->errorGyroIf = constrainf(pidState->errorGyroIf, -itermLimit, +itermLimit); } @@ -1284,14 +1285,12 @@ void pidInit(void) pidState[axis].axis = axis; if (axis == FD_YAW) { - pidState[axis].pidSumLimit = pidProfile()->pidSumLimitYaw; if (yawLpfHz) { pidState[axis].ptermFilterApplyFn = (filterApply4FnPtr) pt1FilterApply4; } else { pidState[axis].ptermFilterApplyFn = (filterApply4FnPtr) nullFilterApply4; } } else { - pidState[axis].pidSumLimit = pidProfile()->pidSumLimit; pidState[axis].ptermFilterApplyFn = (filterApply4FnPtr) nullFilterApply4; } } @@ -1408,3 +1407,11 @@ float getFixedWingLevelTrim(void) { return STATE(AIRPLANE) ? fixedWingLevelTrim : 0; } + +uint16_t getPidSumLimit(const flight_dynamics_index_t axis) { + if (axis == FD_YAW) { + return STATE(MULTIROTOR) ? 400 : 500; + } else { + return 500; + } +} \ No newline at end of file diff --git a/src/main/flight/pid.h b/src/main/flight/pid.h index e0a8b9d310b..e088ccffadf 100644 --- a/src/main/flight/pid.h +++ b/src/main/flight/pid.h @@ -115,8 +115,6 @@ typedef struct pidProfile_s { int16_t max_angle_inclination[ANGLE_INDEX_COUNT]; // Max possible inclination (roll and pitch axis separately - uint16_t pidSumLimit; - uint16_t pidSumLimitYaw; uint16_t pidItermLimitPercent; // Airplane-specific parameters @@ -221,3 +219,4 @@ bool isFixedWingLevelTrimActive(void); void updateFixedWingLevelTrim(timeUs_t currentTimeUs); float getFixedWingLevelTrim(void); bool isAngleHoldLevel(void); +uint16_t getPidSumLimit(const flight_dynamics_index_t axis); \ No newline at end of file diff --git a/src/main/flight/pid_autotune.c b/src/main/flight/pid_autotune.c index 140c4ab61d9..af6896f4233 100755 --- a/src/main/flight/pid_autotune.c +++ b/src/main/flight/pid_autotune.c @@ -171,7 +171,7 @@ void autotuneFixedWingUpdate(const flight_dynamics_index_t axis, float desiredRa float gainFF = tuneCurrent[axis].gainFF; float maxDesiredRate = maxRateSetting; - const float pidSumLimit = (axis == FD_YAW) ? pidProfile()->pidSumLimitYaw : pidProfile()->pidSumLimit; + const float pidSumLimit = getPidSumLimit(axis); const float absDesiredRate = fabsf(desiredRate); const float absReachedRate = fabsf(reachedRate); const float absPidOutput = fabsf(pidOutput); From c92b0a6a2ce375648e0a15b12b585e1c41e91bcb Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Mon, 8 Apr 2024 18:14:43 +0200 Subject: [PATCH 157/241] Update docs --- docs/Settings.md | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/docs/Settings.md b/docs/Settings.md index b6fd431d950..dea4f4f60ad 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -5062,26 +5062,6 @@ Allows to set type of PID controller used in control loop. Possible values: `NON --- -### pidsum_limit - -A limitation to overall amount of correction Flight PID can request on each axis (Roll/Pitch). If when doing a hard maneuver on one axis machine looses orientation on other axis - reducing this parameter may help - -| Default | Min | Max | -| --- | --- | --- | -| 500 | PID_SUM_LIMIT_MIN | PID_SUM_LIMIT_MAX | - ---- - -### pidsum_limit_yaw - -A limitation to overall amount of correction Flight PID can request on each axis (Yaw). If when doing a hard maneuver on one axis machine looses orientation on other axis - reducing this parameter may help - -| Default | Min | Max | -| --- | --- | --- | -| 350 | PID_SUM_LIMIT_MIN | PID_SUM_LIMIT_MAX | - ---- - ### pilot_name Pilot name From b3438919f5fddbfac221affcc48cadbc87464ac9 Mon Sep 17 00:00:00 2001 From: error414 Date: Sat, 16 Mar 2024 10:31:06 +0100 Subject: [PATCH 158/241] new NRA protocol fro radars from nanoradar new rangerfinder NRA15/NRA24 from nanoradar --- docs/Rangefinder.md | 16 +++ src/main/CMakeLists.txt | 3 + src/main/fc/settings.yaml | 2 +- src/main/io/rangefinder.h | 2 + src/main/io/rangefinder_nanoradar.c | 167 ++++++++++++++++++++++++++++ src/main/io/rangefinder_usd1_v0.c | 136 ++++++++++++++++++++++ src/main/sensors/rangefinder.c | 16 +++ src/main/sensors/rangefinder.h | 2 + src/main/target/common.h | 2 + 9 files changed, 345 insertions(+), 1 deletion(-) create mode 100644 src/main/io/rangefinder_nanoradar.c create mode 100644 src/main/io/rangefinder_usd1_v0.c diff --git a/docs/Rangefinder.md b/docs/Rangefinder.md index 095a6f0df33..813184f8374 100644 --- a/docs/Rangefinder.md +++ b/docs/Rangefinder.md @@ -21,6 +21,22 @@ Following rangefinders are supported: * MSP - experimental * TOF10120 - small & lightweight laser range sensor, usable up to 200cm * TERARANGER EVO - 30cm to 600cm, depends on version https://www.terabee.com/sensors-modules/lidar-tof-range-finders/#individual-distance-measurement-sensors +* NRA15/NRA24 - experimental, UART version + +#### NRA15/NRA24 +NRA15/NRA24 from nanoradar use US-D1_V0 or NRA protocol, it depends which firmware you use. Radar can be set by firmware +to two different resolutions. See table below. + +| Radar | Protocol | Resolution | Name in configurator | +|-------|----------|-----------------|-----------------------| +| NRA15 | US-D1_V0 | 0-30m (+-4cm) | USD1_V0 | +| NRA15 | NRA | 0-30m (+-4cm) | NRA15/NRA24 | +| NRA15 | NRA | 0-100m (+-10cm) | NRA15/NRA24 | +| NRA24 | US-D1_V0 | 0-50m (+-4cm) | USD1_V0 | +| NRA24 | US-D1_V0 | 0-200m (+-10cm) | USD1_V0 | +| NRA24 | NRA | 0-50m (+-4cm) | NRA15/NRA24 | +| NRA24 | NRA | 0-200m (+-10cm) | NRA15/NRA24 | + ## Connections diff --git a/src/main/CMakeLists.txt b/src/main/CMakeLists.txt index cba13db687e..28c068966f8 100755 --- a/src/main/CMakeLists.txt +++ b/src/main/CMakeLists.txt @@ -1,3 +1,4 @@ + main_sources(COMMON_SRC main.c @@ -485,6 +486,8 @@ main_sources(COMMON_SRC io/rangefinder.h io/rangefinder_msp.c io/rangefinder_benewake.c + io/rangefinder_usd1_v0.c + io/rangefinder_nanoradar.c io/rangefinder_fake.c io/opflow.h io/opflow_cxof.c diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index cb586eacf06..b2be345391d 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -5,7 +5,7 @@ tables: values: ["NONE", "AUTO", "MPU6000", "MPU6500", "MPU9250", "BMI160", "ICM20689", "BMI088", "ICM42605", "BMI270","LSM6DXX", "FAKE"] enum: accelerationSensor_e - name: rangefinder_hardware - values: ["NONE", "SRF10", "VL53L0X", "MSP", "BENEWAKE", "VL53L1X", "US42", "TOF10120_I2C", "FAKE", "TERARANGER_EVO"] + values: ["NONE", "SRF10", "VL53L0X", "MSP", "BENEWAKE", "VL53L1X", "US42", "TOF10120_I2C", "FAKE", "TERARANGER_EVO", "USD1_V0", "NRA15/NRA24"] enum: rangefinderType_e - name: mag_hardware values: ["NONE", "AUTO", "HMC5883", "AK8975", "MAG3110", "AK8963", "IST8310", "QMC5883", "MPU9250", "IST8308", "LIS3MDL", "MSP", "RM3100", "VCM5883", "MLX90393", "FAKE"] diff --git a/src/main/io/rangefinder.h b/src/main/io/rangefinder.h index 6768c7d75d8..fd51aeb44aa 100644 --- a/src/main/io/rangefinder.h +++ b/src/main/io/rangefinder.h @@ -31,6 +31,8 @@ extern virtualRangefinderVTable_t rangefinderMSPVtable; extern virtualRangefinderVTable_t rangefinderBenewakeVtable; +extern virtualRangefinderVTable_t rangefinderUSD1Vtable; +extern virtualRangefinderVTable_t rangefinderNanoradarVtable; //NRA15/NRA24 extern virtualRangefinderVTable_t rangefinderFakeVtable; void mspRangefinderReceiveNewData(uint8_t * bufferPtr); diff --git a/src/main/io/rangefinder_nanoradar.c b/src/main/io/rangefinder_nanoradar.c new file mode 100644 index 00000000000..f6978448ea4 --- /dev/null +++ b/src/main/io/rangefinder_nanoradar.c @@ -0,0 +1,167 @@ +/* + * This file is part of INAV Project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * Alternatively, the contents of this file may be used under the terms + * of the GNU General Public License Version 3, as described below: + * + * This file is free software: you may copy, redistribute 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. + * + * This file 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 this program. If not, see http://www.gnu.org/licenses/. + */ + +#include +#include + +#include "platform.h" +#include "io/serial.h" +#include "drivers/time.h" + +#if defined(USE_RANGEFINDER_NANORADAR) +#include "drivers/rangefinder/rangefinder_virtual.h" + +#define NANORADAR_HDR 0xAA // Header Byte +#define NANORADAR_END 0x55 + +#define NANORADAR_COMMAND_TARGET_INFO 0x70C + +typedef struct __attribute__((packed)) { + uint8_t header0; + uint8_t header1; + uint8_t commandH; + uint8_t commandL; + uint8_t index; // Target ID + uint8_t rcs; // The section of radar reflection + uint8_t rangeH; // Target distance high 8 bi + uint8_t rangeL; // Target distance low 8 bit + uint8_t rsvd1; + uint8_t info; // VrelH Rsvd1 RollCount + uint8_t vrelL; + uint8_t SNR; // Signal-Noise Ratio + uint8_t end0; + uint8_t end1; +} nanoradarPacket_t; + +#define NANORADAR_PACKET_SIZE sizeof(nanoradarPacket_t) +#define NANORADAR_TIMEOUT_MS 2000 // 2s + +static bool hasNewData = false; +static bool hasEverData = false; +static serialPort_t * serialPort = NULL; +static serialPortConfig_t * portConfig; +static uint8_t buffer[NANORADAR_PACKET_SIZE]; +static unsigned bufferPtr; + +static int32_t sensorData = RANGEFINDER_NO_NEW_DATA; +static timeMs_t lastProtocolActivityMs; + +static bool nanoradarRangefinderDetect(void) +{ + portConfig = findSerialPortConfig(FUNCTION_RANGEFINDER); + if (!portConfig) { + return false; + } + + return true; +} + +static void nanoradarRangefinderInit(void) +{ + if (!portConfig) { + return; + } + + serialPort = openSerialPort(portConfig->identifier, FUNCTION_RANGEFINDER, NULL, NULL, 115200, MODE_RXTX, SERIAL_NOT_INVERTED); + if (!serialPort) { + return; + } + + lastProtocolActivityMs = 0; +} + +static void nanoradarRangefinderUpdate(void) +{ + + nanoradarPacket_t *nanoradarPacket = (nanoradarPacket_t *)buffer; + while (serialRxBytesWaiting(serialPort) > 0) { + uint8_t c = serialRead(serialPort); + + if (bufferPtr < NANORADAR_PACKET_SIZE) { + buffer[bufferPtr++] = c; + } + + if ((bufferPtr == 1) && (nanoradarPacket->header0 != NANORADAR_HDR)) { + bufferPtr = 0; + continue; + } + + if ((bufferPtr == 2) && (nanoradarPacket->header1 != NANORADAR_HDR)) { + bufferPtr = 0; + continue; + } + + //only target info packet we are interested + if (bufferPtr == 4) { + uint16_t command = nanoradarPacket->commandH + (nanoradarPacket->commandL * 0x100); + + if (command != NANORADAR_COMMAND_TARGET_INFO) { + bufferPtr = 0; + continue; + } + } + + // Check for complete packet + if (bufferPtr == NANORADAR_PACKET_SIZE) { + if (nanoradarPacket->end0 == NANORADAR_END && nanoradarPacket->end1 == NANORADAR_END) { + // Valid packet + hasNewData = true; + hasEverData = true; + lastProtocolActivityMs = millis(); + + sensorData = ((nanoradarPacket->rangeH * 0x100) + nanoradarPacket->rangeL); + } + + // Prepare for new packet + bufferPtr = 0; + } + } +} + +static int32_t nanoradarRangefinderGetDistance(void) +{ + int32_t altitude = (sensorData > 0) ? (sensorData) : RANGEFINDER_OUT_OF_RANGE; + + if (hasNewData) { + hasNewData = false; + return altitude; + } + else { + //keep last value for timeout, because radar sends data only if change + if ((millis() - lastProtocolActivityMs) < NANORADAR_TIMEOUT_MS) { + return altitude; + } + + return hasEverData ? RANGEFINDER_OUT_OF_RANGE : RANGEFINDER_NO_NEW_DATA; + } +} + +virtualRangefinderVTable_t rangefinderNanoradarVtable = { + .detect = nanoradarRangefinderDetect, + .init = nanoradarRangefinderInit, + .update = nanoradarRangefinderUpdate, + .read = nanoradarRangefinderGetDistance +}; + +#endif diff --git a/src/main/io/rangefinder_usd1_v0.c b/src/main/io/rangefinder_usd1_v0.c new file mode 100644 index 00000000000..a509d4096c2 --- /dev/null +++ b/src/main/io/rangefinder_usd1_v0.c @@ -0,0 +1,136 @@ +/* + * This file is part of INAV Project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * Alternatively, the contents of this file may be used under the terms + * of the GNU General Public License Version 3, as described below: + * + * This file is free software: you may copy, redistribute 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. + * + * This file 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 this program. If not, see http://www.gnu.org/licenses/. + */ + +#include +#include + + +#include "platform.h" +#include "io/serial.h" +#include "drivers/time.h" + +#if defined(USE_RANGEFINDER_USD1_V0) +#include "drivers/rangefinder/rangefinder_virtual.h" + +#define USD1_HDR_V0 72 // Header Byte for beta V0 of USD1_Serial (0x48) + +#define USD1_PACKET_SIZE 3 +#define USD1_KEEP_DATA_TIMEOUT 2000 // 2s + + +static serialPort_t * serialPort = NULL; +static serialPortConfig_t * portConfig; + +static bool hasNewData = false; +static bool hasEverData = false; +static uint8_t lineBuf[USD1_PACKET_SIZE]; +static int32_t sensorData = RANGEFINDER_NO_NEW_DATA; +static timeMs_t lastProtocolActivityMs; + +static bool usd1RangefinderDetect(void) +{ + portConfig = findSerialPortConfig(FUNCTION_RANGEFINDER); + if (!portConfig) { + return false; + } + + return true; +} + +static void usd1RangefinderInit(void) +{ + if (!portConfig) { + return; + } + + serialPort = openSerialPort(portConfig->identifier, FUNCTION_RANGEFINDER, NULL, NULL, 115200, MODE_RXTX, SERIAL_NOT_INVERTED); + if (!serialPort) { + return; + } + + lastProtocolActivityMs = 0; +} + +static void usd1RangefinderUpdate(void) +{ + float sum = 0; + uint16_t count = 0; + uint8_t index = 0; + + while (serialRxBytesWaiting(serialPort) > 0) { + uint8_t c = serialRead(serialPort); + + if (c == USD1_HDR_V0 && index == 0) { + lineBuf[index] = c; + index = 1; + continue; + } + + if (index > 0) { + lineBuf[index] = c; + index++; + if (index == 3) { + index = 0; + sum += (float)((lineBuf[2]&0x7F) * 128 + (lineBuf[1]&0x7F)); + count++; + } + } + } + + if (count == 0) { + return; + } + + hasNewData = true; + hasEverData = true; + lastProtocolActivityMs = millis(); + sensorData = (int32_t)(2.5f * sum / (float)count); +} + +static int32_t usd1RangefinderGetDistance(void) +{ + int32_t altitude = (sensorData > 0) ? (sensorData) : RANGEFINDER_OUT_OF_RANGE; + + if (hasNewData) { + hasNewData = false; + return altitude; + } + else { + //keep last value for timeout, because radar sends data only if change + if ((millis() - lastProtocolActivityMs) < USD1_KEEP_DATA_TIMEOUT) { + return altitude; + } + + return hasEverData ? RANGEFINDER_OUT_OF_RANGE : RANGEFINDER_NO_NEW_DATA; + } +} + +virtualRangefinderVTable_t rangefinderUSD1Vtable = { + .detect = usd1RangefinderDetect, + .init = usd1RangefinderInit, + .update = usd1RangefinderUpdate, + .read = usd1RangefinderGetDistance +}; + +#endif diff --git a/src/main/sensors/rangefinder.c b/src/main/sensors/rangefinder.c index 88f027f1545..a721bb98634 100644 --- a/src/main/sensors/rangefinder.c +++ b/src/main/sensors/rangefinder.c @@ -130,6 +130,22 @@ static bool rangefinderDetect(rangefinderDev_t * dev, uint8_t rangefinderHardwar rangefinderHardware = RANGEFINDER_BENEWAKE; rescheduleTask(TASK_RANGEFINDER, TASK_PERIOD_MS(RANGEFINDER_VIRTUAL_TASK_PERIOD_MS)); } +#endif + break; + case RANGEFINDER_USD1_V0: +#if defined(USE_RANGEFINDER_USD1_V0) + if (virtualRangefinderDetect(dev, &rangefinderUSD1Vtable)) { + rangefinderHardware = RANGEFINDER_USD1_V0; + rescheduleTask(TASK_RANGEFINDER, TASK_PERIOD_MS(RANGEFINDER_VIRTUAL_TASK_PERIOD_MS)); + } +#endif + break; + case RANGEFINDER_NANORADAR: +#if defined(USE_RANGEFINDER_NANORADAR) + if (virtualRangefinderDetect(dev, &rangefinderNanoradarVtable)) { + rangefinderHardware = RANGEFINDER_NANORADAR; + rescheduleTask(TASK_RANGEFINDER, TASK_PERIOD_MS(RANGEFINDER_VIRTUAL_TASK_PERIOD_MS)); + } #endif break; diff --git a/src/main/sensors/rangefinder.h b/src/main/sensors/rangefinder.h index 2888e7838af..4c2a4e629aa 100644 --- a/src/main/sensors/rangefinder.h +++ b/src/main/sensors/rangefinder.h @@ -32,6 +32,8 @@ typedef enum { RANGEFINDER_TOF10102I2C = 7, RANGEFINDER_FAKE = 8, RANGEFINDER_TERARANGER_EVO = 9, + RANGEFINDER_USD1_V0 = 10, + RANGEFINDER_NANORADAR = 11, } rangefinderType_e; typedef struct rangefinderConfig_s { diff --git a/src/main/target/common.h b/src/main/target/common.h index d146ebb9790..b550df42d0f 100644 --- a/src/main/target/common.h +++ b/src/main/target/common.h @@ -84,6 +84,8 @@ #define USE_RANGEFINDER_US42 #define USE_RANGEFINDER_TOF10120_I2C #define USE_RANGEFINDER_TERARANGER_EVO_I2C +#define USE_RANGEFINDER_USD1_V0 +#define USE_RANGEFINDER_NANORADAR // Allow default optic flow boards #define USE_OPFLOW From c2c03b99f4d47cfbee916813f88caa985acb17eb Mon Sep 17 00:00:00 2001 From: Roman Lut <11955117+RomanLut@users.noreply.github.com> Date: Tue, 9 Apr 2024 13:40:48 +0200 Subject: [PATCH 159/241] do not remove nav modes in connected by usb --- src/main/fc/fc_msp_box.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/fc/fc_msp_box.c b/src/main/fc/fc_msp_box.c index 0cb2ab1b32c..2745f7e041b 100644 --- a/src/main/fc/fc_msp_box.c +++ b/src/main/fc/fc_msp_box.c @@ -213,7 +213,7 @@ void initActiveBoxIds(void) ADD_ACTIVE_BOX(BOXFPVANGLEMIX); } - bool navReadyAltControl = sensors(SENSOR_BARO); + bool navReadyAltControl = getHwBarometerStatus() != HW_SENSOR_NONE; #ifdef USE_GPS navReadyAltControl = navReadyAltControl || (feature(FEATURE_GPS) && (STATE(AIRPLANE) || positionEstimationConfig()->use_gps_no_baro)); From 3f9d10f1551b0e30fbc876787c7df3fe2df0708c Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Tue, 9 Apr 2024 20:53:15 +0200 Subject: [PATCH 160/241] Drop max_throttle settings and set it hardcoded to 1850 for rovers and boats and 2000 for multicopters and fixedwings. --- src/main/blackbox/blackbox.c | 4 +- src/main/fc/fc_msp.c | 8 ++-- src/main/fc/rc_curves.c | 6 +-- src/main/fc/settings.yaml | 6 --- src/main/flight/dynamic_lpf.c | 4 +- src/main/flight/mixer.c | 45 ++++++++++++++------ src/main/flight/mixer.h | 5 ++- src/main/flight/pid.c | 4 +- src/main/navigation/navigation_fixedwing.c | 2 +- src/main/navigation/navigation_multicopter.c | 8 ++-- src/main/navigation/navigation_rover_boat.c | 2 +- src/main/target/ASGARD32F4/config.c | 1 - src/main/target/ASGARD32F7/config.c | 1 - 13 files changed, 53 insertions(+), 43 deletions(-) diff --git a/src/main/blackbox/blackbox.c b/src/main/blackbox/blackbox.c index 4606e8a1787..c8a46532fa4 100644 --- a/src/main/blackbox/blackbox.c +++ b/src/main/blackbox/blackbox.c @@ -1844,9 +1844,9 @@ static bool blackboxWriteSysinfo(void) BLACKBOX_PRINT_HEADER_LINE("Craft name", "%s", systemConfig()->craftName); BLACKBOX_PRINT_HEADER_LINE("P interval", "%u/%u", blackboxConfig()->rate_num, blackboxConfig()->rate_denom); BLACKBOX_PRINT_HEADER_LINE("minthrottle", "%d", getThrottleIdleValue()); - BLACKBOX_PRINT_HEADER_LINE("maxthrottle", "%d", motorConfig()->maxthrottle); + BLACKBOX_PRINT_HEADER_LINE("maxthrottle", "%d", getMaxThrottle()); BLACKBOX_PRINT_HEADER_LINE("gyro_scale", "0x%x", castFloatBytesToInt(1.0f)); - BLACKBOX_PRINT_HEADER_LINE("motorOutput", "%d,%d", getThrottleIdleValue(),motorConfig()->maxthrottle); + BLACKBOX_PRINT_HEADER_LINE("motorOutput", "%d,%d", getThrottleIdleValue(),getMaxThrottle()); BLACKBOX_PRINT_HEADER_LINE("acc_1G", "%u", acc.dev.acc_1G); #ifdef USE_ADC diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index cba93fb59cf..88b2e35780e 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -733,7 +733,7 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF sbufWriteU16(dst, PWM_RANGE_MIDDLE); sbufWriteU16(dst, 0); // Was min_throttle - sbufWriteU16(dst, motorConfig()->maxthrottle); + sbufWriteU16(dst, getMaxThrottle()); sbufWriteU16(dst, motorConfig()->mincommand); sbufWriteU16(dst, currentBatteryProfile->failsafe_throttle); @@ -774,7 +774,7 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF sbufWriteU16(dst, PWM_RANGE_MIDDLE); sbufWriteU16(dst, 0); //Was min_throttle - sbufWriteU16(dst, motorConfig()->maxthrottle); + sbufWriteU16(dst, getMaxThrottle()); sbufWriteU16(dst, motorConfig()->mincommand); sbufWriteU16(dst, currentBatteryProfile->failsafe_throttle); @@ -1858,7 +1858,7 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) sbufReadU16(src); // midrc sbufReadU16(src); //Was min_throttle - motorConfigMutable()->maxthrottle = constrain(sbufReadU16(src), PWM_RANGE_MIN, PWM_RANGE_MAX); + sbufReadU16(src); //Was maxThrottle motorConfigMutable()->mincommand = constrain(sbufReadU16(src), 0, PWM_RANGE_MAX); currentBatteryProfileMutable->failsafe_throttle = constrain(sbufReadU16(src), PWM_RANGE_MIN, PWM_RANGE_MAX); @@ -1906,7 +1906,7 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) sbufReadU16(src); // midrc sbufReadU16(src); // was min_throttle - motorConfigMutable()->maxthrottle = constrain(sbufReadU16(src), PWM_RANGE_MIN, PWM_RANGE_MAX); + sbufReadU16(src); // was maxThrottle motorConfigMutable()->mincommand = constrain(sbufReadU16(src), 0, PWM_RANGE_MAX); currentBatteryProfileMutable->failsafe_throttle = constrain(sbufReadU16(src), PWM_RANGE_MIN, PWM_RANGE_MAX); diff --git a/src/main/fc/rc_curves.c b/src/main/fc/rc_curves.c index 47da45113bc..5453083d279 100644 --- a/src/main/fc/rc_curves.c +++ b/src/main/fc/rc_curves.c @@ -39,7 +39,7 @@ int16_t lookupThrottleRCMid; // THROTTLE curve mid point void generateThrottleCurve(const controlRateConfig_t *controlRateConfig) { const int minThrottle = getThrottleIdleValue(); - lookupThrottleRCMid = minThrottle + (int32_t)(motorConfig()->maxthrottle - minThrottle) * controlRateConfig->throttle.rcMid8 / 100; // [MINTHROTTLE;MAXTHROTTLE] + lookupThrottleRCMid = minThrottle + (int32_t)(getMaxThrottle() - minThrottle) * controlRateConfig->throttle.rcMid8 / 100; // [MINTHROTTLE;MAXTHROTTLE] for (int i = 0; i < THROTTLE_LOOKUP_LENGTH; i++) { const int16_t tmp = 10 * i - controlRateConfig->throttle.rcMid8; @@ -49,7 +49,7 @@ void generateThrottleCurve(const controlRateConfig_t *controlRateConfig) if (tmp < 0) y = controlRateConfig->throttle.rcMid8; lookupThrottleRC[i] = 10 * controlRateConfig->throttle.rcMid8 + tmp * (100 - controlRateConfig->throttle.rcExpo8 + (int32_t) controlRateConfig->throttle.rcExpo8 * (tmp * tmp) / (y * y)) / 10; - lookupThrottleRC[i] = minThrottle + (int32_t) (motorConfig()->maxthrottle - minThrottle) * lookupThrottleRC[i] / 1000; // [MINTHROTTLE;MAXTHROTTLE] + lookupThrottleRC[i] = minThrottle + (int32_t) (getMaxThrottle() - minThrottle) * lookupThrottleRC[i] / 1000; // [MINTHROTTLE;MAXTHROTTLE] } } @@ -62,7 +62,7 @@ int16_t rcLookup(int32_t stickDeflection, uint8_t expo) uint16_t rcLookupThrottle(uint16_t absoluteDeflection) { if (absoluteDeflection > 999) - return motorConfig()->maxthrottle; + return getMaxThrottle(); const uint8_t lookupStep = absoluteDeflection / 100; return lookupThrottleRC[lookupStep] + (absoluteDeflection - lookupStep * 100) * (lookupThrottleRC[lookupStep + 1] - lookupThrottleRC[lookupStep]) / 100; diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index cb586eacf06..b2393250fb4 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -732,12 +732,6 @@ groups: type: motorConfig_t headers: ["flight/mixer.h"] members: - - name: max_throttle - description: "This is the maximum value (in us) sent to esc when armed. Default of 1850 are OK for everyone (legacy). For modern ESCs, higher values (c. 2000) may be more appropriate. If you have brushed motors, the value should be set to 2000." - default_value: 1850 - field: maxthrottle - min: PWM_RANGE_MIN - max: PWM_RANGE_MAX - name: min_command description: "This is the PWM value sent to ESCs when they are not armed. If ESCs beep slowly when powered up, try decreasing this value. It can also be used for calibrating all ESCs at once." default_value: 1000 diff --git a/src/main/flight/dynamic_lpf.c b/src/main/flight/dynamic_lpf.c index 5751c84e85e..0e5b4f6ef28 100644 --- a/src/main/flight/dynamic_lpf.c +++ b/src/main/flight/dynamic_lpf.c @@ -41,8 +41,8 @@ void dynamicLpfGyroTask(void) { return; } - const float throttleConstrained = (float) constrain(rcCommand[THROTTLE], getThrottleIdleValue(), motorConfig()->maxthrottle); - const float throttle = scaleRangef(throttleConstrained, getThrottleIdleValue(), motorConfig()->maxthrottle, 0.0f, 1.0f); + const float throttleConstrained = (float) constrain(rcCommand[THROTTLE], getThrottleIdleValue(), getMaxThrottle()); + const float throttle = scaleRangef(throttleConstrained, getThrottleIdleValue(), getMaxThrottle(), 0.0f, 1.0f); const float cutoffFreq = dynLpfCutoffFreq(throttle, gyroConfig()->gyroDynamicLpfMinHz, gyroConfig()->gyroDynamicLpfMaxHz, gyroConfig()->gyroDynamicLpfCurveExpo); DEBUG_SET(DEBUG_DYNAMIC_GYRO_LPF, 0, cutoffFreq); diff --git a/src/main/flight/mixer.c b/src/main/flight/mixer.c index 834841e6580..d2a073f26ee 100644 --- a/src/main/flight/mixer.c +++ b/src/main/flight/mixer.c @@ -57,6 +57,9 @@ #include "sensors/battery.h" +#define MAX_THROTTLE 2000 +#define MAX_THROTTLE_ROVER 1850 + FASTRAM int16_t motor[MAX_SUPPORTED_MOTORS]; FASTRAM int16_t motor_disarmed[MAX_SUPPORTED_MOTORS]; static float motorMixRange; @@ -83,12 +86,11 @@ PG_RESET_TEMPLATE(reversibleMotorsConfig_t, reversibleMotorsConfig, .neutral = SETTING_3D_NEUTRAL_DEFAULT ); -PG_REGISTER_WITH_RESET_TEMPLATE(motorConfig_t, motorConfig, PG_MOTOR_CONFIG, 10); +PG_REGISTER_WITH_RESET_TEMPLATE(motorConfig_t, motorConfig, PG_MOTOR_CONFIG, 11); PG_RESET_TEMPLATE(motorConfig_t, motorConfig, .motorPwmProtocol = SETTING_MOTOR_PWM_PROTOCOL_DEFAULT, .motorPwmRate = SETTING_MOTOR_PWM_RATE_DEFAULT, - .maxthrottle = SETTING_MAX_THROTTLE_DEFAULT, .mincommand = SETTING_MIN_COMMAND_DEFAULT, .motorPoleCount = SETTING_MOTOR_POLES_DEFAULT, // Most brushless motors that we use are 14 poles ); @@ -106,7 +108,7 @@ void pgResetFn_timerOverrides(timerOverride_t *instance) int getThrottleIdleValue(void) { if (!throttleIdleValue) { - throttleIdleValue = motorConfig()->mincommand + (((motorConfig()->maxthrottle - motorConfig()->mincommand) / 100.0f) * currentBatteryProfile->motor.throttleIdle); + throttleIdleValue = motorConfig()->mincommand + (((getMaxThrottle() - motorConfig()->mincommand) / 100.0f) * currentBatteryProfile->motor.throttleIdle); } return throttleIdleValue; @@ -242,11 +244,11 @@ void mixerResetDisarmedMotors(void) if (feature(FEATURE_REVERSIBLE_MOTORS)) { motorZeroCommand = reversibleMotorsConfig()->neutral; throttleRangeMin = throttleDeadbandHigh; - throttleRangeMax = motorConfig()->maxthrottle; + throttleRangeMax = getMaxThrottle(); } else { motorZeroCommand = motorConfig()->mincommand; throttleRangeMin = throttleIdleValue; - throttleRangeMax = motorConfig()->maxthrottle; + throttleRangeMax = getMaxThrottle(); } reversibleMotorsThrottleState = MOTOR_DIRECTION_FORWARD; @@ -357,7 +359,7 @@ static void applyTurtleModeToMotors(void) { motorOutputNormalised = MIN(1.0f, flipPower * motorOutputNormalised); - motor[i] = (int16_t)scaleRangef(motorOutputNormalised, 0, 1, motorConfig()->mincommand, motorConfig()->maxthrottle); + motor[i] = (int16_t)scaleRangef(motorOutputNormalised, 0, 1, motorConfig()->mincommand, getMaxThrottle()); } } else { // Disarmed mode @@ -407,7 +409,7 @@ void FAST_CODE writeMotors(void) throttleIdleValue, DSHOT_DISARM_COMMAND, motorConfig()->mincommand, - motorConfig()->maxthrottle, + getMaxThrottle(), DSHOT_MIN_THROTTLE, DSHOT_MAX_THROTTLE, true @@ -424,7 +426,7 @@ void FAST_CODE writeMotors(void) throttleRangeMin, throttleRangeMax, reversibleMotorsConfig()->deadband_high, - motorConfig()->maxthrottle, + getMaxThrottle(), true ); } else { @@ -551,7 +553,7 @@ void FAST_CODE mixTable(void) #ifdef USE_PROGRAMMING_FRAMEWORK if (LOGIC_CONDITION_GLOBAL_FLAG(LOGIC_CONDITION_GLOBAL_FLAG_OVERRIDE_THROTTLE)) { throttleRangeMin = throttleIdleValue; - throttleRangeMax = motorConfig()->maxthrottle; + throttleRangeMax = getMaxThrottle(); mixerThrottleCommand = constrain(logicConditionValuesByType[LOGIC_CONDITION_OVERRIDE_THROTTLE], throttleRangeMin, throttleRangeMax); } else #endif @@ -562,7 +564,7 @@ void FAST_CODE mixTable(void) * Throttle is above deadband, FORWARD direction */ reversibleMotorsThrottleState = MOTOR_DIRECTION_FORWARD; - throttleRangeMax = motorConfig()->maxthrottle; + throttleRangeMax = getMaxThrottle(); throttleRangeMin = throttleDeadbandHigh; DISABLE_STATE(SET_REVERSIBLE_MOTORS_FORWARD); } else if (rcCommand[THROTTLE] <= throttleDeadbandLow) { @@ -591,7 +593,7 @@ void FAST_CODE mixTable(void) } else { mixerThrottleCommand = rcCommand[THROTTLE]; throttleRangeMin = throttleIdleValue; - throttleRangeMax = motorConfig()->maxthrottle; + throttleRangeMax = getMaxThrottle(); // Throttle scaling to limit max throttle when battery is full #ifdef USE_PROGRAMMING_FRAMEWORK @@ -630,7 +632,7 @@ void FAST_CODE mixTable(void) motor[i] = rpyMix[i] + constrain(mixerThrottleCommand * currentMixer[i].throttle, throttleMin, throttleMax); if (failsafeIsActive()) { - motor[i] = constrain(motor[i], motorConfig()->mincommand, motorConfig()->maxthrottle); + motor[i] = constrain(motor[i], motorConfig()->mincommand, getMaxThrottle()); } else { motor[i] = constrain(motor[i], throttleRangeMin, throttleRangeMax); } @@ -652,7 +654,7 @@ int16_t getThrottlePercent(bool useScaled) int16_t thr = constrain(mixerThrottleCommand, PWM_RANGE_MIN, PWM_RANGE_MAX); if (useScaled) { - thr = (thr - throttleIdleValue) * 100 / (motorConfig()->maxthrottle - throttleIdleValue); + thr = (thr - throttleIdleValue) * 100 / (getMaxThrottle() - throttleIdleValue); } else { thr = (rxGetChannelValue(THROTTLE) - PWM_RANGE_MIN) * 100 / (PWM_RANGE_MAX - PWM_RANGE_MIN); } @@ -667,7 +669,7 @@ uint16_t setDesiredThrottle(uint16_t throttle, bool allowMotorStop) ENABLE_STATE(NAV_MOTOR_STOP_OR_IDLE); return throttle; } - return constrain(throttle, throttleIdleValue, motorConfig()->maxthrottle); + return constrain(throttle, throttleIdleValue, getMaxThrottle()); } motorStatus_e getMotorStatus(void) @@ -725,3 +727,18 @@ bool areMotorsRunning(void) return false; } + +uint16_t getMaxThrottle() { + + static uint16_t throttle = 0; + + if (throttle == 0) { + if (STATE(ROVER) || STATE(BOAT)) { + throttle = MAX_THROTTLE_ROVER; + } else { + throttle = MAX_THROTTLE; + } + } + + return throttle; +} \ No newline at end of file diff --git a/src/main/flight/mixer.h b/src/main/flight/mixer.h index 9ee6a20654e..0d40fdc11ec 100644 --- a/src/main/flight/mixer.h +++ b/src/main/flight/mixer.h @@ -81,7 +81,6 @@ PG_DECLARE(reversibleMotorsConfig_t, reversibleMotorsConfig); typedef struct motorConfig_s { // PWM values, in milliseconds, common range is 1000-2000 (1ms to 2ms) - uint16_t maxthrottle; // This is the maximum value for the ESCs at full power this value can be increased up to 2000 uint16_t mincommand; // This is the value for the ESCs when they are not armed. In some cases, this value must be lowered down to 900 for some specific ESCs uint16_t motorPwmRate; // The update rate of motor outputs (50-498Hz) uint8_t motorPwmProtocol; @@ -130,4 +129,6 @@ void stopMotorsNoDelay(void); void stopPwmAllMotors(void); void loadPrimaryMotorMixer(void); -bool areMotorsRunning(void); \ No newline at end of file +bool areMotorsRunning(void); + +uint16_t getMaxThrottle(void); \ No newline at end of file diff --git a/src/main/flight/pid.c b/src/main/flight/pid.c index 3da150e39dc..6f296c54b5b 100644 --- a/src/main/flight/pid.c +++ b/src/main/flight/pid.c @@ -466,8 +466,8 @@ static float calculateMultirotorTPAFactor(void) // TPA should be updated only when TPA is actually set if (currentControlRateProfile->throttle.dynPID == 0 || rcCommand[THROTTLE] < currentControlRateProfile->throttle.pa_breakpoint) { tpaFactor = 1.0f; - } else if (rcCommand[THROTTLE] < motorConfig()->maxthrottle) { - tpaFactor = (100 - (uint16_t)currentControlRateProfile->throttle.dynPID * (rcCommand[THROTTLE] - currentControlRateProfile->throttle.pa_breakpoint) / (float)(motorConfig()->maxthrottle - currentControlRateProfile->throttle.pa_breakpoint)) / 100.0f; + } else if (rcCommand[THROTTLE] < getMaxThrottle()) { + tpaFactor = (100 - (uint16_t)currentControlRateProfile->throttle.dynPID * (rcCommand[THROTTLE] - currentControlRateProfile->throttle.pa_breakpoint) / (float)(getMaxThrottle() - currentControlRateProfile->throttle.pa_breakpoint)) / 100.0f; } else { tpaFactor = (100 - currentControlRateProfile->throttle.dynPID) / 100.0f; } diff --git a/src/main/navigation/navigation_fixedwing.c b/src/main/navigation/navigation_fixedwing.c index e6209f460b7..49fbf11ab5b 100755 --- a/src/main/navigation/navigation_fixedwing.c +++ b/src/main/navigation/navigation_fixedwing.c @@ -647,7 +647,7 @@ void applyFixedWingPitchRollThrottleController(navigationFSMStateFlags_t navStat if (rcCommand[THROTTLE] < PWM_RANGE_MIN + (PWM_RANGE_MAX - PWM_RANGE_MIN) * 0.95){ correctedThrottleValue += MAX(0, rcCommand[THROTTLE] - currentBatteryProfile->nav.fw.cruise_throttle); } else { - correctedThrottleValue = motorConfig()->maxthrottle; + correctedThrottleValue = getMaxThrottle(); } isAutoThrottleManuallyIncreased = (rcCommand[THROTTLE] > currentBatteryProfile->nav.fw.cruise_throttle); } else { diff --git a/src/main/navigation/navigation_multicopter.c b/src/main/navigation/navigation_multicopter.c index a9a6997a9f0..54caccb52b5 100644 --- a/src/main/navigation/navigation_multicopter.c +++ b/src/main/navigation/navigation_multicopter.c @@ -114,7 +114,7 @@ static void updateAltitudeThrottleController_MC(timeDelta_t deltaMicros) { // Calculate min and max throttle boundaries (to compensate for integral windup) const int16_t thrCorrectionMin = getThrottleIdleValue() - currentBatteryProfile->nav.mc.hover_throttle; - const int16_t thrCorrectionMax = motorConfig()->maxthrottle - currentBatteryProfile->nav.mc.hover_throttle; + const int16_t thrCorrectionMax = getMaxThrottle() - currentBatteryProfile->nav.mc.hover_throttle; float velocity_controller = navPidApply2(&posControl.pids.vel[Z], posControl.desiredState.vel.z, navGetCurrentActualPositionAndVelocity()->vel.z, US2S(deltaMicros), thrCorrectionMin, thrCorrectionMax, 0); @@ -127,7 +127,7 @@ static void updateAltitudeThrottleController_MC(timeDelta_t deltaMicros) bool adjustMulticopterAltitudeFromRCInput(void) { if (posControl.flags.isTerrainFollowEnabled) { - const float altTarget = scaleRangef(rcCommand[THROTTLE], getThrottleIdleValue(), motorConfig()->maxthrottle, 0, navConfig()->general.max_terrain_follow_altitude); + const float altTarget = scaleRangef(rcCommand[THROTTLE], getThrottleIdleValue(), getMaxThrottle(), 0, navConfig()->general.max_terrain_follow_altitude); // In terrain follow mode we apply different logic for terrain control if (posControl.flags.estAglStatus == EST_TRUSTED && altTarget > 10.0f) { @@ -151,7 +151,7 @@ bool adjustMulticopterAltitudeFromRCInput(void) // Make sure we can satisfy max_manual_climb_rate in both up and down directions if (rcThrottleAdjustment > 0) { // Scaling from altHoldThrottleRCZero to maxthrottle - rcClimbRate = rcThrottleAdjustment * navConfig()->mc.max_manual_climb_rate / (float)(motorConfig()->maxthrottle - altHoldThrottleRCZero - rcControlsConfig()->alt_hold_deadband); + rcClimbRate = rcThrottleAdjustment * navConfig()->mc.max_manual_climb_rate / (float)(getMaxThrottle() - altHoldThrottleRCZero - rcControlsConfig()->alt_hold_deadband); } else { // Scaling from minthrottle to altHoldThrottleRCZero @@ -190,7 +190,7 @@ void setupMulticopterAltitudeController(void) // Make sure we are able to satisfy the deadband altHoldThrottleRCZero = constrain(altHoldThrottleRCZero, getThrottleIdleValue() + rcControlsConfig()->alt_hold_deadband + 10, - motorConfig()->maxthrottle - rcControlsConfig()->alt_hold_deadband - 10); + getMaxThrottle() - rcControlsConfig()->alt_hold_deadband - 10); // Force AH controller to initialize althold integral for pending takeoff on reset // Signal for that is low throttle _and_ low actual altitude diff --git a/src/main/navigation/navigation_rover_boat.c b/src/main/navigation/navigation_rover_boat.c index 5f8134c6a24..8816880388a 100644 --- a/src/main/navigation/navigation_rover_boat.c +++ b/src/main/navigation/navigation_rover_boat.c @@ -127,7 +127,7 @@ void applyRoverBoatPitchRollThrottleController(navigationFSMStateFlags_t navStat rcCommand[YAW] = posControl.rcAdjustment[YAW]; } - rcCommand[THROTTLE] = constrain(currentBatteryProfile->nav.fw.cruise_throttle, motorConfig()->mincommand, motorConfig()->maxthrottle); + rcCommand[THROTTLE] = constrain(currentBatteryProfile->nav.fw.cruise_throttle, motorConfig()->mincommand, getMaxThrottle()); } } } diff --git a/src/main/target/ASGARD32F4/config.c b/src/main/target/ASGARD32F4/config.c index 9aaa2793ce3..fee09920388 100644 --- a/src/main/target/ASGARD32F4/config.c +++ b/src/main/target/ASGARD32F4/config.c @@ -36,5 +36,4 @@ void targetConfiguration(void) { serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(TELEMETRY_UART)].functionMask = FUNCTION_TELEMETRY_SMARTPORT; motorConfigMutable()->motorPwmProtocol = PWM_TYPE_MULTISHOT; - motorConfigMutable()->maxthrottle = 1950; } diff --git a/src/main/target/ASGARD32F7/config.c b/src/main/target/ASGARD32F7/config.c index 9aaa2793ce3..fee09920388 100644 --- a/src/main/target/ASGARD32F7/config.c +++ b/src/main/target/ASGARD32F7/config.c @@ -36,5 +36,4 @@ void targetConfiguration(void) { serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(TELEMETRY_UART)].functionMask = FUNCTION_TELEMETRY_SMARTPORT; motorConfigMutable()->motorPwmProtocol = PWM_TYPE_MULTISHOT; - motorConfigMutable()->maxthrottle = 1950; } From 8b34f38ba2a27b04054cf246c649e05104c5a0b9 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Tue, 9 Apr 2024 20:56:57 +0200 Subject: [PATCH 161/241] Docs update --- docs/Settings.md | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/docs/Settings.md b/docs/Settings.md index b6fd431d950..1b34bddb720 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -2372,16 +2372,6 @@ These are min/max values (in us) which, when a channel is smaller (min) or large --- -### max_throttle - -This is the maximum value (in us) sent to esc when armed. Default of 1850 are OK for everyone (legacy). For modern ESCs, higher values (c. 2000) may be more appropriate. If you have brushed motors, the value should be set to 2000. - -| Default | Min | Max | -| --- | --- | --- | -| 1850 | PWM_RANGE_MIN | PWM_RANGE_MAX | - ---- - ### mc_cd_lpf_hz Cutoff frequency for Control Derivative. This controls the cutoff for the LPF that is applied to the CD (Feed Forward) signal to the PID controller. Lower value will produce a smoother CD gain to the controller, but it will be more delayed. Higher values will produce CD gain that may have more noise in the signal depending on your RC link but wil be less delayed. From 755b312dabfafbed5a5df029f65e7c2f7ba6cf81 Mon Sep 17 00:00:00 2001 From: YI-BOYANG <46438966+YI-BOYANG@users.noreply.github.com> Date: Wed, 10 Apr 2024 10:45:02 +0800 Subject: [PATCH 162/241] Add TAKERF722SE target --- src/main/target/TAKERF722SE/CMakeLists.txt | 1 + src/main/target/TAKERF722SE/target.c | 48 ++++++ src/main/target/TAKERF722SE/target.h | 186 +++++++++++++++++++++ 3 files changed, 235 insertions(+) create mode 100644 src/main/target/TAKERF722SE/CMakeLists.txt create mode 100644 src/main/target/TAKERF722SE/target.c create mode 100644 src/main/target/TAKERF722SE/target.h diff --git a/src/main/target/TAKERF722SE/CMakeLists.txt b/src/main/target/TAKERF722SE/CMakeLists.txt new file mode 100644 index 00000000000..c4716f616ee --- /dev/null +++ b/src/main/target/TAKERF722SE/CMakeLists.txt @@ -0,0 +1 @@ +target_stm32f722xe(TAKERF722SE) \ No newline at end of file diff --git a/src/main/target/TAKERF722SE/target.c b/src/main/target/TAKERF722SE/target.c new file mode 100644 index 00000000000..247efb84e52 --- /dev/null +++ b/src/main/target/TAKERF722SE/target.c @@ -0,0 +1,48 @@ +/* +* This file is part of INAV Project. +* +* INAV 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. +* +* INAV 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 INAV. If not, see . +*/ + +#include + +#include "platform.h" +#include "drivers/io.h" + +#include "drivers/dma.h" +#include "drivers/timer.h" +#include "drivers/timer_def.h" + + + + + +timerHardware_t timerHardware[] = { + + DEF_TIM(TIM3, CH1, PB4, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM3, CH2, PB5, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM3, CH3, PB0, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 0), + + DEF_TIM(TIM4, CH1, PB6, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM4, CH2, PB7, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM8, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM8, CH4, PC9, TIM_USE_OUTPUT_AUTO, 0, 0), + + DEF_TIM(TIM1, CH1, PA8, TIM_USE_LED, 0, 0), +}; + +const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]); + + diff --git a/src/main/target/TAKERF722SE/target.h b/src/main/target/TAKERF722SE/target.h new file mode 100644 index 00000000000..61ab442653d --- /dev/null +++ b/src/main/target/TAKERF722SE/target.h @@ -0,0 +1,186 @@ +/* + * This file is part of INAV Project. + * + * 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. + * + * INAV 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 INAV. If not, see . + */ + +#pragma once + +#define TARGET_BOARD_IDENTIFIER "GEPR" + +#define USBD_PRODUCT_STRING "TAKERF722SE" + +#define LED0 PC14 + + +// *************** BEEPER ************************ + +#define BEEPER PC13 +#define BEEPER_INVERTED + + +// *************** LEDSTRIP ************************ +#define USE_LED_STRIP +#define WS2811_PIN PA8 + + +// *************** UART ***************************** +#define USE_VCP + +#define USE_UART1 +#define UART1_TX_PIN PA9 +#define UART1_RX_PIN PA10 + +#define USE_UART2 +#define UART2_TX_PIN PA2 +#define UART2_RX_PIN PA3 + +#define USE_UART3 +#define UART3_TX_PIN PB10 +#define UART3_RX_PIN PB11 + +#define USE_UART4 +#define UART4_TX_PIN PA0 +#define UART4_RX_PIN PA1 + +#define USE_UART5 +#define UART5_TX_PIN PC12 +#define UART5_RX_PIN PD2 + +#define USE_UART6 +#define UART6_TX_PIN PC6 +#define UART6_RX_PIN PC7 + + +#define SERIAL_PORT_COUNT 7 + +#define DEFAULT_RX_TYPE RX_TYPE_SERIAL +#define SERIALRX_PROVIDER SERIALRX_SBUS +#define SERIALRX_UART SERIAL_PORT_USART2 + + +// *************** SPI Bus ********************** + +#define USE_SPI + +#define USE_SPI_DEVICE_1 +#define SPI1_SCK_PIN PA5 +#define SPI1_MISO_PIN PA6 +#define SPI1_MOSI_PIN PA7 + +#define USE_SPI_DEVICE_2 +#define SPI2_SCK_PIN PB13 +#define SPI2_MISO_PIN PB14 +#define SPI2_MOSI_PIN PB15 + +#define USE_SPI_DEVICE_3 +#define SPI3_SCK_PIN PC10 +#define SPI3_MISO_PIN PC11 +#define SPI3_MOSI_PIN PB2 +#define SPI3_SCK_AF GPIO_AF6_SPI3 +#define SPI3_MISO_AF GPIO_AF6_SPI3 +#define SPI3_MOSI_AF GPIO_AF7_SPI3 + + +// *************** Gyro & ACC ********************** + +#define USE_IMU_MPU6000 +#define IMU_MPU6000_ALIGN CW0_DEG +#define MPU6000_CS_PIN PA4 +#define MPU6000_SPI_BUS BUS_SPI1 + + +#define USE_IMU_ICM42605 +#define IMU_ICM42605_ALIGN CW0_DEG +#define ICM42605_CS_PIN PA4 +#define ICM42605_SPI_BUS BUS_SPI1 + +// *************** I2C/Baro/Mag ********************* +#define USE_I2C +#define USE_I2C_DEVICE_1 +#define I2C1_SCL PB8 +#define I2C1_SDA PB9 + + +//*************************************************** +#define USE_BARO +#define BARO_I2C_BUS BUS_I2C1 +#define USE_BARO_BMP280 +#define USE_BARO_DPS310 +#define USE_BARO_MS5611 + +#define USE_MAG +#define MAG_I2C_BUS BUS_I2C1 +#define USE_MAG_HMC5883 +#define USE_MAG_QMC5883 +#define USE_MAG_IST8310 +#define USE_MAG_IST8308 + +#define TEMPERATURE_I2C_BUS BUS_I2C1 + +#define PITOT_I2C_BUS BUS_I2C1 + +#define USE_RANGEFINDER +#define RANGEFINDER_I2C_BUS BUS_I2C1 +#define BNO055_I2C_BUS BUS_I2C1 + +// *************** FLASH ************************** + +#define USE_FLASHFS + +#define USE_FLASH_M25P16 +#define M25P16_CS_PIN PA15 +#define M25P16_SPI_BUS BUS_SPI3 + +#define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT + +// *************** OSD ***************************** + +#define USE_MAX7456 +#define MAX7456_SPI_BUS BUS_SPI2 +#define MAX7456_CS_PIN PB12 + +// *************** ADC ***************************** + +#define USE_ADC +#define ADC_INSTANCE ADC1 +#define ADC1_DMA_STREAM DMA2_Stream0 +#define ADC_CHANNEL_1_PIN PC3 +#define ADC_CHANNEL_2_PIN PC0 +#define ADC_CHANNEL_3_PIN PC2 + +#define VBAT_ADC_CHANNEL ADC_CHN_1 +#define RSSI_ADC_CHANNEL ADC_CHN_2 +#define CURRENT_METER_ADC_CHANNEL ADC_CHN_3 + + +#define DEFAULT_FEATURES (FEATURE_TX_PROF_SEL | FEATURE_CURRENT_METER | FEATURE_TELEMETRY | FEATURE_VBAT | FEATURE_OSD | FEATURE_BLACKBOX) + + + + +//************************************************** + +#define USE_SERIAL_4WAY_BLHELI_INTERFACE + +#define TARGET_IO_PORTA 0xffff +#define TARGET_IO_PORTB 0xffff +#define TARGET_IO_PORTC 0xffff +#define TARGET_IO_PORTD (BIT(2)) + + +#define MAX_PWM_OUTPUT_PORTS 8 + +#define USE_DSHOT +#define USE_ESC_SENSOR From b79dea677c9e83f115ff5f2b59793799ba6624c1 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Wed, 10 Apr 2024 14:20:11 +0200 Subject: [PATCH 163/241] fix formatting --- src/main/target/TAKERF722SE/target.c | 96 +++---- src/main/target/TAKERF722SE/target.h | 372 +++++++++++++-------------- 2 files changed, 234 insertions(+), 234 deletions(-) diff --git a/src/main/target/TAKERF722SE/target.c b/src/main/target/TAKERF722SE/target.c index 247efb84e52..d67062a9fbc 100644 --- a/src/main/target/TAKERF722SE/target.c +++ b/src/main/target/TAKERF722SE/target.c @@ -1,48 +1,48 @@ -/* -* This file is part of INAV Project. -* -* INAV 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. -* -* INAV 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 INAV. If not, see . -*/ - -#include - -#include "platform.h" -#include "drivers/io.h" - -#include "drivers/dma.h" -#include "drivers/timer.h" -#include "drivers/timer_def.h" - - - - - -timerHardware_t timerHardware[] = { - - DEF_TIM(TIM3, CH1, PB4, TIM_USE_OUTPUT_AUTO, 0, 0), - DEF_TIM(TIM3, CH2, PB5, TIM_USE_OUTPUT_AUTO, 0, 0), - DEF_TIM(TIM3, CH3, PB0, TIM_USE_OUTPUT_AUTO, 0, 0), - DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 0), - - DEF_TIM(TIM4, CH1, PB6, TIM_USE_OUTPUT_AUTO, 0, 0), - DEF_TIM(TIM4, CH2, PB7, TIM_USE_OUTPUT_AUTO, 0, 0), - DEF_TIM(TIM8, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 0), - DEF_TIM(TIM8, CH4, PC9, TIM_USE_OUTPUT_AUTO, 0, 0), - - DEF_TIM(TIM1, CH1, PA8, TIM_USE_LED, 0, 0), -}; - -const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]); - - +/* +* This file is part of INAV Project. +* +* INAV 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. +* +* INAV 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 INAV. If not, see . +*/ + +#include + +#include "platform.h" +#include "drivers/io.h" + +#include "drivers/dma.h" +#include "drivers/timer.h" +#include "drivers/timer_def.h" + + + + + +timerHardware_t timerHardware[] = { + + DEF_TIM(TIM3, CH1, PB4, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM3, CH2, PB5, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM3, CH3, PB0, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 0), + + DEF_TIM(TIM4, CH1, PB6, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM4, CH2, PB7, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM8, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM8, CH4, PC9, TIM_USE_OUTPUT_AUTO, 0, 0), + + DEF_TIM(TIM1, CH1, PA8, TIM_USE_LED, 0, 0), +}; + +const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]); + + diff --git a/src/main/target/TAKERF722SE/target.h b/src/main/target/TAKERF722SE/target.h index 61ab442653d..817dc535f03 100644 --- a/src/main/target/TAKERF722SE/target.h +++ b/src/main/target/TAKERF722SE/target.h @@ -1,186 +1,186 @@ -/* - * This file is part of INAV Project. - * - * 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. - * - * INAV 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 INAV. If not, see . - */ - -#pragma once - -#define TARGET_BOARD_IDENTIFIER "GEPR" - -#define USBD_PRODUCT_STRING "TAKERF722SE" - -#define LED0 PC14 - - -// *************** BEEPER ************************ - -#define BEEPER PC13 -#define BEEPER_INVERTED - - -// *************** LEDSTRIP ************************ -#define USE_LED_STRIP -#define WS2811_PIN PA8 - - -// *************** UART ***************************** -#define USE_VCP - -#define USE_UART1 -#define UART1_TX_PIN PA9 -#define UART1_RX_PIN PA10 - -#define USE_UART2 -#define UART2_TX_PIN PA2 -#define UART2_RX_PIN PA3 - -#define USE_UART3 -#define UART3_TX_PIN PB10 -#define UART3_RX_PIN PB11 - -#define USE_UART4 -#define UART4_TX_PIN PA0 -#define UART4_RX_PIN PA1 - -#define USE_UART5 -#define UART5_TX_PIN PC12 -#define UART5_RX_PIN PD2 - -#define USE_UART6 -#define UART6_TX_PIN PC6 -#define UART6_RX_PIN PC7 - - -#define SERIAL_PORT_COUNT 7 - -#define DEFAULT_RX_TYPE RX_TYPE_SERIAL -#define SERIALRX_PROVIDER SERIALRX_SBUS -#define SERIALRX_UART SERIAL_PORT_USART2 - - -// *************** SPI Bus ********************** - -#define USE_SPI - -#define USE_SPI_DEVICE_1 -#define SPI1_SCK_PIN PA5 -#define SPI1_MISO_PIN PA6 -#define SPI1_MOSI_PIN PA7 - -#define USE_SPI_DEVICE_2 -#define SPI2_SCK_PIN PB13 -#define SPI2_MISO_PIN PB14 -#define SPI2_MOSI_PIN PB15 - -#define USE_SPI_DEVICE_3 -#define SPI3_SCK_PIN PC10 -#define SPI3_MISO_PIN PC11 -#define SPI3_MOSI_PIN PB2 -#define SPI3_SCK_AF GPIO_AF6_SPI3 -#define SPI3_MISO_AF GPIO_AF6_SPI3 -#define SPI3_MOSI_AF GPIO_AF7_SPI3 - - -// *************** Gyro & ACC ********************** - -#define USE_IMU_MPU6000 -#define IMU_MPU6000_ALIGN CW0_DEG -#define MPU6000_CS_PIN PA4 -#define MPU6000_SPI_BUS BUS_SPI1 - - -#define USE_IMU_ICM42605 -#define IMU_ICM42605_ALIGN CW0_DEG -#define ICM42605_CS_PIN PA4 -#define ICM42605_SPI_BUS BUS_SPI1 - -// *************** I2C/Baro/Mag ********************* -#define USE_I2C -#define USE_I2C_DEVICE_1 -#define I2C1_SCL PB8 -#define I2C1_SDA PB9 - - -//*************************************************** -#define USE_BARO -#define BARO_I2C_BUS BUS_I2C1 -#define USE_BARO_BMP280 -#define USE_BARO_DPS310 -#define USE_BARO_MS5611 - -#define USE_MAG -#define MAG_I2C_BUS BUS_I2C1 -#define USE_MAG_HMC5883 -#define USE_MAG_QMC5883 -#define USE_MAG_IST8310 -#define USE_MAG_IST8308 - -#define TEMPERATURE_I2C_BUS BUS_I2C1 - -#define PITOT_I2C_BUS BUS_I2C1 - -#define USE_RANGEFINDER -#define RANGEFINDER_I2C_BUS BUS_I2C1 -#define BNO055_I2C_BUS BUS_I2C1 - -// *************** FLASH ************************** - -#define USE_FLASHFS - -#define USE_FLASH_M25P16 -#define M25P16_CS_PIN PA15 -#define M25P16_SPI_BUS BUS_SPI3 - -#define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT - -// *************** OSD ***************************** - -#define USE_MAX7456 -#define MAX7456_SPI_BUS BUS_SPI2 -#define MAX7456_CS_PIN PB12 - -// *************** ADC ***************************** - -#define USE_ADC -#define ADC_INSTANCE ADC1 -#define ADC1_DMA_STREAM DMA2_Stream0 -#define ADC_CHANNEL_1_PIN PC3 -#define ADC_CHANNEL_2_PIN PC0 -#define ADC_CHANNEL_3_PIN PC2 - -#define VBAT_ADC_CHANNEL ADC_CHN_1 -#define RSSI_ADC_CHANNEL ADC_CHN_2 -#define CURRENT_METER_ADC_CHANNEL ADC_CHN_3 - - -#define DEFAULT_FEATURES (FEATURE_TX_PROF_SEL | FEATURE_CURRENT_METER | FEATURE_TELEMETRY | FEATURE_VBAT | FEATURE_OSD | FEATURE_BLACKBOX) - - - - -//************************************************** - -#define USE_SERIAL_4WAY_BLHELI_INTERFACE - -#define TARGET_IO_PORTA 0xffff -#define TARGET_IO_PORTB 0xffff -#define TARGET_IO_PORTC 0xffff -#define TARGET_IO_PORTD (BIT(2)) - - -#define MAX_PWM_OUTPUT_PORTS 8 - -#define USE_DSHOT -#define USE_ESC_SENSOR +/* + * This file is part of INAV Project. + * + * 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. + * + * INAV 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 INAV. If not, see . + */ + +#pragma once + +#define TARGET_BOARD_IDENTIFIER "GEPR" + +#define USBD_PRODUCT_STRING "TAKERF722SE" + +#define LED0 PC14 + + +// *************** BEEPER ************************ + +#define BEEPER PC13 +#define BEEPER_INVERTED + + +// *************** LEDSTRIP ************************ +#define USE_LED_STRIP +#define WS2811_PIN PA8 + + +// *************** UART ***************************** +#define USE_VCP + +#define USE_UART1 +#define UART1_TX_PIN PA9 +#define UART1_RX_PIN PA10 + +#define USE_UART2 +#define UART2_TX_PIN PA2 +#define UART2_RX_PIN PA3 + +#define USE_UART3 +#define UART3_TX_PIN PB10 +#define UART3_RX_PIN PB11 + +#define USE_UART4 +#define UART4_TX_PIN PA0 +#define UART4_RX_PIN PA1 + +#define USE_UART5 +#define UART5_TX_PIN PC12 +#define UART5_RX_PIN PD2 + +#define USE_UART6 +#define UART6_TX_PIN PC6 +#define UART6_RX_PIN PC7 + + +#define SERIAL_PORT_COUNT 7 + +#define DEFAULT_RX_TYPE RX_TYPE_SERIAL +#define SERIALRX_PROVIDER SERIALRX_SBUS +#define SERIALRX_UART SERIAL_PORT_USART2 + + +// *************** SPI Bus ********************** + +#define USE_SPI + +#define USE_SPI_DEVICE_1 +#define SPI1_SCK_PIN PA5 +#define SPI1_MISO_PIN PA6 +#define SPI1_MOSI_PIN PA7 + +#define USE_SPI_DEVICE_2 +#define SPI2_SCK_PIN PB13 +#define SPI2_MISO_PIN PB14 +#define SPI2_MOSI_PIN PB15 + +#define USE_SPI_DEVICE_3 +#define SPI3_SCK_PIN PC10 +#define SPI3_MISO_PIN PC11 +#define SPI3_MOSI_PIN PB2 +#define SPI3_SCK_AF GPIO_AF6_SPI3 +#define SPI3_MISO_AF GPIO_AF6_SPI3 +#define SPI3_MOSI_AF GPIO_AF7_SPI3 + + +// *************** Gyro & ACC ********************** + +#define USE_IMU_MPU6000 +#define IMU_MPU6000_ALIGN CW0_DEG +#define MPU6000_CS_PIN PA4 +#define MPU6000_SPI_BUS BUS_SPI1 + + +#define USE_IMU_ICM42605 +#define IMU_ICM42605_ALIGN CW0_DEG +#define ICM42605_CS_PIN PA4 +#define ICM42605_SPI_BUS BUS_SPI1 + +// *************** I2C/Baro/Mag ********************* +#define USE_I2C +#define USE_I2C_DEVICE_1 +#define I2C1_SCL PB8 +#define I2C1_SDA PB9 + + +//*************************************************** +#define USE_BARO +#define BARO_I2C_BUS BUS_I2C1 +#define USE_BARO_BMP280 +#define USE_BARO_DPS310 +#define USE_BARO_MS5611 + +#define USE_MAG +#define MAG_I2C_BUS BUS_I2C1 +#define USE_MAG_HMC5883 +#define USE_MAG_QMC5883 +#define USE_MAG_IST8310 +#define USE_MAG_IST8308 + +#define TEMPERATURE_I2C_BUS BUS_I2C1 + +#define PITOT_I2C_BUS BUS_I2C1 + +#define USE_RANGEFINDER +#define RANGEFINDER_I2C_BUS BUS_I2C1 +#define BNO055_I2C_BUS BUS_I2C1 + +// *************** FLASH ************************** + +#define USE_FLASHFS + +#define USE_FLASH_M25P16 +#define M25P16_CS_PIN PA15 +#define M25P16_SPI_BUS BUS_SPI3 + +#define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT + +// *************** OSD ***************************** + +#define USE_MAX7456 +#define MAX7456_SPI_BUS BUS_SPI2 +#define MAX7456_CS_PIN PB12 + +// *************** ADC ***************************** + +#define USE_ADC +#define ADC_INSTANCE ADC1 +#define ADC1_DMA_STREAM DMA2_Stream0 +#define ADC_CHANNEL_1_PIN PC3 +#define ADC_CHANNEL_2_PIN PC0 +#define ADC_CHANNEL_3_PIN PC2 + +#define VBAT_ADC_CHANNEL ADC_CHN_1 +#define RSSI_ADC_CHANNEL ADC_CHN_2 +#define CURRENT_METER_ADC_CHANNEL ADC_CHN_3 + + +#define DEFAULT_FEATURES (FEATURE_TX_PROF_SEL | FEATURE_CURRENT_METER | FEATURE_TELEMETRY | FEATURE_VBAT | FEATURE_OSD | FEATURE_BLACKBOX) + + + + +//************************************************** + +#define USE_SERIAL_4WAY_BLHELI_INTERFACE + +#define TARGET_IO_PORTA 0xffff +#define TARGET_IO_PORTB 0xffff +#define TARGET_IO_PORTC 0xffff +#define TARGET_IO_PORTD (BIT(2)) + + +#define MAX_PWM_OUTPUT_PORTS 8 + +#define USE_DSHOT +#define USE_ESC_SENSOR From 25c545220926c6b09a6c62471a72a0b451295893 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Wed, 10 Apr 2024 16:25:02 +0200 Subject: [PATCH 164/241] Drop MSP_MOTOR_PINS --- src/main/fc/fc_msp.c | 7 ------- src/main/msp/msp_protocol.h | 1 - 2 files changed, 8 deletions(-) diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index cba93fb59cf..f53523b24e8 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -859,13 +859,6 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF sbufWriteU8(dst, currentBatteryProfile->capacity.unit); break; - case MSP_MOTOR_PINS: - // FIXME This is hardcoded and should not be. - for (int i = 0; i < 8; i++) { - sbufWriteU8(dst, i + 1); - } - break; - #ifdef USE_GPS case MSP_RAW_GPS: sbufWriteU8(dst, gpsSol.fixType); diff --git a/src/main/msp/msp_protocol.h b/src/main/msp/msp_protocol.h index 692f8fbffa8..f8eb7ef01b5 100644 --- a/src/main/msp/msp_protocol.h +++ b/src/main/msp/msp_protocol.h @@ -233,7 +233,6 @@ #define MSP_RC_TUNING 111 //out message rc rate, rc expo, rollpitch rate, yaw rate, dyn throttle PID #define MSP_ACTIVEBOXES 113 //out message Active box flags (full width, more than 32 bits) #define MSP_MISC 114 //out message powermeter trig -#define MSP_MOTOR_PINS 115 //out message which pins are in use for motors & servos, for GUI #define MSP_BOXNAMES 116 //out message the aux switch names #define MSP_WP 118 //out message get a WP, WP# is in the payload, returns (WP#, lat, lon, alt, flags) WP#0-home, WP#16-poshold #define MSP_BOXIDS 119 //out message get the permanent IDs associated to BOXes From 77fac1a3c1ad3a223c629b0235b6d65cd40b3f03 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Wed, 10 Apr 2024 20:30:56 +0200 Subject: [PATCH 165/241] Revert "Merge pull request #9903 from iNavFlight/dzikuvx-drop-MSP_FILTER_CONFIG" This reverts commit 0d21b3d71daf17221ced2b8e8ef078ec9cbc1b86, reversing changes made to b5d5f4ca6e3909a58d5dd8ffdf8774d55380044b. --- src/main/fc/fc_msp.c | 59 +++++++++++++++++++++++++++++++++++++ src/main/msp/msp_protocol.h | 3 ++ 2 files changed, 62 insertions(+) diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index f53523b24e8..893e0576457 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -1193,6 +1193,24 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF sbufWriteU8(dst, 0); break; + case MSP_FILTER_CONFIG : + sbufWriteU8(dst, gyroConfig()->gyro_main_lpf_hz); + sbufWriteU16(dst, pidProfile()->dterm_lpf_hz); + sbufWriteU16(dst, pidProfile()->yaw_lpf_hz); + sbufWriteU16(dst, 0); //Was gyroConfig()->gyro_notch_hz + sbufWriteU16(dst, 1); //Was gyroConfig()->gyro_notch_cutoff + sbufWriteU16(dst, 0); //BF: pidProfile()->dterm_notch_hz + sbufWriteU16(dst, 1); //pidProfile()->dterm_notch_cutoff + + sbufWriteU16(dst, 0); //BF: masterConfig.gyro_soft_notch_hz_2 + sbufWriteU16(dst, 1); //BF: masterConfig.gyro_soft_notch_cutoff_2 + + sbufWriteU16(dst, accelerometerConfig()->acc_notch_hz); + sbufWriteU16(dst, accelerometerConfig()->acc_notch_cutoff); + + sbufWriteU16(dst, 0); //Was gyroConfig()->gyro_stage2_lowpass_hz + break; + case MSP_INAV_PID: sbufWriteU8(dst, 0); //Legacy, no longer in use async processing value sbufWriteU16(dst, 0); //Legacy, no longer in use async processing value @@ -2138,6 +2156,47 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) return MSP_RESULT_ERROR; break; + case MSP_SET_FILTER_CONFIG : + if (dataSize >= 5) { + gyroConfigMutable()->gyro_main_lpf_hz = sbufReadU8(src); + pidProfileMutable()->dterm_lpf_hz = constrain(sbufReadU16(src), 0, 500); + pidProfileMutable()->yaw_lpf_hz = constrain(sbufReadU16(src), 0, 255); + if (dataSize >= 9) { + sbufReadU16(src); //Was gyroConfigMutable()->gyro_notch_hz + sbufReadU16(src); //Was gyroConfigMutable()->gyro_notch_cutoff + } else { + return MSP_RESULT_ERROR; + } + if (dataSize >= 13) { + sbufReadU16(src); + sbufReadU16(src); + pidInitFilters(); + } else { + return MSP_RESULT_ERROR; + } + if (dataSize >= 17) { + sbufReadU16(src); // Was gyroConfigMutable()->gyro_soft_notch_hz_2 + sbufReadU16(src); // Was gyroConfigMutable()->gyro_soft_notch_cutoff_2 + } else { + return MSP_RESULT_ERROR; + } + + if (dataSize >= 21) { + accelerometerConfigMutable()->acc_notch_hz = constrain(sbufReadU16(src), 0, 255); + accelerometerConfigMutable()->acc_notch_cutoff = constrain(sbufReadU16(src), 1, 255); + } else { + return MSP_RESULT_ERROR; + } + + if (dataSize >= 22) { + sbufReadU16(src); //Was gyro_stage2_lowpass_hz + } else { + return MSP_RESULT_ERROR; + } + } else + return MSP_RESULT_ERROR; + break; + case MSP_SET_INAV_PID: if (dataSize == 15) { sbufReadU8(src); //Legacy, no longer in use async processing value diff --git a/src/main/msp/msp_protocol.h b/src/main/msp/msp_protocol.h index f8eb7ef01b5..a983d0bc468 100644 --- a/src/main/msp/msp_protocol.h +++ b/src/main/msp/msp_protocol.h @@ -196,6 +196,9 @@ #define MSP_ADVANCED_CONFIG 90 #define MSP_SET_ADVANCED_CONFIG 91 +#define MSP_FILTER_CONFIG 92 +#define MSP_SET_FILTER_CONFIG 93 + #define MSP_SENSOR_CONFIG 96 #define MSP_SET_SENSOR_CONFIG 97 From 7204413a291e3eebb09b7573fd6fc0ccd1441159 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Wed, 10 Apr 2024 20:36:11 +0200 Subject: [PATCH 166/241] Revert "Merge pull request #9865 from iNavFlight/dzikuvx-drop-msp-osd-config" This reverts commit a8de611b1a30917ac61023bfb11169f7c57c232f, reversing changes made to 05e7a31f562839c553bdc68de81e0a1e4312633c. --- src/main/fc/fc_msp.c | 50 +++++++++++++++++++++++++++++++++++++ src/main/msp/msp_protocol.h | 3 +++ 2 files changed, 53 insertions(+) diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index 893e0576457..9dccbf09250 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -1155,6 +1155,26 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF break; #endif + case MSP_OSD_CONFIG: +#ifdef USE_OSD + sbufWriteU8(dst, OSD_DRIVER_MAX7456); // OSD supported + // send video system (AUTO/PAL/NTSC) + sbufWriteU8(dst, osdConfig()->video_system); + sbufWriteU8(dst, osdConfig()->units); + sbufWriteU8(dst, osdConfig()->rssi_alarm); + sbufWriteU16(dst, currentBatteryProfile->capacity.warning); + sbufWriteU16(dst, osdConfig()->time_alarm); + sbufWriteU16(dst, osdConfig()->alt_alarm); + sbufWriteU16(dst, osdConfig()->dist_alarm); + sbufWriteU16(dst, osdConfig()->neg_alt_alarm); + for (int i = 0; i < OSD_ITEM_COUNT; i++) { + sbufWriteU16(dst, osdLayoutsConfig()->item_pos[0][i]); + } +#else + sbufWriteU8(dst, OSD_DRIVER_NONE); // OSD not supported +#endif + break; + case MSP_3D: sbufWriteU16(dst, reversibleMotorsConfig()->deadband_low); sbufWriteU16(dst, reversibleMotorsConfig()->deadband_high); @@ -2396,6 +2416,36 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) #endif #ifdef USE_OSD + case MSP_SET_OSD_CONFIG: + sbufReadU8Safe(&tmp_u8, src); + // set all the other settings + if ((int8_t)tmp_u8 == -1) { + if (dataSize >= 10) { + osdConfigMutable()->video_system = sbufReadU8(src); + osdConfigMutable()->units = sbufReadU8(src); + osdConfigMutable()->rssi_alarm = sbufReadU8(src); + currentBatteryProfileMutable->capacity.warning = sbufReadU16(src); + osdConfigMutable()->time_alarm = sbufReadU16(src); + osdConfigMutable()->alt_alarm = sbufReadU16(src); + // Won't be read if they weren't provided + sbufReadU16Safe(&osdConfigMutable()->dist_alarm, src); + sbufReadU16Safe(&osdConfigMutable()->neg_alt_alarm, src); + } else + return MSP_RESULT_ERROR; + } else { + // set a position setting + if ((dataSize >= 3) && (tmp_u8 < OSD_ITEM_COUNT)) // tmp_u8 == addr + osdLayoutsConfigMutable()->item_pos[0][tmp_u8] = sbufReadU16(src); + else + return MSP_RESULT_ERROR; + } + // Either a element position change or a units change needs + // a full redraw, since an element can change size significantly + // and the old position or the now unused space due to the + // size change need to be erased. + osdStartFullRedraw(); + break; + case MSP_OSD_CHAR_WRITE: if (dataSize >= 55) { osdCharacter_t chr; diff --git a/src/main/msp/msp_protocol.h b/src/main/msp/msp_protocol.h index a983d0bc468..2ee996dc385 100644 --- a/src/main/msp/msp_protocol.h +++ b/src/main/msp/msp_protocol.h @@ -186,6 +186,9 @@ #define MSP_TRANSPONDER_CONFIG 82 //out message Get transponder settings #define MSP_SET_TRANSPONDER_CONFIG 83 //in message Set transponder settings +#define MSP_OSD_CONFIG 84 //out message Get osd settings - betaflight +#define MSP_SET_OSD_CONFIG 85 //in message Set osd settings - betaflight + #define MSP_OSD_CHAR_READ 86 //out message Get osd settings - betaflight #define MSP_OSD_CHAR_WRITE 87 //in message Set osd settings - betaflight From 225a8efe323096498f818caa3849e02bc0ba3483 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Wed, 10 Apr 2024 20:39:47 +0200 Subject: [PATCH 167/241] Revert "Merge pull request #9900 from iNavFlight/dzikuvx-drop-MSP_PIDNAMES" This reverts commit e5ab1e16bae1077d34aaf64904ea2bc9890e33ad, reversing changes made to 2bd253393a7458b8d072c31ccda588e4502fc950. --- src/main/fc/fc_msp.c | 18 ++++++++++++++++++ src/main/msp/msp_protocol.h | 1 + 2 files changed, 19 insertions(+) diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index 9dccbf09250..e8697cae34e 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -140,6 +140,18 @@ static const char * const boardIdentifier = TARGET_BOARD_IDENTIFIER; // from mixer.c extern int16_t motor_disarmed[MAX_SUPPORTED_MOTORS]; +static const char pidnames[] = + "ROLL;" + "PITCH;" + "YAW;" + "ALT;" + "Pos;" + "PosR;" + "NavR;" + "LEVEL;" + "MAG;" + "VEL;"; + typedef enum { MSP_SDCARD_STATE_NOT_PRESENT = 0, MSP_SDCARD_STATE_FATAL = 1, @@ -696,6 +708,12 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF #endif break; + case MSP_PIDNAMES: + for (const char *c = pidnames; *c; c++) { + sbufWriteU8(dst, *c); + } + break; + case MSP_MODE_RANGES: for (int i = 0; i < MAX_MODE_ACTIVATION_CONDITION_COUNT; i++) { const modeActivationCondition_t *mac = modeActivationConditions(i); diff --git a/src/main/msp/msp_protocol.h b/src/main/msp/msp_protocol.h index 2ee996dc385..5d7a0fbd8be 100644 --- a/src/main/msp/msp_protocol.h +++ b/src/main/msp/msp_protocol.h @@ -240,6 +240,7 @@ #define MSP_ACTIVEBOXES 113 //out message Active box flags (full width, more than 32 bits) #define MSP_MISC 114 //out message powermeter trig #define MSP_BOXNAMES 116 //out message the aux switch names +#define MSP_PIDNAMES 117 //out message the PID names #define MSP_WP 118 //out message get a WP, WP# is in the payload, returns (WP#, lat, lon, alt, flags) WP#0-home, WP#16-poshold #define MSP_BOXIDS 119 //out message get the permanent IDs associated to BOXes #define MSP_NAV_STATUS 121 //out message Returns navigation status From 2d20132ecbe118315935d09fe6d78814159b7a83 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Wed, 10 Apr 2024 20:44:01 +0200 Subject: [PATCH 168/241] Revert "Merge pull request #9873 from iNavFlight/dzikuvx-new-msp-frames-for-servos" This reverts commit f7bda375d2ea89316b171758d60679073328de68, reversing changes made to a8de611b1a30917ac61023bfb11169f7c57c232f. --- src/main/fc/fc_msp.c | 41 +++++++++++++++++++++++---- src/main/msp/msp_protocol.h | 4 +++ src/main/msp/msp_protocol_v2_common.h | 1 + src/main/msp/msp_protocol_v2_inav.h | 2 -- 4 files changed, 41 insertions(+), 7 deletions(-) diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index e8697cae34e..75af8dabbbb 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -492,16 +492,29 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF case MSP_SERVO: sbufWriteData(dst, &servo, MAX_SUPPORTED_SERVOS * 2); break; - - case MSP2_INAV_SERVO_CONFIG: + case MSP_SERVO_CONFIGURATIONS: for (int i = 0; i < MAX_SUPPORTED_SERVOS; i++) { sbufWriteU16(dst, servoParams(i)->min); sbufWriteU16(dst, servoParams(i)->max); sbufWriteU16(dst, servoParams(i)->middle); sbufWriteU8(dst, servoParams(i)->rate); + sbufWriteU8(dst, 0); + sbufWriteU8(dst, 0); + sbufWriteU8(dst, 255); // used to be forwardFromChannel, not used anymore, send 0xff for compatibility reasons + sbufWriteU32(dst, 0); //Input reversing is not required since it can be done on mixer level + } + break; + case MSP_SERVO_MIX_RULES: + for (int i = 0; i < MAX_SERVO_RULES; i++) { + sbufWriteU8(dst, customServoMixers(i)->targetChannel); + sbufWriteU8(dst, customServoMixers(i)->inputSource); + sbufWriteU16(dst, customServoMixers(i)->rate); + sbufWriteU8(dst, customServoMixers(i)->speed); + sbufWriteU8(dst, 0); + sbufWriteU8(dst, 100); + sbufWriteU8(dst, 0); } break; - case MSP2_INAV_SERVO_MIXER: for (int i = 0; i < MAX_SERVO_RULES; i++) { sbufWriteU8(dst, customServoMixers(i)->targetChannel); @@ -2065,8 +2078,8 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) return MSP_RESULT_ERROR; break; - case MSP2_INAV_SET_SERVO_CONFIG: - if (dataSize != 8) { + case MSP_SET_SERVO_CONFIGURATION: + if (dataSize != (1 + 14)) { return MSP_RESULT_ERROR; } tmp_u8 = sbufReadU8(src); @@ -2077,10 +2090,28 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) servoParamsMutable(tmp_u8)->max = sbufReadU16(src); servoParamsMutable(tmp_u8)->middle = sbufReadU16(src); servoParamsMutable(tmp_u8)->rate = sbufReadU8(src); + sbufReadU8(src); + sbufReadU8(src); + sbufReadU8(src); // used to be forwardFromChannel, ignored + sbufReadU32(src); // used to be reversedSources servoComputeScalingFactors(tmp_u8); } break; + case MSP_SET_SERVO_MIX_RULE: + sbufReadU8Safe(&tmp_u8, src); + if ((dataSize == 9) && (tmp_u8 < MAX_SERVO_RULES)) { + customServoMixersMutable(tmp_u8)->targetChannel = sbufReadU8(src); + customServoMixersMutable(tmp_u8)->inputSource = sbufReadU8(src); + customServoMixersMutable(tmp_u8)->rate = sbufReadU16(src); + customServoMixersMutable(tmp_u8)->speed = sbufReadU8(src); + sbufReadU16(src); //Read 2bytes for min/max and ignore it + sbufReadU8(src); //Read 1 byte for `box` and ignore it + loadCustomServoMixer(); + } else + return MSP_RESULT_ERROR; + break; + case MSP2_INAV_SET_SERVO_MIXER: sbufReadU8Safe(&tmp_u8, src); if ((dataSize == 7) && (tmp_u8 < MAX_SERVO_RULES)) { diff --git a/src/main/msp/msp_protocol.h b/src/main/msp/msp_protocol.h index 5d7a0fbd8be..9840b39aa39 100644 --- a/src/main/msp/msp_protocol.h +++ b/src/main/msp/msp_protocol.h @@ -243,6 +243,7 @@ #define MSP_PIDNAMES 117 //out message the PID names #define MSP_WP 118 //out message get a WP, WP# is in the payload, returns (WP#, lat, lon, alt, flags) WP#0-home, WP#16-poshold #define MSP_BOXIDS 119 //out message get the permanent IDs associated to BOXes +#define MSP_SERVO_CONFIGURATIONS 120 //out message All servo configurations. #define MSP_NAV_STATUS 121 //out message Returns navigation status #define MSP_NAV_CONFIG 122 //out message Returns navigation parameters #define MSP_3D 124 //out message Settings needed for reversible ESCs @@ -262,6 +263,7 @@ #define MSP_SET_WP 209 //in message sets a given WP (WP#,lat, lon, alt, flags) #define MSP_SELECT_SETTING 210 //in message Select Setting Number (0-2) #define MSP_SET_HEAD 211 //in message define a new heading hold direction +#define MSP_SET_SERVO_CONFIGURATION 212 //in message Servo settings #define MSP_SET_MOTOR 214 //in message PropBalance function #define MSP_SET_NAV_CONFIG 215 //in message Sets nav config parameters - write to the eeprom #define MSP_SET_3D 217 //in message Settings needed for reversible ESCs @@ -288,6 +290,8 @@ #define MSP_GPSSTATISTICS 166 //out message get GPS debugging data #define MSP_ACC_TRIM 240 //out message get acc angle trim values #define MSP_SET_ACC_TRIM 239 //in message set acc angle trim values +#define MSP_SERVO_MIX_RULES 241 //out message Returns servo mixer configuration +#define MSP_SET_SERVO_MIX_RULE 242 //in message Sets servo mixer configuration #define MSP_SET_PASSTHROUGH 245 //in message Sets up passthrough to different peripherals (4way interface, uart, etc...) #define MSP_RTC 246 //out message Gets the RTC clock (returns: secs(i32) millis(u16) - (0,0) if time is not known) #define MSP_SET_RTC 247 //in message Sets the RTC clock (args: secs(i32) millis(u16)) diff --git a/src/main/msp/msp_protocol_v2_common.h b/src/main/msp/msp_protocol_v2_common.h index 2d87219ac6b..82b7f754079 100644 --- a/src/main/msp/msp_protocol_v2_common.h +++ b/src/main/msp/msp_protocol_v2_common.h @@ -32,3 +32,4 @@ // radar commands #define MSP2_COMMON_SET_RADAR_POS 0x100B //SET radar position information #define MSP2_COMMON_SET_RADAR_ITD 0x100C //SET radar information to display + diff --git a/src/main/msp/msp_protocol_v2_inav.h b/src/main/msp/msp_protocol_v2_inav.h index 3312e5bc25d..66e883ab8c7 100755 --- a/src/main/msp/msp_protocol_v2_inav.h +++ b/src/main/msp/msp_protocol_v2_inav.h @@ -108,5 +108,3 @@ #define MSP2_INAV_CUSTOM_OSD_ELEMENTS 0x2100 #define MSP2_INAV_SET_CUSTOM_OSD_ELEMENTS 0x2101 -#define MSP2_INAV_SERVO_CONFIG 0x2200 -#define MSP2_INAV_SET_SERVO_CONFIG 0x2201 \ No newline at end of file From 08f61ffbe47b9f661c56c8a0fc7b286be8b1a155 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Wed, 10 Apr 2024 20:52:18 +0200 Subject: [PATCH 169/241] Reintroduce MSP2_INAV_SET_SERVO_CONFIG and MSP2_INAV_SERVO_CONFIG --- src/main/fc/fc_msp.c | 24 ++++++++++++++++++++++++ src/main/msp/msp_protocol_v2_inav.h | 2 ++ 2 files changed, 26 insertions(+) diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index 75af8dabbbb..67f25cdd32a 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -504,6 +504,14 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF sbufWriteU32(dst, 0); //Input reversing is not required since it can be done on mixer level } break; + case MSP2_INAV_SERVO_CONFIG: + for (int i = 0; i < MAX_SUPPORTED_SERVOS; i++) { + sbufWriteU16(dst, servoParams(i)->min); + sbufWriteU16(dst, servoParams(i)->max); + sbufWriteU16(dst, servoParams(i)->middle); + sbufWriteU8(dst, servoParams(i)->rate); + } + break; case MSP_SERVO_MIX_RULES: for (int i = 0; i < MAX_SERVO_RULES; i++) { sbufWriteU8(dst, customServoMixers(i)->targetChannel); @@ -2098,6 +2106,22 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) } break; + case MSP2_INAV_SET_SERVO_CONFIG: + if (dataSize != 8) { + return MSP_RESULT_ERROR; + } + tmp_u8 = sbufReadU8(src); + if (tmp_u8 >= MAX_SUPPORTED_SERVOS) { + return MSP_RESULT_ERROR; + } else { + servoParamsMutable(tmp_u8)->min = sbufReadU16(src); + servoParamsMutable(tmp_u8)->max = sbufReadU16(src); + servoParamsMutable(tmp_u8)->middle = sbufReadU16(src); + servoParamsMutable(tmp_u8)->rate = sbufReadU8(src); + servoComputeScalingFactors(tmp_u8); + } + break; + case MSP_SET_SERVO_MIX_RULE: sbufReadU8Safe(&tmp_u8, src); if ((dataSize == 9) && (tmp_u8 < MAX_SERVO_RULES)) { diff --git a/src/main/msp/msp_protocol_v2_inav.h b/src/main/msp/msp_protocol_v2_inav.h index 66e883ab8c7..3312e5bc25d 100755 --- a/src/main/msp/msp_protocol_v2_inav.h +++ b/src/main/msp/msp_protocol_v2_inav.h @@ -108,3 +108,5 @@ #define MSP2_INAV_CUSTOM_OSD_ELEMENTS 0x2100 #define MSP2_INAV_SET_CUSTOM_OSD_ELEMENTS 0x2101 +#define MSP2_INAV_SERVO_CONFIG 0x2200 +#define MSP2_INAV_SET_SERVO_CONFIG 0x2201 \ No newline at end of file From f7334495dce55abe7ee637069d7a54617b120437 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Wed, 10 Apr 2024 20:57:19 +0200 Subject: [PATCH 170/241] Revert "Merge pull request #9866 from iNavFlight/dzikuvx-drop-MSP_POSITION_ESTIMATION_CONFIG" This reverts commit 05e7a31f562839c553bdc68de81e0a1e4312633c, reversing changes made to b29b8f1d9434c7d563dbb7ae993d2b86df1aba58. --- src/main/fc/fc_msp.c | 25 +++++++++++++++++++++++++ src/main/msp/msp_protocol.h | 3 +++ 2 files changed, 28 insertions(+) diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index 75af8dabbbb..ee97a9f1e65 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -1381,6 +1381,18 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF break; + case MSP_POSITION_ESTIMATION_CONFIG: + + sbufWriteU16(dst, positionEstimationConfig()->w_z_baro_p * 100); // inav_w_z_baro_p float as value * 100 + sbufWriteU16(dst, positionEstimationConfig()->w_z_gps_p * 100); // 2 inav_w_z_gps_p float as value * 100 + sbufWriteU16(dst, positionEstimationConfig()->w_z_gps_v * 100); // 2 inav_w_z_gps_v float as value * 100 + sbufWriteU16(dst, positionEstimationConfig()->w_xy_gps_p * 100); // 2 inav_w_xy_gps_p float as value * 100 + sbufWriteU16(dst, positionEstimationConfig()->w_xy_gps_v * 100); // 2 inav_w_xy_gps_v float as value * 100 + sbufWriteU8(dst, gpsConfigMutable()->gpsMinSats); // 1 + sbufWriteU8(dst, 1); // 1 inav_use_gps_velned ON/OFF + + break; + case MSP_REBOOT: if (!ARMING_FLAG(ARMED)) { if (mspPostProcessFn) { @@ -2407,6 +2419,19 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) return MSP_RESULT_ERROR; break; + case MSP_SET_POSITION_ESTIMATION_CONFIG: + if (dataSize == 12) { + positionEstimationConfigMutable()->w_z_baro_p = constrainf(sbufReadU16(src) / 100.0f, 0.0f, 10.0f); + positionEstimationConfigMutable()->w_z_gps_p = constrainf(sbufReadU16(src) / 100.0f, 0.0f, 10.0f); + positionEstimationConfigMutable()->w_z_gps_v = constrainf(sbufReadU16(src) / 100.0f, 0.0f, 10.0f); + positionEstimationConfigMutable()->w_xy_gps_p = constrainf(sbufReadU16(src) / 100.0f, 0.0f, 10.0f); + positionEstimationConfigMutable()->w_xy_gps_v = constrainf(sbufReadU16(src) / 100.0f, 0.0f, 10.0f); + gpsConfigMutable()->gpsMinSats = constrain(sbufReadU8(src), 5, 10); + sbufReadU8(src); // was positionEstimationConfigMutable()->use_gps_velned + } else + return MSP_RESULT_ERROR; + break; + case MSP_RESET_CONF: if (!ARMING_FLAG(ARMED)) { suspendRxSignal(); diff --git a/src/main/msp/msp_protocol.h b/src/main/msp/msp_protocol.h index 9840b39aa39..62e3c0d1a3d 100644 --- a/src/main/msp/msp_protocol.h +++ b/src/main/msp/msp_protocol.h @@ -110,6 +110,9 @@ #define MSP_CALIBRATION_DATA 14 #define MSP_SET_CALIBRATION_DATA 15 +#define MSP_POSITION_ESTIMATION_CONFIG 16 +#define MSP_SET_POSITION_ESTIMATION_CONFIG 17 + #define MSP_WP_MISSION_LOAD 18 // Load mission from NVRAM #define MSP_WP_MISSION_SAVE 19 // Save mission to NVRAM #define MSP_WP_GETINFO 20 From 6481f1ef25dc146aff6b4e20d2f213dfc17d895a Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Wed, 10 Apr 2024 21:06:47 +0200 Subject: [PATCH 171/241] Revert "Merge pull request #9901 from iNavFlight/dzikuvx-drop-MSP_PID_ADVANCED" This reverts commit cea4397f7b3695b84a2550b63cd85a1ed9e10abb, reversing changes made to 8fac3549b43acc4cb3439ddcb63f9a641f0b4f00. --- src/main/fc/fc_msp.c | 42 +++++++++++++++++++++++++++++++++++++ src/main/msp/msp_protocol.h | 2 ++ 2 files changed, 44 insertions(+) diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index ee97a9f1e65..63c7468ea69 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -1260,6 +1260,25 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF sbufWriteU16(dst, accelerometerConfig()->acc_notch_cutoff); sbufWriteU16(dst, 0); //Was gyroConfig()->gyro_stage2_lowpass_hz + break; + + case MSP_PID_ADVANCED: + sbufWriteU16(dst, 0); // pidProfile()->rollPitchItermIgnoreRate + sbufWriteU16(dst, 0); // pidProfile()->yawItermIgnoreRate + sbufWriteU16(dst, 0); //pidProfile()->yaw_p_limit + sbufWriteU8(dst, 0); //BF: pidProfile()->deltaMethod + sbufWriteU8(dst, 0); //BF: pidProfile()->vbatPidCompensation + sbufWriteU8(dst, 0); //BF: pidProfile()->setpointRelaxRatio + sbufWriteU8(dst, 0); + sbufWriteU16(dst, pidProfile()->pidSumLimit); + sbufWriteU8(dst, 0); //BF: pidProfile()->itermThrottleGain + + /* + * To keep compatibility on MSP frame length level with Betaflight, axis axisAccelerationLimitYaw + * limit will be sent and received in [dps / 10] + */ + sbufWriteU16(dst, constrain(pidProfile()->axisAccelerationLimitRollPitch / 10, 0, 65535)); + sbufWriteU16(dst, constrain(pidProfile()->axisAccelerationLimitYaw / 10, 0, 65535)); break; case MSP_INAV_PID: @@ -2278,6 +2297,29 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) return MSP_RESULT_ERROR; break; + case MSP_SET_PID_ADVANCED: + if (dataSize == 17) { + sbufReadU16(src); // pidProfileMutable()->rollPitchItermIgnoreRate + sbufReadU16(src); // pidProfileMutable()->yawItermIgnoreRate + sbufReadU16(src); //pidProfile()->yaw_p_limit + + sbufReadU8(src); //BF: pidProfileMutable()->deltaMethod + sbufReadU8(src); //BF: pidProfileMutable()->vbatPidCompensation + sbufReadU8(src); //BF: pidProfileMutable()->setpointRelaxRatio + sbufReadU8(src); + pidProfileMutable()->pidSumLimit = sbufReadU16(src); + sbufReadU8(src); //BF: pidProfileMutable()->itermThrottleGain + + /* + * To keep compatibility on MSP frame length level with Betaflight, axis axisAccelerationLimitYaw + * limit will be sent and received in [dps / 10] + */ + pidProfileMutable()->axisAccelerationLimitRollPitch = sbufReadU16(src) * 10; + pidProfileMutable()->axisAccelerationLimitYaw = sbufReadU16(src) * 10; + } else + return MSP_RESULT_ERROR; + break; + case MSP_SET_INAV_PID: if (dataSize == 15) { sbufReadU8(src); //Legacy, no longer in use async processing value diff --git a/src/main/msp/msp_protocol.h b/src/main/msp/msp_protocol.h index 62e3c0d1a3d..ac847afeaec 100644 --- a/src/main/msp/msp_protocol.h +++ b/src/main/msp/msp_protocol.h @@ -204,6 +204,8 @@ #define MSP_FILTER_CONFIG 92 #define MSP_SET_FILTER_CONFIG 93 +#define MSP_PID_ADVANCED 94 +#define MSP_SET_PID_ADVANCED 95 #define MSP_SENSOR_CONFIG 96 #define MSP_SET_SENSOR_CONFIG 97 From 133c72bcfd43eaff0c0a04333615e05d1f002540 Mon Sep 17 00:00:00 2001 From: Roman Lut <11955117+RomanLut@users.noreply.github.com> Date: Thu, 11 Apr 2024 18:41:55 +0200 Subject: [PATCH 172/241] increased VBATT_PRESENT_THRESHOLD --- src/main/sensors/battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/sensors/battery.c b/src/main/sensors/battery.c index 3745ed7a8ea..2ca7024694e 100644 --- a/src/main/sensors/battery.c +++ b/src/main/sensors/battery.c @@ -66,7 +66,7 @@ #define ADCVREF 3300 // in mV (3300 = 3.3V) #define VBATT_CELL_FULL_MAX_DIFF 10 // Max difference with cell max voltage for the battery to be considered full (10mV steps) -#define VBATT_PRESENT_THRESHOLD 100 // Minimum voltage to consider battery present +#define VBATT_PRESENT_THRESHOLD 220 // Minimum voltage to consider battery present #define VBATT_STABLE_DELAY 40 // Delay after connecting battery to begin monitoring #define VBATT_HYSTERESIS 10 // Batt Hysteresis of +/-100mV for changing battery state #define VBATT_LPF_FREQ 1 // Battery voltage filtering cutoff From 9db5a5446b80331c37d61900d15555722601b592 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Thu, 11 Apr 2024 20:57:12 +0200 Subject: [PATCH 173/241] Version to 7.1.1 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d8247e7cb5a..f74527e5f1b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,7 +51,7 @@ else() endif() endif() -project(INAV VERSION 7.1.0) +project(INAV VERSION 7.1.1) enable_language(ASM) From f40361034d28f1273bcb3ff7aa56b293b8166ecb Mon Sep 17 00:00:00 2001 From: 0crap <31951195+0crap@users.noreply.github.com> Date: Mon, 8 Apr 2024 12:54:16 +0200 Subject: [PATCH 174/241] Update Fixed Wing Landing.md Simple typo fix. --- docs/Fixed Wing Landing.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Fixed Wing Landing.md b/docs/Fixed Wing Landing.md index 4ccb3249536..118221229c5 100644 --- a/docs/Fixed Wing Landing.md +++ b/docs/Fixed Wing Landing.md @@ -54,7 +54,7 @@ This means that practically 4 landing directions can be saved. > [!CAUTION] > The Configuator automatically determines the ground altitude based on databases on the Internet, which may be inaccurate. Please always compare with the measured GPS altitude at the landing site to avoid crashes. -### Global paramters +### Global parameters All settings are available via “Advanced Tuning” in the Configurator. @@ -87,7 +87,7 @@ If the altitude of the waypoint and the "Approach Altitude" are different, the a ## Logic Conditions -The current landing state can be retrieved via ID 41 in "Flight" (FW Land State). This allows additional actions to be executed according to the landing phases, e.g. deplyoment of the landing flaps. +The current landing state can be retrieved via ID 41 in "Flight" (FW Land State). This allows additional actions to be executed according to the landing phases, e.g. deployment of the landing flaps. | Returned value | State | | --- | --- | From 67b688c6b4b0e365ebf200bac175609fec237515 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Fri, 22 Mar 2024 20:01:09 +0100 Subject: [PATCH 175/241] No longer require MAG to unlock GPS related flight modes --- src/main/fc/fc_msp_box.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/fc/fc_msp_box.c b/src/main/fc/fc_msp_box.c index c61c2aa19e9..f1c72458bff 100644 --- a/src/main/fc/fc_msp_box.c +++ b/src/main/fc/fc_msp_box.c @@ -220,9 +220,6 @@ void initActiveBoxIds(void) const bool navFlowDeadReckoning = sensors(SENSOR_OPFLOW) && sensors(SENSOR_ACC) && positionEstimationConfig()->allow_dead_reckoning; bool navReadyPosControl = sensors(SENSOR_ACC) && feature(FEATURE_GPS); - if (STATE(MULTIROTOR)) { - navReadyPosControl = navReadyPosControl && getHwCompassStatus() != HW_SENSOR_NONE; - } if (STATE(ALTITUDE_CONTROL) && navReadyAltControl && (navReadyPosControl || navFlowDeadReckoning)) { ADD_ACTIVE_BOX(BOXNAVPOSHOLD); From 8eeea07da815538a861902477e9c14fa4d76ea5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Spychalski?= Date: Thu, 11 Apr 2024 21:01:07 +0200 Subject: [PATCH 176/241] Merge pull request #9896 from iNavFlight/b14ckyy-Update-FW-landing-Doc Update Fixed Wing Landing.md --- docs/Fixed Wing Landing.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/Fixed Wing Landing.md b/docs/Fixed Wing Landing.md index 118221229c5..10eff364f34 100644 --- a/docs/Fixed Wing Landing.md +++ b/docs/Fixed Wing Landing.md @@ -5,6 +5,8 @@ INAV supports advanced automatic landings for fixed wing aircraft from version 7.1. The procedure is based on landings for man-carrying aircraft, so that safe landings at a specific location are possible. Supported are landings at safehome after "Return to Home" or at a defined LAND waypoint for missions. +Every landing locations can be defined with a target point and 2 different approach headings (colinear to the landing strips) with exclusive direction or opposite directions allowed. +This enables up to 4 different approach directions, based on the landing site and surrounding area. ## General procedure: @@ -34,7 +36,7 @@ The following graphics illustrate the process: ### The following parameters are set for each landing site (Safefome/LAND waypoint): -All settings can also be conveniently made in the Configurator via Missionplanner. +All settings can also be conveniently made in the Configurator via Mission Control. CLI command `fwapproach`: `fwapproach ` From 80adbbc1e52e875070c8fa04a93d241817b9d276 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Spychalski?= Date: Thu, 11 Apr 2024 21:01:57 +0200 Subject: [PATCH 177/241] Merge pull request #9890 from iNavFlight/MrD_Add-extra-description-to-the-min-ground-speed-parameter Add extra description to nav_min_ground_speed parameter --- docs/Settings.md | 2 +- src/main/fc/settings.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Settings.md b/docs/Settings.md index 1f5ccde178e..8608eb01f51 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -3764,7 +3764,7 @@ When ON, NAV engine will slow down when switching to the next waypoint. This pri ### nav_min_ground_speed -Minimum ground speed for navigation flight modes [m/s]. Default 7 m/s. +Minimum ground speed for navigation flight modes [m/s]. Currently, this only affects fixed wing. Default 7 m/s. | Default | Min | Max | | --- | --- | --- | diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index 0f63c66ddd5..66abea46399 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -2493,7 +2493,7 @@ groups: min: 10 max: 2000 - name: nav_min_ground_speed - description: "Minimum ground speed for navigation flight modes [m/s]. Default 7 m/s." + description: "Minimum ground speed for navigation flight modes [m/s]. Currently, this only affects fixed wing. Default 7 m/s." default_value: 7 field: general.min_ground_speed min: 6 From db13d5da541342fa16b6c9d435b1e83e4fa7826f Mon Sep 17 00:00:00 2001 From: breadoven <56191411+breadoven@users.noreply.github.com> Date: Thu, 11 Apr 2024 22:57:28 +0100 Subject: [PATCH 178/241] Update navigation.c --- src/main/navigation/navigation.c | 39 +++++--------------------------- 1 file changed, 6 insertions(+), 33 deletions(-) diff --git a/src/main/navigation/navigation.c b/src/main/navigation/navigation.c index 9e81024c3af..69b4a112b65 100644 --- a/src/main/navigation/navigation.c +++ b/src/main/navigation/navigation.c @@ -1142,7 +1142,6 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .mwError = MW_NAV_ERROR_NONE, .onEvent = { [NAV_FSM_EVENT_TIMEOUT] = NAV_STATE_FW_LANDING_FLARE, // re-process the state - [NAV_FSM_EVENT_SUCCESS] = NAV_STATE_IDLE, [NAV_FSM_EVENT_SWITCH_TO_IDLE] = NAV_STATE_IDLE, } }, @@ -2043,21 +2042,12 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_WAYPOINT_RTH_LAND(navig const navigationFSMEvent_t landEvent = navOnEnteringState_NAV_STATE_RTH_LANDING(previousState); -#ifdef USE_FW_AUTOLAND - if (landEvent == NAV_FSM_EVENT_SWITCH_TO_NAV_STATE_FW_LANDING) { - return NAV_FSM_EVENT_SWITCH_TO_NAV_STATE_FW_LANDING; - } else -#endif - if (landEvent == NAV_FSM_EVENT_SWITCH_TO_RTH_HOVER_ABOVE_HOME) { - return NAV_FSM_EVENT_SWITCH_TO_WAYPOINT_FINISHED; - } else if (landEvent == NAV_FSM_EVENT_SUCCESS) { + if (landEvent == NAV_FSM_EVENT_SUCCESS) { // Landing controller returned success - invoke RTH finishing state and finish the waypoint navOnEnteringState_NAV_STATE_RTH_FINISHING(previousState); - return NAV_FSM_EVENT_SUCCESS; - } - else { - return NAV_FSM_EVENT_NONE; } + + return landEvent; } static navigationFSMEvent_t navOnEnteringState_NAV_STATE_WAYPOINT_NEXT(navigationFSMState_t previousState) @@ -2376,12 +2366,6 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_FW_LANDING_APPROACH(nav return NAV_FSM_EVENT_SWITCH_TO_NAV_STATE_FW_LANDING_ABORT; } - if (isLandingDetected()) { - posControl.fwLandState.landState = FW_AUTOLAND_STATE_IDLE; - //disarm(DISARM_LANDING); - return NAV_FSM_EVENT_SWITCH_TO_IDLE; - } - if (getLandAltitude() <= fwAutolandApproachConfig(posControl.fwLandState.approachSettingIdx)->landAlt + navFwAutolandConfig()->glideAltitude - (fwAutolandApproachConfig(posControl.fwLandState.approachSettingIdx)->isSeaLevelRef ? GPS_home.alt : 0)) { resetPositionController(); posControl.cruise.course = posControl.fwLandState.landingDirection; @@ -2427,12 +2411,6 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_FW_LANDING_GLIDE(naviga return NAV_FSM_EVENT_SUCCESS; } - if (isLandingDetected()) { - posControl.fwLandState.landState = FW_AUTOLAND_STATE_IDLE; - //disarm(DISARM_LANDING); - return NAV_FSM_EVENT_SWITCH_TO_IDLE; - } - setDesiredPosition(NULL, posControl.cruise.course, NAV_POS_UPDATE_HEADING); return NAV_FSM_EVENT_NONE; } @@ -2441,11 +2419,6 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_FW_LANDING_FLARE(naviga { UNUSED(previousState); - if (isLandingDetected()) { - posControl.fwLandState.landState = FW_AUTOLAND_STATE_IDLE; - //disarm(DISARM_LANDING); - return NAV_FSM_EVENT_SUCCESS; - } setDesiredPosition(NULL, posControl.cruise.course, NAV_POS_UPDATE_HEADING); return NAV_FSM_EVENT_NONE; @@ -4083,7 +4056,7 @@ bool isNavHoldPositionActive(void) // Also hold position during emergency landing if position valid return (FLIGHT_MODE(NAV_RTH_MODE) && !posControl.flags.rthTrackbackActive) || FLIGHT_MODE(NAV_POSHOLD_MODE) || - (posControl.navState == NAV_STATE_FW_LANDING_CLIMB_TO_LOITER || posControl.navState == NAV_STATE_FW_LANDING_LOITER) || + (posControl.navState == NAV_STATE_FW_LANDING_CLIMB_TO_LOITER || posControl.navState == NAV_STATE_FW_LANDING_LOITER) || navigationIsExecutingAnEmergencyLanding(); } @@ -4123,7 +4096,7 @@ bool isWaypointNavTrackingActive(void) // is set from current position not previous WP. Works for WP Restart intermediate WP as well as first mission WP. // (NAV_WP_MODE flag isn't set until WP initialisation is finished, i.e. after calculateAndSetActiveWaypoint called) - return FLIGHT_MODE(NAV_WP_MODE) + return FLIGHT_MODE(NAV_WP_MODE) || posControl.navState == NAV_STATE_FW_LANDING_APPROACH || (posControl.flags.rthTrackbackActive && posControl.activeRthTBPointIndex != posControl.rthTBLastSavedIndex); } @@ -5011,7 +4984,7 @@ bool navigationRTHAllowsLanding(void) return false; } #endif - + // WP mission RTH landing setting if (isWaypointMissionRTHActive() && isWaypointMissionValid()) { return posControl.waypointList[posControl.startWpIndex + posControl.waypointCount - 1].p1 > 0; From 50df48e0a7aed68a876c2b2fd5ee845ac2385b4a Mon Sep 17 00:00:00 2001 From: Daniel Li Date: Fri, 12 Apr 2024 14:53:40 +0800 Subject: [PATCH 179/241] Fix Aocoda-RC H743Dual motor 5-8 mis-labeled issue --- src/main/target/AOCODARCH7DUAL/target.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/target/AOCODARCH7DUAL/target.c b/src/main/target/AOCODARCH7DUAL/target.c index 85e8b004937..ac3be127191 100644 --- a/src/main/target/AOCODARCH7DUAL/target.c +++ b/src/main/target/AOCODARCH7DUAL/target.c @@ -36,11 +36,11 @@ timerHardware_t timerHardware[] = { DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 1), // S2 DEF_TIM(TIM5, CH1, PA0, TIM_USE_OUTPUT_AUTO, 0, 2), // S3 DEF_TIM(TIM5, CH2, PA1, TIM_USE_OUTPUT_AUTO, 0, 3), // S4 - - DEF_TIM(TIM5, CH3, PA2, TIM_USE_OUTPUT_AUTO, 0, 4), // S5 - DEF_TIM(TIM5, CH4, PA3, TIM_USE_OUTPUT_AUTO, 0, 5), // S6 - DEF_TIM(TIM4, CH1, PD12, TIM_USE_OUTPUT_AUTO, 0, 6), // S7 - DEF_TIM(TIM4, CH2, PD13, TIM_USE_OUTPUT_AUTO, 0, 7), // S8 + + DEF_TIM(TIM4, CH2, PD13, TIM_USE_OUTPUT_AUTO, 0, 4), // S5 + DEF_TIM(TIM4, CH1, PD12, TIM_USE_OUTPUT_AUTO, 0, 5), // S6 + DEF_TIM(TIM5, CH4, PA3, TIM_USE_OUTPUT_AUTO, 0, 6), // S7 + DEF_TIM(TIM5, CH3, PA2, TIM_USE_OUTPUT_AUTO, 0, 7), // S8 DEF_TIM(TIM4, CH3, PD14, TIM_USE_OUTPUT_AUTO, 0, 0), // S9 DEF_TIM(TIM4, CH4, PD15, TIM_USE_OUTPUT_AUTO, 0, 0), // S10 DMA_NONE From 8736517defa3eba6bf88d66ccd765e22e73f4ebd Mon Sep 17 00:00:00 2001 From: b14ckyy Date: Fri, 12 Apr 2024 20:03:08 +0200 Subject: [PATCH 180/241] add ICM for IFLIGHT_BLITZ_F722 V1.2 --- src/main/target/IFLIGHT_BLITZ_F722/target.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/target/IFLIGHT_BLITZ_F722/target.h b/src/main/target/IFLIGHT_BLITZ_F722/target.h index 0ced96ad5fb..cea6b4422ac 100644 --- a/src/main/target/IFLIGHT_BLITZ_F722/target.h +++ b/src/main/target/IFLIGHT_BLITZ_F722/target.h @@ -42,6 +42,11 @@ #define MPU6000_CS_PIN PA4 #define MPU6000_SPI_BUS BUS_SPI1 +#define USE_IMU_ICM42605 +#define IMU_ICM42605_ALIGN CW0_DEG +#define ICM42605_SPI_BUS BUS_SPI1 +#define ICM42605_CS_PIN PA4 + // *************** I2C /Baro/Mag ********************* #define USE_I2C #define USE_I2C_DEVICE_1 From 16dfea4c76ab5aa755a36cf6af2bd9d40e361c51 Mon Sep 17 00:00:00 2001 From: b14ckyy Date: Fri, 12 Apr 2024 22:38:33 +0200 Subject: [PATCH 181/241] enable all baro --- src/main/target/IFLIGHT_BLITZ_F722/target.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/target/IFLIGHT_BLITZ_F722/target.h b/src/main/target/IFLIGHT_BLITZ_F722/target.h index cea6b4422ac..a3b6ed6b327 100644 --- a/src/main/target/IFLIGHT_BLITZ_F722/target.h +++ b/src/main/target/IFLIGHT_BLITZ_F722/target.h @@ -55,9 +55,7 @@ #define USE_BARO #define BARO_I2C_BUS BUS_I2C1 -#define USE_BARO_BMP280 -#define USE_BARO_MS5611 -#define USE_BARO_DPS310 +#define USE_BARO_ALL #define USE_MAG #define MAG_I2C_BUS BUS_I2C1 From a497c58d974f982099e1f4180584c569015fa617 Mon Sep 17 00:00:00 2001 From: b14ckyy Date: Fri, 12 Apr 2024 22:46:57 +0200 Subject: [PATCH 182/241] remove baro all again due to high flash use. --- src/main/target/IFLIGHT_BLITZ_F722/target.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/target/IFLIGHT_BLITZ_F722/target.h b/src/main/target/IFLIGHT_BLITZ_F722/target.h index a3b6ed6b327..cea6b4422ac 100644 --- a/src/main/target/IFLIGHT_BLITZ_F722/target.h +++ b/src/main/target/IFLIGHT_BLITZ_F722/target.h @@ -55,7 +55,9 @@ #define USE_BARO #define BARO_I2C_BUS BUS_I2C1 -#define USE_BARO_ALL +#define USE_BARO_BMP280 +#define USE_BARO_MS5611 +#define USE_BARO_DPS310 #define USE_MAG #define MAG_I2C_BUS BUS_I2C1 From 354eb2cfedb125bf5e03a3c998d692480052154c Mon Sep 17 00:00:00 2001 From: breadoven <56191411+breadoven@users.noreply.github.com> Date: Fri, 12 Apr 2024 23:18:02 +0100 Subject: [PATCH 183/241] updates --- src/main/fc/fc_init.c | 1 - src/main/io/osd.c | 12 ++--- src/main/navigation/navigation.c | 68 ++++++++++++++++++------ src/main/navigation/navigation.h | 2 +- src/main/navigation/navigation_private.h | 22 ++++---- 5 files changed, 71 insertions(+), 34 deletions(-) diff --git a/src/main/fc/fc_init.c b/src/main/fc/fc_init.c index 849cdc2b7c0..0d4897dd557 100644 --- a/src/main/fc/fc_init.c +++ b/src/main/fc/fc_init.c @@ -60,7 +60,6 @@ #include "drivers/pwm_esc_detect.h" #include "drivers/pwm_mapping.h" #include "drivers/pwm_output.h" -#include "drivers/pwm_output.h" #include "drivers/sensor.h" #include "drivers/serial.h" #include "drivers/serial_softserial.h" diff --git a/src/main/io/osd.c b/src/main/io/osd.c index f0cc50bbaa1..435b09f9e3f 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -1003,7 +1003,7 @@ static const char * divertingToSafehomeMessage(void) return OSD_MESSAGE_STR(OSD_MSG_DIVERT_SAFEHOME); } #endif - return NULL; + return NULL; } @@ -1028,7 +1028,7 @@ static const char * navigationStateMessage(void) linearDescentMessageMs = millis() + 5000; // Show message for 5 seconds. return OSD_MESSAGE_STR(OSD_MSG_RTH_LINEAR_DESCENT); - } else + } else return OSD_MESSAGE_STR(OSD_MSG_HEADING_HOME); } case MW_NAV_STATE_HOLD_INFINIT: @@ -1069,7 +1069,7 @@ static const char * navigationStateMessage(void) // If there is a FS landing delay occurring. That is handled by the calling function. if (posControl.landingDelay > 0) break; - + return OSD_MESSAGE_STR(OSD_MSG_PREPARING_LAND); } case MW_NAV_STATE_LAND_START_DESCENT: @@ -2277,7 +2277,7 @@ static bool osdDrawSingleElement(uint8_t item) { char *p = "ACRO"; #ifdef USE_FW_AUTOLAND - if (FLIGHT_MODE(NAV_FW_AUTOLAND)) + if (FLIGHT_MODE(NAV_FW_AUTOLAND)) p = "LAND"; else #endif @@ -5177,11 +5177,11 @@ textAttributes_t osdGetSystemMessage(char *buff, size_t buff_size, bool isCenter tfp_sprintf(messageBuf, "LANDING DELAY: %3u SECONDS", remainingHoldSec); messages[messageCount++] = messageBuf; - } + } else { #ifdef USE_FW_AUTOLAND - if (canFwLandCanceld()) { + if (canFwLandingBeCancelled()) { messages[messageCount++] = OSD_MESSAGE_STR(OSD_MSG_MOVE_STICKS); } else if (!FLIGHT_MODE(NAV_FW_AUTOLAND)) { #endif diff --git a/src/main/navigation/navigation.c b/src/main/navigation/navigation.c index 69b4a112b65..284afc74109 100644 --- a/src/main/navigation/navigation.c +++ b/src/main/navigation/navigation.c @@ -356,6 +356,7 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_FW_LANDING_LOITER(navig static navigationFSMEvent_t navOnEnteringState_NAV_STATE_FW_LANDING_APPROACH(navigationFSMState_t previousState); static navigationFSMEvent_t navOnEnteringState_NAV_STATE_FW_LANDING_GLIDE(navigationFSMState_t previousState); static navigationFSMEvent_t navOnEnteringState_NAV_STATE_FW_LANDING_FLARE(navigationFSMState_t previousState); +static navigationFSMEvent_t navOnEnteringState_NAV_STATE_FW_LANDING_FINISHED(navigationFSMState_t previousState); static navigationFSMEvent_t navOnEnteringState_NAV_STATE_FW_LANDING_ABORT(navigationFSMState_t previousState); #endif @@ -1107,6 +1108,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { [NAV_FSM_EVENT_SWITCH_TO_EMERGENCY_LANDING] = NAV_STATE_EMERGENCY_LANDING_INITIALIZE, [NAV_FSM_EVENT_SWITCH_TO_COURSE_HOLD] = NAV_STATE_COURSE_HOLD_INITIALIZE, [NAV_FSM_EVENT_SWITCH_TO_CRUISE] = NAV_STATE_CRUISE_INITIALIZE, + [NAV_FSM_EVENT_SWITCH_TO_NAV_STATE_FW_LANDING_FINISHED] = NAV_STATE_FW_LANDING_FINISHED, [NAV_FSM_EVENT_SWITCH_TO_NAV_STATE_FW_LANDING_ABORT] = NAV_STATE_FW_LANDING_ABORT, } }, @@ -1128,6 +1130,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { [NAV_FSM_EVENT_SWITCH_TO_EMERGENCY_LANDING] = NAV_STATE_EMERGENCY_LANDING_INITIALIZE, [NAV_FSM_EVENT_SWITCH_TO_COURSE_HOLD] = NAV_STATE_COURSE_HOLD_INITIALIZE, [NAV_FSM_EVENT_SWITCH_TO_CRUISE] = NAV_STATE_CRUISE_INITIALIZE, + [NAV_FSM_EVENT_SWITCH_TO_NAV_STATE_FW_LANDING_FINISHED] = NAV_STATE_FW_LANDING_FINISHED, [NAV_FSM_EVENT_SWITCH_TO_NAV_STATE_FW_LANDING_ABORT] = NAV_STATE_FW_LANDING_ABORT, } }, @@ -1141,10 +1144,26 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .mwState = MW_NAV_STATE_LAND_IN_PROGRESS, .mwError = MW_NAV_ERROR_NONE, .onEvent = { - [NAV_FSM_EVENT_TIMEOUT] = NAV_STATE_FW_LANDING_FLARE, // re-process the state - [NAV_FSM_EVENT_SWITCH_TO_IDLE] = NAV_STATE_IDLE, + [NAV_FSM_EVENT_TIMEOUT] = NAV_STATE_FW_LANDING_FLARE, // re-process the state + [NAV_FSM_EVENT_SWITCH_TO_NAV_STATE_FW_LANDING_FINISHED] = NAV_STATE_FW_LANDING_FINISHED, + [NAV_FSM_EVENT_SWITCH_TO_IDLE] = NAV_STATE_IDLE, } }, + + [NAV_STATE_FW_LANDING_FINISHED] = { + .persistentId = NAV_PERSISTENT_ID_FW_LANDING_FINISHED, + .onEntry = navOnEnteringState_NAV_STATE_FW_LANDING_FINISHED, + .timeoutMs = 10, + .stateFlags = NAV_REQUIRE_ANGLE, + .mapToFlightModes = NAV_FW_AUTOLAND, + .mwState = MW_NAV_STATE_LAND_IN_PROGRESS, + .mwError = MW_NAV_ERROR_NONE, + .onEvent = { + [NAV_FSM_EVENT_TIMEOUT] = NAV_STATE_FW_LANDING_FINISHED, // re-process the state + [NAV_FSM_EVENT_SWITCH_TO_IDLE] = NAV_STATE_IDLE, + } + }, + [NAV_STATE_FW_LANDING_ABORT] = { .persistentId = NAV_PERSISTENT_ID_FW_LANDING_ABORT, .onEntry = navOnEnteringState_NAV_STATE_FW_LANDING_ABORT, @@ -1697,9 +1716,7 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_HOVER_ABOVE_HOME(na static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_LANDING(navigationFSMState_t previousState) { -#ifndef USE_FW_AUTOLAND UNUSED(previousState); -#endif //On ROVER and BOAT we immediately switch to the next event if (!STATE(ALTITUDE_CONTROL)) { @@ -1712,7 +1729,7 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_LANDING(navigationF /* If position sensors unavailable - land immediately (wait for timeout on GPS) * Continue to check for RTH sanity during landing */ - if (posControl.flags.estHeadingStatus == EST_NONE || checkForPositionSensorTimeout() || (previousState != NAV_STATE_WAYPOINT_REACHED && !validateRTHSanityChecker())) { + if (posControl.flags.estHeadingStatus == EST_NONE || checkForPositionSensorTimeout() || (FLIGHT_MODE(NAV_RTH_MODE) && !validateRTHSanityChecker())) { return NAV_FSM_EVENT_SWITCH_TO_EMERGENCY_LANDING; } @@ -1731,7 +1748,7 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_LANDING(navigationF shIdx = posControl.safehomeState.index; missionFwLandConfigStartIdx = MAX_SAFE_HOMES; #endif - if (previousState == NAV_STATE_WAYPOINT_REACHED && missionIdx >= 0) { + if (FLIGHT_MODE(NAV_WP_MODE) && missionIdx >= 0) { approachSettingIdx = missionFwLandConfigStartIdx + missionIdx; } else if (shIdx >= 0) { approachSettingIdx = shIdx; @@ -1739,7 +1756,7 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_LANDING(navigationF if (!posControl.fwLandState.landAborted && approachSettingIdx >= 0 && (fwAutolandApproachConfig(approachSettingIdx)->landApproachHeading1 != 0 || fwAutolandApproachConfig(approachSettingIdx)->landApproachHeading2 != 0)) { - if (previousState == NAV_STATE_WAYPOINT_REACHED) { + if (FLIGHT_MODE(NAV_WP_MODE)) { posControl.fwLandState.landPos = posControl.activeWaypoint.pos; posControl.fwLandState.landWp = true; } else { @@ -2032,8 +2049,6 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_WAYPOINT_HOLD_TIME(navi static navigationFSMEvent_t navOnEnteringState_NAV_STATE_WAYPOINT_RTH_LAND(navigationFSMState_t previousState) { - UNUSED(previousState); - #ifdef USE_FW_AUTOLAND if (posControl.fwLandState.landAborted) { return NAV_FSM_EVENT_SWITCH_TO_WAYPOINT_FINISHED; @@ -2043,8 +2058,9 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_WAYPOINT_RTH_LAND(navig const navigationFSMEvent_t landEvent = navOnEnteringState_NAV_STATE_RTH_LANDING(previousState); if (landEvent == NAV_FSM_EVENT_SUCCESS) { - // Landing controller returned success - invoke RTH finishing state and finish the waypoint + // Landing controller returned success - invoke RTH finish states and finish the waypoint navOnEnteringState_NAV_STATE_RTH_FINISHING(previousState); + navOnEnteringState_NAV_STATE_RTH_FINISHED(previousState); } return landEvent; @@ -2358,6 +2374,10 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_FW_LANDING_APPROACH(nav { UNUSED(previousState); + if (STATE(LANDING_DETECTED)) { + return NAV_FSM_EVENT_SWITCH_TO_NAV_STATE_FW_LANDING_FINISHED; + } + if ((posControl.flags.estHeadingStatus == EST_NONE) || checkForPositionSensorTimeout()) { return NAV_FSM_EVENT_SWITCH_TO_EMERGENCY_LANDING; } @@ -2402,6 +2422,10 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_FW_LANDING_GLIDE(naviga { UNUSED(previousState); + if (STATE(LANDING_DETECTED)) { + return NAV_FSM_EVENT_SWITCH_TO_NAV_STATE_FW_LANDING_FINISHED; + } + if (isRollPitchStickDeflected(navConfig()->fw.launch_land_abort_deadband)) { return NAV_FSM_EVENT_SWITCH_TO_NAV_STATE_FW_LANDING_ABORT; } @@ -2419,11 +2443,24 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_FW_LANDING_FLARE(naviga { UNUSED(previousState); + if (STATE(LANDING_DETECTED)) { + return NAV_FSM_EVENT_SWITCH_TO_NAV_STATE_FW_LANDING_FINISHED; + } + setDesiredPosition(NULL, posControl.cruise.course, NAV_POS_UPDATE_HEADING); return NAV_FSM_EVENT_NONE; } +static navigationFSMEvent_t navOnEnteringState_NAV_STATE_FW_LANDING_FINISHED(navigationFSMState_t previousState) +{ + UNUSED(previousState); + + posControl.fwLandState.landState = FW_AUTOLAND_STATE_IDLE; + + return NAV_FSM_EVENT_NONE; +} + static navigationFSMEvent_t navOnEnteringState_NAV_STATE_FW_LANDING_ABORT(navigationFSMState_t previousState) { UNUSED(previousState); @@ -4896,9 +4933,9 @@ void abortForcedRTH(void) rthState_e getStateOfForcedRTH(void) { - /* If forced RTH activated and in AUTO_RTH or EMERG state */ + /* If forced RTH activated and in AUTO_RTH, EMERG state or FW Auto Landing */ if (posControl.flags.forcedRTHActivated && ((navGetStateFlags(posControl.navState) & (NAV_AUTO_RTH | NAV_CTL_EMERG | NAV_MIXERAT)) || FLIGHT_MODE(NAV_FW_AUTOLAND))) { - if (posControl.navState == NAV_STATE_RTH_FINISHED || posControl.navState == NAV_STATE_EMERGENCY_LANDING_FINISHED) { + if (posControl.navState == NAV_STATE_RTH_FINISHED || posControl.navState == NAV_STATE_EMERGENCY_LANDING_FINISHED || posControl.navState == NAV_STATE_FW_LANDING_FINISHED) { return RTH_HAS_LANDED; } else { @@ -5142,12 +5179,9 @@ void resetFwAutolandApproach(int8_t idx) } } -bool canFwLandCanceld(void) +bool canFwLandingBeCancelled(void) { - return posControl.navState == NAV_STATE_FW_LANDING_CLIMB_TO_LOITER - || posControl.navState == NAV_STATE_FW_LANDING_LOITER - || posControl.navState == NAV_STATE_FW_LANDING_APPROACH - || posControl.navState == NAV_STATE_FW_LANDING_GLIDE; + return FLIGHT_MODE(NAV_FW_AUTOLAND) && posControl.navState != NAV_STATE_FW_LANDING_FLARE; } #endif diff --git a/src/main/navigation/navigation.h b/src/main/navigation/navigation.h index 6ebdaeccead..19cc5022ed3 100644 --- a/src/main/navigation/navigation.h +++ b/src/main/navigation/navigation.h @@ -693,7 +693,7 @@ uint8_t getActiveWpNumber(void); int32_t navigationGetHomeHeading(void); #ifdef USE_FW_AUTOLAND -bool canFwLandCanceld(void); +bool canFwLandingBeCancelled(void); #endif /* Compatibility data */ diff --git a/src/main/navigation/navigation_private.h b/src/main/navigation/navigation_private.h index d716c58c496..bc5a1482894 100644 --- a/src/main/navigation/navigation_private.h +++ b/src/main/navigation/navigation_private.h @@ -165,16 +165,18 @@ typedef enum { NAV_FSM_EVENT_STATE_SPECIFIC_3, // State-specific event NAV_FSM_EVENT_STATE_SPECIFIC_4, // State-specific event NAV_FSM_EVENT_STATE_SPECIFIC_5, // State-specific event - NAV_FSM_EVENT_STATE_SPECIFIC_6, // State-specific event + + NAV_FSM_EVENT_SWITCH_TO_NAV_STATE_FW_LANDING_ABORT = NAV_FSM_EVENT_STATE_SPECIFIC_1, + NAV_FSM_EVENT_SWITCH_TO_NAV_STATE_FW_LANDING_FINISHED = NAV_FSM_EVENT_STATE_SPECIFIC_2, + NAV_FSM_EVENT_SWITCH_TO_WAYPOINT_HOLD_TIME = NAV_FSM_EVENT_STATE_SPECIFIC_1, + NAV_FSM_EVENT_SWITCH_TO_WAYPOINT_RTH_LAND = NAV_FSM_EVENT_STATE_SPECIFIC_2, + NAV_FSM_EVENT_SWITCH_TO_WAYPOINT_FINISHED = NAV_FSM_EVENT_STATE_SPECIFIC_3, + NAV_FSM_EVENT_SWITCH_TO_NAV_STATE_RTH_INITIALIZE = NAV_FSM_EVENT_STATE_SPECIFIC_1, + NAV_FSM_EVENT_SWITCH_TO_NAV_STATE_RTH_TRACKBACK = NAV_FSM_EVENT_STATE_SPECIFIC_2, NAV_FSM_EVENT_SWITCH_TO_RTH_HEAD_HOME = NAV_FSM_EVENT_STATE_SPECIFIC_3, - NAV_FSM_EVENT_SWITCH_TO_RTH_LANDING = NAV_FSM_EVENT_STATE_SPECIFIC_1, - NAV_FSM_EVENT_SWITCH_TO_WAYPOINT_RTH_LAND = NAV_FSM_EVENT_STATE_SPECIFIC_1, - NAV_FSM_EVENT_SWITCH_TO_WAYPOINT_FINISHED = NAV_FSM_EVENT_STATE_SPECIFIC_2, - NAV_FSM_EVENT_SWITCH_TO_WAYPOINT_HOLD_TIME = NAV_FSM_EVENT_STATE_SPECIFIC_3, NAV_FSM_EVENT_SWITCH_TO_RTH_HOVER_ABOVE_HOME = NAV_FSM_EVENT_STATE_SPECIFIC_4, - NAV_FSM_EVENT_SWITCH_TO_NAV_STATE_RTH_TRACKBACK = NAV_FSM_EVENT_STATE_SPECIFIC_5, - NAV_FSM_EVENT_SWITCH_TO_NAV_STATE_RTH_INITIALIZE = NAV_FSM_EVENT_STATE_SPECIFIC_6, - NAV_FSM_EVENT_SWITCH_TO_NAV_STATE_FW_LANDING_ABORT = NAV_FSM_EVENT_STATE_SPECIFIC_6, + NAV_FSM_EVENT_SWITCH_TO_RTH_LANDING = NAV_FSM_EVENT_STATE_SPECIFIC_5, + NAV_FSM_EVENT_COUNT, } navigationFSMEvent_t; @@ -241,6 +243,7 @@ typedef enum { NAV_PERSISTENT_ID_FW_LANDING_GLIDE = 45, NAV_PERSISTENT_ID_FW_LANDING_FLARE = 46, NAV_PERSISTENT_ID_FW_LANDING_ABORT = 47, + NAV_PERSISTENT_ID_FW_LANDING_FINISHED = 48, } navigationPersistentId_e; typedef enum { @@ -287,12 +290,13 @@ typedef enum { NAV_STATE_CRUISE_INITIALIZE, NAV_STATE_CRUISE_IN_PROGRESS, NAV_STATE_CRUISE_ADJUSTING, - + NAV_STATE_FW_LANDING_CLIMB_TO_LOITER, NAV_STATE_FW_LANDING_LOITER, NAV_STATE_FW_LANDING_APPROACH, NAV_STATE_FW_LANDING_GLIDE, NAV_STATE_FW_LANDING_FLARE, + NAV_STATE_FW_LANDING_FINISHED, NAV_STATE_FW_LANDING_ABORT, NAV_STATE_MIXERAT_INITIALIZE, From 81b1f03325698313be0f167318b406d144a3ffc6 Mon Sep 17 00:00:00 2001 From: Marcelo Bezerra <23555060+mmosca@users.noreply.github.com> Date: Sat, 13 Apr 2024 23:48:29 +0200 Subject: [PATCH 184/241] Use 2 bits for msp displayport font page --- src/main/io/displayport_msp_bf_compat.c | 2 +- src/main/io/displayport_msp_osd.c | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/main/io/displayport_msp_bf_compat.c b/src/main/io/displayport_msp_bf_compat.c index 7067ac140f5..4219d2b2db8 100644 --- a/src/main/io/displayport_msp_bf_compat.c +++ b/src/main/io/displayport_msp_bf_compat.c @@ -27,7 +27,7 @@ uint8_t getBfCharacter(uint8_t ch, uint8_t page) { - uint16_t ech = ch | (page << 8); + uint16_t ech = ch | ((page & 0x3)<< 8) ; if (ech >= 0x20 && ech <= 0x5F) { // ASCII range return ch; diff --git a/src/main/io/displayport_msp_osd.c b/src/main/io/displayport_msp_osd.c index e1e6cb29676..56dbc723439 100644 --- a/src/main/io/displayport_msp_osd.c +++ b/src/main/io/displayport_msp_osd.c @@ -100,7 +100,7 @@ static timeMs_t sendSubFrameMs = 0; static uint8_t currentOsdMode; // HDZero screen mode can change across layouts static uint8_t screen[SCREENSIZE]; -static BITARRAY_DECLARE(fontPage, SCREENSIZE); // font page for each character on the screen +static uint8_t fontPage[SCREENSIZE]; // font page for each character on the screen static BITARRAY_DECLARE(dirty, SCREENSIZE); // change status for each character on the screen static BITARRAY_DECLARE(blinkChar, SCREENSIZE); // Does the character blink? static bool screenCleared; @@ -171,7 +171,7 @@ static int setDisplayMode(displayPort_t *displayPort) static void init(void) { memset(screen, SYM_BLANK, sizeof(screen)); - BITARRAY_CLR_ALL(fontPage); + memset(fontPage, 0, sizeof(fontPage)); BITARRAY_CLR_ALL(dirty); BITARRAY_CLR_ALL(blinkChar); } @@ -204,9 +204,8 @@ static bool readChar(displayPort_t *displayPort, uint8_t col, uint8_t row, uint1 } *c = screen[pos]; - if (bitArrayGet(fontPage, pos)) { - *c |= 0x100; - } + uint8_t page = fontPage[pos]; + *c |= (page & 0x3) << 8; if (attr) { *attr = TEXT_ATTRIBUTES_NONE; @@ -219,10 +218,10 @@ static int setChar(const uint16_t pos, const uint16_t c, textAttributes_t attr) { if (pos < SCREENSIZE) { uint8_t ch = c & 0xFF; - bool page = (c >> 8); - if (screen[pos] != ch || bitArrayGet(fontPage, pos) != page) { + uint8_t page = (c >> 8) & 0x3; + if (screen[pos] != ch || fontPage[pos] != page) { screen[pos] = ch; - (page) ? bitArraySet(fontPage, pos) : bitArrayClr(fontPage, pos); + fontPage[pos] = page & 0x3; (TEXT_ATTRIBUTES_HAVE_BLINK(attr)) ? bitArraySet(blinkChar, pos) : bitArrayClr(blinkChar, pos); bitArraySet(dirty, pos); } @@ -287,7 +286,7 @@ static int drawScreen(displayPort_t *displayPort) // 250Hz uint8_t col = pos % COLS; uint8_t attributes = 0; int endOfLine = row * COLS + screenCols; - bool page = bitArrayGet(fontPage, pos); + uint8_t page = fontPage[pos]; bool blink = bitArrayGet(blinkChar, pos); uint8_t len = 4; @@ -299,7 +298,7 @@ static int drawScreen(displayPort_t *displayPort) // 250Hz if (bitArrayGet(dirty, pos)) { next = pos; } - } while (next == pos && next < endOfLine && bitArrayGet(fontPage, next) == page && bitArrayGet(blinkChar, next) == blink); + } while (next == pos && next < endOfLine && fontPage[next] == page && bitArrayGet(blinkChar, next) == blink); if (!isBfCompatibleVideoSystem(osdConfig())) { attributes |= (page << DISPLAYPORT_MSP_ATTR_FONTPAGE); From 9da168d5dcc6339eb8cc105b93ec2c6e46c3c6ea Mon Sep 17 00:00:00 2001 From: Marcelo Bezerra <23555060+mmosca@users.noreply.github.com> Date: Sun, 14 Apr 2024 16:12:38 +0200 Subject: [PATCH 185/241] Merge blink bitarry into attr array --- src/main/io/displayport_msp_osd.c | 41 +++++++++++++++++++++---------- src/main/io/displayport_msp_osd.h | 20 ++++++++++++--- 2 files changed, 44 insertions(+), 17 deletions(-) diff --git a/src/main/io/displayport_msp_osd.c b/src/main/io/displayport_msp_osd.c index 56dbc723439..ab88ec661fb 100644 --- a/src/main/io/displayport_msp_osd.c +++ b/src/main/io/displayport_msp_osd.c @@ -100,9 +100,8 @@ static timeMs_t sendSubFrameMs = 0; static uint8_t currentOsdMode; // HDZero screen mode can change across layouts static uint8_t screen[SCREENSIZE]; -static uint8_t fontPage[SCREENSIZE]; // font page for each character on the screen +static uint8_t attrs[SCREENSIZE]; // font page for each character on the screen static BITARRAY_DECLARE(dirty, SCREENSIZE); // change status for each character on the screen -static BITARRAY_DECLARE(blinkChar, SCREENSIZE); // Does the character blink? static bool screenCleared; static uint8_t screenRows, screenCols; static videoSystem_e osdVideoSystem; @@ -158,6 +157,22 @@ static uint8_t determineHDZeroOsdMode(void) return HD_3016; } + +uint8_t setAttrPage(uint8_t origAttr, uint8_t page) +{ + return (origAttr & ~DISPLAYPORT_MSP_ATTR_FONTPAGE_MASK) | (page & DISPLAYPORT_MSP_ATTR_FONTPAGE_MASK); +} + +uint8_t setAttrBlink(uint8_t origAttr, uint8_t blink) +{ + return (origAttr & ~DISPLAYPORT_MSP_ATTR_BLINK_MASK) | ((blink << DISPLAYPORT_MSP_ATTR_BLINK) & DISPLAYPORT_MSP_ATTR_BLINK_MASK); +} + +uint8_t setAttrVersion(uint8_t origAttr, uint8_t version) +{ + return (origAttr & ~DISPLAYPORT_MSP_ATTR_VERSION_MASK) | ((version << DISPLAYPORT_MSP_ATTR_VERSION) & DISPLAYPORT_MSP_ATTR_VERSION_MASK); +} + static int setDisplayMode(displayPort_t *displayPort) { if (osdVideoSystem == VIDEO_SYSTEM_HDZERO) { @@ -171,9 +186,8 @@ static int setDisplayMode(displayPort_t *displayPort) static void init(void) { memset(screen, SYM_BLANK, sizeof(screen)); - memset(fontPage, 0, sizeof(fontPage)); + memset(attrs, 0, sizeof(attrs)); BITARRAY_CLR_ALL(dirty); - BITARRAY_CLR_ALL(blinkChar); } static int clearScreen(displayPort_t *displayPort) @@ -204,8 +218,8 @@ static bool readChar(displayPort_t *displayPort, uint8_t col, uint8_t row, uint1 } *c = screen[pos]; - uint8_t page = fontPage[pos]; - *c |= (page & 0x3) << 8; + uint8_t page = getAttrPage(attrs[pos]); + *c |= page << 8; if (attr) { *attr = TEXT_ATTRIBUTES_NONE; @@ -218,11 +232,12 @@ static int setChar(const uint16_t pos, const uint16_t c, textAttributes_t attr) { if (pos < SCREENSIZE) { uint8_t ch = c & 0xFF; - uint8_t page = (c >> 8) & 0x3; - if (screen[pos] != ch || fontPage[pos] != page) { + uint8_t page = (c >> 8) & DISPLAYPORT_MSP_ATTR_FONTPAGE_MASK; + if (screen[pos] != ch || getAttrPage(attrs[pos]) != page) { screen[pos] = ch; - fontPage[pos] = page & 0x3; - (TEXT_ATTRIBUTES_HAVE_BLINK(attr)) ? bitArraySet(blinkChar, pos) : bitArrayClr(blinkChar, pos); + attrs[pos] = setAttrPage(attrs[pos], page); + uint8_t blink = (TEXT_ATTRIBUTES_HAVE_BLINK(attr)) ? 1 : 0; + attrs[pos] = setAttrBlink(attrs[pos], blink); bitArraySet(dirty, pos); } } @@ -286,8 +301,8 @@ static int drawScreen(displayPort_t *displayPort) // 250Hz uint8_t col = pos % COLS; uint8_t attributes = 0; int endOfLine = row * COLS + screenCols; - uint8_t page = fontPage[pos]; - bool blink = bitArrayGet(blinkChar, pos); + uint8_t page = getAttrPage(attrs[pos]); + uint8_t blink = getAttrBlink(attrs[pos]); uint8_t len = 4; do { @@ -298,7 +313,7 @@ static int drawScreen(displayPort_t *displayPort) // 250Hz if (bitArrayGet(dirty, pos)) { next = pos; } - } while (next == pos && next < endOfLine && fontPage[next] == page && bitArrayGet(blinkChar, next) == blink); + } while (next == pos && next < endOfLine && getAttrPage(attrs[next]) == page && getAttrBlink(attrs[next]) == blink); if (!isBfCompatibleVideoSystem(osdConfig())) { attributes |= (page << DISPLAYPORT_MSP_ATTR_FONTPAGE); diff --git a/src/main/io/displayport_msp_osd.h b/src/main/io/displayport_msp_osd.h index 0a2f64c48a2..affd5b39be5 100644 --- a/src/main/io/displayport_msp_osd.h +++ b/src/main/io/displayport_msp_osd.h @@ -27,13 +27,25 @@ #include "drivers/osd.h" #include "msp/msp_serial.h" +// MSP displayport V2 attribute byte bit functions +#define DISPLAYPORT_MSP_ATTR_FONTPAGE 0 // Select bank of 256 characters as per displayPortSeverity_e +#define DISPLAYPORT_MSP_ATTR_BLINK 6 // Device local blink +#define DISPLAYPORT_MSP_ATTR_VERSION 7 // Format indicator; must be zero for V2 (and V1) + +#define DISPLAYPORT_MSP_ATTR_FONTPAGE_MASK 0x3 +#define DISPLAYPORT_MSP_ATTR_BLINK_MASK (1 << DISPLAYPORT_MSP_ATTR_BLINK) +#define DISPLAYPORT_MSP_ATTR_VERSION_MASK (1 << DISPLAYPORT_MSP_ATTR_VERSION) + typedef struct displayPort_s displayPort_t; displayPort_t *mspOsdDisplayPortInit(const videoSystem_e videoSystem); void mspOsdSerialProcess(mspProcessCommandFnPtr mspProcessCommandFn); mspPort_t *getMspOsdPort(void); -// MSP displayport V2 attribute byte bit functions -#define DISPLAYPORT_MSP_ATTR_FONTPAGE 0 // Select bank of 256 characters as per displayPortSeverity_e -#define DISPLAYPORT_MSP_ATTR_BLINK 6 // Device local blink -#define DISPLAYPORT_MSP_ATTR_VERSION 7 // Format indicator; must be zero for V2 (and V1) \ No newline at end of file +#define getAttrPage(attr) (attr & DISPLAYPORT_MSP_ATTR_FONTPAGE_MASK) +#define getAttrBlink(attr) ((attr & DISPLAYPORT_MSP_ATTR_BLINK_MASK) >> DISPLAYPORT_MSP_ATTR_BLINK) +#define getAttrVersion(attr) ((attr & DISPLAYPORT_MSP_ATTR_VERSION_MASK) >> DISPLAYPORT_MSP_ATTR_VERSION) + +uint8_t setAttrPage(uint8_t origAttr, uint8_t page); +uint8_t setAttrBlink(uint8_t origAttr, uint8_t page); +uint8_t setAttrVersion(uint8_t origAttr, uint8_t page); \ No newline at end of file From 1ee021b5a8cf3dc83afe52347ea6ef8ec71922a6 Mon Sep 17 00:00:00 2001 From: Marcelo Bezerra <23555060+mmosca@users.noreply.github.com> Date: Sun, 14 Apr 2024 16:16:58 +0200 Subject: [PATCH 186/241] Formating changes --- src/main/io/displayport_msp_osd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/io/displayport_msp_osd.c b/src/main/io/displayport_msp_osd.c index ab88ec661fb..c9372d9fbf9 100644 --- a/src/main/io/displayport_msp_osd.c +++ b/src/main/io/displayport_msp_osd.c @@ -59,7 +59,7 @@ typedef enum { // defines are from hdzero code SD_3016, HD_5018, HD_3016, // Special HDZERO mode that just sends the centre 30x16 of the 50x18 canvas to the VRX - HD_6022, // added to support DJI wtfos 60x22 grid + HD_6022, // added to support DJI wtfos 60x22 grid HD_5320 // added to support Avatar and BetaflightHD } resolutionType_e; @@ -97,11 +97,11 @@ static timeMs_t sendSubFrameMs = 0; // set screen size #define SCREENSIZE (ROWS*COLS) -static uint8_t currentOsdMode; // HDZero screen mode can change across layouts +static uint8_t currentOsdMode; // HDZero screen mode can change across layouts static uint8_t screen[SCREENSIZE]; -static uint8_t attrs[SCREENSIZE]; // font page for each character on the screen -static BITARRAY_DECLARE(dirty, SCREENSIZE); // change status for each character on the screen +static uint8_t attrs[SCREENSIZE]; // font page, blink and other attributes +static BITARRAY_DECLARE(dirty, SCREENSIZE); // change status for each character on the screen static bool screenCleared; static uint8_t screenRows, screenCols; static videoSystem_e osdVideoSystem; From 1134c4541477b87b5264476fa056fd9528583a47 Mon Sep 17 00:00:00 2001 From: breadoven <56191411+breadoven@users.noreply.github.com> Date: Mon, 15 Apr 2024 15:40:10 +0100 Subject: [PATCH 187/241] Update osd.c --- src/main/io/osd.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index f0cc50bbaa1..f06845c3662 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -1003,7 +1003,7 @@ static const char * divertingToSafehomeMessage(void) return OSD_MESSAGE_STR(OSD_MSG_DIVERT_SAFEHOME); } #endif - return NULL; + return NULL; } @@ -1028,7 +1028,7 @@ static const char * navigationStateMessage(void) linearDescentMessageMs = millis() + 5000; // Show message for 5 seconds. return OSD_MESSAGE_STR(OSD_MSG_RTH_LINEAR_DESCENT); - } else + } else return OSD_MESSAGE_STR(OSD_MSG_HEADING_HOME); } case MW_NAV_STATE_HOLD_INFINIT: @@ -1069,7 +1069,7 @@ static const char * navigationStateMessage(void) // If there is a FS landing delay occurring. That is handled by the calling function. if (posControl.landingDelay > 0) break; - + return OSD_MESSAGE_STR(OSD_MSG_PREPARING_LAND); } case MW_NAV_STATE_LAND_START_DESCENT: @@ -2277,7 +2277,7 @@ static bool osdDrawSingleElement(uint8_t item) { char *p = "ACRO"; #ifdef USE_FW_AUTOLAND - if (FLIGHT_MODE(NAV_FW_AUTOLAND)) + if (FLIGHT_MODE(NAV_FW_AUTOLAND)) p = "LAND"; else #endif @@ -4864,6 +4864,7 @@ static void osdRefresh(timeUs_t currentTimeUs) static uint8_t statsCurrentPage = 0; static bool statsDisplayed = false; static bool statsAutoPagingEnabled = true; + static bool throttleHigh = false; // Detect arm/disarm if (armState != ARMING_FLAG(ARMED)) { @@ -4889,6 +4890,7 @@ static void osdRefresh(timeUs_t currentTimeUs) statsAutoPagingEnabled = osdConfig()->stats_page_auto_swap_time > 0 ? true : false; osdShowStats(statsSinglePageCompatible, statsCurrentPage); osdSetNextRefreshIn(STATS_SCREEN_DISPLAY_TIME); + throttleHigh = checkStickPosition(THR_HI); } armState = ARMING_FLAG(ARMED); @@ -4954,7 +4956,7 @@ static void osdRefresh(timeUs_t currentTimeUs) } // Handle events when either "Splash", "Armed" or "Stats" screens are displayed. - if ((currentTimeUs > resumeRefreshAt) || OSD_RESUME_UPDATES_STICK_COMMAND) { + if (currentTimeUs > resumeRefreshAt || (OSD_RESUME_UPDATES_STICK_COMMAND && !throttleHigh)) { // Time elapsed or canceled by stick commands. // Exit to normal OSD operation. displayClearScreen(osdDisplayPort); @@ -4963,6 +4965,7 @@ static void osdRefresh(timeUs_t currentTimeUs) } else { // Continue "Splash", "Armed" or "Stats" screens. displayHeartbeat(osdDisplayPort); + throttleHigh = checkStickPosition(THR_HI); } return; @@ -5177,7 +5180,7 @@ textAttributes_t osdGetSystemMessage(char *buff, size_t buff_size, bool isCenter tfp_sprintf(messageBuf, "LANDING DELAY: %3u SECONDS", remainingHoldSec); messages[messageCount++] = messageBuf; - } + } else { #ifdef USE_FW_AUTOLAND From d00780a3b898d38eae90960bf69122f91874af3c Mon Sep 17 00:00:00 2001 From: breadoven <56191411+breadoven@users.noreply.github.com> Date: Mon, 15 Apr 2024 16:04:18 +0100 Subject: [PATCH 188/241] Update blackbox.c --- src/main/blackbox/blackbox.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/blackbox/blackbox.c b/src/main/blackbox/blackbox.c index 453b8fda0cc..1bb0165761e 100644 --- a/src/main/blackbox/blackbox.c +++ b/src/main/blackbox/blackbox.c @@ -1308,10 +1308,16 @@ static void writeSlowFrame(void) static void loadSlowState(blackboxSlowState_t *slow) { memcpy(&slow->flightModeFlags, &rcModeActivationMask, sizeof(slow->flightModeFlags)); //was flightModeFlags; - // Also log Nav auto selected flight modes rather than just those selected by boxmode - if (!IS_RC_MODE_ACTIVE(BOXANGLE) && FLIGHT_MODE(ANGLE_MODE)) { + // Also log Nav auto enabled flight modes rather than just those selected by boxmode + if (FLIGHT_MODE(ANGLE_MODE)) { slow->flightModeFlags |= (1 << BOXANGLE); } + if (FLIGHT_MODE(NAV_ALTHOLD_MODE)) { + slow->flightModeFlags |= (1 << BOXNAVALTHOLD); + } + if (FLIGHT_MODE(NAV_RTH_MODE)) { + slow->flightModeFlags |= (1 << BOXNAVRTH); + } if (navigationGetHeadingControlState() == NAV_HEADING_CONTROL_AUTO) { slow->flightModeFlags |= (1 << BOXHEADINGHOLD); } From eb8843bc9c190650c21b3ec10964c1ed96ea8296 Mon Sep 17 00:00:00 2001 From: breadoven <56191411+breadoven@users.noreply.github.com> Date: Mon, 15 Apr 2024 18:09:06 +0100 Subject: [PATCH 189/241] changes --- src/main/fc/fc_core.c | 4 + src/main/navigation/navigation.c | 159 +++++++++++------------ src/main/navigation/navigation_private.h | 19 +-- 3 files changed, 87 insertions(+), 95 deletions(-) diff --git a/src/main/fc/fc_core.c b/src/main/fc/fc_core.c index 0d0863760de..0c8daea2ca8 100644 --- a/src/main/fc/fc_core.c +++ b/src/main/fc/fc_core.c @@ -350,6 +350,10 @@ static void updateArmingStatus(void) DISABLE_ARMING_FLAG(ARMING_DISABLED_NO_PREARM); } + if (ARMING_FLAG(ARMING_DISABLED_LANDING_DETECTED) && !IS_RC_MODE_ACTIVE(BOXARM)) { + DISABLE_ARMING_FLAG(ARMING_DISABLED_LANDING_DETECTED); + } + /* CHECK: Arming switch */ // If arming is disabled and the ARM switch is on // Note that this should be last check so all other blockers could be cleared correctly diff --git a/src/main/navigation/navigation.c b/src/main/navigation/navigation.c index 9e81024c3af..d2a5732de79 100644 --- a/src/main/navigation/navigation.c +++ b/src/main/navigation/navigation.c @@ -328,8 +328,8 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_INITIALIZE(navigati static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_CLIMB_TO_SAFE_ALT(navigationFSMState_t previousState); static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_TRACKBACK(navigationFSMState_t previousState); static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_HEAD_HOME(navigationFSMState_t previousState); -static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_HOVER_PRIOR_TO_LANDING(navigationFSMState_t previousState); -static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_HOVER_ABOVE_HOME(navigationFSMState_t previousState); +static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_LOITER_PRIOR_TO_LANDING(navigationFSMState_t previousState); +static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_LOITER_ABOVE_HOME(navigationFSMState_t previousState); static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_LANDING(navigationFSMState_t previousState); static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_FINISHING(navigationFSMState_t previousState); static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_FINISHED(navigationFSMState_t previousState); @@ -423,7 +423,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_POSHOLD_3D_INITIALIZE, .onEntry = navOnEnteringState_NAV_STATE_POSHOLD_3D_INITIALIZE, .timeoutMs = 0, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_REQUIRE_ANGLE | NAV_REQUIRE_THRTILT, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_HOLD | NAV_REQUIRE_ANGLE | NAV_REQUIRE_THRTILT, .mapToFlightModes = NAV_ALTHOLD_MODE | NAV_POSHOLD_MODE, .mwState = MW_NAV_STATE_HOLD_INFINIT, .mwError = MW_NAV_ERROR_NONE, @@ -438,7 +438,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_POSHOLD_3D_IN_PROGRESS, .onEntry = navOnEnteringState_NAV_STATE_POSHOLD_3D_IN_PROGRESS, .timeoutMs = 10, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_REQUIRE_ANGLE | NAV_REQUIRE_THRTILT | NAV_RC_ALT | NAV_RC_POS | NAV_RC_YAW, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_HOLD | NAV_REQUIRE_ANGLE | NAV_REQUIRE_THRTILT | NAV_RC_ALT | NAV_RC_POS | NAV_RC_YAW, .mapToFlightModes = NAV_ALTHOLD_MODE | NAV_POSHOLD_MODE, .mwState = MW_NAV_STATE_HOLD_INFINIT, .mwError = MW_NAV_ERROR_NONE, @@ -585,7 +585,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { [NAV_FSM_EVENT_SUCCESS] = NAV_STATE_RTH_CLIMB_TO_SAFE_ALT, [NAV_FSM_EVENT_SWITCH_TO_NAV_STATE_RTH_TRACKBACK] = NAV_STATE_RTH_TRACKBACK, [NAV_FSM_EVENT_SWITCH_TO_EMERGENCY_LANDING] = NAV_STATE_EMERGENCY_LANDING_INITIALIZE, - [NAV_FSM_EVENT_SWITCH_TO_RTH_LANDING] = NAV_STATE_RTH_HOVER_PRIOR_TO_LANDING, + [NAV_FSM_EVENT_SWITCH_TO_RTH_LANDING] = NAV_STATE_RTH_LOITER_PRIOR_TO_LANDING, [NAV_FSM_EVENT_SWITCH_TO_IDLE] = NAV_STATE_IDLE, } }, @@ -594,7 +594,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_RTH_CLIMB_TO_SAFE_ALT, .onEntry = navOnEnteringState_NAV_STATE_RTH_CLIMB_TO_SAFE_ALT, .timeoutMs = 10, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_RTH | NAV_RC_POS | NAV_RC_YAW, // allow pos adjustment while climbind to safe alt + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_HOLD | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_RTH | NAV_RC_POS | NAV_RC_YAW, // allow pos adjustment while climbind to safe alt .mapToFlightModes = NAV_RTH_MODE | NAV_ALTHOLD_MODE, .mwState = MW_NAV_STATE_RTH_CLIMB, .mwError = MW_NAV_ERROR_WAIT_FOR_RTH_ALT, @@ -634,13 +634,13 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_RTH_HEAD_HOME, .onEntry = navOnEnteringState_NAV_STATE_RTH_HEAD_HOME, .timeoutMs = 10, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_RTH | NAV_RC_POS | NAV_RC_YAW, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_HOLD | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_RTH | NAV_RC_POS | NAV_RC_YAW, .mapToFlightModes = NAV_RTH_MODE | NAV_ALTHOLD_MODE, .mwState = MW_NAV_STATE_RTH_ENROUTE, .mwError = MW_NAV_ERROR_NONE, .onEvent = { [NAV_FSM_EVENT_TIMEOUT] = NAV_STATE_RTH_HEAD_HOME, // re-process the state - [NAV_FSM_EVENT_SUCCESS] = NAV_STATE_RTH_HOVER_PRIOR_TO_LANDING, + [NAV_FSM_EVENT_SUCCESS] = NAV_STATE_RTH_LOITER_PRIOR_TO_LANDING, [NAV_FSM_EVENT_SWITCH_TO_IDLE] = NAV_STATE_IDLE, [NAV_FSM_EVENT_SWITCH_TO_ALTHOLD] = NAV_STATE_ALTHOLD_INITIALIZE, [NAV_FSM_EVENT_SWITCH_TO_POSHOLD_3D] = NAV_STATE_POSHOLD_3D_INITIALIZE, @@ -651,37 +651,37 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { } }, - [NAV_STATE_RTH_HOVER_PRIOR_TO_LANDING] = { - .persistentId = NAV_PERSISTENT_ID_RTH_HOVER_PRIOR_TO_LANDING, - .onEntry = navOnEnteringState_NAV_STATE_RTH_HOVER_PRIOR_TO_LANDING, + [NAV_STATE_RTH_LOITER_PRIOR_TO_LANDING] = { + .persistentId = NAV_PERSISTENT_ID_RTH_LOITER_PRIOR_TO_LANDING, + .onEntry = navOnEnteringState_NAV_STATE_RTH_LOITER_PRIOR_TO_LANDING, .timeoutMs = 500, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_RTH | NAV_RC_POS | NAV_RC_YAW, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_HOLD | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_RTH | NAV_RC_POS | NAV_RC_YAW, .mapToFlightModes = NAV_RTH_MODE | NAV_ALTHOLD_MODE, .mwState = MW_NAV_STATE_LAND_SETTLE, .mwError = MW_NAV_ERROR_NONE, .onEvent = { - [NAV_FSM_EVENT_TIMEOUT] = NAV_STATE_RTH_HOVER_PRIOR_TO_LANDING, - [NAV_FSM_EVENT_SUCCESS] = NAV_STATE_RTH_LANDING, - [NAV_FSM_EVENT_SWITCH_TO_RTH_HOVER_ABOVE_HOME] = NAV_STATE_RTH_HOVER_ABOVE_HOME, - [NAV_FSM_EVENT_SWITCH_TO_IDLE] = NAV_STATE_IDLE, - [NAV_FSM_EVENT_SWITCH_TO_ALTHOLD] = NAV_STATE_ALTHOLD_INITIALIZE, - [NAV_FSM_EVENT_SWITCH_TO_POSHOLD_3D] = NAV_STATE_POSHOLD_3D_INITIALIZE, - [NAV_FSM_EVENT_SWITCH_TO_EMERGENCY_LANDING] = NAV_STATE_EMERGENCY_LANDING_INITIALIZE, - [NAV_FSM_EVENT_SWITCH_TO_COURSE_HOLD] = NAV_STATE_COURSE_HOLD_INITIALIZE, - [NAV_FSM_EVENT_SWITCH_TO_CRUISE] = NAV_STATE_CRUISE_INITIALIZE, + [NAV_FSM_EVENT_TIMEOUT] = NAV_STATE_RTH_LOITER_PRIOR_TO_LANDING, + [NAV_FSM_EVENT_SUCCESS] = NAV_STATE_RTH_LANDING, + [NAV_FSM_EVENT_SWITCH_TO_RTH_LOITER_ABOVE_HOME] = NAV_STATE_RTH_LOITER_ABOVE_HOME, + [NAV_FSM_EVENT_SWITCH_TO_IDLE] = NAV_STATE_IDLE, + [NAV_FSM_EVENT_SWITCH_TO_ALTHOLD] = NAV_STATE_ALTHOLD_INITIALIZE, + [NAV_FSM_EVENT_SWITCH_TO_POSHOLD_3D] = NAV_STATE_POSHOLD_3D_INITIALIZE, + [NAV_FSM_EVENT_SWITCH_TO_EMERGENCY_LANDING] = NAV_STATE_EMERGENCY_LANDING_INITIALIZE, + [NAV_FSM_EVENT_SWITCH_TO_COURSE_HOLD] = NAV_STATE_COURSE_HOLD_INITIALIZE, + [NAV_FSM_EVENT_SWITCH_TO_CRUISE] = NAV_STATE_CRUISE_INITIALIZE, } }, - [NAV_STATE_RTH_HOVER_ABOVE_HOME] = { - .persistentId = NAV_PERSISTENT_ID_RTH_HOVER_ABOVE_HOME, - .onEntry = navOnEnteringState_NAV_STATE_RTH_HOVER_ABOVE_HOME, + [NAV_STATE_RTH_LOITER_ABOVE_HOME] = { + .persistentId = NAV_PERSISTENT_ID_RTH_LOITER_ABOVE_HOME, + .onEntry = navOnEnteringState_NAV_STATE_RTH_LOITER_ABOVE_HOME, .timeoutMs = 10, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_RTH | NAV_RC_POS | NAV_RC_YAW | NAV_RC_ALT, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_HOLD | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_RTH | NAV_RC_POS | NAV_RC_YAW | NAV_RC_ALT, .mapToFlightModes = NAV_RTH_MODE | NAV_ALTHOLD_MODE, .mwState = MW_NAV_STATE_HOVER_ABOVE_HOME, .mwError = MW_NAV_ERROR_NONE, .onEvent = { - [NAV_FSM_EVENT_TIMEOUT] = NAV_STATE_RTH_HOVER_ABOVE_HOME, + [NAV_FSM_EVENT_TIMEOUT] = NAV_STATE_RTH_LOITER_ABOVE_HOME, [NAV_FSM_EVENT_SWITCH_TO_IDLE] = NAV_STATE_IDLE, [NAV_FSM_EVENT_SWITCH_TO_ALTHOLD] = NAV_STATE_ALTHOLD_INITIALIZE, [NAV_FSM_EVENT_SWITCH_TO_POSHOLD_3D] = NAV_STATE_POSHOLD_3D_INITIALIZE, @@ -695,20 +695,20 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_RTH_LANDING, .onEntry = navOnEnteringState_NAV_STATE_RTH_LANDING, .timeoutMs = 10, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_LAND | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_RTH | NAV_RC_POS | NAV_RC_YAW, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_HOLD | NAV_CTL_LAND | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_RTH | NAV_RC_POS | NAV_RC_YAW, .mapToFlightModes = NAV_RTH_MODE | NAV_ALTHOLD_MODE, .mwState = MW_NAV_STATE_LAND_IN_PROGRESS, .mwError = MW_NAV_ERROR_LANDING, .onEvent = { - [NAV_FSM_EVENT_TIMEOUT] = NAV_STATE_RTH_LANDING, // re-process state - [NAV_FSM_EVENT_SUCCESS] = NAV_STATE_RTH_FINISHING, - [NAV_FSM_EVENT_SWITCH_TO_IDLE] = NAV_STATE_IDLE, - [NAV_FSM_EVENT_SWITCH_TO_ALTHOLD] = NAV_STATE_ALTHOLD_INITIALIZE, - [NAV_FSM_EVENT_SWITCH_TO_POSHOLD_3D] = NAV_STATE_POSHOLD_3D_INITIALIZE, - [NAV_FSM_EVENT_SWITCH_TO_EMERGENCY_LANDING] = NAV_STATE_EMERGENCY_LANDING_INITIALIZE, - [NAV_FSM_EVENT_SWITCH_TO_MIXERAT] = NAV_STATE_MIXERAT_INITIALIZE, - [NAV_FSM_EVENT_SWITCH_TO_NAV_STATE_FW_LANDING] = NAV_STATE_FW_LANDING_CLIMB_TO_LOITER, - [NAV_FSM_EVENT_SWITCH_TO_RTH_HOVER_ABOVE_HOME] = NAV_STATE_RTH_HOVER_ABOVE_HOME, + [NAV_FSM_EVENT_TIMEOUT] = NAV_STATE_RTH_LANDING, // re-process state + [NAV_FSM_EVENT_SUCCESS] = NAV_STATE_RTH_FINISHING, + [NAV_FSM_EVENT_SWITCH_TO_IDLE] = NAV_STATE_IDLE, + [NAV_FSM_EVENT_SWITCH_TO_ALTHOLD] = NAV_STATE_ALTHOLD_INITIALIZE, + [NAV_FSM_EVENT_SWITCH_TO_POSHOLD_3D] = NAV_STATE_POSHOLD_3D_INITIALIZE, + [NAV_FSM_EVENT_SWITCH_TO_EMERGENCY_LANDING] = NAV_STATE_EMERGENCY_LANDING_INITIALIZE, + [NAV_FSM_EVENT_SWITCH_TO_MIXERAT] = NAV_STATE_MIXERAT_INITIALIZE, + [NAV_FSM_EVENT_SWITCH_TO_NAV_STATE_FW_LANDING] = NAV_STATE_FW_LANDING_CLIMB_TO_LOITER, + [NAV_FSM_EVENT_SWITCH_TO_RTH_LOITER_ABOVE_HOME] = NAV_STATE_RTH_LOITER_ABOVE_HOME, } }, @@ -716,7 +716,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_RTH_FINISHING, .onEntry = navOnEnteringState_NAV_STATE_RTH_FINISHING, .timeoutMs = 0, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_LAND | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_RTH, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_HOLD | NAV_CTL_LAND | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_RTH, .mapToFlightModes = NAV_RTH_MODE | NAV_ALTHOLD_MODE, .mwState = MW_NAV_STATE_LAND_IN_PROGRESS, .mwError = MW_NAV_ERROR_LANDING, @@ -827,7 +827,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_WAYPOINT_HOLD_TIME, // There is no state for timed hold? .onEntry = navOnEnteringState_NAV_STATE_WAYPOINT_HOLD_TIME, .timeoutMs = 10, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_WP, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_HOLD | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_WP, .mapToFlightModes = NAV_WP_MODE | NAV_ALTHOLD_MODE, .mwState = MW_NAV_STATE_HOLD_TIMED, .mwError = MW_NAV_ERROR_NONE, @@ -848,7 +848,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_WAYPOINT_RTH_LAND, .onEntry = navOnEnteringState_NAV_STATE_WAYPOINT_RTH_LAND, .timeoutMs = 10, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_LAND | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_WP, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_HOLD | NAV_CTL_LAND | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_WP, .mapToFlightModes = NAV_WP_MODE | NAV_ALTHOLD_MODE, .mwState = MW_NAV_STATE_LAND_IN_PROGRESS, .mwError = MW_NAV_ERROR_LANDING, @@ -886,7 +886,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_WAYPOINT_FINISHED, .onEntry = navOnEnteringState_NAV_STATE_WAYPOINT_FINISHED, .timeoutMs = 10, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_WP | NAV_AUTO_WP_DONE, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_HOLD | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_WP | NAV_AUTO_WP_DONE, .mapToFlightModes = NAV_WP_MODE | NAV_ALTHOLD_MODE, .mwState = MW_NAV_STATE_WP_ENROUTE, .mwError = MW_NAV_ERROR_FINISH, @@ -907,7 +907,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_EMERGENCY_LANDING_INITIALIZE, .onEntry = navOnEnteringState_NAV_STATE_EMERGENCY_LANDING_INITIALIZE, .timeoutMs = 0, - .stateFlags = NAV_CTL_EMERG | NAV_REQUIRE_ANGLE, + .stateFlags = NAV_CTL_EMERG | NAV_CTL_HOLD | NAV_REQUIRE_ANGLE, .mapToFlightModes = 0, .mwState = MW_NAV_STATE_EMERGENCY_LANDING, .mwError = MW_NAV_ERROR_LANDING, @@ -925,7 +925,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_EMERGENCY_LANDING_IN_PROGRESS, .onEntry = navOnEnteringState_NAV_STATE_EMERGENCY_LANDING_IN_PROGRESS, .timeoutMs = 10, - .stateFlags = NAV_CTL_EMERG | NAV_REQUIRE_ANGLE, + .stateFlags = NAV_CTL_EMERG | NAV_CTL_HOLD | NAV_REQUIRE_ANGLE, .mapToFlightModes = 0, .mwState = MW_NAV_STATE_EMERGENCY_LANDING, .mwError = MW_NAV_ERROR_LANDING, @@ -943,7 +943,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_EMERGENCY_LANDING_FINISHED, .onEntry = navOnEnteringState_NAV_STATE_EMERGENCY_LANDING_FINISHED, .timeoutMs = 10, - .stateFlags = NAV_CTL_EMERG | NAV_REQUIRE_ANGLE, + .stateFlags = NAV_CTL_EMERG | NAV_CTL_HOLD | NAV_REQUIRE_ANGLE, .mapToFlightModes = 0, .mwState = MW_NAV_STATE_LANDED, .mwError = MW_NAV_ERROR_LANDING, @@ -1052,7 +1052,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_FW_LANDING_CLIMB_TO_LOITER, .onEntry = navOnEnteringState_NAV_STATE_FW_LANDING_CLIMB_TO_LOITER, .timeoutMs = 10, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_REQUIRE_ANGLE | NAV_AUTO_RTH, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_HOLD | NAV_REQUIRE_ANGLE | NAV_AUTO_RTH, .mapToFlightModes = NAV_FW_AUTOLAND, .mwState = MW_NAV_STATE_LAND_IN_PROGRESS, .mwError = MW_NAV_ERROR_NONE, @@ -1073,7 +1073,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_FW_LANDING_LOITER, .onEntry = navOnEnteringState_NAV_STATE_FW_LANDING_LOITER, .timeoutMs = 10, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_REQUIRE_ANGLE | NAV_AUTO_RTH, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_HOLD | NAV_REQUIRE_ANGLE | NAV_AUTO_RTH, .mapToFlightModes = NAV_FW_AUTOLAND, .mwState = MW_NAV_STATE_LAND_IN_PROGRESS, .mwError = MW_NAV_ERROR_NONE, @@ -1246,7 +1246,7 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_POSHOLD_3D_INITIALIZE(n } // Prepare position controller if idle or current Mode NOT active in position hold state - if (previousState != NAV_STATE_RTH_HOVER_PRIOR_TO_LANDING && previousState != NAV_STATE_RTH_HOVER_ABOVE_HOME && + if (previousState != NAV_STATE_RTH_LOITER_PRIOR_TO_LANDING && previousState != NAV_STATE_RTH_LOITER_ABOVE_HOME && previousState != NAV_STATE_RTH_LANDING && previousState != NAV_STATE_WAYPOINT_RTH_LAND && previousState != NAV_STATE_WAYPOINT_FINISHED && previousState != NAV_STATE_WAYPOINT_HOLD_TIME) { @@ -1427,7 +1427,7 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_INITIALIZE(navigati setHomePosition(&navGetCurrentActualPositionAndVelocity()->pos, posControl.actualState.yaw, NAV_POS_UPDATE_XY | NAV_POS_UPDATE_HEADING, NAV_HOME_VALID_ALL); setDesiredPosition(&navGetCurrentActualPositionAndVelocity()->pos, posControl.actualState.yaw, NAV_POS_UPDATE_XY | NAV_POS_UPDATE_Z | NAV_POS_UPDATE_HEADING); - return NAV_FSM_EVENT_SWITCH_TO_RTH_LANDING; // NAV_STATE_RTH_HOVER_PRIOR_TO_LANDING + return NAV_FSM_EVENT_SWITCH_TO_RTH_LANDING; // NAV_STATE_RTH_LOITER_PRIOR_TO_LANDING } else { // Switch to RTH trackback @@ -1501,8 +1501,9 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_CLIMB_TO_SAFE_ALT(n initializeRTHSanityChecker(); } - // Save initial home distance for future use + // Save initial home distance and direction for future use posControl.rthState.rthInitialDistance = posControl.homeDistance; + posControl.activeWaypoint.bearing = posControl.homeDirection; fpVector3_t * tmpHomePos = rthGetHomeTargetPosition(RTH_HOME_ENROUTE_INITIAL); if (navConfig()->general.flags.rth_tail_first && !STATE(FIXED_WING_LEGACY)) { @@ -1616,7 +1617,7 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_HEAD_HOME(navigatio if ((posControl.flags.estPosStatus >= EST_USABLE)) { fpVector3_t * tmpHomePos = rthGetHomeTargetPosition(RTH_HOME_ENROUTE_PROPORTIONAL); - if (isWaypointReached(tmpHomePos, 0)) { + if (isWaypointReached(tmpHomePos, &posControl.activeWaypoint.bearing)) { // Successfully reached position target - update XYZ-position setDesiredPosition(tmpHomePos, posControl.rthState.homePosition.heading, NAV_POS_UPDATE_XY | NAV_POS_UPDATE_Z | NAV_POS_UPDATE_HEADING); @@ -1625,7 +1626,7 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_HEAD_HOME(navigatio if (navConfig()->general.flags.rth_use_linear_descent && posControl.rthState.rthLinearDescentActive) posControl.rthState.rthLinearDescentActive = false; - return NAV_FSM_EVENT_SUCCESS; // NAV_STATE_RTH_HOVER_PRIOR_TO_LANDING + return NAV_FSM_EVENT_SUCCESS; // NAV_STATE_RTH_LOITER_PRIOR_TO_LANDING } else { setDesiredPosition(tmpHomePos, 0, NAV_POS_UPDATE_Z | NAV_POS_UPDATE_XY); return NAV_FSM_EVENT_NONE; @@ -1639,7 +1640,7 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_HEAD_HOME(navigatio return NAV_FSM_EVENT_NONE; } -static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_HOVER_PRIOR_TO_LANDING(navigationFSMState_t previousState) +static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_LOITER_PRIOR_TO_LANDING(navigationFSMState_t previousState) { UNUSED(previousState); @@ -1673,7 +1674,7 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_HOVER_PRIOR_TO_LAND if (!pauseLanding && ((ABS(wrap_18000(posControl.rthState.homePosition.heading - posControl.actualState.yaw)) < DEGREES_TO_CENTIDEGREES(15)) || STATE(FIXED_WING_LEGACY))) { resetLandingDetector(); // force reset landing detector just in case updateClimbRateToAltitudeController(0, 0, ROC_TO_ALT_RESET); - return navigationRTHAllowsLanding() ? NAV_FSM_EVENT_SUCCESS : NAV_FSM_EVENT_SWITCH_TO_RTH_HOVER_ABOVE_HOME; // success = land + return navigationRTHAllowsLanding() ? NAV_FSM_EVENT_SUCCESS : NAV_FSM_EVENT_SWITCH_TO_RTH_LOITER_ABOVE_HOME; // success = land } else { fpVector3_t * tmpHomePos = rthGetHomeTargetPosition(RTH_HOME_ENROUTE_FINAL); setDesiredPosition(tmpHomePos, posControl.rthState.homePosition.heading, NAV_POS_UPDATE_XY | NAV_POS_UPDATE_Z | NAV_POS_UPDATE_HEADING); @@ -1681,7 +1682,7 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_HOVER_PRIOR_TO_LAND } } -static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_HOVER_ABOVE_HOME(navigationFSMState_t previousState) +static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_LOITER_ABOVE_HOME(navigationFSMState_t previousState) { UNUSED(previousState); @@ -1690,7 +1691,7 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_HOVER_ABOVE_HOME(na return NAV_FSM_EVENT_SWITCH_TO_EMERGENCY_LANDING; } - fpVector3_t * tmpHomePos = rthGetHomeTargetPosition(RTH_HOME_FINAL_HOVER); + fpVector3_t * tmpHomePos = rthGetHomeTargetPosition(RTH_HOME_FINAL_LOITER); setDesiredPosition(tmpHomePos, 0, NAV_POS_UPDATE_Z); return NAV_FSM_EVENT_NONE; @@ -2046,9 +2047,9 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_WAYPOINT_RTH_LAND(navig #ifdef USE_FW_AUTOLAND if (landEvent == NAV_FSM_EVENT_SWITCH_TO_NAV_STATE_FW_LANDING) { return NAV_FSM_EVENT_SWITCH_TO_NAV_STATE_FW_LANDING; - } else + } else #endif - if (landEvent == NAV_FSM_EVENT_SWITCH_TO_RTH_HOVER_ABOVE_HOME) { + if (landEvent == NAV_FSM_EVENT_SWITCH_TO_RTH_LOITER_ABOVE_HOME) { return NAV_FSM_EVENT_SWITCH_TO_WAYPOINT_FINISHED; } else if (landEvent == NAV_FSM_EVENT_SUCCESS) { // Landing controller returned success - invoke RTH finishing state and finish the waypoint @@ -2567,7 +2568,7 @@ static fpVector3_t * rthGetHomeTargetPosition(rthTargetMode_e mode) posControl.rthState.homeTmpWaypoint.z = posControl.rthState.rthFinalAltitude; break; - case RTH_HOME_FINAL_HOVER: + case RTH_HOME_FINAL_LOITER: if (navConfig()->general.rth_home_altitude) { posControl.rthState.homeTmpWaypoint.z = posControl.rthState.homePosition.pos.z + navConfig()->general.rth_home_altitude; } @@ -2852,30 +2853,28 @@ static bool getLocalPosNextWaypoint(fpVector3_t * nextWpPos) /*----------------------------------------------------------- * Check if waypoint is/was reached. - * waypointBearing stores initial bearing to waypoint + * 'waypointBearing' stores initial bearing to waypoint. *-----------------------------------------------------------*/ static bool isWaypointReached(const fpVector3_t * waypointPos, const int32_t * waypointBearing) { posControl.wpDistance = calculateDistanceToDestination(waypointPos); - // Airplane will do a circular loiter at hold waypoints and might never approach them closer than waypoint_radius - // Check within 10% margin of circular loiter radius - if (STATE(AIRPLANE) && isNavHoldPositionActive() && posControl.wpDistance <= (navConfig()->fw.loiter_radius * 1.10f)) { - return true; - } + // Check if waypoint was missed based on bearing to WP exceeding given angular limit relative to initial waypoint bearing. + // Default angular limit = 100 degs with a reduced limit of 60 degs used if fixed wing waypoint turn smoothing option active + uint16_t relativeBearingErrorLimit = 10000; - if (navGetStateFlags(posControl.navState) & NAV_AUTO_WP || posControl.flags.rthTrackbackActive) { + if (STATE(AIRPLANE) && posControl.flags.wpTurnSmoothingActive) { // If WP turn smoothing CUT option used WP is reached when start of turn is initiated - if (navConfig()->fw.wp_turn_smoothing == WP_TURN_SMOOTHING_CUT && posControl.flags.wpTurnSmoothingActive) { + if (navConfig()->fw.wp_turn_smoothing == WP_TURN_SMOOTHING_CUT) { posControl.flags.wpTurnSmoothingActive = false; return true; } - // Check if waypoint was missed based on bearing to WP exceeding 100 degrees relative to waypoint Yaw - // Same method for turn smoothing option but relative bearing set at 60 degrees - uint16_t relativeBearing = posControl.flags.wpTurnSmoothingActive ? 6000 : 10000; - if (ABS(wrap_18000(calculateBearingToDestination(waypointPos) - *waypointBearing)) > relativeBearing) { - return true; - } + relativeBearingErrorLimit = 6000; + } + + + if (ABS(wrap_18000(calculateBearingToDestination(waypointPos) - *waypointBearing)) > relativeBearingErrorLimit) { + return true; } return posControl.wpDistance <= (navConfig()->general.waypoint_radius); @@ -3453,9 +3452,6 @@ void updateLandingStatus(timeMs_t currentTimeMs) } resetLandingDetector(); - if (!IS_RC_MODE_ACTIVE(BOXARM)) { - DISABLE_ARMING_FLAG(ARMING_DISABLED_LANDING_DETECTED); - } return; } @@ -4075,16 +4071,7 @@ bool isLastMissionWaypoint(void) /* Checks if Nav hold position is active */ bool isNavHoldPositionActive(void) { - // WP mode last WP hold and Timed hold positions - if (FLIGHT_MODE(NAV_WP_MODE)) { - return isLastMissionWaypoint() || NAV_Status.state == MW_NAV_STATE_HOLD_TIMED; - } - // RTH mode (spiral climb and Home positions but excluding RTH Trackback point positions) and POSHOLD mode - // Also hold position during emergency landing if position valid - return (FLIGHT_MODE(NAV_RTH_MODE) && !posControl.flags.rthTrackbackActive) || - FLIGHT_MODE(NAV_POSHOLD_MODE) || - (posControl.navState == NAV_STATE_FW_LANDING_CLIMB_TO_LOITER || posControl.navState == NAV_STATE_FW_LANDING_LOITER) || - navigationIsExecutingAnEmergencyLanding(); + return navGetCurrentStateFlags() & NAV_CTL_HOLD; } float getActiveSpeed(void) @@ -4123,7 +4110,7 @@ bool isWaypointNavTrackingActive(void) // is set from current position not previous WP. Works for WP Restart intermediate WP as well as first mission WP. // (NAV_WP_MODE flag isn't set until WP initialisation is finished, i.e. after calculateAndSetActiveWaypoint called) - return FLIGHT_MODE(NAV_WP_MODE) + return FLIGHT_MODE(NAV_WP_MODE) || posControl.navState == NAV_STATE_FW_LANDING_APPROACH || (posControl.flags.rthTrackbackActive && posControl.activeRthTBPointIndex != posControl.rthTBLastSavedIndex); } @@ -5011,7 +4998,7 @@ bool navigationRTHAllowsLanding(void) return false; } #endif - + // WP mission RTH landing setting if (isWaypointMissionRTHActive() && isWaypointMissionValid()) { return posControl.waypointList[posControl.startWpIndex + posControl.waypointCount - 1].p1 > 0; diff --git a/src/main/navigation/navigation_private.h b/src/main/navigation/navigation_private.h index d716c58c496..121597c93bc 100644 --- a/src/main/navigation/navigation_private.h +++ b/src/main/navigation/navigation_private.h @@ -171,7 +171,7 @@ typedef enum { NAV_FSM_EVENT_SWITCH_TO_WAYPOINT_RTH_LAND = NAV_FSM_EVENT_STATE_SPECIFIC_1, NAV_FSM_EVENT_SWITCH_TO_WAYPOINT_FINISHED = NAV_FSM_EVENT_STATE_SPECIFIC_2, NAV_FSM_EVENT_SWITCH_TO_WAYPOINT_HOLD_TIME = NAV_FSM_EVENT_STATE_SPECIFIC_3, - NAV_FSM_EVENT_SWITCH_TO_RTH_HOVER_ABOVE_HOME = NAV_FSM_EVENT_STATE_SPECIFIC_4, + NAV_FSM_EVENT_SWITCH_TO_RTH_LOITER_ABOVE_HOME = NAV_FSM_EVENT_STATE_SPECIFIC_4, NAV_FSM_EVENT_SWITCH_TO_NAV_STATE_RTH_TRACKBACK = NAV_FSM_EVENT_STATE_SPECIFIC_5, NAV_FSM_EVENT_SWITCH_TO_NAV_STATE_RTH_INITIALIZE = NAV_FSM_EVENT_STATE_SPECIFIC_6, NAV_FSM_EVENT_SWITCH_TO_NAV_STATE_FW_LANDING_ABORT = NAV_FSM_EVENT_STATE_SPECIFIC_6, @@ -197,7 +197,7 @@ typedef enum { NAV_PERSISTENT_ID_RTH_INITIALIZE = 8, NAV_PERSISTENT_ID_RTH_CLIMB_TO_SAFE_ALT = 9, NAV_PERSISTENT_ID_RTH_HEAD_HOME = 10, - NAV_PERSISTENT_ID_RTH_HOVER_PRIOR_TO_LANDING = 11, + NAV_PERSISTENT_ID_RTH_LOITER_PRIOR_TO_LANDING = 11, NAV_PERSISTENT_ID_RTH_LANDING = 12, NAV_PERSISTENT_ID_RTH_FINISHING = 13, NAV_PERSISTENT_ID_RTH_FINISHED = 14, @@ -228,7 +228,7 @@ typedef enum { NAV_PERSISTENT_ID_CRUISE_ADJUSTING = 34, NAV_PERSISTENT_ID_WAYPOINT_HOLD_TIME = 35, - NAV_PERSISTENT_ID_RTH_HOVER_ABOVE_HOME = 36, + NAV_PERSISTENT_ID_RTH_LOITER_ABOVE_HOME = 36, NAV_PERSISTENT_ID_UNUSED_4 = 37, // was NAV_STATE_WAYPOINT_HOVER_ABOVE_HOME NAV_PERSISTENT_ID_RTH_TRACKBACK = 38, @@ -258,8 +258,8 @@ typedef enum { NAV_STATE_RTH_CLIMB_TO_SAFE_ALT, NAV_STATE_RTH_TRACKBACK, NAV_STATE_RTH_HEAD_HOME, - NAV_STATE_RTH_HOVER_PRIOR_TO_LANDING, - NAV_STATE_RTH_HOVER_ABOVE_HOME, + NAV_STATE_RTH_LOITER_PRIOR_TO_LANDING, + NAV_STATE_RTH_LOITER_ABOVE_HOME, NAV_STATE_RTH_LANDING, NAV_STATE_RTH_FINISHING, NAV_STATE_RTH_FINISHED, @@ -287,7 +287,7 @@ typedef enum { NAV_STATE_CRUISE_INITIALIZE, NAV_STATE_CRUISE_IN_PROGRESS, NAV_STATE_CRUISE_ADJUSTING, - + NAV_STATE_FW_LANDING_CLIMB_TO_LOITER, NAV_STATE_FW_LANDING_LOITER, NAV_STATE_FW_LANDING_APPROACH, @@ -327,9 +327,10 @@ typedef enum { /* Additional flags */ NAV_CTL_LAND = (1 << 14), - NAV_AUTO_WP_DONE = (1 << 15), //Waypoint mission reached the last waypoint and is idling + NAV_AUTO_WP_DONE = (1 << 15), // Waypoint mission reached the last waypoint and is idling - NAV_MIXERAT = (1 << 16), //MIXERAT in progress + NAV_MIXERAT = (1 << 16), // MIXERAT in progress + NAV_CTL_HOLD = (1 << 17), // Nav loiter active at position or will be when position reached } navigationFSMStateFlags_t; typedef struct { @@ -396,7 +397,7 @@ typedef enum { RTH_HOME_ENROUTE_INITIAL, // Initial position for RTH approach RTH_HOME_ENROUTE_PROPORTIONAL, // Prorpotional position for RTH approach RTH_HOME_ENROUTE_FINAL, // Final position for RTH approach - RTH_HOME_FINAL_HOVER, // Final hover altitude (if rth_home_altitude is set) + RTH_HOME_FINAL_LOITER, // Final loiter altitude (if rth_home_altitude is set) RTH_HOME_FINAL_LAND, // Home position and altitude } rthTargetMode_e; From 537f1ffdb045b15ace7c236a5645029ce6577300 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Mon, 15 Apr 2024 21:06:00 +0200 Subject: [PATCH 190/241] Update deadband defaults --- src/main/fc/settings.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index ba443dc19d6..521f9bcf193 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -1668,12 +1668,12 @@ groups: members: - name: deadband description: "These are values (in us) by how much RC input can be different before it's considered valid. For transmitters with jitter on outputs, this value can be increased. Defaults are zero, but can be increased up to 10 or so if rc inputs twitch while idle." - default_value: 5 + default_value: 2 min: 0 max: 32 - name: yaw_deadband description: "These are values (in us) by how much RC input can be different before it's considered valid. For transmitters with jitter on outputs, this value can be increased. Defaults are zero, but can be increased up to 10 or so if rc inputs twitch while idle." - default_value: 5 + default_value: 2 min: 0 max: 100 - name: pos_hold_deadband From 032f61e4b151346bf51e78cc2e0e037be2ad4c3a Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Mon, 15 Apr 2024 21:30:39 +0200 Subject: [PATCH 191/241] enforce rx auto smoothing in ez tune --- .vscode/tasks.json | 8 ++++---- src/main/flight/ez_tune.c | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 3ca90b787d3..7be2cd3d176 100755 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -4,9 +4,9 @@ "version": "2.0.0", "tasks": [ { - "label": "Build Matek F722-SE", + "label": "Build AOCODARCH7DUAL", "type": "shell", - "command": "make MATEKF722SE", + "command": "make AOCODARCH7DUAL", "group": "build", "problemMatcher": [], "options": { @@ -14,9 +14,9 @@ } }, { - "label": "Build Matek F722", + "label": "Build AOCODARCH7DUAL", "type": "shell", - "command": "make MATEKF722", + "command": "make AOCODARCH7DUAL", "group": { "kind": "build", "isDefault": true diff --git a/src/main/flight/ez_tune.c b/src/main/flight/ez_tune.c index 128a108ccb0..050ad0735d9 100644 --- a/src/main/flight/ez_tune.c +++ b/src/main/flight/ez_tune.c @@ -34,6 +34,8 @@ #include "sensors/gyro.h" #include "fc/controlrate_profile.h" +#include "rx/rx.h" + PG_REGISTER_PROFILE_WITH_RESET_TEMPLATE(ezTuneSettings_t, ezTune, PG_EZ_TUNE, 0); PG_RESET_TEMPLATE(ezTuneSettings_t, ezTune, @@ -70,6 +72,9 @@ static float getYawPidScale(float input) { void ezTuneUpdate(void) { if (ezTune()->enabled) { + //Enforce RC auto smoothing + rxConfigMutable()->autoSmooth = 1; + // Setup filtering //Set Dterm LPF pidProfileMutable()->dterm_lpf_hz = MAX(ezTune()->filterHz - 5, 50); From dc2c27a26fcf12cf44ba661fce22c194ec8f778f Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Mon, 15 Apr 2024 21:31:23 +0200 Subject: [PATCH 192/241] Docs update --- docs/Settings.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Settings.md b/docs/Settings.md index e1f1816813e..dd22b2eba73 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -658,7 +658,7 @@ These are values (in us) by how much RC input can be different before it's consi | Default | Min | Max | | --- | --- | --- | -| 5 | 0 | 32 | +| 2 | 0 | 32 | --- @@ -6198,7 +6198,7 @@ These are values (in us) by how much RC input can be different before it's consi | Default | Min | Max | | --- | --- | --- | -| 5 | 0 | 100 | +| 2 | 0 | 100 | --- From 79e974d73555d8c91037e48acd7da35c7f547fe9 Mon Sep 17 00:00:00 2001 From: breadoven <56191411+breadoven@users.noreply.github.com> Date: Tue, 16 Apr 2024 09:48:31 +0100 Subject: [PATCH 193/241] Update navigation.c --- src/main/navigation/navigation.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/navigation/navigation.c b/src/main/navigation/navigation.c index d2a5732de79..c85359ee50d 100644 --- a/src/main/navigation/navigation.c +++ b/src/main/navigation/navigation.c @@ -2859,21 +2859,21 @@ static bool isWaypointReached(const fpVector3_t * waypointPos, const int32_t * w { posControl.wpDistance = calculateDistanceToDestination(waypointPos); - // Check if waypoint was missed based on bearing to WP exceeding given angular limit relative to initial waypoint bearing. + // Check if waypoint was missed based on bearing to waypoint exceeding given angular limit relative to initial waypoint bearing. // Default angular limit = 100 degs with a reduced limit of 60 degs used if fixed wing waypoint turn smoothing option active - uint16_t relativeBearingErrorLimit = 10000; + uint16_t relativeBearingTargetAngle = 10000; if (STATE(AIRPLANE) && posControl.flags.wpTurnSmoothingActive) { - // If WP turn smoothing CUT option used WP is reached when start of turn is initiated + // If WP mode turn smoothing CUT option used waypoint is reached when start of turn is initiated if (navConfig()->fw.wp_turn_smoothing == WP_TURN_SMOOTHING_CUT) { posControl.flags.wpTurnSmoothingActive = false; return true; } - relativeBearingErrorLimit = 6000; + relativeBearingTargetAngle = 6000; } - if (ABS(wrap_18000(calculateBearingToDestination(waypointPos) - *waypointBearing)) > relativeBearingErrorLimit) { + if (ABS(wrap_18000(calculateBearingToDestination(waypointPos) - *waypointBearing)) > relativeBearingTargetAngle) { return true; } From 17e785514493cdedc4dbd3c31434491ea792ca82 Mon Sep 17 00:00:00 2001 From: breadoven <56191411+breadoven@users.noreply.github.com> Date: Tue, 16 Apr 2024 09:56:45 +0100 Subject: [PATCH 194/241] Update osd.c --- src/main/io/osd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index f06845c3662..c6574db97c6 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -4864,7 +4864,7 @@ static void osdRefresh(timeUs_t currentTimeUs) static uint8_t statsCurrentPage = 0; static bool statsDisplayed = false; static bool statsAutoPagingEnabled = true; - static bool throttleHigh = false; + static bool isThrottleHigh = false; // Detect arm/disarm if (armState != ARMING_FLAG(ARMED)) { @@ -4890,7 +4890,7 @@ static void osdRefresh(timeUs_t currentTimeUs) statsAutoPagingEnabled = osdConfig()->stats_page_auto_swap_time > 0 ? true : false; osdShowStats(statsSinglePageCompatible, statsCurrentPage); osdSetNextRefreshIn(STATS_SCREEN_DISPLAY_TIME); - throttleHigh = checkStickPosition(THR_HI); + isThrottleHigh = checkStickPosition(THR_HI); } armState = ARMING_FLAG(ARMED); @@ -4956,7 +4956,7 @@ static void osdRefresh(timeUs_t currentTimeUs) } // Handle events when either "Splash", "Armed" or "Stats" screens are displayed. - if (currentTimeUs > resumeRefreshAt || (OSD_RESUME_UPDATES_STICK_COMMAND && !throttleHigh)) { + if (currentTimeUs > resumeRefreshAt || (OSD_RESUME_UPDATES_STICK_COMMAND && !isThrottleHigh)) { // Time elapsed or canceled by stick commands. // Exit to normal OSD operation. displayClearScreen(osdDisplayPort); @@ -4965,7 +4965,7 @@ static void osdRefresh(timeUs_t currentTimeUs) } else { // Continue "Splash", "Armed" or "Stats" screens. displayHeartbeat(osdDisplayPort); - throttleHigh = checkStickPosition(THR_HI); + isThrottleHigh = checkStickPosition(THR_HI); } return; From a6e45042449c2c2b8eb4347d69e829c144c03891 Mon Sep 17 00:00:00 2001 From: jhemcu <1553061986@qq.com> Date: Wed, 17 Apr 2024 00:46:43 +0800 Subject: [PATCH 195/241] Fix the problem --- src/main/target/JHEMCUF405WING/target.c | 6 +++--- src/main/target/JHEMCUF745/config.c | 28 +++++++++++++++++++++++++ src/main/target/JHEMCUF745/target.c | 4 +--- src/main/target/JHEMCUF745/target.h | 3 ++- 4 files changed, 34 insertions(+), 7 deletions(-) create mode 100644 src/main/target/JHEMCUF745/config.c diff --git a/src/main/target/JHEMCUF405WING/target.c b/src/main/target/JHEMCUF405WING/target.c index 8dd1df5e1e7..e8187f936b2 100644 --- a/src/main/target/JHEMCUF405WING/target.c +++ b/src/main/target/JHEMCUF405WING/target.c @@ -38,10 +38,10 @@ timerHardware_t timerHardware[] = { DEF_TIM(TIM2, CH1, PA15, TIM_USE_OUTPUT_AUTO, 1, 0), // S8 DEF_TIM(TIM2, CH3, PB10, TIM_USE_OUTPUT_AUTO, 1, 0), // S9 DEF_TIM(TIM2, CH4, PB11, TIM_USE_OUTPUT_AUTO, 1, 0), // S10 - DEF_TIM(TIM1, CH3N,PB15, TIM_USE_OUTPUT_AUTO, 1, 0), // S11 + DEF_TIM(TIM12, CH2,PB15, TIM_USE_OUTPUT_AUTO, 1, 0), // S11 - DEF_TIM(TIM1, CH1, PA8, TIM_USE_LED, 0, 0), //2812LED D(1,5,3) - DEF_TIM(TIM5, CH3, PA2, TIM_USE_ANY, 0, 0), //TX2 softserial1_Tx + DEF_TIM(TIM1, CH1, PA8, TIM_USE_LED, 0, 0), // 2812LED + DEF_TIM(TIM5, CH3, PA2, TIM_USE_ANY, 0, 0), // TX2 }; const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]); diff --git a/src/main/target/JHEMCUF745/config.c b/src/main/target/JHEMCUF745/config.c new file mode 100644 index 00000000000..53eed72d8c0 --- /dev/null +++ b/src/main/target/JHEMCUF745/config.c @@ -0,0 +1,28 @@ +/* + * This file is part of INAV. + * + * INAV 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. + * + * INAV 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 INAV. If not, see . + */ + +#include +#include "platform.h" + +#include "fc/fc_msp_box.h" +#include "io/piniobox.h" + +void targetConfiguration(void) +{ + timerOverridesMutable(timer2id(TIM1))->outputMode = OUTPUT_MODE_MOTORS; + timerOverridesMutable(timer2id(TIM3))->outputMode = OUTPUT_MODE_MOTORS; +} diff --git a/src/main/target/JHEMCUF745/target.c b/src/main/target/JHEMCUF745/target.c index 20c97d40cf4..f603cbe43be 100644 --- a/src/main/target/JHEMCUF745/target.c +++ b/src/main/target/JHEMCUF745/target.c @@ -30,11 +30,9 @@ #include "drivers/pinio.h" timerHardware_t timerHardware[] = { - DEF_TIM(TIM1, CH3, PE13, TIM_USE_PPM, 0, 1), // PPM, DMA2_ST6 - DEF_TIM(TIM3, CH3, PB0, TIM_USE_OUTPUT_AUTO, 0, 0), // M1, DMA1_ST7 DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 0), // M2, DMA1_ST2 - DEF_TIM(TIM1, CH1, PE9, TIM_USE_OUTPUT_AUTO, 0, 2), // M3, DMA2_ST2 + DEF_TIM(TIM1, CH1, PE9, TIM_USE_OUTPUT_AUTO, 0, 0), // M3 DEF_TIM(TIM1, CH2, PE11, TIM_USE_OUTPUT_AUTO, 0, 1), // M4, DMA2_ST4 DEF_TIM(TIM8, CH4, PC9, TIM_USE_OUTPUT_AUTO, 0, 0), // M5, DMA2_ST7 DEF_TIM(TIM5, CH4, PA3, TIM_USE_OUTPUT_AUTO, 0, 0), // M6, DMA1_ST1 diff --git a/src/main/target/JHEMCUF745/target.h b/src/main/target/JHEMCUF745/target.h index 6b325ecbebb..dfd45749d2d 100644 --- a/src/main/target/JHEMCUF745/target.h +++ b/src/main/target/JHEMCUF745/target.h @@ -29,6 +29,7 @@ #define BEEPER_INVERTED #define USE_DSHOT +#define USE_DSHOT_DMAR #define USE_ESC_SENSOR #define USE_IMU_MPU6000 @@ -153,4 +154,4 @@ #define TARGET_IO_PORTD 0xffff #define TARGET_IO_PORTE 0xffff -#define MAX_PWM_OUTPUT_PORTS 6 +#define MAX_PWM_OUTPUT_PORTS 8 From 859969f5739e091c5cdc4e862f9f85f31dbe4014 Mon Sep 17 00:00:00 2001 From: jhemcu <1553061986@qq.com> Date: Wed, 17 Apr 2024 01:28:23 +0800 Subject: [PATCH 196/241] missing some headers on the timerOverridesMutable change to the F745 --- src/main/target/JHEMCUF745/config.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/target/JHEMCUF745/config.c b/src/main/target/JHEMCUF745/config.c index 53eed72d8c0..fb2fe04f963 100644 --- a/src/main/target/JHEMCUF745/config.c +++ b/src/main/target/JHEMCUF745/config.c @@ -15,11 +15,12 @@ * along with INAV. If not, see . */ +#include #include -#include "platform.h" -#include "fc/fc_msp_box.h" -#include "io/piniobox.h" +#include + +#include "drivers/pwm_mapping.h" void targetConfiguration(void) { From c3eba6ad835d80b9a3ba56103e2d24660e22aa36 Mon Sep 17 00:00:00 2001 From: Sensei Date: Tue, 16 Apr 2024 22:56:44 -0500 Subject: [PATCH 197/241] Merge pull request #9669 from Aocoda-RC/aocodarc-f405v3 Add AOCODARCF4V3 target --- src/main/target/AOCODARCF4V3/CMakeLists.txt | 3 + src/main/target/AOCODARCF4V3/config.c | 40 ++++ src/main/target/AOCODARCF4V3/target.c | 46 +++++ src/main/target/AOCODARCF4V3/target.h | 192 ++++++++++++++++++++ 4 files changed, 281 insertions(+) create mode 100644 src/main/target/AOCODARCF4V3/CMakeLists.txt create mode 100644 src/main/target/AOCODARCF4V3/config.c create mode 100644 src/main/target/AOCODARCF4V3/target.c create mode 100644 src/main/target/AOCODARCF4V3/target.h diff --git a/src/main/target/AOCODARCF4V3/CMakeLists.txt b/src/main/target/AOCODARCF4V3/CMakeLists.txt new file mode 100644 index 00000000000..706b818e2b8 --- /dev/null +++ b/src/main/target/AOCODARCF4V3/CMakeLists.txt @@ -0,0 +1,3 @@ +target_stm32f405xg(AOCODARCF4V3_SD) +target_stm32f405xg(AOCODARCF4V3) + diff --git a/src/main/target/AOCODARCF4V3/config.c b/src/main/target/AOCODARCF4V3/config.c new file mode 100644 index 00000000000..c80a92940a9 --- /dev/null +++ b/src/main/target/AOCODARCF4V3/config.c @@ -0,0 +1,40 @@ +/* + * 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 "fc/fc_msp_box.h" +//#include "fc/config.h" + +#include "io/piniobox.h" +#include "drivers/serial.h" +#include "io/serial.h" +void targetConfiguration(void) +{ + pinioBoxConfigMutable()->permanentId[0] = BOX_PERMANENT_ID_USER1; + pinioBoxConfigMutable()->permanentId[1] = BOX_PERMANENT_ID_USER2; + pinioBoxConfigMutable()->permanentId[2] = BOX_PERMANENT_ID_USER3; + // beeperConfigMutable()->pwmMode = true; + serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART5)].functionMask = FUNCTION_MSP; + serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART5)].msp_baudrateIndex = BAUD_115200; + serialConfigMutable()->portConfigs[4].functionMask = FUNCTION_VTX_TRAMP; + serialConfigMutable()->portConfigs[4].peripheral_baudrateIndex = BAUD_115200; + serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART2)].functionMask = FUNCTION_RX_SERIAL; + serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART3)].functionMask = FUNCTION_ESCSERIAL; + serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART1)].functionMask = FUNCTION_GPS; +} diff --git a/src/main/target/AOCODARCF4V3/target.c b/src/main/target/AOCODARCF4V3/target.c new file mode 100644 index 00000000000..8581cc5bf11 --- /dev/null +++ b/src/main/target/AOCODARCF4V3/target.c @@ -0,0 +1,46 @@ +/* + * This file is part of INAV. + * + * INAV 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. + * + * INAV 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 INAV. If not, see . + */ + + +#include + +#include "platform.h" +#include "drivers/io.h" +#include "drivers/timer.h" +#include "drivers/pwm_mapping.h" +#include "drivers/bus.h" + +timerHardware_t timerHardware[] = { + DEF_TIM(TIM5, CH4, PA3, TIM_USE_PPM, 0, 0 ), // PPM IN + + DEF_TIM(TIM8, CH1, PC6, TIM_USE_OUTPUT_AUTO, 0, 1 ), // S1 + DEF_TIM(TIM8, CH2, PC7, TIM_USE_OUTPUT_AUTO, 0, 1 ), // S2 + DEF_TIM(TIM8, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 1 ), // S3 + DEF_TIM(TIM8, CH4, PC9, TIM_USE_OUTPUT_AUTO, 0, 0 ), // S4 + + DEF_TIM(TIM2, CH1, PA15, TIM_USE_OUTPUT_AUTO, 0, 0 ), // S5 + DEF_TIM(TIM1, CH1, PA8, TIM_USE_OUTPUT_AUTO, 0, 1 ), // S6 + + DEF_TIM(TIM2, CH3, PB10, TIM_USE_OUTPUT_AUTO, 0, 0 ), // S7 + DEF_TIM(TIM2, CH4, PB11, TIM_USE_OUTPUT_AUTO, 0, 0 ), // S8 + + DEF_TIM(TIM3, CH4, PB1, TIM_USE_LED, 0, 0 ), // LED_STRIP + + +}; + +const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]); diff --git a/src/main/target/AOCODARCF4V3/target.h b/src/main/target/AOCODARCF4V3/target.h new file mode 100644 index 00000000000..0c95564162e --- /dev/null +++ b/src/main/target/AOCODARCF4V3/target.h @@ -0,0 +1,192 @@ +/* + * This file is part of INAV. + * + * INAV 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. + * + * INAV 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 INAV. If not, see . + */ + +#pragma once + +#define USE_TARGET_CONFIG + +#ifdef AOCODARCF4V3 +#define TARGET_BOARD_IDENTIFIER "AOF4V3" +#define USBD_PRODUCT_STRING "AOCODARCF4V3" +#else +#define TARGET_BOARD_IDENTIFIER "AOF4V3SD" +#define USBD_PRODUCT_STRING "AOCODARCF4V3_SD" +#endif + +// ******** Board LEDs ********************** +#define LED0 PC13 + +// ******* Beeper *********** +#define BEEPER PB8 +#define BEEPER_INVERTED + + +// ******* GYRO and ACC ******** +#define USE_IMU_MPU6500 +#define IMU_MPU6500_ALIGN CW90_DEG +#define MPU6500_SPI_BUS BUS_SPI1 +#define MPU6500_CS_PIN PA4 + +#define USE_IMU_MPU6000 +#define IMU_MPU6000_ALIGN CW90_DEG +#define MPU6000_SPI_BUS BUS_SPI1 +#define MPU6000_CS_PIN PA4 + +#define USE_IMU_ICM42605 +#define IMU_ICM42605_ALIGN CW90_DEG +#define ICM42605_SPI_BUS BUS_SPI1 +#define ICM42605_CS_PIN PA4 + + +// *************** Baro ************************** +#define USE_I2C +#define USE_I2C_DEVICE_1 + +#define I2C1_SCL PB6 // SCL +#define I2C1_SDA PB7 // SDA +#define DEFAULT_I2C_BUS BUS_I2C1 + +#define USE_BARO +#define BARO_I2C_BUS DEFAULT_I2C_BUS + +#define USE_BARO_BMP280 +#define USE_BARO_MS5611 +#define USE_BARO_DPS310 +#define USE_BARO_SPL06 + +//*********** Magnetometer / Compass ************* +#define USE_MAG +#define MAG_I2C_BUS DEFAULT_I2C_BUS +#define USE_MAG_ALL + +// ******* SERIAL ******** +#define USE_VCP +#define VBUS_SENSING_PIN PB12 +#define VBUS_SENSING_ENABLED + +#define USE_UART1 +#define UART1_TX_PIN PA9 +#define UART1_RX_PIN PA10 + +#define USE_UART2 +#define UART2_TX_PIN PA2 +#define UART2_RX_PIN PA3 + +#define USE_UART3 +#define UART3_TX_PIN PC10 +#define UART3_RX_PIN PC11 + +#define USE_UART4 +#define UART4_TX_PIN PA0 +#define UART4_RX_PIN PA1 + +#define USE_UART5 +#define UART5_TX_PIN PC12 +#define UART5_RX_PIN PD2 + + +#define SERIAL_PORT_COUNT 6 + + +// ******* SPI ******** +#define USE_SPI + +#define USE_SPI_DEVICE_1 +#define SPI1_NSS_PIN PA4 +#define SPI1_SCK_PIN PA5 +#define SPI1_MISO_PIN PA6 +#define SPI1_MOSI_PIN PA7 + +#define USE_SPI_DEVICE_2 +#define SPI2_NSS_PIN PA13 +#define SPI2_SCK_PIN PB13 +#define SPI2_MISO_PIN PB14 +#define SPI2_MOSI_PIN PB15 + +#define USE_SPI_DEVICE_3 +#define SPI3_NSS_PIN PC0 +#define SPI3_SCK_PIN PB3 +#define SPI3_MISO_PIN PB4 +#define SPI3_MOSI_PIN PB5 + +// ******* ADC ******** +#define USE_ADC +#define ADC_CHANNEL_1_PIN PC1 +#define ADC_CHANNEL_2_PIN PC2 +#define ADC_CHANNEL_3_PIN PC3 + +#define VBAT_ADC_CHANNEL ADC_CHN_2 +#define RSSI_ADC_CHANNEL ADC_CHN_3 +#define CURRENT_METER_ADC_CHANNEL ADC_CHN_1 + +#define VBAT_SCALE_DEFAULT 1100 +#define CURRENT_METER_SCALE 206 + +// ******* OSD ******** +#define USE_OSD +#define USE_MAX7456 +#define MAX7456_SPI_BUS BUS_SPI2 +#define MAX7456_CS_PIN PA13 + +//******* FLASH ******** +#if defined(AOCODARCF4V3_SD) +#define USE_SDCARD +#define USE_SDCARD_SPI +#define SDCARD_SPI_BUS BUS_SPI3 +#define SDCARD_CS_PIN PC0 +#define SDCARD_DETECT_INVERTED +#define SDCARD_DETECT_PIN PC14 +#define ENABLE_BLACKBOX_LOGGING_ON_SDCARD_BY_DEFAULT +#else +#define USE_FLASHFS +#define USE_FLASH_M25P16 +#define M25P16_SPI_BUS BUS_SPI3 +#define M25P16_CS_PIN PC0 +#define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT +#endif +// *************** PINIO *************************** +#define USE_PINIO +#define USE_PINIOBOX +#define PINIO1_PIN PC5 // VTX power switcher +#define PINIO2_PIN PA14 //bluetooth +#define PINIO3_PIN PC15 //Camera control +#define PINIO1_FLAGS PINIO_FLAGS_INVERTED +#define PINIO2_FLAGS PINIO_FLAGS_INVERTED + +//************ LEDSTRIP ***************** +#define USE_LED_STRIP +#define WS2811_PIN PB1 + +// ******* FEATURES ******** +#define DEFAULT_RX_TYPE RX_TYPE_SERIAL +#define SERIALRX_UART SERIAL_PORT_USART2 +#define SERIALRX_PROVIDER SERIALRX_CRSF + +#define DEFAULT_FEATURES (FEATURE_OSD | FEATURE_TELEMETRY | FEATURE_CURRENT_METER | FEATURE_VBAT | FEATURE_TX_PROF_SEL | FEATURE_GPS | FEATURE_BLACKBOX | FEATURE_LED_STRIP) + +#define TARGET_IO_PORTA 0xffff +#define TARGET_IO_PORTB 0xffff +#define TARGET_IO_PORTC 0xffff +#define TARGET_IO_PORTD 0xffff + +#define MAX_PWM_OUTPUT_PORTS 10 + +// ESC-related features +#define USE_DSHOT +#define USE_SERIALSHOT +#define USE_ESC_SENSOR +#define USE_SERIAL_4WAY_BLHELI_INTERFACE From c5a05c0496aef2b136100436febe456b4db592e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Spychalski?= Date: Wed, 10 Apr 2024 14:13:50 +0200 Subject: [PATCH 198/241] Merge pull request #9919 from YI-BOYANG/master Add GEPRC TAKERF722SE target --- src/main/target/TAKERF722SE/CMakeLists.txt | 1 + src/main/target/TAKERF722SE/target.c | 48 ++++++ src/main/target/TAKERF722SE/target.h | 186 +++++++++++++++++++++ 3 files changed, 235 insertions(+) create mode 100644 src/main/target/TAKERF722SE/CMakeLists.txt create mode 100644 src/main/target/TAKERF722SE/target.c create mode 100644 src/main/target/TAKERF722SE/target.h diff --git a/src/main/target/TAKERF722SE/CMakeLists.txt b/src/main/target/TAKERF722SE/CMakeLists.txt new file mode 100644 index 00000000000..c4716f616ee --- /dev/null +++ b/src/main/target/TAKERF722SE/CMakeLists.txt @@ -0,0 +1 @@ +target_stm32f722xe(TAKERF722SE) \ No newline at end of file diff --git a/src/main/target/TAKERF722SE/target.c b/src/main/target/TAKERF722SE/target.c new file mode 100644 index 00000000000..247efb84e52 --- /dev/null +++ b/src/main/target/TAKERF722SE/target.c @@ -0,0 +1,48 @@ +/* +* This file is part of INAV Project. +* +* INAV 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. +* +* INAV 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 INAV. If not, see . +*/ + +#include + +#include "platform.h" +#include "drivers/io.h" + +#include "drivers/dma.h" +#include "drivers/timer.h" +#include "drivers/timer_def.h" + + + + + +timerHardware_t timerHardware[] = { + + DEF_TIM(TIM3, CH1, PB4, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM3, CH2, PB5, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM3, CH3, PB0, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 0), + + DEF_TIM(TIM4, CH1, PB6, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM4, CH2, PB7, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM8, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM8, CH4, PC9, TIM_USE_OUTPUT_AUTO, 0, 0), + + DEF_TIM(TIM1, CH1, PA8, TIM_USE_LED, 0, 0), +}; + +const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]); + + diff --git a/src/main/target/TAKERF722SE/target.h b/src/main/target/TAKERF722SE/target.h new file mode 100644 index 00000000000..61ab442653d --- /dev/null +++ b/src/main/target/TAKERF722SE/target.h @@ -0,0 +1,186 @@ +/* + * This file is part of INAV Project. + * + * 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. + * + * INAV 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 INAV. If not, see . + */ + +#pragma once + +#define TARGET_BOARD_IDENTIFIER "GEPR" + +#define USBD_PRODUCT_STRING "TAKERF722SE" + +#define LED0 PC14 + + +// *************** BEEPER ************************ + +#define BEEPER PC13 +#define BEEPER_INVERTED + + +// *************** LEDSTRIP ************************ +#define USE_LED_STRIP +#define WS2811_PIN PA8 + + +// *************** UART ***************************** +#define USE_VCP + +#define USE_UART1 +#define UART1_TX_PIN PA9 +#define UART1_RX_PIN PA10 + +#define USE_UART2 +#define UART2_TX_PIN PA2 +#define UART2_RX_PIN PA3 + +#define USE_UART3 +#define UART3_TX_PIN PB10 +#define UART3_RX_PIN PB11 + +#define USE_UART4 +#define UART4_TX_PIN PA0 +#define UART4_RX_PIN PA1 + +#define USE_UART5 +#define UART5_TX_PIN PC12 +#define UART5_RX_PIN PD2 + +#define USE_UART6 +#define UART6_TX_PIN PC6 +#define UART6_RX_PIN PC7 + + +#define SERIAL_PORT_COUNT 7 + +#define DEFAULT_RX_TYPE RX_TYPE_SERIAL +#define SERIALRX_PROVIDER SERIALRX_SBUS +#define SERIALRX_UART SERIAL_PORT_USART2 + + +// *************** SPI Bus ********************** + +#define USE_SPI + +#define USE_SPI_DEVICE_1 +#define SPI1_SCK_PIN PA5 +#define SPI1_MISO_PIN PA6 +#define SPI1_MOSI_PIN PA7 + +#define USE_SPI_DEVICE_2 +#define SPI2_SCK_PIN PB13 +#define SPI2_MISO_PIN PB14 +#define SPI2_MOSI_PIN PB15 + +#define USE_SPI_DEVICE_3 +#define SPI3_SCK_PIN PC10 +#define SPI3_MISO_PIN PC11 +#define SPI3_MOSI_PIN PB2 +#define SPI3_SCK_AF GPIO_AF6_SPI3 +#define SPI3_MISO_AF GPIO_AF6_SPI3 +#define SPI3_MOSI_AF GPIO_AF7_SPI3 + + +// *************** Gyro & ACC ********************** + +#define USE_IMU_MPU6000 +#define IMU_MPU6000_ALIGN CW0_DEG +#define MPU6000_CS_PIN PA4 +#define MPU6000_SPI_BUS BUS_SPI1 + + +#define USE_IMU_ICM42605 +#define IMU_ICM42605_ALIGN CW0_DEG +#define ICM42605_CS_PIN PA4 +#define ICM42605_SPI_BUS BUS_SPI1 + +// *************** I2C/Baro/Mag ********************* +#define USE_I2C +#define USE_I2C_DEVICE_1 +#define I2C1_SCL PB8 +#define I2C1_SDA PB9 + + +//*************************************************** +#define USE_BARO +#define BARO_I2C_BUS BUS_I2C1 +#define USE_BARO_BMP280 +#define USE_BARO_DPS310 +#define USE_BARO_MS5611 + +#define USE_MAG +#define MAG_I2C_BUS BUS_I2C1 +#define USE_MAG_HMC5883 +#define USE_MAG_QMC5883 +#define USE_MAG_IST8310 +#define USE_MAG_IST8308 + +#define TEMPERATURE_I2C_BUS BUS_I2C1 + +#define PITOT_I2C_BUS BUS_I2C1 + +#define USE_RANGEFINDER +#define RANGEFINDER_I2C_BUS BUS_I2C1 +#define BNO055_I2C_BUS BUS_I2C1 + +// *************** FLASH ************************** + +#define USE_FLASHFS + +#define USE_FLASH_M25P16 +#define M25P16_CS_PIN PA15 +#define M25P16_SPI_BUS BUS_SPI3 + +#define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT + +// *************** OSD ***************************** + +#define USE_MAX7456 +#define MAX7456_SPI_BUS BUS_SPI2 +#define MAX7456_CS_PIN PB12 + +// *************** ADC ***************************** + +#define USE_ADC +#define ADC_INSTANCE ADC1 +#define ADC1_DMA_STREAM DMA2_Stream0 +#define ADC_CHANNEL_1_PIN PC3 +#define ADC_CHANNEL_2_PIN PC0 +#define ADC_CHANNEL_3_PIN PC2 + +#define VBAT_ADC_CHANNEL ADC_CHN_1 +#define RSSI_ADC_CHANNEL ADC_CHN_2 +#define CURRENT_METER_ADC_CHANNEL ADC_CHN_3 + + +#define DEFAULT_FEATURES (FEATURE_TX_PROF_SEL | FEATURE_CURRENT_METER | FEATURE_TELEMETRY | FEATURE_VBAT | FEATURE_OSD | FEATURE_BLACKBOX) + + + + +//************************************************** + +#define USE_SERIAL_4WAY_BLHELI_INTERFACE + +#define TARGET_IO_PORTA 0xffff +#define TARGET_IO_PORTB 0xffff +#define TARGET_IO_PORTC 0xffff +#define TARGET_IO_PORTD (BIT(2)) + + +#define MAX_PWM_OUTPUT_PORTS 8 + +#define USE_DSHOT +#define USE_ESC_SENSOR From db497ffb2b56caffce0ec6b8a5a4ab230483c1b9 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Wed, 17 Apr 2024 18:18:07 +0200 Subject: [PATCH 199/241] Optimize PID axis processing --- src/main/flight/pid.c | 49 +++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/src/main/flight/pid.c b/src/main/flight/pid.c index c61fe5353f7..02ff8c2dad8 100644 --- a/src/main/flight/pid.c +++ b/src/main/flight/pid.c @@ -154,7 +154,7 @@ static EXTENDED_FASTRAM float iTermAntigravityGain; #endif static EXTENDED_FASTRAM uint8_t usedPidControllerType; -typedef void (*pidControllerFnPtr)(pidState_t *pidState, flight_dynamics_index_t axis, float dT, float dT_inv); +typedef void (*pidControllerFnPtr)(pidState_t *pidState, float dT, float dT_inv); static EXTENDED_FASTRAM pidControllerFnPtr pidControllerApplyFn; static EXTENDED_FASTRAM filterApplyFnPtr dTermLpfFilterApplyFn; static EXTENDED_FASTRAM bool levelingEnabled = false; @@ -744,16 +744,15 @@ static void applyItermLimiting(pidState_t *pidState) { } } -static void nullRateController(pidState_t *pidState, flight_dynamics_index_t axis, float dT, float dT_inv) { +static void nullRateController(pidState_t *pidState, float dT, float dT_inv) { UNUSED(pidState); - UNUSED(axis); UNUSED(dT); UNUSED(dT_inv); } -static void NOINLINE pidApplyFixedWingRateController(pidState_t *pidState, flight_dynamics_index_t axis, float dT, float dT_inv) +static void NOINLINE pidApplyFixedWingRateController(pidState_t *pidState, float dT, float dT_inv) { - const float rateTarget = getFlightAxisRateOverride(axis, pidState->rateTarget); + const float rateTarget = getFlightAxisRateOverride(pidState->axis, pidState->rateTarget); const float rateError = rateTarget - pidState->gyroRate; const float newPTerm = pTermProcess(pidState, rateError, dT); @@ -769,16 +768,16 @@ static void NOINLINE pidApplyFixedWingRateController(pidState_t *pidState, fligh applyItermLimiting(pidState); - const uint16_t limit = getPidSumLimit(axis); + const uint16_t limit = getPidSumLimit(pidState->axis); if (pidProfile()->pidItermLimitPercent != 0){ float itermLimit = limit * pidProfile()->pidItermLimitPercent * 0.01f; pidState->errorGyroIf = constrainf(pidState->errorGyroIf, -itermLimit, +itermLimit); } - axisPID[axis] = constrainf(newPTerm + newFFTerm + pidState->errorGyroIf + newDTerm, -limit, +limit); + axisPID[pidState->axis] = constrainf(newPTerm + newFFTerm + pidState->errorGyroIf + newDTerm, -limit, +limit); - if (FLIGHT_MODE(SOARING_MODE) && axis == FD_PITCH && calculateRollPitchCenterStatus() == CENTERED) { + if (FLIGHT_MODE(SOARING_MODE) && pidState->axis == FD_PITCH && calculateRollPitchCenterStatus() == CENTERED) { if (!angleFreefloatDeadband(DEGREES_TO_DECIDEGREES(navConfig()->fw.soaring_pitch_deadband), FD_PITCH)) { axisPID[FD_PITCH] = 0; // center pitch servo if pitch attitude within soaring mode deadband } @@ -786,16 +785,16 @@ static void NOINLINE pidApplyFixedWingRateController(pidState_t *pidState, fligh #ifdef USE_AUTOTUNE_FIXED_WING if (FLIGHT_MODE(AUTO_TUNE) && !FLIGHT_MODE(MANUAL_MODE)) { - autotuneFixedWingUpdate(axis, rateTarget, pidState->gyroRate, constrainf(newPTerm + newFFTerm, -limit, +limit)); + autotuneFixedWingUpdate(pidState->axis, rateTarget, pidState->gyroRate, constrainf(newPTerm + newFFTerm, -limit, +limit)); } #endif #ifdef USE_BLACKBOX - axisPID_P[axis] = newPTerm; - axisPID_I[axis] = pidState->errorGyroIf; - axisPID_D[axis] = newDTerm; - axisPID_F[axis] = newFFTerm; - axisPID_Setpoint[axis] = rateTarget; + axisPID_P[pidState->axis] = newPTerm; + axisPID_I[pidState->axis] = pidState->errorGyroIf; + axisPID_D[pidState->axis] = newDTerm; + axisPID_F[pidState->axis] = newFFTerm; + axisPID_Setpoint[pidState->axis] = rateTarget; #endif pidState->previousRateGyro = pidState->gyroRate; @@ -818,10 +817,10 @@ static float FAST_CODE applyItermRelax(const int axis, float currentPidSetpoint, return itermErrorRate; } -static void FAST_CODE NOINLINE pidApplyMulticopterRateController(pidState_t *pidState, flight_dynamics_index_t axis, float dT, float dT_inv) +static void FAST_CODE NOINLINE pidApplyMulticopterRateController(pidState_t *pidState, float dT, float dT_inv) { - const float rateTarget = getFlightAxisRateOverride(axis, pidState->rateTarget); + const float rateTarget = getFlightAxisRateOverride(pidState->axis, pidState->rateTarget); const float rateError = rateTarget - pidState->gyroRate; const float newPTerm = pTermProcess(pidState, rateError, dT); @@ -835,13 +834,13 @@ static void FAST_CODE NOINLINE pidApplyMulticopterRateController(pidState_t *pid */ const float newCDTerm = rateTargetDeltaFiltered * pidState->kCD; - const uint16_t limit = getPidSumLimit(axis); + const uint16_t limit = getPidSumLimit(pidState->axis); // TODO: Get feedback from mixer on available correction range for each axis const float newOutput = newPTerm + newDTerm + pidState->errorGyroIf + newCDTerm; const float newOutputLimited = constrainf(newOutput, -limit, +limit); - float itermErrorRate = applyItermRelax(axis, rateTarget, rateError); + float itermErrorRate = applyItermRelax(pidState->axis, rateTarget, rateError); #ifdef USE_ANTIGRAVITY itermErrorRate *= iTermAntigravityGain; @@ -859,14 +858,14 @@ static void FAST_CODE NOINLINE pidApplyMulticopterRateController(pidState_t *pid // Don't grow I-term if motors are at their limit applyItermLimiting(pidState); - axisPID[axis] = newOutputLimited; + axisPID[pidState->axis] = newOutputLimited; #ifdef USE_BLACKBOX - axisPID_P[axis] = newPTerm; - axisPID_I[axis] = pidState->errorGyroIf; - axisPID_D[axis] = newDTerm; - axisPID_F[axis] = newCDTerm; - axisPID_Setpoint[axis] = rateTarget; + axisPID_P[pidState->axis] = newPTerm; + axisPID_I[pidState->axis] = pidState->errorGyroIf; + axisPID_D[pidState->axis] = newDTerm; + axisPID_F[pidState->axis] = newCDTerm; + axisPID_Setpoint[pidState->axis] = rateTarget; #endif pidState->previousRateTarget = rateTarget; @@ -1230,7 +1229,7 @@ void FAST_CODE pidController(float dT) checkItermLimitingActive(&pidState[axis]); checkItermFreezingActive(&pidState[axis], axis); - pidControllerApplyFn(&pidState[axis], axis, dT, dT_inv); + pidControllerApplyFn(&pidState[axis], dT, dT_inv); } } From b317a66dc182a14e82185f998098d67816f3946f Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Wed, 17 Apr 2024 18:58:27 +0200 Subject: [PATCH 200/241] Ez Tune snappiness --- docs/Settings.md | 10 ++++++++++ src/main/fc/fc_msp.c | 31 ++++++++++++++++++------------- src/main/fc/settings.yaml | 6 ++++++ src/main/flight/ez_tune.c | 6 +++++- src/main/flight/ez_tune.h | 1 + 5 files changed, 40 insertions(+), 14 deletions(-) diff --git a/docs/Settings.md b/docs/Settings.md index dd22b2eba73..d4c2fb197e8 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -932,6 +932,16 @@ EzTune response --- +### ez_snappiness + +EzTune snappiness + +| Default | Min | Max | +| --- | --- | --- | +| 0 | 0 | 100 | + +--- + ### ez_stability EzTune stability diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index 68296b00912..d0244dd0d3c 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -1644,6 +1644,7 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF sbufWriteU8(dst, ezTune()->aggressiveness); sbufWriteU8(dst, ezTune()->rate); sbufWriteU8(dst, ezTune()->expo); + sbufWriteU8(dst, ezTune()->snappiness); } break; #endif @@ -3232,21 +3233,25 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) case MSP2_INAV_EZ_TUNE_SET: { - if (dataSize == 10) { - ezTuneMutable()->enabled = sbufReadU8(src); - ezTuneMutable()->filterHz = sbufReadU16(src); - ezTuneMutable()->axisRatio = sbufReadU8(src); - ezTuneMutable()->response = sbufReadU8(src); - ezTuneMutable()->damping = sbufReadU8(src); - ezTuneMutable()->stability = sbufReadU8(src); - ezTuneMutable()->aggressiveness = sbufReadU8(src); - ezTuneMutable()->rate = sbufReadU8(src); - ezTuneMutable()->expo = sbufReadU8(src); - - ezTuneUpdate(); - } else { + + if (dataSize < 10 || dataSize > 11) { return MSP_RESULT_ERROR; } + + ezTuneMutable()->enabled = sbufReadU8(src); + ezTuneMutable()->filterHz = sbufReadU16(src); + ezTuneMutable()->axisRatio = sbufReadU8(src); + ezTuneMutable()->response = sbufReadU8(src); + ezTuneMutable()->damping = sbufReadU8(src); + ezTuneMutable()->stability = sbufReadU8(src); + ezTuneMutable()->aggressiveness = sbufReadU8(src); + ezTuneMutable()->rate = sbufReadU8(src); + ezTuneMutable()->expo = sbufReadU8(src); + + if (dataSize == 11) { + ezTuneMutable()->snappiness = sbufReadU8(src); + } + ezTuneUpdate(); } break; diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index 521f9bcf193..1e4f9770744 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -1561,6 +1561,12 @@ groups: field: expo min: 0 max: 200 + - name: ez_snappiness + description: "EzTune snappiness" + default_value: 0 + field: snappiness + min: 0 + max: 100 - name: PG_RPM_FILTER_CONFIG headers: ["flight/rpm_filter.h"] diff --git a/src/main/flight/ez_tune.c b/src/main/flight/ez_tune.c index 050ad0735d9..4bde5b645e8 100644 --- a/src/main/flight/ez_tune.c +++ b/src/main/flight/ez_tune.c @@ -36,7 +36,7 @@ #include "rx/rx.h" -PG_REGISTER_PROFILE_WITH_RESET_TEMPLATE(ezTuneSettings_t, ezTune, PG_EZ_TUNE, 0); +PG_REGISTER_PROFILE_WITH_RESET_TEMPLATE(ezTuneSettings_t, ezTune, PG_EZ_TUNE, 1); PG_RESET_TEMPLATE(ezTuneSettings_t, ezTune, .enabled = SETTING_EZ_ENABLED_DEFAULT, @@ -48,6 +48,7 @@ PG_RESET_TEMPLATE(ezTuneSettings_t, ezTune, .aggressiveness = SETTING_EZ_AGGRESSIVENESS_DEFAULT, .rate = SETTING_EZ_RATE_DEFAULT, .expo = SETTING_EZ_EXPO_DEFAULT, + .snappiness = SETTING_EZ_SNAPPINESS_DEFAULT, ); #define EZ_TUNE_PID_RP_DEFAULT { 40, 75, 23, 100 } @@ -142,5 +143,8 @@ void ezTuneUpdate(void) { ((controlRateConfig_t*)currentControlRateProfile)->stabilized.rcExpo8 = scaleRange(ezTune()->rate, 0, 200, 40, 100); ((controlRateConfig_t*)currentControlRateProfile)->stabilized.rcYawExpo8 = scaleRange(ezTune()->rate, 0, 200, 40, 100); + //D-Boost snappiness + pidProfileMutable()->dBoostMin = scaleRangef(ezTune()->snappiness, 0, 100, 1.0f, 0.0f); + } } \ No newline at end of file diff --git a/src/main/flight/ez_tune.h b/src/main/flight/ez_tune.h index 5fcc1ef6f7f..d923dca2199 100644 --- a/src/main/flight/ez_tune.h +++ b/src/main/flight/ez_tune.h @@ -36,6 +36,7 @@ typedef struct ezTuneSettings_s { uint8_t aggressiveness; uint8_t rate; uint8_t expo; + uint8_t snappiness; } ezTuneSettings_t; PG_DECLARE_PROFILE(ezTuneSettings_t, ezTune); From 09ed11ca35a7cd09741c17723287348005eb0bf5 Mon Sep 17 00:00:00 2001 From: error414 Date: Wed, 17 Apr 2024 21:34:31 +0200 Subject: [PATCH 201/241] rename NRA15/NRA24 only to NRA --- docs/Rangefinder.md | 18 +++++++++--------- src/main/fc/settings.yaml | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/Rangefinder.md b/docs/Rangefinder.md index 813184f8374..b53ae439b7e 100644 --- a/docs/Rangefinder.md +++ b/docs/Rangefinder.md @@ -27,15 +27,15 @@ Following rangefinders are supported: NRA15/NRA24 from nanoradar use US-D1_V0 or NRA protocol, it depends which firmware you use. Radar can be set by firmware to two different resolutions. See table below. -| Radar | Protocol | Resolution | Name in configurator | -|-------|----------|-----------------|-----------------------| -| NRA15 | US-D1_V0 | 0-30m (+-4cm) | USD1_V0 | -| NRA15 | NRA | 0-30m (+-4cm) | NRA15/NRA24 | -| NRA15 | NRA | 0-100m (+-10cm) | NRA15/NRA24 | -| NRA24 | US-D1_V0 | 0-50m (+-4cm) | USD1_V0 | -| NRA24 | US-D1_V0 | 0-200m (+-10cm) | USD1_V0 | -| NRA24 | NRA | 0-50m (+-4cm) | NRA15/NRA24 | -| NRA24 | NRA | 0-200m (+-10cm) | NRA15/NRA24 | +| Radar | Protocol | Resolution | Name in configurator | +|-------|----------|-----------------|----------------------| +| NRA15 | US-D1_V0 | 0-30m (+-4cm) | USD1_V0 | +| NRA15 | NRA | 0-30m (+-4cm) | NRA | +| NRA15 | NRA | 0-100m (+-10cm) | NRA | +| NRA24 | US-D1_V0 | 0-50m (+-4cm) | USD1_V0 | +| NRA24 | US-D1_V0 | 0-200m (+-10cm) | USD1_V0 | +| NRA24 | NRA | 0-50m (+-4cm) | NRA | +| NRA24 | NRA | 0-200m (+-10cm) | NRA | ## Connections diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index b2be345391d..11658135417 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -5,7 +5,7 @@ tables: values: ["NONE", "AUTO", "MPU6000", "MPU6500", "MPU9250", "BMI160", "ICM20689", "BMI088", "ICM42605", "BMI270","LSM6DXX", "FAKE"] enum: accelerationSensor_e - name: rangefinder_hardware - values: ["NONE", "SRF10", "VL53L0X", "MSP", "BENEWAKE", "VL53L1X", "US42", "TOF10120_I2C", "FAKE", "TERARANGER_EVO", "USD1_V0", "NRA15/NRA24"] + values: ["NONE", "SRF10", "VL53L0X", "MSP", "BENEWAKE", "VL53L1X", "US42", "TOF10120_I2C", "FAKE", "TERARANGER_EVO", "USD1_V0", "NRA"] enum: rangefinderType_e - name: mag_hardware values: ["NONE", "AUTO", "HMC5883", "AK8975", "MAG3110", "AK8963", "IST8310", "QMC5883", "MPU9250", "IST8308", "LIS3MDL", "MSP", "RM3100", "VCM5883", "MLX90393", "FAKE"] From 069c71811a12a673263e8671288ea41feef91a10 Mon Sep 17 00:00:00 2001 From: Jonathan Hudson Date: Fri, 19 Apr 2024 16:16:18 +0100 Subject: [PATCH 202/241] update auto-declination generator to current IGRF13 model (#9962) --- .../navigation/navigation_declination_gen.c | 66 +++++++++---------- src/utils/declination.py | 4 +- 2 files changed, 35 insertions(+), 35 deletions(-) mode change 100644 => 100755 src/utils/declination.py diff --git a/src/main/navigation/navigation_declination_gen.c b/src/main/navigation/navigation_declination_gen.c index 04e1c731726..c7d632cd87c 100644 --- a/src/main/navigation/navigation_declination_gen.c +++ b/src/main/navigation/navigation_declination_gen.c @@ -1,7 +1,7 @@ /* this file is automatically generated by src/utils/declination.py - DO NOT EDIT! */ -/* Updated on 2019-05-16 19:59:45.672184 */ +/* Updated on 2024-04-19 12:54:15.842704 */ #include @@ -16,25 +16,25 @@ #define SAMPLING_MAX_LAT 90.00000f static const float declination_table[19][37] = { - {149.21545f,139.21545f,129.21545f,119.21545f,109.21545f,99.21545f,89.21545f,79.21545f,69.21545f,59.21545f,49.21545f,39.21545f,29.21545f,19.21545f,9.21545f,-0.78455f,-10.78455f,-20.78455f,-30.78455f,-40.78455f,-50.78455f,-60.78455f,-70.78455f,-80.78455f,-90.78455f,-100.78455f,-110.78455f,-120.78455f,-130.78455f,-140.78455f,-150.78455f,-160.78455f,-170.78455f,179.21545f,169.21545f,159.21545f,149.21545f}, - {129.49173f,117.24379f,106.10409f,95.92286f,86.51411f,77.69583f,69.30955f,61.22803f,53.35622f,45.62814f,38.00071f,30.44524f,22.93795f,15.45138f,7.94874f,0.38309f,-7.29841f,-15.14665f,-23.20230f,-31.49030f,-40.01947f,-48.78754f,-57.79007f,-67.03110f,-76.53295f,-86.34401f,-96.54357f,-107.24276f,-118.57946f,-130.70159f,-143.72988f,-157.69312f,-172.44642f,172.37735f,157.31228f,142.89420f,129.49173f}, - {85.58549f,77.67225f,71.30884f,65.86377f,60.92589f,56.17990f,51.37001f,46.30480f,40.87538f,35.06788f,28.95999f,22.69753f,16.44959f,10.34723f,4.42361f,-1.41547f,-7.36729f,-13.65814f,-20.45428f,-27.80115f,-35.61613f,-43.73164f,-51.96263f,-60.16701f,-68.28139f,-76.33426f,-84.45291f,-92.88710f,-102.08596f,-112.90534f,-127.14324f,-148.72029f,177.01697f,138.42469f,112.13402f,96.22709f,85.58549f}, - {47.63660f,46.34868f,44.88668f,43.46724f,42.13334f,40.75578f,39.03991f,36.60567f,33.13133f,28.48297f,22.78165f,16.40811f,9.93011f,3.92458f,-1.26916f,-5.73344f,-9.95561f,-14.59663f,-20.17634f,-26.83800f,-34.30473f,-42.04900f,-49.54378f,-56.41737f,-62.46557f,-67.58445f,-71.67147f,-74.48888f,-75.41488f,-72.72854f,-60.65739f,-20.78150f,26.31817f,42.64478f,47.39885f,48.29568f,47.63660f}, - {30.97061f,31.18244f,30.92007f,30.51421f,30.19783f,30.07382f,29.96272f,29.32724f,27.44230f,23.71829f,17.99066f,10.70786f,2.93356f,-4.02123f,-9.25421f,-12.72420f,-15.16719f,-17.68585f,-21.36741f,-26.80526f,-33.62817f,-40.77079f,-47.22749f,-52.37678f,-55.85085f,-57.33789f,-56.38997f,-52.20324f,-43.65581f,-30.23589f,-13.76879f,1.84396f,13.87138f,22.01689f,27.05355f,29.80197f,30.97061f}, - {22.35701f,22.87747f,22.95380f,22.77246f,22.50130f,22.37009f,22.48347f,22.51381f,21.59756f,18.63829f,12.92222f,4.75452f,-4.29892f,-12.13023f,-17.44827f,-20.36076f,-21.71093f,-22.23838f,-22.95576f,-25.55066f,-30.56100f,-36.48539f,-41.58017f,-44.82620f,-45.65465f,-43.72977f,-38.84914f,-30.98997f,-21.09926f,-11.31468f,-3.00404f,3.97652f,9.93802f,14.84528f,18.57977f,21.04644f,22.35701f}, - {16.83374f,17.31701f,17.52984f,17.52512f,17.27497f,16.89826f,16.64631f,16.52197f,15.82359f,13.20018f,7.50544f,-1.01430f,-10.31063f,-17.86218f,-22.52054f,-24.77956f,-25.51811f,-24.67883f,-22.16922f,-20.17352f,-21.46713f,-25.48482f,-29.63408f,-31.91043f,-31.42054f,-28.23519f,-22.87573f,-15.95318f,-8.88587f,-3.41726f,0.43088f,3.87433f,7.44305f,10.85242f,13.73685f,15.75505f,16.83374f}, - {13.16653f,13.42584f,13.56856f,13.64914f,13.49908f,13.04415f,12.54312f,12.17294f,11.33249f,8.62333f,2.85124f,-5.49975f,-14.06214f,-20.49962f,-23.98868f,-24.97282f,-24.13471f,-21.32697f,-16.43179f,-11.33581f,-9.07326f,-10.72561f,-14.43596f,-17.29905f,-17.69300f,-15.77796f,-12.24267f,-7.56947f,-3.00400f,-0.11834f,1.39928f,3.14408f,5.63638f,8.32414f,10.72028f,12.39111f,13.16653f}, - {10.90437f,10.88236f,10.81163f,10.86511f,10.80010f,10.39894f,9.91702f,9.49494f,8.41184f,5.36760f,-0.47690f,-8.26124f,-15.66061f,-20.76090f,-22.78986f,-21.89942f,-18.89020f,-14.52921f,-9.53528f,-4.91597f,-1.91353f,-1.76484f,-4.25201f,-7.17489f,-8.55660f,-8.15241f,-6.39303f,-3.54345f,-0.64444f,0.81130f,1.15035f,2.11074f,4.17898f,6.59237f,8.80142f,10.33532f,10.90437f}, - {9.69156f,9.50282f,9.23338f,9.25605f,9.28344f,8.98186f,8.56848f,8.04846f,6.56771f,3.06569f,-2.75457f,-9.75616f,-15.91853f,-19.62874f,-20.10653f,-17.62100f,-13.38807f,-8.80249f,-4.83206f,-1.62618f,0.85458f,1.72352f,0.35339f,-2.00271f,-3.58526f,-3.93648f,-3.30170f,-1.78891f,-0.13334f,0.41999f,0.14853f,0.72192f,2.61852f,5.02104f,7.34668f,9.06648f,9.69156f}, - {8.99220f,9.02256f,8.80901f,8.93941f,9.15462f,8.99412f,8.49413f,7.54605f,5.38233f,1.29060f,-4.51973f,-10.72800f,-15.61393f,-17.87879f,-17.08037f,-13.87843f,-9.54744f,-5.34026f,-2.15287f,0.11672f,2.02473f,3.04733f,2.31093f,0.47960f,-0.96646f,-1.54925f,-1.53032f,-1.00772f,-0.42112f,-0.63497f,-1.37540f,-1.17754f,0.48492f,2.94585f,5.61932f,7.87900f,8.99220f}, - {8.04368f,8.88487f,9.24731f,9.76871f,10.30385f,10.32830f,9.60849f,7.94603f,4.81731f,-0.08975f,-6.10101f,-11.65411f,-15.25677f,-16.15822f,-14.52060f,-11.22653f,-7.24580f,-3.44558f,-0.61333f,1.25309f,2.76805f,3.73177f,3.36695f,1.97948f,0.74967f,0.13075f,-0.18979f,-0.42444f,-0.85420f,-1.93961f,-3.28866f,-3.62225f,-2.35247f,0.08639f,3.11990f,6.05468f,8.04368f}, - {6.44887f,8.52898f,10.00772f,11.25814f,12.19628f,12.38325f,11.43950f,9.05774f,4.87180f,-1.07081f,-7.58681f,-12.76972f,-15.34699f,-15.21292f,-13.06213f,-9.80318f,-6.10115f,-2.52848f,0.26062f,2.11110f,3.47313f,4.40612f,4.43031f,3.60979f,2.68625f,2.01876f,1.34276f,0.35243f,-1.18272f,-3.35038f,-5.50704f,-6.45531f,-5.60558f,-3.25332f,0.01287f,3.49652f,6.44887f}, - {4.61309f,7.91484f,10.67459f,12.86217f,14.28349f,14.59916f,13.44634f,10.43327f,5.19620f,-1.95110f,-9.25904f,-14.43995f,-16.45824f,-15.72227f,-13.22423f,-9.85034f,-6.14231f,-2.53072f,0.48676f,2.68447f,4.29956f,5.52570f,6.19623f,6.20084f,5.73301f,4.92006f,3.60085f,1.53163f,-1.39438f,-4.87688f,-7.94536f,-9.43097f,-8.85100f,-6.51552f,-3.06017f,0.84306f,4.61309f}, - {3.21875f,7.41586f,11.19354f,14.28261f,16.32057f,16.89633f,15.56524f,11.80300f,5.20653f,-3.55470f,-11.97809f,-17.43029f,-19.22616f,-18.17302f,-15.37952f,-11.69571f,-7.65025f,-3.63286f,-0.01295f,2.99661f,5.46716f,7.56207f,9.25413f,10.31810f,10.49165f,9.54146f,7.26006f,3.54973f,-1.33752f,-6.50635f,-10.55663f,-12.38793f,-11.79132f,-9.25449f,-5.49875f,-1.18292f,3.21875f}, - {2.52051f,7.33138f,11.79037f,15.58977f,18.29190f,19.30865f,17.85567f,12.95067f,3.98293f,-7.53431f,-17.54806f,-23.19596f,-24.60407f,-23.07402f,-19.77569f,-15.49637f,-10.73649f,-5.85097f,-1.12175f,3.26826f,7.26895f,10.88888f,14.03678f,16.41453f,17.52792f,16.76756f,13.54324f,7.61980f,-0.22282f,-7.89770f,-13.19396f,-15.21847f,-14.33135f,-11.37454f,-7.18383f,-2.40863f,2.52051f}, - {2.02983f,7.36989f,12.37081f,16.71056f,19.89761f,21.11515f,18.97400f,11.40232f,-2.70274f,-18.81527f,-29.66002f,-33.88571f,-33.57644f,-30.58814f,-26.04521f,-20.59815f,-14.64262f,-8.44459f,-2.20066f,3.93897f,9.85468f,15.42277f,20.45728f,24.64081f,27.44761f,28.04182f,25.18387f,17.54097f,5.49796f,-6.72811f,-14.58218f,-17.34691f,-16.39748f,-13.14509f,-8.58967f,-3.38880f,2.02983f}, - {0.42359f,5.67280f,10.45897f,14.18719f,15.84273f,13.44387f,3.31185f,-17.06908f,-37.86930f,-48.41039f,-50.74957f,-48.66334f,-44.20871f,-38.40471f,-31.78712f,-24.66267f,-17.22360f,-9.60278f,-1.90231f,5.78964f,13.38658f,20.79088f,27.87654f,34.46122f,40.25514f,44.75763f,47.03469f,45.25758f,36.18138f,17.77476f,-1.60905f,-12.11869f,-14.89059f,-13.37813f,-9.65915f,-4.84192f,0.42359f}, - {-178.76222f,-168.76222f,-158.76222f,-148.76222f,-138.76222f,-128.76222f,-118.76222f,-108.76222f,-98.76222f,-88.76222f,-78.76222f,-68.76222f,-58.76222f,-48.76222f,-38.76222f,-28.76222f,-18.76222f,-8.76222f,1.23778f,11.23778f,21.23778f,31.23778f,41.23778f,51.23778f,61.23778f,71.23778f,81.23778f,91.23778f,101.23778f,111.23778f,121.23778f,131.23778f,141.23778f,151.23778f,161.23778f,171.23778f,-178.76222f} + {148.63040f,138.63040f,128.63040f,118.63040f,108.63040f,98.63040f,88.63040f,78.63040f,68.63040f,58.63040f,48.63040f,38.63040f,28.63040f,18.63040f,8.63040f,-1.36960f,-11.36960f,-21.36960f,-31.36960f,-41.36960f,-51.36960f,-61.36960f,-71.36960f,-81.36960f,-91.36960f,-101.36960f,-111.36960f,-121.36960f,-131.36960f,-141.36960f,-151.36960f,-161.36960f,-171.36960f,178.63040f,168.63040f,158.63040f,148.63040f}, + {128.87816f,116.70769f,105.62443f,95.48127f,86.09683f,77.29367f,68.91718f,60.84302f,52.97822f,45.25811f,37.64003f,30.09478f,22.59702f,15.11676f,7.61418f,0.03947f,-7.66207f,-15.54157f,-23.63819f,-31.97410f,-40.55489f,-49.37538f,-58.42917f,-67.71936f,-77.26833f,-87.12519f,-97.37007f,-108.11458f,-119.49579f,-131.65830f,-144.71588f,-158.68662f,-173.41452f,171.47213f,156.49935f,142.18469f,128.87816f}, + {85.86755f,77.88182f,71.42849f,65.89217f,60.86962f,56.04972f,51.17842f,46.06489f,40.60132f,34.77619f,28.67056f,22.43282f,16.23087f,10.18755f,4.31917f,-1.49067f,-7.45797f,-13.81467f,-20.71641f,-28.18762f,-36.12471f,-44.34676f,-52.66473f,-60.93937f,-69.11381f,-77.22546f,-85.41334f,-93.94372f,-103.29064f,-114.35005f,-128.97727f,-151.06023f,174.83520f,137.67818f,112.23020f,96.52063f,85.86756f}, + {48.43188f,46.98353f,45.36982f,43.80186f,42.32760f,40.82382f,38.99678f,36.46379f,32.90329f,28.18877f,22.45599f,16.10387f,9.71432f,3.86202f,-1.14650f,-5.45997f,-9.64078f,-14.38658f,-20.18766f,-27.11174f,-34.80967f,-42.71859f,-50.31107f,-57.23008f,-63.28782f,-68.39719f,-72.47622f,-75.31221f,-76.30788f,-73.74072f,-61.55512f,-18.96160f,29.20071f,44.46666f,48.67974f,49.28540f,48.43188f}, + {31.58850f,31.74835f,31.39924f,30.87678f,30.43574f,30.19800f,29.98360f,29.24010f,27.23113f,23.37602f,17.54538f,10.24099f,2.57680f,-4.11819f,-8.98330f,-12.08874f,-14.32383f,-16.91831f,-20.97106f,-26.92020f,-34.17714f,-41.56631f,-48.09571f,-53.19469f,-56.53278f,-57.82558f,-56.66031f,-52.27310f,-43.55594f,-29.95085f,-13.24765f,2.54212f,14.60798f,22.72224f,27.72553f,30.44935f,31.58850f}, + {22.79850f,23.32533f,23.34746f,23.05694f,22.66226f,22.42885f,22.46289f,22.41289f,21.37705f,18.23370f,12.30982f,4.02530f,-4.93197f,-12.42012f,-17.23389f,-19.62803f,-20.56810f,-20.93312f,-21.98947f,-25.41090f,-31.19026f,-37.44166f,-42.49725f,-45.51856f,-46.02918f,-43.74555f,-38.55838f,-30.56411f,-20.73773f,-11.07131f,-2.79308f,4.21937f,10.21441f,15.15242f,18.92948f,21.44642f,22.79850f}, + {17.16987f,17.68582f,17.85385f,17.73377f,17.34906f,16.86130f,16.52747f,16.34574f,15.56790f,12.74839f,6.74610f,-2.00418f,-11.22826f,-18.37193f,-22.46233f,-24.19496f,-24.47888f,-23.22908f,-20.72783f,-19.60150f,-21.98233f,-26.43395f,-30.43203f,-32.35125f,-31.47499f,-27.95264f,-22.40690f,-15.51422f,-8.63620f,-3.35146f,0.42144f,3.87188f,7.48128f,10.95260f,13.91406f,16.01563f,17.16987f}, + {13.46149f,13.75829f,13.85281f,13.81813f,13.52893f,12.94281f,12.32698f,11.88976f,11.00215f,8.11359f,1.99478f,-6.62228f,-15.08744f,-21.05798f,-23.92224f,-24.34577f,-23.04831f,-19.84546f,-14.88685f,-10.38631f,-9.06427f,-11.31395f,-15.06340f,-17.65505f,-17.71488f,-15.54256f,-11.89991f,-7.27581f,-2.87289f,-0.16517f,1.24684f,2.97092f,5.51371f,8.29954f,10.80542f,12.58786f,13.46149f}, + {11.19370f,11.20122f,11.07257f,11.02175f,10.82482f,10.26986f,9.62418f,9.09716f,7.97068f,4.77978f,-1.35469f,-9.31946f,-16.55524f,-21.15274f,-22.50861f,-21.01857f,-17.63827f,-13.15823f,-8.29683f,-4.01764f,-1.51484f,-1.87967f,-4.62279f,-7.47003f,-8.63091f,-8.05888f,-6.24442f,-3.42551f,-0.62936f,0.67783f,0.89029f,1.80510f,3.93778f,6.48671f,8.83523f,10.50781f,11.19370f}, + {9.96310f,9.79689f,9.46606f,9.40362f,9.31492f,8.84240f,8.22130f,7.55735f,6.02850f,2.43377f,-3.55150f,-10.60044f,-16.54723f,-19.75861f,-19.59018f,-16.58982f,-12.16100f,-7.67553f,-3.93189f,-0.91522f,1.34973f,1.87637f,0.22653f,-2.15228f,-3.61566f,-3.90720f,-3.29932f,-1.83286f,-0.23997f,0.20367f,-0.19418f,0.32122f,2.29252f,4.85536f,7.33778f,9.21090f,9.96310f}, + {9.18888f,9.24336f,8.98253f,9.05281f,9.17191f,8.83598f,8.10836f,7.00345f,4.80464f,0.69064f,-5.15618f,-11.30079f,-15.93916f,-17.74937f,-16.42349f,-12.86230f,-8.44857f,-4.38855f,-1.42704f,0.70613f,2.51072f,3.31152f,2.34785f,0.48172f,-0.89199f,-1.49634f,-1.59901f,-1.18437f,-0.66243f,-0.94842f,-1.78088f,-1.62463f,0.11657f,2.73547f,5.55820f,7.95812f,9.18888f}, + {8.09034f,8.95675f,9.30400f,9.80188f,10.27100f,10.13647f,9.19791f,7.38846f,4.25004f,-0.60600f,-6.53915f,-11.93135f,-15.26054f,-15.79066f,-13.79060f,-10.27561f,-6.25103f,-2.56551f,0.07346f,1.80766f,3.24155f,4.05015f,3.51428f,2.10305f,0.93136f,0.25053f,-0.27213f,-0.70545f,-1.24346f,-2.37500f,-3.75122f,-4.07408f,-2.71911f,-0.15132f,2.99380f,6.02278f,8.09034f}, + {6.27792f,8.37723f,9.88296f,11.16334f,12.08487f,12.15767f,11.03142f,8.51947f,4.34248f,-1.47518f,-7.78911f,-12.71269f,-15.01118f,-14.61457f,-12.25578f,-8.87216f,-5.13675f,-1.63793f,0.99774f,2.71417f,3.98293f,4.78698f,4.67468f,3.82712f,2.93970f,2.18792f,1.25958f,-0.01231f,-1.71794f,-3.92282f,-6.03566f,-6.90283f,-5.95491f,-3.51614f,-0.20102f,3.30598f,6.27792f}, + {4.15672f,7.47883f,10.31556f,12.59798f,14.06987f,14.34572f,13.08042f,9.97537f,4.77447f,-2.16465f,-9.14687f,-14.00316f,-15.77819f,-14.88455f,-12.28640f,-8.84845f,-5.11869f,-1.55612f,1.34605f,3.41756f,4.91977f,6.01696f,6.56254f,6.51350f,6.02774f,5.09138f,3.48456f,1.07344f,-2.08240f,-5.60383f,-8.56486f,-9.89888f,-9.20525f,-6.83312f,-3.41374f,0.42499f,4.15672f}, + {2.38746f,6.60961f,10.51138f,13.76537f,15.94256f,16.59043f,15.27093f,11.52705f,5.06990f,-3.36003f,-11.36932f,-16.51244f,-18.15167f,-17.03678f,-14.21651f,-10.51524f,-6.47146f,-2.49805f,1.03216f,3.92789f,6.27640f,8.24229f,9.81368f,10.78355f,10.85070f,9.68870f,7.04509f,2.91449f,-2.25894f,-7.44786f,-11.30963f,-12.92043f,-12.20858f,-9.70263f,-6.08438f,-1.92562f,2.38746f}, + {1.14371f,5.95768f,10.55039f,14.56595f,17.51248f,18.77049f,17.56825f,12.99646f,4.54568f,-6.33792f,-15.91121f,-21.43028f,-22.88293f,-21.44177f,-18.22110f,-13.99911f,-9.28961f,-4.46489f,0.18470f,4.47851f,8.37200f,11.87759f,14.90388f,17.13814f,18.04159f,16.93503f,13.18748f,6.66358f,-1.56678f,-9.20492f,-14.20053f,-15.96059f,-14.99797f,-12.15657f,-8.19328f,-3.64820f,1.14371f}, + {-0.35955f,4.92766f,9.99739f,14.51863f,17.99503f,19.64821f,18.23668f,11.99980f,-0.09657f,-14.74873f,-25.55246f,-30.33910f,-30.58104f,-28.00627f,-23.75441f,-18.51083f,-12.70165f,-6.61593f,-0.46628f,5.58665f,11.41580f,16.88997f,21.81133f,25.83916f,28.40134f,28.57592f,24.99531f,16.28607f,3.28542f,-9.10495f,-16.59733f,-19.05958f,-18.04316f,-14.91590f,-10.58486f,-5.61478f,-0.35955f}, + {-5.35521f,-0.10619f,4.69597f,8.54683f,10.65268f,9.65875f,3.42678f,-9.71040f,-26.04578f,-37.63969f,-42.28407f,-42.02380f,-38.82980f,-33.88684f,-27.86664f,-21.16414f,-14.02720f,-6.62426f,0.91924f,8.49972f,16.02040f,23.37681f,30.43782f,37.01500f,42.80483f,47.26542f,49.32663f,46.69337f,34.75696f,10.85970f,-10.89085f,-20.36338f,-21.94791f,-19.71753f,-15.63466f,-10.66363f,-5.35521f}, + {-166.99999f,-156.99999f,-146.99999f,-136.99999f,-126.99999f,-116.99999f,-106.99999f,-96.99999f,-86.99999f,-76.99999f,-66.99999f,-56.99999f,-46.99999f,-36.99999f,-26.99999f,-16.99999f,-6.99999f,3.00001f,13.00001f,23.00001f,33.00000f,43.00000f,53.00000f,63.00000f,73.00000f,83.00000f,93.00000f,103.00000f,113.00000f,123.00000f,133.00000f,143.00000f,153.00000f,163.00000f,173.00000f,-177.00000f,-167.00000f} }; #else /* !NAV_AUTO_MAG_DECLINATION_PRECISE */ @@ -45,19 +45,19 @@ static const float declination_table[19][37] = { #define SAMPLING_MAX_LAT 60.00000f static const int8_t declination_table[13][37] = { - {48,46,45,43,42,41,39,37,33,28,23,16,10,4,-1,-6,-10,-15,-20,-27,-34,-42,-50,-56,-62,-68,-72,-74,-75,-73,-61,-21,26,43,47,48,48}, - {31,31,31,31,30,30,30,29,27,24,18,11,3,-4,-9,-13,-15,-18,-21,-27,-34,-41,-47,-52,-56,-57,-56,-52,-44,-30,-14,2,14,22,27,30,31}, - {22,23,23,23,23,22,22,23,22,19,13,5,-4,-12,-17,-20,-22,-22,-23,-26,-31,-36,-42,-45,-46,-44,-39,-31,-21,-11,-3,4,10,15,19,21,22}, - {17,17,18,18,17,17,17,17,16,13,8,-1,-10,-18,-23,-25,-26,-25,-22,-20,-21,-25,-30,-32,-31,-28,-23,-16,-9,-3,0,4,7,11,14,16,17}, - {13,13,14,14,13,13,13,12,11,9,3,-5,-14,-20,-24,-25,-24,-21,-16,-11,-9,-11,-14,-17,-18,-16,-12,-8,-3,0,1,3,6,8,11,12,13}, - {11,11,11,11,11,10,10,9,8,5,0,-8,-16,-21,-23,-22,-19,-15,-10,-5,-2,-2,-4,-7,-9,-8,-6,-4,-1,1,1,2,4,7,9,10,11}, - {10,10,9,9,9,9,9,8,7,3,-3,-10,-16,-20,-20,-18,-13,-9,-5,-2,1,2,0,-2,-4,-4,-3,-2,0,0,0,1,3,5,7,9,10}, - {9,9,9,9,9,9,8,8,5,1,-5,-11,-16,-18,-17,-14,-10,-5,-2,0,2,3,2,0,-1,-2,-2,-1,0,-1,-1,-1,0,3,6,8,9}, - {8,9,9,10,10,10,10,8,5,0,-6,-12,-15,-16,-15,-11,-7,-3,-1,1,3,4,3,2,1,0,0,0,-1,-2,-3,-4,-2,0,3,6,8}, - {6,9,10,11,12,12,11,9,5,-1,-8,-13,-15,-15,-13,-10,-6,-3,0,2,3,4,4,4,3,2,1,0,-1,-3,-6,-6,-6,-3,0,3,6}, - {5,8,11,13,14,15,13,10,5,-2,-9,-14,-16,-16,-13,-10,-6,-3,0,3,4,6,6,6,6,5,4,2,-1,-5,-8,-9,-9,-7,-3,1,5}, - {3,7,11,14,16,17,16,12,5,-4,-12,-17,-19,-18,-15,-12,-8,-4,0,3,5,8,9,10,10,10,7,4,-1,-7,-11,-12,-12,-9,-5,-1,3}, - {3,7,12,16,18,19,18,13,4,-8,-18,-23,-25,-23,-20,-15,-11,-6,-1,3,7,11,14,16,18,17,14,8,0,-8,-13,-15,-14,-11,-7,-2,3} + {48,47,45,44,42,41,39,36,33,28,22,16,10,4,-1,-5,-10,-14,-20,-27,-35,-43,-50,-57,-63,-68,-72,-75,-76,-74,-62,-19,29,44,49,49,48}, + {32,32,31,31,30,30,30,29,27,23,18,10,3,-4,-9,-12,-14,-17,-21,-27,-34,-42,-48,-53,-57,-58,-57,-52,-44,-30,-13,3,15,23,28,30,32}, + {23,23,23,23,23,22,22,22,21,18,12,4,-5,-12,-17,-20,-21,-21,-22,-25,-31,-37,-42,-46,-46,-44,-39,-31,-21,-11,-3,4,10,15,19,21,23}, + {17,18,18,18,17,17,17,16,16,13,7,-2,-11,-18,-22,-24,-24,-23,-21,-20,-22,-26,-30,-32,-31,-28,-22,-16,-9,-3,0,4,7,11,14,16,17}, + {13,14,14,14,14,13,12,12,11,8,2,-7,-15,-21,-24,-24,-23,-20,-15,-10,-9,-11,-15,-18,-18,-16,-12,-7,-3,0,1,3,6,8,11,13,13}, + {11,11,11,11,11,10,10,9,8,5,-1,-9,-17,-21,-23,-21,-18,-13,-8,-4,-2,-2,-5,-7,-9,-8,-6,-3,-1,1,1,2,4,6,9,11,11}, + {10,10,9,9,9,9,8,8,6,2,-4,-11,-17,-20,-20,-17,-12,-8,-4,-1,1,2,0,-2,-4,-4,-3,-2,0,0,0,0,2,5,7,9,10}, + {9,9,9,9,9,9,8,7,5,1,-5,-11,-16,-18,-16,-13,-8,-4,-1,1,3,3,2,0,-1,-1,-2,-1,-1,-1,-2,-2,0,3,6,8,9}, + {8,9,9,10,10,10,9,7,4,-1,-7,-12,-15,-16,-14,-10,-6,-3,0,2,3,4,4,2,1,0,0,-1,-1,-2,-4,-4,-3,0,3,6,8}, + {6,8,10,11,12,12,11,9,4,-1,-8,-13,-15,-15,-12,-9,-5,-2,1,3,4,5,5,4,3,2,1,0,-2,-4,-6,-7,-6,-4,0,3,6}, + {4,7,10,13,14,14,13,10,5,-2,-9,-14,-16,-15,-12,-9,-5,-2,1,3,5,6,7,7,6,5,3,1,-2,-6,-9,-10,-9,-7,-3,0,4}, + {2,7,11,14,16,17,15,12,5,-3,-11,-17,-18,-17,-14,-11,-6,-2,1,4,6,8,10,11,11,10,7,3,-2,-7,-11,-13,-12,-10,-6,-2,2}, + {1,6,11,15,18,19,18,13,5,-6,-16,-21,-23,-21,-18,-14,-9,-4,0,4,8,12,15,17,18,17,13,7,-2,-9,-14,-16,-15,-12,-8,-4,1} }; #endif diff --git a/src/utils/declination.py b/src/utils/declination.py old mode 100644 new mode 100755 index 8608ffda95f..44f5c9f21db --- a/src/utils/declination.py +++ b/src/utils/declination.py @@ -14,7 +14,7 @@ import pathlib import sys -import igrf12 +import igrf import numpy as np SAMPLING_RES = 10 @@ -73,7 +73,7 @@ def declination_tables(query): for i, lat in enumerate(lats): for j, lon in enumerate(lons): - mag = igrf12.igrf(date, glat=lat, glon=lon, alt_km=0., isv=0, itype=1) + mag = igrf.igrf(date, glat=lat, glon=lon, alt_km=0., isv=0, itype=1) intensity[i][j] = mag.total / 1e5 inclination[i][j] = mag.incl declination[i][j] = mag.decl From a1d28a5e2c8f2f57112d4cc5f6de954dd3803f6e Mon Sep 17 00:00:00 2001 From: Marcelo Bezerra <23555060+mmosca@users.noreply.github.com> Date: Sat, 20 Apr 2024 21:46:05 +0200 Subject: [PATCH 203/241] Merge pull request #9807 from jhemcu/jhemcu-targets Target: Add JHEMCUF405WING, JHEMCUF745, JHEMCUH743HD board --- src/main/target/JHEMCUF405WING/CMakeLists.txt | 1 + src/main/target/JHEMCUF405WING/config.c | 42 ++++ src/main/target/JHEMCUF405WING/target.c | 47 ++++ src/main/target/JHEMCUF405WING/target.h | 163 ++++++++++++++ src/main/target/JHEMCUF745/CMakeLists.txt | 1 + src/main/target/JHEMCUF745/config.c | 29 +++ src/main/target/JHEMCUF745/target.c | 44 ++++ src/main/target/JHEMCUF745/target.h | 157 ++++++++++++++ src/main/target/JHEMCUH743HD/CMakeLists.txt | 1 + src/main/target/JHEMCUH743HD/config.c | 66 ++++++ src/main/target/JHEMCUH743HD/target.c | 49 +++++ src/main/target/JHEMCUH743HD/target.h | 205 ++++++++++++++++++ 12 files changed, 805 insertions(+) create mode 100644 src/main/target/JHEMCUF405WING/CMakeLists.txt create mode 100644 src/main/target/JHEMCUF405WING/config.c create mode 100644 src/main/target/JHEMCUF405WING/target.c create mode 100644 src/main/target/JHEMCUF405WING/target.h create mode 100644 src/main/target/JHEMCUF745/CMakeLists.txt create mode 100644 src/main/target/JHEMCUF745/config.c create mode 100644 src/main/target/JHEMCUF745/target.c create mode 100644 src/main/target/JHEMCUF745/target.h create mode 100644 src/main/target/JHEMCUH743HD/CMakeLists.txt create mode 100644 src/main/target/JHEMCUH743HD/config.c create mode 100644 src/main/target/JHEMCUH743HD/target.c create mode 100644 src/main/target/JHEMCUH743HD/target.h diff --git a/src/main/target/JHEMCUF405WING/CMakeLists.txt b/src/main/target/JHEMCUF405WING/CMakeLists.txt new file mode 100644 index 00000000000..fb99881c9bd --- /dev/null +++ b/src/main/target/JHEMCUF405WING/CMakeLists.txt @@ -0,0 +1 @@ +target_stm32f405xg(JHEMCUF405WING) diff --git a/src/main/target/JHEMCUF405WING/config.c b/src/main/target/JHEMCUF405WING/config.c new file mode 100644 index 00000000000..07f44ab29f7 --- /dev/null +++ b/src/main/target/JHEMCUF405WING/config.c @@ -0,0 +1,42 @@ +/* + * This file is part of INAV Project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * Alternatively, the contents of this file may be used under the terms + * of the GNU General Public License Version 3, as described below: + * + * This file is free software: you may copy, redistribute 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. + * + * This file 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 this program. If not, see http://www.gnu.org/licenses/. + */ + +#include +#include + +#include "platform.h" + +#include "fc/fc_msp_box.h" +#include "fc/config.h" +#include "io/serial.h" +#include "io/piniobox.h" + +void targetConfiguration(void) +{ + serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART1)].functionMask = FUNCTION_RX_SERIAL; + serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART3)].functionMask = FUNCTION_GPS; + serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART6)].functionMask = FUNCTION_MSP; + + pinioBoxConfigMutable()->permanentId[0] = BOX_PERMANENT_ID_USER1; +} diff --git a/src/main/target/JHEMCUF405WING/target.c b/src/main/target/JHEMCUF405WING/target.c new file mode 100644 index 00000000000..e8187f936b2 --- /dev/null +++ b/src/main/target/JHEMCUF405WING/target.c @@ -0,0 +1,47 @@ +/* + * This file is part of INAV. + * + * INAV 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. + * + * INAV 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 INAV. If not, see . + */ +#include +#include +#include + +#include "drivers/bus.h" +#include "drivers/io.h" +#include "drivers/pwm_mapping.h" +#include "drivers/timer.h" +#include "drivers/pinio.h" +#include "drivers/sensor.h" + +timerHardware_t timerHardware[] = { + DEF_TIM(TIM4, CH2, PB7, TIM_USE_OUTPUT_AUTO, 1, 0), // S1 D(1,3,2) + DEF_TIM(TIM4, CH1, PB6, TIM_USE_OUTPUT_AUTO, 1, 0), // S2 D(1,0,2) + + DEF_TIM(TIM3, CH3, PB0, TIM_USE_OUTPUT_AUTO, 1, 0), // S3 D(1,7,5) + DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 1, 0), // S4 D(1,2,5) + DEF_TIM(TIM8, CH3, PC8, TIM_USE_OUTPUT_AUTO, 1, 0), // S5 D(2,4,7) + DEF_TIM(TIM8, CH4, PC9, TIM_USE_OUTPUT_AUTO, 1, 0), // S6 D(2,7,7) + + DEF_TIM(TIM8, CH2N,PB14, TIM_USE_OUTPUT_AUTO, 1, 0), // S7 + DEF_TIM(TIM2, CH1, PA15, TIM_USE_OUTPUT_AUTO, 1, 0), // S8 + DEF_TIM(TIM2, CH3, PB10, TIM_USE_OUTPUT_AUTO, 1, 0), // S9 + DEF_TIM(TIM2, CH4, PB11, TIM_USE_OUTPUT_AUTO, 1, 0), // S10 + DEF_TIM(TIM12, CH2,PB15, TIM_USE_OUTPUT_AUTO, 1, 0), // S11 + + DEF_TIM(TIM1, CH1, PA8, TIM_USE_LED, 0, 0), // 2812LED + DEF_TIM(TIM5, CH3, PA2, TIM_USE_ANY, 0, 0), // TX2 +}; + +const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]); diff --git a/src/main/target/JHEMCUF405WING/target.h b/src/main/target/JHEMCUF405WING/target.h new file mode 100644 index 00000000000..fd64ff153d6 --- /dev/null +++ b/src/main/target/JHEMCUF405WING/target.h @@ -0,0 +1,163 @@ +/* + * This file is part of INAV. + * + * INAV 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. + * + * INAV 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 INAV. If not, see . + */ + +#pragma once + +#define USE_TARGET_CONFIG + +#define TARGET_BOARD_IDENTIFIER "JH45" +#define USBD_PRODUCT_STRING "JHEMCUF405WING" + +// LEDs +#define LED0 PA14 //Blue +#define LED1 PA13 //Green + +// Beeper +#define BEEPER PC15 +#define BEEPER_INVERTED + +// SPI1 +#define USE_SPI +#define USE_SPI_DEVICE_1 +#define SPI1_SCK_PIN PA5 +#define SPI1_MISO_PIN PA6 +#define SPI1_MOSI_PIN PA7 + +// SPI2 +#define USE_SPI_DEVICE_2 +#define SPI2_SCK_PIN PB13 +#define SPI2_MISO_PIN PC2 +#define SPI2_MOSI_PIN PC3 + +// SPI3 +#define USE_SPI_DEVICE_3 +#define SPI3_SCK_PIN PB3 +#define SPI3_MISO_PIN PB4 +#define SPI3_MOSI_PIN PB5 + +// Serial ports +#define USE_VCP + +#define USE_UART1 +#define UART1_TX_PIN PA9 +#define UART1_RX_PIN PA10 + +#define USE_UART2 +#define UART2_TX_PIN PA2 +#define UART2_RX_PIN PA3 + +#define USE_UART3 +#define UART3_TX_PIN PC10 +#define UART3_RX_PIN PC11 + +#define USE_UART4 +#define UART4_TX_PIN PA0 +#define UART4_RX_PIN PA1 + +#define USE_UART5 +#define UART5_TX_PIN PC12 +#define UART5_RX_PIN PD2 + +#define USE_UART6 +#define UART6_TX_PIN PC6 +#define UART6_RX_PIN PC7 + +// Optional Softserial on UART2 TX Pin PA2 +#define USE_SOFTSERIAL1 +#define SOFTSERIAL_1_TX_PIN PA2 +#define SOFTSERIAL_1_RX_PIN PA2 + +#define SERIAL_PORT_COUNT 8 + +#define USE_I2C +#define USE_I2C_DEVICE_1 +#define I2C1_SCL PB8 +#define I2C1_SDA PB9 + +// ICM42605/ICM42688P +#define USE_IMU_ICM42605 +#define IMU_ICM42605_ALIGN CW270_DEG +#define ICM42605_CS_PIN PA4 +#define ICM42605_SPI_BUS BUS_SPI1 + +// Baro +#define USE_BARO +#define BARO_I2C_BUS BUS_I2C1 +#define USE_BARO_ALL + +// Mag +#define USE_MAG +#define MAG_I2C_BUS BUS_I2C1 +#define USE_MAG_ALL + +#define RANGEFINDER_I2C_BUS BUS_I2C1 +#define PITOT_I2C_BUS BUS_I2C1 +#define TEMPERATURE_I2C_BUS BUS_I2C1 + +// OSD +#define USE_MAX7456 +#define MAX7456_CS_PIN PB12 +#define MAX7456_SPI_BUS BUS_SPI2 + +// SD Card +#define USE_SDCARD +#define USE_SDCARD_SPI +#define SDCARD_SPI_BUS BUS_SPI3 +#define SDCARD_CS_PIN PC14 + +#define ENABLE_BLACKBOX_LOGGING_ON_SDCARD_BY_DEFAULT + +#define DEFAULT_RX_TYPE RX_TYPE_SERIAL +#define SERIALRX_PROVIDER SERIALRX_CRSF +#define SERIALRX_UART SERIAL_PORT_USART1 + +// ADC +#define USE_ADC +#define ADC_INSTANCE ADC1 +#define ADC1_DMA_STREAM DMA2_Stream0 +#define ADC_CHANNEL_1_PIN PC0 +#define ADC_CHANNEL_2_PIN PC1 +#define ADC_CHANNEL_3_PIN PC5 +#define ADC_CHANNEL_4_PIN PC4 +#define VBAT_ADC_CHANNEL ADC_CHN_1 +#define CURRENT_METER_ADC_CHANNEL ADC_CHN_2 +#define RSSI_ADC_CHANNEL ADC_CHN_4 +#define AIRSPEED_ADC_CHANNEL ADC_CHN_3 + +// LED2812 +#define USE_LED_STRIP +#define WS2811_PIN PA8 + +// PINIO +#define USE_PINIO +#define USE_PINIOBOX +#define PINIO1_PIN PC13 // 2xCamera switcher + +// OTHERS +#define DEFAULT_FEATURES (FEATURE_TX_PROF_SEL | FEATURE_OSD | FEATURE_CURRENT_METER | FEATURE_VBAT | FEATURE_TELEMETRY | FEATURE_BLACKBOX | FEATURE_AIRMODE) +#define CURRENT_METER_SCALE 175 + +#define USE_DSHOT +#define USE_ESC_SENSOR +#define USE_SERIAL_4WAY_BLHELI_INTERFACE + +#define TARGET_IO_PORTA 0xffff +#define TARGET_IO_PORTB 0xffff +#define TARGET_IO_PORTC 0xffff +#define TARGET_IO_PORTD (BIT(2)) + +#define MAX_PWM_OUTPUT_PORTS 11 \ No newline at end of file diff --git a/src/main/target/JHEMCUF745/CMakeLists.txt b/src/main/target/JHEMCUF745/CMakeLists.txt new file mode 100644 index 00000000000..5f5a85e7c5d --- /dev/null +++ b/src/main/target/JHEMCUF745/CMakeLists.txt @@ -0,0 +1 @@ +target_stm32f745xg(JHEMCUF745) diff --git a/src/main/target/JHEMCUF745/config.c b/src/main/target/JHEMCUF745/config.c new file mode 100644 index 00000000000..fb2fe04f963 --- /dev/null +++ b/src/main/target/JHEMCUF745/config.c @@ -0,0 +1,29 @@ +/* + * This file is part of INAV. + * + * INAV 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. + * + * INAV 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 INAV. If not, see . + */ + +#include +#include + +#include + +#include "drivers/pwm_mapping.h" + +void targetConfiguration(void) +{ + timerOverridesMutable(timer2id(TIM1))->outputMode = OUTPUT_MODE_MOTORS; + timerOverridesMutable(timer2id(TIM3))->outputMode = OUTPUT_MODE_MOTORS; +} diff --git a/src/main/target/JHEMCUF745/target.c b/src/main/target/JHEMCUF745/target.c new file mode 100644 index 00000000000..f603cbe43be --- /dev/null +++ b/src/main/target/JHEMCUF745/target.c @@ -0,0 +1,44 @@ +/* + * This file is part of INAV. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * Alternatively, the contents of this file may be used under the terms + * of the GNU General Public License Version 3, as described below: + * + * This file is free software: you may copy, redistribute 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. + * + * This file 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 this program. If not, see http://www.gnu.org/licenses/. + */ + +#include +#include "drivers/io.h" +#include "drivers/pwm_mapping.h" +#include "drivers/timer.h" +#include "drivers/bus.h" +#include "drivers/pinio.h" + +timerHardware_t timerHardware[] = { + DEF_TIM(TIM3, CH3, PB0, TIM_USE_OUTPUT_AUTO, 0, 0), // M1, DMA1_ST7 + DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 0), // M2, DMA1_ST2 + DEF_TIM(TIM1, CH1, PE9, TIM_USE_OUTPUT_AUTO, 0, 0), // M3 + DEF_TIM(TIM1, CH2, PE11, TIM_USE_OUTPUT_AUTO, 0, 1), // M4, DMA2_ST4 + DEF_TIM(TIM8, CH4, PC9, TIM_USE_OUTPUT_AUTO, 0, 0), // M5, DMA2_ST7 + DEF_TIM(TIM5, CH4, PA3, TIM_USE_OUTPUT_AUTO, 0, 0), // M6, DMA1_ST1 + DEF_TIM(TIM3, CH1, PB4, TIM_USE_OUTPUT_AUTO, 0, 0), // S7 + DEF_TIM(TIM3, CH2, PB5, TIM_USE_OUTPUT_AUTO, 0, 0), // S8 + DEF_TIM(TIM4, CH1, PD12, TIM_USE_LED, 0, 0), // LED_STRIP, DMA1_ST0 +}; + +const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]); diff --git a/src/main/target/JHEMCUF745/target.h b/src/main/target/JHEMCUF745/target.h new file mode 100644 index 00000000000..dfd45749d2d --- /dev/null +++ b/src/main/target/JHEMCUF745/target.h @@ -0,0 +1,157 @@ +/* + * This file is part of INAV. + * + * Cleanflight and Betaflight are free software. You can redistribute + * this software and/or modify this software 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 and Betaflight are distributed in the hope that they + * 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 this software. + * + * If not, see . + */ + +#pragma once + +#define TARGET_BOARD_IDENTIFIER "JHF7" +#define USBD_PRODUCT_STRING "JHEMCUF745" + +#define LED0 PA2 + +#define BEEPER PD15 +#define BEEPER_INVERTED + +#define USE_DSHOT +#define USE_DSHOT_DMAR +#define USE_ESC_SENSOR + +#define USE_IMU_MPU6000 +#define IMU_MPU6000_ALIGN CW270_DEG +#define GYRO_INT_EXTI PE1 +#define MPU6000_CS_PIN SPI4_NSS_PIN +#define MPU6000_SPI_BUS BUS_SPI4 + +#define USE_IMU_ICM42605 +#define IMU_ICM42605_ALIGN CW270_DEG +#define ICM42605_CS_PIN SPI4_NSS_PIN +#define ICM42605_SPI_BUS BUS_SPI4 +#define ICM42605_EXTI_PIN PE1 + +#define USB_IO +#define USE_VCP +#define VBUS_SENSING_ENABLED +#define VBUS_SENSING_PIN PA8 + +#define USE_UART1 +#define UART1_TX_PIN PA9 +#define UART1_RX_PIN PA10 + +#define USE_UART2 +#define UART2_TX_PIN PD5 +#define UART2_RX_PIN PD6 + +#define USE_UART3 +#define UART3_TX_PIN PB10 +#define UART3_RX_PIN PB11 + +#define USE_UART4 +#define UART4_TX_PIN PA0 +#define UART4_RX_PIN PA1 + +#define USE_UART5 +#define UART5_TX_PIN PC12 +#define UART5_RX_PIN PD2 + +#define USE_UART6 +#define UART6_TX_PIN PC6 +#define UART6_RX_PIN PC7 + +#define USE_UART7 +#define UART7_RX_PIN PE7 +#define UART7_TX_PIN PE8 + +#define SERIAL_PORT_COUNT 8 // VCP,UART1,UART2,UART3,UART4,UART5,UART6 + +#define USE_SPI +#define USE_SPI_DEVICE_1 // FLASH +#define USE_SPI_DEVICE_2 // OSD +#define USE_SPI_DEVICE_4 // ICM20689 + +#define SPI1_NSS_PIN PA4 +#define SPI1_SCK_PIN PA5 +#define SPI1_MISO_PIN PA6 +#define SPI1_MOSI_PIN PA7 + +#define SPI2_NSS_PIN PB12 +#define SPI2_SCK_PIN PB13 +#define SPI2_MISO_PIN PB14 +#define SPI2_MOSI_PIN PB15 + +#define SPI4_NSS_PIN PE4 +#define SPI4_SCK_PIN PE2 +#define SPI4_MISO_PIN PE5 +#define SPI4_MOSI_PIN PE6 + +#define USE_MAX7456 +#define MAX7456_SPI_BUS BUS_SPI2 +#define MAX7456_CS_PIN SPI2_NSS_PIN + +#define M25P16_CS_PIN SPI1_NSS_PIN +#define M25P16_SPI_BUS BUS_SPI1 +#define USE_FLASHFS +#define USE_FLASH_M25P16 +#define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT + +#define USE_I2C +#define USE_I2C_DEVICE_1 +#define I2C1_SCL PB6 +#define I2C1_SDA PB7 + +// External I2C bus is the same as interal one +#define MAG_I2C_BUS BUS_I2C1 +#define TEMPERATURE_I2C_BUS BUS_I2C1 +#define RANGEFINDER_I2C_BUS BUS_I2C1 +#define DEFAULT_I2C_BUS BUS_I2C1 + +#define USE_BARO +#define USE_BARO_ALL +#define BARO_I2C_BUS BUS_I2C1 + +#define USE_MAG +#define USE_MAG_ALL + +#define USE_ADC +#define ADC_CHANNEL_1_PIN PC2 +#define ADC_CHANNEL_2_PIN PC3 +#define ADC_CHANNEL_3_PIN PC5 + +#define CURRENT_METER_ADC_CHANNEL ADC_CHN_1 +#define VBAT_ADC_CHANNEL ADC_CHN_2 +#define RSSI_ADC_CHANNEL ADC_CHN_3 + +#define ENABLE_BLACKBOX_LOGGING_ON_SDCARD_BY_DEFAULT + +#define DEFAULT_FEATURES (FEATURE_TX_PROF_SEL | FEATURE_TELEMETRY | FEATURE_OSD | FEATURE_VBAT | FEATURE_BLACKBOX) +#define DEFAULT_RX_TYPE RX_TYPE_SERIAL +#define SERIALRX_UART SERIAL_PORT_USART1 +#define SERIALRX_PROVIDER SERIALRX_SBUS + +#define USE_LED_STRIP +#define WS2811_PIN PD12 + +#define USE_SERIAL_4WAY_BLHELI_INTERFACE + +#define TARGET_IO_PORTA 0xffff +#define TARGET_IO_PORTB 0xffff +#define TARGET_IO_PORTC 0xffff +#define TARGET_IO_PORTD 0xffff +#define TARGET_IO_PORTE 0xffff + +#define MAX_PWM_OUTPUT_PORTS 8 diff --git a/src/main/target/JHEMCUH743HD/CMakeLists.txt b/src/main/target/JHEMCUH743HD/CMakeLists.txt new file mode 100644 index 00000000000..b0192886d6c --- /dev/null +++ b/src/main/target/JHEMCUH743HD/CMakeLists.txt @@ -0,0 +1 @@ +target_stm32h743xi(JHEMCUH743HD) \ No newline at end of file diff --git a/src/main/target/JHEMCUH743HD/config.c b/src/main/target/JHEMCUH743HD/config.c new file mode 100644 index 00000000000..4f0aea919e7 --- /dev/null +++ b/src/main/target/JHEMCUH743HD/config.c @@ -0,0 +1,66 @@ +/* + * 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 "config/config_master.h" +#include "config/feature.h" + +#include "drivers/sensor.h" +#include "drivers/pwm_esc_detect.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 "sensors/battery.h" +#include "sensors/sensors.h" + +#include "telemetry/telemetry.h" + +#include "io/piniobox.h" + +void targetConfiguration(void) +{ + pinioBoxConfigMutable()->permanentId[0] = BOX_PERMANENT_ID_USER1; + pinioBoxConfigMutable()->permanentId[1] = BOX_PERMANENT_ID_USER2; + + + /* + * UART1 is SerialRX + */ + serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART1)].functionMask = FUNCTION_RX_SERIAL; + + /* + * Enable MSP at 115200 at UART4 + */ + serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART4)].functionMask = FUNCTION_MSP; + serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART4)].msp_baudrateIndex = BAUD_115200; +} diff --git a/src/main/target/JHEMCUH743HD/target.c b/src/main/target/JHEMCUH743HD/target.c new file mode 100644 index 00000000000..adb753b9d17 --- /dev/null +++ b/src/main/target/JHEMCUH743HD/target.c @@ -0,0 +1,49 @@ +/* + * This file is part of INAV. + * + * INAV 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. + * + * INAV 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 INAV. If not, see . + */ + +#include + +#include "platform.h" + +#include "drivers/bus.h" +#include "drivers/io.h" +#include "drivers/pwm_mapping.h" +#include "drivers/timer.h" +#include "drivers/pinio.h" +#include "drivers/sensor.h" + +BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, MPU6000_SPI_BUS, MPU6000_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_MPU6000_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_bmi270, DEVHW_BMI270, BMI270_SPI_BUS, BMI270_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_BMI270_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_icm42605, DEVHW_ICM42605, ICM42605_SPI_BUS, ICM42605_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU_ICM42605_ALIGN); + + +timerHardware_t timerHardware[] = { + + DEF_TIM(TIM5, CH1, PA0, TIM_USE_OUTPUT_AUTO, 0, 0), // S1 + DEF_TIM(TIM5, CH2, PA1, TIM_USE_OUTPUT_AUTO, 0, 1), // S2 + DEF_TIM(TIM5, CH3, PA2, TIM_USE_OUTPUT_AUTO, 0, 2), // S3 + DEF_TIM(TIM5, CH4, PA3, TIM_USE_OUTPUT_AUTO, 0, 3), // S4 + + DEF_TIM(TIM3, CH3, PB0, TIM_USE_OUTPUT_AUTO, 0, 4), // S5 + DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 5), // S6 + DEF_TIM(TIM8, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 6), // S7 + DEF_TIM(TIM8, CH4, PC9, TIM_USE_OUTPUT_AUTO, 0, 7), // S8 + + DEF_TIM(TIM1, CH1, PA8, TIM_USE_LED, 0, 9), // LED_2812 +}; + +const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]); diff --git a/src/main/target/JHEMCUH743HD/target.h b/src/main/target/JHEMCUH743HD/target.h new file mode 100644 index 00000000000..92300b52564 --- /dev/null +++ b/src/main/target/JHEMCUH743HD/target.h @@ -0,0 +1,205 @@ +/* + * This file is part of INAV. + * + * INAV 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. + * + * INAV 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 INAV. If not, see . + */ + +#pragma once + +#define TARGET_BOARD_IDENTIFIER "JHEH743HD" +#define USBD_PRODUCT_STRING "JHEMCUH743HD" + +#define USE_TARGET_CONFIG + +#define LED0 PE5 +#define LED1 PE4 + +#define BEEPER PE3 +#define BEEPER_INVERTED + +// *************** IMU generic *********************** +#define USE_DUAL_GYRO +#define USE_TARGET_IMU_HARDWARE_DESCRIPTORS + +// *************** SPI1 IMU0 MPU6000 **************** +#define USE_SPI +#define USE_SPI_DEVICE_1 +#define SPI1_SCK_PIN PA5 +#define SPI1_MISO_PIN PA6 +#define SPI1_MOSI_PIN PA7 + +#define USE_IMU_MPU6000 +#define IMU_MPU6000_ALIGN CW180_DEG +#define MPU6000_SPI_BUS BUS_SPI1 +#define MPU6000_CS_PIN PA4 + +#define USE_IMU_BMI270 +#define IMU_BMI270_ALIGN CW180_DEG +#define BMI270_SPI_BUS BUS_SPI1 +#define BMI270_CS_PIN PA4 + +#define USE_IMU_ICM42605 +#define IMU_ICM42605_ALIGN CW180_DEG +#define ICM42605_SPI_BUS BUS_SPI1 +#define ICM42605_CS_PIN PA4 + +// *************** SPI2 OSD *********************** +#define USE_SPI_DEVICE_2 +#define SPI2_SCK_PIN PB13 +#define SPI2_MISO_PIN PB14 +#define SPI2_MOSI_PIN PB15 + +#define USE_MAX7456 +#define MAX7456_SPI_BUS BUS_SPI2 +#define MAX7456_CS_PIN PB12 + +// *************** SPI3 FLASH *********************** +#define USE_SPI_DEVICE_3 +#define SPI3_SCK_PIN PC10 +#define SPI3_MISO_PIN PC11 +#define SPI3_MOSI_PIN PB2 +#define SPI3_NSS_PIN PA15 +#define SPI3_SCK_AF GPIO_AF6_SPI3 +#define SPI3_MISO_AF GPIO_AF6_SPI3 +#define SPI3_MOSI_AF GPIO_AF7_SPI3 + +#define M25P16_SPI_BUS BUS_SPI3 +#define M25P16_CS_PIN SPI3_NSS_PIN + +#define W25N01G_SPI_BUS BUS_SPI3 +#define W25N01G_CS_PIN SPI3_NSS_PIN + +#define USE_BLACKBOX +#define USE_FLASHFS +#define USE_FLASH_M25P16 +#define USE_FLASH_W25N01G +#define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT + +// *************** I2C /Baro/Mag ********************* +#define USE_I2C +#define USE_I2C_DEVICE_1 +#define I2C1_SCL PB6 +#define I2C1_SDA PB7 + +#define USE_I2C_DEVICE_2 +#define I2C2_SCL PB10 +#define I2C2_SDA PB11 + +#define USE_BARO +#define BARO_I2C_BUS BUS_I2C1 +#define USE_BARO_ALL + +#define USE_MAG +#define MAG_I2C_BUS BUS_I2C1 +#define USE_MAG_ALL + +#define TEMPERATURE_I2C_BUS BUS_I2C1 +#define PITOT_I2C_BUS BUS_I2C1 + +#define USE_RANGEFINDER +#define RANGEFINDER_I2C_BUS BUS_I2C1 + +// *************** UART ***************************** +#define USE_VCP + +#define USE_UART1 +#define UART1_TX_PIN PA9 +#define UART1_RX_PIN PA10 + +#define USE_UART2 +#define UART2_TX_PIN PD5 +#define UART2_RX_PIN PD6 + +#define USE_UART3 +#define UART3_TX_PIN PD8 +#define UART3_RX_PIN PD9 + +#define USE_UART4 +#define UART4_TX_PIN PD1 +#define UART4_RX_PIN PD0 + +#define USE_UART5 +#define UART5_TX_PIN PC12 +#define UART5_RX_PIN PD2 + +#define USE_UART6 +#define UART6_TX_PIN PC6 +#define UART6_RX_PIN PC7 + +#define USE_UART7 +#define UART7_TX_PIN PE8 +#define UART7_RX_PIN PE7 + +#define USE_UART8 +#define UART8_TX_PIN PE1 +#define UART8_RX_PIN PE0 + +#define SERIAL_PORT_COUNT 9 + +#define DEFAULT_RX_TYPE RX_TYPE_SERIAL +#define SERIALRX_PROVIDER SERIALRX_SBUS + +// *************** ADC ***************************** +#define USE_ADC +#define ADC_INSTANCE ADC3 + +#ifdef MAMBAH743_2022B + +#define ADC_CHANNEL_1_PIN PC1 +#define ADC_CHANNEL_2_PIN PC3 +#define ADC_CHANNEL_3_PIN PC0 + +#define VBAT_ADC_CHANNEL ADC_CHN_1 +#define CURRENT_METER_ADC_CHANNEL ADC_CHN_2 +#define AIRSPEED_ADC_CHANNEL ADC_CHN_3 + +#else + +#define ADC_CHANNEL_1_PIN PC1 +#define ADC_CHANNEL_2_PIN PC3 +#define ADC_CHANNEL_3_PIN PC2 +#define ADC_CHANNEL_4_PIN PC0 + +#define VBAT_ADC_CHANNEL ADC_CHN_1 +#define CURRENT_METER_ADC_CHANNEL ADC_CHN_2 +#define RSSI_ADC_CHANNEL ADC_CHN_3 +#define AIRSPEED_ADC_CHANNEL ADC_CHN_4 + +#endif + +// *************** PINIO *************************** +#define USE_PINIO +#define USE_PINIOBOX + +#define PINIO1_PIN PC2 +#define PINIO2_PIN PC5 + +// *************** LEDSTRIP ************************ +#define USE_LED_STRIP +#define WS2811_PIN PA8 + +#define DEFAULT_FEATURES (FEATURE_OSD | FEATURE_TELEMETRY | FEATURE_CURRENT_METER | FEATURE_VBAT | FEATURE_TX_PROF_SEL) +#define CURRENT_METER_SCALE 250 + +#define USE_SERIAL_4WAY_BLHELI_INTERFACE + +#define TARGET_IO_PORTA 0xffff +#define TARGET_IO_PORTB 0xffff +#define TARGET_IO_PORTC 0xffff +#define TARGET_IO_PORTD 0xffff +#define TARGET_IO_PORTE 0xffff + +#define MAX_PWM_OUTPUT_PORTS 8 +#define USE_DSHOT +#define USE_ESC_SENSOR \ No newline at end of file From 269f1f915b8b36e2c2f07d4a4ffeed58cae65651 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Sun, 21 Apr 2024 11:53:21 +0200 Subject: [PATCH 204/241] Fix ZEEZF7 output mapping --- src/main/target/ZEEZF7/target.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/target/ZEEZF7/target.c b/src/main/target/ZEEZF7/target.c index f1f5356dcb2..79bfc08d2cb 100755 --- a/src/main/target/ZEEZF7/target.c +++ b/src/main/target/ZEEZF7/target.c @@ -32,9 +32,9 @@ timerHardware_t timerHardware[] = { DEF_TIM(TIM3, CH1, PB4, TIM_USE_OUTPUT_AUTO, 0, 0), // S3 DEF_TIM(TIM2, CH2, PB3, TIM_USE_OUTPUT_AUTO, 0, 0), // S4 DEF_TIM(TIM8, CH1, PC6, TIM_USE_OUTPUT_AUTO, 0, 1), // S5 - DEF_TIM(TIM3, CH2, PC7, TIM_USE_OUTPUT_AUTO, 0, 0), // S6 - DEF_TIM(TIM3, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 0), // S7 - DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 0), // S8 + DEF_TIM(TIM8, CH2, PC7, TIM_USE_OUTPUT_AUTO, 0, 0), // S6 + DEF_TIM(TIM8, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 0), // S7 + DEF_TIM(TIM1, CH3N, PB1, TIM_USE_OUTPUT_AUTO, 0, 0), // S8 #endif #ifdef ZEEZF7V2 @@ -42,10 +42,10 @@ timerHardware_t timerHardware[] = { DEF_TIM(TIM4, CH1, PB6, TIM_USE_OUTPUT_AUTO, 0, 0), // S2 DEF_TIM(TIM3, CH1, PB4, TIM_USE_OUTPUT_AUTO, 0, 0), // S3 DEF_TIM(TIM2, CH2, PB3, TIM_USE_OUTPUT_AUTO, 0, 0), // S4 - DEF_TIM(TIM3, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 0), // S5 - DEF_TIM(TIM3, CH2, PC7, TIM_USE_OUTPUT_AUTO, 0, 0), // S6 + DEF_TIM(TIM8, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 0), // S5 + DEF_TIM(TIM8, CH2, PC7, TIM_USE_OUTPUT_AUTO, 0, 0), // S6 DEF_TIM(TIM8, CH1, PC6, TIM_USE_OUTPUT_AUTO, 0, 1), // S7 - DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 0), // S8 + DEF_TIM(TIM1, CH3N, PB1, TIM_USE_OUTPUT_AUTO, 0, 0), // S8 #endif #ifdef ZEEZF7 From 7dabfb0ddfe4d424f19beedc5a7a1968ead4492f Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Sun, 21 Apr 2024 11:53:21 +0200 Subject: [PATCH 205/241] Fix ZEEZF7 output mapping --- src/main/target/ZEEZF7/target.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/target/ZEEZF7/target.c b/src/main/target/ZEEZF7/target.c index f1f5356dcb2..79bfc08d2cb 100755 --- a/src/main/target/ZEEZF7/target.c +++ b/src/main/target/ZEEZF7/target.c @@ -32,9 +32,9 @@ timerHardware_t timerHardware[] = { DEF_TIM(TIM3, CH1, PB4, TIM_USE_OUTPUT_AUTO, 0, 0), // S3 DEF_TIM(TIM2, CH2, PB3, TIM_USE_OUTPUT_AUTO, 0, 0), // S4 DEF_TIM(TIM8, CH1, PC6, TIM_USE_OUTPUT_AUTO, 0, 1), // S5 - DEF_TIM(TIM3, CH2, PC7, TIM_USE_OUTPUT_AUTO, 0, 0), // S6 - DEF_TIM(TIM3, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 0), // S7 - DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 0), // S8 + DEF_TIM(TIM8, CH2, PC7, TIM_USE_OUTPUT_AUTO, 0, 0), // S6 + DEF_TIM(TIM8, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 0), // S7 + DEF_TIM(TIM1, CH3N, PB1, TIM_USE_OUTPUT_AUTO, 0, 0), // S8 #endif #ifdef ZEEZF7V2 @@ -42,10 +42,10 @@ timerHardware_t timerHardware[] = { DEF_TIM(TIM4, CH1, PB6, TIM_USE_OUTPUT_AUTO, 0, 0), // S2 DEF_TIM(TIM3, CH1, PB4, TIM_USE_OUTPUT_AUTO, 0, 0), // S3 DEF_TIM(TIM2, CH2, PB3, TIM_USE_OUTPUT_AUTO, 0, 0), // S4 - DEF_TIM(TIM3, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 0), // S5 - DEF_TIM(TIM3, CH2, PC7, TIM_USE_OUTPUT_AUTO, 0, 0), // S6 + DEF_TIM(TIM8, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 0), // S5 + DEF_TIM(TIM8, CH2, PC7, TIM_USE_OUTPUT_AUTO, 0, 0), // S6 DEF_TIM(TIM8, CH1, PC6, TIM_USE_OUTPUT_AUTO, 0, 1), // S7 - DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 0), // S8 + DEF_TIM(TIM1, CH3N, PB1, TIM_USE_OUTPUT_AUTO, 0, 0), // S8 #endif #ifdef ZEEZF7 From 3e961f725d3c157ef1f17e746f3f25d8aad342ee Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Sun, 21 Apr 2024 11:58:22 +0200 Subject: [PATCH 206/241] Fix line endings --- src/main/target/TAKERF722SE/target.c | 96 +++---- src/main/target/TAKERF722SE/target.h | 372 +++++++++++++-------------- 2 files changed, 234 insertions(+), 234 deletions(-) diff --git a/src/main/target/TAKERF722SE/target.c b/src/main/target/TAKERF722SE/target.c index 247efb84e52..d67062a9fbc 100644 --- a/src/main/target/TAKERF722SE/target.c +++ b/src/main/target/TAKERF722SE/target.c @@ -1,48 +1,48 @@ -/* -* This file is part of INAV Project. -* -* INAV 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. -* -* INAV 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 INAV. If not, see . -*/ - -#include - -#include "platform.h" -#include "drivers/io.h" - -#include "drivers/dma.h" -#include "drivers/timer.h" -#include "drivers/timer_def.h" - - - - - -timerHardware_t timerHardware[] = { - - DEF_TIM(TIM3, CH1, PB4, TIM_USE_OUTPUT_AUTO, 0, 0), - DEF_TIM(TIM3, CH2, PB5, TIM_USE_OUTPUT_AUTO, 0, 0), - DEF_TIM(TIM3, CH3, PB0, TIM_USE_OUTPUT_AUTO, 0, 0), - DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 0), - - DEF_TIM(TIM4, CH1, PB6, TIM_USE_OUTPUT_AUTO, 0, 0), - DEF_TIM(TIM4, CH2, PB7, TIM_USE_OUTPUT_AUTO, 0, 0), - DEF_TIM(TIM8, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 0), - DEF_TIM(TIM8, CH4, PC9, TIM_USE_OUTPUT_AUTO, 0, 0), - - DEF_TIM(TIM1, CH1, PA8, TIM_USE_LED, 0, 0), -}; - -const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]); - - +/* +* This file is part of INAV Project. +* +* INAV 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. +* +* INAV 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 INAV. If not, see . +*/ + +#include + +#include "platform.h" +#include "drivers/io.h" + +#include "drivers/dma.h" +#include "drivers/timer.h" +#include "drivers/timer_def.h" + + + + + +timerHardware_t timerHardware[] = { + + DEF_TIM(TIM3, CH1, PB4, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM3, CH2, PB5, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM3, CH3, PB0, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 0), + + DEF_TIM(TIM4, CH1, PB6, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM4, CH2, PB7, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM8, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM8, CH4, PC9, TIM_USE_OUTPUT_AUTO, 0, 0), + + DEF_TIM(TIM1, CH1, PA8, TIM_USE_LED, 0, 0), +}; + +const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]); + + diff --git a/src/main/target/TAKERF722SE/target.h b/src/main/target/TAKERF722SE/target.h index 61ab442653d..817dc535f03 100644 --- a/src/main/target/TAKERF722SE/target.h +++ b/src/main/target/TAKERF722SE/target.h @@ -1,186 +1,186 @@ -/* - * This file is part of INAV Project. - * - * 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. - * - * INAV 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 INAV. If not, see . - */ - -#pragma once - -#define TARGET_BOARD_IDENTIFIER "GEPR" - -#define USBD_PRODUCT_STRING "TAKERF722SE" - -#define LED0 PC14 - - -// *************** BEEPER ************************ - -#define BEEPER PC13 -#define BEEPER_INVERTED - - -// *************** LEDSTRIP ************************ -#define USE_LED_STRIP -#define WS2811_PIN PA8 - - -// *************** UART ***************************** -#define USE_VCP - -#define USE_UART1 -#define UART1_TX_PIN PA9 -#define UART1_RX_PIN PA10 - -#define USE_UART2 -#define UART2_TX_PIN PA2 -#define UART2_RX_PIN PA3 - -#define USE_UART3 -#define UART3_TX_PIN PB10 -#define UART3_RX_PIN PB11 - -#define USE_UART4 -#define UART4_TX_PIN PA0 -#define UART4_RX_PIN PA1 - -#define USE_UART5 -#define UART5_TX_PIN PC12 -#define UART5_RX_PIN PD2 - -#define USE_UART6 -#define UART6_TX_PIN PC6 -#define UART6_RX_PIN PC7 - - -#define SERIAL_PORT_COUNT 7 - -#define DEFAULT_RX_TYPE RX_TYPE_SERIAL -#define SERIALRX_PROVIDER SERIALRX_SBUS -#define SERIALRX_UART SERIAL_PORT_USART2 - - -// *************** SPI Bus ********************** - -#define USE_SPI - -#define USE_SPI_DEVICE_1 -#define SPI1_SCK_PIN PA5 -#define SPI1_MISO_PIN PA6 -#define SPI1_MOSI_PIN PA7 - -#define USE_SPI_DEVICE_2 -#define SPI2_SCK_PIN PB13 -#define SPI2_MISO_PIN PB14 -#define SPI2_MOSI_PIN PB15 - -#define USE_SPI_DEVICE_3 -#define SPI3_SCK_PIN PC10 -#define SPI3_MISO_PIN PC11 -#define SPI3_MOSI_PIN PB2 -#define SPI3_SCK_AF GPIO_AF6_SPI3 -#define SPI3_MISO_AF GPIO_AF6_SPI3 -#define SPI3_MOSI_AF GPIO_AF7_SPI3 - - -// *************** Gyro & ACC ********************** - -#define USE_IMU_MPU6000 -#define IMU_MPU6000_ALIGN CW0_DEG -#define MPU6000_CS_PIN PA4 -#define MPU6000_SPI_BUS BUS_SPI1 - - -#define USE_IMU_ICM42605 -#define IMU_ICM42605_ALIGN CW0_DEG -#define ICM42605_CS_PIN PA4 -#define ICM42605_SPI_BUS BUS_SPI1 - -// *************** I2C/Baro/Mag ********************* -#define USE_I2C -#define USE_I2C_DEVICE_1 -#define I2C1_SCL PB8 -#define I2C1_SDA PB9 - - -//*************************************************** -#define USE_BARO -#define BARO_I2C_BUS BUS_I2C1 -#define USE_BARO_BMP280 -#define USE_BARO_DPS310 -#define USE_BARO_MS5611 - -#define USE_MAG -#define MAG_I2C_BUS BUS_I2C1 -#define USE_MAG_HMC5883 -#define USE_MAG_QMC5883 -#define USE_MAG_IST8310 -#define USE_MAG_IST8308 - -#define TEMPERATURE_I2C_BUS BUS_I2C1 - -#define PITOT_I2C_BUS BUS_I2C1 - -#define USE_RANGEFINDER -#define RANGEFINDER_I2C_BUS BUS_I2C1 -#define BNO055_I2C_BUS BUS_I2C1 - -// *************** FLASH ************************** - -#define USE_FLASHFS - -#define USE_FLASH_M25P16 -#define M25P16_CS_PIN PA15 -#define M25P16_SPI_BUS BUS_SPI3 - -#define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT - -// *************** OSD ***************************** - -#define USE_MAX7456 -#define MAX7456_SPI_BUS BUS_SPI2 -#define MAX7456_CS_PIN PB12 - -// *************** ADC ***************************** - -#define USE_ADC -#define ADC_INSTANCE ADC1 -#define ADC1_DMA_STREAM DMA2_Stream0 -#define ADC_CHANNEL_1_PIN PC3 -#define ADC_CHANNEL_2_PIN PC0 -#define ADC_CHANNEL_3_PIN PC2 - -#define VBAT_ADC_CHANNEL ADC_CHN_1 -#define RSSI_ADC_CHANNEL ADC_CHN_2 -#define CURRENT_METER_ADC_CHANNEL ADC_CHN_3 - - -#define DEFAULT_FEATURES (FEATURE_TX_PROF_SEL | FEATURE_CURRENT_METER | FEATURE_TELEMETRY | FEATURE_VBAT | FEATURE_OSD | FEATURE_BLACKBOX) - - - - -//************************************************** - -#define USE_SERIAL_4WAY_BLHELI_INTERFACE - -#define TARGET_IO_PORTA 0xffff -#define TARGET_IO_PORTB 0xffff -#define TARGET_IO_PORTC 0xffff -#define TARGET_IO_PORTD (BIT(2)) - - -#define MAX_PWM_OUTPUT_PORTS 8 - -#define USE_DSHOT -#define USE_ESC_SENSOR +/* + * This file is part of INAV Project. + * + * 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. + * + * INAV 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 INAV. If not, see . + */ + +#pragma once + +#define TARGET_BOARD_IDENTIFIER "GEPR" + +#define USBD_PRODUCT_STRING "TAKERF722SE" + +#define LED0 PC14 + + +// *************** BEEPER ************************ + +#define BEEPER PC13 +#define BEEPER_INVERTED + + +// *************** LEDSTRIP ************************ +#define USE_LED_STRIP +#define WS2811_PIN PA8 + + +// *************** UART ***************************** +#define USE_VCP + +#define USE_UART1 +#define UART1_TX_PIN PA9 +#define UART1_RX_PIN PA10 + +#define USE_UART2 +#define UART2_TX_PIN PA2 +#define UART2_RX_PIN PA3 + +#define USE_UART3 +#define UART3_TX_PIN PB10 +#define UART3_RX_PIN PB11 + +#define USE_UART4 +#define UART4_TX_PIN PA0 +#define UART4_RX_PIN PA1 + +#define USE_UART5 +#define UART5_TX_PIN PC12 +#define UART5_RX_PIN PD2 + +#define USE_UART6 +#define UART6_TX_PIN PC6 +#define UART6_RX_PIN PC7 + + +#define SERIAL_PORT_COUNT 7 + +#define DEFAULT_RX_TYPE RX_TYPE_SERIAL +#define SERIALRX_PROVIDER SERIALRX_SBUS +#define SERIALRX_UART SERIAL_PORT_USART2 + + +// *************** SPI Bus ********************** + +#define USE_SPI + +#define USE_SPI_DEVICE_1 +#define SPI1_SCK_PIN PA5 +#define SPI1_MISO_PIN PA6 +#define SPI1_MOSI_PIN PA7 + +#define USE_SPI_DEVICE_2 +#define SPI2_SCK_PIN PB13 +#define SPI2_MISO_PIN PB14 +#define SPI2_MOSI_PIN PB15 + +#define USE_SPI_DEVICE_3 +#define SPI3_SCK_PIN PC10 +#define SPI3_MISO_PIN PC11 +#define SPI3_MOSI_PIN PB2 +#define SPI3_SCK_AF GPIO_AF6_SPI3 +#define SPI3_MISO_AF GPIO_AF6_SPI3 +#define SPI3_MOSI_AF GPIO_AF7_SPI3 + + +// *************** Gyro & ACC ********************** + +#define USE_IMU_MPU6000 +#define IMU_MPU6000_ALIGN CW0_DEG +#define MPU6000_CS_PIN PA4 +#define MPU6000_SPI_BUS BUS_SPI1 + + +#define USE_IMU_ICM42605 +#define IMU_ICM42605_ALIGN CW0_DEG +#define ICM42605_CS_PIN PA4 +#define ICM42605_SPI_BUS BUS_SPI1 + +// *************** I2C/Baro/Mag ********************* +#define USE_I2C +#define USE_I2C_DEVICE_1 +#define I2C1_SCL PB8 +#define I2C1_SDA PB9 + + +//*************************************************** +#define USE_BARO +#define BARO_I2C_BUS BUS_I2C1 +#define USE_BARO_BMP280 +#define USE_BARO_DPS310 +#define USE_BARO_MS5611 + +#define USE_MAG +#define MAG_I2C_BUS BUS_I2C1 +#define USE_MAG_HMC5883 +#define USE_MAG_QMC5883 +#define USE_MAG_IST8310 +#define USE_MAG_IST8308 + +#define TEMPERATURE_I2C_BUS BUS_I2C1 + +#define PITOT_I2C_BUS BUS_I2C1 + +#define USE_RANGEFINDER +#define RANGEFINDER_I2C_BUS BUS_I2C1 +#define BNO055_I2C_BUS BUS_I2C1 + +// *************** FLASH ************************** + +#define USE_FLASHFS + +#define USE_FLASH_M25P16 +#define M25P16_CS_PIN PA15 +#define M25P16_SPI_BUS BUS_SPI3 + +#define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT + +// *************** OSD ***************************** + +#define USE_MAX7456 +#define MAX7456_SPI_BUS BUS_SPI2 +#define MAX7456_CS_PIN PB12 + +// *************** ADC ***************************** + +#define USE_ADC +#define ADC_INSTANCE ADC1 +#define ADC1_DMA_STREAM DMA2_Stream0 +#define ADC_CHANNEL_1_PIN PC3 +#define ADC_CHANNEL_2_PIN PC0 +#define ADC_CHANNEL_3_PIN PC2 + +#define VBAT_ADC_CHANNEL ADC_CHN_1 +#define RSSI_ADC_CHANNEL ADC_CHN_2 +#define CURRENT_METER_ADC_CHANNEL ADC_CHN_3 + + +#define DEFAULT_FEATURES (FEATURE_TX_PROF_SEL | FEATURE_CURRENT_METER | FEATURE_TELEMETRY | FEATURE_VBAT | FEATURE_OSD | FEATURE_BLACKBOX) + + + + +//************************************************** + +#define USE_SERIAL_4WAY_BLHELI_INTERFACE + +#define TARGET_IO_PORTA 0xffff +#define TARGET_IO_PORTB 0xffff +#define TARGET_IO_PORTC 0xffff +#define TARGET_IO_PORTD (BIT(2)) + + +#define MAX_PWM_OUTPUT_PORTS 8 + +#define USE_DSHOT +#define USE_ESC_SENSOR From 34e8d82b6039cd4208fba7e987bed163fc92f902 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Sun, 21 Apr 2024 12:02:36 +0200 Subject: [PATCH 207/241] Enable baro-less navigation by default --- docs/Settings.md | 4 ++-- src/main/fc/settings.yaml | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/Settings.md b/docs/Settings.md index 8608eb01f51..9c31498ef19 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -1844,11 +1844,11 @@ Allows to chose when the home position is reset. Can help prevent resetting home ### inav_use_gps_no_baro -_// TODO_ +Defines if INAV should use only use GPS data for altitude estimation when barometer is not available. If set to ON, INAV will allow GPS assisted modes and RTH even when there is no barometer installed. | Default | Min | Max | | --- | --- | --- | -| OFF | OFF | ON | +| ON | OFF | ON | --- diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index 66abea46399..d2d8c5c433e 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -2288,9 +2288,10 @@ groups: field: use_gps_velned type: bool - name: inav_use_gps_no_baro + description: "Defines if INAV should use only use GPS data for altitude estimation when barometer is not available. If set to ON, INAV will allow GPS assisted modes and RTH even when there is no barometer installed." field: use_gps_no_baro type: bool - default_value: OFF + default_value: ON - name: inav_allow_dead_reckoning description: "Defines if INAV will dead-reckon over short GPS outages. May also be useful for indoors OPFLOW navigation" default_value: OFF From 1d919de74403f53bf0c1a6ef0ff5735f08d84676 Mon Sep 17 00:00:00 2001 From: breadoven <56191411+breadoven@users.noreply.github.com> Date: Sun, 21 Apr 2024 20:58:42 +0100 Subject: [PATCH 208/241] Update navigation.c --- src/main/navigation/navigation.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/navigation/navigation.c b/src/main/navigation/navigation.c index 284afc74109..e8d481a6cf8 100644 --- a/src/main/navigation/navigation.c +++ b/src/main/navigation/navigation.c @@ -1156,7 +1156,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .timeoutMs = 10, .stateFlags = NAV_REQUIRE_ANGLE, .mapToFlightModes = NAV_FW_AUTOLAND, - .mwState = MW_NAV_STATE_LAND_IN_PROGRESS, + .mwState = MW_NAV_STATE_LANDED, .mwError = MW_NAV_ERROR_NONE, .onEvent = { [NAV_FSM_EVENT_TIMEOUT] = NAV_STATE_FW_LANDING_FINISHED, // re-process the state From feba572aea875a2b0bdb2bb876ae1e7256e67caf Mon Sep 17 00:00:00 2001 From: YI-BOYANG <46438966+YI-BOYANG@users.noreply.github.com> Date: Sat, 27 Apr 2024 17:53:14 +0800 Subject: [PATCH 209/241] Add GEPRCF745_BT_HD target --- .../target/GEPRCF745_BT_HD/CMakeLists.txt | 1 + src/main/target/GEPRCF745_BT_HD/config.c | 63 ++++++ src/main/target/GEPRCF745_BT_HD/target.c | 52 +++++ src/main/target/GEPRCF745_BT_HD/target.h | 198 ++++++++++++++++++ 4 files changed, 314 insertions(+) create mode 100644 src/main/target/GEPRCF745_BT_HD/CMakeLists.txt create mode 100644 src/main/target/GEPRCF745_BT_HD/config.c create mode 100644 src/main/target/GEPRCF745_BT_HD/target.c create mode 100644 src/main/target/GEPRCF745_BT_HD/target.h diff --git a/src/main/target/GEPRCF745_BT_HD/CMakeLists.txt b/src/main/target/GEPRCF745_BT_HD/CMakeLists.txt new file mode 100644 index 00000000000..815e08923a8 --- /dev/null +++ b/src/main/target/GEPRCF745_BT_HD/CMakeLists.txt @@ -0,0 +1 @@ +target_stm32f745xg(GEPRCF745_BT_HD) diff --git a/src/main/target/GEPRCF745_BT_HD/config.c b/src/main/target/GEPRCF745_BT_HD/config.c new file mode 100644 index 00000000000..f228c3e023f --- /dev/null +++ b/src/main/target/GEPRCF745_BT_HD/config.c @@ -0,0 +1,63 @@ +/* + * This file is part of INAV. + * + * INAV 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. + * + * INAV 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 INAV. If not, see . + */ + +#include +#include + +#include + +#include "common/axis.h" + +#include "config/config_master.h" +#include "config/feature.h" + +#include "drivers/sensor.h" +#include "drivers/pwm_esc_detect.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 "sensors/battery.h" +#include "sensors/sensors.h" + +#include "telemetry/telemetry.h" + +#include "fc/fc_msp_box.h" + +#include "io/piniobox.h" + + +#define BLUETOOTH_MSP_BAUDRATE BAUD_115200 + +void targetConfiguration(void) +{ + pinioBoxConfigMutable()->permanentId[0] = BOXARM; + pinioBoxConfigMutable()->permanentId[1] = BOX_PERMANENT_ID_USER1; + + serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART3)].functionMask = FUNCTION_MSP; + serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART3)].msp_baudrateIndex = BLUETOOTH_MSP_BAUDRATE; +} + diff --git a/src/main/target/GEPRCF745_BT_HD/target.c b/src/main/target/GEPRCF745_BT_HD/target.c new file mode 100644 index 00000000000..57a8c2a8914 --- /dev/null +++ b/src/main/target/GEPRCF745_BT_HD/target.c @@ -0,0 +1,52 @@ +/* +* This file is part of INAV Project. +* +* INAV 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. +* +* INAV 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 INAV. If not, see . +*/ + +#include + +#include "platform.h" + +#include "drivers/bus.h" +#include "drivers/io.h" +#include "drivers/pwm_mapping.h" +#include "drivers/timer.h" +#include "drivers/sensor.h" + + +BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, IMU1_SPI_BUS, IMU1_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU1_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000_2, DEVHW_MPU6000, IMU2_SPI_BUS, IMU2_CS_PIN, NONE, 1, DEVFLAGS_NONE, IMU2_ALIGN); + +BUSDEV_REGISTER_SPI_TAG(busdev_icm42688, DEVHW_MPU6000, IMU1_SPI_BUS, IMU1_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU1_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_icm42688_2, DEVHW_ICM42605, IMU2_SPI_BUS, IMU2_CS_PIN, NONE, 1, DEVFLAGS_NONE, IMU2_ALIGN); + + + +timerHardware_t timerHardware[] = { + + DEF_TIM(TIM3, CH3, PB0, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM3, CH2, PB5, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM3, CH1, PB4, TIM_USE_OUTPUT_AUTO, 0, 0), + + DEF_TIM(TIM4, CH1, PD12, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM4, CH2, PD13, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM8, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM8, CH4, PC9, TIM_USE_OUTPUT_AUTO, 0, 0), + + DEF_TIM(TIM1, CH1, PA8, TIM_USE_LED, 0, 0), +}; + +const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]); diff --git a/src/main/target/GEPRCF745_BT_HD/target.h b/src/main/target/GEPRCF745_BT_HD/target.h new file mode 100644 index 00000000000..340f7bbe390 --- /dev/null +++ b/src/main/target/GEPRCF745_BT_HD/target.h @@ -0,0 +1,198 @@ +/* + * This file is part of INAV Project. + * + * INAV 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. + * + * INAV 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 INAV. If not, see . + */ + +#pragma once + +#define TARGET_BOARD_IDENTIFIER "GEPR" +#define USBD_PRODUCT_STRING "GEPRCF745_BT_HD" + +#define USE_TARGET_CONFIG + +#define LED0 PC13 + +#define BEEPER PD2 +#define BEEPER_INVERTED + + +//**************** SPI BUS ************************* +#define USE_SPI + +#define USE_SPI_DEVICE_1 +#define SPI1_SCK_PIN PA5 +#define SPI1_MISO_PIN PA6 +#define SPI1_MOSI_PIN PA7 + +#define USE_SPI_DEVICE_2 +#define SPI2_SCK_PIN PB13 +#define SPI2_MISO_PIN PB14 +#define SPI2_MOSI_PIN PB15 + +#define USE_SPI_DEVICE_3 +#define SPI3_SCK_PIN PC10 +#define SPI3_MISO_PIN PC11 +#define SPI3_MOSI_PIN PC12 + +#define USE_SPI_DEVICE_4 +#define SPI4_SCK_PIN PE2 +#define SPI4_MISO_PIN PE5 +#define SPI4_MOSI_PIN PE6 + + + +// *************** Gyro & ACC ********************** + +#define USE_DUAL_GYRO +#define USE_TARGET_IMU_HARDWARE_DESCRIPTORS +#define USE_IMU_MPU6000 +#define USE_IMU_ICM42605 + + +// *****IMU1 MPU6000 & ICM42688 ON SPI1 ************** +#define IMU1_ALIGN CW180_DEG +#define IMU1_SPI_BUS BUS_SPI1 +#define IMU1_CS_PIN PA4 + + + +// *****IMU2 MPU6000 & ICM42688 ON SPI2 ************** +#define IMU2_ALIGN CW0_DEG +#define IMU2_SPI_BUS BUS_SPI2 +#define IMU2_CS_PIN PB12 + + +// *************** I2C/Baro/Mag ********************* +#define USE_I2C +#define USE_I2C_DEVICE_1 +#define I2C1_SCL PB8 +#define I2C1_SDA PB9 + + +#define USE_BARO +#define BARO_I2C_BUS BUS_I2C1 +#define USE_BARO_BMP280 +#define USE_BARO_DPS310 +#define USE_BARO_MS5611 + +#define USE_MAG +#define MAG_I2C_BUS BUS_I2C1 +#define USE_MAG_HMC5883 +#define USE_MAG_QMC5883 +#define USE_MAG_IST8310 +#define USE_MAG_IST8308 +#define USE_MAG_MAG3110 +#define USE_MAG_LIS3MDL + +#define TEMPERATURE_I2C_BUS BUS_I2C1 + +#define PITOT_I2C_BUS BUS_I2C1 + +#define USE_RANGEFINDER +#define RANGEFINDER_I2C_BUS BUS_I2C1 +#define BNO055_I2C_BUS BUS_I2C1 + +// *************** FLASH ************************** +#define USE_SDCARD +#define USE_SDCARD_SPI +#define SDCARD_SPI_BUS BUS_SPI3 +#define SDCARD_CS_PIN PA15 + +#define ENABLE_BLACKBOX_LOGGING_ON_SDCARD_BY_DEFAULT + + +// ************PINIO to disable BT***************** +#define USE_PINIO +#define USE_PINIOBOX +#define PINIO1_PIN PE13 +#define PINIO1_FLAGS PINIO_FLAGS_INVERTED + + +// ************PINIO to other +#define PINIO2_PIN PC14 //Enable vsw + + +// *************** OSD ***************************** +#define USE_MAX7456 +#define MAX7456_SPI_BUS BUS_SPI4 +#define MAX7456_CS_PIN PE4 + +// *************** UART ***************************** +#define USE_VCP + +#define USE_UART1 +#define UART1_RX_PIN PA10 +#define UART1_TX_PIN PA9 + +#define USE_UART2 +#define UART2_RX_PIN PA3 +#define UART2_TX_PIN PA2 + +#define USE_UART3 +#define UART3_RX_PIN PB11 +#define UART3_TX_PIN PB10 + +#define USE_UART4 +#define UART4_RX_PIN PA1 +#define UART4_TX_PIN PA0 + +#define USE_UART6 +#define UART6_RX_PIN PC7 +#define UART6_TX_PIN PC6 + +#define USE_UART7 +#define UART7_RX_PIN PE7 +#define UART7_TX_PIN PE8 + +#define USE_UART8 +#define UART8_RX_PIN PE0 +#define UART8_TX_PIN PE1 + +#define SERIAL_PORT_COUNT 8 + +#define DEFAULT_RX_TYPE RX_TYPE_SERIAL +#define SERIALRX_PROVIDER SERIALRX_SBUS +#define SERIALRX_UART SERIAL_PORT_USART2 + +// *************** ADC ***************************** +#define USE_ADC +#define ADC_INSTANCE ADC1 +#define ADC1_DMA_STREAM DMA2_Stream0 +#define ADC_CHANNEL_1_PIN PC3 +#define ADC_CHANNEL_2_PIN PC5 +#define ADC_CHANNEL_3_PIN PC2 + +#define VBAT_ADC_CHANNEL ADC_CHN_1 +#define RSSI_ADC_CHANNEL ADC_CHN_2 +#define CURRENT_METER_ADC_CHANNEL ADC_CHN_3 + + +#define DEFAULT_FEATURES (FEATURE_TX_PROF_SEL | FEATURE_CURRENT_METER | FEATURE_TELEMETRY | FEATURE_VBAT | FEATURE_OSD | FEATURE_BLACKBOX) + +#define USE_LED_STRIP +#define WS2811_PIN PA8 + +#define USE_SERIAL_4WAY_BLHELI_INTERFACE + +#define TARGET_IO_PORTA 0xffff +#define TARGET_IO_PORTB 0xffff +#define TARGET_IO_PORTC 0xffff +#define TARGET_IO_PORTD 0xffff +#define TARGET_IO_PORTE 0xffff + +#define MAX_PWM_OUTPUT_PORTS 8 + +#define USE_DSHOT +#define USE_ESC_SENSOR From a53296abb7d9aa10f850b34aae11cc142db6aab3 Mon Sep 17 00:00:00 2001 From: Marcelo Bezerra <23555060+mmosca@users.noreply.github.com> Date: Sat, 27 Apr 2024 13:11:40 +0200 Subject: [PATCH 210/241] Fix function prototypes and macos warnings --- src/main/flight/mixer.c | 2 +- src/main/flight/mixer_profile.c | 2 +- src/main/io/displayport_msp_osd.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/flight/mixer.c b/src/main/flight/mixer.c index d2a073f26ee..716b48d7aa4 100644 --- a/src/main/flight/mixer.c +++ b/src/main/flight/mixer.c @@ -728,7 +728,7 @@ bool areMotorsRunning(void) return false; } -uint16_t getMaxThrottle() { +uint16_t getMaxThrottle(void) { static uint16_t throttle = 0; diff --git a/src/main/flight/mixer_profile.c b/src/main/flight/mixer_profile.c index 7b2590ff70b..5769b56fbdb 100644 --- a/src/main/flight/mixer_profile.c +++ b/src/main/flight/mixer_profile.c @@ -79,7 +79,7 @@ void pgResetFn_mixerProfiles(mixerProfile_t *instance) } } -void activateMixerConfig(){ +void activateMixerConfig(void){ currentMixerProfileIndex = getConfigMixerProfile(); currentMixerConfig = *mixerConfig(); nextMixerProfileIndex = (currentMixerProfileIndex + 1) % MAX_MIXER_PROFILE_COUNT; diff --git a/src/main/io/displayport_msp_osd.c b/src/main/io/displayport_msp_osd.c index e1e6cb29676..0d797e1f756 100644 --- a/src/main/io/displayport_msp_osd.c +++ b/src/main/io/displayport_msp_osd.c @@ -525,7 +525,7 @@ void mspOsdSerialProcess(mspProcessCommandFnPtr mspProcessCommandFn) } } -mspPort_t *getMspOsdPort() +mspPort_t *getMspOsdPort(void) { if (mspPort.port) { return &mspPort; From 30d96107bc6a506e4816375a0e08e68936feee67 Mon Sep 17 00:00:00 2001 From: Marcelo Bezerra <23555060+mmosca@users.noreply.github.com> Date: Sat, 27 Apr 2024 13:19:12 +0200 Subject: [PATCH 211/241] macos-latest got bumped to macos-14 and introduces some new failures on sitl Move it back to macos-13 until it can be updated back to latest. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 09e27045ca6..6fddc02df85 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -74,7 +74,7 @@ jobs: path: ./build_SITL/*_SITL build-SITL-Mac: - runs-on: macos-latest + runs-on: macos-13 steps: - uses: actions/checkout@v3 - name: Install dependencies From cc276acef9070b2a19a64c75dd7e35098374022b Mon Sep 17 00:00:00 2001 From: Marcelo Bezerra <23555060+mmosca@users.noreply.github.com> Date: Sat, 27 Apr 2024 13:56:54 +0200 Subject: [PATCH 212/241] More warnings, last of the alignment errors --- src/main/build/build_config.h | 2 +- src/main/cms/cms_types.h | 8 +++++++- src/main/config/parameter_group.h | 2 +- src/main/fc/cli.c | 2 +- src/main/io/osd_hud.c | 4 ++-- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/build/build_config.h b/src/main/build/build_config.h index d97e6d300ce..75bb46668d7 100644 --- a/src/main/build/build_config.h +++ b/src/main/build/build_config.h @@ -40,7 +40,7 @@ #endif #ifdef __APPLE__ -#define FASTRAM __attribute__ ((section("__DATA,__.fastram_bss"), aligned(4))) +#define FASTRAM __attribute__ ((section("__DATA,__.fastram_bss"), aligned(8))) #else #define FASTRAM __attribute__ ((section(".fastram_bss"), aligned(4))) #endif diff --git a/src/main/cms/cms_types.h b/src/main/cms/cms_types.h index 9b2b06646c5..a07e55eaaa4 100644 --- a/src/main/cms/cms_types.h +++ b/src/main/cms/cms_types.h @@ -26,6 +26,12 @@ //type of elements +#ifndef __APPLE__ +#define OSD_ENTRY_ATTR __attribute__((packed)) +#else +#define OSD_ENTRY_ATTR +#endif + typedef enum { OME_Label, @@ -71,7 +77,7 @@ typedef struct const void * const data; const uint8_t type; // from OSD_MenuElement uint8_t flags; -} __attribute__((packed)) OSD_Entry; +} OSD_ENTRY_ATTR OSD_Entry; // Bits in flags #define PRINT_VALUE (1 << 0) // Value has been changed, need to redraw diff --git a/src/main/config/parameter_group.h b/src/main/config/parameter_group.h index 9594ad96c41..28a647ecb96 100644 --- a/src/main/config/parameter_group.h +++ b/src/main/config/parameter_group.h @@ -64,7 +64,7 @@ static inline uint16_t pgIsProfile(const pgRegistry_t* reg) {return (reg->size & #ifdef __APPLE__ extern const pgRegistry_t __pg_registry_start[] __asm("section$start$__DATA$__pg_registry"); extern const pgRegistry_t __pg_registry_end[] __asm("section$end$__DATA$__pg_registry"); -#define PG_REGISTER_ATTRIBUTES __attribute__ ((section("__DATA,__pg_registry"), used, aligned(4))) +#define PG_REGISTER_ATTRIBUTES __attribute__ ((section("__DATA,__pg_registry"), used, aligned(8))) extern const uint8_t __pg_resetdata_start[] __asm("section$start$__DATA$__pg_resetdata"); extern const uint8_t __pg_resetdata_end[] __asm("section$end$__DATA$__pg_resetdata"); diff --git a/src/main/fc/cli.c b/src/main/fc/cli.c index 48345583412..97de1bd6ed1 100644 --- a/src/main/fc/cli.c +++ b/src/main/fc/cli.c @@ -1171,7 +1171,7 @@ static void cliRxRange(char *cmdline) ptr = cmdline; i = fastA2I(ptr); if (i >= 0 && i < NON_AUX_CHANNEL_COUNT) { - int rangeMin, rangeMax; + int rangeMin = 0, rangeMax = 0; ptr = nextArg(ptr); if (ptr) { diff --git a/src/main/io/osd_hud.c b/src/main/io/osd_hud.c index 47cc96f834b..07bc181d1c1 100644 --- a/src/main/io/osd_hud.c +++ b/src/main/io/osd_hud.c @@ -122,8 +122,8 @@ int8_t radarGetNearestPOI(void) */ void osdHudDrawPoi(uint32_t poiDistance, int16_t poiDirection, int32_t poiAltitude, uint8_t poiType, uint16_t poiSymbol, int16_t poiP1, int16_t poiP2) { - int poi_x; - int poi_y; + int poi_x = -1; + int poi_y = -1; uint8_t center_x; uint8_t center_y; bool poi_is_oos = 0; From 8256875af9e297df0dd0895b73c5d0243bb44383 Mon Sep 17 00:00:00 2001 From: Marcelo Bezerra <23555060+mmosca@users.noreply.github.com> Date: Sat, 27 Apr 2024 14:01:53 +0200 Subject: [PATCH 213/241] Back to latest macos --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6fddc02df85..09e27045ca6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -74,7 +74,7 @@ jobs: path: ./build_SITL/*_SITL build-SITL-Mac: - runs-on: macos-13 + runs-on: macos-latest steps: - uses: actions/checkout@v3 - name: Install dependencies From a030a2d06787ef81c601e9f940f3d78ab7633743 Mon Sep 17 00:00:00 2001 From: Marcelo Bezerra <23555060+mmosca@users.noreply.github.com> Date: Sat, 27 Apr 2024 15:42:07 +0200 Subject: [PATCH 214/241] Add separate x64 build --- .github/workflows/ci.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 09e27045ca6..4ff42bfa935 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -109,6 +109,42 @@ jobs: name: ${{ env.BUILD_NAME }}_SITL-MacOS path: ./build_SITL/*_SITL + build-SITL-Mac-large: + runs-on: macos-latest-large + steps: + - uses: actions/checkout@v3 + - name: Install dependencies + run: | + brew install cmake ninja ruby + + - name: Setup environment + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: true + run: | + # This is the hash of the commit for the PR + # when the action is triggered by PR, empty otherwise + COMMIT_ID=${{ github.event.pull_request.head.sha }} + # This is the hash of the commit when triggered by push + # but the hash of refs/pull//merge, which is different + # from the hash of the latest commit in the PR, that's + # why we try github.event.pull_request.head.sha first + COMMIT_ID=${COMMIT_ID:-${{ github.sha }}} + BUILD_SUFFIX=ci-$(date '+%Y%m%d')-$(git rev-parse --short ${COMMIT_ID}) + VERSION=$(grep project CMakeLists.txt|awk -F VERSION '{ gsub(/^[ \t]+|[ \t\)]+$/, "", $2); print $2 }') + echo "BUILD_SUFFIX=${BUILD_SUFFIX}" >> $GITHUB_ENV + echo "BUILD_NAME=inav-${VERSION}-${BUILD_SUFFIX}" >> $GITHUB_ENV + - name: Build SITL + run: | + mkdir -p build_SITL && cd build_SITL + cmake -DSITL=ON -DWARNINGS_AS_ERRORS=ON -G Ninja .. + ninja + + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: ${{ env.BUILD_NAME }}_SITL-MacOS-x64 + path: ./build_SITL/*_SITL + build-SITL-Windows: runs-on: windows-latest defaults: From f6a86f80f978c24c7e5bcca5c21c63091d3166ef Mon Sep 17 00:00:00 2001 From: Marcelo Bezerra <23555060+mmosca@users.noreply.github.com> Date: Sat, 27 Apr 2024 15:47:06 +0200 Subject: [PATCH 215/241] Build MacOSX sitl as universal binary --- .github/workflows/ci.yml | 38 +------------------------------------- 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4ff42bfa935..111a0cc35c0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -100,7 +100,7 @@ jobs: - name: Build SITL run: | mkdir -p build_SITL && cd build_SITL - cmake -DSITL=ON -DWARNINGS_AS_ERRORS=ON -G Ninja .. + cmake -DSITL=ON -DWARNINGS_AS_ERRORS=ON -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -G Ninja .. ninja - name: Upload artifacts @@ -109,42 +109,6 @@ jobs: name: ${{ env.BUILD_NAME }}_SITL-MacOS path: ./build_SITL/*_SITL - build-SITL-Mac-large: - runs-on: macos-latest-large - steps: - - uses: actions/checkout@v3 - - name: Install dependencies - run: | - brew install cmake ninja ruby - - - name: Setup environment - env: - ACTIONS_ALLOW_UNSECURE_COMMANDS: true - run: | - # This is the hash of the commit for the PR - # when the action is triggered by PR, empty otherwise - COMMIT_ID=${{ github.event.pull_request.head.sha }} - # This is the hash of the commit when triggered by push - # but the hash of refs/pull//merge, which is different - # from the hash of the latest commit in the PR, that's - # why we try github.event.pull_request.head.sha first - COMMIT_ID=${COMMIT_ID:-${{ github.sha }}} - BUILD_SUFFIX=ci-$(date '+%Y%m%d')-$(git rev-parse --short ${COMMIT_ID}) - VERSION=$(grep project CMakeLists.txt|awk -F VERSION '{ gsub(/^[ \t]+|[ \t\)]+$/, "", $2); print $2 }') - echo "BUILD_SUFFIX=${BUILD_SUFFIX}" >> $GITHUB_ENV - echo "BUILD_NAME=inav-${VERSION}-${BUILD_SUFFIX}" >> $GITHUB_ENV - - name: Build SITL - run: | - mkdir -p build_SITL && cd build_SITL - cmake -DSITL=ON -DWARNINGS_AS_ERRORS=ON -G Ninja .. - ninja - - - name: Upload artifacts - uses: actions/upload-artifact@v3 - with: - name: ${{ env.BUILD_NAME }}_SITL-MacOS-x64 - path: ./build_SITL/*_SITL - build-SITL-Windows: runs-on: windows-latest defaults: From e92337a5fce818c08a68ed632b46ef32f7740680 Mon Sep 17 00:00:00 2001 From: Roman Lut <11955117+RomanLut@users.noreply.github.com> Date: Sat, 27 Apr 2024 17:32:00 +0200 Subject: [PATCH 216/241] SITL: implemented built-in serial receivers support in SITL, implemented FC proxy mode, updated SITL docs (#9365) * implemented built-in serial receivers support in SITL implemented FC Proxy for SITL update SITL.md * Update SITL.md * Update SITL.md * Update SITL.md * Update SITL.md * [SITL] update POSIX serial functions to support non-standard baud rates * disable xon/hof on serial port (SITL serial_proxy) --------- Co-authored-by: Jonathan Hudson --- docs/SITL/SITL.md | 142 ++-- docs/SITL/assets/serial_receiver_crsf.png | Bin 0 -> 6993 bytes docs/SITL/assets/serial_receiver_proxy.png | Bin 0 -> 7107 bytes docs/SITL/assets/serial_receiver_sbus.png | Bin 0 -> 6803 bytes docs/development/Building SITL.md | 39 + src/main/drivers/serial_tcp.c | 49 +- src/main/drivers/serial_tcp.h | 8 +- src/main/fc/fc_init.c | 8 + src/main/fc/fc_tasks.c | 8 + src/main/main.c | 8 + src/main/rx/sim.c | 19 +- src/main/rx/sim.h | 1 + src/main/target/SITL/serial_proxy.c | 784 +++++++++++++++++++++ src/main/target/SITL/serial_proxy.h | 64 ++ src/main/target/SITL/target.c | 109 ++- 15 files changed, 1143 insertions(+), 96 deletions(-) create mode 100644 docs/SITL/assets/serial_receiver_crsf.png create mode 100644 docs/SITL/assets/serial_receiver_proxy.png create mode 100644 docs/SITL/assets/serial_receiver_sbus.png create mode 100644 docs/development/Building SITL.md create mode 100644 src/main/target/SITL/serial_proxy.c create mode 100644 src/main/target/SITL/serial_proxy.h diff --git a/docs/SITL/SITL.md b/docs/SITL/SITL.md index 0c127135781..df3279f6d31 100644 --- a/docs/SITL/SITL.md +++ b/docs/SITL/SITL.md @@ -16,6 +16,10 @@ Currently supported are INAV SITL communicates for sensor data and control directly with the corresponding simulator, see the documentation of the individual simulators and the Configurator or the command line options. +AS SITL is still an inav software, but running on PC, it is possible to use HITL interface for communication. + +INAV-X-Plane-HITL plugin https://github.com/RomanLut/INAV-X-Plane-HITL can be used with SITL. + ## Sensors The following sensors are emulated: - IMU (Gyro, Accelerometer) @@ -30,13 +34,18 @@ The following sensors are emulated: Select "FAKE" as type for all mentioned, so that they receive the data from the simulator. -## Serial ports+ -UARTs are replaced by TCP starting with port 5760 ascending. UART 1 port 5760, UART2 5761, ... -By default, UART1 and UART2 are available as MSP connections. Other UARTs will have TCP listeners if they have an INAV function assigned. -To connect the Configurator to SITL: Select TCP and connect to ```localhost:5760``` (or ```127.0.0.1:5760``` if your OS doesn't understand `localhost`) (if SITL is running on the same machine). +## Serial ports +UARTs are replaced by TCP starting with port 5760 ascending. UART1 is mapped to port 5760, UART2 to 5761, etc. + +By default, UART1 and UART2 are configured for MSP connections. Other UARTs will have TCP listeners if they have an INAV function assigned. + +To connect the Configurator to SITL, select "SITL". + +Alternativelly, select "TCP" and connect to ```localhost:5760``` (or ```127.0.0.1:5760``` if your OS doesn't understand `localhost`) (if SITL is running on the same machine). + IPv4 and IPv6 are supported, either raw addresses or host-name lookup. -The assignment and status of user UART/TCP connections is displayed on the console. +The assignment and status of used UART/TCP connections is displayed on the console. ``` INAV 6.1.0 SITL @@ -51,39 +60,73 @@ INAV 6.1.0 SITL All other interfaces (I2C, SPI, etc.) are not emulated. ## Remote control -MSP_RX (TCP/IP) or joystick (via simulator) or serial receiver via USB/Serial interface are supported. +Multiple methods for connecting RC Controllers are available: +- MSP_RX (TCP/IP) +- joystick (via simulator) +- serial receiver via USB to serial converter +- any receiver with proxy flight controller + ### MSP_RX -MSP_RX is the default, 18 channels are supported over TCP/IP serial emulation. +MSP_RX is the default, 18 channels are supported over TCP/IP connection. ### Joystick interface Only 8 channels are supported. -Select "SIM (SITL)" as the receiver and set up a joystick in the simulator, details of which can be found in the documentation for the individual simulators. + +Select "SIM (SITL)" as the receiver and set up a joystick in the simulator. + +*Not available with INAV-X-Plane-HITL plugin.* ### Serial Receiver via USB -Connect a serial receiver (e.g. SBUS) to the PC via a UART/USB adapter. Configure the receiver in the Configurator as usual. +- Connect a serial receiver to the PC via a USB-to-serial adapter +- Configure the receiver in the SITL as usual +- While starting SITL from configurator, enable "Serial receiver" option + +The SITL offers a built-in option for forwarding the host's serial port to the SITL UART. + +Please note that 100000(SBUS) and 420000(CRSF) are non-standart baud rates which may not be supported by some USB-to-serial adapters. FDTI and CH340 should work. CP2102/9 does not work. -The Configurator offers a built-in option for forwarding the serial data to the SITL TCP port, if SITL is started manually the following option can be used: -The connection can then be established with a programme that forwards the serial data unaltered to TCP, e.g. with the Python script tcp_serial_redirect.py (https://github.com/Scavanger/TCP-Serial-Redirect) -If necessary, please download the required runtime environment from https://www.python.org/. -Please use the linked version, which has a smaller buffer, otherwise the control response is relatively slow. +#### Example SBUS: +For this you need a USB-to-serial adapter, receiver with inverter, or receiver which can output inverted SBUS (normal UART). -### Example SBUS: -For this you need a FT232 module. With FT-Prog (https://ftdichip.com/utilities/) the signals can be inverted: Devices->Scan and Parse, then Hardware Specific -> Invert RS232 Signals -> Invert RXD. +SBUS protocol is inverted UART. + +Receiver's SBUS output should be connected to the USB-to-serial adapter's RX pin (via inverter). + +With FT-Prog (https://ftdichip.com/utilities/) the signal can be inverted by adapter: Devices->Scan and Parse, then Hardware Specific -> Invert RS232 Signals -> Invert RXD. ![SITL-SBUS-FT232](assets/SITL-SBUS-FT232.png) -For SBUS, the command line arguments of the python script are: -```python tcp_serial_redirect.py --parity E --stopbits 2 -c 127.0.0.1:[INAV-UART-PORT] COMXX 100000``` +![SITL-SBUS](assets/serial_receiver_sbus.png) ### Telemetry +In the SITL configuration, enable serial receiver on some port and configure receiver type "Serial", "SBUS". + +#### Example CRSF: + +On receiver side, CRSF is normal UART. + +Connect receiver's RX/TX pins (and GND, 5V of course) to USB-To-Serial adapter's TX/RX pins (RX to TX, TX to RX). + +![SITL-SBUS](assets/serial_receiver_crsf.png) + +In the SITL configuration, enable serial receiver on some port and configure receiver type "Serial", "CRSF". + +### Proxy Flight controller + +The last, but probably the most easiest way to connect receiver to the SITL, is to use any inav/betaflight Flight controler as proxy. + +Connect receiver of any type to FC and configure FC to the point where channels are correctly updated in the "Receiver" tab. Inav and Betaflight are supported. -LTM and MAVLink telemetry are supported, either as a discrete function or shared with MSP. +You also can use your plane/quad ( if receiver is powered from USB). + +![SITL-SBUS](assets/serial_receiver_proxy.png) + +In the SITL configuration, select "Receiver type: SIM" regardles of the kind of receiver used. -RX Telemetry via a return channel through the receiver is not yet supported by SITL. ## OSD For the OSD the program INAV-Sim-OSD is available: https://github.com/Scavanger/INAV-SIM-OSD. @@ -91,6 +134,8 @@ For this, activate MSP-Displayport on a UART/TCP port and connect to the corresp Note: INAV-Sim-OSD only works if the simulator is in window mode. +*With INAV-X-Plane-HITL plugin, OSD is supported natively.* + ## Command line The command line options are only necessary if the SITL executable is started by hand. @@ -103,7 +148,7 @@ If SITL is started without command line options, only a serial MSP / CLI connect ```--path``` Path and file name to config file. If not present, eeprom.bin in the current directory is used. Example: ```C:\INAV_SITL\flying-wing.bin```, ```/home/user/sitl-eeproms/test-eeprom.bin```. -```--sim=[sim]``` Select the simulator. xp = X-Plane, rf = RealFlight. Example: ```--sim=xp``` +```--sim=[sim]``` Select the simulator. xp = X-Plane, rf = RealFlight. Example: ```--sim=xp```. If not specified, configurator-only mode is started. Omit for usage with INAV-X-Plane-HITL plugin. ```--simip=[ip]``` Hostname or IP address of the simulator, if you specify a simulator with "--sim" and omit this option IPv4 localhost (`127.0.0.1`) will be used. Example: ```--simip=172.65.21.15```, ```--simip acme-sims.org```, ```--sim ::1```. @@ -118,6 +163,18 @@ To assign motor1 to virtual receiver channel 1, servo 1 to channel 2, and servo2 ```--chanmap:M01-01,S01-02,S02-03``` Please also read the documentation of the individual simulators. +```--serialport``` Use serial receiver or proxy FC connected to host's serial port, f.e. ```--serialportCOM5``` or ```--serialportdev/ttyACM3``` + +```--serialuart``` Map serial receiver to SITL UART, f.e. ```--serialuart=3``` for UART3. Omit if using ```--fcproxy```. + +```--baudrate``` Serial receiver baudrate (default: 115200) + +```--stopbits=[None|One|Two]``` Serial receiver stopbits (default: One) + +```--parity=[Even|None|Odd]``` Serial receiver parity (default: None) + +```--fcproxy``` Use inav/betaflight FC as a proxy for serial receiver. + ```--help``` Displays help for the command line options. For options that take an argument, either form `--flag=value` or `--flag value` may be used. @@ -125,46 +182,13 @@ For options that take an argument, either form `--flag=value` or `--flag value` ## Running SITL It is recommended to start the tools in the following order: 1. Simulator, aircraft should be ready for take-off -2. INAV-SITL +2. SITL 3. OSD -4. serial redirect for RC input - -## Compile - -### Linux and FreeBSD: -Almost like normal, ruby, cmake and make are also required. -With cmake, the option "-DSITL=ON" must be specified. - -``` -mkdir build_SITL -cd build_SITL -cmake -DSITL=ON .. -make -``` - -### Windows: -Compile under cygwin, then as in Linux. -Copy cygwin1.dll into the directory, or include cygwin's /bin/ directory in the environment variable PATH. - -If the build fails (segfault, possibly out of memory), adding `-DCMAKE_BUILD_TYPE=MinRelSize` to the `cmake` command may help. - -#### Build manager - -`ninja` may also be used (parallel builds without `-j $(nproc)`): - -``` -cmake -GNinja -DSITL=ON .. -ninja -``` - -### Compiler requirements -* Modern GCC. Must be a *real* GCC, macOS faking it with clang will not work. GCC 10 to GCC 13 are known to work. -* Unix sockets networking. Cygwin is required on Windows (vice `winsock`). -* Pthreads +For INav-X-Plane-HITL plugin: +1. SITL (Run in configurator-only mode) +2. X-Plane -## Supported environments +# #Forwarding serial data for other UART -* Linux on x86_64, ia-32, Aarch64 (e.g. Rpi4), RISCV64 (e.g. VisionFive2) -* Windows on x86_64 -* FreeBSD (x86_64 at least). +Other UARTs can then be mapped to host's serial port using external tool, which can be found in directories ```inav-configurator\resources\sitl\linux\Ser2TCP```, ```inav-configurator\resources\sitl\windows\Ser2TCP.exe``` diff --git a/docs/SITL/assets/serial_receiver_crsf.png b/docs/SITL/assets/serial_receiver_crsf.png new file mode 100644 index 0000000000000000000000000000000000000000..55ae6af98b62a85984c02020ab6280473c3c3848 GIT binary patch literal 6993 zcmZvBc{G&&`#vdz3>8_@V<}3MExQ@J%9fB2vW4tRvJ69F5T=rSH})(cS+Z|q%f9c+ z*rORUm>J9b^!~m-pWpBN&iAk9Joh>G{oLn%uIt>_>v}~z(b2d>$3aIyL2>EPL)E7g z6z2d63d*~*RA-S#LChUz4|XrL=U)1*ue{z`de~AZ*|=KSazApmw6lF`YiZ-_-fb&? zmJ#$s%RsFsf;UnuvIKoZVVJW{A{`tYW&!6ae`GZ&F&Ki z;-1cJG#0!z2ab-X{5(+Xx=$-cyU0b<#58jv=s%n7B)wT zZ0(ytkq-)RLlGO4EE*qgq#ha!l_O@xa1{H-e%GLm~T8S7U9`YW6492gDqKNmWrI9aIo z;;<+o%VrDy^wYaC2^r)3>3jTq>112{=KV^2e&D^H(*`c3uXO~8ZXb~%I|fDq*tq#V zEp|^{72PKn-wdEK+mYu0UZv>upG3%UN|HgKA6g|{`Q7{h8&r!~WeIwE(q+edFG~0O z-uLGA)DX$S-I;3* zfAE$(go`Uc*snHjPyccmW-@$0%gFa3VP%z|Z+grGeLuFv8(5%w6>^%$HOVlurub&Q zY1LiD{N~+-rht)&?iF~~9cmnzXx|Ph+D7K2A?h>MSzP`01j!=cj>3fN#(jTtgnR>> z@Yg3$^ESN6lBJ}ZDj(F3yHLE-KE*+x$A&&AwPMb3NQAxn)vTRj&rCno(lV9R6t-h9 zjhVFT1%QbV)J*e#p;H|RqE=En_y33gB7})R@xO;_!abCwVbMLP3A93kj)2Aoz!;f73;=x zH>?Ht0Rd}(Ns%K8@px&aa(^l;gISRy8u3^m!RQ&-Jer5fK?E$g_(`^W&;2v$3N#2& zNhF{|35rKnt9+KO7R@w!`YEg>Q27WxvLbn$71H|SbO&XK8F~&ipyMvA=|FOQn2t z?jL3@Qq?Iz>s`L4nIjopIDj&X$`O+YZ|XTA@bqgq4NcCaIJXgkbV=@6jT$z9X6})* z{gAA{Nv3gw=Y^ht6!G}d4rFp(^gzPQs6v|&JGNq9OLYb_bzrRU=8GV%uWaJE?G6;Z zMn{?ISNu_bk8Nb^39lGFoQ#BK zq-Ntt;6i8V(W#A%fQ;+0y~cjeIQPm+jZ36j64dpLy+yc|dF*fZCz2n9!QYq83$b*I zGSBGwY-yhtM@;trT;Ol`-c;P8K~BuQH+LE?dGERLn%rT}CE~l?aLG@(R7k{YBc;aO z=Da*%iLwFv>u%*2EmY_WtmzvE!%q3ZjCpsSV3F&g;dD1Jj(9bKH@>xL{iAO2@DA-O z31O{=Sl+O;V!L)vlp}->WW_AYU`QK)1$dKL>y*LCyZ*WgJMD@ibFUaLWc&s>OL_86 zUjVev#m5{Rjji!15K}u})V7*#$C?jl>fQSFyXmq}{P2MKc6+?ZjoDP|uTFNuZ<#n( zG!^Pw-|qS#S0Waz0msY2YUEVKnERJ!cJAGLW^Fl+y)^{9bfj$U4hJGHcc32o^d{xY zqB|AOeS2Z~3n)tkM-IqpvlYfDe4@p9G_yz@{Kh94oGY zH^HZy{NU4(>kT4+#i0aaSNV^_{k~JpLExYs&5{?|909%#cA14smEy}Zns$<`(URs1PnxH1g8EpV z{QSJHra#T%dL11+Jk)J{bZ8yoDfp0VQsj232W3756W-CtoJhyKVg*Mcw_SF$pAXPx zTuoyhs_#*5|J(LemM<>Q;ovDq)V%Y7{BfazO@EU#kjk+0T&sU~!CRj2=Mfgj&gi=B zI)ao0qdoQ^(s}EzTe>sm{pQ#+rl>YxHaQaC)9iJ8*rYdr)6bdOwd zkKk?w^||4Pd`n*UfYK^@$v?(m=kBWSKw&-~xLh}(zn}U$AGzxF-XXi?`8qa{zDo0* zwAH`zE~Ni{ODA^SxwR9Xt}cWS@Ojqk-Pn_!Jr8pTNY54Ss5@4)Y51@lecaXwZ@e2Q z@m1#r$#Xf#q{1UME_5w5&`ICa@AQ*#k1-C^4ex=>!eopl&RMaja}`SLtS#ObsB(`N zR~Am(iMmOZYHRUi0CFC%jQ{%PXu0v)YZAKlCU8DHM&lyb$Nb)v)9@c6Ww;i7V)Vj| z=fsb_YGm7VF08|g)U8rlvW7zVtxZAdG=40?X;sBrMZSLdPMLfnqv=ugDCMB!+G-uw zBSC|Giyv3i$sL{WX~V%X2hVz8xywdEv2m-pM}%OwH8!=@ei*t;vMZ@$6gtHt@@*yxE9JGY|ZX= zzMsBV+nDZzneHyc9H6kM#+}Yd=mOZ2J8kCGl&P#{&yp1$}Ur#-p0U{j)Mjp75`^1 z2e~i+gp&(`Z8U*Rp*`5(BS>Zibn#TQAcj~_2VvMQ6VchowBRIK7Pl74_LhdK8|?GT zzYV;`=RWr2#r6q$xd2^|_f}%E^H$$$wEc9ioXFX79y@>+7RTIQXFKmn4WQRQ9^G|( z%Cpd|S91aSJ235I2B^*?-q!rt+2MMYhTw%I zj#iV}@boY?y($R>8eCoY)Gc0~htn)oG(e8bmIHCBSr^NaSpGCTUc`I3<QfHk*}jz?vtd-1%6S%Y@xnuILqHd=#Zu?Z}=W! z{*|{sA$;DMpYHJ<4`e(R(wA}JRHPz6CU8i0sF<7~{uL3~t)XAoMICc!RgkoPD` zb{1(D!wZg5;DDYFRm-;LGrJ0Qxddoiw}zJ11n^uDYopEvA6v@DLK?Iuk1g>NhD~lM zep0T{fF#&QD$Ii}xzO8oE+Pu>j%5>nE4-$%fRvYR)HZU}xz1ZV=|pk?0qJmwkC2?b zk)s%W|D!$UAcI~&9Suy0owY{F*@=93t*fhJ3u(2NrKL8}<)gFnc-Llq&dT!C64Ro| z+UOAqP4w5&4a^IAs11-Yx0EjYxi^bH{ct@&7yA3deB}2xAHzV;z9tDs6~ z9we#gFGUbuABR@X_1_}AnS(DE&lR?uu#FhB?m|jJ-}ldwB4BR zl$(9XHGW!hjuAxN$%$=} zloKadF?eD9pL5iP>=^@LekNIqpMsAEvm4Cg=bc!J|z~Q`^->{^7 z>&c{ljI6MspGC=IZN`!w(|KcKAI&C6DQ126Ho&8uPkx}Ps2EV1y6g)~3%e;sAm zs0W5WEaT_sl@_R0NF0}t$)Hw4omiPwP!1}42$!A$cAMP?tZnSoknCuIoFy%z&o3xc zZ5|rGU9%1A?G1)}=X@m#I05Yn=bCx~ zzDwEqW=KZPQg&4>BESVY(0qTj-qHU{c16s3lC1N%>XJ_bn)k{4Do{3>j*U;$c z@LX}u4|PjXp`e+5Ht`qc*$sjLnLEBtS$~_6^{Fx|zaL#5zpMfcRwlDMh+zJ(kFe_% zKSi7B`-2%4ZXYU`FUiLYKKy+fHiM5iM-#o3u%oGQlo%!c{emt;tF18RKt;6GKck)p z%)XRIcPcWVs_%N_Dj{xU^mwZ7%VJ0^Z_k^SxQb5Dh+Ek5M2-r3|CdOBA3*Q5lJkG6 z9;zLl{2faY9ag0z7ljbHdyt_A?P8dW0?yzu(Ss5oMu;=b(RY_mGm4Wpd^Y56+1qDA zjJqWw+{ssU3Ied-;i{BSvns;}$CjVvM^f-pCZ0x#s|4an@1tN7m+gL`)plqs$oSf8 z;ZLx>GQkkpD&_^bG8$Xy%8J3%yL}KXaMx<6&`T241!y7>&X@0Mgx1tggoT^2k_I-+ zjfVfIf8lA2lRX2)uQxyLXWZnw%9rh-MQ+3}4-?(Oso}4%c$EdWg+&#D@ zob;mBzA5!%Iy;wuizY4Ug&#ywOsd2~O4e6pHC#%zsr{WPaESK8nq%fWD~gKf(hiIt&FZgxgqr1{D?$=yvCm6)$yaOy!d?punRM zSSIxfa&`n((VR z_v+FRy$iyL+BnDjM-)dZ~r7 zg;2|hf>*|$0~S}TptQ)X`KOG)!tN2}951-ba2)b131Q0+R0{^nr)c)ajgMb~k4()? z*X8IEi)+9Q%HS?zvBU^_Dr0On%gfzs(}N43wnTAPI8$}wrJf^jIm`kwE+OlqmK zE2-qItvpXYloiI8Z`6${f<;^)Cz)kSFMmCu|7C^AeZgCz-65@IU{gYTe$g&| zBhGX2@^h~bn>|0I5{*BPeC>mLzvvL8(2zrrPBg#Vmizue=?mWM$m{Tk$YN0-y}C)0 zqOJ{JU0HiGU;h1had(-99>S*&p_SX>%yTbiSeUpm$0|A89v87$DOM^~t4P=*YFeFh z>wN1xV0)9h;P-|2*?52TJy9;E&izPG^$T8t;*5td)al2Mr?NdEVV+e#$9L#gfpP;( z8bVk=MG4D5pAOS{@ZmTFmlaRD?Igo^g~b?m{Dop8=Ihn>G*L0rtNEj^q6E6^{JB|q zXEx_u(j5p@Ss8#+#DSVH&$iP8#w&Hy;NeR7a3_D?foBIE4t3dw9tmzIS0_*mt3vuO zENK1;*)um%3LCs|m?d_$L%9pC12s)dg1t27|Fuy5)xuu%|LX?UXsq<^`Nv%$%F7kT z+1m~NT1HlS`?x8}>RmhoLaYhhnQQa`>pqw^8pf)5y_oHFce{OHfjjYe9!kGaaOpG~ z*AkbmIAmN6xiG<%L>G zzcGX2@mv|HQNuZ%&>VpbIm5dZKR-T?4mH*g>mRoZNKc?LZAp?bQD&&6e$LpCvAvAU zEeqB43{V);$QIBTc`;y2-1K{OyHV{btv)g`4s?pIkW}5 z&Ry2kvc#&KE4cJNR_WFyO$yCJR~hE3kUSOMKwAC6s#ZeF*gnI7$iy#{C>c4+J?c2 zM@1CbD|+t`hxMMVa>D4->_dyjuG3!A26C&_84-%4SdU%QS=(2O1}MT1m`n_-Ar3k?6Q zTl)GP@S}1*4)xrzi-3-(cg9eSlb>AA5?dUrsD~5Tkl1!RMcGJNsim!l2DaZelx0rn za%Z59vtuHwhKXA7U)pZ^68+=?jI9GTO)--sO61mH`+?gRPEPP!3cku;Chas@f zP!WzXm@!bXcPbKz*f(}wI=UDF@_4^AbtgH26afhIHx3PBk)5X^VT@wnQR9<#L~M(t z<|)q#&C+uHckQ{3V@rmH1)a?PErGz)Z(vQbtpP~Tu*$HJ0!UBbWHc~NI~)D~XzGHV ze+bR+51~;sySiaLdz4E59%BD1t

    S7OCC|LD6nvnaZmSU}{r0$xP)chApVHzX_8P zw?E!~(|rq?Dof+f-Ib>l3`bMF>;I1g|2jyf7op%GUjhyHiRqqQ-%vbK(@`x|e);bI E0Qf`1nwWpG`n;AQ{n z`I&uUM9v1Z%Vf(3 z$CtOlr`PwBdsYsIQui=3@06Yr_wl`>ISGA)sjP>@)z-y@iOpZb6B85ry>V3)!Hbys zOmp~W6X)r+PpI0uFr$>sePZ6vhGld_^Pjc$z1};fev5xPm)G_zBPUDG0anYg;! z6!c^K50Qwcd)Kj&YltTj4RcqPettPTJj88pEE9+EM10=Z;`|iG{#iz9d4|7#Kp$~= z?qIXCcXFYxwRW!S`1p8nagj=;5{X2oX&jE`uSsonRb%g|&9rC>bM1tV@7L~UUlM)C zq;b;8mHx*1nCwuD0?{$q?t$Xk_QYD5Z9f;g`HXhn>@0T~WnVe3aGO)Wj@&}{ff_uy zEoTCQr`6B+y7WRA`ARQv&@(~>u=Ii8QwWv*4rE-IYOEG>>vHR=xYx%^T{$ssiPpF{ z6<3up9W#XcC0~^>h|mihM9o@d>;%9@cx&+fW!v^5-s>qdmVWG~?_&o(go?@f)0^8f z3-+cA(8o&aauq?~nCX#T(`TXsQYEg|3Zia8NwMmFP|fn49_rCR!|~&(&_7G}1fh>4 z)W(It@vedwKDY`!NJp(Lf%ZMelEAA|;jNmcR|B+mUGwgfz4Kd|-X#lj*$*=t!i^uD$uM+#q#kn*MXVPq+amjsjbs+@3hSk`WIc4HVJgM|HW>~ z`e%k)KK`EuOM4$XXOTZ@oQGzlFh-&h*9t(N373dr8)LA9G`L=CZ%CP`>)^%wZc+`0 z+^9zR(eX4VMKS^q&l9CO%q|42`%3lWo(->cL_J4Kpu^%lDAoa&c{Hn!(i4Q$$GP%3B%#SX1Cn&CY#vi1PAyk_)HQCS<174qX!?o@rVlX+wgxftkxw~bR zw~0XX&AM8~JI*3NzXR?O_M)?OHw4KQ@EFi+RpaCE}Ww_9C!4=gV=p=Q4M`sk8r2 zmNlKW0zye|J1gJ~?Sbxo%J>QozvBfnP)lb&CTnQtbuvMX;XN^Toz=f%b36>Sub7zUG1}~bdFE$%(K3PXf0Gr;YV`N7)hgf z21IHMYW8oU4B z-lemOf^tTYD6Jo%R^g`H%xQ~Borzr)UG2NL%&Mw=ufYbe8xOhO!^~NPb9uWaT?Rgg8Pxa8vx#EGVL7Rpb2pJvv8V)>DO8JEpGxmn z*>~?mfO41Vn3$t&U8uRxRlh^DybIJ#0$ewL0@q(Pd4P>5elLql7rPN#rh_@?%YDr6 zS0&2w^o^`BS5kJ4bs=`EbV@GQaOlmYq01H#aT?(luf3n%x|+wr;5u|DcIzCZ2-49V z12n(6#0l`?`tKyeZQckAoq5yh{`|F5J12jHi{=Vv2y|5ZtHq-EX@jc~azPqZ%)q!p z&64q}=XL!G9AAM=10Coomk1}ahFirC?B;udztIQ}7kfxK^y})}tZ<9g?#H_dV!tlj z@x8Jh36i|&zc+h06v%v{D{DPSnyIkA#{H{wiHRX4Sgsp!S=Y?{?##51sdrU*_A8Uo3HT!$mXdyP1Pd zM|EuL&xrzVe)~6K<9K_(MU`2|P`-Z8Tw@vDP5x<)7R$@lKEnp#i-hbGknimK?NSLS zFo%@8fRD>}g!iD6PVb;vcNW&_OJ65?N&(*AsamA{b~EKGsPn+;%PbDdW|Aa-_4K<4 z>zYGZkc-48L%#f_!W%5uH+6fHPs&IZ4<|V$Z9)&D){%H4KIC&T{9|VChs(huH*ji; zBF3MuqFy?QT07mpav^M0t>Ea77!bh&^7w-AT%VydTSyG}X#E-=R?I`~M*bwN3bMFe z$a{nD-C3O6|IM#gryDF{B78Z;w2GZb+csGLWF9Ztq6y(W=TmeIL3L4U9Uzb3Ri7u3 z+}se<>YeR?!5%7Gk$_@>{@klXP2+3h)SwR!N-m@wPj48%y1ckYM*tq>-E2&AG!Q+r z858BNgA=)UA(brnr(bydg-^A5*VMOnU=PtN{%jd7Q|h=&gZi2P66{3|tHmIrE?{2ea}i+oh(E=!BnElxG!_n+wu92gzhdw0UPathxvKOMi#ukAWPADx{SZ5ly9V{F z{eD2MSzSsE;F6E13qkju!K0@Ylm}@f*&2!Uu(TZnu8U0_bN2Yz z>DEc6-8K8wF!Q}CGZDOT&t3Lp&{V3c&mBG*hR3YB6>94AC8$Z>kKI;)2ymJLBlS8< z5u`3+KE^l(TtPxMJEaz>*Pg`F;CuPkgH*EGE`&3u*V*cw6}X1{!>^ifiM|Y*-wd+B z&Ty%VwOTzcCuA7=Z_IhkBJ!8YspW0oPwLG1*u!C+LG;@vyPm$Mb~!_h<$@(X<9lY; zY8wJ1{Id?8I%ux|Zh7TJNwRafo0Lc-*e~C%#$M9UqI@PHOS!MIK!3GZ@Mz}Us4h`s z={~PLoT`D#Y~Y`<$qd4ZmkZU(weWFnv)Aba2kw6Cx2OD`|~o+ zbuZ9xw4wvd)YgJ2EKN7pAG&2ack)rcqAFFEu>S^5Jy529U9{DQ3!tZyI znJGbizalPz8sLY0S~^U`{!DYaQ7 zn8&yyQX61VT=v%u?7Z6gDAy-5@?$C-9;U27^cPAgS}|>7YOb?~A9^bcvp)GRHp|l6 zKgiM?`8*rAu#9v4O}QRDcDTkE^dx2>==dT_00*D=sNyY_ns=zQAntvinnX~~`hCCg z52z%oiIJEgF8#AqQ3+KbUZKO@fHFhO-$i!c+(qKXaL9*-CK67j-WIZM;S*4C@QQtD z+SI8hUKw*YD=skwMzg=4os5N^+Ic(`e5z9@ckbddroE;<7HEsi0K^IE*#P@J5+t2d z&~|I(*-Y{>ey@B7-X+h(j@ikuhr)lh4WyuESS+55Vv)?L9e{`F+$4 ztq#;6*8S}LtYM`?zD{P=Y{ixW=0@$EnNJrhBjUZyBlr^2>yNElY!8re2+`^D*4#I0 z{fzAt`;qR?!X^;UgI~w$JINSZpUV>L*)_Zc96

    t7mHzQv=Rahf7`Y7b0Wy0waKz zFY(r0sJzx^qwu#M$>l?ZvjOsvus)as+1i-YQZ3>1i(2=Jlz$uXik#&22ZSo};>&KY z&UDjzy0^Bid|-mJ28Nae#jl;S;pLvk;@aC#h$!#t?u%i>LrcV>mat~txwr+X?rz-i z^e4*oG=AtyQfqJ#*}8cAj#svVzc(Sn`OFH3k`d73$95jpD00JK+q@s?q3+>UsXzEc zTRv1>ea~dIHymIpyCkZ&SwuE|xA4*m3T8Wv;z1xnVSVNyu)Y`!II9poS<>Ym82xAl zD$WWF>uA0Z9b)zq^@!a9((8A@iP~qhKElqdNtkvcU$@QlXt9RP>-H}p_K!LNBS)9BPTt`*6x%{N7Lsc?V6I3 zzYG0zJ->xELtsCPeel5D5Smt42^&sxdtuamnZ>CQvs$#^ zFwj}Q7_`f3EqswAt{v@DaBm}xhxRoh_5R}hYsMsoTZ^spcZZry6@}<9l%yWmx$?j= zQq2Pu`D+3>%MCvyOP#lsok8cX(AJMc2hRpZ6BVBeK>U|AaF=S+xTsJ4112r5?+af$ zMWfw+dA1EckQ9`mK#S@-`TRgFjJvQG#Q6Vc_dRwTeE42zm&k~A7+{h0n5)c7N821&V=X6s7+i20k+ zJgpxu=7ZA1XQq6MzT#635)L2O6e3F+M!nLVaT@au7WrB8Jr zG1JQD7S60gqiSor(!P+WB&slZZ9Hc}U1rogJ1(7*(0w4;n*78IEgx?fDx+-gNgo?` z2?I52_-6UovjOS#r{#}YvF2jQsA%7+1ixKD4W2MuS=;fl@cU_b@{6KbT)K9OjE2(_ z!OFSl8Bjpcf%x2~-W4^|H~P@ckgt*JxQ+8})r2$uFu2L%j49wn(*aWZO8eBEE>|Ds zhjAgDcQvUcHSsUbD5Vp-LfdGhcxEH#j+bF+I~CCjXK`f1a1A)N$(>&MBAZ%vFNe>E zRpeq~;!I1PClVE>Q75r=xwWEr>w!I5%Wbvn?Qg_c&NZ`;wqPwX1u_Qc8>rP-BOFb%wDNPy{WmsQ%kH8j$ia+K3l zwIn}Oy4pp{R`aVcF>Jz9DuJ`_S80oEsw-|mK4}2PWG|JorZ=?wY^Mz6WmDIMz53m< zsx}09CNFz+Z)AKj;~STvSp8{V zLRc41HUY9}P*_#mVeu?W?pz&nk95^SR3vz?Ihf`;StgGo0sKg;l3cGwDEzUD>6Y%Z z(i~!}RmO0DCifZgv)`_oAB&8MzaHJEsKyr(GVHMq%NXUc-ESvR>>P`3Ot$ZTAKj+$ z)^zt5y3pd=YX2rnxv;*D@?NV5%2{Pya^O&<<+MwAqHT%W>&9=>)T0O6x=J zh$>Z@^&=mbdUJcf~S-M(k< zr|w`g*YA|JBN{Em?Sd4(L-^9xmGaKmhIJX*P!_Pwl2VTJGUp2BTixQAO9>rcw+a#V zn^iY~-Pm}FOu~5lZbKX?c20*g24nHM3elymhHti3k*b{LbnrO|luYhvLDsrxJR*w; zpyjr!P^iz5RC#3$XWvTsNb51gX`?)Dpc;=rqVCA$ouwB2dJ1)?w%ZL{`U@2j|ELeKz%iS_%_xE!Tn>wTC84f|J z9t68zq|;K%lTttJiA~4dwB%P}77wQ~kNF&d`y5>afGgfd@X`G}U^Nuy+LK3Bk&8n4 z!l_~pV8@_(AB4IC?D&fL#v1HrKc*GGm;R`IB;dsFf0o692S)-98sSvP-(lo`i5&k| z|Hz13W}pmX$2G}sfByKl0#b4os14vNZ0+<-boE(3Aut||QtYr{!K^faXbQkeCupwW zGhgu%7DxO+(^c9)4LzQ4*<}njQ_~|pfY(T@^%QkgCMs^arUo$-K3#*ki5YYHRGQ1# z4N}w%y>irF_Jzz57B(*^Lt2@Yl_yAxCvJZ8sOCp9TS^1p^;Dd#du`RPeCEx$T`C^@yV8x@38v<6hL*U1f=WB#RBf9bZK@uD!kEN(MRCuHYG>V5&& zDr9AYqZwhKi~N0nZo7hjaz_fmHKXA_0mg1Ed3X(AhDZi^I3yDB6I=Qz7I25u;)^fE7VZ33 zmv?bd0GyZ|N{Va;iOB`kH@t+N%gV|kO3bS%b3Cj^zY^uv3;)r;a6Bo5!>LWBiW!nu zwNqXQDOi7UI^vIrNHj!Nr0naF|r% zT?_Bj)gv*)hm^X2B3i#J>T}*?fc5Sg8v=1@ywjZ=dz^?zUpxUVkpKvOtbcXTfq3u? zz&N(RaL9S*A87oOf&M>edIkjxQ8;g0`t|*LMR+of#s_LFwt13t$E< zF6;spXVTF1HCTMP1(I7w2#fZ-_<6*8dT^e`fILCN%WgW1|MWm^!Q3hFn8V2Y>fCv? z=x81^4^;C)`_YSUikDB!jIKgRMZR}oql^fG7CR>gjEB&A9e9KCBPaA$jA*I+|xX;6CO0RPJ>)xGVM*UbS@gmAl;qXa{pp@WGica7Qjd+ud&z znaNYPu*e}qaZLD@4-)Jd44DR%4mI994ZLe5gC%{A3 zcj^C<@c$OKX=(l4BgDshT=#NxWPxzjk4(k|F~RLf$c74IVB=7h;0rUvMecAeMxT$d p-l9-}Rjz->{;6X$9RuC7h9?0m;teNg|JUfWH4M~C?mT(-e*lHFgdG3? literal 0 HcmV?d00001 diff --git a/docs/SITL/assets/serial_receiver_sbus.png b/docs/SITL/assets/serial_receiver_sbus.png new file mode 100644 index 0000000000000000000000000000000000000000..ce4ebcce1690df41de20165d5f73fedf4d640a48 GIT binary patch literal 6803 zcmaJ`cQl;cw)_Kp~`<(sk^G4}tsa&JJO-)8dc1`t};&U>x zOF%L*@`qO`ND|d|4Bey`ipzO(USm$SZT=(nZ$W31L=kuy~JNXl~u zxkoOgV~@+`%0HHi#r2CTJBx^jVbS&T^Yf``X`&+D)!sS{4GqrDl?Gm)$jH16%IBQY z24d8Gv&K#y1Xou$yXLxpDux##jN~U#t1rncA`#oYTUcr5lHs9Ur$-SHkIWJ}XF8Hy z=C+R0`!-GnQcuUSk5IpG$A_tdrvnou)6>(fVG^@NCb$j6>hkpO$sY=)!6AB?MP^#L zhHeX8Ik1NB-6#FOk8$wPruFuij+M>TmEN_@}UKcZJl^?}4hUk$61Fk}zE>SpL23Gf7r8E)W{DFIYY|!|S-uAgq$w&!CBx;=e zr_*y(5nzm>JdT4Q4t7=RivGiW@?gM*+4Hz(+7fd&GAMzg4E~uZ{?wrS+s6#IWo5;8 zDiFw8B$t~1KH*J(|G70S{P4#kK}D*VJ4uSY#j?PnS3&4c?As^js%+8qeKS(;GYrE8 zpRxC&l<#$-o^|EI;_!h@<}EuaJC;(q(;G3i0Z)Lk-YdunE`}?&lEoFQP{XLi3Bt4N zg@dVg^iagjaLr|&fB&juvwzuxd)_KT@5D?7eVl65(HwzWB5(d+ON`gS=SwJBK^!qQvG?ofFqlT` z=Asmqn?;*bXLq8QCVFtMB+iphJ+{&Cdxpz3584u|zfeQ7vRg+`5rg0j*kl?5Mj=2& zyxBb6JpIwyy$+SRQ+JbJ^h|xf&+A8e7HhDa9?|`ldq-FXE#(=YGro+{!~(Mx% zvhJ-+sI&W7^Q+(;J)^d5X51SwR`MFn~^x#?ZhE}?n$0FE3I;l4c)F6&O0r7VvT>{c$-w84T`6z$>Prsdt@_(uP z3An%2{*M@SkI!=%@688{`JO@i2+#QCoZUXW%JtX=h8%>W5eT%lm}FOi)+(0;kMAm7 zcPN}LkMadsF$!BY^=&m)B}uj~7^a1?si9*REAK!q(|ROmp^7Z9SX=0~Wq3A?LrpD7 z)6+!autp}7witme3su<~9Yk7DL*41Q46$@)5zvs4(;f1~jDd=6Bl9uw z-dyJ!ilD8F);zV6-Ct4hE!&`{*o|kP-}-N>*u0YbSjNa@+K~)l4KJvuTrNqqBgev) z2=afd_^&0MC_wiM=$KZh!cH##V=k{?tnci&jI0vd3vo~`$e>L^U7y*j2D|Z!ot-v; zUB6Qag>n|V3~ERAVW-)i@on;~N#1yzbC4qa^7K`_Nh1r;@TQ&rn48{+jG0|O+|5oo zc}F`{loh_MvU4~Mn|S1f&utzFT=Y^Fw5o zn`X-=N-uY4z6rD)8#Pme_5EFTp6HmOORP`!!?T!N%N7C#>@Btt9sRx{;knLx5sq$5 zmcAFkpE@9)`&S>G_}&Z53e;`YF5PHuRpXnZ^OL9sw5kn9qPMz2KAco6U$ztONTq|T zZSD5Z)5vW;kw%<~^4|-iQm-2rRi|2v?;L-5H~D+jElWbcunIcG3#9Cz;l24+JnwjR zih&`va5_PNnOV0-&Fkfn;Vnk%?f4d*N57vo9zI!$Y~WyfgIyuzBR6}Ef!v)c8HI)3emhYQ1^8&95b zjMC5TycD^+@{9oS>+Ks7P6y{HR4mgt>L>%967~D-U>v|#@>1x z1UEgj_1LQD_%I#T|1&<$RW{SdNvY;ow&Tfq=<>yuW(cUaD;ptQUj{WwsB1({cqp+O zZZI9P6nq$Tu)WLTV0Mny>Z0<=bH+Ci+DA$el_wFB<~#o@O*zUYUQT)HNP~x{|oz|dq6;7`3v^kQYD10>w{1$p7QvGH8?zG z^1iLHte>?Xk83@v?EtfU`8my;xQuz>lqm68pMT=}DmQh{Vzy|<+3>m>(3f-;;k?n8 zdHAAtqT^F8&{?lRt2M5bwZg(x7zY3EWi8%tY&d@C{@fTBSLRM{c3%?9!?JQ*tS?T^ zY~<>k>8>JV{}62h>!x9O267BK0qJD@IJO~<8ts8)x{#K`%Qp@&=$1}0Nu7lt$#2B# z)XFXDm7U3)(7V&Grr9=1ma3HW45_TYJI4Mx$`mqZ!^`?+8A-(amO+@=9V_5I#wy_X z$1UnVDB!d8F4)+>6F|{9?IQ_`xdg;4H{Bpxf>P93;RD9*+f;Azy}VYYp+!}f*Xy`; zZ2EF)>+zwVrwWiQwOVoG7r0l@r@6rk9bvfG&#FT#%R?2@e-W3~2O^3?e#F6U3kLwh zKS{L!pj#s>huXtbTnds)NvQMsDR;u&9b&j6k4HLp72+1C%LB)jJ?8Of@0a$-jojG9 z4f5FP?FZLfky$rxU3shG4$&IDfAdx>p6lfhcm0~<2_0v#t8sS(Z+|4PB2=bgDeEc- zTZ7rK+3%Q2L$V7a0TMO>%)%?i*a8i|`3IjiW9fBL#hx>QO}isbgWa)P#A86tdjMTz zIFbPZsUN&eF{!Lbvn3~ovWb{=9;jCmgyW0qx~+F-h48Vl3ojqlDwyYA0&6z&IIe`I zj_n%3Z|Hk=3l+l4jxGI7b`jrJx4%$4IPhO@nv$qHC}8Z4w;$@B&Gv8%X49#Ea@U)C zkKY;j7Wokk%sBocNu-DLPIMebIJ=6q8|i-JdL-BVo3LCcG3=#Wc3CVh@wEY=0~cA2 zwyzh;byhG3wm8H9@6ca^abaKjNj|#5nYz5r^ay0k*LJa&#eD;4ExFgmUtZyIdmSz% z)7e_qB$7IJj(fFYX)6XSWL>di)b>N~Do^}sGvF}}sA=Jyympw=PZ-DwTL`Mz=ZvAg z%*YL=`}|HjAl*A!b6S^bwZ_j_2)&-AnA<37z1c=-8-Q$LpRlufKgw4q<;;HYISr>Y=yi~&?En?!ze!t%6+<3$6N})0K6SMG?`+N#4!{#Gksyoi ze;`CE5@Z(`I-3p)KS%6yroNqJGbn{#7_aNIIZS%x(TPnoT6l$^B%s{EkVSBWyk~;@k_D_tdT(ajB@n1hjjuh z-zmL-DJq99pAbK;zI-fE$g4+pDLD4VO2>mX{;;^wrF1`x;vaa?Dlm1h7%CYd>K<~Vo=KkW#*pW1t==nX*_QpaC!UNDt47E)o0 zE#v>v(&$L6{9?RBJ+x@}2;?7e6#B9vA}JeCp-SuCT$<*Lm$iUrZJP=_~*g+K_w?l^phF(5C*cX9(RlFIASMG!9G3t}E? zP1sSBJI}4K2Qr4j%CT~&EzS2{n-corsVDw z-fMLMJkRCt+csWP48S77)}a2owOGW40W0l94}b<($*LfEc_>*agN6ZvaJp`@TKyH` z$Q>POGZ*&2f&0m{ZtK1!JE$4p$U&s1VZ8hB!YLjIc^y=7VfEsM0YTUe0aVt{`)t0v zd5PtFdZ0cnsCndusKQ@%wz^*u(zG>j5q;4}M}N#dBa*@*#jWbV4@f z!3@t)1m`*}YfyTWZFXyU_&|(h48ORt=uynC)GU!v$O_jE+~K3PjO7s}%0uAn0G&2v z{qaNJYx_SOs_EV}hkNCm-?-GR%9jsB$IfRQ_C+#LO&%`gMarT%zi<#{MjWuAXmIoyAmKW#*DCKCB8AChtVeaRd z+J>`gM0rlK={A__nv3%H#kgszs_OH}o5k*$F)I;t)LFjOfyrEMBaTv&%t6d<5~U*)ACI} zUf6Cdq2GRO6+bim03eY6SzAZD`(e1)UCWZ5`qIld6{Z2HhHi=xaPK9>{TleSO>oui zC4e3yIGjJDLYmvvJbo#Z&mv)2D+3i_^+W;VJj{8`AwC*-1-N?9DJ5*R5NH)Zg!NRf z-PPlP_I|CyG8i~tINSr?rI1)riF4OfKNDIYoSG6uH0=cxo-y4zGb^e3%RZ1#*M<5AX=#Y^xF`OQ~;R%Y$kQCaDJ2nrxIl(tbQ9 z?Xg$9KG?Y=35qUotC-AH_oOLXsvmU3RG#D|Ug4JR+za0e4dQ!Ksf4I6eRN^walQl* zej*Oy&Cg~?)H_Ec+v2fz^fWG*px`la@cbb=IT8!KZqaE`4VNYjKL;fo;vlQGjaJIZk z?M|d(kRRTP4v+{+*E^K6N2bOYFQGK1ki2s9N!5L}S&;3TjW+Rpr)PRNj(SnM^C)W2 z{`sB1i|wzhzy|QuFUv*ddqOgK4sB0)&=jXU3f~}g#*1f1z#T2xG6eR?@_0}_9SU)> z36|FNo*>Cd!p{L`BYR)9iNR6{u%bKyD(8IDukdUWth0`>f}Ux=s@NiFPr`{$*?J?; zo8Ssk^S5apfx`RNpW6T5qW+&kc72EnU$Xou4ohAT82rzmIWvh(NZBHgGX8H$jVdP6ETcwQ7} z?6KwzJQ|&As@62}4?xWx{lf0Qap=>rSIiK=`0T#h@~bQ+HgB$m3Uz-lvds}dTFGm! z+2p5TMCiTaddzQ(1k&CTId1j(%w+AK3-JxvcG>`zR7pnkL`diD$FAi-_DhWKR%+s& zXz1G};f$jI8a(nDPu?ez$G=anZpOS9-6r915uy(@DjrXA1Dja4Aq_X{dl=Py^%+pY zx`~?ZmQR4&g5e?3TL-Piz@>3Ut+@1D2SUxQnAC4;D&nE8KJP-?4*n znS;p84l1sqUL3DP3?NT9WjICVFa%aj_P9C?;@fpyWa+xAIt@xieU|C2wLmI$%TdL7 z-!Xkq_~ilc?oD4p2R1>y!TTF?L{zkk65df4+J6Y!v^$u|jk}h(bF@S@AReN2<}lOR z%l#j72t)!W+U)cu(`Mc}jx$!JHN|hk8$hM6hQzy%y-C#X4;##h2jE))f4E~P#~<#< z`G2_M-%j`X3;PaCjklr)bJPj_69)M-2$hmge&zXeB=@F7`%m-hT8(zE6n*mZ6@GfA z^A}Sb3}H{Ye}N@oYNQkNe`v=)F$PUMM;GA=hS4@D?AqTUVdpVDRO4OzTO`u)i+;-u z1Y9ZTl@?dblka;e-vSkr_z*7!f@<>FaNh!Vsw({zCK`QRpn%Sd5!{GuGP@4GpUVE- z_TiT#?aJ=LEk)64twCIiy3PAhNPH^2!mh~I*o6`9Rj%iyuOvNQKpRt3ku-|rkG**< zFmLqIhu-=0bri*{+Bn=seK8w~kOKMnwiBABw|nDQQE26*4j(=CHirLHj@~{Tsowi? z=ezIhHSXhdPS@cVWu22fuxBT)J+cWENhm72lda#@wy|lrRV+b(D`W-Plc0%zNevE@ z)o{k8-w{$d`+{~^70xR0slGy9xcr6^xF}G;p6ZowPBQ@Burpo-c9)n45RLn!2Nt;} zq8=_4eT6jiJTy6*GG~X;1F0h7$Q9koop8S0QaqL8^1DK&M6{|NOzQ5aC0^*Z<}y=)RLbsN5~>1GMKi<0GciJTrw$A?lp2T=mkLSSx_ zLkY#=WkipIMay;->4V_K^}maQvH}u&;phzq{Ia|{g9$!Q;xq$s{Lg*gY$O0%)DFCY zp^!hn^iPe^C`@86Oe6>%O7jN-<}f220?ZRVkkP~13cS_QRSJ-o-zR*8vYz44doGOt z30{@k51al|8q{J57c28v`Qr zUAqXScYXlAQUKA1@`dqWT1*XbR8FXGkh5e95(dvvik)` z)C@;}Jp%{hu5DX>gPF<6&osG#xlQpoynI!02LMrzsD#i2DZ%jN6X7Rc9B2fN@m9r} z1=5-MOIB;47uPz+3Wg2wiqzhcpnnQ0OO z;1{U*#NOq503MS*B#YjSfFR~R&!UpcDm}qpw8iseC(UXMayRO zIXZolEYjBf$5$Qyudn_+uSxDph=PfduJ^0H3?pqH50e_Zs&N3LVpayqFUqjpNOcsd w!ddi^+$~KH8A>3%SM0yovYE3_WE5oY#^62)TLa%n|3Ju8m9!MAserialPort.rxCallback) { + port->serialPort.rxCallback((uint16_t)buffer[i], port->serialPort.rxCallbackData); + } else { + pthread_mutex_lock(&port->receiveMutex); + port->serialPort.rxBuffer[port->serialPort.rxBufferHead] = buffer[i]; + port->serialPort.rxBufferHead = (port->serialPort.rxBufferHead + 1) % port->serialPort.rxBufferSize; + pthread_mutex_unlock(&port->receiveMutex); + } + } +} + +void tcpReceiveBytesEx( int portIndex, const uint8_t* buffer, ssize_t recvSize ) { + tcpReceiveBytes( &tcpPorts[portIndex], buffer, recvSize ); +} + int tcpReceive(tcpPort_t *port) { char addrbuf[IPADDRESS_PRINT_BUFLEN]; @@ -162,22 +180,12 @@ int tcpReceive(tcpPort_t *port) return 0; } - for (ssize_t i = 0; i < recvSize; i++) { - - if (port->serialPort.rxCallback) { - port->serialPort.rxCallback((uint16_t)buffer[i], port->serialPort.rxCallbackData); - } else { - pthread_mutex_lock(&port->receiveMutex); - port->serialPort.rxBuffer[port->serialPort.rxBufferHead] = buffer[i]; - port->serialPort.rxBufferHead = (port->serialPort.rxBufferHead + 1) % port->serialPort.rxBufferSize; - pthread_mutex_unlock(&port->receiveMutex); - } - } - if (recvSize < 0) { recvSize = 0; } + tcpReceiveBytes( port, buffer, recvSize ); + return (int)recvSize; } @@ -240,9 +248,21 @@ void tcpWritBuf(serialPort_t *instance, const void *data, int count) send(port->clientSocketFd, data, count, 0); } +int getTcpPortIndex(const serialPort_t *instance) { + for (int i = 0; i < SERIAL_PORT_COUNT; i++) { + if ( &(tcpPorts[i].serialPort) == instance) return i; + } + return -1; +} + void tcpWrite(serialPort_t *instance, uint8_t ch) { tcpWritBuf(instance, (void*)&ch, 1); + + int index = getTcpPortIndex(instance); + if ( !serialFCProxy && serialProxyIsConnected() && (index == (serialUartIndex-1)) ) { + serialProxyWriteData( (unsigned char *)&ch, 1); + } } uint32_t tcpTotalRxBytesWaiting(const serialPort_t *instance) @@ -263,6 +283,10 @@ uint32_t tcpTotalRxBytesWaiting(const serialPort_t *instance) return count; } +uint32_t tcpRXBytesFree(int portIndex) { + return tcpPorts[portIndex].serialPort.rxBufferSize - tcpTotalRxBytesWaiting( &tcpPorts[portIndex].serialPort); +} + uint32_t tcpTotalTxBytesFree(const serialPort_t *instance) { UNUSED(instance); @@ -272,7 +296,6 @@ uint32_t tcpTotalTxBytesFree(const serialPort_t *instance) bool isTcpTransmitBufferEmpty(const serialPort_t *instance) { UNUSED(instance); - return true; } diff --git a/src/main/drivers/serial_tcp.h b/src/main/drivers/serial_tcp.h index d27610eb805..7f394b8ccd3 100644 --- a/src/main/drivers/serial_tcp.h +++ b/src/main/drivers/serial_tcp.h @@ -26,6 +26,8 @@ #include #include +#include "drivers/serial.h" + #define BASE_IP_ADDRESS 5760 #define TCP_BUFFER_SIZE 2048 #define TCP_MAX_PACKET_SIZE 65535 @@ -50,5 +52,7 @@ typedef struct serialPort_t *tcpOpen(USART_TypeDef *USARTx, serialReceiveCallbackPtr callback, void *rxCallbackData, uint32_t baudRate, portMode_t mode, portOptions_t options); -void tcpSend(tcpPort_t *port); -int tcpReceive(tcpPort_t *port); +extern void tcpSend(tcpPort_t *port); +extern int tcpReceive(tcpPort_t *port); +extern void tcpReceiveBytesEx( int portIndex, const uint8_t* buffer, ssize_t recvSize ); +extern uint32_t tcpRXBytesFree(int portIndex); \ No newline at end of file diff --git a/src/main/fc/fc_init.c b/src/main/fc/fc_init.c index 2839a338f22..b1352c1ce27 100644 --- a/src/main/fc/fc_init.c +++ b/src/main/fc/fc_init.c @@ -147,6 +147,10 @@ #include "telemetry/telemetry.h" +#if defined(SITL_BUILD) +#include "target/SITL/serial_proxy.h" +#endif + #ifdef USE_HARDWARE_REVISION_DETECTION #include "hardware_revision.h" #endif @@ -223,6 +227,10 @@ void init(void) flashDeviceInitialized = flashInit(); #endif +#if defined(SITL_BUILD) + serialProxyInit(); +#endif + initEEPROM(); ensureEEPROMContainsValidData(); suspendRxSignal(); diff --git a/src/main/fc/fc_tasks.c b/src/main/fc/fc_tasks.c index 246d65c0a7e..406622af38f 100755 --- a/src/main/fc/fc_tasks.c +++ b/src/main/fc/fc_tasks.c @@ -93,6 +93,10 @@ #include "config/feature.h" +#if defined(SITL_BUILD) +#include "target/SITL/serial_proxy.h" +#endif + void taskHandleSerial(timeUs_t currentTimeUs) { UNUSED(currentTimeUs); @@ -421,6 +425,10 @@ void fcTasksInit(void) #if defined(USE_SMARTPORT_MASTER) setTaskEnabled(TASK_SMARTPORT_MASTER, true); #endif + +#if defined(SITL_BUILD) + serialProxyStart(); +#endif } cfTask_t cfTasks[TASK_COUNT] = { diff --git a/src/main/main.c b/src/main/main.c index c002fbab25c..c303602dcbc 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -27,6 +27,11 @@ #include "scheduler/scheduler.h" +#if defined(SITL_BUILD) +#include "target/SITL/serial_proxy.h" +#endif + + #ifdef SOFTSERIAL_LOOPBACK serialPort_t *loopbackPort; #endif @@ -65,6 +70,9 @@ int main(void) loopbackInit(); while (true) { +#if defined(SITL_BUILD) + serialProxyProcess(); +#endif scheduler(); processLoopback(); } diff --git a/src/main/rx/sim.c b/src/main/rx/sim.c index a2a336f612e..62d9a9b864c 100644 --- a/src/main/rx/sim.c +++ b/src/main/rx/sim.c @@ -31,15 +31,14 @@ static uint16_t channels[MAX_SUPPORTED_RC_CHANNEL_COUNT]; static bool hasNewData = false; +static uint16_t rssi = 0; -static uint16_t rxSimReadRawRC(const rxRuntimeConfig_t *rxRuntimeConfigPtr, uint8_t chan) -{ +static uint16_t rxSimReadRawRC(const rxRuntimeConfig_t *rxRuntimeConfigPtr, uint8_t chan) { UNUSED(rxRuntimeConfigPtr); return channels[chan]; } -void rxSimSetChannelValue(uint16_t* values, uint8_t count) -{ +void rxSimSetChannelValue(uint16_t* values, uint8_t count) { for (size_t i = 0; i < count; i++) { channels[i] = values[i]; } @@ -47,10 +46,11 @@ void rxSimSetChannelValue(uint16_t* values, uint8_t count) hasNewData = true; } -static uint8_t rxSimFrameStatus(rxRuntimeConfig_t *rxRuntimeConfig) -{ +static uint8_t rxSimFrameStatus(rxRuntimeConfig_t *rxRuntimeConfig) { UNUSED(rxRuntimeConfig); + lqTrackerSet(rxRuntimeConfig->lqTracker, rssi); + if (!hasNewData) { return RX_FRAME_PENDING; } @@ -59,8 +59,7 @@ static uint8_t rxSimFrameStatus(rxRuntimeConfig_t *rxRuntimeConfig) return RX_FRAME_COMPLETE; } -void rxSimInit(const rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig) -{ +void rxSimInit(const rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig) { UNUSED(rxConfig); rxRuntimeConfig->channelCount = MAX_SUPPORTED_RC_CHANNEL_COUNT; @@ -68,4 +67,8 @@ void rxSimInit(const rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig) rxRuntimeConfig->rcReadRawFn = rxSimReadRawRC; rxRuntimeConfig->rcFrameStatusFn = rxSimFrameStatus; } + +void rxSimSetRssi(uint16_t value) { + rssi = value; +} #endif diff --git a/src/main/rx/sim.h b/src/main/rx/sim.h index 88342acad73..9c8ff36d1b0 100644 --- a/src/main/rx/sim.h +++ b/src/main/rx/sim.h @@ -20,4 +20,5 @@ #include "rx/rx.h" void rxSimSetChannelValue(uint16_t* values, uint8_t count); +void rxSimSetRssi(uint16_t value); void rxSimInit(const rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig); diff --git a/src/main/target/SITL/serial_proxy.c b/src/main/target/SITL/serial_proxy.c new file mode 100644 index 00000000000..281fefd3ede --- /dev/null +++ b/src/main/target/SITL/serial_proxy.c @@ -0,0 +1,784 @@ +/* + * This file is part of INAV Project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * Alternatively, the contents of this file may be used under the terms + * of the GNU General Public License Version 3, as described below: + * + * This file is free software: you may copy, redistribute 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. + * + * This file 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 this program. If not, see http://www.gnu.org/licenses/. + */ + +#include "serial_proxy.h" + +#if defined(SITL_BUILD) + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "platform.h" + +#include +#include +#include +#include +#include + +#include "drivers/time.h" +#include "msp/msp_serial.h" +#include "msp/msp_protocol.h" +#include "common/crc.h" +#include "rx/sim.h" + +#include + +#ifdef __FreeBSD__ +# define __BSD_VISIBLE 1 +#endif + +#ifdef __linux__ +#include +#ifndef TCGETS2 +#include +#endif +#else +#include +#endif + +#ifdef __APPLE__ +#include +#endif + +#include "drivers/serial_tcp.h" + +#define SYM_BEGIN '$' +#define SYM_PROTO_V1 'M' +#define SYM_PROTO_V2 'X' +#define SYM_FROM_MWC '>' +#define SYM_TO_MWC '<' +#define SYM_UNSUPPORTED '!' + +#define JUMBO_FRAME_MIN_SIZE 255 +#define MAX_MSP_MESSAGE 1024 +#define RX_CONFIG_SIZE 24 + +typedef enum { + DS_IDLE, + DS_PROTO_IDENTIFIER, + DS_DIRECTION_V1, + DS_DIRECTION_V2, + DS_FLAG_V2, + DS_PAYLOAD_LENGTH_V1, + DS_PAYLOAD_LENGTH_JUMBO_LOW, + DS_PAYLOAD_LENGTH_JUMBO_HIGH, + DS_PAYLOAD_LENGTH_V2_LOW, + DS_PAYLOAD_LENGTH_V2_HIGH, + DS_CODE_V1, + DS_CODE_JUMBO_V1, + DS_CODE_V2_LOW, + DS_CODE_V2_HIGH, + DS_PAYLOAD_V1, + DS_PAYLOAD_V2, + DS_CHECKSUM_V1, + DS_CHECKSUM_V2, +} TDecoderState; + +static TDecoderState decoderState = DS_IDLE; + +typedef enum { + RXC_IDLE = 0, + RXC_RQ = 1, + RXC_DONE = 2 +} TRXConfigState; + +static TRXConfigState rxConfigState = RXC_IDLE; + +static int message_length_expected; +static unsigned char message_buffer[MAX_MSP_MESSAGE]; +static int message_length_received; +static int unsupported; +static int code; +static int message_direction; +static uint8_t message_checksum; +static int reqCount = 0; +static uint16_t rssi = 0; +static uint8_t rxConfigBuffer[RX_CONFIG_SIZE]; + +static timeMs_t lastWarning = 0; + +int serialUartIndex = -1; +char serialPort[64] = ""; +int serialBaudRate = 115200; +OptSerialStopBits_e serialStopBits = OPT_SERIAL_STOP_BITS_ONE; //0:None|1:One|2:OnePointFive|3:Two +OptSerialParity_e serialParity = OPT_SERIAL_PARITY_NONE; +bool serialFCProxy = false; + +#define FC_PROXY_REQUEST_PERIOD_MIN_MS 20 //inav can handle 100 msp messages per second max +#define FC_PROXY_REQUEST_PERIOD_TIMEOUT_MS 200 +#define FC_PROXY_REQUEST_PERIOD_RSSI_MS 300 +#define SERIAL_BUFFER_SIZE 256 + +#if defined(__CYGWIN__) +#include +static HANDLE hSerial; +#else +static int fd; +#endif + +static bool connected = false; +static bool started = false; + +static timeMs_t nextProxyRequestTimeout = 0; +static timeMs_t nextProxyRequestMin = 0; +static timeMs_t nextProxyRequestRssi = 0; + +static timeMs_t lastVisit = 0; + +#if !defined(__CYGWIN__) +#if !defined( __linux__) && !defined(__APPLE__) +static int rate_to_constant(int baudrate) +{ +#ifdef __FreeBSD__ + return baudrate; +#else +#define B(x) case x: return B##x + switch (baudrate) { + B(50); + B(75); + B(110); + B(134); + B(150); + B(200); + B(300); + B(600); + B(1200); + B(1800); + B(2400); + B(4800); + B(9600); + B(19200); + B(38400); + B(57600); + B(115200); + B(230400); + default: + return 0; + } +#undef B +#endif +} +#endif + +static void close_serial(void) +{ +#ifdef __linux__ + ioctl(fd, TCFLSH, TCIOFLUSH); +#else + tcflush(fd, TCIOFLUSH); +#endif + close(fd); +} + +static int set_fd_speed(void) +{ + int res = -1; +#ifdef __linux__ + // Just user BOTHER for everything (allows non-standard speeds) + struct termios2 t; + if ((res = ioctl(fd, TCGETS2, &t)) != -1) { + t.c_cflag &= ~CBAUD; + t.c_cflag |= BOTHER; + t.c_ospeed = t.c_ispeed = serialBaudRate; + res = ioctl(fd, TCSETS2, &t); + } +#elif __APPLE__ + speed_t speed = serialBaudRate; + res = ioctl(fd, IOSSIOSPEED, &speed); +#else + int speed = rate_to_constant(serialBaudRate); + struct termios term; + if (tcgetattr(fd, &term)) return -1; + if (speed == 0) { + res = -1; + } else { + if (cfsetispeed(&term, speed) != -1) { + cfsetospeed(&term, speed); + res = tcsetattr(fd, TCSANOW, &term); + } + if (res != -1) { + memset(&term, 0, sizeof(term)); + res = (tcgetattr(fd, &term)); + } + } +#endif + return res; +} + +static int set_attributes(void) +{ + struct termios tio; + memset (&tio, 0, sizeof(tio)); + int res = -1; +#ifdef __linux__ + res = ioctl(fd, TCGETS, &tio); +#else + res = tcgetattr(fd, &tio); +#endif + if (res != -1) { + // cfmakeraw ... + tio.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON); + tio.c_oflag &= ~OPOST; + tio.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN); + tio.c_cflag &= ~(CSIZE | PARENB); + tio.c_cflag |= CS8 | CREAD | CLOCAL; + tio.c_cc[VTIME] = 0; + tio.c_cc[VMIN] = 0; + + switch (serialStopBits) { + case OPT_SERIAL_STOP_BITS_ONE: + tio.c_cflag &= ~CSTOPB; + break; + case OPT_SERIAL_STOP_BITS_TWO: + tio.c_cflag |= CSTOPB; + break; + case OPT_SERIAL_STOP_BITS_INVALID: + break; + } + + switch (serialParity) { + case OPT_SERIAL_PARITY_EVEN: + tio.c_cflag |= PARENB; + tio.c_cflag &= ~PARODD; + break; + case OPT_SERIAL_PARITY_NONE: + tio.c_cflag &= ~PARENB; + tio.c_cflag &= ~PARODD; + break; + case OPT_SERIAL_PARITY_ODD: + tio.c_cflag |= PARENB; + tio.c_cflag |= PARODD; + break; + case OPT_SERIAL_PARITY_INVALID: + break; + } +#ifdef __linux__ + res = ioctl(fd, TCSETS, &tio); +#else + res = tcsetattr(fd, TCSANOW, &tio); +#endif + } + if (res != -1) { + res = set_fd_speed(); + } + return res; +} +#endif + +void serialProxyInit(void) +{ + char portName[64 + 20]; + if ( strlen(serialPort) < 1) { + return; + } + connected = false; + +#if defined(__CYGWIN__) + sprintf(portName, "\\\\.\\%s", serialPort); + + hSerial = CreateFile(portName, + GENERIC_READ | GENERIC_WRITE, + 0, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + + if (hSerial == INVALID_HANDLE_VALUE) { + if (GetLastError() == ERROR_FILE_NOT_FOUND) { + fprintf(stderr, "[SERIALPROXY] ERROR: Sserial port was not attached. Reason: %s not available.\n", portName); + } else { + fprintf(stderr, "[SERIALPROXY] ERROR: Can not connect to serial port, unknown error.\n"); + } + return; + } else { + DCB dcbSerialParams = { 0 }; + if (!GetCommState(hSerial, &dcbSerialParams)) { + fprintf(stderr, "[SERIALPROXY] ALERT: failed to get current serial parameters!\n"); + } else { + dcbSerialParams.BaudRate = serialBaudRate; + dcbSerialParams.ByteSize = 8; + + // Disable software flow control (XON/XOFF) + dcbSerialParams.fOutX = FALSE; + dcbSerialParams.fInX = FALSE; + + // Disable hardware flow control (RTS/CTS) + dcbSerialParams.fRtsControl = RTS_CONTROL_DISABLE; + dcbSerialParams.fDtrControl = DTR_CONTROL_DISABLE; + + // Disable any special processing of bytes + dcbSerialParams.fBinary = TRUE; + + switch (serialStopBits) { + case OPT_SERIAL_STOP_BITS_ONE: + dcbSerialParams.StopBits = ONESTOPBIT; + break; + case OPT_SERIAL_STOP_BITS_TWO: + dcbSerialParams.StopBits = TWOSTOPBITS; + break; + case OPT_SERIAL_STOP_BITS_INVALID: + break; + } + + switch (serialParity) { + case OPT_SERIAL_PARITY_EVEN: + dcbSerialParams.Parity = EVENPARITY; + break; + case OPT_SERIAL_PARITY_NONE: + dcbSerialParams.Parity = NOPARITY; + break; + case OPT_SERIAL_PARITY_ODD: + dcbSerialParams.Parity = ODDPARITY; + break; + case OPT_SERIAL_PARITY_INVALID: + break; + } + + if (!SetCommState(hSerial, &dcbSerialParams)) { + fprintf(stderr, "[SERIALPROXY] ALERT: Could not set Serial Port parameters\n"); + } else { + COMMTIMEOUTS comTimeOut; + comTimeOut.ReadIntervalTimeout = MAXDWORD; + comTimeOut.ReadTotalTimeoutMultiplier = 0; + comTimeOut.ReadTotalTimeoutConstant = 0; + comTimeOut.WriteTotalTimeoutMultiplier = 0; + comTimeOut.WriteTotalTimeoutConstant = 0; + SetCommTimeouts(hSerial, &comTimeOut); + } + } + } +#else + strcpy(portName, serialPort); // because, windows ... + fd = open(serialPort, O_RDWR | O_NOCTTY); + if (fd != -1) { + int res = 1; + res = set_attributes(); + if (res == -1) { + fprintf(stderr, "[SERIALPROXY] ALERT: Failed to configure device: %s %s\n", portName, strerror(errno)); + close(fd); + fd = -1; + } + } else { + fprintf(stderr, "[SERIALPROXY] ERROR: Can not connect to serial port %s\n", portName); + return; + } +#endif + connected = true; + + if ( !serialFCProxy ) { + fprintf(stderr, "[SERIALPROXY] Connected %s to UART%d\n", portName, serialUartIndex); + } else { + fprintf(stderr, "[SERIALPROXY] Using proxy flight controller on %s\n", portName); + } +} + +void serialProxyStart(void) +{ + started = true; +} + +void serialProxyClose(void) +{ + if (connected) { + connected = false; +#if defined(__CYGWIN__) + CloseHandle(hSerial); +#else + close_serial(); +#endif + started = false; + nextProxyRequestTimeout = 0; + nextProxyRequestMin = 0; + nextProxyRequestRssi = 0; + lastWarning = 0; + lastVisit = 0; + } +} + +static bool canOutputWarning(void) +{ + if ( millis() > lastWarning ) { + lastWarning = millis() + 5000; + return true; + } + return false; +} + +int serialProxyReadData(unsigned char *buffer, unsigned int nbChar) +{ + if (!connected) return 0; + +#if defined(__CYGWIN__) + COMSTAT status; + DWORD errors; + DWORD bytesRead; + + ClearCommError(hSerial, &errors, &status); + if (status.cbInQue > 0) { + unsigned int toRead = (status.cbInQue > nbChar) ? nbChar : status.cbInQue; + if (ReadFile(hSerial, buffer, toRead, &bytesRead, NULL) && (bytesRead != 0)) { + return bytesRead; + } + } + return 0; +#else + if (nbChar == 0) return 0; + int bytesRead = read(fd, buffer, nbChar); + return bytesRead; +#endif +} + +bool serialProxyWriteData(unsigned char *buffer, unsigned int nbChar) +{ + if (!connected) return false; + +#if defined(__CYGWIN__) + COMSTAT status; + DWORD errors; + DWORD bytesSent; + if (!WriteFile(hSerial, (void *)buffer, nbChar, &bytesSent, 0)) { + ClearCommError(hSerial, &errors, &status); + if ( canOutputWarning() ) { + fprintf(stderr, "[SERIALPROXY] ERROR: Can not write to serial port\n"); + } + return false; + } + if ( bytesSent != nbChar ) { + if ( canOutputWarning() ) { + fprintf(stderr, "[SERIALPROXY] ERROR: Can not write to serial port\n"); + } + } +#else + ssize_t l = write(fd, buffer, nbChar); + if ( l != (ssize_t)nbChar ) { + if ( canOutputWarning() ) { + fprintf(stderr, "[SERIALPROXY] ERROR: Can not write to serial port\n"); + } + return false; + } +#endif + return true; +} + +bool serialProxyIsConnected(void) +{ + return connected; +} + +static void mspSendCommand(int cmd, unsigned char *data, int dataLen) +{ + uint8_t msgBuf[MAX_MSP_MESSAGE] = { '$', 'X', '<' }; + int msgLen = 3; + + mspHeaderV2_t *hdrV2 = (mspHeaderV2_t *)&msgBuf[msgLen]; + hdrV2->flags = 0; + hdrV2->cmd = cmd; + hdrV2->size = dataLen; + msgLen += sizeof(mspHeaderV2_t); + + for ( int i = 0; i < dataLen; i++ ) { + msgBuf[msgLen++] = data[i]; + } + + uint8_t crc = crc8_dvb_s2_update(0, (uint8_t *)hdrV2, sizeof(mspHeaderV2_t)); + crc = crc8_dvb_s2_update(crc, data, dataLen); + msgBuf[msgLen] = crc; + msgLen++; + + serialProxyWriteData((unsigned char *)&msgBuf, msgLen); +} + +static void mspRequestChannels(void) +{ + mspSendCommand(MSP_RC, NULL, 0); +} + +static void mspRequestRssi(void) +{ + mspSendCommand(MSP_ANALOG, NULL, 0); +} + +static void requestRXConfigState(void) +{ + mspSendCommand(MSP_RX_CONFIG, NULL, 0); + rxConfigState = RXC_RQ; + fprintf(stderr, "[SERIALPROXY] Requesting RX config from proxy FC...\n"); +} + +static void processMessage(void) +{ + if ( code == MSP_RC ) { + if ( reqCount > 0 ) reqCount--; + int count = message_length_received / 2; + if ( count <= MAX_SUPPORTED_RC_CHANNEL_COUNT) { + uint16_t *channels = (uint16_t *)(&message_buffer[0]); + //AETR => AERT + uint v = channels[2]; + channels[2] = channels[3]; + channels[3] = v; + if ( rssi > 0 ) { + rxSimSetChannelValue(channels, count); + } + } + } else if ( code == MSP_ANALOG ) { + if ( reqCount > 0 ) reqCount--; + if ( message_length_received >= 7 ) { + rssi = *((uint16_t *)(&message_buffer[3])); + rxSimSetRssi( rssi ); + } + } else if ( code == MSP_RX_CONFIG ) { + memcpy( &(rxConfigBuffer[0]), &(message_buffer[0]), RX_CONFIG_SIZE ); + *((uint16_t *) & (rxConfigBuffer[1])) = 2500; //maxcheck + *((uint16_t *) & (rxConfigBuffer[5])) = 500; //mincheck + + mspSendCommand( MSP_SET_RX_CONFIG, rxConfigBuffer, RX_CONFIG_SIZE ); + rxConfigState = RXC_DONE; + fprintf(stderr, "[SERIALPROXY] Setting RX config on proxy FC...\n"); + } +} + +static void decodeProxyMessages(unsigned char *data, int len) +{ + for (int i = 0; i < len; i++) { + switch (decoderState) { + case DS_IDLE: // sync char 1 + if (data[i] == SYM_BEGIN) { + decoderState = DS_PROTO_IDENTIFIER; + } + break; + + case DS_PROTO_IDENTIFIER: // sync char 2 + switch (data[i]) { + case SYM_PROTO_V1: + decoderState = DS_DIRECTION_V1; + break; + case SYM_PROTO_V2: + decoderState = DS_DIRECTION_V2; + break; + default: + //unknown protocol + decoderState = DS_IDLE; + } + break; + + case DS_DIRECTION_V1: // direction (should be >) + + case DS_DIRECTION_V2: + unsupported = 0; + switch (data[i]) { + case SYM_FROM_MWC: + message_direction = 1; + break; + case SYM_TO_MWC: + message_direction = 0; + break; + case SYM_UNSUPPORTED: + unsupported = 1; + break; + } + decoderState = decoderState == DS_DIRECTION_V1 ? DS_PAYLOAD_LENGTH_V1 : DS_FLAG_V2; + break; + + case DS_FLAG_V2: + // Ignored for now + decoderState = DS_CODE_V2_LOW; + break; + + case DS_PAYLOAD_LENGTH_V1: + message_length_expected = data[i]; + + if (message_length_expected == JUMBO_FRAME_MIN_SIZE) { + decoderState = DS_CODE_JUMBO_V1; + } else { + message_length_received = 0; + decoderState = DS_CODE_V1; + } + break; + + case DS_PAYLOAD_LENGTH_V2_LOW: + message_length_expected = data[i]; + decoderState = DS_PAYLOAD_LENGTH_V2_HIGH; + break; + + case DS_PAYLOAD_LENGTH_V2_HIGH: + message_length_expected |= data[i] << 8; + message_length_received = 0; + if (message_length_expected <= MAX_MSP_MESSAGE) { + decoderState = message_length_expected > 0 ? DS_PAYLOAD_V2 : DS_CHECKSUM_V2; + } else { + //too large payload + decoderState = DS_IDLE; + } + break; + + case DS_CODE_V1: + case DS_CODE_JUMBO_V1: + code = data[i]; + if (message_length_expected > 0) { + // process payload + if (decoderState == DS_CODE_JUMBO_V1) { + decoderState = DS_PAYLOAD_LENGTH_JUMBO_LOW; + } else { + decoderState = DS_PAYLOAD_V1; + } + } else { + // no payload + decoderState = DS_CHECKSUM_V1; + } + break; + + case DS_CODE_V2_LOW: + code = data[i]; + decoderState = DS_CODE_V2_HIGH; + break; + + case DS_CODE_V2_HIGH: + code |= data[i] << 8; + decoderState = DS_PAYLOAD_LENGTH_V2_LOW; + break; + + case DS_PAYLOAD_LENGTH_JUMBO_LOW: + message_length_expected = data[i]; + decoderState = DS_PAYLOAD_LENGTH_JUMBO_HIGH; + break; + + case DS_PAYLOAD_LENGTH_JUMBO_HIGH: + message_length_expected |= data[i] << 8; + message_length_received = 0; + decoderState = DS_PAYLOAD_V1; + break; + + case DS_PAYLOAD_V1: + case DS_PAYLOAD_V2: + message_buffer[message_length_received] = data[i]; + message_length_received++; + + if (message_length_received >= message_length_expected) { + decoderState = decoderState == DS_PAYLOAD_V1 ? DS_CHECKSUM_V1 : DS_CHECKSUM_V2; + } + break; + + case DS_CHECKSUM_V1: + if (message_length_expected >= JUMBO_FRAME_MIN_SIZE) { + message_checksum = JUMBO_FRAME_MIN_SIZE; + } else { + message_checksum = message_length_expected; + } + message_checksum ^= code; + if (message_length_expected >= JUMBO_FRAME_MIN_SIZE) { + message_checksum ^= message_length_expected & 0xFF; + message_checksum ^= (message_length_expected & 0xFF00) >> 8; + } + for (int ii = 0; ii < message_length_received; ii++) { + message_checksum ^= message_buffer[ii]; + } + if (message_checksum == data[i]) { + processMessage(); + } + decoderState = DS_IDLE; + break; + + case DS_CHECKSUM_V2: + message_checksum = 0; + message_checksum = crc8_dvb_s2(message_checksum, 0); // flag + message_checksum = crc8_dvb_s2(message_checksum, code & 0xFF); + message_checksum = crc8_dvb_s2(message_checksum, (code & 0xFF00) >> 8); + message_checksum = crc8_dvb_s2(message_checksum, message_length_expected & 0xFF); + message_checksum = crc8_dvb_s2(message_checksum, (message_length_expected & 0xFF00) >> 8); + for (int ii = 0; ii < message_length_received; ii++) { + message_checksum = crc8_dvb_s2(message_checksum, message_buffer[ii]); + } + if (message_checksum == data[i]) { + processMessage(); + } + decoderState = DS_IDLE; + break; + + default: + break; + } + } +} + +void serialProxyProcess(void) +{ + + if (!started) return; + if (!connected) return; + + if ((millis() - lastVisit) > 500) { + if ( lastVisit > 0 ) { + fprintf(stderr, "timeout=%dms\n", millis() - lastVisit); + } + } + lastVisit = millis(); + + if ( serialFCProxy ) { + //first we have to change FC min_check and max_check thresholds to avoid activating stick commands on proxy FC + if ( rxConfigState == RXC_IDLE ) { + requestRXConfigState(); + } else if ( rxConfigState == RXC_DONE ) { + if ( (nextProxyRequestTimeout <= millis()) || ((reqCount == 0) && (nextProxyRequestMin <= millis()))) { + nextProxyRequestTimeout = millis() + FC_PROXY_REQUEST_PERIOD_TIMEOUT_MS; + nextProxyRequestMin = millis() + FC_PROXY_REQUEST_PERIOD_MIN_MS; + mspRequestChannels(); + reqCount++; + } + + if ( nextProxyRequestRssi <= millis()) { + nextProxyRequestRssi = millis() + FC_PROXY_REQUEST_PERIOD_RSSI_MS; + mspRequestRssi(); + reqCount++; + } + } + + unsigned char buf[SERIAL_BUFFER_SIZE]; + int count = serialProxyReadData(buf, SERIAL_BUFFER_SIZE); + if (count == 0) return; + decodeProxyMessages(buf, count); + + } else { + + if ( serialUartIndex == -1 ) return; + unsigned char buf[SERIAL_BUFFER_SIZE]; + uint32_t avail = tcpRXBytesFree(serialUartIndex - 1); + if ( avail == 0 ) return; + if (avail > SERIAL_BUFFER_SIZE) avail = SERIAL_BUFFER_SIZE; + + int count = serialProxyReadData(buf, avail); + if (count == 0) return; + + tcpReceiveBytesEx( serialUartIndex - 1, buf, count); + } + +} +#endif diff --git a/src/main/target/SITL/serial_proxy.h b/src/main/target/SITL/serial_proxy.h new file mode 100644 index 00000000000..5cb97516399 --- /dev/null +++ b/src/main/target/SITL/serial_proxy.h @@ -0,0 +1,64 @@ +/* + * This file is part of INAV Project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * Alternatively, the contents of this file may be used under the terms + * of the GNU General Public License Version 3, as described below: + * + * This file is free software: you may copy, redistribute 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. + * + * This file 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 this program. If not, see http://www.gnu.org/licenses/. + */ + + +#include +#include +#include + +#include + +#if defined(SITL_BUILD) + +typedef enum +{ + OPT_SERIAL_STOP_BITS_ONE, + OPT_SERIAL_STOP_BITS_TWO, + OPT_SERIAL_STOP_BITS_INVALID +} OptSerialStopBits_e; + +typedef enum +{ + OPT_SERIAL_PARITY_EVEN, + OPT_SERIAL_PARITY_NONE, + OPT_SERIAL_PARITY_ODD, + OPT_SERIAL_PARITY_INVALID +} OptSerialParity_e; + + +extern int serialUartIndex; ///1 for UART1 +extern char serialPort[64]; +extern int serialBaudRate; +extern OptSerialStopBits_e serialStopBits; +extern OptSerialParity_e serialParity; +extern bool serialFCProxy; + +extern void serialProxyInit(void); +extern void serialProxyStart(void); +extern void serialProxyProcess(void); +extern void serialProxyClose(void); +extern bool serialProxyIsConnected(void); +extern bool serialProxyWriteData(unsigned char *buffer, unsigned int nbChar); + +#endif \ No newline at end of file diff --git a/src/main/target/SITL/target.c b/src/main/target/SITL/target.c index e8861eec56d..e473c636981 100644 --- a/src/main/target/SITL/target.c +++ b/src/main/target/SITL/target.c @@ -56,6 +56,8 @@ #include "target/SITL/sim/realFlight.h" #include "target/SITL/sim/xplane.h" +#include "target/SITL/serial_proxy.h" + // More dummys const int timerHardwareCount = 0; timerHardware_t timerHardware[1]; @@ -170,19 +172,47 @@ bool parseMapping(char* mapStr) return true; } +OptSerialStopBits_e parseStopBits(const char* optarg){ + if ( strcmp(optarg, "One") == 0 ) { + return OPT_SERIAL_STOP_BITS_ONE; + } else if ( strcmp(optarg, "Two") == 0 ) { + return OPT_SERIAL_STOP_BITS_TWO; + } else { + return OPT_SERIAL_STOP_BITS_INVALID; + } +} + +OptSerialParity_e parseParity(const char* optarg){ + if ( strcmp(optarg, "Even") == 0 ) { + return OPT_SERIAL_PARITY_EVEN; + } else if ( strcmp(optarg, "None") == 0 ) { + return OPT_SERIAL_PARITY_NONE; + } else if ( strcmp(optarg, "Odd") == 0 ) { + return OPT_SERIAL_PARITY_ODD; + } else { + return OPT_SERIAL_PARITY_INVALID; + } +} + void printCmdLineOptions(void) { printVersion(); fprintf(stderr, "Avaiable options:\n"); - fprintf(stderr, "--path=[path] Path and filename of eeprom.bin. If not specified 'eeprom.bin' in program directory is used.\n"); - fprintf(stderr, "--sim=[rf|xp] Simulator interface: rf = RealFligt, xp = XPlane. Example: --sim=rf\n"); - fprintf(stderr, "--simip=[ip] IP-Address oft the simulator host. If not specified localhost (127.0.0.1) is used.\n"); - fprintf(stderr, "--simport=[port] Port oft the simulator host.\n"); - fprintf(stderr, "--useimu Use IMU sensor data from the simulator instead of using attitude data from the simulator directly (experimental, not recommended).\n"); - fprintf(stderr, "--chanmap=[mapstring] Channel mapping. Maps INAVs motor and servo PWM outputs to the virtual receiver output in the simulator.\n"); - fprintf(stderr, " The mapstring has the following format: M(otor)|S(servo)-,... All numbers must have two digits\n"); - fprintf(stderr, " For example: Map motor 1 to virtal receiver output 1, servo 1 to output 2 and servo 2 to output 3:\n"); - fprintf(stderr, " --chanmap=M01-01,S01-02,S02-03\n"); + fprintf(stderr, "--path=[path] Path and filename of eeprom.bin. If not specified 'eeprom.bin' in program directory is used.\n"); + fprintf(stderr, "--sim=[rf|xp] Simulator interface: rf = RealFligt, xp = XPlane. Example: --sim=rf\n"); + fprintf(stderr, "--simip=[ip] IP-Address oft the simulator host. If not specified localhost (127.0.0.1) is used.\n"); + fprintf(stderr, "--simport=[port] Port oft the simulator host.\n"); + fprintf(stderr, "--useimu Use IMU sensor data from the simulator instead of using attitude data from the simulator directly (experimental, not recommended).\n"); + fprintf(stderr, "--serialuart=[uart] UART number on which serial receiver is configured in SITL, f.e. 3 for UART3\n"); + fprintf(stderr, "--serialport=[serialport] Host's serial port to which serial receiver/proxy FC is connected, f.e. COM3, /dev/ttyACM3\n"); + fprintf(stderr, "--baudrate=[baudrate] Serial receiver baudrate (default: 115200).\n"); + fprintf(stderr, "--stopbits=[None|One|Two] Serial receiver stopbits (default: One).\n"); + fprintf(stderr, "--parity=[Even|None|Odd] Serial receiver parity (default: None).\n"); + fprintf(stderr, "--fcproxy Use inav/betaflight FC as a proxy for serial receiver.\n"); + fprintf(stderr, "--chanmap=[mapstring] Channel mapping. Maps INAVs motor and servo PWM outputs to the virtual receiver output in the simulator.\n"); + fprintf(stderr, " The mapstring has the following format: M(otor)|S(servo)-,... All numbers must have two digits\n"); + fprintf(stderr, " For example: Map motor 1 to virtal receiver output 1, servo 1 to output 2 and servo 2 to output 3:\n"); + fprintf(stderr, " --chanmap=M01-01,S01-02,S02-03\n"); } void parseArguments(int argc, char *argv[]) @@ -202,7 +232,13 @@ void parseArguments(int argc, char *argv[]) {"simport", required_argument, 0, 'p'}, {"help", no_argument, 0, 'h'}, {"path", required_argument, 0, 'e'}, - {"version", no_argument, 0, 'v'}, + {"version", no_argument, 0, 'v'}, + {"serialuart", required_argument, 0, '0'}, + {"serialport", required_argument, 0, '1'}, + {"baudrate", required_argument, 0, '2'}, + {"stopbits", required_argument, 0, '3'}, + {"parity", required_argument, 0, '4'}, + {"fcproxy", no_argument, 0, '5'}, {NULL, 0, NULL, 0} }; @@ -242,10 +278,54 @@ void parseArguments(int argc, char *argv[]) fprintf(stderr, "[EEPROM] Invalid path, using eeprom file in program directory\n."); } break; - case 'v': - printVersion(); - exit(0); - default: + case 'v': + printVersion(); + exit(0); + case '0': + serialUartIndex = atoi(optarg); + if ( (serialUartIndex<1) || (serialUartIndex>8) ) { + fprintf(stderr, "[serialuart] Invalid argument\n."); + exit(0); + } + break; + case '1': + if ( (strlen(optarg)<1) || (strlen(optarg)>63) ) { + fprintf(stderr, "[serialport] Invalid argument\n."); + exit(0); + } else { + strcpy( serialPort, optarg ); + } + break; + case '2': + serialBaudRate = atoi(optarg); + if ( serialBaudRate < 1200 ) + { + fprintf(stderr, "[baudrate] Invalid argument\n."); + exit(0); + } + break; + case '3': + serialStopBits = parseStopBits(optarg); + if ( serialStopBits == OPT_SERIAL_STOP_BITS_INVALID ) + { + fprintf(stderr, "[stopbits] Invalid argument\n."); + exit(0); + } + break; + + case '4': + serialParity = parseParity(optarg); + if ( serialParity== OPT_SERIAL_PARITY_INVALID ) + { + fprintf(stderr, "[parity] Invalid argument\n."); + exit(0); + } + break; + case '5': + serialFCProxy = true; + break; + + default: printCmdLineOptions(); exit(0); } @@ -304,6 +384,7 @@ void systemReset(void) #else closefrom(3); #endif + serialProxyClose(); execvp(c_argv[0], c_argv); // restart } From f3f0397e07003eb3dc510f23e27fdd07192a2fdd Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Mon, 29 Apr 2024 15:02:20 +0200 Subject: [PATCH 217/241] Revert enforcing mode on TIM3 --- src/main/target/MAMBAF405_2022A/config.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/target/MAMBAF405_2022A/config.c b/src/main/target/MAMBAF405_2022A/config.c index ba3a5344c20..d632230c240 100644 --- a/src/main/target/MAMBAF405_2022A/config.c +++ b/src/main/target/MAMBAF405_2022A/config.c @@ -57,7 +57,4 @@ void targetConfiguration(void) serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART4)].functionMask = FUNCTION_MSP; serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART4)].msp_baudrateIndex = BAUD_115200; - - // To improve backwards compatibility with INAV versions 6.x and older - timerOverridesMutable(timer2id(TIM3))->outputMode = OUTPUT_MODE_MOTORS; } From ab7ab945a2f1b45578ff54baab1e3256b7310eff Mon Sep 17 00:00:00 2001 From: Marcelo Bezerra <23555060+mmosca@users.noreply.github.com> Date: Mon, 29 Apr 2024 17:37:25 +0200 Subject: [PATCH 218/241] Looks like inav never had the pins for the NANO variant correct. --- src/main/target/FLYWOOF745/target.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/main/target/FLYWOOF745/target.c b/src/main/target/FLYWOOF745/target.c index a82a708f51a..04c083ac94f 100644 --- a/src/main/target/FLYWOOF745/target.c +++ b/src/main/target/FLYWOOF745/target.c @@ -30,17 +30,26 @@ #include "drivers/pinio.h" timerHardware_t timerHardware[] = { - // DEF_TIM(TIM1, CH3, PE13, TIM_USE_PPM, 0, 1), // PPM, DMA2_ST6 +// DEF_TIM(TIM1, CH3, PE13, TIM_USE_PPM, 0, 1), // PPM, +// DMA2_ST6 - DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 0), // M1 , DMA1_ST2 - DEF_TIM(TIM8, CH4, PC9, TIM_USE_OUTPUT_AUTO, 0, 0), // M2 , DMA2_ST7 - DEF_TIM(TIM3, CH3, PB0, TIM_USE_OUTPUT_AUTO, 0, 0), // M3 , DMA1_ST7 - DEF_TIM(TIM1, CH2, PE11, TIM_USE_OUTPUT_AUTO, 0, 1), // M4 , DMA2_ST4 - DEF_TIM(TIM1, CH1, PE9, TIM_USE_OUTPUT_AUTO, 0, 2), // M5 , DMA2_ST2 - DEF_TIM(TIM5, CH4, PA3, TIM_USE_OUTPUT_AUTO, 0, 0), // M6 , DMA1_ST1 - DEF_TIM(TIM3, CH1, PB4, TIM_USE_OUTPUT_AUTO, 0, 0), // M7 , DMA1_ST4 - DEF_TIM(TIM3, CH2, PB5, TIM_USE_OUTPUT_AUTO, 0, 0), // M8 , DMA1_ST5 - DEF_TIM(TIM4, CH1, PD12, TIM_USE_LED, 0, 0), // LED_STRIP, DMA1_ST0 +#ifdef FLYWOOF745 + DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 0), // M1 , DMA1_ST2 + DEF_TIM(TIM8, CH4, PC9, TIM_USE_OUTPUT_AUTO, 0, 0), // M2 , DMA2_ST7 + DEF_TIM(TIM3, CH3, PB0, TIM_USE_OUTPUT_AUTO, 0, 0), // M3 , DMA1_ST7 + DEF_TIM(TIM1, CH2, PE11, TIM_USE_OUTPUT_AUTO, 0, 1), // M4 , DMA2_ST4 + DEF_TIM(TIM1, CH1, PE9, TIM_USE_OUTPUT_AUTO, 0, 2), // M5 , DMA2_ST2 +#else /* FLYWOOF745NANO */ + DEF_TIM(TIM3, CH3, PB0, TIM_USE_OUTPUT_AUTO, 0, 0), // M1 , DMA1_ST7 + DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 0), // M2 , DMA1_ST2 + DEF_TIM(TIM1, CH1, PE9, TIM_USE_OUTPUT_AUTO, 0, 2), // M3 , DMA2_ST2 + DEF_TIM(TIM1, CH2, PE11, TIM_USE_OUTPUT_AUTO, 0, 1), // M4 , DMA2_ST4 + DEF_TIM(TIM8, CH4, PC9, TIM_USE_OUTPUT_AUTO, 0, 0), // M5 , DMA2_ST7 +#endif + DEF_TIM(TIM5, CH4, PA3, TIM_USE_OUTPUT_AUTO, 0, 0), // M6 , DMA1_ST1 + DEF_TIM(TIM3, CH1, PB4, TIM_USE_OUTPUT_AUTO, 0, 0), // M7 , DMA1_ST4 + DEF_TIM(TIM3, CH2, PB5, TIM_USE_OUTPUT_AUTO, 0, 0), // M8 , DMA1_ST5 + DEF_TIM(TIM4, CH1, PD12, TIM_USE_LED, 0, 0), // LED_STRIP, DMA1_ST0 }; const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]); From 72b5fab0cc7977ad7662690d7bb4f306fe2ba36f Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Mon, 29 Apr 2024 15:02:20 +0200 Subject: [PATCH 219/241] Revert enforcing mode on TIM3 --- src/main/target/MAMBAF405_2022A/config.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/target/MAMBAF405_2022A/config.c b/src/main/target/MAMBAF405_2022A/config.c index ba3a5344c20..d632230c240 100644 --- a/src/main/target/MAMBAF405_2022A/config.c +++ b/src/main/target/MAMBAF405_2022A/config.c @@ -57,7 +57,4 @@ void targetConfiguration(void) serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART4)].functionMask = FUNCTION_MSP; serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART4)].msp_baudrateIndex = BAUD_115200; - - // To improve backwards compatibility with INAV versions 6.x and older - timerOverridesMutable(timer2id(TIM3))->outputMode = OUTPUT_MODE_MOTORS; } From 0bf3d3c3c421c0759ab97f14567361688b2924db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Spychalski?= Date: Mon, 29 Apr 2024 19:34:18 +0200 Subject: [PATCH 220/241] Merge pull request #9990 from iNavFlight/mmosca-flywoof745-fixes Match F745 and F745NANO motor pins to BF target --- src/main/target/FLYWOOF745/target.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/main/target/FLYWOOF745/target.c b/src/main/target/FLYWOOF745/target.c index a82a708f51a..04c083ac94f 100644 --- a/src/main/target/FLYWOOF745/target.c +++ b/src/main/target/FLYWOOF745/target.c @@ -30,17 +30,26 @@ #include "drivers/pinio.h" timerHardware_t timerHardware[] = { - // DEF_TIM(TIM1, CH3, PE13, TIM_USE_PPM, 0, 1), // PPM, DMA2_ST6 +// DEF_TIM(TIM1, CH3, PE13, TIM_USE_PPM, 0, 1), // PPM, +// DMA2_ST6 - DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 0), // M1 , DMA1_ST2 - DEF_TIM(TIM8, CH4, PC9, TIM_USE_OUTPUT_AUTO, 0, 0), // M2 , DMA2_ST7 - DEF_TIM(TIM3, CH3, PB0, TIM_USE_OUTPUT_AUTO, 0, 0), // M3 , DMA1_ST7 - DEF_TIM(TIM1, CH2, PE11, TIM_USE_OUTPUT_AUTO, 0, 1), // M4 , DMA2_ST4 - DEF_TIM(TIM1, CH1, PE9, TIM_USE_OUTPUT_AUTO, 0, 2), // M5 , DMA2_ST2 - DEF_TIM(TIM5, CH4, PA3, TIM_USE_OUTPUT_AUTO, 0, 0), // M6 , DMA1_ST1 - DEF_TIM(TIM3, CH1, PB4, TIM_USE_OUTPUT_AUTO, 0, 0), // M7 , DMA1_ST4 - DEF_TIM(TIM3, CH2, PB5, TIM_USE_OUTPUT_AUTO, 0, 0), // M8 , DMA1_ST5 - DEF_TIM(TIM4, CH1, PD12, TIM_USE_LED, 0, 0), // LED_STRIP, DMA1_ST0 +#ifdef FLYWOOF745 + DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 0), // M1 , DMA1_ST2 + DEF_TIM(TIM8, CH4, PC9, TIM_USE_OUTPUT_AUTO, 0, 0), // M2 , DMA2_ST7 + DEF_TIM(TIM3, CH3, PB0, TIM_USE_OUTPUT_AUTO, 0, 0), // M3 , DMA1_ST7 + DEF_TIM(TIM1, CH2, PE11, TIM_USE_OUTPUT_AUTO, 0, 1), // M4 , DMA2_ST4 + DEF_TIM(TIM1, CH1, PE9, TIM_USE_OUTPUT_AUTO, 0, 2), // M5 , DMA2_ST2 +#else /* FLYWOOF745NANO */ + DEF_TIM(TIM3, CH3, PB0, TIM_USE_OUTPUT_AUTO, 0, 0), // M1 , DMA1_ST7 + DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 0), // M2 , DMA1_ST2 + DEF_TIM(TIM1, CH1, PE9, TIM_USE_OUTPUT_AUTO, 0, 2), // M3 , DMA2_ST2 + DEF_TIM(TIM1, CH2, PE11, TIM_USE_OUTPUT_AUTO, 0, 1), // M4 , DMA2_ST4 + DEF_TIM(TIM8, CH4, PC9, TIM_USE_OUTPUT_AUTO, 0, 0), // M5 , DMA2_ST7 +#endif + DEF_TIM(TIM5, CH4, PA3, TIM_USE_OUTPUT_AUTO, 0, 0), // M6 , DMA1_ST1 + DEF_TIM(TIM3, CH1, PB4, TIM_USE_OUTPUT_AUTO, 0, 0), // M7 , DMA1_ST4 + DEF_TIM(TIM3, CH2, PB5, TIM_USE_OUTPUT_AUTO, 0, 0), // M8 , DMA1_ST5 + DEF_TIM(TIM4, CH1, PD12, TIM_USE_LED, 0, 0), // LED_STRIP, DMA1_ST0 }; const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]); From e0f383bae3752c436453b13779cf164396a8a5c5 Mon Sep 17 00:00:00 2001 From: Marcelo Bezerra <23555060+mmosca@users.noreply.github.com> Date: Mon, 29 Apr 2024 20:15:12 +0200 Subject: [PATCH 221/241] Revert to macos13 in release_7.1.1 to fix build without backporting all fixes --- .github/workflows/ci.yml | 312 +++++++++++++++++++-------------------- 1 file changed, 156 insertions(+), 156 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 09e27045ca6..94dc8bf344a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,156 +1,156 @@ -name: Build firmware -# Don't enable CI on push, just on PR. If you -# are working on the main repo and want to trigger -# a CI build submit a draft PR. -on: pull_request - -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - id: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] - - steps: - - uses: actions/checkout@v3 - - name: Install dependencies - run: sudo apt-get update && sudo apt-get -y install ninja-build - - name: Setup environment - env: - ACTIONS_ALLOW_UNSECURE_COMMANDS: true - run: | - # This is the hash of the commit for the PR - # when the action is triggered by PR, empty otherwise - COMMIT_ID=${{ github.event.pull_request.head.sha }} - # This is the hash of the commit when triggered by push - # but the hash of refs/pull//merge, which is different - # from the hash of the latest commit in the PR, that's - # why we try github.event.pull_request.head.sha first - COMMIT_ID=${COMMIT_ID:-${{ github.sha }}} - BUILD_SUFFIX=ci-$(date '+%Y%m%d')-$(git rev-parse --short ${COMMIT_ID}) - VERSION=$(grep project CMakeLists.txt|awk -F VERSION '{ gsub(/^[ \t]+|[ \t\)]+$/, "", $2); print $2 }') - echo "BUILD_SUFFIX=${BUILD_SUFFIX}" >> $GITHUB_ENV - echo "BUILD_NAME=inav-${VERSION}-${BUILD_SUFFIX}" >> $GITHUB_ENV - - uses: actions/cache@v1 - with: - path: downloads - key: ${{ runner.os }}-downloads-${{ hashFiles('CMakeLists.txt') }}-${{ hashFiles('**/cmake/*')}} - - name: Build targets (${{ matrix.id }}) - run: mkdir -p build && cd build && cmake -DWARNINGS_AS_ERRORS=ON -DCI_JOB_INDEX=${{ matrix.id }} -DCI_JOB_COUNT=${{ strategy.job-total }} -DBUILD_SUFFIX=${{ env.BUILD_SUFFIX }} -G Ninja .. && ninja ci - - name: Upload artifacts - uses: actions/upload-artifact@v3 - with: - name: ${{ env.BUILD_NAME }} - path: ./build/*.hex - - build-SITL-Linux: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Install dependencies - run: sudo apt-get update && sudo apt-get -y install ninja-build - - name: Setup environment - env: - ACTIONS_ALLOW_UNSECURE_COMMANDS: true - run: | - # This is the hash of the commit for the PR - # when the action is triggered by PR, empty otherwise - COMMIT_ID=${{ github.event.pull_request.head.sha }} - # This is the hash of the commit when triggered by push - # but the hash of refs/pull//merge, which is different - # from the hash of the latest commit in the PR, that's - # why we try github.event.pull_request.head.sha first - COMMIT_ID=${COMMIT_ID:-${{ github.sha }}} - BUILD_SUFFIX=ci-$(date '+%Y%m%d')-$(git rev-parse --short ${COMMIT_ID}) - VERSION=$(grep project CMakeLists.txt|awk -F VERSION '{ gsub(/^[ \t]+|[ \t\)]+$/, "", $2); print $2 }') - echo "BUILD_SUFFIX=${BUILD_SUFFIX}" >> $GITHUB_ENV - echo "BUILD_NAME=inav-${VERSION}-${BUILD_SUFFIX}" >> $GITHUB_ENV - - name: Build SITL - run: mkdir -p build_SITL && cd build_SITL && cmake -DSITL=ON -DWARNINGS_AS_ERRORS=ON -G Ninja .. && ninja - - name: Upload artifacts - uses: actions/upload-artifact@v3 - with: - name: ${{ env.BUILD_NAME }}_SITL - path: ./build_SITL/*_SITL - - build-SITL-Mac: - runs-on: macos-latest - steps: - - uses: actions/checkout@v3 - - name: Install dependencies - run: | - brew install cmake ninja ruby - - - name: Setup environment - env: - ACTIONS_ALLOW_UNSECURE_COMMANDS: true - run: | - # This is the hash of the commit for the PR - # when the action is triggered by PR, empty otherwise - COMMIT_ID=${{ github.event.pull_request.head.sha }} - # This is the hash of the commit when triggered by push - # but the hash of refs/pull//merge, which is different - # from the hash of the latest commit in the PR, that's - # why we try github.event.pull_request.head.sha first - COMMIT_ID=${COMMIT_ID:-${{ github.sha }}} - BUILD_SUFFIX=ci-$(date '+%Y%m%d')-$(git rev-parse --short ${COMMIT_ID}) - VERSION=$(grep project CMakeLists.txt|awk -F VERSION '{ gsub(/^[ \t]+|[ \t\)]+$/, "", $2); print $2 }') - echo "BUILD_SUFFIX=${BUILD_SUFFIX}" >> $GITHUB_ENV - echo "BUILD_NAME=inav-${VERSION}-${BUILD_SUFFIX}" >> $GITHUB_ENV - - name: Build SITL - run: | - mkdir -p build_SITL && cd build_SITL - cmake -DSITL=ON -DWARNINGS_AS_ERRORS=ON -G Ninja .. - ninja - - - name: Upload artifacts - uses: actions/upload-artifact@v3 - with: - name: ${{ env.BUILD_NAME }}_SITL-MacOS - path: ./build_SITL/*_SITL - - build-SITL-Windows: - runs-on: windows-latest - defaults: - run: - shell: C:\tools\cygwin\bin\bash.exe -o igncr '{0}' - steps: - - uses: actions/checkout@v3 - - name: Setup Cygwin - uses: egor-tensin/setup-cygwin@v4 - with: - packages: cmake ruby ninja gcc-g++ - - name: Setup environment - env: - ACTIONS_ALLOW_UNSECURE_COMMANDS: true - run: | - # This is the hash of the commit for the PR - # when the action is triggered by PR, empty otherwise - COMMIT_ID=${{ github.event.pull_request.head.sha }} - # This is the hash of the commit when triggered by push - # but the hash of refs/pull//merge, which is different - # from the hash of the latest commit in the PR, that's - # why we try github.event.pull_request.head.sha first - COMMIT_ID=${COMMIT_ID:-${{ github.sha }}} - BUILD_SUFFIX=ci-$(date '+%Y%m%d')-$(git rev-parse --short ${COMMIT_ID}) - VERSION=$(grep project CMakeLists.txt|awk -F VERSION '{ gsub(/^[ \t]+|[ \t\)]+$/, "", $2); print $2 }') - echo "BUILD_SUFFIX=${BUILD_SUFFIX}" >> $GITHUB_ENV - echo "BUILD_NAME=inav-${VERSION}-${BUILD_SUFFIX}" >> $GITHUB_ENV - - name: Build SITL - run: mkdir -p build_SITL && cd build_SITL && cmake -DSITL=ON -DWARNINGS_AS_ERRORS=ON -G Ninja .. && ninja - - name: Upload artifacts - uses: actions/upload-artifact@v3 - with: - name: ${{ env.BUILD_NAME }}_SITL-WIN - path: ./build_SITL/*.exe - - - test: - needs: [build] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Install dependencies - run: sudo apt-get update && sudo apt-get -y install ninja-build - - name: Run Tests - run: mkdir -p build && cd build && cmake -DTOOLCHAIN=none -G Ninja .. && ninja check +name: Build firmware +# Don't enable CI on push, just on PR. If you +# are working on the main repo and want to trigger +# a CI build submit a draft PR. +on: pull_request + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + id: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + + steps: + - uses: actions/checkout@v3 + - name: Install dependencies + run: sudo apt-get update && sudo apt-get -y install ninja-build + - name: Setup environment + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: true + run: | + # This is the hash of the commit for the PR + # when the action is triggered by PR, empty otherwise + COMMIT_ID=${{ github.event.pull_request.head.sha }} + # This is the hash of the commit when triggered by push + # but the hash of refs/pull//merge, which is different + # from the hash of the latest commit in the PR, that's + # why we try github.event.pull_request.head.sha first + COMMIT_ID=${COMMIT_ID:-${{ github.sha }}} + BUILD_SUFFIX=ci-$(date '+%Y%m%d')-$(git rev-parse --short ${COMMIT_ID}) + VERSION=$(grep project CMakeLists.txt|awk -F VERSION '{ gsub(/^[ \t]+|[ \t\)]+$/, "", $2); print $2 }') + echo "BUILD_SUFFIX=${BUILD_SUFFIX}" >> $GITHUB_ENV + echo "BUILD_NAME=inav-${VERSION}-${BUILD_SUFFIX}" >> $GITHUB_ENV + - uses: actions/cache@v1 + with: + path: downloads + key: ${{ runner.os }}-downloads-${{ hashFiles('CMakeLists.txt') }}-${{ hashFiles('**/cmake/*')}} + - name: Build targets (${{ matrix.id }}) + run: mkdir -p build && cd build && cmake -DWARNINGS_AS_ERRORS=ON -DCI_JOB_INDEX=${{ matrix.id }} -DCI_JOB_COUNT=${{ strategy.job-total }} -DBUILD_SUFFIX=${{ env.BUILD_SUFFIX }} -G Ninja .. && ninja ci + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: ${{ env.BUILD_NAME }} + path: ./build/*.hex + + build-SITL-Linux: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Install dependencies + run: sudo apt-get update && sudo apt-get -y install ninja-build + - name: Setup environment + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: true + run: | + # This is the hash of the commit for the PR + # when the action is triggered by PR, empty otherwise + COMMIT_ID=${{ github.event.pull_request.head.sha }} + # This is the hash of the commit when triggered by push + # but the hash of refs/pull//merge, which is different + # from the hash of the latest commit in the PR, that's + # why we try github.event.pull_request.head.sha first + COMMIT_ID=${COMMIT_ID:-${{ github.sha }}} + BUILD_SUFFIX=ci-$(date '+%Y%m%d')-$(git rev-parse --short ${COMMIT_ID}) + VERSION=$(grep project CMakeLists.txt|awk -F VERSION '{ gsub(/^[ \t]+|[ \t\)]+$/, "", $2); print $2 }') + echo "BUILD_SUFFIX=${BUILD_SUFFIX}" >> $GITHUB_ENV + echo "BUILD_NAME=inav-${VERSION}-${BUILD_SUFFIX}" >> $GITHUB_ENV + - name: Build SITL + run: mkdir -p build_SITL && cd build_SITL && cmake -DSITL=ON -DWARNINGS_AS_ERRORS=ON -G Ninja .. && ninja + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: ${{ env.BUILD_NAME }}_SITL + path: ./build_SITL/*_SITL + + build-SITL-Mac: + runs-on: macos-13 + steps: + - uses: actions/checkout@v3 + - name: Install dependencies + run: | + brew install cmake ninja ruby + + - name: Setup environment + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: true + run: | + # This is the hash of the commit for the PR + # when the action is triggered by PR, empty otherwise + COMMIT_ID=${{ github.event.pull_request.head.sha }} + # This is the hash of the commit when triggered by push + # but the hash of refs/pull//merge, which is different + # from the hash of the latest commit in the PR, that's + # why we try github.event.pull_request.head.sha first + COMMIT_ID=${COMMIT_ID:-${{ github.sha }}} + BUILD_SUFFIX=ci-$(date '+%Y%m%d')-$(git rev-parse --short ${COMMIT_ID}) + VERSION=$(grep project CMakeLists.txt|awk -F VERSION '{ gsub(/^[ \t]+|[ \t\)]+$/, "", $2); print $2 }') + echo "BUILD_SUFFIX=${BUILD_SUFFIX}" >> $GITHUB_ENV + echo "BUILD_NAME=inav-${VERSION}-${BUILD_SUFFIX}" >> $GITHUB_ENV + - name: Build SITL + run: | + mkdir -p build_SITL && cd build_SITL + cmake -DSITL=ON -DWARNINGS_AS_ERRORS=ON -G Ninja .. + ninja + + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: ${{ env.BUILD_NAME }}_SITL-MacOS + path: ./build_SITL/*_SITL + + build-SITL-Windows: + runs-on: windows-latest + defaults: + run: + shell: C:\tools\cygwin\bin\bash.exe -o igncr '{0}' + steps: + - uses: actions/checkout@v3 + - name: Setup Cygwin + uses: egor-tensin/setup-cygwin@v4 + with: + packages: cmake ruby ninja gcc-g++ + - name: Setup environment + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: true + run: | + # This is the hash of the commit for the PR + # when the action is triggered by PR, empty otherwise + COMMIT_ID=${{ github.event.pull_request.head.sha }} + # This is the hash of the commit when triggered by push + # but the hash of refs/pull//merge, which is different + # from the hash of the latest commit in the PR, that's + # why we try github.event.pull_request.head.sha first + COMMIT_ID=${COMMIT_ID:-${{ github.sha }}} + BUILD_SUFFIX=ci-$(date '+%Y%m%d')-$(git rev-parse --short ${COMMIT_ID}) + VERSION=$(grep project CMakeLists.txt|awk -F VERSION '{ gsub(/^[ \t]+|[ \t\)]+$/, "", $2); print $2 }') + echo "BUILD_SUFFIX=${BUILD_SUFFIX}" >> $GITHUB_ENV + echo "BUILD_NAME=inav-${VERSION}-${BUILD_SUFFIX}" >> $GITHUB_ENV + - name: Build SITL + run: mkdir -p build_SITL && cd build_SITL && cmake -DSITL=ON -DWARNINGS_AS_ERRORS=ON -G Ninja .. && ninja + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: ${{ env.BUILD_NAME }}_SITL-WIN + path: ./build_SITL/*.exe + + + test: + needs: [build] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Install dependencies + run: sudo apt-get update && sudo apt-get -y install ninja-build + - name: Run Tests + run: mkdir -p build && cd build && cmake -DTOOLCHAIN=none -G Ninja .. && ninja check From 6669af879e7c5072f37c0e482aac7d0a31fda572 Mon Sep 17 00:00:00 2001 From: Marcelo Bezerra <23555060+mmosca@users.noreply.github.com> Date: Mon, 29 Apr 2024 20:17:11 +0200 Subject: [PATCH 222/241] back to unix line endings --- .github/workflows/ci.yml | 312 +++++++++++++++++++-------------------- 1 file changed, 156 insertions(+), 156 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 94dc8bf344a..6fddc02df85 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,156 +1,156 @@ -name: Build firmware -# Don't enable CI on push, just on PR. If you -# are working on the main repo and want to trigger -# a CI build submit a draft PR. -on: pull_request - -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - id: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] - - steps: - - uses: actions/checkout@v3 - - name: Install dependencies - run: sudo apt-get update && sudo apt-get -y install ninja-build - - name: Setup environment - env: - ACTIONS_ALLOW_UNSECURE_COMMANDS: true - run: | - # This is the hash of the commit for the PR - # when the action is triggered by PR, empty otherwise - COMMIT_ID=${{ github.event.pull_request.head.sha }} - # This is the hash of the commit when triggered by push - # but the hash of refs/pull//merge, which is different - # from the hash of the latest commit in the PR, that's - # why we try github.event.pull_request.head.sha first - COMMIT_ID=${COMMIT_ID:-${{ github.sha }}} - BUILD_SUFFIX=ci-$(date '+%Y%m%d')-$(git rev-parse --short ${COMMIT_ID}) - VERSION=$(grep project CMakeLists.txt|awk -F VERSION '{ gsub(/^[ \t]+|[ \t\)]+$/, "", $2); print $2 }') - echo "BUILD_SUFFIX=${BUILD_SUFFIX}" >> $GITHUB_ENV - echo "BUILD_NAME=inav-${VERSION}-${BUILD_SUFFIX}" >> $GITHUB_ENV - - uses: actions/cache@v1 - with: - path: downloads - key: ${{ runner.os }}-downloads-${{ hashFiles('CMakeLists.txt') }}-${{ hashFiles('**/cmake/*')}} - - name: Build targets (${{ matrix.id }}) - run: mkdir -p build && cd build && cmake -DWARNINGS_AS_ERRORS=ON -DCI_JOB_INDEX=${{ matrix.id }} -DCI_JOB_COUNT=${{ strategy.job-total }} -DBUILD_SUFFIX=${{ env.BUILD_SUFFIX }} -G Ninja .. && ninja ci - - name: Upload artifacts - uses: actions/upload-artifact@v3 - with: - name: ${{ env.BUILD_NAME }} - path: ./build/*.hex - - build-SITL-Linux: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Install dependencies - run: sudo apt-get update && sudo apt-get -y install ninja-build - - name: Setup environment - env: - ACTIONS_ALLOW_UNSECURE_COMMANDS: true - run: | - # This is the hash of the commit for the PR - # when the action is triggered by PR, empty otherwise - COMMIT_ID=${{ github.event.pull_request.head.sha }} - # This is the hash of the commit when triggered by push - # but the hash of refs/pull//merge, which is different - # from the hash of the latest commit in the PR, that's - # why we try github.event.pull_request.head.sha first - COMMIT_ID=${COMMIT_ID:-${{ github.sha }}} - BUILD_SUFFIX=ci-$(date '+%Y%m%d')-$(git rev-parse --short ${COMMIT_ID}) - VERSION=$(grep project CMakeLists.txt|awk -F VERSION '{ gsub(/^[ \t]+|[ \t\)]+$/, "", $2); print $2 }') - echo "BUILD_SUFFIX=${BUILD_SUFFIX}" >> $GITHUB_ENV - echo "BUILD_NAME=inav-${VERSION}-${BUILD_SUFFIX}" >> $GITHUB_ENV - - name: Build SITL - run: mkdir -p build_SITL && cd build_SITL && cmake -DSITL=ON -DWARNINGS_AS_ERRORS=ON -G Ninja .. && ninja - - name: Upload artifacts - uses: actions/upload-artifact@v3 - with: - name: ${{ env.BUILD_NAME }}_SITL - path: ./build_SITL/*_SITL - - build-SITL-Mac: - runs-on: macos-13 - steps: - - uses: actions/checkout@v3 - - name: Install dependencies - run: | - brew install cmake ninja ruby - - - name: Setup environment - env: - ACTIONS_ALLOW_UNSECURE_COMMANDS: true - run: | - # This is the hash of the commit for the PR - # when the action is triggered by PR, empty otherwise - COMMIT_ID=${{ github.event.pull_request.head.sha }} - # This is the hash of the commit when triggered by push - # but the hash of refs/pull//merge, which is different - # from the hash of the latest commit in the PR, that's - # why we try github.event.pull_request.head.sha first - COMMIT_ID=${COMMIT_ID:-${{ github.sha }}} - BUILD_SUFFIX=ci-$(date '+%Y%m%d')-$(git rev-parse --short ${COMMIT_ID}) - VERSION=$(grep project CMakeLists.txt|awk -F VERSION '{ gsub(/^[ \t]+|[ \t\)]+$/, "", $2); print $2 }') - echo "BUILD_SUFFIX=${BUILD_SUFFIX}" >> $GITHUB_ENV - echo "BUILD_NAME=inav-${VERSION}-${BUILD_SUFFIX}" >> $GITHUB_ENV - - name: Build SITL - run: | - mkdir -p build_SITL && cd build_SITL - cmake -DSITL=ON -DWARNINGS_AS_ERRORS=ON -G Ninja .. - ninja - - - name: Upload artifacts - uses: actions/upload-artifact@v3 - with: - name: ${{ env.BUILD_NAME }}_SITL-MacOS - path: ./build_SITL/*_SITL - - build-SITL-Windows: - runs-on: windows-latest - defaults: - run: - shell: C:\tools\cygwin\bin\bash.exe -o igncr '{0}' - steps: - - uses: actions/checkout@v3 - - name: Setup Cygwin - uses: egor-tensin/setup-cygwin@v4 - with: - packages: cmake ruby ninja gcc-g++ - - name: Setup environment - env: - ACTIONS_ALLOW_UNSECURE_COMMANDS: true - run: | - # This is the hash of the commit for the PR - # when the action is triggered by PR, empty otherwise - COMMIT_ID=${{ github.event.pull_request.head.sha }} - # This is the hash of the commit when triggered by push - # but the hash of refs/pull//merge, which is different - # from the hash of the latest commit in the PR, that's - # why we try github.event.pull_request.head.sha first - COMMIT_ID=${COMMIT_ID:-${{ github.sha }}} - BUILD_SUFFIX=ci-$(date '+%Y%m%d')-$(git rev-parse --short ${COMMIT_ID}) - VERSION=$(grep project CMakeLists.txt|awk -F VERSION '{ gsub(/^[ \t]+|[ \t\)]+$/, "", $2); print $2 }') - echo "BUILD_SUFFIX=${BUILD_SUFFIX}" >> $GITHUB_ENV - echo "BUILD_NAME=inav-${VERSION}-${BUILD_SUFFIX}" >> $GITHUB_ENV - - name: Build SITL - run: mkdir -p build_SITL && cd build_SITL && cmake -DSITL=ON -DWARNINGS_AS_ERRORS=ON -G Ninja .. && ninja - - name: Upload artifacts - uses: actions/upload-artifact@v3 - with: - name: ${{ env.BUILD_NAME }}_SITL-WIN - path: ./build_SITL/*.exe - - - test: - needs: [build] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Install dependencies - run: sudo apt-get update && sudo apt-get -y install ninja-build - - name: Run Tests - run: mkdir -p build && cd build && cmake -DTOOLCHAIN=none -G Ninja .. && ninja check +name: Build firmware +# Don't enable CI on push, just on PR. If you +# are working on the main repo and want to trigger +# a CI build submit a draft PR. +on: pull_request + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + id: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + + steps: + - uses: actions/checkout@v3 + - name: Install dependencies + run: sudo apt-get update && sudo apt-get -y install ninja-build + - name: Setup environment + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: true + run: | + # This is the hash of the commit for the PR + # when the action is triggered by PR, empty otherwise + COMMIT_ID=${{ github.event.pull_request.head.sha }} + # This is the hash of the commit when triggered by push + # but the hash of refs/pull//merge, which is different + # from the hash of the latest commit in the PR, that's + # why we try github.event.pull_request.head.sha first + COMMIT_ID=${COMMIT_ID:-${{ github.sha }}} + BUILD_SUFFIX=ci-$(date '+%Y%m%d')-$(git rev-parse --short ${COMMIT_ID}) + VERSION=$(grep project CMakeLists.txt|awk -F VERSION '{ gsub(/^[ \t]+|[ \t\)]+$/, "", $2); print $2 }') + echo "BUILD_SUFFIX=${BUILD_SUFFIX}" >> $GITHUB_ENV + echo "BUILD_NAME=inav-${VERSION}-${BUILD_SUFFIX}" >> $GITHUB_ENV + - uses: actions/cache@v1 + with: + path: downloads + key: ${{ runner.os }}-downloads-${{ hashFiles('CMakeLists.txt') }}-${{ hashFiles('**/cmake/*')}} + - name: Build targets (${{ matrix.id }}) + run: mkdir -p build && cd build && cmake -DWARNINGS_AS_ERRORS=ON -DCI_JOB_INDEX=${{ matrix.id }} -DCI_JOB_COUNT=${{ strategy.job-total }} -DBUILD_SUFFIX=${{ env.BUILD_SUFFIX }} -G Ninja .. && ninja ci + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: ${{ env.BUILD_NAME }} + path: ./build/*.hex + + build-SITL-Linux: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Install dependencies + run: sudo apt-get update && sudo apt-get -y install ninja-build + - name: Setup environment + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: true + run: | + # This is the hash of the commit for the PR + # when the action is triggered by PR, empty otherwise + COMMIT_ID=${{ github.event.pull_request.head.sha }} + # This is the hash of the commit when triggered by push + # but the hash of refs/pull//merge, which is different + # from the hash of the latest commit in the PR, that's + # why we try github.event.pull_request.head.sha first + COMMIT_ID=${COMMIT_ID:-${{ github.sha }}} + BUILD_SUFFIX=ci-$(date '+%Y%m%d')-$(git rev-parse --short ${COMMIT_ID}) + VERSION=$(grep project CMakeLists.txt|awk -F VERSION '{ gsub(/^[ \t]+|[ \t\)]+$/, "", $2); print $2 }') + echo "BUILD_SUFFIX=${BUILD_SUFFIX}" >> $GITHUB_ENV + echo "BUILD_NAME=inav-${VERSION}-${BUILD_SUFFIX}" >> $GITHUB_ENV + - name: Build SITL + run: mkdir -p build_SITL && cd build_SITL && cmake -DSITL=ON -DWARNINGS_AS_ERRORS=ON -G Ninja .. && ninja + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: ${{ env.BUILD_NAME }}_SITL + path: ./build_SITL/*_SITL + + build-SITL-Mac: + runs-on: macos-13 + steps: + - uses: actions/checkout@v3 + - name: Install dependencies + run: | + brew install cmake ninja ruby + + - name: Setup environment + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: true + run: | + # This is the hash of the commit for the PR + # when the action is triggered by PR, empty otherwise + COMMIT_ID=${{ github.event.pull_request.head.sha }} + # This is the hash of the commit when triggered by push + # but the hash of refs/pull//merge, which is different + # from the hash of the latest commit in the PR, that's + # why we try github.event.pull_request.head.sha first + COMMIT_ID=${COMMIT_ID:-${{ github.sha }}} + BUILD_SUFFIX=ci-$(date '+%Y%m%d')-$(git rev-parse --short ${COMMIT_ID}) + VERSION=$(grep project CMakeLists.txt|awk -F VERSION '{ gsub(/^[ \t]+|[ \t\)]+$/, "", $2); print $2 }') + echo "BUILD_SUFFIX=${BUILD_SUFFIX}" >> $GITHUB_ENV + echo "BUILD_NAME=inav-${VERSION}-${BUILD_SUFFIX}" >> $GITHUB_ENV + - name: Build SITL + run: | + mkdir -p build_SITL && cd build_SITL + cmake -DSITL=ON -DWARNINGS_AS_ERRORS=ON -G Ninja .. + ninja + + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: ${{ env.BUILD_NAME }}_SITL-MacOS + path: ./build_SITL/*_SITL + + build-SITL-Windows: + runs-on: windows-latest + defaults: + run: + shell: C:\tools\cygwin\bin\bash.exe -o igncr '{0}' + steps: + - uses: actions/checkout@v3 + - name: Setup Cygwin + uses: egor-tensin/setup-cygwin@v4 + with: + packages: cmake ruby ninja gcc-g++ + - name: Setup environment + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: true + run: | + # This is the hash of the commit for the PR + # when the action is triggered by PR, empty otherwise + COMMIT_ID=${{ github.event.pull_request.head.sha }} + # This is the hash of the commit when triggered by push + # but the hash of refs/pull//merge, which is different + # from the hash of the latest commit in the PR, that's + # why we try github.event.pull_request.head.sha first + COMMIT_ID=${COMMIT_ID:-${{ github.sha }}} + BUILD_SUFFIX=ci-$(date '+%Y%m%d')-$(git rev-parse --short ${COMMIT_ID}) + VERSION=$(grep project CMakeLists.txt|awk -F VERSION '{ gsub(/^[ \t]+|[ \t\)]+$/, "", $2); print $2 }') + echo "BUILD_SUFFIX=${BUILD_SUFFIX}" >> $GITHUB_ENV + echo "BUILD_NAME=inav-${VERSION}-${BUILD_SUFFIX}" >> $GITHUB_ENV + - name: Build SITL + run: mkdir -p build_SITL && cd build_SITL && cmake -DSITL=ON -DWARNINGS_AS_ERRORS=ON -G Ninja .. && ninja + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: ${{ env.BUILD_NAME }}_SITL-WIN + path: ./build_SITL/*.exe + + + test: + needs: [build] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Install dependencies + run: sudo apt-get update && sudo apt-get -y install ninja-build + - name: Run Tests + run: mkdir -p build && cd build && cmake -DTOOLCHAIN=none -G Ninja .. && ninja check From 59d9160597b4370fcf234e692d8f1b1fbf8b4c4d Mon Sep 17 00:00:00 2001 From: Marcelo Bezerra <23555060+mmosca@users.noreply.github.com> Date: Mon, 29 Apr 2024 20:17:55 +0200 Subject: [PATCH 223/241] Unix line endings --- src/main/target/TAKERF722SE/target.c | 96 +++---- src/main/target/TAKERF722SE/target.h | 372 +++++++++++++-------------- 2 files changed, 234 insertions(+), 234 deletions(-) diff --git a/src/main/target/TAKERF722SE/target.c b/src/main/target/TAKERF722SE/target.c index 247efb84e52..d67062a9fbc 100644 --- a/src/main/target/TAKERF722SE/target.c +++ b/src/main/target/TAKERF722SE/target.c @@ -1,48 +1,48 @@ -/* -* This file is part of INAV Project. -* -* INAV 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. -* -* INAV 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 INAV. If not, see . -*/ - -#include - -#include "platform.h" -#include "drivers/io.h" - -#include "drivers/dma.h" -#include "drivers/timer.h" -#include "drivers/timer_def.h" - - - - - -timerHardware_t timerHardware[] = { - - DEF_TIM(TIM3, CH1, PB4, TIM_USE_OUTPUT_AUTO, 0, 0), - DEF_TIM(TIM3, CH2, PB5, TIM_USE_OUTPUT_AUTO, 0, 0), - DEF_TIM(TIM3, CH3, PB0, TIM_USE_OUTPUT_AUTO, 0, 0), - DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 0), - - DEF_TIM(TIM4, CH1, PB6, TIM_USE_OUTPUT_AUTO, 0, 0), - DEF_TIM(TIM4, CH2, PB7, TIM_USE_OUTPUT_AUTO, 0, 0), - DEF_TIM(TIM8, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 0), - DEF_TIM(TIM8, CH4, PC9, TIM_USE_OUTPUT_AUTO, 0, 0), - - DEF_TIM(TIM1, CH1, PA8, TIM_USE_LED, 0, 0), -}; - -const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]); - - +/* +* This file is part of INAV Project. +* +* INAV 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. +* +* INAV 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 INAV. If not, see . +*/ + +#include + +#include "platform.h" +#include "drivers/io.h" + +#include "drivers/dma.h" +#include "drivers/timer.h" +#include "drivers/timer_def.h" + + + + + +timerHardware_t timerHardware[] = { + + DEF_TIM(TIM3, CH1, PB4, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM3, CH2, PB5, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM3, CH3, PB0, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 0), + + DEF_TIM(TIM4, CH1, PB6, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM4, CH2, PB7, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM8, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM8, CH4, PC9, TIM_USE_OUTPUT_AUTO, 0, 0), + + DEF_TIM(TIM1, CH1, PA8, TIM_USE_LED, 0, 0), +}; + +const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]); + + diff --git a/src/main/target/TAKERF722SE/target.h b/src/main/target/TAKERF722SE/target.h index 61ab442653d..817dc535f03 100644 --- a/src/main/target/TAKERF722SE/target.h +++ b/src/main/target/TAKERF722SE/target.h @@ -1,186 +1,186 @@ -/* - * This file is part of INAV Project. - * - * 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. - * - * INAV 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 INAV. If not, see . - */ - -#pragma once - -#define TARGET_BOARD_IDENTIFIER "GEPR" - -#define USBD_PRODUCT_STRING "TAKERF722SE" - -#define LED0 PC14 - - -// *************** BEEPER ************************ - -#define BEEPER PC13 -#define BEEPER_INVERTED - - -// *************** LEDSTRIP ************************ -#define USE_LED_STRIP -#define WS2811_PIN PA8 - - -// *************** UART ***************************** -#define USE_VCP - -#define USE_UART1 -#define UART1_TX_PIN PA9 -#define UART1_RX_PIN PA10 - -#define USE_UART2 -#define UART2_TX_PIN PA2 -#define UART2_RX_PIN PA3 - -#define USE_UART3 -#define UART3_TX_PIN PB10 -#define UART3_RX_PIN PB11 - -#define USE_UART4 -#define UART4_TX_PIN PA0 -#define UART4_RX_PIN PA1 - -#define USE_UART5 -#define UART5_TX_PIN PC12 -#define UART5_RX_PIN PD2 - -#define USE_UART6 -#define UART6_TX_PIN PC6 -#define UART6_RX_PIN PC7 - - -#define SERIAL_PORT_COUNT 7 - -#define DEFAULT_RX_TYPE RX_TYPE_SERIAL -#define SERIALRX_PROVIDER SERIALRX_SBUS -#define SERIALRX_UART SERIAL_PORT_USART2 - - -// *************** SPI Bus ********************** - -#define USE_SPI - -#define USE_SPI_DEVICE_1 -#define SPI1_SCK_PIN PA5 -#define SPI1_MISO_PIN PA6 -#define SPI1_MOSI_PIN PA7 - -#define USE_SPI_DEVICE_2 -#define SPI2_SCK_PIN PB13 -#define SPI2_MISO_PIN PB14 -#define SPI2_MOSI_PIN PB15 - -#define USE_SPI_DEVICE_3 -#define SPI3_SCK_PIN PC10 -#define SPI3_MISO_PIN PC11 -#define SPI3_MOSI_PIN PB2 -#define SPI3_SCK_AF GPIO_AF6_SPI3 -#define SPI3_MISO_AF GPIO_AF6_SPI3 -#define SPI3_MOSI_AF GPIO_AF7_SPI3 - - -// *************** Gyro & ACC ********************** - -#define USE_IMU_MPU6000 -#define IMU_MPU6000_ALIGN CW0_DEG -#define MPU6000_CS_PIN PA4 -#define MPU6000_SPI_BUS BUS_SPI1 - - -#define USE_IMU_ICM42605 -#define IMU_ICM42605_ALIGN CW0_DEG -#define ICM42605_CS_PIN PA4 -#define ICM42605_SPI_BUS BUS_SPI1 - -// *************** I2C/Baro/Mag ********************* -#define USE_I2C -#define USE_I2C_DEVICE_1 -#define I2C1_SCL PB8 -#define I2C1_SDA PB9 - - -//*************************************************** -#define USE_BARO -#define BARO_I2C_BUS BUS_I2C1 -#define USE_BARO_BMP280 -#define USE_BARO_DPS310 -#define USE_BARO_MS5611 - -#define USE_MAG -#define MAG_I2C_BUS BUS_I2C1 -#define USE_MAG_HMC5883 -#define USE_MAG_QMC5883 -#define USE_MAG_IST8310 -#define USE_MAG_IST8308 - -#define TEMPERATURE_I2C_BUS BUS_I2C1 - -#define PITOT_I2C_BUS BUS_I2C1 - -#define USE_RANGEFINDER -#define RANGEFINDER_I2C_BUS BUS_I2C1 -#define BNO055_I2C_BUS BUS_I2C1 - -// *************** FLASH ************************** - -#define USE_FLASHFS - -#define USE_FLASH_M25P16 -#define M25P16_CS_PIN PA15 -#define M25P16_SPI_BUS BUS_SPI3 - -#define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT - -// *************** OSD ***************************** - -#define USE_MAX7456 -#define MAX7456_SPI_BUS BUS_SPI2 -#define MAX7456_CS_PIN PB12 - -// *************** ADC ***************************** - -#define USE_ADC -#define ADC_INSTANCE ADC1 -#define ADC1_DMA_STREAM DMA2_Stream0 -#define ADC_CHANNEL_1_PIN PC3 -#define ADC_CHANNEL_2_PIN PC0 -#define ADC_CHANNEL_3_PIN PC2 - -#define VBAT_ADC_CHANNEL ADC_CHN_1 -#define RSSI_ADC_CHANNEL ADC_CHN_2 -#define CURRENT_METER_ADC_CHANNEL ADC_CHN_3 - - -#define DEFAULT_FEATURES (FEATURE_TX_PROF_SEL | FEATURE_CURRENT_METER | FEATURE_TELEMETRY | FEATURE_VBAT | FEATURE_OSD | FEATURE_BLACKBOX) - - - - -//************************************************** - -#define USE_SERIAL_4WAY_BLHELI_INTERFACE - -#define TARGET_IO_PORTA 0xffff -#define TARGET_IO_PORTB 0xffff -#define TARGET_IO_PORTC 0xffff -#define TARGET_IO_PORTD (BIT(2)) - - -#define MAX_PWM_OUTPUT_PORTS 8 - -#define USE_DSHOT -#define USE_ESC_SENSOR +/* + * This file is part of INAV Project. + * + * 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. + * + * INAV 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 INAV. If not, see . + */ + +#pragma once + +#define TARGET_BOARD_IDENTIFIER "GEPR" + +#define USBD_PRODUCT_STRING "TAKERF722SE" + +#define LED0 PC14 + + +// *************** BEEPER ************************ + +#define BEEPER PC13 +#define BEEPER_INVERTED + + +// *************** LEDSTRIP ************************ +#define USE_LED_STRIP +#define WS2811_PIN PA8 + + +// *************** UART ***************************** +#define USE_VCP + +#define USE_UART1 +#define UART1_TX_PIN PA9 +#define UART1_RX_PIN PA10 + +#define USE_UART2 +#define UART2_TX_PIN PA2 +#define UART2_RX_PIN PA3 + +#define USE_UART3 +#define UART3_TX_PIN PB10 +#define UART3_RX_PIN PB11 + +#define USE_UART4 +#define UART4_TX_PIN PA0 +#define UART4_RX_PIN PA1 + +#define USE_UART5 +#define UART5_TX_PIN PC12 +#define UART5_RX_PIN PD2 + +#define USE_UART6 +#define UART6_TX_PIN PC6 +#define UART6_RX_PIN PC7 + + +#define SERIAL_PORT_COUNT 7 + +#define DEFAULT_RX_TYPE RX_TYPE_SERIAL +#define SERIALRX_PROVIDER SERIALRX_SBUS +#define SERIALRX_UART SERIAL_PORT_USART2 + + +// *************** SPI Bus ********************** + +#define USE_SPI + +#define USE_SPI_DEVICE_1 +#define SPI1_SCK_PIN PA5 +#define SPI1_MISO_PIN PA6 +#define SPI1_MOSI_PIN PA7 + +#define USE_SPI_DEVICE_2 +#define SPI2_SCK_PIN PB13 +#define SPI2_MISO_PIN PB14 +#define SPI2_MOSI_PIN PB15 + +#define USE_SPI_DEVICE_3 +#define SPI3_SCK_PIN PC10 +#define SPI3_MISO_PIN PC11 +#define SPI3_MOSI_PIN PB2 +#define SPI3_SCK_AF GPIO_AF6_SPI3 +#define SPI3_MISO_AF GPIO_AF6_SPI3 +#define SPI3_MOSI_AF GPIO_AF7_SPI3 + + +// *************** Gyro & ACC ********************** + +#define USE_IMU_MPU6000 +#define IMU_MPU6000_ALIGN CW0_DEG +#define MPU6000_CS_PIN PA4 +#define MPU6000_SPI_BUS BUS_SPI1 + + +#define USE_IMU_ICM42605 +#define IMU_ICM42605_ALIGN CW0_DEG +#define ICM42605_CS_PIN PA4 +#define ICM42605_SPI_BUS BUS_SPI1 + +// *************** I2C/Baro/Mag ********************* +#define USE_I2C +#define USE_I2C_DEVICE_1 +#define I2C1_SCL PB8 +#define I2C1_SDA PB9 + + +//*************************************************** +#define USE_BARO +#define BARO_I2C_BUS BUS_I2C1 +#define USE_BARO_BMP280 +#define USE_BARO_DPS310 +#define USE_BARO_MS5611 + +#define USE_MAG +#define MAG_I2C_BUS BUS_I2C1 +#define USE_MAG_HMC5883 +#define USE_MAG_QMC5883 +#define USE_MAG_IST8310 +#define USE_MAG_IST8308 + +#define TEMPERATURE_I2C_BUS BUS_I2C1 + +#define PITOT_I2C_BUS BUS_I2C1 + +#define USE_RANGEFINDER +#define RANGEFINDER_I2C_BUS BUS_I2C1 +#define BNO055_I2C_BUS BUS_I2C1 + +// *************** FLASH ************************** + +#define USE_FLASHFS + +#define USE_FLASH_M25P16 +#define M25P16_CS_PIN PA15 +#define M25P16_SPI_BUS BUS_SPI3 + +#define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT + +// *************** OSD ***************************** + +#define USE_MAX7456 +#define MAX7456_SPI_BUS BUS_SPI2 +#define MAX7456_CS_PIN PB12 + +// *************** ADC ***************************** + +#define USE_ADC +#define ADC_INSTANCE ADC1 +#define ADC1_DMA_STREAM DMA2_Stream0 +#define ADC_CHANNEL_1_PIN PC3 +#define ADC_CHANNEL_2_PIN PC0 +#define ADC_CHANNEL_3_PIN PC2 + +#define VBAT_ADC_CHANNEL ADC_CHN_1 +#define RSSI_ADC_CHANNEL ADC_CHN_2 +#define CURRENT_METER_ADC_CHANNEL ADC_CHN_3 + + +#define DEFAULT_FEATURES (FEATURE_TX_PROF_SEL | FEATURE_CURRENT_METER | FEATURE_TELEMETRY | FEATURE_VBAT | FEATURE_OSD | FEATURE_BLACKBOX) + + + + +//************************************************** + +#define USE_SERIAL_4WAY_BLHELI_INTERFACE + +#define TARGET_IO_PORTA 0xffff +#define TARGET_IO_PORTB 0xffff +#define TARGET_IO_PORTC 0xffff +#define TARGET_IO_PORTD (BIT(2)) + + +#define MAX_PWM_OUTPUT_PORTS 8 + +#define USE_DSHOT +#define USE_ESC_SENSOR From 61ac48fc2e6f8006e9ce1d0b8e2b274b39e8c24a Mon Sep 17 00:00:00 2001 From: Marcelo Bezerra <23555060+mmosca@users.noreply.github.com> Date: Mon, 29 Apr 2024 20:23:29 +0200 Subject: [PATCH 224/241] fix warning --- src/main/flight/mixer_profile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/flight/mixer_profile.c b/src/main/flight/mixer_profile.c index 7b2590ff70b..5769b56fbdb 100644 --- a/src/main/flight/mixer_profile.c +++ b/src/main/flight/mixer_profile.c @@ -79,7 +79,7 @@ void pgResetFn_mixerProfiles(mixerProfile_t *instance) } } -void activateMixerConfig(){ +void activateMixerConfig(void){ currentMixerProfileIndex = getConfigMixerProfile(); currentMixerConfig = *mixerConfig(); nextMixerProfileIndex = (currentMixerProfileIndex + 1) % MAX_MIXER_PROFILE_COUNT; From 3fd5f286516de7bd924ade4d34c62413ba5b0fbe Mon Sep 17 00:00:00 2001 From: Marcelo Bezerra <23555060+mmosca@users.noreply.github.com> Date: Mon, 29 Apr 2024 20:33:50 +0200 Subject: [PATCH 225/241] Fix warnings --- src/main/io/displayport_msp_osd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/io/displayport_msp_osd.c b/src/main/io/displayport_msp_osd.c index e1e6cb29676..0d797e1f756 100644 --- a/src/main/io/displayport_msp_osd.c +++ b/src/main/io/displayport_msp_osd.c @@ -525,7 +525,7 @@ void mspOsdSerialProcess(mspProcessCommandFnPtr mspProcessCommandFn) } } -mspPort_t *getMspOsdPort() +mspPort_t *getMspOsdPort(void) { if (mspPort.port) { return &mspPort; From 3af52f7769aef555f0860ff4eb1b65da67ed3a5e Mon Sep 17 00:00:00 2001 From: Marcelo Bezerra <23555060+mmosca@users.noreply.github.com> Date: Mon, 29 Apr 2024 20:44:10 +0200 Subject: [PATCH 226/241] More warning fixes --- src/main/build/build_config.h | 2 +- src/main/cms/cms_types.h | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/build/build_config.h b/src/main/build/build_config.h index d97e6d300ce..75bb46668d7 100644 --- a/src/main/build/build_config.h +++ b/src/main/build/build_config.h @@ -40,7 +40,7 @@ #endif #ifdef __APPLE__ -#define FASTRAM __attribute__ ((section("__DATA,__.fastram_bss"), aligned(4))) +#define FASTRAM __attribute__ ((section("__DATA,__.fastram_bss"), aligned(8))) #else #define FASTRAM __attribute__ ((section(".fastram_bss"), aligned(4))) #endif diff --git a/src/main/cms/cms_types.h b/src/main/cms/cms_types.h index 9b2b06646c5..a07e55eaaa4 100644 --- a/src/main/cms/cms_types.h +++ b/src/main/cms/cms_types.h @@ -26,6 +26,12 @@ //type of elements +#ifndef __APPLE__ +#define OSD_ENTRY_ATTR __attribute__((packed)) +#else +#define OSD_ENTRY_ATTR +#endif + typedef enum { OME_Label, @@ -71,7 +77,7 @@ typedef struct const void * const data; const uint8_t type; // from OSD_MenuElement uint8_t flags; -} __attribute__((packed)) OSD_Entry; +} OSD_ENTRY_ATTR OSD_Entry; // Bits in flags #define PRINT_VALUE (1 << 0) // Value has been changed, need to redraw From a469daae88e46ba3c47e913854de3d0df04b18c4 Mon Sep 17 00:00:00 2001 From: Marcelo Bezerra <23555060+mmosca@users.noreply.github.com> Date: Mon, 29 Apr 2024 20:50:24 +0200 Subject: [PATCH 227/241] macos latest --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6fddc02df85..09e27045ca6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -74,7 +74,7 @@ jobs: path: ./build_SITL/*_SITL build-SITL-Mac: - runs-on: macos-13 + runs-on: macos-latest steps: - uses: actions/checkout@v3 - name: Install dependencies From 09d404f06493e71cf3a96b153c7b0cd909129918 Mon Sep 17 00:00:00 2001 From: breadoven <56191411+breadoven@users.noreply.github.com> Date: Wed, 1 May 2024 19:58:53 +0100 Subject: [PATCH 228/241] nav hold fix --- src/main/navigation/navigation.c | 43 ++++++++++++++---------- src/main/navigation/navigation_private.h | 1 - 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/main/navigation/navigation.c b/src/main/navigation/navigation.c index b443dc49941..eca17c2d656 100644 --- a/src/main/navigation/navigation.c +++ b/src/main/navigation/navigation.c @@ -424,7 +424,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_POSHOLD_3D_INITIALIZE, .onEntry = navOnEnteringState_NAV_STATE_POSHOLD_3D_INITIALIZE, .timeoutMs = 0, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_HOLD | NAV_REQUIRE_ANGLE | NAV_REQUIRE_THRTILT, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_REQUIRE_ANGLE | NAV_REQUIRE_THRTILT, .mapToFlightModes = NAV_ALTHOLD_MODE | NAV_POSHOLD_MODE, .mwState = MW_NAV_STATE_HOLD_INFINIT, .mwError = MW_NAV_ERROR_NONE, @@ -439,7 +439,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_POSHOLD_3D_IN_PROGRESS, .onEntry = navOnEnteringState_NAV_STATE_POSHOLD_3D_IN_PROGRESS, .timeoutMs = 10, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_HOLD | NAV_REQUIRE_ANGLE | NAV_REQUIRE_THRTILT | NAV_RC_ALT | NAV_RC_POS | NAV_RC_YAW, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_REQUIRE_ANGLE | NAV_REQUIRE_THRTILT | NAV_RC_ALT | NAV_RC_POS | NAV_RC_YAW, .mapToFlightModes = NAV_ALTHOLD_MODE | NAV_POSHOLD_MODE, .mwState = MW_NAV_STATE_HOLD_INFINIT, .mwError = MW_NAV_ERROR_NONE, @@ -595,7 +595,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_RTH_CLIMB_TO_SAFE_ALT, .onEntry = navOnEnteringState_NAV_STATE_RTH_CLIMB_TO_SAFE_ALT, .timeoutMs = 10, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_HOLD | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_RTH | NAV_RC_POS | NAV_RC_YAW, // allow pos adjustment while climbind to safe alt + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_RTH | NAV_RC_POS | NAV_RC_YAW, // allow pos adjustment while climbind to safe alt .mapToFlightModes = NAV_RTH_MODE | NAV_ALTHOLD_MODE, .mwState = MW_NAV_STATE_RTH_CLIMB, .mwError = MW_NAV_ERROR_WAIT_FOR_RTH_ALT, @@ -635,7 +635,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_RTH_HEAD_HOME, .onEntry = navOnEnteringState_NAV_STATE_RTH_HEAD_HOME, .timeoutMs = 10, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_HOLD | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_RTH | NAV_RC_POS | NAV_RC_YAW, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_RTH | NAV_RC_POS | NAV_RC_YAW, .mapToFlightModes = NAV_RTH_MODE | NAV_ALTHOLD_MODE, .mwState = MW_NAV_STATE_RTH_ENROUTE, .mwError = MW_NAV_ERROR_NONE, @@ -656,7 +656,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_RTH_LOITER_PRIOR_TO_LANDING, .onEntry = navOnEnteringState_NAV_STATE_RTH_LOITER_PRIOR_TO_LANDING, .timeoutMs = 500, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_HOLD | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_RTH | NAV_RC_POS | NAV_RC_YAW, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_RTH | NAV_RC_POS | NAV_RC_YAW, .mapToFlightModes = NAV_RTH_MODE | NAV_ALTHOLD_MODE, .mwState = MW_NAV_STATE_LAND_SETTLE, .mwError = MW_NAV_ERROR_NONE, @@ -677,7 +677,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_RTH_LOITER_ABOVE_HOME, .onEntry = navOnEnteringState_NAV_STATE_RTH_LOITER_ABOVE_HOME, .timeoutMs = 10, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_HOLD | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_RTH | NAV_RC_POS | NAV_RC_YAW | NAV_RC_ALT, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_RTH | NAV_RC_POS | NAV_RC_YAW | NAV_RC_ALT, .mapToFlightModes = NAV_RTH_MODE | NAV_ALTHOLD_MODE, .mwState = MW_NAV_STATE_HOVER_ABOVE_HOME, .mwError = MW_NAV_ERROR_NONE, @@ -696,7 +696,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_RTH_LANDING, .onEntry = navOnEnteringState_NAV_STATE_RTH_LANDING, .timeoutMs = 10, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_HOLD | NAV_CTL_LAND | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_RTH | NAV_RC_POS | NAV_RC_YAW, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_LAND | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_RTH | NAV_RC_POS | NAV_RC_YAW, .mapToFlightModes = NAV_RTH_MODE | NAV_ALTHOLD_MODE, .mwState = MW_NAV_STATE_LAND_IN_PROGRESS, .mwError = MW_NAV_ERROR_LANDING, @@ -717,7 +717,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_RTH_FINISHING, .onEntry = navOnEnteringState_NAV_STATE_RTH_FINISHING, .timeoutMs = 0, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_HOLD | NAV_CTL_LAND | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_RTH, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_LAND | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_RTH, .mapToFlightModes = NAV_RTH_MODE | NAV_ALTHOLD_MODE, .mwState = MW_NAV_STATE_LAND_IN_PROGRESS, .mwError = MW_NAV_ERROR_LANDING, @@ -828,7 +828,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_WAYPOINT_HOLD_TIME, // There is no state for timed hold? .onEntry = navOnEnteringState_NAV_STATE_WAYPOINT_HOLD_TIME, .timeoutMs = 10, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_HOLD | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_WP, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_WP, .mapToFlightModes = NAV_WP_MODE | NAV_ALTHOLD_MODE, .mwState = MW_NAV_STATE_HOLD_TIMED, .mwError = MW_NAV_ERROR_NONE, @@ -849,7 +849,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_WAYPOINT_RTH_LAND, .onEntry = navOnEnteringState_NAV_STATE_WAYPOINT_RTH_LAND, .timeoutMs = 10, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_HOLD | NAV_CTL_LAND | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_WP, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_LAND | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_WP, .mapToFlightModes = NAV_WP_MODE | NAV_ALTHOLD_MODE, .mwState = MW_NAV_STATE_LAND_IN_PROGRESS, .mwError = MW_NAV_ERROR_LANDING, @@ -887,7 +887,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_WAYPOINT_FINISHED, .onEntry = navOnEnteringState_NAV_STATE_WAYPOINT_FINISHED, .timeoutMs = 10, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_HOLD | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_WP | NAV_AUTO_WP_DONE, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_WP | NAV_AUTO_WP_DONE, .mapToFlightModes = NAV_WP_MODE | NAV_ALTHOLD_MODE, .mwState = MW_NAV_STATE_WP_ENROUTE, .mwError = MW_NAV_ERROR_FINISH, @@ -908,7 +908,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_EMERGENCY_LANDING_INITIALIZE, .onEntry = navOnEnteringState_NAV_STATE_EMERGENCY_LANDING_INITIALIZE, .timeoutMs = 0, - .stateFlags = NAV_CTL_EMERG | NAV_CTL_HOLD | NAV_REQUIRE_ANGLE, + .stateFlags = NAV_CTL_EMERG | NAV_REQUIRE_ANGLE, .mapToFlightModes = 0, .mwState = MW_NAV_STATE_EMERGENCY_LANDING, .mwError = MW_NAV_ERROR_LANDING, @@ -926,7 +926,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_EMERGENCY_LANDING_IN_PROGRESS, .onEntry = navOnEnteringState_NAV_STATE_EMERGENCY_LANDING_IN_PROGRESS, .timeoutMs = 10, - .stateFlags = NAV_CTL_EMERG | NAV_CTL_HOLD | NAV_REQUIRE_ANGLE, + .stateFlags = NAV_CTL_EMERG | NAV_REQUIRE_ANGLE, .mapToFlightModes = 0, .mwState = MW_NAV_STATE_EMERGENCY_LANDING, .mwError = MW_NAV_ERROR_LANDING, @@ -944,7 +944,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_EMERGENCY_LANDING_FINISHED, .onEntry = navOnEnteringState_NAV_STATE_EMERGENCY_LANDING_FINISHED, .timeoutMs = 10, - .stateFlags = NAV_CTL_EMERG | NAV_CTL_HOLD | NAV_REQUIRE_ANGLE, + .stateFlags = NAV_CTL_EMERG | NAV_REQUIRE_ANGLE, .mapToFlightModes = 0, .mwState = MW_NAV_STATE_LANDED, .mwError = MW_NAV_ERROR_LANDING, @@ -1053,7 +1053,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_FW_LANDING_CLIMB_TO_LOITER, .onEntry = navOnEnteringState_NAV_STATE_FW_LANDING_CLIMB_TO_LOITER, .timeoutMs = 10, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_HOLD | NAV_REQUIRE_ANGLE | NAV_AUTO_RTH, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_REQUIRE_ANGLE | NAV_AUTO_RTH, .mapToFlightModes = NAV_FW_AUTOLAND, .mwState = MW_NAV_STATE_LAND_IN_PROGRESS, .mwError = MW_NAV_ERROR_NONE, @@ -1074,7 +1074,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_FW_LANDING_LOITER, .onEntry = navOnEnteringState_NAV_STATE_FW_LANDING_LOITER, .timeoutMs = 10, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_HOLD | NAV_REQUIRE_ANGLE | NAV_AUTO_RTH, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_REQUIRE_ANGLE | NAV_AUTO_RTH, .mapToFlightModes = NAV_FW_AUTOLAND, .mwState = MW_NAV_STATE_LAND_IN_PROGRESS, .mwError = MW_NAV_ERROR_NONE, @@ -4081,7 +4081,16 @@ bool isLastMissionWaypoint(void) /* Checks if Nav hold position is active */ bool isNavHoldPositionActive(void) { - return navGetCurrentStateFlags() & NAV_CTL_HOLD; + // WP mode last WP hold and Timed hold positions + if (FLIGHT_MODE(NAV_WP_MODE)) { + return isLastMissionWaypoint() || posControl.waypointList[posControl.activeWaypointIndex].action == NAV_WP_ACTION_HOLD_TIME; + } + // RTH mode (spiral climb and Home positions but excluding RTH Trackback point positions) and POSHOLD mode + // Also hold position during emergency landing if position valid + return (FLIGHT_MODE(NAV_RTH_MODE) && !posControl.flags.rthTrackbackActive) || + FLIGHT_MODE(NAV_POSHOLD_MODE) || + (posControl.navState == NAV_STATE_FW_LANDING_CLIMB_TO_LOITER || posControl.navState == NAV_STATE_FW_LANDING_LOITER) || + navigationIsExecutingAnEmergencyLanding(); } float getActiveSpeed(void) diff --git a/src/main/navigation/navigation_private.h b/src/main/navigation/navigation_private.h index 015c9e371c5..5d23d36fc59 100644 --- a/src/main/navigation/navigation_private.h +++ b/src/main/navigation/navigation_private.h @@ -334,7 +334,6 @@ typedef enum { NAV_AUTO_WP_DONE = (1 << 15), // Waypoint mission reached the last waypoint and is idling NAV_MIXERAT = (1 << 16), // MIXERAT in progress - NAV_CTL_HOLD = (1 << 17), // Nav loiter active at position or will be when position reached } navigationFSMStateFlags_t; typedef struct { From 2a62aff039be188f132317a5e1d3bc58c5924b83 Mon Sep 17 00:00:00 2001 From: breadoven <56191411+breadoven@users.noreply.github.com> Date: Fri, 3 May 2024 11:46:33 +0100 Subject: [PATCH 229/241] WP altitude enforce hold fix --- src/main/navigation/navigation.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/navigation/navigation.c b/src/main/navigation/navigation.c index eca17c2d656..cedd3b3e9e3 100644 --- a/src/main/navigation/navigation.c +++ b/src/main/navigation/navigation.c @@ -4081,10 +4081,11 @@ bool isLastMissionWaypoint(void) /* Checks if Nav hold position is active */ bool isNavHoldPositionActive(void) { - // WP mode last WP hold and Timed hold positions - if (FLIGHT_MODE(NAV_WP_MODE)) { - return isLastMissionWaypoint() || posControl.waypointList[posControl.activeWaypointIndex].action == NAV_WP_ACTION_HOLD_TIME; - } + // WP mode last WP hold and Timed/Alt Enforce hold positions + return isLastMissionWaypoint() || + NAV_Status.state == MW_NAV_STATE_HOLD_TIMED || + posControl.waypointList[posControl.activeWaypointIndex].action == NAV_WP_ACTION_HOLD_TIME; + // RTH mode (spiral climb and Home positions but excluding RTH Trackback point positions) and POSHOLD mode // Also hold position during emergency landing if position valid return (FLIGHT_MODE(NAV_RTH_MODE) && !posControl.flags.rthTrackbackActive) || From d40bc0dc0cdfe055690f4fa53ef820046bae9715 Mon Sep 17 00:00:00 2001 From: breadoven <56191411+breadoven@users.noreply.github.com> Date: Fri, 3 May 2024 21:44:09 +0100 Subject: [PATCH 230/241] improvements --- src/main/navigation/navigation.c | 29 +++++++++++--------- src/main/navigation/navigation_fixedwing.c | 10 ++----- src/main/navigation/navigation_multicopter.c | 11 +++----- 3 files changed, 23 insertions(+), 27 deletions(-) diff --git a/src/main/navigation/navigation.c b/src/main/navigation/navigation.c index 09271e5f10f..bef708ecb1b 100644 --- a/src/main/navigation/navigation.c +++ b/src/main/navigation/navigation.c @@ -1898,16 +1898,12 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_WAYPOINT_IN_PROGRESS(na setDesiredPosition(&tmpWaypoint, 0, NAV_POS_UPDATE_XY | NAV_POS_UPDATE_BEARING); // Use linear climb between WPs arriving at WP altitude when within 10% of total distance to WP - // Update climbrate until within 25% of total distance to WP, then hold constant - static float climbRate = 0; - if (posControl.wpDistance > 0.25f * posControl.wpInitialDistance) { + // Update climb rate until within 100cm of total climb xy distance to WP, then hold constant + float climbRate = 0.0f; + if (posControl.wpDistance - 0.1f * posControl.wpInitialDistance > 100.0f) { climbRate = posControl.actualState.velXY * (posControl.activeWaypoint.pos.z - posControl.actualState.abs.pos.z) / (posControl.wpDistance - 0.1f * posControl.wpInitialDistance); } - - if (fabsf(climbRate) >= (STATE(AIRPLANE) ? navConfig()->fw.max_auto_climb_rate : navConfig()->mc.max_auto_climb_rate)) { - climbRate = 0; - } updateClimbRateToAltitudeController(climbRate, posControl.activeWaypoint.pos.z, ROC_TO_ALT_TARGET); if(STATE(MULTIROTOR)) { @@ -3401,14 +3397,20 @@ bool isProbablyStillFlying(void) float getDesiredClimbRate(float targetAltitude, timeDelta_t deltaMicros) { const bool emergLandingIsActive = navigationIsExecutingAnEmergencyLanding(); - float maxClimbRate = STATE(MULTIROTOR) ? navConfig()->mc.max_auto_climb_rate : navConfig()->fw.max_auto_climb_rate; + + if (posControl.flags.rocToAltMode == ROC_TO_ALT_CONSTANT) { + if (posControl.flags.isAdjustingAltitude) { + maxClimbRate = STATE(MULTIROTOR) ? navConfig()->mc.max_manual_climb_rate : navConfig()->fw.max_manual_climb_rate; + } + + return constrainf(posControl.desiredState.climbRateDemand, -maxClimbRate, maxClimbRate); + } + if (posControl.desiredState.climbRateDemand) { - maxClimbRate = ABS(posControl.desiredState.climbRateDemand); + maxClimbRate = constrainf(ABS(posControl.desiredState.climbRateDemand), 0.0f, maxClimbRate); } else if (emergLandingIsActive) { maxClimbRate = navConfig()->general.emerg_descent_rate; - } else if (posControl.flags.isAdjustingAltitude) { - maxClimbRate = STATE(MULTIROTOR) ? navConfig()->mc.max_manual_climb_rate : navConfig()->fw.max_manual_climb_rate; } const float targetAltitudeError = targetAltitude - navGetCurrentActualPositionAndVelocity()->pos.z; @@ -3420,8 +3422,8 @@ float getDesiredClimbRate(float targetAltitude, timeDelta_t deltaMicros) targetVel = pidProfile()->fwAltControlResponseFactor * targetAltitudeError / 100.0f; } - if (emergLandingIsActive && targetAltitudeError > -50) { - return -100; // maintain 1 m/s descent during emerg landing when approaching T/O altitude + if (emergLandingIsActive && targetAltitudeError > -50.0f) { + return -100.0f; // maintain 1 m/s descent during emerg landing when within 50cm of min speed landing altitude target } else { return constrainf(targetVel, -maxClimbRate, maxClimbRate); } @@ -3439,6 +3441,7 @@ void updateClimbRateToAltitudeController(float desiredClimbRate, float targetAlt if (mode == ROC_TO_ALT_CURRENT) { posControl.desiredState.pos.z = navGetCurrentActualPositionAndVelocity()->pos.z; + desiredClimbRate = 0.0f; } else if (mode == ROC_TO_ALT_TARGET) { posControl.desiredState.pos.z = targetAltitude; } diff --git a/src/main/navigation/navigation_fixedwing.c b/src/main/navigation/navigation_fixedwing.c index 0eaa41ef165..68714ca4803 100755 --- a/src/main/navigation/navigation_fixedwing.c +++ b/src/main/navigation/navigation_fixedwing.c @@ -133,11 +133,7 @@ static void updateAltitudeVelocityAndPitchController_FW(timeDelta_t deltaMicros) { static pt1Filter_t velzFilterState; - float desiredClimbRate = posControl.desiredState.climbRateDemand; - - if (posControl.flags.rocToAltMode != ROC_TO_ALT_CONSTANT) { - desiredClimbRate = getDesiredClimbRate(posControl.desiredState.pos.z, deltaMicros); - } + float desiredClimbRate = getDesiredClimbRate(posControl.desiredState.pos.z, deltaMicros); // Reduce max allowed climb pitch if performing loiter (stall prevention) if (needToCalculateCircularLoiter && desiredClimbRate > 0.0f) { @@ -770,8 +766,8 @@ void applyFixedWingEmergencyLandingController(timeUs_t currentTimeUs) rcCommand[THROTTLE] = setDesiredThrottle(currentBatteryProfile->failsafe_throttle, true); if (posControl.flags.estAltStatus >= EST_USABLE) { - // target min descent rate 10m above takeoff altitude - updateClimbRateToAltitudeController(0, 1000.0f, ROC_TO_ALT_TARGET); + // target min descent rate at distance 2 x emerg descent rate above takeoff altitude + updateClimbRateToAltitudeController(0, 2.0f * navConfig()->general.emerg_descent_rate, ROC_TO_ALT_TARGET); applyFixedWingAltitudeAndThrottleController(currentTimeUs); int16_t pitchCorrection = constrain(posControl.rcAdjustment[PITCH], -DEGREES_TO_DECIDEGREES(navConfig()->fw.max_dive_angle), DEGREES_TO_DECIDEGREES(navConfig()->fw.max_climb_angle)); diff --git a/src/main/navigation/navigation_multicopter.c b/src/main/navigation/navigation_multicopter.c index 41d1f7a5642..b108ef6aa31 100644 --- a/src/main/navigation/navigation_multicopter.c +++ b/src/main/navigation/navigation_multicopter.c @@ -76,11 +76,7 @@ float getSqrtControllerVelocity(float targetAltitude, timeDelta_t deltaMicros) // Position to velocity controller for Z axis static void updateAltitudeVelocityController_MC(timeDelta_t deltaMicros) { - float targetVel = posControl.desiredState.climbRateDemand; - - if (posControl.flags.rocToAltMode != ROC_TO_ALT_CONSTANT) { - targetVel = getDesiredClimbRate(posControl.desiredState.pos.z, deltaMicros); - } + float targetVel = getDesiredClimbRate(posControl.desiredState.pos.z, deltaMicros); posControl.pids.pos[Z].output_constrained = targetVel; // only used for Blackbox and OSD info @@ -141,6 +137,7 @@ bool adjustMulticopterAltitudeFromRCInput(void) } else { const int16_t rcThrottleAdjustment = applyDeadbandRescaled(rcCommand[THROTTLE] - altHoldThrottleRCZero, rcControlsConfig()->alt_hold_deadband, -500, 500); + if (rcThrottleAdjustment) { // set velocity proportional to stick movement float rcClimbRate; @@ -928,8 +925,8 @@ static void applyMulticopterEmergencyLandingController(timeUs_t currentTimeUs) // Check if last correction was not too long ago if (deltaMicrosPositionUpdate < MAX_POSITION_UPDATE_INTERVAL_US) { - // target min descent rate 5m above takeoff altitude - updateClimbRateToAltitudeController(0, 500.0f, ROC_TO_ALT_TARGET); + // target min descent rate at distance 2 x emerg descent rate above takeoff altitude + updateClimbRateToAltitudeController(0, 2.0f * navConfig()->general.emerg_descent_rate, ROC_TO_ALT_TARGET); updateAltitudeVelocityController_MC(deltaMicrosPositionUpdate); updateAltitudeThrottleController_MC(deltaMicrosPositionUpdate); } From 83de3f941d3b7cf247a9fbf5bb9469bf761f90de Mon Sep 17 00:00:00 2001 From: breadoven <56191411+breadoven@users.noreply.github.com> Date: Sat, 4 May 2024 11:25:58 +0100 Subject: [PATCH 231/241] change loiter control logic --- src/main/navigation/navigation.c | 54 ++++++++++++---------- src/main/navigation/navigation_fixedwing.c | 9 ++-- src/main/navigation/navigation_private.h | 1 + 3 files changed, 36 insertions(+), 28 deletions(-) diff --git a/src/main/navigation/navigation.c b/src/main/navigation/navigation.c index cedd3b3e9e3..1d24f9ae57b 100644 --- a/src/main/navigation/navigation.c +++ b/src/main/navigation/navigation.c @@ -424,7 +424,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_POSHOLD_3D_INITIALIZE, .onEntry = navOnEnteringState_NAV_STATE_POSHOLD_3D_INITIALIZE, .timeoutMs = 0, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_REQUIRE_ANGLE | NAV_REQUIRE_THRTILT, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_HOLD | NAV_REQUIRE_ANGLE | NAV_REQUIRE_THRTILT, .mapToFlightModes = NAV_ALTHOLD_MODE | NAV_POSHOLD_MODE, .mwState = MW_NAV_STATE_HOLD_INFINIT, .mwError = MW_NAV_ERROR_NONE, @@ -439,7 +439,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_POSHOLD_3D_IN_PROGRESS, .onEntry = navOnEnteringState_NAV_STATE_POSHOLD_3D_IN_PROGRESS, .timeoutMs = 10, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_REQUIRE_ANGLE | NAV_REQUIRE_THRTILT | NAV_RC_ALT | NAV_RC_POS | NAV_RC_YAW, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_HOLD | NAV_REQUIRE_ANGLE | NAV_REQUIRE_THRTILT | NAV_RC_ALT | NAV_RC_POS | NAV_RC_YAW, .mapToFlightModes = NAV_ALTHOLD_MODE | NAV_POSHOLD_MODE, .mwState = MW_NAV_STATE_HOLD_INFINIT, .mwError = MW_NAV_ERROR_NONE, @@ -595,7 +595,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_RTH_CLIMB_TO_SAFE_ALT, .onEntry = navOnEnteringState_NAV_STATE_RTH_CLIMB_TO_SAFE_ALT, .timeoutMs = 10, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_RTH | NAV_RC_POS | NAV_RC_YAW, // allow pos adjustment while climbind to safe alt + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_HOLD | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_RTH | NAV_RC_POS | NAV_RC_YAW, // allow pos adjustment while climbing to safe alt .mapToFlightModes = NAV_RTH_MODE | NAV_ALTHOLD_MODE, .mwState = MW_NAV_STATE_RTH_CLIMB, .mwError = MW_NAV_ERROR_WAIT_FOR_RTH_ALT, @@ -656,7 +656,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_RTH_LOITER_PRIOR_TO_LANDING, .onEntry = navOnEnteringState_NAV_STATE_RTH_LOITER_PRIOR_TO_LANDING, .timeoutMs = 500, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_RTH | NAV_RC_POS | NAV_RC_YAW, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_HOLD | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_RTH | NAV_RC_POS | NAV_RC_YAW, .mapToFlightModes = NAV_RTH_MODE | NAV_ALTHOLD_MODE, .mwState = MW_NAV_STATE_LAND_SETTLE, .mwError = MW_NAV_ERROR_NONE, @@ -677,7 +677,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_RTH_LOITER_ABOVE_HOME, .onEntry = navOnEnteringState_NAV_STATE_RTH_LOITER_ABOVE_HOME, .timeoutMs = 10, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_RTH | NAV_RC_POS | NAV_RC_YAW | NAV_RC_ALT, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_HOLD | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_RTH | NAV_RC_POS | NAV_RC_YAW | NAV_RC_ALT, .mapToFlightModes = NAV_RTH_MODE | NAV_ALTHOLD_MODE, .mwState = MW_NAV_STATE_HOVER_ABOVE_HOME, .mwError = MW_NAV_ERROR_NONE, @@ -696,7 +696,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_RTH_LANDING, .onEntry = navOnEnteringState_NAV_STATE_RTH_LANDING, .timeoutMs = 10, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_LAND | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_RTH | NAV_RC_POS | NAV_RC_YAW, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_HOLD | NAV_CTL_LAND | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_RTH | NAV_RC_POS | NAV_RC_YAW, .mapToFlightModes = NAV_RTH_MODE | NAV_ALTHOLD_MODE, .mwState = MW_NAV_STATE_LAND_IN_PROGRESS, .mwError = MW_NAV_ERROR_LANDING, @@ -717,7 +717,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_RTH_FINISHING, .onEntry = navOnEnteringState_NAV_STATE_RTH_FINISHING, .timeoutMs = 0, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_LAND | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_RTH, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_HOLD | NAV_CTL_LAND | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_RTH, .mapToFlightModes = NAV_RTH_MODE | NAV_ALTHOLD_MODE, .mwState = MW_NAV_STATE_LAND_IN_PROGRESS, .mwError = MW_NAV_ERROR_LANDING, @@ -828,7 +828,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_WAYPOINT_HOLD_TIME, // There is no state for timed hold? .onEntry = navOnEnteringState_NAV_STATE_WAYPOINT_HOLD_TIME, .timeoutMs = 10, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_WP, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_HOLD | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_WP, .mapToFlightModes = NAV_WP_MODE | NAV_ALTHOLD_MODE, .mwState = MW_NAV_STATE_HOLD_TIMED, .mwError = MW_NAV_ERROR_NONE, @@ -849,7 +849,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_WAYPOINT_RTH_LAND, .onEntry = navOnEnteringState_NAV_STATE_WAYPOINT_RTH_LAND, .timeoutMs = 10, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_LAND | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_WP, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_HOLD | NAV_CTL_LAND | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_WP, .mapToFlightModes = NAV_WP_MODE | NAV_ALTHOLD_MODE, .mwState = MW_NAV_STATE_LAND_IN_PROGRESS, .mwError = MW_NAV_ERROR_LANDING, @@ -887,7 +887,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_WAYPOINT_FINISHED, .onEntry = navOnEnteringState_NAV_STATE_WAYPOINT_FINISHED, .timeoutMs = 10, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_WP | NAV_AUTO_WP_DONE, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_HOLD | NAV_REQUIRE_ANGLE | NAV_REQUIRE_MAGHOLD | NAV_REQUIRE_THRTILT | NAV_AUTO_WP | NAV_AUTO_WP_DONE, .mapToFlightModes = NAV_WP_MODE | NAV_ALTHOLD_MODE, .mwState = MW_NAV_STATE_WP_ENROUTE, .mwError = MW_NAV_ERROR_FINISH, @@ -926,7 +926,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_EMERGENCY_LANDING_IN_PROGRESS, .onEntry = navOnEnteringState_NAV_STATE_EMERGENCY_LANDING_IN_PROGRESS, .timeoutMs = 10, - .stateFlags = NAV_CTL_EMERG | NAV_REQUIRE_ANGLE, + .stateFlags = NAV_CTL_HOLD | NAV_CTL_EMERG | NAV_REQUIRE_ANGLE, .mapToFlightModes = 0, .mwState = MW_NAV_STATE_EMERGENCY_LANDING, .mwError = MW_NAV_ERROR_LANDING, @@ -944,7 +944,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_EMERGENCY_LANDING_FINISHED, .onEntry = navOnEnteringState_NAV_STATE_EMERGENCY_LANDING_FINISHED, .timeoutMs = 10, - .stateFlags = NAV_CTL_EMERG | NAV_REQUIRE_ANGLE, + .stateFlags = NAV_CTL_HOLD | NAV_CTL_EMERG | NAV_REQUIRE_ANGLE, .mapToFlightModes = 0, .mwState = MW_NAV_STATE_LANDED, .mwError = MW_NAV_ERROR_LANDING, @@ -1053,7 +1053,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_FW_LANDING_CLIMB_TO_LOITER, .onEntry = navOnEnteringState_NAV_STATE_FW_LANDING_CLIMB_TO_LOITER, .timeoutMs = 10, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_REQUIRE_ANGLE | NAV_AUTO_RTH, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_HOLD | NAV_REQUIRE_ANGLE | NAV_AUTO_RTH, .mapToFlightModes = NAV_FW_AUTOLAND, .mwState = MW_NAV_STATE_LAND_IN_PROGRESS, .mwError = MW_NAV_ERROR_NONE, @@ -1074,7 +1074,7 @@ static const navigationFSMStateDescriptor_t navFSM[NAV_STATE_COUNT] = { .persistentId = NAV_PERSISTENT_ID_FW_LANDING_LOITER, .onEntry = navOnEnteringState_NAV_STATE_FW_LANDING_LOITER, .timeoutMs = 10, - .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_REQUIRE_ANGLE | NAV_AUTO_RTH, + .stateFlags = NAV_CTL_ALT | NAV_CTL_POS | NAV_CTL_YAW | NAV_CTL_HOLD | NAV_REQUIRE_ANGLE | NAV_AUTO_RTH, .mapToFlightModes = NAV_FW_AUTOLAND, .mwState = MW_NAV_STATE_LAND_IN_PROGRESS, .mwError = MW_NAV_ERROR_NONE, @@ -4081,17 +4081,21 @@ bool isLastMissionWaypoint(void) /* Checks if Nav hold position is active */ bool isNavHoldPositionActive(void) { - // WP mode last WP hold and Timed/Alt Enforce hold positions - return isLastMissionWaypoint() || - NAV_Status.state == MW_NAV_STATE_HOLD_TIMED || - posControl.waypointList[posControl.activeWaypointIndex].action == NAV_WP_ACTION_HOLD_TIME; - - // RTH mode (spiral climb and Home positions but excluding RTH Trackback point positions) and POSHOLD mode - // Also hold position during emergency landing if position valid - return (FLIGHT_MODE(NAV_RTH_MODE) && !posControl.flags.rthTrackbackActive) || - FLIGHT_MODE(NAV_POSHOLD_MODE) || - (posControl.navState == NAV_STATE_FW_LANDING_CLIMB_TO_LOITER || posControl.navState == NAV_STATE_FW_LANDING_LOITER) || - navigationIsExecutingAnEmergencyLanding(); + /* If the current Nav state isn't flagged as a hold point (NAV_CTL_HOLD) then + * waypoints are assumed to be hold points by default unless excluded as defined here */ + + if (navGetCurrentStateFlags() & NAV_CTL_HOLD) { + return true; + } + + if (FLIGHT_MODE(NAV_WP_MODE)) { + return posControl.waypointList[posControl.activeWaypointIndex].action != NAV_WP_ACTION_WAYPOINT || isLastMissionWaypoint(); + } + + return posControl.navState != NAV_STATE_FW_LANDING_APPROACH && + posControl.navState != NAV_STATE_FW_LANDING_GLIDE && + posControl.navState != NAV_STATE_FW_LANDING_FLARE && + !posControl.flags.rthTrackbackActive; } float getActiveSpeed(void) diff --git a/src/main/navigation/navigation_fixedwing.c b/src/main/navigation/navigation_fixedwing.c index 2dfebdf8d98..e9991203578 100755 --- a/src/main/navigation/navigation_fixedwing.c +++ b/src/main/navigation/navigation_fixedwing.c @@ -290,9 +290,12 @@ static void calculateVirtualPositionTarget_FW(float trackingPeriod) // Detemine if a circular loiter is required. // For waypoints only use circular loiter when angular visibility is > 30 degs, otherwise head straight toward target #define TAN_15DEG 0.26795f - needToCalculateCircularLoiter = isNavHoldPositionActive() && - (distanceToActualTarget <= (navLoiterRadius / TAN_15DEG)) && - (distanceToActualTarget > 50.0f); + + bool loiterApproachActive = isNavHoldPositionActive() && + distanceToActualTarget <= (navLoiterRadius / TAN_15DEG) && + distanceToActualTarget > 50.0f; + needToCalculateCircularLoiter = loiterApproachActive || (navGetCurrentStateFlags() & NAV_CTL_HOLD); + //if vtol landing is required, fly straight to homepoint if ((posControl.navState == NAV_STATE_RTH_HEAD_HOME) && navigationRTHAllowsLanding() && checkMixerATRequired(MIXERAT_REQUEST_LAND)){ needToCalculateCircularLoiter = false; diff --git a/src/main/navigation/navigation_private.h b/src/main/navigation/navigation_private.h index 5d23d36fc59..ddd2bb908da 100644 --- a/src/main/navigation/navigation_private.h +++ b/src/main/navigation/navigation_private.h @@ -334,6 +334,7 @@ typedef enum { NAV_AUTO_WP_DONE = (1 << 15), // Waypoint mission reached the last waypoint and is idling NAV_MIXERAT = (1 << 16), // MIXERAT in progress + NAV_CTL_HOLD = (1 << 17), // Nav loiter active at position } navigationFSMStateFlags_t; typedef struct { From 8ad1e5dbdec4373d5330f281a17a9b34da6ac6db Mon Sep 17 00:00:00 2001 From: breadoven <56191411+breadoven@users.noreply.github.com> Date: Sat, 4 May 2024 13:41:21 +0100 Subject: [PATCH 232/241] simplify hold state logic --- src/main/navigation/navigation.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/navigation/navigation.c b/src/main/navigation/navigation.c index 1d24f9ae57b..070bd1b4b83 100644 --- a/src/main/navigation/navigation.c +++ b/src/main/navigation/navigation.c @@ -4092,10 +4092,7 @@ bool isNavHoldPositionActive(void) return posControl.waypointList[posControl.activeWaypointIndex].action != NAV_WP_ACTION_WAYPOINT || isLastMissionWaypoint(); } - return posControl.navState != NAV_STATE_FW_LANDING_APPROACH && - posControl.navState != NAV_STATE_FW_LANDING_GLIDE && - posControl.navState != NAV_STATE_FW_LANDING_FLARE && - !posControl.flags.rthTrackbackActive; + return !FLIGHT_MODE(NAV_FW_AUTOLAND) && !posControl.flags.rthTrackbackActive; } float getActiveSpeed(void) From 1dc91058761816cc2427495e48f373393e62cf32 Mon Sep 17 00:00:00 2001 From: bishko <23706061+bishko@users.noreply.github.com> Date: Sun, 5 May 2024 13:06:13 +0100 Subject: [PATCH 233/241] Create Building in Gitpod.md (#10004) Gitpod offer by far the easierst and fastest method for building INAV targets. I wrote a small .md for those who want to have a step-by-step guide. --- docs/development/Building in Gitpod.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 docs/development/Building in Gitpod.md diff --git a/docs/development/Building in Gitpod.md b/docs/development/Building in Gitpod.md new file mode 100644 index 00000000000..4434b734433 --- /dev/null +++ b/docs/development/Building in Gitpod.md @@ -0,0 +1,15 @@ +# Building in Gitpod + +Gitpod offers an online build environment for building INAV targets. +## Setting up the environment + +1. Go to https://gitpod.io/new +1. Paste `https://github.com/iNavFlight/inav/tree/master` into the field called "Select a repository" +1. Cick on the link that shows in the drop down and Gitpod will atomatically selects the adequate Editor and Browser +1. Leave the other fields as default and click "Continue". Your build environment will be created. +1. At the bottom of the page, you will see a command line. Type `make [TARGET]` and wait for the target to be built. +1. Your new target will be located in a folder called `bin`, which can be found at the top left of the page. + +NOTE: You can use this method to build your forks as well. Just paste in the link to your fork and follow the rest of the steps. + +You are done! From 32ba12297524e04305106e0667043b9b57055337 Mon Sep 17 00:00:00 2001 From: breadoven <56191411+breadoven@users.noreply.github.com> Date: Mon, 6 May 2024 09:00:46 +0100 Subject: [PATCH 234/241] Add comments --- src/main/navigation/navigation.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/navigation/navigation.c b/src/main/navigation/navigation.c index 070bd1b4b83..b00442895b6 100644 --- a/src/main/navigation/navigation.c +++ b/src/main/navigation/navigation.c @@ -4088,10 +4088,12 @@ bool isNavHoldPositionActive(void) return true; } + // No hold required for basic WP type unless it's the last mission waypoint if (FLIGHT_MODE(NAV_WP_MODE)) { return posControl.waypointList[posControl.activeWaypointIndex].action != NAV_WP_ACTION_WAYPOINT || isLastMissionWaypoint(); } + // No hold required for Trackback WPs or for fixed wing autoland WPs not flagged as hold points (returned above if they are) return !FLIGHT_MODE(NAV_FW_AUTOLAND) && !posControl.flags.rthTrackbackActive; } From feedd3f4c68a6f1bc4f5cbec3979503106b12e16 Mon Sep 17 00:00:00 2001 From: Roman Lut <11955117+RomanLut@users.noreply.github.com> Date: Mon, 6 May 2024 15:04:13 +0200 Subject: [PATCH 235/241] fix ist8308 compass --- src/main/drivers/compass/compass_ist8308.c | 3 ++- src/main/drivers/compass/compass_ist8310.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/drivers/compass/compass_ist8308.c b/src/main/drivers/compass/compass_ist8308.c index 739c0965e9d..75d7386350d 100644 --- a/src/main/drivers/compass/compass_ist8308.c +++ b/src/main/drivers/compass/compass_ist8308.c @@ -121,8 +121,9 @@ static bool ist8308Read(magDev_t * mag) return false; } + // Invert Y axis to co convert from left to right coordinate system mag->magADCRaw[X] = (int16_t)(buf[1] << 8 | buf[0]) * LSB2FSV; - mag->magADCRaw[Y] = (int16_t)(buf[3] << 8 | buf[2]) * LSB2FSV; + mag->magADCRaw[Y] = -(int16_t)(buf[3] << 8 | buf[2]) * LSB2FSV; mag->magADCRaw[Z] = (int16_t)(buf[5] << 8 | buf[4]) * LSB2FSV; return true; diff --git a/src/main/drivers/compass/compass_ist8310.c b/src/main/drivers/compass/compass_ist8310.c index bbd4687eadc..c7b5b0b1249 100644 --- a/src/main/drivers/compass/compass_ist8310.c +++ b/src/main/drivers/compass/compass_ist8310.c @@ -139,7 +139,7 @@ static bool ist8310Read(magDev_t * mag) return false; } - // Looks like datasheet is incorrect and we need to invert Y axis to conform to right hand rule + // Invert Y axis to co convert from left to right coordinate system mag->magADCRaw[X] = (int16_t)(buf[1] << 8 | buf[0]) * LSB2FSV; mag->magADCRaw[Y] = -(int16_t)(buf[3] << 8 | buf[2]) * LSB2FSV; mag->magADCRaw[Z] = (int16_t)(buf[5] << 8 | buf[4]) * LSB2FSV; From 6eb637743d920ef0ae54f55620654a5ed5fb1c90 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Tue, 7 May 2024 17:07:08 +0200 Subject: [PATCH 236/241] Compilation fix --- src/main/navigation/navigation.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/navigation/navigation.c b/src/main/navigation/navigation.c index 0ab403a8ae5..711ee05f37a 100644 --- a/src/main/navigation/navigation.c +++ b/src/main/navigation/navigation.c @@ -1451,7 +1451,7 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_INITIALIZE(navigati bool trackbackActive = navConfig()->general.flags.rth_trackback_mode == RTH_TRACKBACK_ON || (navConfig()->general.flags.rth_trackback_mode == RTH_TRACKBACK_FS && posControl.flags.forcedRTHActivated); - if (trackbackActive && posControl.activeRthTBPointIndex >= 0 && !isWaypointMissionRTHActive()) { + if (trackbackActive && rth_trackback.activePointIndex >= 0 && !isWaypointMissionRTHActive()) { rthTrackBackUpdate(true); // save final trackpoint for altitude and max trackback distance reference posControl.flags.rthTrackbackActive = true; calculateAndSetActiveWaypointToLocalPosition(getRthTrackBackPosition()); From a6e256c2ca996c16bcf5724590e5044f7aaf2f96 Mon Sep 17 00:00:00 2001 From: bishko <23706061+bishko@users.noreply.github.com> Date: Tue, 7 May 2024 16:08:42 +0100 Subject: [PATCH 237/241] Update Building in Gitpod.md Adding a few points that are required to get HEX files. --- docs/development/Building in Gitpod.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/development/Building in Gitpod.md b/docs/development/Building in Gitpod.md index 4434b734433..fb0203a529f 100644 --- a/docs/development/Building in Gitpod.md +++ b/docs/development/Building in Gitpod.md @@ -1,14 +1,18 @@ # Building in Gitpod Gitpod offers an online build environment for building INAV targets. -## Setting up the environment +## Setting up the environment and building targets 1. Go to https://gitpod.io/new -1. Paste `https://github.com/iNavFlight/inav/tree/master` into the field called "Select a repository" -1. Cick on the link that shows in the drop down and Gitpod will atomatically selects the adequate Editor and Browser +1. Paste `https://github.com/iNavFlight/inav/tree/[version]` into the field called "Select a repository". +1. Ensure that you substitute [version] (e.g. 7.1.0) with the version number of INAV that you want to build. +1. Cick on the link that shows in the drop down and Gitpod will atomatically selects the adequate Editor and Browser. 1. Leave the other fields as default and click "Continue". Your build environment will be created. 1. At the bottom of the page, you will see a command line. Type `make [TARGET]` and wait for the target to be built. -1. Your new target will be located in a folder called `bin`, which can be found at the top left of the page. +1. Once the build has finished, navigate to the build folder using `cd build`. +1. Once in the folder, run `objcopy -O ihex -R .eeprom [TARGET].elf [TARGET].hex` to convert the `.elf` file to a `.hex` file. +1. Your new target `.hex` binary will be located in a folder called `bin`, which can be found at the top left of the page. + NOTE: You can use this method to build your forks as well. Just paste in the link to your fork and follow the rest of the steps. From 01303686fd19e8e51925e860ba8f146850ba2915 Mon Sep 17 00:00:00 2001 From: breadoven <56191411+breadoven@users.noreply.github.com> Date: Tue, 7 May 2024 22:47:44 +0100 Subject: [PATCH 238/241] fixes --- src/main/flight/pid.c | 2 +- src/main/navigation/navigation.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/flight/pid.c b/src/main/flight/pid.c index 944dcd7db41..e647fe475e3 100644 --- a/src/main/flight/pid.c +++ b/src/main/flight/pid.c @@ -169,7 +169,7 @@ static EXTENDED_FASTRAM bool angleHoldIsLevel = false; static EXTENDED_FASTRAM float fixedWingLevelTrim; static EXTENDED_FASTRAM pidController_t fixedWingLevelTrimController; -PG_REGISTER_PROFILE_WITH_RESET_TEMPLATE(pidProfile_t, pidProfile, PG_PID_PROFILE, 7); +PG_REGISTER_PROFILE_WITH_RESET_TEMPLATE(pidProfile_t, pidProfile, PG_PID_PROFILE, 8); PG_RESET_TEMPLATE(pidProfile_t, pidProfile, .bank_mc = { diff --git a/src/main/navigation/navigation.c b/src/main/navigation/navigation.c index 8ea4a9a3713..19178ddb1bd 100644 --- a/src/main/navigation/navigation.c +++ b/src/main/navigation/navigation.c @@ -1664,7 +1664,7 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_LOITER_PRIOR_TO_LAN if (!pauseLanding && ((ABS(wrap_18000(posControl.rthState.homePosition.heading - posControl.actualState.yaw)) < DEGREES_TO_CENTIDEGREES(15)) || STATE(FIXED_WING_LEGACY))) { resetLandingDetector(); // force reset landing detector just in case updateClimbRateToAltitudeController(0, 0, ROC_TO_ALT_CURRENT); - return navigationRTHAllowsLanding() ? NAV_FSM_EVENT_SUCCESS : NAV_FSM_EVENT_SWITCH_TO_RTH_HOVER_ABOVE_HOME; // success = land + return navigationRTHAllowsLanding() ? NAV_FSM_EVENT_SUCCESS : NAV_FSM_EVENT_SWITCH_TO_RTH_LOITER_ABOVE_HOME; // success = land } else { fpVector3_t * tmpHomePos = rthGetHomeTargetPosition(RTH_HOME_ENROUTE_FINAL); setDesiredPosition(tmpHomePos, posControl.rthState.homePosition.heading, NAV_POS_UPDATE_XY | NAV_POS_UPDATE_Z | NAV_POS_UPDATE_HEADING); @@ -1920,7 +1920,7 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_WAYPOINT_IN_PROGRESS(na setDesiredPosition(&tmpWaypoint, 0, NAV_POS_UPDATE_XY | NAV_POS_UPDATE_BEARING); // Use linear climb between WPs arriving at WP altitude when within 10% of total distance to WP - // Update climb rate until within 100cm of total climb xy distance to WP, then hold constant + // Update climb rate until within 100cm of total climb xy distance to WP float climbRate = 0.0f; if (posControl.wpDistance - 0.1f * posControl.wpInitialDistance > 100.0f) { climbRate = posControl.actualState.velXY * (posControl.activeWaypoint.pos.z - posControl.actualState.abs.pos.z) / From 75ea2ce41798451259def2229698e5a2e97d3c2f Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Sat, 11 May 2024 08:35:19 +0200 Subject: [PATCH 239/241] Fix line ends --- .../target/GEPRCF745_BT_HD/CMakeLists.txt | 2 +- src/main/target/GEPRCF745_BT_HD/config.c | 126 +++--- src/main/target/GEPRCF745_BT_HD/target.c | 104 ++--- src/main/target/GEPRCF745_BT_HD/target.h | 396 +++++++++--------- 4 files changed, 314 insertions(+), 314 deletions(-) diff --git a/src/main/target/GEPRCF745_BT_HD/CMakeLists.txt b/src/main/target/GEPRCF745_BT_HD/CMakeLists.txt index 815e08923a8..6d067ab102c 100644 --- a/src/main/target/GEPRCF745_BT_HD/CMakeLists.txt +++ b/src/main/target/GEPRCF745_BT_HD/CMakeLists.txt @@ -1 +1 @@ -target_stm32f745xg(GEPRCF745_BT_HD) +target_stm32f745xg(GEPRCF745_BT_HD) diff --git a/src/main/target/GEPRCF745_BT_HD/config.c b/src/main/target/GEPRCF745_BT_HD/config.c index f228c3e023f..d2f972270a2 100644 --- a/src/main/target/GEPRCF745_BT_HD/config.c +++ b/src/main/target/GEPRCF745_BT_HD/config.c @@ -1,63 +1,63 @@ -/* - * This file is part of INAV. - * - * INAV 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. - * - * INAV 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 INAV. If not, see . - */ - -#include -#include - -#include - -#include "common/axis.h" - -#include "config/config_master.h" -#include "config/feature.h" - -#include "drivers/sensor.h" -#include "drivers/pwm_esc_detect.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 "sensors/battery.h" -#include "sensors/sensors.h" - -#include "telemetry/telemetry.h" - -#include "fc/fc_msp_box.h" - -#include "io/piniobox.h" - - -#define BLUETOOTH_MSP_BAUDRATE BAUD_115200 - -void targetConfiguration(void) -{ - pinioBoxConfigMutable()->permanentId[0] = BOXARM; - pinioBoxConfigMutable()->permanentId[1] = BOX_PERMANENT_ID_USER1; - - serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART3)].functionMask = FUNCTION_MSP; - serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART3)].msp_baudrateIndex = BLUETOOTH_MSP_BAUDRATE; -} - +/* + * This file is part of INAV. + * + * INAV 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. + * + * INAV 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 INAV. If not, see . + */ + +#include +#include + +#include + +#include "common/axis.h" + +#include "config/config_master.h" +#include "config/feature.h" + +#include "drivers/sensor.h" +#include "drivers/pwm_esc_detect.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 "sensors/battery.h" +#include "sensors/sensors.h" + +#include "telemetry/telemetry.h" + +#include "fc/fc_msp_box.h" + +#include "io/piniobox.h" + + +#define BLUETOOTH_MSP_BAUDRATE BAUD_115200 + +void targetConfiguration(void) +{ + pinioBoxConfigMutable()->permanentId[0] = BOXARM; + pinioBoxConfigMutable()->permanentId[1] = BOX_PERMANENT_ID_USER1; + + serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART3)].functionMask = FUNCTION_MSP; + serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART3)].msp_baudrateIndex = BLUETOOTH_MSP_BAUDRATE; +} + diff --git a/src/main/target/GEPRCF745_BT_HD/target.c b/src/main/target/GEPRCF745_BT_HD/target.c index 57a8c2a8914..6fe88bde011 100644 --- a/src/main/target/GEPRCF745_BT_HD/target.c +++ b/src/main/target/GEPRCF745_BT_HD/target.c @@ -1,52 +1,52 @@ -/* -* This file is part of INAV Project. -* -* INAV 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. -* -* INAV 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 INAV. If not, see . -*/ - -#include - -#include "platform.h" - -#include "drivers/bus.h" -#include "drivers/io.h" -#include "drivers/pwm_mapping.h" -#include "drivers/timer.h" -#include "drivers/sensor.h" - - -BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, IMU1_SPI_BUS, IMU1_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU1_ALIGN); -BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000_2, DEVHW_MPU6000, IMU2_SPI_BUS, IMU2_CS_PIN, NONE, 1, DEVFLAGS_NONE, IMU2_ALIGN); - -BUSDEV_REGISTER_SPI_TAG(busdev_icm42688, DEVHW_MPU6000, IMU1_SPI_BUS, IMU1_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU1_ALIGN); -BUSDEV_REGISTER_SPI_TAG(busdev_icm42688_2, DEVHW_ICM42605, IMU2_SPI_BUS, IMU2_CS_PIN, NONE, 1, DEVFLAGS_NONE, IMU2_ALIGN); - - - -timerHardware_t timerHardware[] = { - - DEF_TIM(TIM3, CH3, PB0, TIM_USE_OUTPUT_AUTO, 0, 0), - DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 0), - DEF_TIM(TIM3, CH2, PB5, TIM_USE_OUTPUT_AUTO, 0, 0), - DEF_TIM(TIM3, CH1, PB4, TIM_USE_OUTPUT_AUTO, 0, 0), - - DEF_TIM(TIM4, CH1, PD12, TIM_USE_OUTPUT_AUTO, 0, 0), - DEF_TIM(TIM4, CH2, PD13, TIM_USE_OUTPUT_AUTO, 0, 0), - DEF_TIM(TIM8, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 0), - DEF_TIM(TIM8, CH4, PC9, TIM_USE_OUTPUT_AUTO, 0, 0), - - DEF_TIM(TIM1, CH1, PA8, TIM_USE_LED, 0, 0), -}; - -const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]); +/* +* This file is part of INAV Project. +* +* INAV 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. +* +* INAV 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 INAV. If not, see . +*/ + +#include + +#include "platform.h" + +#include "drivers/bus.h" +#include "drivers/io.h" +#include "drivers/pwm_mapping.h" +#include "drivers/timer.h" +#include "drivers/sensor.h" + + +BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000, DEVHW_MPU6000, IMU1_SPI_BUS, IMU1_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU1_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_mpu6000_2, DEVHW_MPU6000, IMU2_SPI_BUS, IMU2_CS_PIN, NONE, 1, DEVFLAGS_NONE, IMU2_ALIGN); + +BUSDEV_REGISTER_SPI_TAG(busdev_icm42688, DEVHW_MPU6000, IMU1_SPI_BUS, IMU1_CS_PIN, NONE, 0, DEVFLAGS_NONE, IMU1_ALIGN); +BUSDEV_REGISTER_SPI_TAG(busdev_icm42688_2, DEVHW_ICM42605, IMU2_SPI_BUS, IMU2_CS_PIN, NONE, 1, DEVFLAGS_NONE, IMU2_ALIGN); + + + +timerHardware_t timerHardware[] = { + + DEF_TIM(TIM3, CH3, PB0, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM3, CH2, PB5, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM3, CH1, PB4, TIM_USE_OUTPUT_AUTO, 0, 0), + + DEF_TIM(TIM4, CH1, PD12, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM4, CH2, PD13, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM8, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM8, CH4, PC9, TIM_USE_OUTPUT_AUTO, 0, 0), + + DEF_TIM(TIM1, CH1, PA8, TIM_USE_LED, 0, 0), +}; + +const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]); diff --git a/src/main/target/GEPRCF745_BT_HD/target.h b/src/main/target/GEPRCF745_BT_HD/target.h index 340f7bbe390..3d61f663dd8 100644 --- a/src/main/target/GEPRCF745_BT_HD/target.h +++ b/src/main/target/GEPRCF745_BT_HD/target.h @@ -1,198 +1,198 @@ -/* - * This file is part of INAV Project. - * - * INAV 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. - * - * INAV 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 INAV. If not, see . - */ - -#pragma once - -#define TARGET_BOARD_IDENTIFIER "GEPR" -#define USBD_PRODUCT_STRING "GEPRCF745_BT_HD" - -#define USE_TARGET_CONFIG - -#define LED0 PC13 - -#define BEEPER PD2 -#define BEEPER_INVERTED - - -//**************** SPI BUS ************************* -#define USE_SPI - -#define USE_SPI_DEVICE_1 -#define SPI1_SCK_PIN PA5 -#define SPI1_MISO_PIN PA6 -#define SPI1_MOSI_PIN PA7 - -#define USE_SPI_DEVICE_2 -#define SPI2_SCK_PIN PB13 -#define SPI2_MISO_PIN PB14 -#define SPI2_MOSI_PIN PB15 - -#define USE_SPI_DEVICE_3 -#define SPI3_SCK_PIN PC10 -#define SPI3_MISO_PIN PC11 -#define SPI3_MOSI_PIN PC12 - -#define USE_SPI_DEVICE_4 -#define SPI4_SCK_PIN PE2 -#define SPI4_MISO_PIN PE5 -#define SPI4_MOSI_PIN PE6 - - - -// *************** Gyro & ACC ********************** - -#define USE_DUAL_GYRO -#define USE_TARGET_IMU_HARDWARE_DESCRIPTORS -#define USE_IMU_MPU6000 -#define USE_IMU_ICM42605 - - -// *****IMU1 MPU6000 & ICM42688 ON SPI1 ************** -#define IMU1_ALIGN CW180_DEG -#define IMU1_SPI_BUS BUS_SPI1 -#define IMU1_CS_PIN PA4 - - - -// *****IMU2 MPU6000 & ICM42688 ON SPI2 ************** -#define IMU2_ALIGN CW0_DEG -#define IMU2_SPI_BUS BUS_SPI2 -#define IMU2_CS_PIN PB12 - - -// *************** I2C/Baro/Mag ********************* -#define USE_I2C -#define USE_I2C_DEVICE_1 -#define I2C1_SCL PB8 -#define I2C1_SDA PB9 - - -#define USE_BARO -#define BARO_I2C_BUS BUS_I2C1 -#define USE_BARO_BMP280 -#define USE_BARO_DPS310 -#define USE_BARO_MS5611 - -#define USE_MAG -#define MAG_I2C_BUS BUS_I2C1 -#define USE_MAG_HMC5883 -#define USE_MAG_QMC5883 -#define USE_MAG_IST8310 -#define USE_MAG_IST8308 -#define USE_MAG_MAG3110 -#define USE_MAG_LIS3MDL - -#define TEMPERATURE_I2C_BUS BUS_I2C1 - -#define PITOT_I2C_BUS BUS_I2C1 - -#define USE_RANGEFINDER -#define RANGEFINDER_I2C_BUS BUS_I2C1 -#define BNO055_I2C_BUS BUS_I2C1 - -// *************** FLASH ************************** -#define USE_SDCARD -#define USE_SDCARD_SPI -#define SDCARD_SPI_BUS BUS_SPI3 -#define SDCARD_CS_PIN PA15 - -#define ENABLE_BLACKBOX_LOGGING_ON_SDCARD_BY_DEFAULT - - -// ************PINIO to disable BT***************** -#define USE_PINIO -#define USE_PINIOBOX -#define PINIO1_PIN PE13 -#define PINIO1_FLAGS PINIO_FLAGS_INVERTED - - -// ************PINIO to other -#define PINIO2_PIN PC14 //Enable vsw - - -// *************** OSD ***************************** -#define USE_MAX7456 -#define MAX7456_SPI_BUS BUS_SPI4 -#define MAX7456_CS_PIN PE4 - -// *************** UART ***************************** -#define USE_VCP - -#define USE_UART1 -#define UART1_RX_PIN PA10 -#define UART1_TX_PIN PA9 - -#define USE_UART2 -#define UART2_RX_PIN PA3 -#define UART2_TX_PIN PA2 - -#define USE_UART3 -#define UART3_RX_PIN PB11 -#define UART3_TX_PIN PB10 - -#define USE_UART4 -#define UART4_RX_PIN PA1 -#define UART4_TX_PIN PA0 - -#define USE_UART6 -#define UART6_RX_PIN PC7 -#define UART6_TX_PIN PC6 - -#define USE_UART7 -#define UART7_RX_PIN PE7 -#define UART7_TX_PIN PE8 - -#define USE_UART8 -#define UART8_RX_PIN PE0 -#define UART8_TX_PIN PE1 - -#define SERIAL_PORT_COUNT 8 - -#define DEFAULT_RX_TYPE RX_TYPE_SERIAL -#define SERIALRX_PROVIDER SERIALRX_SBUS -#define SERIALRX_UART SERIAL_PORT_USART2 - -// *************** ADC ***************************** -#define USE_ADC -#define ADC_INSTANCE ADC1 -#define ADC1_DMA_STREAM DMA2_Stream0 -#define ADC_CHANNEL_1_PIN PC3 -#define ADC_CHANNEL_2_PIN PC5 -#define ADC_CHANNEL_3_PIN PC2 - -#define VBAT_ADC_CHANNEL ADC_CHN_1 -#define RSSI_ADC_CHANNEL ADC_CHN_2 -#define CURRENT_METER_ADC_CHANNEL ADC_CHN_3 - - -#define DEFAULT_FEATURES (FEATURE_TX_PROF_SEL | FEATURE_CURRENT_METER | FEATURE_TELEMETRY | FEATURE_VBAT | FEATURE_OSD | FEATURE_BLACKBOX) - -#define USE_LED_STRIP -#define WS2811_PIN PA8 - -#define USE_SERIAL_4WAY_BLHELI_INTERFACE - -#define TARGET_IO_PORTA 0xffff -#define TARGET_IO_PORTB 0xffff -#define TARGET_IO_PORTC 0xffff -#define TARGET_IO_PORTD 0xffff -#define TARGET_IO_PORTE 0xffff - -#define MAX_PWM_OUTPUT_PORTS 8 - -#define USE_DSHOT -#define USE_ESC_SENSOR +/* + * This file is part of INAV Project. + * + * INAV 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. + * + * INAV 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 INAV. If not, see . + */ + +#pragma once + +#define TARGET_BOARD_IDENTIFIER "GEPR" +#define USBD_PRODUCT_STRING "GEPRCF745_BT_HD" + +#define USE_TARGET_CONFIG + +#define LED0 PC13 + +#define BEEPER PD2 +#define BEEPER_INVERTED + + +//**************** SPI BUS ************************* +#define USE_SPI + +#define USE_SPI_DEVICE_1 +#define SPI1_SCK_PIN PA5 +#define SPI1_MISO_PIN PA6 +#define SPI1_MOSI_PIN PA7 + +#define USE_SPI_DEVICE_2 +#define SPI2_SCK_PIN PB13 +#define SPI2_MISO_PIN PB14 +#define SPI2_MOSI_PIN PB15 + +#define USE_SPI_DEVICE_3 +#define SPI3_SCK_PIN PC10 +#define SPI3_MISO_PIN PC11 +#define SPI3_MOSI_PIN PC12 + +#define USE_SPI_DEVICE_4 +#define SPI4_SCK_PIN PE2 +#define SPI4_MISO_PIN PE5 +#define SPI4_MOSI_PIN PE6 + + + +// *************** Gyro & ACC ********************** + +#define USE_DUAL_GYRO +#define USE_TARGET_IMU_HARDWARE_DESCRIPTORS +#define USE_IMU_MPU6000 +#define USE_IMU_ICM42605 + + +// *****IMU1 MPU6000 & ICM42688 ON SPI1 ************** +#define IMU1_ALIGN CW180_DEG +#define IMU1_SPI_BUS BUS_SPI1 +#define IMU1_CS_PIN PA4 + + + +// *****IMU2 MPU6000 & ICM42688 ON SPI2 ************** +#define IMU2_ALIGN CW0_DEG +#define IMU2_SPI_BUS BUS_SPI2 +#define IMU2_CS_PIN PB12 + + +// *************** I2C/Baro/Mag ********************* +#define USE_I2C +#define USE_I2C_DEVICE_1 +#define I2C1_SCL PB8 +#define I2C1_SDA PB9 + + +#define USE_BARO +#define BARO_I2C_BUS BUS_I2C1 +#define USE_BARO_BMP280 +#define USE_BARO_DPS310 +#define USE_BARO_MS5611 + +#define USE_MAG +#define MAG_I2C_BUS BUS_I2C1 +#define USE_MAG_HMC5883 +#define USE_MAG_QMC5883 +#define USE_MAG_IST8310 +#define USE_MAG_IST8308 +#define USE_MAG_MAG3110 +#define USE_MAG_LIS3MDL + +#define TEMPERATURE_I2C_BUS BUS_I2C1 + +#define PITOT_I2C_BUS BUS_I2C1 + +#define USE_RANGEFINDER +#define RANGEFINDER_I2C_BUS BUS_I2C1 +#define BNO055_I2C_BUS BUS_I2C1 + +// *************** FLASH ************************** +#define USE_SDCARD +#define USE_SDCARD_SPI +#define SDCARD_SPI_BUS BUS_SPI3 +#define SDCARD_CS_PIN PA15 + +#define ENABLE_BLACKBOX_LOGGING_ON_SDCARD_BY_DEFAULT + + +// ************PINIO to disable BT***************** +#define USE_PINIO +#define USE_PINIOBOX +#define PINIO1_PIN PE13 +#define PINIO1_FLAGS PINIO_FLAGS_INVERTED + + +// ************PINIO to other +#define PINIO2_PIN PC14 //Enable vsw + + +// *************** OSD ***************************** +#define USE_MAX7456 +#define MAX7456_SPI_BUS BUS_SPI4 +#define MAX7456_CS_PIN PE4 + +// *************** UART ***************************** +#define USE_VCP + +#define USE_UART1 +#define UART1_RX_PIN PA10 +#define UART1_TX_PIN PA9 + +#define USE_UART2 +#define UART2_RX_PIN PA3 +#define UART2_TX_PIN PA2 + +#define USE_UART3 +#define UART3_RX_PIN PB11 +#define UART3_TX_PIN PB10 + +#define USE_UART4 +#define UART4_RX_PIN PA1 +#define UART4_TX_PIN PA0 + +#define USE_UART6 +#define UART6_RX_PIN PC7 +#define UART6_TX_PIN PC6 + +#define USE_UART7 +#define UART7_RX_PIN PE7 +#define UART7_TX_PIN PE8 + +#define USE_UART8 +#define UART8_RX_PIN PE0 +#define UART8_TX_PIN PE1 + +#define SERIAL_PORT_COUNT 8 + +#define DEFAULT_RX_TYPE RX_TYPE_SERIAL +#define SERIALRX_PROVIDER SERIALRX_SBUS +#define SERIALRX_UART SERIAL_PORT_USART2 + +// *************** ADC ***************************** +#define USE_ADC +#define ADC_INSTANCE ADC1 +#define ADC1_DMA_STREAM DMA2_Stream0 +#define ADC_CHANNEL_1_PIN PC3 +#define ADC_CHANNEL_2_PIN PC5 +#define ADC_CHANNEL_3_PIN PC2 + +#define VBAT_ADC_CHANNEL ADC_CHN_1 +#define RSSI_ADC_CHANNEL ADC_CHN_2 +#define CURRENT_METER_ADC_CHANNEL ADC_CHN_3 + + +#define DEFAULT_FEATURES (FEATURE_TX_PROF_SEL | FEATURE_CURRENT_METER | FEATURE_TELEMETRY | FEATURE_VBAT | FEATURE_OSD | FEATURE_BLACKBOX) + +#define USE_LED_STRIP +#define WS2811_PIN PA8 + +#define USE_SERIAL_4WAY_BLHELI_INTERFACE + +#define TARGET_IO_PORTA 0xffff +#define TARGET_IO_PORTB 0xffff +#define TARGET_IO_PORTC 0xffff +#define TARGET_IO_PORTD 0xffff +#define TARGET_IO_PORTE 0xffff + +#define MAX_PWM_OUTPUT_PORTS 8 + +#define USE_DSHOT +#define USE_ESC_SENSOR From 35ce764405515216a6742cecdc36f81a755de0f6 Mon Sep 17 00:00:00 2001 From: breadoven <56191411+breadoven@users.noreply.github.com> Date: Sat, 11 May 2024 21:29:58 +0100 Subject: [PATCH 240/241] Fix max climb rate during loiter --- src/main/navigation/navigation_fixedwing.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/navigation/navigation_fixedwing.c b/src/main/navigation/navigation_fixedwing.c index db9f4d67283..71a7f99fc34 100755 --- a/src/main/navigation/navigation_fixedwing.c +++ b/src/main/navigation/navigation_fixedwing.c @@ -135,9 +135,9 @@ static void updateAltitudeVelocityAndPitchController_FW(timeDelta_t deltaMicros) float desiredClimbRate = getDesiredClimbRate(posControl.desiredState.pos.z, deltaMicros); - // Reduce max allowed climb pitch if performing loiter (stall prevention) - if (needToCalculateCircularLoiter && desiredClimbRate > 0.0f) { - desiredClimbRate *= 0.67f; + // Reduce max allowed climb rate by 2/3 if performing loiter (stall prevention) + if (needToCalculateCircularLoiter && desiredClimbRate > 0.67f * navConfig()->fw.max_auto_climb_rate) { + desiredClimbRate = 0.67f * navConfig()->fw.max_auto_climb_rate; } // Here we use negative values for dive for better clarity From 6f4ff6b4de8567645abd09e10ab9d2cb63febba7 Mon Sep 17 00:00:00 2001 From: breadoven <56191411+breadoven@users.noreply.github.com> Date: Mon, 13 May 2024 17:32:14 +0100 Subject: [PATCH 241/241] Fix trackback error --- src/main/navigation/navigation.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/navigation/navigation.c b/src/main/navigation/navigation.c index 711ee05f37a..1354d818a0d 100644 --- a/src/main/navigation/navigation.c +++ b/src/main/navigation/navigation.c @@ -1448,10 +1448,7 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_INITIALIZE(navigati } else { // Switch to RTH trackback - bool trackbackActive = navConfig()->general.flags.rth_trackback_mode == RTH_TRACKBACK_ON || - (navConfig()->general.flags.rth_trackback_mode == RTH_TRACKBACK_FS && posControl.flags.forcedRTHActivated); - - if (trackbackActive && rth_trackback.activePointIndex >= 0 && !isWaypointMissionRTHActive()) { + if (rthTrackBackIsActive() && rth_trackback.activePointIndex >= 0 && !isWaypointMissionRTHActive()) { rthTrackBackUpdate(true); // save final trackpoint for altitude and max trackback distance reference posControl.flags.rthTrackbackActive = true; calculateAndSetActiveWaypointToLocalPosition(getRthTrackBackPosition()); @@ -3200,7 +3197,7 @@ bool rthAltControlStickOverrideCheck(uint8_t axis) (axis == ROLL && STATE(MULTIROTOR) && !posControl.flags.rthTrackbackActive)) { return false; } - + static timeMs_t rthOverrideStickHoldStartTime[2]; if (rxGetChannelValue(axis) > rxConfig()->maxcheck) {