Showing posts with label RSS. Show all posts
Showing posts with label RSS. Show all posts

RSS for LaMetric

One of the latest apps for LaMetric time is a long-time over-due and incredibly useful and welcome addition - RSS feed.

LaMetric is an internet radio, clock, smart speaker all rolled into one. You can read more about it on this blog. I suggest you head over and buy one now. They really are awesome tech toys.


With the RSS feed app, you can spool your favourite websites directly onto the 8-bit display so you never miss an update again. RSS is a way of pushing content from one website to another, automatically, so you don't have to go the original site to check for updates yourself. Really Simple. I've been waiting for this to appear on LaMetric for a long time now.

Need to know when your favourite blogger has posted? You will know without having to switch on your device. You will be able to read the new content directly on your LaMetric scrolling display in all its 8-bit glory.

RSS app running on Samsung Galaxy Note 9. Setting up your RSS feed is as simple as adding the RSS feed then clicking a few buttons until your feed appears the way you want it on your LaMetric display.

LaMetric Time app 
The app is really easy to use. You simply add the RSS feed into the appropriate edit box and you should find your feed appearing on your LaMetric display immediately.

The hard part is finding a site's RSS feed. Many sites provide you with this (click the orange icon usually located with the other social media links). This is a link to the BBC news RSS feeds to get you started. Finding the RSS feed for a blogger is much more tricky. As far as I can tell, the best way is to use the following:

http://blog.domain.name/feeds/posts/default?alt=rss 

Where blog.domain.name is the domain name for the blog. For example, the RSS feed for this blog is http://superdecade.blogspot.com/feeds/posts/default?alt=rss 

Don't have LaMetric? Get on the interwebs and buy one now!

That's it for today. If you enjoyed this post, then you might like to read some other LaMetric posts, or other posts about RSS feeds. Maybe you just want something completely different.

Improved SenseHat headlines ticker

Last time I introduced my SenseHat RSS feed display code. Today I have made some improvements to the script.

The Sense HAT provides an 8x8 LED maxtrix display, accelerometer, gyroscope, magnetometer, air pressure sensor, temperature sensor and air pressure sensor, as well as a small joystick.  Basically a bundle of sensors that plug in directly to the GPIO pins on your Raspberry Pi. They are well worth purchasing should you wish to upgrade your Pi.



First off, the list 'feedlink' can be populated with as many RSS feeds as you like.  Here I have three BBC feeds, but they could be substituted for any feed you like.  Currently the ticker loops through all of the articles in each feed. You could change it so that each feed is chained to the end of the previous one.  With this code you can switch the the start of the next feed by shaking the Raspberry Pi.  The shake is detected by a change in the 'pitch' of the SenseHat.  You can change the sensitivity of the shake with the THRESHOLD variable.  The new feed will be displayed after the previous article has finished.
The RSS feed ticker scrolling over the SenseHat, however my camera frame rate can't keep up.

I have added some exception handling to the showFeed routine to handle an index out of bounds error. I think this could occur with the previous code.



#Sense Hat RSS reader
#version 2
#For Python 2
from sense_hat import SenseHat
import feedparser
import time


def showFeed(d, n):
    """Shows feed (d) article (n)"""
    try:
        sense.show_message(d.entries[n].description,
                           back_colour=[255,0,0],
                           text_colour=[255,255,255],
                           scroll_speed=0.07)
    except IndexError as e:
        sense.show_message("ERROR")



        
sense = SenseHat()
sense.set_rotation(270)
sense.low_light = True

feed = []
feedlink = ['http://feeds.bbci.co.uk/news/rss.xml?edition=uk',
            'http://feeds.bbci.co.uk/news/technology/rss.xml',
            'http://feeds.bbci.co.uk/news/uk/rss.xml']

ARTICLE_LIMIT = 20
THRESHOLD = 15 # threshold for tilt (changes feed)

print "Running on SenseHat:"
while True:
    #read the feeds in
    for thisFeed in range(len(feedlink)):
        feed.append(feedparser.parse(feedlink[thisFeed]))

    i = 0 #article pointer
    f = 0 #feed pointer
    
    while i < ARTICLE_LIMIT:
        orientation1 = sense.get_orientation_degrees()
        time.sleep(0.5)
        print 'feed ',f,'article',i
        showFeed(feed[f],i)
        orientation2 = sense.get_orientation_degrees()
        #check for shake
        print 'shake detected ',abs(orientation2['pitch'] - orientation1['pitch'])
        if (abs(orientation2['pitch'] - orientation1['pitch'])> THRESHOLD):
            f += 1 #change feed
            i = 0 # return to start of feed
            if (f == len(feed)):
                f = 0
        else:
            i += 1
    time.sleep(2.5)

