From 2d63fcc58f5ccd0cd32f74d150cf8b5df1f3fc70 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 4 Feb 2022 16:36:06 +0000 Subject: [PATCH] Fix 3 bugs --- compLib/MetricsLogging.py | 6 +++--- compLib/Motor.py | 5 ++++- compLib/Spi.py | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/compLib/MetricsLogging.py b/compLib/MetricsLogging.py index 0501a2c..4535af5 100644 --- a/compLib/MetricsLogging.py +++ b/compLib/MetricsLogging.py @@ -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 diff --git a/compLib/Motor.py b/compLib/Motor.py index 426c6ee..9cafbcb 100644 --- a/compLib/Motor.py +++ b/compLib/Motor.py @@ -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) diff --git a/compLib/Spi.py b/compLib/Spi.py index d342178..ad712a9 100644 --- a/compLib/Spi.py +++ b/compLib/Spi.py @@ -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():