8

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.

1 Answer 1

1

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).

2
  • Thanks! What about drawing? How do I draw text at a certain coordinate of the screen?
    – David C
    Commented Apr 5, 2014 at 0:46
  • I have absolutely no idea! Never used a framebuffer or pi before–I just know my way around the IO library enough to push data to one. I'd ask another question about the format of the data. It seems like your own experience from pygame would be a good place to start looking. Commented Apr 5, 2014 at 4:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.