In the last 3 blogs (1, 2, 3) I explained how the first attempt to run a Photo Wall on a Raspberry Pi failed as there is no browser on Pi able to use the GPU and efficiently run the code linked above.
The next attempt is using JavaFX. And it succeeded.
I use a Pi2 with Raspbian Jessie Lite (so no Desktop), as I want to save CPU / memory on my PI for the “real thing” :), the Photo Wall.
On my Pi I run Oracle JDK 8 of type “Linux ARM 32 Hard Float ABI” + Gluon JavaFX Embedded SDK which I installed on my Pi according to the instructions (“2.1.4. Embedded”).
You can find the sources for the Java FX Photo Wall at GitHub, and you can either build it with maven or import it in Eclipse for further development on top of it. Once you built it, you may start it by calling:
sudo /opt/jdk1.8.0_111/bin/java -jar Wall2-0.0.1-SNAPSHOT.jar
You may also try to run it as a non-root, and be ready to ignore the warnings you get and the experiment how good it works as non-root.
Probably the most important aspect you should consider is the hint about finding a ttf font file to use in the application. This is NOT a feature, it is just a workaround for an issue (I’d call it bug) appearing between FTFactory.java (line 102 – 106) and libfreetype.so (starting on line 2129 + 2514). I don’t know why in Java class it happens that I get for:
error = OSFreetype.FT_New_Face(library, buffer, 0, ptr);
error to be != 0; It could be because some setting is wrong on my PI, but however before calling
it would probably be a good idea to verify if face != null; As I feel that in my case it happens that face == null, and most probably if face == null, probably a “Done_Face” on that face would however make no sense. Maybe throwing a checked exception with some nice error message to let one understand what went wrong would be a better approach. Of course, it might be you have more luck than I had and you can comment out the 2 lines in the App.java class:
Font.loadFont(getClass().getResource("/DejaVuSans.ttf").toExternalForm(), 10); scene.getStylesheets().add(getClass().getResource("/app.css").toExternalForm());
as it could be that your PI is correctly configured. However, if the application breaks during the start, just follow the mentioned hint. As I said, these lines are actually not at all needed, as I’m NOT writing anything on the screen, but apparently the ProgressBar needs a Font (although no text is displayed) and hence there is an error during the start.
Another point you should consider is memory split: Using
and then “9 Advanced Options” -> “A3 Memory Split” you may set the CPU / GPU memory split. I allocated 512 MB for the GPU. I had out of memory problems with less than that.
And finally I disabled the overscan, as otherwise the JavaFX screen was partially displayed out of screen. So my file “/boot/config.txt” contains this (uncommented) line: disable_overscan=1 . You can either directly edit the file (take care what you do ! you may break your PI OS) or probably achieve the same result using the raspi-config application.
Btw, details about the source for the displayed images in the two cgi-bin blogs: here and here. And if you want to get some nice frames for your photos, then check here.
For any questions, bug reports, suggestions, use the appropriate thread in the Raspberry PI forum.
Leave a Reply