Browse Source

higest and lowest values of a motor should be used instead of 255 and -255

master
Lukas Reichwein 5 years ago
parent
commit
ca92b344ac
  1. 16
      Code/libraries/Joystick/Steuerung.cpp

16
Code/libraries/Joystick/Steuerung.cpp

@ -19,16 +19,16 @@ void Steuerung::applyPWMValuesDependingOnReadings() {
(left -> PWMValue) = this -> yValue; (left -> PWMValue) = this -> yValue;
(right -> PWMValue) = (this -> yValue) - (this -> xValue); (right -> PWMValue) = (this -> yValue) - (this -> xValue);
if ((this -> xValue) >= (this -> yValue)) { if ((this -> xValue) >= (this -> yValue)) {
(left -> PWMValue) = 255;
(right -> PWMValue) = -255;
(left -> PWMValue) = left -> highestValue;
(right -> PWMValue) = right -> lowestValue;
} }
} else { } else {
//+y , -x //+y , -x
(left -> PWMValue) = this -> yValue; (left -> PWMValue) = this -> yValue;
(right -> PWMValue) = (this -> yValue) + (this -> xValue); (right -> PWMValue) = (this -> yValue) + (this -> xValue);
if (abs(this -> xValue) >= (this -> yValue)) { if (abs(this -> xValue) >= (this -> yValue)) {
(left -> PWMValue) = -255;
(right -> PWMValue) = 255;
(left -> PWMValue) = left -> lowestValue;
(right -> PWMValue) = right -> highestValue;
} }
} }
} else { } else {
@ -37,16 +37,16 @@ void Steuerung::applyPWMValuesDependingOnReadings() {
(left -> PWMValue) = this -> yValue; (left -> PWMValue) = this -> yValue;
(right -> PWMValue) = (this -> yValue) + (this -> xValue); (right -> PWMValue) = (this -> yValue) + (this -> xValue);
if (this -> xValue >= abs(this -> yValue)) { if (this -> xValue >= abs(this -> yValue)) {
(left -> PWMValue) = 255;
(right -> PWMValue) = -255;
(left -> PWMValue) = left -> highestValue;
(right -> PWMValue) = right -> lowestValue;
} }
} else { } else {
//-y , -x //-y , -x
(left -> PWMValue) = this -> yValue; (left -> PWMValue) = this -> yValue;
(right -> PWMValue) = (this -> yValue) - (this -> xValue); (right -> PWMValue) = (this -> yValue) - (this -> xValue);
if (abs(this -> xValue) >= abs(this -> yValue)) { if (abs(this -> xValue) >= abs(this -> yValue)) {
(left -> PWMValue) = -255;
(right -> PWMValue) = 255;
(left -> PWMValue) = left -> lowestValue;
(right -> PWMValue) = right -> highestValue;
} }
} }
} }

Loading…
Cancel
Save