fixed to fast switching between autopilot mode
This commit is contained in:
@@ -57,16 +57,18 @@ void Autopilot::runAutopilot() {
|
|||||||
if (this->routeInfo.currentPoint >= 2 && this->state == State::GetToStartPoint)
|
if (this->routeInfo.currentPoint >= 2 && this->state == State::GetToStartPoint)
|
||||||
this->state = State::SelfDrivingAvailable;
|
this->state = State::SelfDrivingAvailable;
|
||||||
|
|
||||||
if (this->state == State::SelfDrivingAvailable
|
if (ControlPadButton::isControlPadButtonPressed(this->input, ControlPadButton::PadButton::Action)
|
||||||
&& ControlPadButton::isControlPadButtonPressed(this->input, ControlPadButton::PadButton::Action)) {
|
&& millis() - this->lastAutopilotChangeMillis > this->autopilotChangeDelayMillis) {
|
||||||
|
|
||||||
|
if (this->state == State::SelfDrivingAvailable) {
|
||||||
this->state = State::SelfDriving;
|
this->state = State::SelfDriving;
|
||||||
this->updateDisplay = true;
|
this->updateDisplay = true;
|
||||||
}
|
this->lastAutopilotChangeMillis = millis();
|
||||||
|
} else if (this->state == State::SelfDriving) {
|
||||||
if (this->state == State::SelfDriving
|
|
||||||
&& ControlPadButton::isControlPadButtonPressed(this->input, ControlPadButton::PadButton::Action)) {
|
|
||||||
this->state = State::SelfDrivingAvailable;
|
this->state = State::SelfDrivingAvailable;
|
||||||
this->updateDisplay = true;
|
this->updateDisplay = true;
|
||||||
|
this->lastAutopilotChangeMillis = millis();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->state == State::SelfDriving) {
|
if (this->state == State::SelfDriving) {
|
||||||
|
|||||||
@@ -126,9 +126,11 @@ class Autopilot : public ManualControl {
|
|||||||
uint8_t ntripReconnectMaxAttemps = 10;
|
uint8_t ntripReconnectMaxAttemps = 10;
|
||||||
uint16_t displayUpdateDelayMillis = 1000;
|
uint16_t displayUpdateDelayMillis = 1000;
|
||||||
uint16_t reconnectNtripDelayMillis = 1000;
|
uint16_t reconnectNtripDelayMillis = 1000;
|
||||||
|
uint16_t autopilotChangeDelayMillis = 500;
|
||||||
uint32_t displayUpdateLastMillis = 0;
|
uint32_t displayUpdateLastMillis = 0;
|
||||||
uint32_t loopLastMillis = 0;
|
uint32_t loopLastMillis = 0;
|
||||||
uint32_t reconnectNtripLastMillis = 0;
|
uint32_t reconnectNtripLastMillis = 0;
|
||||||
|
uint32_t lastAutopilotChangeMillis = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // AUTOPILOT_H
|
#endif // AUTOPILOT_H
|
||||||
|
|||||||
Reference in New Issue
Block a user