ready to test capture Route and Autopiloz

This commit is contained in:
2022-02-03 19:50:48 +01:00
parent 5ca21b09b2
commit bc37abcb66
20 changed files with 226 additions and 39 deletions
+13 -1
View File
@@ -11,13 +11,19 @@
#include "navigation.h"
Navigation::Navigation(uint8_t rx, uint8_t tx) {
Navigation::Navigation(uint8_t rx, uint8_t tx, Route* route) {
this->gps = new TinyGPSPlus;
Serial1.begin(9600, SERIAL_8N1, rx, tx);
if (route)
this->route = route;
else
this->route = new Route();
}
Navigation::~Navigation() {
delete this->gps;
if (this->route)
delete this->route;
}
void Navigation::loop() {
@@ -25,6 +31,12 @@ void Navigation::loop() {
gps->encode(Serial1.read());
}
void Navigation::newRoute() {
if (this->route)
delete this->route;
this->route = new Route();
}
bool Navigation::startNavigation() {
Point newTargetPoint = this->route->startRoute();
this->navigationStarted = this->setTargetPoint(newTargetPoint);