Documentation
This commit is contained in:
parent
cbe3a379bd
commit
8f2944da71
4 changed files with 40 additions and 1 deletions
|
@ -13,6 +13,12 @@ class Display(object):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def write(line: int, text: string):
|
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:
|
if len(text) > CHARS_PER_LINE:
|
||||||
logstash_logger.error(f"Too many characters specified!")
|
logstash_logger.error(f"Too many characters specified!")
|
||||||
return
|
return
|
||||||
|
@ -35,5 +41,8 @@ class Display(object):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def clear():
|
def clear():
|
||||||
|
"""Clear the display
|
||||||
|
|
||||||
|
"""
|
||||||
for i in range(1, LINE_COUNT + 1):
|
for i in range(1, LINE_COUNT + 1):
|
||||||
Display.write(i, "")
|
Display.write(i, "")
|
||||||
|
|
|
@ -11,6 +11,13 @@ class IRSensor(object):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def read(sensor: int) -> int:
|
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:
|
if sensor <= 0 or sensor > SENSOR_COUNT:
|
||||||
raise IndexError("Invalid sensor specified!")
|
raise IndexError("Invalid sensor specified!")
|
||||||
|
|
||||||
|
@ -31,6 +38,11 @@ class IRSensor(object):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def set(sensor: int, on: bool):
|
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:
|
if sensor <= 0 or sensor > SENSOR_COUNT:
|
||||||
raise IndexError("Invalid sensor specified!")
|
raise IndexError("Invalid sensor specified!")
|
||||||
|
|
||||||
|
|
|
@ -32,9 +32,16 @@ point_queue = queue.Queue()
|
||||||
workers = []
|
workers = []
|
||||||
|
|
||||||
class MetricsLogging():
|
class MetricsLogging():
|
||||||
|
"""Used to send metrics / points to a influxdb
|
||||||
|
"""
|
||||||
|
|
||||||
@staticmethod
|
@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:
|
try:
|
||||||
r = requests.get(INFLUX_HOST)
|
r = requests.get(INFLUX_HOST)
|
||||||
if r.status_code == 200:
|
if r.status_code == 200:
|
||||||
|
@ -47,6 +54,12 @@ class MetricsLogging():
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def put(sensorType, value, port):
|
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:
|
if EXTENSIVE_LOGGING:
|
||||||
point = Point(sensorType) \
|
point = Point(sensorType) \
|
||||||
.tag("host", HOSTNAME) \
|
.tag("host", HOSTNAME) \
|
||||||
|
|
|
@ -6,8 +6,13 @@ RESET_PIN = 23
|
||||||
BOOT_PIN = 17
|
BOOT_PIN = 17
|
||||||
|
|
||||||
class Reset:
|
class Reset:
|
||||||
|
"""Reset the co-processor
|
||||||
|
"""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def reset_bot():
|
def reset_bot():
|
||||||
|
"""Reset the co-processor
|
||||||
|
"""
|
||||||
GPIO.setmode(GPIO.BCM)
|
GPIO.setmode(GPIO.BCM)
|
||||||
GPIO.setup(RESET_PIN, GPIO.OUT)
|
GPIO.setup(RESET_PIN, GPIO.OUT)
|
||||||
GPIO.setup(BOOT_PIN, GPIO.OUT)
|
GPIO.setup(BOOT_PIN, GPIO.OUT)
|
||||||
|
|
Reference in a new issue