0

Broken Guide
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Broken Guide

by MattPackwood on Fri May 14, 2021 8:12 pm

Hi,

it looks like the latest libraries break the Covid Progress Tracker

https://learn.adafruit.com/adafruit-mag ... on-tracker

Matt

MattPackwood
 
Posts: 58
Joined: Wed Jul 23, 2014 9:13 pm

Re: Broken Guide

by dastels on Fri May 14, 2021 10:54 pm

What, exactly, are you seeing?

Dave

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

Re: Broken Guide

by MattPackwood on Sat May 15, 2021 9:50 am

IMG_2546.jpeg
IMG_2546.jpeg (28.44 KiB) Viewed 374 times


Sorry, I should have included this....

MattPackwood
 
Posts: 58
Joined: Wed Jul 23, 2014 9:13 pm

Re: Broken Guide

by dastels on Sat May 15, 2021 10:23 am

I'm not seeing a problem looking at the code in the guide. Can you post exactly the code.py that's on the MagTag in case something is different that the code in the guide.

Dave

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

Re: Broken Guide

by MattPackwood on Sat May 15, 2021 2:14 pm

Here you go...

Code: Select all | TOGGLE FULL SIZE
from adafruit_magtag.magtag import MagTag
from adafruit_progressbar.progressbar import ProgressBar

# Set up where we'll be fetching data from
DATA_SOURCE = "https://raw.githubusercontent.com/owid/covid-19-data/master/public/data/vaccinations/country_data/United%20States.csv"
# Find data for other countries/states here:
# https://github.com/owid/covid-19-data/tree/master/public/data/vaccinations

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

