From 3c743371b0729ae441129f4eaa4b727fd98687a7 Mon Sep 17 00:00:00 2001 From: Matt Jones Date: Sat, 18 May 2019 11:52:23 -0400 Subject: [PATCH] update variables --- code.py | 28 +++++++++++++++------------- secrets.py | 4 ++-- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/code.py b/code.py index 69fcce3..a54c7b0 100644 --- a/code.py +++ b/code.py @@ -14,12 +14,13 @@ BG_DIRECTION = [0, 'direction'] DATA_AGE = [0, 'date'] -# Alert Colors +# Display Colors RED = 0xFF0000; # CRIT HIGH, CRIT LOW ORANGE = 0xFFA500; # WARN LOW YELLOW = 0xFFFF00; # WARN HIGH GREEN = 0x00FF00; # BASE PURPLE = 0x800080; # STALE DATA +BLACK = 0x000000; # TEXT # Alert Levels CRIT_HIGH = 280 @@ -33,8 +34,6 @@ def stale_data(timestamp): # This is in minutessd stale_time = 6 - stale = False - # Get the current timestamp in GMT epoch_time = time.time() print("Epoch GMT time:", epoch_time) @@ -49,11 +48,12 @@ def stale_data(timestamp): print("Data age: ", last_check) if last_check > stale_time: - stale = True + return True else: - stale = False + return False - return stale + # In the case where we have no idea, don't trust the data + return True def get_bg_color(val, timestamp): if stale_data(timestamp): @@ -70,7 +70,9 @@ def get_bg_color(val, timestamp): return GREEN def text_transform_bg(val): - return str(val) + ' mg/dl' + + # If you are outside the US you may want to change this + return str(val) + ' mg/dl' def text_transform_direction(val): if val == "Flat": @@ -92,19 +94,19 @@ def text_transform_direction(val): # the current working directory (where this file is) cwd = ("/"+__file__).rsplit('/', 1)[0] pyportal = PyPortal(url=DATA_SOURCE, - headers={'api-secret': secrets['api_key']}, - caption_text=secrets['human'], + headers={'api-secret': secrets['api_key']}, # If you don't have auth on your site you can ignore this + caption_text=secrets['human'], # Name of the person you are following caption_position=(100, 80), # This is going to be subjective to the length of the name caption_font=cwd+"/fonts/Arial-Bold-24-Complete.bdf", - caption_color=0x000000, + caption_color=BLACK, # Black text is easier to read, feel free to change it json_path=(BG_VALUE, BG_DIRECTION, DATA_AGE), status_neopixel=board.NEOPIXEL, default_bg=0xFFFFFF, text_font=cwd+"/fonts/Arial-Bold-24-Complete.bdf", text_position=((90, 120), # VALUE location (140, 160)), # DIRECTION location - text_color=(0x000000, # sugar text color - 0x000000), # direction text color + text_color=(BLACK, # sugar text color + BLACK), # direction text color text_wrap=(35, # characters to wrap for sugar 0), # no wrap for direction text_maxlen=(180, 30), # max text size for sugar & direction @@ -124,6 +126,6 @@ def text_transform_direction(val): print("Response is", value) except RuntimeError as e: - print("Some error occured, retrying! -", e) + print("An error occured, retrying! -", e) time.sleep(180) diff --git a/secrets.py b/secrets.py index 180f91a..3266c24 100644 --- a/secrets.py +++ b/secrets.py @@ -4,8 +4,8 @@ # keep it a secret. secrets = { - 'ssid' : '', # Keep the two '' quotes around the name - 'password' : '', # Keep the two '' quotes around password + 'ssid' : '', # Wifi SSID you are connecting to + 'password' : '', # Wifi password, you do have one right? 'api_key': '', # This needs to be a sha1 hash of the api secret 'timezone' : "Africa/Abidjan", # http://worldtimeapi.org/timezones 'aio_username' : '', # free, needed for the timestamp https://io.adafruit.com/