optimized navigation

This commit is contained in:
2023-05-11 10:54:41 +02:00
parent 9b4017da9f
commit f2b63f1ce6
5 changed files with 23 additions and 10 deletions
+11 -5
View File
@@ -25,11 +25,11 @@ void Autopilot::loop() {
if (!this->selfDriving && this->navigationStarted)
ManualControl::loop();
if (millis() - this->lastMillis < delay)
if (millis() - this->loopLastMillis < loopDelayMillis)
return;
this->runAutopilot();
this->lastMillis = millis();
this->loopLastMillis = millis();
}
void Autopilot::runAutopilot() {
@@ -38,14 +38,20 @@ void Autopilot::runAutopilot() {
this->courseCorrection = this->navigation->getCourseCorrection();
this->routeInfo = this->navigation->getRouteInfo();
this->updateDisplay = true;
if (millis() - this->displayUpdateLastMillis > this->displayUpdateDelayMillis) {
this->updateDisplay = true;
this->displayUpdateLastMillis = millis();
}
// Check if start Point is near to current Location
if (this->routeInfo.currentPoint >= 2)
this->selfDrivingAvailable = true;
if (!this->selfDriving && this->selfDrivingAvailable)
this->setSelfDriving(ControlPadButton::isControlPadButtonPressed(this->input, ControlPadButton::PadButton::Action));
if (!this->selfDriving
&& this->selfDrivingAvailable
&& ControlPadButton::isControlPadButtonPressed(this->input, ControlPadButton::PadButton::Action))
this->setSelfDriving(true);
if (this->routeInfo.currentPoint == this->routeInfo.totalPoints) {
this->setSelfDriving(false);