Keine Ahnung, ob das hilft, probiers einfach aus:
Code:
// Calculate joystick data to tank mixed control
private void CalculateTankCoordinates()
{
double d = 0;
int A = 0, B = 0;
d = ((MaxY - System.Math.Abs(ValueY)) * (System.Math.Abs(ValueX) / MaxX));
if (ValueX >= 0)
{
A = (int)(ValueY + d);
B = (int)(ValueY - d);
}
else
{
A = (int)(ValueY - d);
B = (int)(ValueY + d);
}
ValueLeft = A;
ValueRight = B;
}
Mit ValueX/Y: Eingangswerte
MaxX/MaxY: Maximalausschläge
ValueLeft/Right: Ausgangswerte als int konvertiert (so ne PWM kann ja mit doubles nix anfangen)
Lesezeichen