User avatar
elParaguayo
Posts: 1929
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

[WIP] RPi Information Screen

Sun Aug 04, 2013 6:41 pm

EDIT: There is a new and improved version of the script for the official touch screen display. See this thread for more info.

EDIT: Working version of code is here: https://github.com/elParaguayo/RPI-Info-Screen.
I would strongly advise using git to maintain the copy of the script on your machine as there are likely to be numerous updates going through and doing "git pull" is far less stressful than keeping track of multiple files.

I've been working on this for a while but thought I'd share where I've got to so far.

The idea:
I've bought one of these small screens and wanted to use it as a lightweight way of viewing useful information that I access regularly (e.g. weather forecasts, travel updates etc etc)

How it works:
There's a python script running pygame which provides the output. The script is extensible in that each screen is a plugin. The user installs just those screens that they want to use.

I will look to implement a button to move on to the next screen, but at the moment the screens rotate on a timed display.

Current screens:

Weather
Image

This uses data provided by WeatherUnderground

Tube status
Image

This uses data provided by TfL

MythTV recordings
Image

This uses MythTV python bindings to poll the backend (needs a bit of effort to get it working!)

Digital clock
Image

Coded by me.

To implement
Bus times
Train times
Football scores
Logitech media server status

I also need a better name for it!


I'll update when I do more.

el_P
Last edited by elParaguayo on Thu Oct 22, 2015 9:32 am, edited 3 times in total.
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

dan3008
Posts: 1172
Joined: Wed Aug 15, 2012 1:05 pm

Re: [WIP] RPi Information Screen

Mon Aug 05, 2013 6:02 pm

Nice little project you got going on their :D

Im interested about how you are implementing the plugins? I've never had a lot of luck with pygame and plugins? Or are each just their own module that when run take control of the display until the next one is called?

either way, I'm interested in helping make plugins for it if you want a hand :)

Drop me a private message if you want anything. I once wrote a bus tracker for my regular bus's here in sheffield, where most track live arrival times to the TSY webpage. I am sure I can mod it for TfL's bus times :)
dan3008 wrote:Pays your money, takes your choice

User avatar
elParaguayo
Posts: 1929
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: [WIP] RPi Information Screen

Mon Aug 05, 2013 8:03 pm

Dan,

Thanks for the comments.

I've got plugins working as follows:
  • Only main script has control of the screen for display purposes.
  • This script uses the imp module to search for python files in the plugins folder.
  • Each plugin must follow a specific template.
  • The main script tries to create an instance of each plugin and stores it in a list.
  • When a plugin is activated, the main script calls the showScreen method from the plugin which creates the surface and returns it to the main script for displaying.
As for your offer to help, the more the merrier plus I'd like to think that people can adapt the program for their own purposes, rather than just using it as a finished product. I'll need to tidy up the script and set up a template plugin. Once that's done, I'll upload the script to github,

In terms of buses, I can do this for London buses (I already have a webserver running on one of my pis which gives me customised travel info for my commute (train, bus and tube) so I can tweak the code pretty quickly).

I also realised that I missed the obvious plugin - digital photo frame.

el_P
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

User avatar
elParaguayo
Posts: 1929
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: [WIP] RPi Information Screen

Tue Aug 06, 2013 9:48 pm

Logitech media server status screen coming along nicely:
Image

Just need to get the details of the next playing track...
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

dan3008
Posts: 1172
Joined: Wed Aug 15, 2012 1:05 pm

Re: [WIP] RPi Information Screen

Thu Aug 15, 2013 8:36 pm

Looks like you've got things coming along pretty well. Dont suppose youre at a point were we can take a peek at the source? I'd love to be able to get a similar system working with my pi :)
dan3008 wrote:Pays your money, takes your choice

User avatar
elParaguayo
Posts: 1929
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: [WIP] RPi Information Screen

Fri Aug 16, 2013 1:39 pm

It's getting closer.

There are still a few things I want to get running better before I post as well as two more screens to complete:
  • London bus departures (80% done)
  • Train departures
Should hope to have something ready to upload by the end of the week.

Biggest issue is going to be how to deal with different screen resolutions. At the moment, everything's hard coded for my screen...
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

dan3008
Posts: 1172
Joined: Wed Aug 15, 2012 1:05 pm

Re: [WIP] RPi Information Screen

Fri Aug 16, 2013 8:07 pm

You can always look into how to get the screen resolution in python? I've done it before, but cant remember how...

If i find anything i'll share
dan3008 wrote:Pays your money, takes your choice

