1111import time
1212import board
1313from adafruit_pyportal import PyPortal
14+ from adafruit_pyportal .network import CONTENT_JSON
1415
1516cwd = ("/" + __file__ ).rsplit ('/' , 1 )[0 ] # the current working directory (where this file is)
1617
@@ -34,7 +35,7 @@ def identity(x):
3435 default_bg = cwd + "/on_this_day_bg.bmp" ,
3536 text_font = cwd + "fonts/Arial-ItalicMT-17.bdf" ,
3637 text_transform = [identity ]* 6 , # we do this so the date doesnt get commas
37- text_position = ((10 , 70 ), (10 , 100 ), (10 , 130 ),(60 , 160 ), (105 , 190 ), (10 , 220 )),
38+ text_position = ((10 , 60 ), (10 , 90 ), (10 , 120 ),(60 , 150 ), (105 , 180 ), (10 , 210 )),
3839 text_color = (0xFFFFFF , 0xFFFFFF , 0xFFFFFF , 0xFFFFFF , 0xFFFFFF , 0xFFFFFF ),
3940 text_maxlen = (50 , 50 , 50 , 50 , 50 , 50 ), # cut off characters
4041 )
@@ -54,13 +55,13 @@ def identity(x):
5455 print (url )
5556 response = None
5657 try :
57- response = pyportal .fetch (url )
58+ response = pyportal .fetch (url , force_content_type = CONTENT_JSON )
5859 print ("Response is" , response )
5960 except RuntimeError as e :
6061 print ("Some error occured, retrying! -" , e )
6162
6263 # Make a QR code from web reference
63- pyportal .show_QR (bytearray (response [5 ]), qr_size = 3 ,
64+ pyportal .show_QR (bytearray (response [5 ], "utf-8" ), qr_size = 3 ,
6465 x = 220 , y = 10 )
6566
6667 # wait 10 minutes before running again
0 commit comments