magtag.add_text(
    text_font="/fonts/ncenR14.pcf",
    text_position=((magtag.graphics.display.width // 2) - 1, 8,),
    text_anchor_point=(0.5, 0.5),
    is_data=False,
)  # Title

magtag.add_text(
    text_font="/fonts/ncenR14.pcf",
    text_position=((magtag.graphics.display.width // 2) - 1, 23,),
    text_anchor_point=(0.5, 0.5),
    is_data=False,
)  # Date

magtag.add_text(
    text_font="/fonts/ncenR14.pcf",
    text_position=((magtag.graphics.display.width // 2) - 1, 40,),
    text_anchor_point=(0.5, 0.5),
    is_data=False,
)  # Vaccinated text

magtag.add_text(
    text_font="/fonts/ncenR14.pcf",
    text_position=((magtag.graphics.display.width // 2) - 1, 85,),
    text_anchor_point=(0.5, 0.5),
    is_data=False,
)  # Fully vaccinated text

BAR_WIDTH = magtag.graphics.display.width - 80
BAR_HEIGHT = 25
BAR_X = magtag.graphics.display.width // 2 - BAR_WIDTH // 2

progress_bar = ProgressBar(
    BAR_X, 50, BAR_WIDTH, BAR_HEIGHT, 1.0, bar_color=0x999999, outline_color=0x000000
)

progress_bar_1 = ProgressBar(
    BAR_X, 95, BAR_WIDTH, BAR_HEIGHT, 1.0, bar_color=0x999999, outline_color=0x000000
)

magtag.graphics.splash.append(progress_bar)
magtag.graphics.splash.append(progress_bar_1)
magtag.graphics.set_background("/bmps/background.bmp")


try:
    value = magtag.fetch().split("\n")[-2].split(",")
    print("Response is", value)

    vaccinated = int(value[-2]) / 331984513
    fully_vaccinated = int(value[-1]) / 331984513

    magtag.set_text(f"{value[0]} Vaccination Rates", 0, False)
    magtag.set_text(value[1], 1, False)
    magtag.set_text("Vaccinated: {:.2f}%".format(vaccinated * 100), 2, False)
    magtag.set_text(
        "Fully Vaccinated: {:.2f}%".format(fully_vaccinated * 100), 3, False
    )

    progress_bar.progress = vaccinated
    progress_bar_1.progress = fully_vaccinated

    magtag.refresh()

    seconds_to_sleep = 24 * 60 * 60  # Sleep for one day
    print(f"Sleeping for {seconds_to_sleep} seconds")
    magtag.exit_and_deep_sleep(seconds_to_sleep)

except (ValueError, RuntimeError) as e:
    print("Some error occured, retrying! -", e)

MattPackwood
 
Posts: 58
Joined: Wed Jul 23, 2014 9:13 pm

Re: Broken Guide

by MattPackwood on Sat May 15, 2021 2:17 pm

And I did a:

Code: Select all | TOGGLE FULL SIZE
Matt-Packwoods-iMac:~ $ circup update --all
Found device at /Volumes/CIRCUITPY, running CircuitPython 6.2.0.
Downloading latest version information.


  [####################################]  100%         
  [####################################]  100%         

OK

Found 2 module[s] needing update.
Updated neopixel
Updated adafruit_progressbar


And it is working again, so it is a library issue (I guess)

MattPackwood
 
Posts: 58
Joined: Wed Jul 23, 2014 9:13 pm

Re: Broken Guide

by dherrada on Tue Jun 01, 2021 10:49 am

Hi. I'm the author of the guide. Can you try again and see if it's still not working? It could have been fixed in one of the libraries. It also might just need you to copy the libraries over again. Weird stuff like that has happened to me a decent amount, especially on slightly less stable chips like the ESP32-S2

dherrada
 
Posts: 140
Joined: Thu Jan 04, 2018 4:59 pm

Re: Broken Guide

by richjteel on Sun Aug 01, 2021 3:41 pm

I ran into a problem with the covid tracker as well and found that the API used in the guide is no longer updated, as of 7 March 2021, and stopped working in May.

FROM: https://covidtracking.com/data/api
"Notice: The COVID Tracking Project has ended all data collection as of March 7, 2021. The existing API will continue to work until May 2021, but will only include data up to March 7, 2021."

I updated the code to https://covid2019-api.herokuapp.com/v2/total instead. It does not provide the same data but perhaps someone can find a better API to use and add it here. Attached is the updated version of my working code.

20210801_153104.jpg
MagTag Result
20210801_153104.jpg (793.18 KiB) Viewed 121 times


NOTE: I just received the MagTag. I'm working through the MagTag Project Selector project on learn.adafruit.com. I'm attempting to get all of the sub projects listed in the example to work.
Attachments
covid.py
Updated Code
(3.31 KiB) Downloaded 3 times

richjteel
 
Posts: 3
Joined: Sun Jun 25, 2017 5:02 pm

Re: Broken Guide

by dherrada on Tue Aug 03, 2021 10:21 am

Thanks. That's really helpful. I'll update the guide.

Also, the magtag project selector can be a bit complicated to set up. Feel free to ask me if you're having any issues.

dherrada
 
Posts: 140
Joined: Thu Jan 04, 2018 4:59 pm

Re: Broken Guide

by dherrada on Tue Aug 03, 2021 10:23 am

Oh wait, can you confirm that this is the guide you are talking about? https://learn.adafruit.com/adafruit-mag ... r/overview

dherrada
 
Posts: 140
Joined: Thu Jan 04, 2018 4:59 pm

Re: Broken Guide

by richjteel on Tue Aug 03, 2021 4:20 pm

@dherrada, Sorry, that is not the one that I was commenting on. I did not realize there were two covid apps for the MagTag. I was referring to the other one at https://learn.adafruit.com/magtag-covid ... ot-display. I totally posted in the wrong thread.

I thought that I would be helpful but instead hijacked a thread unintentionally. Would you want me to delete my post and post it as a new topic to see if it will help someone else out or should I leave it here?

richjteel
 
Posts: 3
Joined: Sun Jun 25, 2017 5:02 pm

Re: Broken Guide

by Cutie_And_Grump on Fri Aug 06, 2021 1:51 pm

richjteel wrote:I ran into a problem with the covid tracker as well and found that the API used in the guide is no longer updated, as of 7 March 2021, and stopped working in May.

FROM: https://covidtracking.com/data/api
"Notice: The COVID Tracking Project has ended all data collection as of March 7, 2021. The existing API will continue to work until May 2021, but will only include data up to March 7, 2021."

I updated the code to https://covid2019-api.herokuapp.com/v2/total instead. It does not provide the same data but perhaps someone can find a better API to use and add it here. Attached is the updated version of my working code.

20210801_153104.jpg


NOTE: I just received the MagTag. I'm working through the MagTag Project Selector project on learn.adafruit.com. I'm attempting to get all of the sub projects listed in the example to work.



richjteel I found https://apidocs.covidactnow.org/ to work quite well. You do need to sign up for a free api key to access the data. There is quite a bit of data available to access, country and state levels. I hope this helps.

Cutie_And_Grump
 
Posts: 1
Joined: Mon Jul 22, 2019 5:58 pm

Please be positive and constructive with your questions and comments.