RSS feed for Raspberry Pi SenseHat

I have written a short script for running a news feed on a Raspberry Pi SenseHat.  The Sense HAT provides an 8x8 LED maxtrix display, accelerometer, gyroscope, magnetometer, air pressure sensor, temperature sensor and air pressure sensor, as well as a small joystick.  Basically a bundle of sensors that plug in directly to the GPIO pins on your Raspberry Pi. They are well worth purchasing should you wish to upgrade your Pi.



The feed picks up the headlines from the BBC news service and then runs continuously on the SenseHat display. Any other valid newsfeed could be substituted for the BBC feed.

RSS feed running on the Raspberry Pi with SenseHat.  I couldn't get a much better photo then this.

Step 1

I used feedparser for the RSS feeds.  This can be installed on your Pi using the following command:

sudo pip install feedparser

Step 2

The following Python 2 code runs an infinite loop which loads the first twenty articles from the BBC website and displays them continuously on the SenseHat display.

#Sense Hat RSS reader
#For Python 2
from sense_hat import SenseHat
import feedparser
import time

sense = SenseHat()
sense.set_rotation(270)
ARTICLE_LIMIT = 20

print "Ticker running on SenseHat"
while True:
    for i in range(ARTICLE_LIMIT):
        time.sleep(0.5)
        d = feedparser.parse('http://feeds.bbci.co.uk/news/rss.xml?edition=uk')
        sense.show_message(d.entries[i].description,
                           back_colour=[255,0,0],
                           text_colour=[255,255,255],
                           scroll_speed=0.07)
        
    time.sleep(2.5)

If you liked this article, then you might like my other SenseHat posts, or my other Raspberry Pi posts.

Changing where Susan looks for the news

Unless you live in the UK, you will probably want to change where Susan looks for your news and weather information.  Susan uses RSS feeds to get news and weather.  By default these point to the BBC news feeds.  To change things, first find the RSS for the news or weather service you want.

Here is the RSS feed for BBC business news:

http://feeds.bbci.co.uk/news/business/rss.xml


To set the business news as your main news feed, type:

setNewsfeed http://feeds.bbci.co.uk/news/business/rss.xml


Type 'rerun' to check everything went as planned. You should now be getting the news from your chosen feed.

Changing the Weather Feed.

First find the RSS weather feed for your area.

Second use the setWeatherfeed command as described above for the news feed.  Type 'rerun' or 'weather' to check that everything is as expected.

Changing the primary feed.

The primary feed is an additional news feed that you can set to any RSS feed you like. Susan will pull items from this feed onto here display at random intervals whenever she is bored.

Set the primary feed using the setPrimaryfeed command, followed by the RSS feed, as described above for the news feeds.


Still reading?  
See all Susan related posts.  
You might also like - the Reverse Polish Notation Calculator.

OSMC, or, what I did with my Pi next

Whilst waiting for a new larger SD card I thought I would give OSMC (Open Source Media Center) for Raspberry Pi a try.

The OSMC interface looking rather pretty.

OSMC is a Linux-based entertainment system. I've got mine hooked up to a 2TB external hard disk from which it effortlessly plays my music, movies and pictures. It also displays the weather (although curiously only in Heathrow) and  OSMC also comes with the capability to install various apps.  I've got the OneDrive and Flickr apps so I can view my cloud photo collection (my collection of cloud photos is impressive). There are also add-ons for Dropbox, Facebook, YouTube, eBooks, email, quizzes, RSS editors... etc....

Really, my RISC OS media center doesn't get a look-in anymore.



Now for some useful OSMC videos:

"It's a media player. It plays media. That's what media players do." - A video from ExplainingComputers




#OSMC #Raspberry Pi

RSS feeds

I've been playing with RSS feeds in JavaScript.  My first attempt is a webpage that shows the top BBC news stories; provides a Google search box and, rather uselessly displays the current day of the week.  I shall continue to work on it in an attempt to make a rather useful homepage.  Please take the code and give it to children to hack.  Have fun.  Oh, and a link to the jQuery RSS feedreader code I used.


Label

World Karma Game