46 lines
1.2 KiB
C++
46 lines
1.2 KiB
C++
/**
|
|
* @file captureRoute.cpp
|
|
* @author Alexander Klein (alex@kleiax.de)
|
|
* @brief Contains the implementation of the class CaptureRoute
|
|
* @version 0.1
|
|
* @date 2022-02-15
|
|
*
|
|
* @copyright Copyright (c) 2022
|
|
*
|
|
*/
|
|
|
|
#include "driveModi/Modi/CaptureRoute/captureRoute.h"
|
|
|
|
CaptureRoute::CaptureRoute(MoveControl* moveControl, const ControlPadInput *input, Navigation* navigation)
|
|
: ManualControl(moveControl, input) {
|
|
this->navigation = navigation;
|
|
this->routeInfo = navigation->getRouteInfo();
|
|
}
|
|
|
|
void CaptureRoute::loop() {
|
|
ManualControl::loop();
|
|
|
|
if (millis() - this->lastMillis < delay) {
|
|
return;
|
|
}
|
|
this->runCaptureRoute();
|
|
this->lastMillis = millis();
|
|
}
|
|
|
|
void CaptureRoute::runCaptureRoute() {
|
|
if (ControlPadButton::isControlPadButtonPressed(this->input, ControlPadButton::PadButton::Action)) {
|
|
if (this->navigation->addCurrentPosToRoute()) {
|
|
this->routeInfo = navigation->getRouteInfo();
|
|
this->updateDisplay = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
bool CaptureRoute::shouldUpdate() {
|
|
if (this->updateDisplay) {
|
|
this->updateDisplay = false;
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|