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
|
||||
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, "")
|
||||
|
|
|
@ -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!")
|
||||
|
||||
|
|
|
@ -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) \
|
||||
|
|
|
@ -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)
|
||||
|
|
Reference in a new issue