Skip to content

Commit

Permalink
pass some variations from int8_t to int16_t, so that in the future th…
Browse files Browse the repository at this point in the history
…e number of trackback points can be increased
  • Loading branch information
Julio Cesar authored and Julio Cesar committed Oct 30, 2023
1 parent 9aa64c6 commit bee5128
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
8 changes: 3 additions & 5 deletions src/main/navigation/rth_trackback.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void rthTrackBackUpdate(bool forceSaveTrackPoint)
{
static bool suspendTracking = false;
bool fwLoiterIsActive = STATE(AIRPLANE) && (NAV_Status.state == MW_NAV_STATE_HOLD_TIMED || FLIGHT_MODE(NAV_POSHOLD_MODE));

if (!fwLoiterIsActive && suspendTracking) {
suspendTracking = false;
}
Expand All @@ -55,8 +55,7 @@ void rthTrackBackUpdate(bool forceSaveTrackPoint)
return;
}

// Record trackback points based on significant change in course/altitude until
// points limit reached. Overwrite older points from then on.
// Record trackback points based on significant change in course/altitude until points limit reached. Overwrite older points from then on.
if (posControl.flags.estPosStatus >= EST_USABLE && posControl.flags.estAltStatus >= EST_USABLE) {
static int32_t previousTBTripDist; // cm
static int16_t previousTBCourse; // degrees
Expand All @@ -82,8 +81,7 @@ void rthTrackBackUpdate(bool forceSaveTrackPoint)
if (ABS(wrap_18000(DEGREES_TO_CENTIDEGREES(DECIDEGREES_TO_DEGREES(gpsSol.groundCourse) - previousTBCourse))) > DEGREES_TO_CENTIDEGREES(45)) {
saveTrackpoint = true;
} else if (distanceCounter >= 9) {
// Distance based trackpoint logged if at least 10 distance increments occur without altitude or course change
// and deviation from projected course path > 20m
// Distance based trackpoint logged if at least 10 distance increments occur without altitude or course change and deviation from projected course path > 20m
float distToPrevPoint = calculateDistanceToDestination(&rth_trackback.pointsList[rth_trackback.activePointIndex]);

fpVector3_t virtualCoursePoint;
Expand Down
6 changes: 3 additions & 3 deletions src/main/navigation/rth_trackback.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
typedef struct
{
fpVector3_t pointsList[NAV_RTH_TRACKBACK_POINTS]; // buffer of points stored
int8_t lastSavedIndex; // last trackback point index saved
int8_t activePointIndex; // trackback points counter
int8_t WrapAroundCounter; // stores trackpoint array overwrite index position
int16_t lastSavedIndex; // last trackback point index saved
int16_t activePointIndex; // trackback points counter
int16_t WrapAroundCounter; // stores trackpoint array overwrite index position
} rth_trackback_t;

extern rth_trackback_t rth_trackback;
Expand Down

0 comments on commit bee5128

Please sign in to comment.