Added configuration option: DISPLAY_IN_TERMINAL

This allows you to turn of displaying the data to the terminal if your
using glucose-monitor with a Raspberry Pi display.
master
Ronald 1 year ago
parent 22071bbe8d
commit c0cb6e12ec

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

Loading…
Cancel
Save