🎁📬❄️📦 Holiday Shipping Deadlines are approaching! International customers and domestic ground - get your orders in 12/9/2020 📦❄️📬🎁
0

Magtag
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Magtag

by jhowardpatterson on Mon Nov 16, 2020 4:46 pm

I have the Magtag and have installed the Esptool and Circuitpython for Magtag, but not script I run changes the display on the Magtag. It is still stuck on the original image. Using Windows10 and Mu. Green light is on, and the script to blink the red light works, just nothing on the e-ink display.

-Howard

jhowardpatterson
 
Posts: 13
Joined: Sat Dec 30, 2017 11:14 pm

Re: Magtag

by tannewt on Mon Nov 16, 2020 5:57 pm

What code are you running to change the display?

tannewt
 
Posts: 1922
Joined: Thu Oct 06, 2016 8:48 pm

Re: Magtag

by dastels on Mon Nov 16, 2020 6:00 pm

If you can post one of the scripts that fail to affect the display, I have a MagTag that should be here later today to try it out on.

Dave

dastels
 
Posts: 4251
Joined: Tue Oct 20, 2015 3:22 pm

Re: Magtag

by jhowardpatterson on Mon Nov 16, 2020 11:37 pm

Here's the script I was keen to install. It's a countdown script until the US presidential inauguration:

Code: Select all | TOGGLE FULL SIZE
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
#
# SPDX-License-Identifier: Unlicense
import time
import rtc
from adafruit_magtag.magtag import MagTag

# The time of the thing!
EVENT_YEAR = 2021
EVENT_MONTH = 1
EVENT_DAY = 20
EVENT_HOUR = 12
EVENT_MINUTE = 00
# we'll make a python-friendly structure
event_time = time.struct_time((EVENT_YEAR, EVENT_MONTH, EVENT_DAY,
                               EVENT_HOUR, EVENT_MINUTE, 0,  # we don't track seconds
                               -1, -1, False))  # we dont know day of week/year or DST

# Set up where we'll be fetching data from
# pylint: disable=line-too-long
DATA_SOURCE = "http://worldtimeapi.org/api/timezone/America/New_York"

magtag = MagTag()
magtag.network.connect()

magtag.add_text(
    text_font="Arial-Bold-24.bdf",
    text_position=(10, 25),
    line_spacing=0.85,
)

magtag.graphics.qrcode(b"https://buildbackbetter.com/",
                       qr_size=3, x=200, y=25)

timestamp = None
lasttimefetch_stamp = None
while True:
    if not lasttimefetch_stamp or (time.monotonic() - lasttimefetch_stamp) > 3600:
        try:
            response = magtag.network.requests.get(DATA_SOURCE)
            datetime_str = response.json()['datetime']
            datesplit = datetime_str.split("-")
            year = int(datesplit[0])
            month = int(datesplit[1])
            timesplit = datesplit[2].split("T")
            mday = int(timesplit[0])
            timesplit = timesplit[1].split(":")
            hours = int(timesplit[0])
            minutes = int(timesplit[1])
            seconds = int(float(timesplit[2].split("-")[0]))
            rtc.RTC().datetime = time.struct_time((year, month, mday, hours, minutes, seconds, 0, 0, False))
            lasttimefetch_stamp = time.monotonic()
        except (ValueError, RuntimeError) as e:
            print("Some error occured, retrying! -", e)
            continue

    if not timestamp or (time.monotonic() - timestamp) > 60:  # once a minute
        now = time.localtime()
        print("Current time:", now)
        remaining = time.mktime(event_time) - time.mktime(now)
        print("Time remaining (s):", remaining)
        if remaining < 0:
            print("EVENT TIME")
            magtag.set_text("It's Time\nTo Party!")
            magtag.peripherals.neopixel_disable = False
            while True:  # that's all folks
                magtag.peripherals.neopixels.fill(0xFF0000) # red
                time.sleep(0.25)
                magtag.peripherals.neopixels.fill(0xFFFFFF) # white
                time.sleep(0.25)
                magtag.peripherals.neopixels.fill(0x0000FF) # blue
                time.sleep(0.25)
        secs_remaining = remaining % 60
        remaining //= 60
        mins_remaining = remaining % 60
        remaining //= 60
        hours_remaining = remaining % 24
        remaining //= 24
        days_remaining = remaining
        print("%d days, %d hours, %d minutes and %s seconds" %
              (days_remaining, hours_remaining, mins_remaining, secs_remaining))
        magtag.set_text("%d Days\n%d Hours\n%d Mins" %
                        (days_remaining, hours_remaining, mins_remaining))
        timestamp = time.monotonic()
    # wait around
    time.sleep(1)


I also tried the simple "Hello World!" type script below, also without luck:


Code: Select all | TOGGLE FULL SIZE
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
#
# SPDX-License-Identifier: Unlicense
import time
import terminalio
from adafruit_magtag.magtag import MagTag

magtag = MagTag()

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

magtag.set_text("Hello World")

