14
14
BG_DIRECTION = [0 , 'direction' ]
15
15
DATA_AGE = [0 , 'date' ]
16
16
17
- # Alert Colors
17
+ # Display Colors
18
18
RED = 0xFF0000 ; # CRIT HIGH, CRIT LOW
19
19
ORANGE = 0xFFA500 ; # WARN LOW
20
20
YELLOW = 0xFFFF00 ; # WARN HIGH
21
21
GREEN = 0x00FF00 ; # BASE
22
22
PURPLE = 0x800080 ; # STALE DATA
23
+ BLACK = 0x000000 ; # TEXT
23
24
24
25
# Alert Levels
25
26
CRIT_HIGH = 280
@@ -33,8 +34,6 @@ def stale_data(timestamp):
33
34
# This is in minutessd
34
35
stale_time = 6
35
36
36
- stale = False
37
-
38
37
# Get the current timestamp in GMT
39
38
epoch_time = time .time ()
40
39
print ("Epoch GMT time:" , epoch_time )
@@ -49,11 +48,12 @@ def stale_data(timestamp):
49
48
print ("Data age: " , last_check )
50
49
51
50
if last_check > stale_time :
52
- stale = True
51
+ return True
53
52
else :
54
- stale = False
53
+ return False
55
54
56
- return stale
55
+ # In the case where we have no idea, don't trust the data
56
+ return True
57
57
58
58
def get_bg_color (val , timestamp ):
59
59
if stale_data (timestamp ):
@@ -70,7 +70,9 @@ def get_bg_color(val, timestamp):
70
70
return GREEN
71
71
72
72
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'
74
76
75
77
def text_transform_direction (val ):
76
78
if val == "Flat" :
@@ -92,19 +94,19 @@ def text_transform_direction(val):
92
94
# the current working directory (where this file is)
93
95
cwd = ("/" + __file__ ).rsplit ('/' , 1 )[0 ]
94
96
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
97
99
caption_position = (100 , 80 ), # This is going to be subjective to the length of the name
98
100
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
100
102
json_path = (BG_VALUE , BG_DIRECTION , DATA_AGE ),
101
103
status_neopixel = board .NEOPIXEL ,
102
104
default_bg = 0xFFFFFF ,
103
105
text_font = cwd + "/fonts/Arial-Bold-24-Complete.bdf" ,
104
106
text_position = ((90 , 120 ), # VALUE location
105
107
(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
108
110
text_wrap = (35 , # characters to wrap for sugar
109
111
0 ), # no wrap for direction
110
112
text_maxlen = (180 , 30 ), # max text size for sugar & direction
@@ -124,6 +126,6 @@ def text_transform_direction(val):
124
126
print ("Response is" , value )
125
127
126
128
except RuntimeError as e :
127
- print ("Some error occured, retrying! -" , e )
129
+ print ("An error occured, retrying! -" , e )
128
130
time .sleep (180 )
129
131
0 commit comments