added extra function for azimuth overflow

This commit is contained in:
2023-08-13 17:03:19 +02:00
parent cd319f43e4
commit 30e2b75ea6
2 changed files with 14 additions and 11 deletions
+12 -11
View File
@@ -263,17 +263,8 @@ int16_t Navigation::calculateCourseCorrection(Point& point) {
correctionCourse = targetCourse - this->realAzimuth;
this->lastUsedCalcAzimuth = false;
}
if (correctionCourse > 180)
correctionCourse -= 360;
else if (correctionCourse < -180)
correctionCourse += 360;
//Rotate result by 180° to corrigate Azimuth
correctionCourse += 180;
correctionCourse = correctionCourse > 180 ? correctionCourse -360 : correctionCourse;
return correctionCourse;
return Navigation::fixDegree(correctionCourse);
}
bool Navigation::nextPoint() {
@@ -294,6 +285,16 @@ void Navigation::setOutputStatusPrintPVTdata(bool status) {
Navigation::outputStatusPrintPVTdata = status;
}
int16_t Navigation::fixDegree(int16_t degree) {
while (degree < -180 || degree > 180) {
if (degree > 180)
degree -= 360;
else if (degree < -180)
degree += 360;
}
return degree;
}
void Navigation::printPVTdata(UBX_NAV_PVT_data_t *ubxDataStruct) {
if (!Navigation::outputStatusPrintPVTdata)
return;
+2
View File
@@ -210,6 +210,8 @@ class Navigation {
* @param status
*/
static void setOutputStatusPrintPVTdata(bool status);
// map input in range from -180 to 180 degree
static int16_t fixDegree(int16_t degree);
private:
void updateCurrentLocation();