mwrich4
Posts: 21
Joined: Wed Jul 25, 2012 1:24 pm
Location: Stuart, Florida

Java FX on non-console LCD

Sat May 13, 2017 6:30 pm

I've developed using windows and most recently C/Asm on an embedded system using an LCD display with touchscreen.

I thought it would be an enlightening experience to add an LCD screen to a raspberry Pi and use Java to create a small interface to serve as my 'Hello World' experience for this platform.

My LCD is one of the many 3.5 320x480 SPI models like the Waveshare model (which I discovered later). I have successfully tested my panels using the Adafruit tutorial and helps for having the system boot with the console on the LCD. However, I want to leave the console in its default configuration and use the LCD as an extension to the base system. Eventually, this would become a foundation for various embedded/headless ideas I might have.

After many frustrating hours searching the RaspPi forums and google, I was surprised to not find any postings from anyone else trying this configuration. Also, I couldn't find a cohesive howto for installing Java with JavaFX including setting up a development environment. I have installed Java with JavaFX using the distro from ChrisWhoCodes. Eventually, I also got a clean compile with some test code.

My next step, I believe, is to set up a system that uses the LCD as a console, revert the console to the HDMI. This way I know I have the SPD/LCD driver installed, which is something I haven't been able to find out how to do without someone else's predefined script. Then install Java with JavaFX, and then again try some small test code. Writing to the lcd, just a circle or hello world would be a great start.

I'd appreciate any directions for finding my way to this goal.

As I progress, I start each investigation with a clean Raspbian image, fully updated, including any niceties like my favorite browser, VNC configuration, remote shell and other settings preconfigured. I hope to eventually produce a guide to share.

Thanks in advance,
Mark

mwrich4
Posts: 21
Joined: Wed Jul 25, 2012 1:24 pm
Location: Stuart, Florida

Re: Java FX on non-console LCD

Tue Jun 06, 2017 6:02 pm

I've found a promising post here Is it possible to force Java to write all graphics output to FrameBuffer? that seems to be what I want. It points to this article Java: Graphics in Linux.

While I chew on this info, I'm gonna post the 2 github repositories mentioned for documentation sake.

Desktop/Android/HTML5/iOS Java game development framework
Acces to Linux frame buffer devices from Java. E.g. for driving LCD SPI displays on the Raspberry Pi

and on it goes . . .

User avatar
xranby
Posts: 535
Joined: Sat Mar 03, 2012 10:02 pm
Contact: Website

Re: Java FX on non-console LCD

Wed Jun 07, 2017 10:27 am

mwrich4 wrote:My LCD is one of the many 3.5 320x480 SPI models like the Waveshare model (which I discovered later). I have successfully tested my panels using the Adafruit tutorial and helps for having the system boot with the console on the LCD. However, I want to leave the console in its default configuration and use the LCD as an extension to the base system.
Hi to redirect the output to the attached framebuffer serial LCD i would use a tool called raspi2fb
https://github.com/AndrewFromMelbourne/raspi2fb

raspi2fb allows the JavaFX output to the primary "DispmanX" display to be mirrored to the attached LCD display.

You have to compile raspi2fb from source using the instructions on the github page.
Xerxes Rånby @xranby I once had two, then I gave one away. Now both are in use every day!
twitter.com/xranby

User avatar
bitbank
Posts: 171
Joined: Sat Nov 07, 2015 8:01 am
Location: Sarasota, Florida
Contact: Website

Re: Java FX on non-console LCD

Wed Jun 07, 2017 1:03 pm

mwrich4 wrote:I've found a promising post here Is it possible to force Java to write all graphics output to FrameBuffer? that seems to be what I want. It points to this article Java: Graphics in Linux.

While I chew on this info, I'm gonna post the 2 github repositories mentioned for documentation sake.

Desktop/Android/HTML5/iOS Java game development framework
Acces to Linux frame buffer devices from Java. E.g. for driving LCD SPI displays on the Raspberry Pi

and on it goes . . .
What specific type of information are you trying to send to the secondary LCD? If it's just simple text and graphics primitives, you can just talk to the display directly using code like mine (https://github.com/bitbank2/SPI_LCD). I created simple C functions to draw text, rectangles and image tiles. These can be called through the JNI interface.
The fastest code is none at all :)

mwrich4
Posts: 21
Joined: Wed Jul 25, 2012 1:24 pm
Location: Stuart, Florida

Re: Java FX on non-console LCD

Wed Jun 07, 2017 4:47 pm

bitbank wrote: What specific type of information are you trying to send to the secondary LCD? If it's just simple text and graphics primitives, you can just talk to the display directly using code like mine (https://github.com/bitbank2/SPI_LCD). I created simple C functions to draw text, rectangles and image tiles. These can be called through the JNI interface.
Yes, I'd start with simple text and graphics primitives. Since there's a touchpad available, I'd at least make some hotspots. Depending on my satisfaction level by then, buttons and perhaps a simple numpad for entry. I was hoping JavaFX would provide the widgets and interaction code.

I had thought of using C, but I thought a journey through Java and JavaFX might be interesting and bolster my resume. I did the display handling in a pure C project before, although it wasn't a serial display, with buttons and simple windowing. Lots of work.

I know I've picked a task that's quite a mouthful. I'm surprised how few are using the Pi like this, even after 5 years. When the Pi came out there were so few 'capable and cheap' development boards, I expected this path to have already been followed. Even JavaFX looks like it didn't finish maturing for the Pi platform. It looks like only an intrepid few have tried, judging by Google results.

mwrich4
Posts: 21
Joined: Wed Jul 25, 2012 1:24 pm
Location: Stuart, Florida

Re: Java FX on non-console LCD

Wed Jun 07, 2017 4:55 pm

xranby wrote: raspi2fb allows the JavaFX output to the primary "DispmanX" display to be mirrored to the attached LCD display.
I'll take a look at this, thanks. I've been avoiding investigating 'mirrored' solutions because I had imagined using a headless system, perhaps without X, to make some small turnkey device.

It seems to me that mirrored output would require the app to be running in a graphical environment and simply copy the canvas to the other display. I'd rather learn about making a separate virtual canvas and have JavaFX use that for the contents to be sent to serial LCD panel. It seems the most efficient or pure to me, but I'm new to this platform.

User avatar
Gavinmc42
Posts: 1339
Joined: Wed Aug 28, 2013 3:31 am

Re: Java FX on non-console LCD

Tue Jun 27, 2017 10:37 am

I think Netbeans comes with JavaFX examples.
Started with the Stopwatch example, but have not tested it on an LCD.
I have used it to overlay cluster dials on omxplayer videos
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

Return to “Java”

Who is online

Users browsing this forum: No registered users and 4 guests