dan3008
Posts: 1172
Joined: Wed Aug 15, 2012 1:05 pm

Re: [WIP] RPi Information Screen

Wed Aug 21, 2013 10:30 pm

This is going to sound silly. I've got loads of code working to do something quite similar to your project, the only thing i'm missing is a weather forecast. Then i'm going to make it customisable, and release the code.

Can i ask how you did the forecast?

thanks

daniel
dan3008 wrote:Pays your money, takes your choice

User avatar
elParaguayo
Posts: 1929
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: [WIP] RPi Information Screen

Thu Aug 22, 2013 6:28 am

I registered for a developer's api at Weather Underground (you get a limited number of free requests per day - should be fine for my needs!) . You then work out the address of the json feed for the data you want and then parse that appropriately.

Should be able to upload some code later today.

Would also be good to see what you're doing.


Apologies for the delay, I've been working on a class to parse football scores from the BBC website. Working version finished and tested last night.
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

User avatar
elParaguayo
Posts: 1929
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: [WIP] RPi Information Screen

Thu Aug 22, 2013 6:33 am

dan3008 wrote:You can always look into how to get the screen resolution in python? I've done it before, but cant remember how...

If i find anything i'll share
The problem isn't so much getting the resolution but how the program deals with it . I could find the resolution and then just scale the output to fill it but that's messy with different aspect ratios and I suspect may end up ugly too.

Ideally what I'd like it's custom layouts designed for specific resolutions ie bigger screens may allow for me information...
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

User avatar
elParaguayo
Posts: 1929
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: [WIP] RPi Information Screen

Thu Aug 22, 2013 11:47 am

Here's an example script for getting weather data:

Code: Select all

#!/usr/bin/python
# -*- coding: utf-8 -*-

import urllib2
import simplejson as json

datasource = "http://api.wunderground.com/api/[YOUR API KEY]/forecast/q/UK/London.json"
page = urllib2.urlopen(datasource)
weather = json.load(page)
detail = weather['forecast']['simpleforecast']['forecastday']

for day in detail:
    weatherdate = day['date']['weekday']
    weatherhigh = day['high']['celsius'] + u'\xb0' + "C"
    weatherlow = day['low']['celsius'] + u'\xb0' + "C"
    weatherpop = str(day['pop']) + "%"
    print weatherdate
    print "\tHigh:\t\t%s" % weatherhigh
    print "\tLow:\t\t%s" % weatherlow
    print "\tChance of rain:\t%s" % weatherpop
    print "-----------------------------"
This will output something like this:

Code: Select all

Thursday
	High:		25°C
	Low:		16°C
	Chance of rain:	70%
-----------------------------
Friday
	High:		26°C
	Low:		17°C
	Chance of rain:	0%
-----------------------------
Saturday
	High:		23°C
	Low:		15°C
	Chance of rain:	60%
-----------------------------
Sunday
	High:		23°C
	Low:		15°C
	Chance of rain:	20%
-----------------------------
As stated earlier, you'll need to register for an API key - see here.
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

dan3008
Posts: 1172
Joined: Wed Aug 15, 2012 1:05 pm

Re: [WIP] RPi Information Screen

Thu Aug 22, 2013 4:20 pm

That's brilliant. Thank you so much, I'll take a proper look, and see about intergrating it. Looks a LOT easyer than the HTML parsing i was trying to get working.

My code is using the display size to determine the sizes of all the text ect, so scales it like that. Its not the pretyest of code, but once i've got a weather screen working, and a config working for all the modules, then I'll release the code :)

Thanks for the help :D
dan3008 wrote:Pays your money, takes your choice

User avatar
elParaguayo
Posts: 1929
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: [WIP] RPi Information Screen

Sat Aug 31, 2013 6:22 pm

Football scores done:
Image
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

User avatar
elParaguayo
Posts: 1929
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: [WIP] RPi Information Screen

Sat Aug 31, 2013 6:58 pm

Buses (showing a few stops in Clapham):
Image

The user can filter bus routes for a particular stop as necessary.
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

fightforlife
Posts: 14
Joined: Thu May 30, 2013 11:02 am

Re: [WIP] RPi Information Screen

Sun Sep 01, 2013 9:29 am

Im very interested in your project. Great work!

Do you think it would be possible to use your screens on one of these: http://www.ebay.de/itm/350859490117?ssP ... 1497.l2649?

nexusrex
Posts: 234
Joined: Thu Jul 04, 2013 2:25 pm

Re: [WIP] RPi Information Screen

