|
|
|
|
@ -1,5 +1,11 @@
|
|
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
glucose_monitor.py - A script to display glucose levels on a Raspberry Pi
|
|
|
|
|
|
|
|
|
|
Configurable with a config file
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
|
import configparser
|
|
|
|
|
@ -22,7 +28,8 @@ import yaml
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# CONSTANTS
|
|
|
|
|
DEFAULT_INTERVAL = 5
|
|
|
|
|
DEFAULT_DATA_REFRESH_INTERVAL = 5
|
|
|
|
|
DEFAULT_SCREEN_REFRESH_INTERVAL = 1
|
|
|
|
|
DEFAULT_FONT_SIZE = 9
|
|
|
|
|
DEFAULT_DEBUG_SCREEN_WIDTH = 128
|
|
|
|
|
DEFAULT_DEBUG_SCREEN_HEIGHT = 32
|
|
|
|
|
@ -260,7 +267,8 @@ def main():
|
|
|
|
|
logging.fatal("no password specified in config file")
|
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
|
delay = DEFAULT_INTERVAL
|
|
|
|
|
data_refresh_interval = DEFAULT_DATA_REFRESH_INTERVAL
|
|
|
|
|
screen_refresh_interval = DEFAULT_SCREEN_REFRESH_INTERVAL
|
|
|
|
|
font = "DEFAULT"
|
|
|
|
|
font_size = DEFAULT_FONT_SIZE
|
|
|
|
|
lines = [
|
|
|
|
|
@ -269,8 +277,10 @@ def main():
|
|
|
|
|
]
|
|
|
|
|
if "general" in config:
|
|
|
|
|
general_config = config["general"]
|
|
|
|
|
if "interval" in general_config:
|
|
|
|
|
delay = int(config["general"]["interval"])
|
|
|
|
|
if "data_refresh_interval" in general_config:
|
|
|
|
|
data_refresh_interval = int(config["general"]["data_refresh_interval"])
|
|
|
|
|
if "screen_refresh_interval" in general_config:
|
|
|
|
|
screen_refresh_interval = int(config["general"]["screen_refresh_interval"])
|
|
|
|
|
|
|
|
|
|
# TODO: Add format specifier to check if high and low
|
|
|
|
|
# if "upper_bound" in general_config:
|
|
|
|
|
@ -366,8 +376,6 @@ def main():
|
|
|
|
|
display.setDefaultFont()
|
|
|
|
|
|
|
|
|
|
while not SHOULD_EXIT:
|
|
|
|
|
display.clearScreen()
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
graph = libreview_session.getGraph(patient_id)
|
|
|
|
|
graph["connection"]["glucoseMeasurement"]
|
|
|
|
|
@ -386,13 +394,14 @@ def main():
|
|
|
|
|
except KeyError:
|
|
|
|
|
logging.error("the data returned from the API was not in an expected format")
|
|
|
|
|
|
|
|
|
|
computed_output_lines = []
|
|
|
|
|
for output_line in output_lines:
|
|
|
|
|
computed_output_lines.append(eval(f"f'{output_line}'"))
|
|
|
|
|
display.displayLines(computed_output_lines)
|
|
|
|
|
|
|
|
|
|
time.sleep(delay)
|
|
|
|
|
for _ in range(data_refresh_interval//screen_refresh_interval):
|
|
|
|
|
display.clearScreen()
|
|
|
|
|
computed_output_lines = []
|
|
|
|
|
for output_line in output_lines:
|
|
|
|
|
computed_output_lines.append(eval(f"f'{output_line}'"))
|
|
|
|
|
display.displayLines(computed_output_lines)
|
|
|
|
|
|
|
|
|
|
time.sleep(screen_refresh_interval)
|
|
|
|
|
|
|
|
|
|
logging.debug("exiting now...")
|
|
|
|
|
|