added extra function for azimuth overflow
This commit is contained in:
@@ -264,16 +264,7 @@ int16_t Navigation::calculateCourseCorrection(Point& point) {
|
||||
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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user