From 8f2944da715a08f568e26d9518d9558b70144ce1 Mon Sep 17 00:00:00 2001 From: Konstantin Lampalzer Date: Sun, 12 Sep 2021 13:42:55 +0200 Subject: [PATCH] Documentation --- compLib/Display.py | 9 +++++++++ compLib/IRSensor.py | 12 ++++++++++++ compLib/MetricsLogging.py | 15 ++++++++++++++- compLib/Reset.py | 5 +++++ 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/compLib/Display.py b/compLib/Display.py index 3253f16..82ad451 100644 --- a/compLib/Display.py +++ b/compLib/Display.py @@ -13,6 +13,12 @@ class Display(object): @staticmethod def write(line: int, text: string): + """Write a string of text to the integrated display. + + :param line: Line to write. Between 1 and 4 + :param text: Text to write. Up to 16 characters + :raises: IndexError + """ if len(text) > CHARS_PER_LINE: logstash_logger.error(f"Too many characters specified!") return @@ -35,5 +41,8 @@ class Display(object): @staticmethod def clear(): + """Clear the display + + """ for i in range(1, LINE_COUNT + 1): Display.write(i, "") diff --git a/compLib/IRSensor.py b/compLib/IRSensor.py index f2747af..8e679f9 100644 --- a/compLib/IRSensor.py +++ b/compLib/IRSensor.py @@ -11,6 +11,13 @@ class IRSensor(object): @staticmethod def read(sensor: int) -> int: + """Read one infrared sensor + + :param sensor: Which sensor to read. Between 1 and 5 + :raises: IndexError + :return: Sensor value. 10 bit accuracy + :rtype: int + """ if sensor <= 0 or sensor > SENSOR_COUNT: raise IndexError("Invalid sensor specified!") @@ -31,6 +38,11 @@ class IRSensor(object): @staticmethod def set(sensor: int, on: bool): + """Turn on / off a IR emitter + + :param sensor: Which sensor to read. Between 1 and 5 + :raises: IndexError + """ if sensor <= 0 or sensor > SENSOR_COUNT: raise IndexError("Invalid sensor specified!") diff --git a/compLib/MetricsLogging.py b/compLib/MetricsLogging.py index 24f3099..5fc4ee2 100644 --- a/compLib/MetricsLogging.py +++ b/compLib/MetricsLogging.py @@ -32,9 +32,16 @@ point_queue = queue.Queue() workers = [] class MetricsLogging(): + """Used to send metrics / points to a influxdb + """ @staticmethod - def is_influx_reachable(): + def is_influx_reachable() -> bool: + """Check if we can send metrics to the database + + :return: Is reachable? + :rtype: bool + """ try: r = requests.get(INFLUX_HOST) if r.status_code == 200: @@ -47,6 +54,12 @@ class MetricsLogging(): @staticmethod def put(sensorType, value, port): + """Put a datapoint into a time-series-database + + :param sensorType: A key used to identify a datapoint + :param value: Value measured by the sensor + :param port: Port of the sensor which was read + """ if EXTENSIVE_LOGGING: point = Point(sensorType) \ .tag("host", HOSTNAME) \ diff --git a/compLib/Reset.py b/compLib/Reset.py index 34194c5..dd52a60 100644 --- a/compLib/Reset.py +++ b/compLib/Reset.py @@ -6,8 +6,13 @@ RESET_PIN = 23 BOOT_PIN = 17 class Reset: + """Reset the co-processor + """ + @staticmethod def reset_bot(): + """Reset the co-processor + """ GPIO.setmode(GPIO.BCM) GPIO.setup(RESET_PIN, GPIO.OUT) GPIO.setup(BOOT_PIN, GPIO.OUT)