adrian.oconnor
Posts: 30
Joined: Mon Nov 14, 2011 9:51 pm
Contact: Website

Writing a display-board application for Raspberry Pi

Tue May 22, 2012 11:03 am

My first project, when my Raspberry Pi arrives in a couple of weeks time (hopefully), will be to create some sort of information display board for the office using the Raspberry Pi connected to a TV on a wall. It'll show useful information (on a loop) that it'll pull from a server.

Right now, I'm just trying to pull together information and sources that I think will help me map out the app before I start writing it, and I'd love your advice/feedback/tips:

The data that it pulls will describe screens. Each screen will contain text items (with bounding boxes and style information for the text) and images (URLs and coordinates to display them). The items will be drawn in-order, and will hopefully support alpha etc. Screens will be shown in sequence, and will wrap back to the start after the last screen. It'll check for updates to the JSON periodically.

The app will be written in C and will use OpenGL ES for drawing graphics on the screen.

I'm not a C programmer by trade (I switch between .NET/C#, Java, Javascript, Objective-C/iOS and a few others), but I do know C well enough that I'll get by. I don't know OpenGL especially well yet either (I did go through the NeHe tutorials a while ago, so I know I can pick it up), and I think I shall buy this book: http://www.amazon.co.uk/OpenGL-ES-2-0-P ... 713&sr=8-1). Despite both of those things, I think C and OpenGL are the best options for this programme, given the Raspberry Pi's limitations and the way I want it to work.

I'll follow the information on this blog post (http://benosteen.wordpress.com/2012/04/ ... x-windows/) to use OpenGL ES without X Windows, because that seems sensible (not least of all because it makes it really easy to start from SSH).

One thing I'm really not sure about is drawing text on the screen. Does anybody know what kind of font rendering options we have with OpenGL ES and the Raspberry PI? Ideally, I'll be able to use OpenType fonts or something and have them nicely aliased at large sizes. I don't know if that's even possible, but I really hope so. I'd definitely rather render the text on the device (rather than pre-render it as images), just because it'll make it easier to update the display as information changes.

The data will be JSON, so it'll probably use the json-c library or Jansson (http://www.digip.org/jansson/). Rather than fetch the data over HTTP, I might use ZeroMQ and have a little control app on a remote PC or something (or maybe even both 0MQ and HTTP if it makes sense). The ZeroMQ support would make it easy to push data from other apps (like a web app, for instance). I'll probably write a little supporting app in Rails for updating the screens.

Do you think these are good choices? Would Python/SDL be any better? Does Python/SDL work on on Raspberry Pi without X and with full HW-acceleration?

If it works out (and is genuinely useful), I'll do this as an open-source thing in my spare time.

Any feedback is much appreciated. I won't start any thing until I actually have a Pi to work on, and it looks like it's still 3 weeks away, but that gives me time to think about it and work out what I want it to do.

Thanks!
Adrian

felix123
Posts: 153
Joined: Tue May 15, 2012 6:06 am

Re: Writing a display-board application for Raspberry Pi

Tue May 22, 2012 11:58 am

Are you planning to do it as a programming exercise? If not then you might want to check out xibo, which does pretty much the same thing, I think some people in the forum are trying to run it on the Raspberry

Sent from my A501 Using ForumTouch for Android

adrian.oconnor
Posts: 30
Joined: Mon Nov 14, 2011 9:51 pm
Contact: Website

Re: Writing a display-board application for Raspberry Pi

Tue May 22, 2012 2:24 pm

Xibo looks interesting, but I don't think it'll do what I want. I will certainly check it out though -- if there's already a tool that does the job I won't write another just as an exercise. My main objective is to drive things from a database (so we can review on-going changes in another system), and that means having a really flexible way of adding data to the screen from another app on the network. RSS feeds probably won't let us do that, where-as a 0MQ queue and a suitable JSON syntax would.

Thanks for the pointer, I'll give it a proper look later.


adrian.oconnor
Posts: 30
Joined: Mon Nov 14, 2011 9:51 pm
Contact: Website

Re: Writing a display-board application for Raspberry Pi

Tue May 22, 2012 6:28 pm

Thanks for the suggestion, Bsport. Graphene looks good, but a web app isn't really what I'm thinking -- I could do that myself with little trouble in Rails or .NET (and just make it bespoke to my needs -- I need to display a stream of stuff ).

