Skip to content

Commit 3c74337

Browse files
committed
update variables
1 parent 9f85971 commit 3c74337

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

code.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414
BG_DIRECTION = [0, 'direction']
1515
DATA_AGE = [0, 'date']
1616

17-
# Alert Colors
17+
# Display Colors
1818
RED = 0xFF0000; # CRIT HIGH, CRIT LOW
1919
ORANGE = 0xFFA500; # WARN LOW
2020
YELLOW = 0xFFFF00; # WARN HIGH
2121
GREEN = 0x00FF00; # BASE
2222
PURPLE = 0x800080; # STALE DATA
23+
BLACK = 0x000000; # TEXT
2324

2425
# Alert Levels
2526
CRIT_HIGH = 280
@@ -33,8 +34,6 @@ def stale_data(timestamp):
3334
# This is in minutessd
3435
stale_time = 6
3536

36-
stale = False
37-
3837
# Get the current timestamp in GMT
3938
epoch_time = time.time()
4039
print("Epoch GMT time:", epoch_time)
@@ -49,11 +48,12 @@ def stale_data(timestamp):
4948
print("Data age: ", last_check)
5049

5150
if last_check > stale_time:
52-
stale = True
51+
return True
5352
else:
54-
stale = False
53+
return False
5554

56-
return stale
55+
# In the case where we have no idea, don't trust the data
56+
return True
5757

5858
def get_bg_color(val, timestamp):
5959
if stale_data(timestamp):
@@ -70,7 +70,9 @@ def get_bg_color(val, timestamp):
7070
return GREEN
7171

7272
def text_transform_bg(val):
73-
return str(val) + ' mg/dl'
73+
74+
# If you are outside the US you may want to change this
75+
return str(val) + ' mg/dl'
7476

7577
def text_transform_direction(val):
7678
if val == "Flat":
@@ -92,19 +94,19 @@ def text_transform_direction(val):
9294
# the current working directory (where this file is)
9395
cwd = ("/"+__file__).rsplit('/', 1)[0]
9496
pyportal = PyPortal(url=DATA_SOURCE,
95-
headers={'api-secret': secrets['api_key']},
96-
caption_text=secrets['human'],
97+
headers={'api-secret': secrets['api_key']}, # If you don't have auth on your site you can ignore this
98+
caption_text=secrets['human'], # Name of the person you are following
9799
caption_position=(100, 80), # This is going to be subjective to the length of the name
98100
caption_font=cwd+"/fonts/Arial-Bold-24-Complete.bdf",
99-
caption_color=0x000000,
101+
caption_color=BLACK, # Black text is easier to read, feel free to change it
100102
json_path=(BG_VALUE, BG_DIRECTION, DATA_AGE),
101103
status_neopixel=board.NEOPIXEL,
102104
default_bg=0xFFFFFF,
103105
text_font=cwd+"/fonts/Arial-Bold-24-Complete.bdf",
104106
text_position=((90, 120), # VALUE location
105107
(140, 160)), # DIRECTION location
106-
text_color=(0x000000, # sugar text color
107-
0x000000), # direction text color
108+
text_color=(BLACK, # sugar text color
109+
BLACK), # direction text color
108110
text_wrap=(35, # characters to wrap for sugar
109111
0), # no wrap for direction
110112
text_maxlen=(180, 30), # max text size for sugar & direction
@@ -124,6 +126,6 @@ def text_transform_direction(val):
124126
print("Response is", value)
125127

126128
except RuntimeError as e:
127-
print("Some error occured, retrying! -", e)
129+
print("An error occured, retrying! -", e)
128130
time.sleep(180)
129131

secrets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
# keep it a secret.
55

66
secrets = {
7-
'ssid' : '', # Keep the two '' quotes around the name
8-
'password' : '', # Keep the two '' quotes around password
7+
'ssid' : '', # Wifi SSID you are connecting to
8+
'password' : '', # Wifi password, you do have one right?
99
'api_key': '', # This needs to be a sha1 hash of the api secret
1010
'timezone' : "Africa/Abidjan", # http://worldtimeapi.org/timezones
1111
'aio_username' : '', # free, needed for the timestamp https://io.adafruit.com/

0 commit comments

Comments
 (0)