Current situation: a simple imageviewer in a loop. I'm displaying still images by using the framebuffer via fbi. I generate the list of images by a simple script right before firing it up. It runs in an infinite loop. To stop the slideshow, my script fetches the pid of fbi and kills the process.

Now I'd like to have some extra functionality by implementing a physical 'PREV' and 'NEXT' button, attached to the GPIO pins.

The most simple approach will be to launch a seperate process listening to those 2 buttons, kill the fbi process at press, re-write the imagelist and restart fbi. While this is easy to design, something tells me there must be a better, cleaner approach.

I assume I could modify the fbi source and implement the functionality right into it. This will take an awfull lot more effort though as my coding skills might not suffice to bring this approach to a good end.

What other approaches are possible?

  • I think this sort of question asking for opinions might be better suited to a forum such as raspberrypi.org/forums
    – joan
    Sep 16 '15 at 8:28
  • does fbi allow this sort of control from a keyboard? If so you should be able to send those key strokes programmatically to the fbi stdio based on GPIO activity.
    – rob
    Sep 16 '15 at 11:59

Given your issue seems to be with the messiness of restarting fbi, which is intended to be interactive program, here's a (perhaps) better approach (but still simple):

Get imagemagick:

sudo apt-get install imagemagick

Use it to convert images as needed directly to the framebuffer. Depends on your framebuffer (which you can details on in /sys/class/graphics). Lets say the framebuffer was 640x480, and color depth 8:8:8. Then you could use a single command line something like (untested):

convert -size 640x480 -depth 8 my_image.png rgb:- > /dev/fb0

There may be some trickiness if your fb is 5:6:5 format, as I believe imagemagick does not support that.

Note that because imagemagick's convert utility understands practically every image format, you can replace my_image.png with most any image. (Imagemagick has lots of other nifty features, too, for example if you wanted to add text or other overlays).

  • I will test this out but I'm scared about the performance. Currently I use imagemagick to generate every image out of several layers (picture, text, top and sidebanner). The Pi2 clearly is struggling during this process. But your idea to divert it to /dev/fb0 might open a different angle. Perhaps I can convert > file before and write the results to /dev/fb0 at a later stage?
    – EDP
    Sep 17 '15 at 6:36
  • 1
    If you don't need the images converted on the fly, then yes, you can certainly convert before hand, and just save a set of raw image files that are ready to be sent to the framebuffer. At that point, you can just write them directly to the framebuffer (via cat, for example). But you may get a little bit better performance using dd (something like "dd if=image1.raw of=/dev/fb0 bs=1m")
    – Brian
    Sep 17 '15 at 14:03
  • Sounds very promising. The dev/fb0 combined with using dd, this opens a lot of possibilities to my digital signage projects. I'll put this to the testsbank asap. I assume that I also can write partial content to the framebuffer, and so eliminate my initial layering-scripting?
    – EDP
    Sep 17 '15 at 14:20
  • Yes - in fact, you can use dd with the seek option to write to a specific portion of the framebuffer. For example, if you wanted to just update the bottom quarter of the screen (perhaps for a banner), you could seek to that position and only write there.
    – Brian
    Sep 17 '15 at 14:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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