Skip to content

see if that fixes quote #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions examples/espatcontrol_quoteEPD.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import busio
from digitalio import DigitalInOut
from adafruit_espatcontrol import adafruit_espatcontrol
from adafruit_espatcontrol import adafruit_espatcontrol_requests as requests
import ujson
from adafruit_epd.epd import Adafruit_EPD
from adafruit_epd.il0373 import Adafruit_IL0373
Expand Down Expand Up @@ -48,6 +49,8 @@
rts_pin=rtspin, debug=True)
esp.hard_reset()

requests.set_interface(esp)

# Extract a value from a json string
def get_value(response, location):
"""Extract a value from a json object, based on the path in 'location'"""
Expand Down Expand Up @@ -172,13 +175,13 @@ def draw_bmp(filename, x, y): # pylint: disable=too-many-locals, too-many-branch
# great, lets get the data

print("Retrieving data source...", end='')
header, body = esp.request_url(DATA_SOURCE)
req = requests.get(DATA_SOURCE)
print("Reply is OK!")
except (RuntimeError, adafruit_espatcontrol.OKError) as e:
print("Failed to get data, retrying\n", e)
continue

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

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