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 -1
View File
@@ -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) {
+3
View File
@@ -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;