11import random
22import board
3- import adafruit_pyportal
3+ import time
4+ from adafruit_pyportal import PyPortal
45
56cwd = ("/" + __file__ ).rsplit ('/' , 1 )[0 ] # the current working directory (where this file is)
67
78DAY = ["Day of the year" ]
89PERSON = ["Person" ]
910NOTABLE = ["Notable for" ]
10- YEAR = ["year " ]
11+ YEAR = ["Year " ]
1112ACCOMPLISH = ["Accomplishment" ]
1213WEB = ["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)
1718pyportal = 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-
3128while 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 )
0 commit comments