Besides, my reasons for doing it this way are so we can make the most of the R-Pi's limited memory -- not having a web browser or X loaded should theoretically give us more RAM to play with and give us, hopefully, a more responsive system. That said, I haven't actually use a Pi yet, so maybe it'd work just fine in X with Firefox or Chrome and a bunch of Javascript to animate the images and text I want to show?

theHetman
Posts: 88
Joined: Tue Jan 10, 2012 5:42 pm

Re: Writing a display-board application for Raspberry Pi

Tue May 22, 2012 7:31 pm

The Pi supports OpenVG 1.1 and I think that's what you need for your project.

http://www.khronos.org/registry/vg/

It's a 2D library that will draw lines, curves and filled objects along with rendering bitmaps. V1.1 has font rendering and you can apply 2D transforms to all objects as well as filters and blend modes.

adrian.oconnor
Posts: 30
Joined: Mon Nov 14, 2011 9:51 pm
Contact: Website

Re: Writing a display-board application for Raspberry Pi

Tue May 22, 2012 7:47 pm

OpenVG looks very interesting, thank you for that (I'd never even heard of it before). I'll certainly spend some time trying it out. Fonts look non-trivial, but I bet there'll be examples out there to learn from...

Bsport
Posts: 3
Joined: Tue May 22, 2012 3:25 pm

Re: Writing a display-board application for Raspberry Pi

Thu May 24, 2012 2:43 pm

Be interested to see how you get on with this, as Ive got a project thats going to require something like this.

I had just thought of going the web based route myself. Best example i've seen is http://www.panic.com/blog/2010/03/the-p ... tus-board/ but they used a TV with embedded windows xp machine, articles a little out of date now. so a normal TV and raspberry pi would be enough.

adrian.oconnor
Posts: 30
Joined: Mon Nov 14, 2011 9:51 pm
Contact: Website

Re: Writing a display-board application for Raspberry Pi

Thu May 24, 2012 3:05 pm

I hadn't seen that particular Panic blog post before, but I love what they did. That's really good. I actually know love the Panic blog for two things: the Audion story, and his crazy fireworks pictures :) I also bought Coda 2 and Diet Coda this morning :)

So I guess a web browser is probably the easiest (and maybe smartest way to go). I've been a web programmer for over 10 years now, so it'd make sense from a getting-things-done point of view, but I think it'll limit the amount of animation I can do -- I really need to display a constant stream of ever-changing images that we can review and flag if we need to. I could be wrong, but I'm assuming that Chrome on something as low-powered as a Raspberry Pi wouldn't do so well as OpenGL.

I'll have a play with both options when the Pi finally arrives and post back here...

Bsport
Posts: 3
Joined: Tue May 22, 2012 3:25 pm

Re: Writing a display-board application for Raspberry Pi

Thu May 24, 2012 3:17 pm

somewhere on the forums someone put together a virtual machine of a raspberry pi, if you havent got one yet.

In regard to performance maybe worth looking into Web GL and pushing the rendering to the GPU.

Just finished install coda 2 myself... code folding YAY

adrian.oconnor
Posts: 30
Joined: Mon Nov 14, 2011 9:51 pm
Contact: Website

Re: Writing a display-board application for Raspberry Pi

Thu May 24, 2012 7:28 pm

Is WebGL accelerated, given that it's Linux, on ARM, on Raspberry Pi, in X? If any one of those things stops acceleration, it's going to be horribly slow.

I did see that people have had the RasPi image running in qemu, but I don't really have the time/inclination myself. I'll just wait until I finally get a board -- I ordered last week and RS said 3 weeks in the delivery field...

theHetman
Posts: 88
Joined: Tue Jan 10, 2012 5:42 pm

Re: Writing a display-board application for Raspberry Pi

Thu May 24, 2012 8:19 pm

Currently X Windows has no hardware acceleration and is rather slow. Even scrolling a window of text is not very fast. I doubt if you will get much performance from running your application in a browser under X on the Pi for a while yet. The GPU is fast though and writing a application that can be run from the shell and uses OpenVG would be very quick.

adrian.oconnor
Posts: 30
Joined: Mon Nov 14, 2011 9:51 pm
Contact: Website

Re: Writing a display-board application for Raspberry Pi

Thu May 31, 2012 9:25 am

Thanks for your input, @theHetman. OpenVG looks great -- I think it'll be useful for many things I want to do, and I'm glad I have it in my toolkit. I've been playing with MonkVG, using it with the iOS SDK. I think it will do all I need. Would you recommend that library for RaspberryPi too, or is there some other OpenVG implementation that might work even better? Do I even need a third party library with RPi?

