Skip to content

Commit d243064

Browse files
committed
init commit
1 parent df82a50 commit d243064

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

PyPortal_on_this_day/code.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import random
2+
import board
3+
import adafruit_pyportal
4+
5+
cwd = ("/"+__file__).rsplit('/', 1)[0] # the current working directory (where this file is)
6+
7+
DAY = ["Day of the year"]
8+
PERSON = ["Person"]
9+
NOTABLE = ["Notable for"]
10+
YEAR = ["year"]
11+
ACCOMPLISH = ["Accomplishment"]
12+
WEB = ["Web Reference"]
13+
14+
DATA = Fake_Requests(cwd+"/jan1_hist_json.py")
15+
16+
# create pyportal object w no data source (we'll feed it text later)
17+
pyportal = PyPortal(url = DATA,
18+
json_path = (DAY, PERSON, NOTABLE, YEAR, ACCOMPLISH, WEB),
19+
status_neopixel = board.NEOPIXEL,
20+
default_bg = None,
21+
text_font = cwd+"fonts/Arial-ItalicMT-17.bdf",
22+
text_position=((5, 10), (5, 50), (5, 90),(5, 130), (5, 170), (5, 210)),
23+
text_color=(0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF),
24+
text_maxlen=(50, 50, 50, 50, 50, 50), # cut off characters
25+
)
26+
27+
pyportal.set_text("loading ...") # display while user waits
28+
pyportal.preload_font() # speed things up by preloading font
29+
pyportal.set_text("What happened today in history?") # show title
30+
31+
while True:
32+
if pyportal.touchscreen.touch_point:
33+
while True:
34+
response = None
35+
try:
36+
response = pyportal.fetch()
37+
print("Response is", response)
38+
except RuntimeError as e:
39+
print("Some error occured, retrying! -", e)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"Day of the year":"January 1",
3+
"Person":"Mary Acworth Evershed",
4+
"Notable for":"Astronomer, Scholor, born",
5+
"year":"1867",
6+
"Accomplishment":"Solar Eclipse documentation",
7+
"Web Reference": "https://en.wikipedia.org/wiki/Mary_Acworth_Evershed",
8+
}

0 commit comments

Comments
 (0)