1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-26 01:35:35 +03:00

limit update rate + use Ms

This commit is contained in:
breadoven 2023-01-25 20:55:58 +00:00
parent 3560bb57ea
commit dfabcbdd1d
6 changed files with 22 additions and 17 deletions

View file

@ -2801,12 +2801,18 @@ void calculateFarAwayTarget(fpVector3_t * farAwayPos, int32_t bearing, int32_t d
/*-----------------------------------------------------------
* NAV land detector
*-----------------------------------------------------------*/
void updateLandingStatus(void)
void updateLandingStatus(timeMs_t currentTimeMs)
{
if (STATE(AIRPLANE) && !navConfig()->general.flags.disarm_on_landing) {
return; // no point using this with a fixed wing if not set to disarm
}
static timeMs_t lastUpdateTimeMs = 0;
if (currentTimeMs < lastUpdateTimeMs + HZ2MS(100)) { // limit update to 100Hz
return;
}
lastUpdateTimeMs = currentTimeMs;
static bool landingDetectorIsActive;
DEBUG_SET(DEBUG_LANDING, 0, landingDetectorIsActive);
@ -2831,7 +2837,7 @@ void updateLandingStatus(void)
if (navConfig()->general.flags.disarm_on_landing) {
ENABLE_ARMING_FLAG(ARMING_DISABLED_LANDING_DETECTED);
disarm(DISARM_LANDING);
} else if (!navigationIsFlyingAutonomousMode()) {
} else if (!navigationInAutomaticThrottleMode()) {
// for multirotor only - reactivate landing detector without disarm when throttle raised toward hover throttle
landingDetectorIsActive = rxGetChannelValue(THROTTLE) < (0.5 * (currentBatteryProfile->nav.mc.hover_throttle + getThrottleIdleValue()));
}