Skip to content

Commit 6aa1bce

Browse files
authored
Merge pull request #19 from ladyada/master
see if that fixes quote
2 parents 9591608 + 398f7aa commit 6aa1bce

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

examples/espatcontrol_quoteEPD.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import busio
1111
from digitalio import DigitalInOut
1212
from adafruit_espatcontrol import adafruit_espatcontrol
13+
from adafruit_espatcontrol import adafruit_espatcontrol_requests as requests
1314
import ujson
1415
from adafruit_epd.epd import Adafruit_EPD
1516
from adafruit_epd.il0373 import Adafruit_IL0373
@@ -48,6 +49,8 @@
4849
rts_pin=rtspin, debug=True)
4950
esp.hard_reset()
5051

52+
requests.set_interface(esp)
53+
5154
# Extract a value from a json string
5255
def get_value(response, location):
5356
"""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
172175
# great, lets get the data
173176

174177
print("Retrieving data source...", end='')
175-
header, body = esp.request_url(DATA_SOURCE)
178+
req = requests.get(DATA_SOURCE)
176179
print("Reply is OK!")
177180
except (RuntimeError, adafruit_espatcontrol.OKError) as e:
178181
print("Failed to get data, retrying\n", e)
179182
continue
180183

181-
body = body.split(b'\n')[1] # unclear why but there's extra data at beginning/end
184+
body = req.text
182185
print('-'*40, "Size: ", len(body))
183186
print(str(body, 'utf-8'))
184187
print('-'*40)
@@ -193,13 +196,13 @@ def draw_bmp(filename, x, y): # pylint: disable=too-many-locals, too-many-branch
193196
start_y = 10
194197
display.fill(Adafruit_EPD.WHITE)
195198
draw_bmp("lilblinka.bmp", display.width - 75, display.height - 80)
196-
for i,line in enumerate(lines):
199+
for i, line in enumerate(lines):
197200
display.text(line, start_x, start_y+i*10, Adafruit_EPD.BLACK)
198201
display.text(author, 10, display.height-20, Adafruit_EPD.RED)
199202
display.display()
200203

201204
# normally we wouldn't have to do this, but we get bad fragments
202-
header = body = None
205+
req = None
203206
gc.collect()
204207
print(gc.mem_free()) # pylint: disable=no-member
205208
time.sleep(TIME_BETWEEN_QUERY)

0 commit comments

Comments
 (0)