From 15689bf56b022b3458160162c7616db06bb40bf7 Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Wed, 4 Jan 2023 00:17:39 +0100 Subject: [PATCH] bug fixes --- lib/Navigation/navigation.h | 2 +- src/SpecialMenus/Route/menuRoutePoints.cpp | 29 ++++++++++++++----- src/SpecialMenus/Route/menuRoutePoints.h | 2 +- .../menuSysteminformatio.cpp | 1 + .../driveModi/Autopilot/menuAutopilot.cpp | 4 +-- 5 files changed, 25 insertions(+), 13 deletions(-) diff --git a/lib/Navigation/navigation.h b/lib/Navigation/navigation.h index 524f63e..536f7e8 100644 --- a/lib/Navigation/navigation.h +++ b/lib/Navigation/navigation.h @@ -27,7 +27,7 @@ * around the half accuracy of the positioning system * */ -#define MIN_DISTANCE_BETWEEN_POINTS 1 +#define MIN_DISTANCE_BETWEEN_POINTS 0.1 /** * @brief This struct inherits the result of the navigation diff --git a/src/SpecialMenus/Route/menuRoutePoints.cpp b/src/SpecialMenus/Route/menuRoutePoints.cpp index 78437a4..295764c 100644 --- a/src/SpecialMenus/Route/menuRoutePoints.cpp +++ b/src/SpecialMenus/Route/menuRoutePoints.cpp @@ -13,6 +13,9 @@ MenuRoutePoints::MenuRoutePoints(Route *route) : MenuInformationSites() { this->route = route; +} + +void MenuRoutePoints::init() { uint16_t amountPoints = this->route->getRouteInfo().totalPoints; if (amountPoints > UINT8_MAX) this->error = true; @@ -21,8 +24,12 @@ MenuRoutePoints::MenuRoutePoints(Route *route) : MenuInformationSites() { } void MenuRoutePoints::printPage() const { - String lineOne = "N"; - String lineTwo = "E"; + uint8_t currentPage = this->getCurrentPage(); + if (this->lastPageNumber == currentPage) + return; + + String lineOne = "N "; + String lineTwo = "E "; if (this->error) { lineOne = "Error: To much"; @@ -40,24 +47,30 @@ void MenuRoutePoints::printPage() const { } Point p; - uint8_t currentPage = this->getCurrentPage(); if (currentPage == 0) p = this->route->startRoute(); - else if (currentPage == this->getCountPages()) - p = this->route->endRoute(); else if (this->lastPageNumber - 1 == currentPage) p = this->route->getPreviousPoint(); else if (this->lastPageNumber + 1 == currentPage) p = this->route->getNextPoint(); + else if (currentPage == this->getCountPages() - 1) + p = this->route->endRoute(); else std::cout << "Error in: MenuRoutePoints::printPage()" << std::endl; - lineOne.concat(p.getLatitude()); + char buf[20]; + char* string; + + info = this->route->getRouteInfo(); + string = dtostrf(p.getLatitude(), 9, 7, buf); + lineOne.concat(string); lineOne.concat(" "); lineOne.concat(info.currentPoint); - lineTwo.concat(p.getLongitude()); + // lineOne.concat(currentPage); + string = dtostrf(p.getLongitude(), 9, 7, buf); + lineTwo.concat(string); lineTwo.concat(" "); lineTwo.concat(info.totalPoints); - + // std::cout << "MenuRoutePoints::printPage currentPage: " << (int) currentPage << std::endl; this->print(lineOne, lineTwo); } diff --git a/src/SpecialMenus/Route/menuRoutePoints.h b/src/SpecialMenus/Route/menuRoutePoints.h index 78ce87f..4004764 100644 --- a/src/SpecialMenus/Route/menuRoutePoints.h +++ b/src/SpecialMenus/Route/menuRoutePoints.h @@ -19,12 +19,12 @@ class MenuRoutePoints : public MenuInformationSites { public: MenuRoutePoints(Route *route); + void init () override; void printPage() const override; private: Route* route; - uint8_t lastPageNumber = 0; bool error = false; }; diff --git a/src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp b/src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp index fe57fa3..00359da 100644 --- a/src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp +++ b/src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp @@ -29,6 +29,7 @@ void MenuSysteminformation::printPage() const { case 1: lineOne = "Max alloc heap:"; lineTwo.concat(ESP.getMaxAllocHeap()); + break; case 2: lineOne = "Uptime in secs:"; diff --git a/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp b/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp index 4893ecf..963078a 100644 --- a/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp +++ b/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp @@ -59,9 +59,7 @@ void MenuAutopilot::printMenu() { sprintf(buf2, "vorhanden."); } } - if (!navigationStarted && !navigationEnded){ - - } + if (this->lcd) { this->lcd->clear(); this->lcd->setCursor(0, 0);