Solution Sprint 6 -- Digital Signage
From BUGwiki
Contents |
The Problem
Not enough signs on Broadway.
The Solution
We will create a digital sign system using a BUG and a projector. Passers by can interact with the sign via Twitter and text message. Based on the messages that the sign receives it could ...
- Display the message.
- Show a Google Image Search/Flickr search result related to the message.
- Move some sort of game piece.
- ...
Materials
- BUGbase running Linaro-based rootfs
- Projector
Design
Display System
Web browser (which one?)
Webkit + GTK + Python
We can use Webkit, GTK, and Python to create a full-screen web browser.
Here's how I got it working:
opkg install libwebkitgtk-1.0-dev # BEGIN BROKEN DEV TOOL WORKAROUND # mkdir -p /opt/buildbot/slave/build_repo_full/build/tmp/sysroots/x86_64-linux/ mkdir -p /opt/jenkins/workspace/oe-buglabs-sw2.1-scratch/oe-tmp/sysroots/x86_64-linux/ ln -s /usr /opt/buildbot/slave/build_repo_full/build/tmp/sysroots/x86_64-linux/usr ln -s /usr /opt/jenkins/workspace/oe-buglabs-sw2.1-scratch/oe-tmp/sysroots/x86_64-linux/usr # END BROKEN DEV TOOL WORKAROUND # wget http://pywebkitgtk.googlecode.com/files/pywebkitgtk-1.1.8.tar.gz tar xzf pywebkitgtk-1.1.8.tar.gz cd pywebkitgtk-1.1.8 ./configure --prefix=/usr make make install
Here's a Python program that creates a window and opens a given url:
import sys import gtk import webkit site = "http://www.google.com" if len(sys.argv) == 2: site = sys.argv[1] print "site is", site window = gtk.Window() view = webkit.WebView() view.open(site) window.add(view) window.show_all() window.fullscreen() window.connect('delete-event', lambda window, event: gtk.main_quit()) gtk.main()
Save it to a file called pywebkit_example.py, then set the display and run it like this:
export DISPLAY=:0.0 python pywebkit_example.py http://webkit.willfixeverything.com
You should see a full screen browser open up and display the page.
Twitter Interaction
Which libraries/APIs?
Text Message Interaction
Which libraries/APIs?
Communication Backend and Browser
Socket.io? xmlhttprequest() polling? etc?
Comet/AJAX (xmlrequest) and Java
Ajax for Java developers: Write scalable Comet applications with Jetty and Direct Web Remoting
Webkit and JavaScript Bindings
If we use webkit then we might be able to create JavaScript bindings that could be used to communicate with the webkit container. We could then write JNI bindings between this program and the Java backend. Or we could use some form of IPC. Either way, the JavaScript binds would simplify the client (browser) code.
socket.io
There is a Java library for socket.io. It seems to require Jetty 7.2.2 because later versions of Jetty changed the constructor interface for at least one of the classes that is used by the library.