Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a Ruby app that talks to the framebuffer?

I have a Raspberry PiTFT 7" Touchscreen display and I'd like to create a simple app to display and output system data (ie. CPU usage, temperature etc).

I've noticed that the current common method of implementing this is to use the pygame library to output into the framebuffer /dev/fb1 in which the display is connected to.

I'd like to perform the same action but using Ruby as I am more familiar with the language.

Can someone point me in the right direction as to how do I get started?

I've looked at both rubygame and gosu libraries, and they seem to be able to do what I want to do, which is to draw a screen but I am unable to find any information as to how to direct the output into the framebuffer itself.

like image 288
David C Avatar asked Mar 27 '14 16:03

David C


1 Answers

The ruby corelib has an IO class you should be able to use to direct output to the framebuffer, say:

device = IO.sysopen '/dev/fb1'
buffer = IO.new device, 'a'
buffer.puts "Your usecase."

You can use the same pattern to interact with many of the special /dev files, such as writing to /dev/null or reading from /dev/random (although both of these are better abstracted already through File::NULL and Random).

like image 76
Chris Keele Avatar answered Sep 30 '22 12:09

Chris Keele