In my spare time, I'm going to start prototyping this app on iOS using stuff that I'm already familiar with (ASIHttp, JSONKit and so on). The only problem with this approach is that if Apple announce that AppleTV is going to soon support apps (at WWDC in a couple of weeks), it'll probably spell the end of my interest in using the RPi for this purpose (especially if RS still haven't shipped my RaspberryPi... at least I can get my hands on an AppleTV).

I do have one more question -- how do you create fonts for OpenVG? I have a 512x512 image with Arial bold that I found in the MonkVG project, and it looks like it was auto generated by a tool -- do you know what tools do that?

Many thanks,
Adrian

theHetman
Posts: 88
Joined: Tue Jan 10, 2012 5:42 pm

Re: Writing a display-board application for Raspberry Pi

Thu May 31, 2012 12:35 pm

adrian.oconnor wrote:Thanks for your input, @theHetman. OpenVG looks great -- I think it'll be useful for many things I want to do, and I'm glad I have it in my toolkit. I've been playing with MonkVG, using it with the iOS SDK. I think it will do all I need. Would you recommend that library for RaspberryPi too, or is there some other OpenVG implementation that might work even better? Do I even need a third party library with RPi?
OpenVG is a native API on the Pi so you don't need another Library. You just include the header and link the library and you are good to go (well you need to link EGL too). I'm working on a framework for doing graphics demos on the Pi and I plan to do some OpenVG demos. As yet I've not really looked in detail at OpenVG API.
In my spare time, I'm going to start prototyping this app on iOS using stuff that I'm already familiar with (ASIHttp, JSONKit and so on). The only problem with this approach is that if Apple announce that AppleTV is going to soon support apps (at WWDC in a couple of weeks), it'll probably spell the end of my interest in using the RPi for this purpose (especially if RS still haven't shipped my RaspberryPi... at least I can get my hands on an AppleTV).

I do have one more question -- how do you create fonts for OpenVG? I have a 512x512 image with Arial bold that I found in the MonkVG project, and it looks like it was auto generated by a tool -- do you know what tools do that?
You know that OpenVG renders outline fonts? As I've said I've not looked at the API in depth yet so I'm not sure what type of fonts it uses but it will certainly be an open format and I'm sure there are many free fonts to choose from.

godFather89
Posts: 150
Joined: Fri May 18, 2012 9:40 am
Location: Timisoara, RO

Re: Writing a display-board application for Raspberry Pi

Thu May 31, 2012 12:42 pm

adrian.oconnor wrote:I'm not a C programmer by trade (I switch between .NET/C#, Java, Javascript, Objective-C/iOS and a few others), but I do know C well enough that I'll get by. I don't know OpenGL especially well yet either (I did go through the NeHe tutorials a while ago, so I know I can pick it up), and I think I shall buy this book: http://www.amazon.co.uk/OpenGL-ES-2-0-P ... 713&sr=8-1). Despite both of those things, I think C and OpenGL are the best options for this programme, given the Raspberry Pi's limitations and the way I want it to work.
Why not use QT?

adrian.oconnor
Posts: 30
Joined: Mon Nov 14, 2011 9:51 pm
Contact: Website

Re: Writing a display-board application for Raspberry Pi

Thu May 31, 2012 1:06 pm

@theHetman I wondered about outline fonts. I got a bit lost in the OpenVG spec. I also wonder if that's something that MonkVG doesn't implement. Being able to use an OpenType (or any) scalable font would be excellent (as long as OpenVG also has methods for measuring the text etc, which I guess it must do). I guess I won't get to play with OpenVG proper until I get my RaspberryPi.

@godFather89 I haven't used Qt before, so I don't know if it's a good fit or not. I figured that I've already got my work cut out learning OpenGL ES, so I don't really want to add anything else on top. If it turns out to be a good fit, I'd certainly take a look. Does Qt require X windows?

obijywk
Posts: 9
Joined: Sat May 12, 2012 10:56 pm
Location: New York

Re: Writing a display-board application for Raspberry Pi

Thu May 31, 2012 2:13 pm

Here's an example from the mesa project of using a freetype font as an outline font with OpenVG/EGL:
http://cgit.freedesktop.org/mesa/demos/ ... nvg/text.c

I've been planning to get something like this running on Raspberry Pi but haven't had time to complete it yet.

godFather89
Posts: 150
Joined: Fri May 18, 2012 9:40 am
Location: Timisoara, RO

Re: Writing a display-board application for Raspberry Pi

Thu May 31, 2012 7:17 pm

