I got it to partially work using ‘demo’, albeit it is not automatically changing news feeds. Curiously, it will change feeds if I invoke Ctrl-C. So I don’t know how to fix this just yet. I am using 3 horizontally chained 16x32 panels. I am also still using python 2.7.16 with the following changes:
Changed line 51 from ‘unicode’ to ‘str’.
Changed line 70 ‘16’ to ‘10’ to resize font to a smaller size. I also changed the font type here to DejaVuSerif.ttf.
Changed line 96 to os.system("sudo ./demo -D 1 --led-cols=96 --led-rows=16 --led-brightness=75 --led-chain=3 "+disp)
Invoking code from /home/pi/rpi-rgb-led-matrix/examples-api-use
Lingering issues:
Feed doesn’t automatically update.
Scroll speed too fast
Sometimes on start it fails and have to re-start.
I will try to figure it out using runtext. This did not work: os.system("sudo ./runtext.py --led-cols 96 -r 16 -b 50 -c 3 --text"+disp)
coming over from github - my biggest challenge right now is that I can’t get it to work without having to keep pressing control+c to get it to switch stories!
yeah that’s what I did - obviously summarized all my changes in the comments - so far got it all the way where I want it just except the fact that I have to press control c to change the stories lol
What about the thought about addidng some timer related interruption which do the same that CTRL+C does > changing rssfeed, which is actually a picture maybe like after 60 seconds.
I think the -t 60 in rssparse.py end leads somewhere to older versions on demo-main and not in rssparse.py.
So instead of rssparse.py, the code in demo-main should be modified. There’s some changes in the last 2-3 years instead of rssparse.py, where’s pretty much nothing modifications.
My ”coding skills” are blank paper, can program only lathe.
I am experimenting with sending non-alphanumeric unicode characters through, but only the “hearts” display properly. Anyone have a clue how to translate them into the display?
Not sure why. Did you install the other library? Also, the color def() are remnants that can be deleted. I tried to delete in above code but it’s not letting me.
The code I uploaded had some indent errors which I fixed. Perhaps it will work now. I find when I cut and paste code here sometimes it isn’t indented correctly.
# THIS SCRIPT USES THE LIBRARY AT:
# https://github.com/hzeller/rpi-rgb-led-matrix
# BE SURE TO CLONE IT AND READ THE README, as highlighted in the video :)
import os, time, threading, random
import feedparser
from PIL import Image, ImageFont, ImageDraw
from random import shuffle, choice
BITLY_ACCESS_TOKEN="BITLY_ACCESS_TOKEN"
items=[]
titles=[]
displayItems=[]
feeds=[
#enter all news feeds you want here
"https://www.spglobal.com/spdji/en/rss/rss-details/?rssFeedName=corporate-news",
"https://markets.businessinsider.com/rss/news",
"https://markets.businessinsider.com/rss/analysts-opinions",
"https://www.globenewswire.com/RssFeed/orgclass/1/feedTitle/GlobeNewswire%20-%20News%20about%20Public%20Companies",
"https://www.globenewswire.com/RssFeed/subjectcode/13-Earnings%20Releases%20And%20Operating%20Results/feedTitle/GlobeNewswire%20-%20Earnings%20Releases%20And%20Operating%20Results",
"https://www.globenewswire.com/RssFeed/subjectcode/8-Calendar%20Of%20Events/feedTitle/GlobeNewswire%20-%20Calendar%20Of%20Events",
"https://www.globenewswire.com/RssFeed/subjectcode/43-Technical%20Analysis/feedTitle/GlobeNewswire%20-%20Technical%20Analysis",
"https://seekingalpha.com/market_currents.xml",
"https://www.investing.com/rss/news.rss",
"https://stocksnewsfeed.com/feed/",
"https://feeds.a.dj.com/rss/RSSWorldNews.xml",
"https://feeds.a.dj.com/rss/RSSWSJD.xml",
"https://feeds.a.dj.com/rss/WSJcomUSBusiness.xml",
"http://www.cnbc.com/id/19746125/device/rss/rss.xml",
]
def populateItems():
#first clear out everything
del items[:]
del displayItems[:]
#delete all the image files
os.system("find . -name \*.ppm -delete")
for url in feeds:
feed=feedparser.parse(url)
posts=feed["items"]
for post in posts:
items.append(post)
shuffle(items)
def createLinks():
try:
populateItems()
for idx, item in enumerate(items):
title = item["title"].encode('ascii', 'ignore').decode()
titles.append(title)
except ValueError:
print("Bummer :( I couldn't make you 'dem links :(")
finally:
print("\nWill get more news next half hour!\n\n")
def run():
print("News Fetched at {}\n".format(time.ctime()))
createLinks()
threading.Timer(len(items) * 60, run).start()
showOnLEDDisplay()
def showOnLEDDisplay():
#for disp in displayItems[:60]:
colors = [
"255,0,0", # red
"0,255,0", # green
"189,51,164", # byzantinee
"252,194,0" # golden poppy
]
for disp in titles:
print(disp)
randomColor = choice(colors)
title = "'" + disp + "'"
os.system("sudo ./scrolling-text-example -f ../fonts/5x8.bdf -y3 -s9 -l1 -C "+ randomColor +" -B 0,48,143 --led-cols=96 --led-rows=16 --led-brightness=50 --led-chain=3 "+title)
if __name__ == '__main__':
run()
It is a starting point and of course it can be modified as you wish. I am using a 5v, 4a power supply and so far no issues. Yes, it stops after awhile and can be modified to loop. I am also going to modify it to start with the power button, so I don’t have to ssh into it each time.
I find it a fun platform to work with and develop other interesting projects (I’ll post).
Now it works pretty long as I have many feeds, but eventually it pauses for a long time. I left mine on and at some time when I was in sleep, it started again.
Just wondering, what code or something is doing that update. Could it update sooner, so no long pause?