Fix 3 bugs
This commit is contained in:
parent
ed9a22b1c7
commit
2d63fcc58f
3 changed files with 8 additions and 5 deletions
|
@ -170,7 +170,7 @@ class Motor(object):
|
|||
if speed < min(curve) or speed > max(curve):
|
||||
raise ValueError(f'Speed out of range: {str(speed)} ticks/s')
|
||||
|
||||
for index in range(len(curve) - 2):
|
||||
for index in range(len(curve) - 1):
|
||||
if speed >= curve[index] and speed <= curve[index + 1] and curve[index] != curve[index + 1]:
|
||||
return Motor.__map(speed, curve[index], curve[index + 1], index * 5, index * 5 + 5)
|
||||
|
||||
|
@ -184,7 +184,10 @@ class Motor(object):
|
|||
if power < 0 or power > 100:
|
||||
raise ValueError(f'Power out of range: {str(power)}%')
|
||||
|
||||
print(power)
|
||||
requiredSpeed = Motor.__map(power, 0, 100, min(curve), max(curve))
|
||||
print(requiredSpeed)
|
||||
|
||||
return Motor.__interpolateSpeed(curve, requiredSpeed)
|
||||
|
||||
|
||||
|
|
Reference in a new issue