put testmode into operation
This commit is contained in:
@@ -22,8 +22,9 @@ void TestMode::loop() {
|
||||
if (millis() - this->lastMillis < this->delay)
|
||||
return;
|
||||
|
||||
if (millis() - this->actionStart > this->maneuverTime) {
|
||||
if (millis() - this->actionStart > this->maneuverTime || this->abort) {
|
||||
this->busy = false;
|
||||
this->abort = false;
|
||||
this->moveControl->setDrivingStatus(DrivingStatus::stop);
|
||||
}
|
||||
}
|
||||
@@ -82,59 +83,58 @@ bool TestMode::drive(int16_t cm, int16_t degree) {
|
||||
}
|
||||
|
||||
bool TestMode::leftEngine(int16_t powerPercentage, int16_t seconds) {
|
||||
if (this->busy)
|
||||
return false;
|
||||
|
||||
if (powerPercentage >= 100 || powerPercentage <= -100)
|
||||
return false;
|
||||
|
||||
if (true) {
|
||||
std::cout << "It works... %: " << powerPercentage << " s: " << seconds << std::endl;
|
||||
return false;
|
||||
std::cout << "TestMode::leftEngine: 1" << std::endl;
|
||||
if (this->engineInit(powerPercentage, seconds)) {
|
||||
this->moveControl->setRawPowerLeft(powerPercentage);
|
||||
return true;
|
||||
}
|
||||
|
||||
this->actionStart = millis();
|
||||
this->moveControl->setDrivingStatus(DrivingStatus::raw);
|
||||
this->moveControl->setRawPowerLeft(powerPercentage);
|
||||
this->maneuverTime = seconds * 1000;
|
||||
this->busy = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TestMode::rightEngine(int16_t powerPercentage, int16_t seconds) {
|
||||
if (this->busy)
|
||||
return false;
|
||||
|
||||
if (powerPercentage >= 100 || powerPercentage <= -100)
|
||||
return false;
|
||||
|
||||
if (true) {
|
||||
std::cout << "It works... %: " << powerPercentage << " s: " << seconds << std::endl;
|
||||
return false;
|
||||
if (this->engineInit(powerPercentage, seconds)) {
|
||||
this->moveControl->setRawPowerRight(powerPercentage);
|
||||
return true;
|
||||
}
|
||||
|
||||
this->actionStart = millis();
|
||||
this->moveControl->setDrivingStatus(DrivingStatus::raw);
|
||||
this->moveControl->setRawPowerRight(powerPercentage);
|
||||
this->maneuverTime = seconds * 1000;
|
||||
this->busy = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TestMode::bothEngine(int16_t powerPercentage, int16_t seconds) {
|
||||
if (this->engineInit(powerPercentage, seconds)) {
|
||||
this->moveControl->setRawPowerLeft(powerPercentage);
|
||||
this->moveControl->setRawPowerRight(powerPercentage);;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void TestMode::abortManeuver() {
|
||||
this->abort = true;
|
||||
}
|
||||
|
||||
uint8_t TestMode::getRemainingManeuverTime() {
|
||||
if (busy)
|
||||
return (uint8_t) ((this->maneuverTime - (millis() - this->actionStart)) / 1000);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool TestMode::engineInit(int16_t powerPercentage, int16_t seconds) {
|
||||
if (this->busy)
|
||||
return false;
|
||||
|
||||
if (powerPercentage >= 100 || powerPercentage <= -100)
|
||||
return false;
|
||||
|
||||
if (seconds < 0)
|
||||
return false;
|
||||
|
||||
if (true) {
|
||||
std::cout << "It works... %: " << powerPercentage << " s: " << seconds << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
this->actionStart = millis();
|
||||
this->moveControl->setDrivingStatus(DrivingStatus::raw);
|
||||
this->moveControl->setRawPowerLeft(powerPercentage);
|
||||
this->moveControl->setRawPowerRight(powerPercentage);
|
||||
this->maneuverTime = seconds * 1000;
|
||||
this->busy = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user