added dutyCycle to menuManualControl
This commit is contained in:
@@ -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
|
||||
*
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
+1
-1
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user