adrian.oconnor wrote:Does Qt require X windows?
No. And it's hardware accelerated. Also QML is very easy to use if you already know Javascript, HTML, CSS. Of course, you can combine all the above with the speed and power of C++.

obijywk
Posts: 9
Joined: Sat May 12, 2012 10:56 pm
Location: New York

Re: Writing a display-board application for Raspberry Pi

Fri Jun 01, 2012 4:11 am

I've got OpenVG freetype text rendering running.
The performance seems quite good - it's rendering a 1920x1080 screen of 48 "Hello World" strings at 60fps using only 10% cpu.

I put the code in github here: https://github.com/obijywk/rpresent

adrian.oconnor
Posts: 30
Joined: Mon Nov 14, 2011 9:51 pm
Contact: Website

Re: Writing a display-board application for Raspberry Pi

Fri Jun 01, 2012 2:14 pm

@obijywk awesome - thanks for sharing your code, that's really useful. I had a look at the FreeType library last night after @theHetman pointed me in the right direction. I'll try and get it running on MonkVG so I can have a play with it this weekend, but if not I'll just wait for my RPi.

Out of interest, and totally unrelated, but does the GCC that comes with the ARM distribution of Linux support Objective C (and does anybody know if it'd work well with this sort of stuff)?

User avatar
AndrewS
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
Contact: Website

Re: Writing a display-board application for Raspberry Pi

Tue Jun 05, 2012 6:50 pm

adrian.oconnor wrote:Out of interest, and totally unrelated, but does the GCC that comes with the ARM distribution of Linux support Objective C?
On the Debian distro, gcc -v says:

Code: Select all

Using built-in specs.
Target: arm-linux-gnueabi
Configured with: ../src/configure -v --with-pkgversion='Debian 4.4.5-8' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.4 --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --disable-sjlj-exceptions --enable-checking=release --build=arm-linux-gnueabi --host=arm-linux-gnueabi --target=arm-linux-gnueabi
Thread model: posix
gcc version 4.4.5 (Debian 4.4.5-8)
So "yes" ;)

Twinkletoes
Posts: 210
Joined: Fri May 25, 2012 9:44 pm

Re: Writing a display-board application for Raspberry Pi

Tue Jun 05, 2012 9:06 pm

Take a look at OpenSplash - an open source media player designed for signage. It's built from plugins and it's easy to replace any plugin to make it talk to your favourite RSS feed or CMS. It runs on Windows, Debian, Fedora, iOS and Android.

www.opensplash.net

I've integrated it with 3 different CMS packages and it took about 5 days each time, mainly implementing the protocol of each CMS.

obijywk
Posts: 9
Joined: Sat May 12, 2012 10:56 pm
Location: New York

Re: Writing a display-board application for Raspberry Pi

Fri Jun 08, 2012 4:55 am

I uploaded some more code to https://github.com/obijywk/rpresent
I added a weather demo that pulls some weather data from Google and displays it.
The interesting bit here is probably downloading the GIF into ImageMagick, copying it into an OpenVG image, and then drawing it with (ugly pixelated) hardware-accelerated scaling.

adrian.oconnor
Posts: 30
Joined: Mon Nov 14, 2011 9:51 pm
Contact: Website

Re: Writing a display-board application for Raspberry Pi

Fri Jun 08, 2012 9:00 am

@obijywk: That is really excellent thanks for that. My RaspberryPi turned up yesterday, so I can start playing with OpenVG properly at last :) (though not till next week, because I have a really busy weekend ahead, and also because I loaned out my HDMI cable, and also because my Apple wired keyboard doesn't seem to work, so I need to find another...)

Really nice to see the XML code too -- I've done plenty of XML work before, but never in C++, so have your code to bootstrap things is really handy. I'll probably still use JSON for my own project though.

User avatar
ajstarks
Posts: 129
Joined: Fri Jun 22, 2012 2:14 am

Re: Writing a display-board application for Raspberry Pi

Wed Aug 15, 2012 1:09 am

Here's a small library built on OpenVG running on the Raspberry Pi:

https://github.com/ajstarks/openvg.

It's a high-level API working using shapes (Circle, Ellipse, Rectangle, Rounded Rectangle, Polygon lines (polyline, straight), curves (Arc, Quadratic and Cubic Bezier) and images. Text display works for any TrueType font (the basic library embeds DejaVu Sans, Serif, and Mono).

Output samples: http://www.flickr.com/photos/ajstarks/s ... 913689774/

Return to “General programming discussion”