Skip to content

Commit

Permalink
update variables
Browse files Browse the repository at this point in the history
  • Loading branch information
mattyjones committed May 18, 2019
1 parent 9f85971 commit 3c74337
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
28 changes: 15 additions & 13 deletions code.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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):
Expand All @@ -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":
Expand All @@ -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
Expand All @@ -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)

4 changes: 2 additions & 2 deletions secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down

0 comments on commit 3c74337

Please sign in to comment.