importtimeimport board
importrandomfrom adafruit_pyportal import PyPortal
# Set up where we'll be fetching data from, json is over 60k so loading from local.txt smaller one
DATA_SOURCE ="https://raw.githubusercontent.com/codyogden/killedbygoogle/master/graveyard.json"
DESCRIPTION_LOCATION =[0,'description']
NAME_LOCATION =[0,'name']
DATECLOSE_LOCATION =[0,'dateClose']# the current working directory (where this file is)
cwd =("/"+__file__).rsplit('/',1)[0]
pyportal = PyPortal(url=DATA_SOURCE,
json_path=(DESCRIPTION_LOCATION, NAME_LOCATION, DATECLOSE_LOCATION),
status_neopixel=board.NEOPIXEL,
default_bg=cwd+"/quote_background.bmp",
text_font=cwd+"/fonts/Arial-Italic-12.bdf",
text_position=((20,120),# quote location(500,500),# author location(220,10)),# dateclose location
text_color=(0xFFFFFF,# quote text color0x8080FF,# author text color, pushed off screen for now0xFFFFFF),#dateclose text color
text_wrap=(35,# characters to wrap for quote0,# no wrap for author0),# no wrap for date
text_maxlen=(180,30,10),# max text size for quote & author & dateclose)# speed up projects with lots of text by preloading the font!
pyportal.preload_font()# first run, get the full chunk of data so we can see how many entries there are
NUM_ENTRIES =0whilenot NUM_ENTRIES:
try:
all_json = pyportal.fetch(raw_url_json=True)
NUM_ENTRIES =len(all_json)
all_json =None# and clean upexceptRuntimeErroras e:
print("Some error occured, retrying! -", e)# now we can randomize them!whileTrue:
try:
DESCRIPTION_LOCATION[0]= NAME_LOCATION[0]= DATECLOSE_LOCATION[0]=random.randint(0, NUM_ENTRIES -1)
value = pyportal.fetch()print("Response is", value)exceptRuntimeErroras e:
print("Some error occured, retrying! -", e)time.sleep(10)
import time
import board
import random
from adafruit_pyportal import PyPortal
# Set up where we'll be fetching data from, json is over 60k so loading from local.txt smaller one
DATA_SOURCE = "https://raw.githubusercontent.com/codyogden/killedbygoogle/master/graveyard.json"
DESCRIPTION_LOCATION = [0, 'description']
NAME_LOCATION = [0, 'name']
DATECLOSE_LOCATION =[0, 'dateClose']
# the current working directory (where this file is)
cwd = ("/"+__file__).rsplit('/', 1)[0]
pyportal = PyPortal(url=DATA_SOURCE,
json_path=(DESCRIPTION_LOCATION, NAME_LOCATION, DATECLOSE_LOCATION),
status_neopixel=board.NEOPIXEL,
default_bg=cwd+"/quote_background.bmp",
text_font=cwd+"/fonts/Arial-Italic-12.bdf",
text_position=((20, 120), # quote location
(500, 500), # author location
(220, 10)), # dateclose location
text_color=(0xFFFFFF, # quote text color
0x8080FF, # author text color, pushed off screen for now
0xFFFFFF), #dateclose text color
text_wrap=(35, # characters to wrap for quote
0, # no wrap for author
0), # no wrap for date
text_maxlen=(180, 30, 10), # max text size for quote & author & dateclose
)
# speed up projects with lots of text by preloading the font!
pyportal.preload_font()
# first run, get the full chunk of data so we can see how many entries there are
NUM_ENTRIES = 0
while not NUM_ENTRIES:
try:
all_json = pyportal.fetch(raw_url_json=True)
NUM_ENTRIES = len(all_json)
all_json = None # and clean up
except RuntimeError as e:
print("Some error occured, retrying! -", e)
# now we can randomize them!
while True:
try:
DESCRIPTION_LOCATION[0] = NAME_LOCATION[0] = DATECLOSE_LOCATION[0] = random.randint(0, NUM_ENTRIES -1)
value = pyportal.fetch()
print("Response is", value)
except RuntimeError as e:
print("Some error occured, retrying! -", e)
time.sleep(10)
Adafruit publishes a wide range of writing and video content, including interviews and reporting on the maker market and the wider technology world. Our standards page is intended as a guide to best practices that Adafruit uses, as well as an outline of the ethical standards Adafruit aspires to. While Adafruit is not an independent journalistic institution, Adafruit strives to be a fair, informative, and positive voice within the community – check it out here: adafruit.com/editorialstandards
Stop breadboarding and soldering – start making immediately! Adafruit’s Circuit Playground is jam-packed with LEDs, sensors, buttons, alligator clip pads and more. Build projects with Circuit Playground in a few minutes with the drag-and-drop MakeCode programming site, learn computer science using the CS Discoveries class on code.org, jump into CircuitPython to learn Python and hardware together, TinyGO, or even use the Arduino IDE. Circuit Playground Express is the newest and best Circuit Playground board, with support for CircuitPython, MakeCode, and Arduino. It has a powerful processor, 10 NeoPixels, mini speaker, InfraRed receive and transmit, two buttons, a switch, 14 alligator clip pads, and lots of sensors: capacitive touch, IR proximity, temperature, light, motion and sound. A whole wide world of electronics and coding is waiting for you, and it fits in the palm of your hand.
Have an amazing project to share? The Electronics Show and Tell is every Wednesday at 7pm ET! To join, head over to YouTube and check out the show’s live chat – we’ll post the link there.
I never got into all that google+ stuff to begin with. I guess I’m “old fashioned”, but I like to keep control of my data and my applications. And now, seeing that your stuff can go away in an instant, I’m not sorry for my choice.
By the way, I see that you still use the 3 band resistor color code. There are so many sellers out there that handle the 4 band (plus tolerance) types where I can’t see a space between 4 and tolerance.
It seems strange to me that things like Project Tango and the Nexus device line make it into the list of dead Google things. Project Tango has been replaced with the next iteration of Google’s AR framework, so it’s hardly dead, and “Pixel” vs “Nexus” is really just a different naming convention. Compare that to killing off entire apps or services like Inbox and goo.gl.
I never got into all that google+ stuff to begin with. I guess I’m “old fashioned”, but I like to keep control of my data and my applications. And now, seeing that your stuff can go away in an instant, I’m not sorry for my choice.
By the way, I see that you still use the 3 band resistor color code. There are so many sellers out there that handle the 4 band (plus tolerance) types where I can’t see a space between 4 and tolerance.
It seems strange to me that things like Project Tango and the Nexus device line make it into the list of dead Google things. Project Tango has been replaced with the next iteration of Google’s AR framework, so it’s hardly dead, and “Pixel” vs “Nexus” is really just a different naming convention. Compare that to killing off entire apps or services like Inbox and goo.gl.