mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-23 16:25:26 +03:00
rangefinder debug mode
This commit is contained in:
parent
a1f34965de
commit
0fa7a2a773
3 changed files with 11 additions and 1 deletions
|
@ -50,5 +50,6 @@ typedef enum {
|
|||
DEBUG_NOTCH,
|
||||
DEBUG_NAV_LANDING_DETECTOR,
|
||||
DEBUG_FW_CLIMB_RATE_TO_ALTITUDE,
|
||||
DEBUG_RANGEFINDER,
|
||||
DEBUG_COUNT
|
||||
} debugType_e;
|
||||
|
|
|
@ -327,7 +327,8 @@ static const char * const lookupTableDebug[DEBUG_COUNT] = {
|
|||
"GYRO",
|
||||
"NOTCH",
|
||||
"NAV_LANDING",
|
||||
"FW_ALTITUDE"
|
||||
"FW_ALTITUDE",
|
||||
"RANGEFINDER"
|
||||
};
|
||||
|
||||
#ifdef TELEMETRY_LTM
|
||||
|
|
|
@ -48,6 +48,8 @@
|
|||
|
||||
#include "scheduler/scheduler.h"
|
||||
|
||||
#include "build/debug.h"
|
||||
|
||||
rangefinder_t rangefinder;
|
||||
|
||||
#define RANGEFINDER_HARDWARE_TIMEOUT_MS 500 // Accept 500ms of non-responsive sensor, report HW failure otherwise
|
||||
|
@ -182,6 +184,9 @@ int32_t rangefinderRead(void)
|
|||
{
|
||||
if (rangefinder.dev.read) {
|
||||
const int32_t distance = rangefinder.dev.read();
|
||||
|
||||
DEBUG_SET(DEBUG_RANGEFINDER, 0, distance);
|
||||
|
||||
if (distance >= 0) {
|
||||
rangefinder.lastValidResponseTimeMs = millis();
|
||||
rangefinder.rawAltitude = applyMedianFilter(distance);
|
||||
|
@ -200,6 +205,8 @@ int32_t rangefinderRead(void)
|
|||
rangefinder.rawAltitude = RANGEFINDER_OUT_OF_RANGE;
|
||||
}
|
||||
|
||||
DEBUG_SET(DEBUG_RANGEFINDER, 1, rangefinder.rawAltitude);
|
||||
|
||||
return rangefinder.rawAltitude;
|
||||
}
|
||||
|
||||
|
@ -217,6 +224,7 @@ int32_t rangefinderCalculateAltitude(int32_t rangefinderDistance, float cosTiltA
|
|||
} else {
|
||||
rangefinder.calculatedAltitude = rangefinderDistance * cosTiltAngle;
|
||||
}
|
||||
DEBUG_SET(DEBUG_RANGEFINDER, 2, rangefinder.calculatedAltitude);
|
||||
return rangefinder.calculatedAltitude;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue