Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import time
import random
from adafruit_magtag.magtag import MagTag
magtag = MagTag()
magtag.network.connect()
key = "fontaine-status"
latest_id = ""
while True:
data = magtag.get_io_data(key)
# print(data)
feed = magtag.get_io_feed(key)
# print(feed)
send_value = random.randint(15,35)
magtag.push_to_io(key,send_value)
print("Sending:",send_value)
some_value = data[-1]['value']
# print(some_value)
# using the internal "_get_io_client" seems to be the only way to do that ?
client = magtag.network._get_io_client()
last = client.receive_data(key)
the_id = last['id']
if the_id != latest_id:
print("New value:",last['value'])
latest_id = the_id
# magtag.set_text(f"{some_value}", index = 0)
time.sleep(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment