Fix 3 bugs

This commit is contained in:
root 2022-02-04 16:36:06 +00:00
parent ed9a22b1c7
commit 2d63fcc58f
3 changed files with 8 additions and 5 deletions

View file

@ -71,10 +71,10 @@ class MetricsLogging():
@staticmethod
def worker():
while True:
point = object()
for job in iter(point_queue.get, point):
try:
points = point_queue.get_many()
write_api.write(BUCKET, ORG, points)
write_api.write(BUCKET, ORG, point)
time.sleep(0.1)
except Exception as e:
pass

View file

@ -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)

View file

@ -205,7 +205,7 @@ class Spi(object):
def health_check_loop():
while SPI_HEALTH:
Spi.health_check()
time.sleep(5)
time.sleep(0.75)
@staticmethod
def get_version():