diff --git a/include/moveControl.h b/include/moveControl.h index 08510e7..0764481 100644 --- a/include/moveControl.h +++ b/include/moveControl.h @@ -154,6 +154,9 @@ class MoveControl { */ Speedometer* getSpeedometerRight() const { return this->right_speedometer; } + uint16_t getDutycycleLeft() const { return this->left_motor->getDutycycle(); } + uint16_t getDutycycleRight() const { return this->right_motor->getDutycycle(); } + /** * @brief Set the min delay between each loop * diff --git a/lib/MotorControl/motorControl.cpp b/lib/MotorControl/motorControl.cpp index ac22f5b..f94111f 100644 --- a/lib/MotorControl/motorControl.cpp +++ b/lib/MotorControl/motorControl.cpp @@ -159,7 +159,7 @@ bool MotorControl::isAccelerationNegative() { void MotorControl::setRealPower(int8_t power) { //TODO: Exceptionhandling - if (power <= 100 || power <= -100) { + if (power <= 100 && power >= -100) { this->power = power; } else { return; @@ -170,6 +170,7 @@ void MotorControl::setRealPower(int8_t power) { digitalWrite(this->dir_1, LOW); digitalWrite(this->dir_2, LOW); ledcWrite(this->pwm_channel, 0); + this->dutycycle = 0; return; } @@ -186,6 +187,7 @@ void MotorControl::setRealPower(int8_t power) { } ledcWrite(this->pwm_channel, pwm_val); + this->dutycycle = pwm_val; } void MotorControl::increasePower(int8_t power) { diff --git a/lib/MotorControl/motorControl.h b/lib/MotorControl/motorControl.h index 287fbd9..4880a42 100644 --- a/lib/MotorControl/motorControl.h +++ b/lib/MotorControl/motorControl.h @@ -142,6 +142,8 @@ class MotorControl { * @return int8_t percent of power (-100 to 100) */ int8_t getTargetPower(); + + uint16_t getDutycycle() const { return this->dutycycle; } bool isTargetPowerReached(); bool isAccelerationPositive(); bool isAccelerationNegative(); @@ -157,6 +159,7 @@ class MotorControl { uint8_t pwm_pin; uint8_t pwm_channel; uint8_t pwm_res = PWMRES; + uint16_t dutycycle = 0; uint8_t dutycycle_min; uint8_t dutycycle_max; uint8_t dir_1; diff --git a/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp b/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp index 8145ac1..55b354d 100644 --- a/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp +++ b/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp @@ -42,6 +42,16 @@ void MenuManualControl::printPage() const { lineOne.concat(this->manualControl->getMaxRotation()); lineTwo = "Decrease by 0.1"; break; + + case 5: + lineOne = "Dutycycle Left:"; + lineTwo.concat(this->manualControl->getDutycycleLeft()); + break; + + case 6: + lineOne = "Dutycycle Right:"; + lineTwo.concat(this->manualControl->getDutycycleRight()); + break; default: this->printDefault(); @@ -55,7 +65,8 @@ void MenuManualControl::init() { this->firstPrint = false; this->driveManager->changeModus(Modi::ManualControl); this->manualControl = (ManualControl*) this->driveManager->getDriveModiPtr(); - this->setCountPages(5); + this->setCountPages(7); + this->updateDelay = 500; } void MenuManualControl::runCommand() const { diff --git a/src/driveModi/Modi/ManualControl/manualControl.h b/src/driveModi/Modi/ManualControl/manualControl.h index cb0295b..d478c44 100644 --- a/src/driveModi/Modi/ManualControl/manualControl.h +++ b/src/driveModi/Modi/ManualControl/manualControl.h @@ -76,6 +76,9 @@ class ManualControl : public DriveModi { void decreaseMaxRotation(double increase = 0.1) { max_rotation -= increase; } double getMaxRotation() { return this->max_rotation; } + uint16_t getDutycycleLeft() const { return this->moveControl->getDutycycleLeft(); } + uint16_t getDutycycleRight() const { return this->moveControl->getDutycycleRight(); } + protected: MoveControl *moveControl; const ControlPadInput* input; diff --git a/src/moveControl.cpp b/src/moveControl.cpp index 8992dc4..d36a9ad 100644 --- a/src/moveControl.cpp +++ b/src/moveControl.cpp @@ -123,7 +123,7 @@ void MoveControl::emergencyStop() { } void MoveControl::setSpeed(double speed) { - if (speed < 0.1 && speed > -0.1) { + if (speed < 0.2 && speed > -0.2) { this->x_speed = 0; return; }