def valMap(x, in_min, in_max, out_min, out_max):
return ((x - in_min) * (out_max - out_min)) // (in_max - in_min) + out_min
def limit(self, input):
if -0.2 <= input <= 0.2:
input = 192
if input < -0.2:
input = valMap(input, -0.2, -1, 138, 192)
if input > 0.2:
input = valMap(input, 0.2, 1, 192, 242)
return input
The input's value ranges from -1 to +1 float. This only works as expected in the last if statement. All other if statements throw out strange numbers.
This did work in Python2.
Thank you