json_path=DATA_LOCATION,
)

magtag.network.connect()

magtag.add_text(
    text_font=terminalio.FONT,
    text_position=(
        (magtag.graphics.display.width // 2) - 1,
        (magtag.graphics.display.height // 2) - 1,
    ),
    text_scale=3,
    text_transform=text_transform,
    text_anchor_point=(0.5, 0.5),
)

magtag.preload_font(b"$012345789")  # preload numbers
magtag.preload_font((0x00A3, 0x20AC))  # preload gbp/euro symbol

timestamp = None

while True:
    if not timestamp or (time.monotonic() -
                         timestamp) > 60:  # once every 60 seconds...
        try:
            value = magtag.fetch()
            print("Response is", value)
        except (ValueError, RuntimeError) as e:
            print("Some error occured, retrying! -", e)
        timestamp = time.monotonic()
Esempio n. 2
0
magtag.add_text(
    text_position=(70, 30),
    text_font="/fonts/Arial-12.bdf",
    text_transform=lambda x: "@%s" % x,
)

# Tweet text
magtag.add_text(
    text_font="/fonts/Arial-Bold-12.pcf",
    text_wrap=30,
    text_maxlen=160,
    text_position=(
        5,
        (magtag.graphics.display.height // 2) + 20,
    ),
    line_spacing=0.75,
)

# preload characters
magtag.preload_font()

try:
    value = magtag.fetch()
    print("Response is", value)
except (ValueError, RuntimeError) as e:
    print("Some error occured, retrying! -", e)

time.sleep(2)
print("Sleeping!")
magtag.exit_and_deep_sleep(SLEEP_TIME * 60)
Esempio n. 3
0
)

MAGTAG.add_text(
    text_font=terminalio.FONT,
    text_position=(
        115,
        15,
    ),
    text_wrap=29,
    text_anchor_point=(0, 0),
    text_scale=1,
    line_spacing=1.0,
    is_data=False,
)

MAGTAG.preload_font()  # preload characters

SONG = (
    (330, 1),
    (370, 1),
    (392, 2),
    (370, 2),
    (330, 2),
    (330, 1),
    (370, 1),
    (392, 1),
    (494, 1),
    (370, 1),
    (392, 1),
    (330, 2),
)