dwilliss
dwilliss

Reputation: 924

JavaFX Screen size?

I'm using a PiTFT on my pi and running a JavaFX program. I got the output going to the PiTFT by running fbcp in the background. I had to set disable_overscan=1 in /boot/config.txt to get it to show the whole image. That all works fine now.

My problem is that the touch screen calibration doesn't seem to effect JavaFX apps. The X and Y axis are swapped. Does anybody know how to calibrate the touch screen for JavaFX apps?

I don't know if this is a problem with the touchscreen driver for the PiTFT or a JavaFX configuration problem, so I'm going to post the same question to the adafruit forums and if I get an answer in one place, I'll copy it to the other.

Upvotes: 1

Views: 974

Answers (1)

hsilomedus
hsilomedus

Reputation: 221

I've struggled with the same problem today, and I managed to figure it out.

The PiTFT is by default a portrait display with a resolution of 240x320. The driver conf is originally made to rotate the display. The touchscreen setting for X are aware of that and have the rotate option set accordingly. And yes, this will not affect JavaFX since it doesn't run in X.

What I did:

in /boot/config.txt

disable_overscan=1
framebuffer_width=480
framebuffer_height=640
#set specific CVT mode
hdmi_cvt 480 640 60 1 0 0 0
#set CVT as default
hdmi_group=2
hdmi_mode=87
hdmi_force_hotplug=1

With this, the main display resolution is set to 480x640, and overscan is disabled.

Next, in /etc/modprobe.d/adafruit.conf, change the rotate option to be 0.

Save everything and reboot. Then fbcp & java Main, and it should be working OK.

Btw, be aware that I used the pre-built raspbian image from adafruit.

Upvotes: 2

Related Questions