optimized navigation
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user