|
|
|
|
@ -208,6 +208,7 @@ def main():
|
|
|
|
|
delay = DEFAULT_INTERVAL
|
|
|
|
|
|
|
|
|
|
show_on_screen = False
|
|
|
|
|
show_in_terminal = True
|
|
|
|
|
if 'SCREEN' in config:
|
|
|
|
|
if 'TYPE' not in config['SCREEN']:
|
|
|
|
|
logging.fatal("no screen type in config file")
|
|
|
|
|
@ -262,6 +263,11 @@ def main():
|
|
|
|
|
def clear_display():
|
|
|
|
|
display.clear()
|
|
|
|
|
|
|
|
|
|
if "DISPLAY_IN_TERMINAL" in config['SCREEN']:
|
|
|
|
|
if config['SCREEN']['DISPLAY_IN_TERMINAL'].lower() == "false":
|
|
|
|
|
show_in_terminal = False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
libreview_session = LibreViewSession()
|
|
|
|
|
libreview_session.authenticate(config['CREDENTIALS']['EMAIL'], config['CREDENTIALS']['PASSWORD'])
|
|
|
|
|
|
|
|
|
|
@ -289,13 +295,14 @@ def main():
|
|
|
|
|
if not SHOULD_EXIT and not first_run:
|
|
|
|
|
time.sleep(delay)
|
|
|
|
|
elif first_run:
|
|
|
|
|
first_run = False
|
|
|
|
|
|
|
|
|
|
if show_in_terminal:
|
|
|
|
|
clear_terminal()
|
|
|
|
|
|
|
|
|
|
if show_on_screen:
|
|
|
|
|
clear_display()
|
|
|
|
|
|
|
|
|
|
first_run = False
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
graph = libreview_session.getGraph(patient_id)
|
|
|
|
|
except requests.exceptions.ConnectionError:
|
|
|
|
|
@ -314,12 +321,19 @@ def main():
|
|
|
|
|
logging.error("the data returned from the API was not in an expected format")
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
if show_on_screen:
|
|
|
|
|
clear_display()
|
|
|
|
|
|
|
|
|
|
glucoseMeasurement = graph['connection']['glucoseMeasurement']
|
|
|
|
|
|
|
|
|
|
print("Timestamp: ", glucoseMeasurement['Timestamp'], "\n")
|
|
|
|
|
print("Glucose units:",glucoseMeasurement['Value'])
|
|
|
|
|
print("Is high: ", glucoseMeasurement['isHigh'])
|
|
|
|
|
print("Is low: ", glucoseMeasurement['isLow'])
|
|
|
|
|
if show_in_terminal:
|
|
|
|
|
clear_terminal()
|
|
|
|
|
|
|
|
|
|
print(f"Timestamp: {glucoseMeasurement['Timestamp']}\n")
|
|
|
|
|
print(f"Glucose units: {glucoseMeasurement['Value']}")
|
|
|
|
|
print(f"Is high: {glucoseMeasurement['isHigh']}")
|
|
|
|
|
print(f"Is low: {glucoseMeasurement['isLow']}")
|
|
|
|
|
print(f"Refresh rate: {delay} seconds")
|
|
|
|
|
|
|
|
|
|
if show_on_screen:
|
|
|
|
|
draw.text((x, top), glucoseMeasurement['Timestamp'], font=font, fill=255)
|
|
|
|
|
|