Sun Sep 01, 2013 10:41 am

I'm very interested in your project. Great work !
i will make a portable gaming computer with raspbian image
can i use the Weather and the Digital clock but for egypt
i want to make a program use your Weather and the Digital clock
if anyone can help me will be good
my questions is
1- how do you make the Weather
2- how do you make the Digital clock
3- can i add the the Weather and the Digital clock on my program
4- i want to make my program like google now i mean a weather forecast and a digital clock and google search and voice orders
like play "name of the song or video"
do you recommend for me google search or voice google search

User avatar
elParaguayo
Posts: 1929
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: [WIP] RPi Information Screen

Sun Sep 01, 2013 7:56 pm

fightforlife wrote:Im very interested in your project. Great work!

Do you think it would be possible to use your screens on one of these: http://www.ebay.de/itm/350859490117?ssP ... 1497.l2649?
I'm not sure. This script uses PyGame to output to the monitor (via HDMI or RCA). That monitor looks like it would need to connect via GPIO pins so would likely need coding differently. You may want to ask how the screen works in one of the other sub-forums here.
nexusrex wrote:I'm very interested in your project. Great work !
i will make a portable gaming computer with raspbian image
can i use the Weather and the Digital clock but for egypt
i want to make a program use your Weather and the Digital clock
if anyone can help me will be good
my questions is
1- how do you make the Weather
2- how do you make the Digital clock
3- can i add the the Weather and the Digital clock on my program
4- i want to make my program like google now i mean a weather forecast and a digital clock and google search and voice orders
like play "name of the song or video"
do you recommend for me google search or voice google search
Taking your questions in turn:

Weather and clock for Egypt:
Clock: Yes. Provided you've set your timezone correctly the clock will show the right time.
Weather: I'd expect this to work. You'd need to register for a developer's API at WeatherUnderground and then change the datasource link in the script (assuming they have a data feed for Egypt). If WeatherUnderground don't have the data then you just need to find a different website with the right data and adapt the script.

1) How does the weather work - see code example earlier in this thread - I've given an example.
2) Everything is done in Pygame. The script creates a surface and then displays it. For the clock, it's as simple as get the time, get a digital font and display it.
3) What's your program? You may not need PyGame but you can still use the data in your program. You may want to start a separate thread to get help on your program.
4) Search the forum for this - I've seen scripts that use Google voice search (e.g. http://blog.oscarliang.net/raspberry-pi ... like-siri/)

Good luck!
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

nexusrex
Posts: 234
Joined: Thu Jul 04, 2013 2:25 pm

Re: [WIP] RPi Information Screen

Sun Sep 01, 2013 8:17 pm

elParaguayo wrote:
fightforlife wrote:Im very interested in your project. Great work!

Do you think it would be possible to use your screens on one of these: http://www.ebay.de/itm/350859490117?ssP ... 1497.l2649?
I'm not sure. This script uses PyGame to output to the monitor (via HDMI or RCA). That monitor looks like it would need to connect via GPIO pins so would likely need coding differently. You may want to ask how the screen works in one of the other sub-forums here.
nexusrex wrote:I'm very interested in your project. Great work !
i will make a portable gaming computer with raspbian image
can i use the Weather and the Digital clock but for egypt
i want to make a program use your Weather and the Digital clock
if anyone can help me will be good
my questions is
1- how do you make the Weather
2- how do you make the Digital clock
3- can i add the the Weather and the Digital clock on my program
4- i want to make my program like google now i mean a weather forecast and a digital clock and google search and voice orders
like play "name of the song or video"
do you recommend for me google search or voice google search
Taking your questions in turn:

Weather and clock for Egypt:
Clock: Yes. Provided you've set your timezone correctly the clock will show the right time.
Weather: I'd expect this to work. You'd need to register for a developer's API at WeatherUnderground and then change the datasource link in the script (assuming they have a data feed for Egypt). If WeatherUnderground don't have the data then you just need to find a different website with the right data and adapt the script.

1) How does the weather work - see code example earlier in this thread - I've given an example.
2) Everything is done in Pygame. The script creates a surface and then displays it. For the clock, it's as simple as get the time, get a digital font and display it.
3) What's your program? You may not need PyGame but you can still use the data in your program. You may want to start a separate thread to get help on your program.
4) Search the forum for this - I've seen scripts that use Google voice search (e.g. http://blog.oscarliang.net/raspberry-pi ... like-siri/)

