added dutyCycle to menuManualControl

This commit is contained in:
2023-05-22 22:10:54 +02:00
parent 77b7eeae92
commit a310be0f6c
6 changed files with 25 additions and 3 deletions
+3
View File
@@ -154,6 +154,9 @@ class MoveControl {
*/ */
Speedometer* getSpeedometerRight() const { return this->right_speedometer; } 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 * @brief Set the min delay between each loop
* *
+3 -1
View File
@@ -159,7 +159,7 @@ bool MotorControl::isAccelerationNegative() {
void MotorControl::setRealPower(int8_t power) { void MotorControl::setRealPower(int8_t power) {
//TODO: Exceptionhandling //TODO: Exceptionhandling
if (power <= 100 || power <= -100) { if (power <= 100 && power >= -100) {
this->power = power; this->power = power;
} else { } else {
return; return;
@@ -170,6 +170,7 @@ void MotorControl::setRealPower(int8_t power) {
digitalWrite(this->dir_1, LOW); digitalWrite(this->dir_1, LOW);
digitalWrite(this->dir_2, LOW); digitalWrite(this->dir_2, LOW);
ledcWrite(this->pwm_channel, 0); ledcWrite(this->pwm_channel, 0);
this->dutycycle = 0;
return; return;
} }
@@ -186,6 +187,7 @@ void MotorControl::setRealPower(int8_t power) {
} }
ledcWrite(this->pwm_channel, pwm_val); ledcWrite(this->pwm_channel, pwm_val);
this->dutycycle = pwm_val;
} }
void MotorControl::increasePower(int8_t power) { void MotorControl::increasePower(int8_t power) {
+3
View File
@@ -142,6 +142,8 @@ class MotorControl {
* @return int8_t percent of power (-100 to 100) * @return int8_t percent of power (-100 to 100)
*/ */
int8_t getTargetPower(); int8_t getTargetPower();
uint16_t getDutycycle() const { return this->dutycycle; }
bool isTargetPowerReached(); bool isTargetPowerReached();
bool isAccelerationPositive(); bool isAccelerationPositive();
bool isAccelerationNegative(); bool isAccelerationNegative();
@@ -157,6 +159,7 @@ class MotorControl {
uint8_t pwm_pin; uint8_t pwm_pin;
uint8_t pwm_channel; uint8_t pwm_channel;
uint8_t pwm_res = PWMRES; uint8_t pwm_res = PWMRES;
uint16_t dutycycle = 0;
uint8_t dutycycle_min; uint8_t dutycycle_min;
uint8_t dutycycle_max; uint8_t dutycycle_max;
uint8_t dir_1; uint8_t dir_1;
@@ -43,6 +43,16 @@ void MenuManualControl::printPage() const {
lineTwo = "Decrease by 0.1"; lineTwo = "Decrease by 0.1";
break; break;
case 5:
lineOne = "Dutycycle Left:";
lineTwo.concat(this->manualControl->getDutycycleLeft());
break;
case 6:
lineOne = "Dutycycle Right:";
lineTwo.concat(this->manualControl->getDutycycleRight());
break;
default: default:
this->printDefault(); this->printDefault();
return; return;
@@ -55,7 +65,8 @@ void MenuManualControl::init() {
this->firstPrint = false; this->firstPrint = false;
this->driveManager->changeModus(Modi::ManualControl); this->driveManager->changeModus(Modi::ManualControl);
this->manualControl = (ManualControl*) this->driveManager->getDriveModiPtr(); this->manualControl = (ManualControl*) this->driveManager->getDriveModiPtr();
this->setCountPages(5); this->setCountPages(7);
this->updateDelay = 500;
} }
void MenuManualControl::runCommand() const { void MenuManualControl::runCommand() const {
@@ -76,6 +76,9 @@ class ManualControl : public DriveModi {
void decreaseMaxRotation(double increase = 0.1) { max_rotation -= increase; } void decreaseMaxRotation(double increase = 0.1) { max_rotation -= increase; }
double getMaxRotation() { return this->max_rotation; } double getMaxRotation() { return this->max_rotation; }
uint16_t getDutycycleLeft() const { return this->moveControl->getDutycycleLeft(); }
uint16_t getDutycycleRight() const { return this->moveControl->getDutycycleRight(); }
protected: protected:
MoveControl *moveControl; MoveControl *moveControl;
const ControlPadInput* input; const ControlPadInput* input;
+1 -1
View File
@@ -123,7 +123,7 @@ void MoveControl::emergencyStop() {
} }
void MoveControl::setSpeed(double speed) { void MoveControl::setSpeed(double speed) {
if (speed < 0.1 && speed > -0.1) { if (speed < 0.2 && speed > -0.2) {
this->x_speed = 0; this->x_speed = 0;
return; return;
} }