I'm working on a simple FFB rudder for MSFS2020. The rudder control has a range of -1.000 to 1.000 with 0 being centered. I need the negative range to display as a positive range (inverse). So that when I move the rudder either way from center it will go from 0 up to 1. Not sure how to do this in c++. Any help with the syntax?
You could use the abs() function.
float value;
float absValue;
void setup()
{
Serial.begin(115200);
while(!Serial);
value = 0.955;
absValue = abs(value);
Serial.println(value,3);
Serial.println(absValue,3);
value = -0.973;
absValue = abs(value);
Serial.println(value,3);
Serial.println(absValue,3);
}
void loop()
{
}
Gives...
13:23:46.589 -> 0.955
13:23:46.589 -> 0.955
13:23:46.589 -> -0.973
13:23:46.589 -> 0.973
1 Like
You can easily "roll your own"...
if (x < 0) x = 0 - x;
Thanks!
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.