Good luck!
1) i will see it
2) thanks
3) my program is a PA (Personal Assistant) put your clock program and a weather program and google voice search and a PA together
4) THANKS!!!
now my problem is
where is your clock script
sorry i'm something a beginer

User avatar
elParaguayo
Posts: 1929
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: [WIP] RPi Information Screen

Sun Sep 01, 2013 8:43 pm

nexusrex wrote: 1) i will see it
2) thanks
3) my program is a PA (Personal Assistant) put your clock program and a weather program and google voice search and a PA together
4) THANKS!!!
now my problem is
where is your clock script
sorry i'm something a beginer
Don't worry about being a beginner - it's fantastic that people are inspired to try something new with the Raspberry Pi.

As for my clock script, it's not available yet - still tidying up code before I post it. However, if you're looking at displaying dates from a script, look at the Python datetime module.
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

nexusrex
Posts: 234
Joined: Thu Jul 04, 2013 2:25 pm

Re: [WIP] RPi Information Screen

Sun Sep 01, 2013 9:27 pm

thanks
but do you have any site have an example for the script

User avatar
elParaguayo
Posts: 1929
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: [WIP] RPi Information Screen

Mon Sep 02, 2013 5:36 pm

NexusRex,

Here's a very basic script which gives you an idea of how my clock works. I'll leave it to you to work out how to change font, colours etc (there's lots of information on Google that taught me everything in this project - but don't be afraid to ask for help if you get stuck).

Code: Select all

#!/usr/bin/python

# Import the appropriate modules
import pygame
from time import strftime

# Set the screen size
size = (300,150)

# Initialise pygame
pygame.init()

# Set our screen size
screen = pygame.display.set_mode(size)

# Set header (useful for testing, not so much for full screen mode!)
pygame.display.set_caption("Test clock script")

# Stop keys repeating (not so necessary for this script, but useful if you want to capture other key presses)
pygame.key.set_repeat()


# Function to show our clock
def showClock(clockScreen):
    # Fill the screen with a black background
    clockScreen.fill((0,0,0))
    
    # Define some fonts to draw text with
    myfont = pygame.font.SysFont(None, 100)
    myfontsmall = pygame.font.SysFont(None, 50)
    
    # Create the strings to display
    mytime = strftime("%H:%M")
    mysecs = strftime("%S")
    
    # Render the strings
    clocklabel = myfont.render(mytime, 1, (255,255,255))
    secondlabel = myfontsmall.render(mysecs, 1, (255,255,255))
    
    # And position them on the screen
    textpos = clocklabel.get_rect() # Gets the rectangle of the hours and minutes...
    textpos.centerx = clockScreen.get_rect().centerx # ...and center horizontally...
    textpos.centery = clockScreen.get_rect().centery # ...and vertically
    secpos =  (textpos[0] + textpos[2] + 10, textpos[1] + textpos[3] - 55) # A bit of trial and error to position the seconds
    
    # Draw the text onto our screen
    clockScreen.blit(secondlabel, secpos)
    clockScreen.blit(clocklabel, textpos) 
    
    # Update the display (i.e. show the output of the above!)
    pygame.display.flip()


# Set up a boolean for a clean loop
quitloop=False

# Set up a variable to check when to refresh display
refresh = 0

# Run our main loop
while not quitloop:
    for event in pygame.event.get():
        
        # Handle quit message received
        if event.type == pygame.QUIT:
            quitloop = True 
        
        # 'Q' to quit    
        if (event.type == pygame.KEYUP): 
            if (event.key == pygame.K_q):
                quitloop = True
    
    # If pygame's clock is greater than our variable then we need to update display
    if pygame.time.get_ticks() > refresh:
        
        # Run the function to update display      
        showClock(screen)
        
        # Update refresh time to 500ms in the future
        refresh = pygame.time.get_ticks() + 500

# This will only happen once the above loop has ended.                
print "Exiting..."
If you've got any further questions on how to do something for your own programme please post them in a new thread. I'd prefer to keep this thread to discussions about the information screen project.

el_P
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

southpaw
Posts: 52
Joined: Wed Nov 30, 2011 2:23 pm

Re: [WIP] RPi Information Screen

Mon Sep 02, 2013 6:25 pm

nice job elParaguayo, i am very much interested in your work, i have purchased the same 7"display and have api for my local weather from wunderground (thanks for link), hoping to use it in a similar situation to yours, I don't require bus route data but sure I can think of other data I can use instead. would be eternally grateful if you do post your work when complete, not trying to rush you, just thought I would let you know there are others interested in this besides the guys that have posted above. Unfortunately this is one of those subjects that appeals to noobs so I may require a bit of hand holding and will probably end up asking a daft question or 2 along the way
best wishes and once again, many thanks

