Skip to content

Commit 6ad280f

Browse files
committed
formatting changes
1 parent d7be911 commit 6ad280f

1 file changed

Lines changed: 21 additions & 10 deletions

File tree

Dashblock_API/dashblock_learn.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# Set up where we'll be fetching data from
1818
DATA_SOURCE = "https://api.dashblock.io/model/v1?api_key=39c755c0-c84e-11e9-8ee0-7bf8836bd560&url=https%3A%2F%2Flearn.adafruit.com%2F&model_id=3rOMRrfFn"
1919
GUIDE_COUNT = ['entities', 0, 'guide count']
20-
CAPTION = 'learn.adafruit.com'
20+
CAPTION = 'total tutorials:'
2121

2222
# determine the current working directory
2323
# needed so we know where to find files
@@ -28,26 +28,37 @@
2828
pyportal = PyPortal(url=DATA_SOURCE,
2929
json_path = (GUIDE_COUNT),
3030
status_neopixel=board.NEOPIXEL,
31-
#default_bg=cwd+"/wordoftheday_background.bmp",
32-
text_font=cwd+"/fonts/Arial-ItalicMT-17.bdf",
33-
text_position=((50, 100)), # definition location
31+
default_bg=cwd+"/adabot_cover.bmp",
32+
text_font=cwd+"/fonts/Collegiate-50.bdf",
33+
text_position=((40, 100)), # definition location
3434
text_color=(0x8080FF),
35-
text_wrap=(0),
36-
text_maxlen=(180), # max text size for word, part of speech and def
35+
text_wrap=(20),
36+
text_maxlen=(4), # max text size for word, part of speech and def
3737
caption_text=CAPTION,
38-
caption_font=cwd+"/fonts/Arial-ItalicMT-17.bdf",
39-
caption_position=(50, 220),
38+
caption_font=cwd+"/fonts/Collegiate-24.bdf",
39+
caption_position=(40, 60),
4040
caption_color=0xFFFFFF)
4141

42+
# track the last value so we can play a sound when it updates
43+
last_value = 0
44+
4245
print("loading...") # print to repl while waiting for font to load
4346
pyportal.preload_font() # speed things up by preloading font
4447

4548
while True:
4649
try:
47-
# pylint: disable=protected-access
4850
value = pyportal.fetch()
4951
print("Response is", value)
52+
int_value = int(value[:4])
53+
print(int_value)
54+
if last_value < int_value: # ooh it went up!
55+
print("New follower!")
56+
pyportal.play_file(cwd+"/coin.wav") # uncomment make a noise!
57+
last_value = int_value
5058
except RuntimeError as e:
5159
print("Some error occured, retrying! -", e)
60+
except ValueError as e:
61+
print("Value error occured, retrying! -", e)
62+
continue
5263

53-
time.sleep(3600) #update every hour
64+
time.sleep(600) #update every 10 mins

0 commit comments

Comments
 (0)