Skip to content

Commit 0d6394c

Browse files
committed
add pics and update local data source
1 parent 6bab570 commit 0d6394c

4 files changed

Lines changed: 16 additions & 19 deletions

File tree

PyPortal_on_this_day/code.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,36 @@
11
import random
22
import board
3-
import adafruit_pyportal
3+
import time
4+
from adafruit_pyportal import PyPortal
45

56
cwd = ("/"+__file__).rsplit('/', 1)[0] # the current working directory (where this file is)
67

78
DAY = ["Day of the year"]
89
PERSON = ["Person"]
910
NOTABLE = ["Notable for"]
10-
YEAR = ["year"]
11+
YEAR = ["Year"]
1112
ACCOMPLISH = ["Accomplishment"]
1213
WEB = ["Web Reference"]
1314

14-
DATA = Fake_Requests(cwd+"/jan1_history_json.py")
15+
DATA = cwd+"/local.txt"
1516

1617
# create pyportal object w no data source (we'll feed it text later)
1718
pyportal = PyPortal(url = DATA,
1819
json_path = (DAY, PERSON, NOTABLE, YEAR, ACCOMPLISH, WEB),
1920
status_neopixel = board.NEOPIXEL,
20-
default_bg = None,
21+
default_bg = cwd + "/mary_jan1.bmp",
2122
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_position=((10, 70), (10, 100), (10, 130),(60, 160), (105, 190), (10, 220)),
2324
text_color=(0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF),
2425
text_maxlen=(50, 50, 50, 50, 50, 50), # cut off characters
2526
)
2627

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-
3128
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)
29+
response = None
30+
try:
31+
response = pyportal.fetch()
32+
print("Response is", response)
33+
except RuntimeError as e:
34+
print("Some error occured, retrying! -", e)
35+
36+
time.sleep(60)
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"Day of the year":"January 1",
33
"Person":"Mary Acworth Evershed",
4-
"Notable for":"Astronomer, Scholor, born",
4+
"Notable for":"Astronomer, Scholar",
55
"Year":"1867",
66
"Accomplishment":"Solar Eclipse documentation",
7-
"Web Reference": "https://en.wikipedia.org/wiki/Mary_Acworth_Evershed",
7+
"Web Reference": "wikipedia.org/wiki/Mary_Acworth_Evershed",
88
}

PyPortal_on_this_day/mary_jan1.bmp

150 KB
Binary file not shown.
150 KB
Binary file not shown.

0 commit comments

Comments
 (0)