fixed to fast switching between autopilot mode

This commit is contained in:
2023-05-24 13:48:24 +02:00
parent 74d56576ae
commit 6a2a437e21
2 changed files with 12 additions and 8 deletions
+10 -8
View File
@@ -57,16 +57,18 @@ void Autopilot::runAutopilot() {
if (this->routeInfo.currentPoint >= 2 && this->state == State::GetToStartPoint)
this->state = State::SelfDrivingAvailable;
if (this->state == State::SelfDrivingAvailable
&& ControlPadButton::isControlPadButtonPressed(this->input, ControlPadButton::PadButton::Action)) {
this->state = State::SelfDriving;
this->updateDisplay = true;
}
if (this->state == State::SelfDriving
&& ControlPadButton::isControlPadButtonPressed(this->input, ControlPadButton::PadButton::Action)) {
if (ControlPadButton::isControlPadButtonPressed(this->input, ControlPadButton::PadButton::Action)
&& millis() - this->lastAutopilotChangeMillis > this->autopilotChangeDelayMillis) {
if (this->state == State::SelfDrivingAvailable) {
this->state = State::SelfDriving;
this->updateDisplay = true;
this->lastAutopilotChangeMillis = millis();
} else if (this->state == State::SelfDriving) {
this->state = State::SelfDrivingAvailable;
this->updateDisplay = true;
this->lastAutopilotChangeMillis = millis();
}
}
if (this->state == State::SelfDriving) {