10
10
import busio
11
11
from digitalio import DigitalInOut
12
12
from adafruit_espatcontrol import adafruit_espatcontrol
13
+ from adafruit_espatcontrol import adafruit_espatcontrol_requests as requests
13
14
import ujson
14
15
from adafruit_epd .epd import Adafruit_EPD
15
16
from adafruit_epd .il0373 import Adafruit_IL0373
48
49
rts_pin = rtspin , debug = True )
49
50
esp .hard_reset ()
50
51
52
+ requests .set_interface (esp )
53
+
51
54
# Extract a value from a json string
52
55
def get_value (response , location ):
53
56
"""Extract a value from a json object, based on the path in 'location'"""
@@ -172,13 +175,13 @@ def draw_bmp(filename, x, y): # pylint: disable=too-many-locals, too-many-branch
172
175
# great, lets get the data
173
176
174
177
print ("Retrieving data source..." , end = '' )
175
- header , body = esp . request_url (DATA_SOURCE )
178
+ req = requests . get (DATA_SOURCE )
176
179
print ("Reply is OK!" )
177
180
except (RuntimeError , adafruit_espatcontrol .OKError ) as e :
178
181
print ("Failed to get data, retrying\n " , e )
179
182
continue
180
183
181
- body = body . split ( b' \n ' )[ 1 ] # unclear why but there's extra data at beginning/end
184
+ body = req . text
182
185
print ('-' * 40 , "Size: " , len (body ))
183
186
print (str (body , 'utf-8' ))
184
187
print ('-' * 40 )
@@ -193,13 +196,13 @@ def draw_bmp(filename, x, y): # pylint: disable=too-many-locals, too-many-branch
193
196
start_y = 10
194
197
display .fill (Adafruit_EPD .WHITE )
195
198
draw_bmp ("lilblinka.bmp" , display .width - 75 , display .height - 80 )
196
- for i ,line in enumerate (lines ):
199
+ for i , line in enumerate (lines ):
197
200
display .text (line , start_x , start_y + i * 10 , Adafruit_EPD .BLACK )
198
201
display .text (author , 10 , display .height - 20 , Adafruit_EPD .RED )
199
202
display .display ()
200
203
201
204
# normally we wouldn't have to do this, but we get bad fragments
202
- header = body = None
205
+ req = None
203
206
gc .collect ()
204
207
print (gc .mem_free ()) # pylint: disable=no-member
205
208
time .sleep (TIME_BETWEEN_QUERY )
0 commit comments