buttons = magtag.peripherals.buttons
button_colors = ((255, 0, 0), (255, 150, 0), (0, 255, 255), (180, 0, 255))
button_tones = (1047, 1318, 1568, 2093)
timestamp = time.monotonic()

while True:
    for i, b in enumerate(buttons):
        if not b.value:
            print("Button %c pressed" % chr((ord("A") + i)))
            magtag.peripherals.neopixel_disable = False
            magtag.peripherals.neopixels.fill(button_colors[i])
            magtag.peripherals.play_tone(button_tones[i], 0.25)
            break
    else:
        magtag.peripherals.neopixel_disable = True
    time.sleep(0.01)

jhowardpatterson
 
Posts: 13
Joined: Sat Dec 30, 2017 11:14 pm

Re: Magtag

by tannewt on Tue Nov 17, 2020 6:19 pm

Hi! Things are moving fast. I'm about to release 6.1.0-beta.0 so please update to it when it is released. It initializes the display natively so it should ideally just work.

tannewt
 
Posts: 1922
Joined: Thu Oct 06, 2016 8:48 pm

Re: Magtag

by jhowardpatterson on Tue Nov 17, 2020 9:20 pm

Installed the beta update, but still no joy. Starting to wonder if the display is pad. Can you recommend a script or test to see if it is working?

jhowardpatterson
 
Posts: 13
Joined: Sat Dec 30, 2017 11:14 pm

Re: Magtag

by adafruit2 on Wed Nov 18, 2020 12:33 am

in Mu, what do you see on the REPL? is there a CIRCUITPY drive with some files on it?

adafruit2
Site Admin
 
Posts: 19499
Joined: Fri Mar 11, 2005 7:36 pm

Re: Magtag

by jhowardpatterson on Wed Nov 18, 2020 3:25 pm

The REPL shows the following;

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.

Press any key to enter the REPL. Use CTRL-D to reload.

Here is a screencap of the CIRCUITPY files:

circuitpy files.PNG
circuitpy files.PNG (19.04 KiB) Viewed 133 times

jhowardpatterson
 
Posts: 13
Joined: Sat Dec 30, 2017 11:14 pm

Re: Magtag

by adafruit2 on Wed Nov 18, 2020 3:34 pm

whats in code.py?

adafruit2
Site Admin
 
Posts: 19499
Joined: Fri Mar 11, 2005 7:36 pm

Re: Magtag

by jhowardpatterson on Wed Nov 18, 2020 4:05 pm

Code: Select all | TOGGLE FULL SIZE
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
#
# SPDX-License-Identifier: Unlicense
import time
import terminalio
from adafruit_magtag.magtag import MagTag

magtag = MagTag()

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

magtag.set_text("Hello World")

buttons = magtag.peripherals.buttons
button_colors = ((255, 0, 0), (255, 150, 0), (0, 255, 255), (180, 0, 255))
button_tones = (1047, 1318, 1568, 2093)
timestamp = time.monotonic()

while True:
    for i, b in enumerate(buttons):
        if not b.value:
            print("Button %c pressed" % chr((ord("A") + i)))
            magtag.peripherals.neopixel_disable = False
            magtag.peripherals.neopixels.fill(button_colors[i])
            magtag.peripherals.play_tone(button_tones[i], 0.25)
            break
    else:
        magtag.peripherals.neopixel_disable = True
    time.sleep(0.01)

jhowardpatterson
 
Posts: 13
Joined: Sat Dec 30, 2017 11:14 pm

Re: Magtag

by adafruit2 on Wed Nov 18, 2020 6:04 pm

and when you press Control-D in the REPL doesnt start?

adafruit2
Site Admin
 
Posts: 19499
Joined: Fri Mar 11, 2005 7:36 pm

Re: Magtag

by jhowardpatterson on Wed Nov 18, 2020 7:14 pm

No, nothing happens with the display or the LEDs. Could it be a library issue? And BTW, thanks for pursuing this.:)

jhowardpatterson
 
Posts: 13
Joined: Sat Dec 30, 2017 11:14 pm

Re: Magtag

by tannewt on Thu Nov 19, 2020 2:39 pm

Note that beta.0 has a nasty bug. I'm hoping to release beta.1 today with a number of fixes.

tannewt
 
Posts: 1922
Joined: Thu Oct 06, 2016 8:48 pm

Re: Magtag

by jhowardpatterson on Fri Nov 20, 2020 4:04 pm

Tried the beta1, but same issues. The display hasn't changed since I unwrapped the packaging last week. Should I request a replacement?

jhowardpatterson
 
Posts: 13
Joined: Sat Dec 30, 2017 11:14 pm

Re: Magtag

by adafruit2 on Fri Nov 20, 2020 7:33 pm

i want to try one more thing
try downloading this 'all in one' bin and progamming it to the magtag using the rom bootloader. does the screen every 'change'? it should refresh once a minute or so

if not! can you post a photo of the front & back of your 'tag - if the connector is loose we'll be able to tell and its an easy fix

adafruit2
Site Admin
 
Posts: 19499
Joined: Fri Mar 11, 2005 7:36 pm

Please be positive and constructive with your questions and comments.