nexusrex
Posts: 234
Joined: Thu Jul 04, 2013 2:25 pm

Re: [WIP] RPi Information Screen

Mon Sep 02, 2013 6:50 pm

elParaguayo wrote:NexusRex,

Here's a very basic script which gives you an idea of how my clock works. I'll leave it to you to work out how to change font, colours etc (there's lots of information on Google that taught me everything in this project - but don't be afraid to ask for help if you get stuck).

Code: Select all

#!/usr/bin/python

# Import the appropriate modules
import pygame
from time import strftime

# Set the screen size
size = (300,150)

# Initialise pygame
pygame.init()

# Set our screen size
screen = pygame.display.set_mode(size)

# Set header (useful for testing, not so much for full screen mode!)
pygame.display.set_caption("Test clock script")

# Stop keys repeating (not so necessary for this script, but useful if you want to capture other key presses)
pygame.key.set_repeat()


# Function to show our clock
def showClock(clockScreen):
    # Fill the screen with a black background
    clockScreen.fill((0,0,0))
    
    # Define some fonts to draw text with
    myfont = pygame.font.SysFont(None, 100)
    myfontsmall = pygame.font.SysFont(None, 50)
    
    # Create the strings to display
    mytime = strftime("%H:%M")
    mysecs = strftime("%S")
    
    # Render the strings
    clocklabel = myfont.render(mytime, 1, (255,255,255))
    secondlabel = myfontsmall.render(mysecs, 1, (255,255,255))
    
    # And position them on the screen
    textpos = clocklabel.get_rect() # Gets the rectangle of the hours and minutes...
    textpos.centerx = clockScreen.get_rect().centerx # ...and center horizontally...
    textpos.centery = clockScreen.get_rect().centery # ...and vertically
    secpos =  (textpos[0] + textpos[2] + 10, textpos[1] + textpos[3] - 55) # A bit of trial and error to position the seconds
    
    # Draw the text onto our screen
    clockScreen.blit(secondlabel, secpos)
    clockScreen.blit(clocklabel, textpos) 
    
    # Update the display (i.e. show the output of the above!)
    pygame.display.flip()


# Set up a boolean for a clean loop
quitloop=False

# Set up a variable to check when to refresh display
refresh = 0

# Run our main loop
while not quitloop:
    for event in pygame.event.get():
        
        # Handle quit message received
        if event.type == pygame.QUIT:
            quitloop = True 
        
        # 'Q' to quit    
        if (event.type == pygame.KEYUP): 
            if (event.key == pygame.K_q):
                quitloop = True
    
    # If pygame's clock is greater than our variable then we need to update display
    if pygame.time.get_ticks() > refresh:
        
        # Run the function to update display      
        showClock(screen)
        
        # Update refresh time to 500ms in the future
        refresh = pygame.time.get_ticks() + 500

# This will only happen once the above loop has ended.                
print "Exiting..."
If you've got any further questions on how to do something for your own programme please post them in a new thread. I'd prefer to keep this thread to discussions about the information screen project.

el_P
thanks and i will make a post for the program

User avatar
elParaguayo
Posts: 1929
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: [WIP] RPi Information Screen

Mon Sep 02, 2013 7:04 pm

southpaw wrote:nice job elParaguayo, i am very much interested in your work, i have purchased the same 7"display and have api for my local weather from wunderground (thanks for link), hoping to use it in a similar situation to yours, I don't require bus route data but sure I can think of other data I can use instead. would be eternally grateful if you do post your work when complete, not trying to rush you, just thought I would let you know there are others interested in this besides the guys that have posted above. Unfortunately this is one of those subjects that appeals to noobs so I may require a bit of hand holding and will probably end up asking a daft question or 2 along the way
best wishes and once again, many thanks
I'll try to post something soon. Just trying to find a nice way to allow user to set appropriate variables.
As for being noob, join the club! I'm making this up as I go along.
Will be great if you can find more uses for this - that was always my hope.
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

dan3008
Posts: 1172
Joined: Wed Aug 15, 2012 1:05 pm

Re: [WIP] RPi Information Screen

Tue Sep 03, 2013 7:29 am

I'm using easyGui for my config screens. I'll be sharing my progress soon, its almost finished, so I'll show you soon :)
dan3008 wrote:Pays your money, takes your choice

Return to “Other projects”

Who is online

Users browsing this forum: No registered users and 3 guests