I found some resources online that suggest changing the CIRCUITPY_PYSTACK_SIZE in py/circuitpy_mpconfig.h to fix pystack exhausted errors. I was able to clone the adafruit/circuitpython repository and make this change to the file, however I'm not sure how to implement this updated circuitpython to my MagTag - 2.9" Grayscale E-Ink WiFi Display. I'm not sure if this is the best route to fix the issue but any resources or help in loading a custom version of circuitpython to my board would be appreciated!
I've attached my code below for reference (with some values missing). I have tried to make the logic as simple as I can to fix the pystack exhausted errors but nothing seems to be working.
Code: Select all
from adafruit_magtag.magtag import MagTag
import socketpool
import adafruit_requests
import ssl
import wifi
import gc
current = {'old_data': 'none', 'new_data': 'empty'}
wifi.radio.connect(<SSID>, <password>)
pool = socketpool.SocketPool(wifi.radio)
requests = adafruit_requests.Session(pool, ssl.create_default_context())
JSON_URL = <url>
magtag = MagTag()
def check_for_update():
response = requests.get(JSON_URL)
new_data = response.json()["tagdata1"]
current.update({'new_data': new_data})
if current['old_data'] == current['new_data']:
gc.collect()
magtag.enter_light_sleep(10)
check_for_update()
else:
program()
def program():
magtag.add_text(
text_position=(
(magtag.graphics.display.width // 2) -1,
(magtag.graphics.display.height // 2) -1,
),
text_scale=3,
text_anchor_point=(0.5, 0.5),)
magtag.set_text(current['new_data'])
gc.collect()
value = current['new_data']
current.update({'old_data' : value})
magtag.enter_light_sleep(10)
check_for_update()
check_for_update()