Skip to content

Instantly share code, notes, and snippets.

@Neradoc
Created May 4, 2021 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Neradoc/0093bac7d0ec5608f4fa7918e4950f1d to your computer and use it in GitHub Desktop.
Save Neradoc/0093bac7d0ec5608f4fa7918e4950f1d to your computer and use it in GitHub Desktop.
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