简体   繁体   English

JavaFX输出到SPI总线而不是RPi上的HDMI

[英]JavaFX output to the SPI bus instead of HDMI on a RPi

I am experimenting with a JavaFX application on a raspberry. 我正在树莓上试验JavaFX应用程序。 It works great on my HDMI monitor, and the rendered size seems all ok. 它可以在我的HDMI监视器上很好地工作,并且呈现的尺寸似乎还可以。

However, I now have added my 3.5 inch touch screen running on the SPI interface but I still get the JavaFX output on the HDMI monitor. 但是,我现在添加了在SPI接口上运行的3.5英寸触摸屏,但仍在HDMI监视器上获得了JavaFX输出。 It works ok for the graphical interface. 对于图形界面,它可以正常工作。 The console appears on the 3.5 inch LCD, so I guess I need to set a setting somewhere for JavaFX to also output the 3.5 LCD, but I cannot remember how to do this. 该控制台出现在3.5英寸LCD上,因此我想我需要为JavaFX设置一个设置以也输出3.5 LCD,但是我不记得该怎么做。

[Edit:] This is my (shortened) application code: [编辑:]这是我的(缩短的)应用程序代码:

public class Main extends Application {

    private static int width = 480;
    private static int height = 320;

    static final Text statusText = new Text(25, 300, "(no status update)");
    static final Label messagesArea = new Label("");

    @Override
    public void start(Stage stage) throws Exception {
        stage.setTitle("Registration UHF scanner");
        final Group rootGroup = new Group();
        final Scene scene = new Scene(rootGroup, width, height, Color.BLACK);

        final Text title = new Text(25, 45, "Youth 2000 UHF Registration");
        title.setFill(Color.WHITESMOKE);
        title.setFont(Font.font(java.awt.Font.SERIF, FontWeight.BOLD, 25));
        rootGroup.getChildren().add(title);

        messagesArea.setWrapText(true);
        messagesArea.setStyle("-fx-font-family: \"Comic Sans MS\"; -fx-font-size: 16; -fx-text-fill: white;");
        messagesArea.setTranslateX(25);
        messagesArea.setTranslateY(35);

        rootGroup.getChildren().add(messagesArea);

        statusText.setFill(Color.WHITESMOKE);
        statusText.setFont(Font.font(java.awt.Font.SERIF, 16));
        rootGroup.getChildren().add(statusText);

        scene.addEventFilter(KeyEvent.ANY, new EventHandler<KeyEvent>() {
                @Override
                public void handle(KeyEvent keyEvent) {
                    System.out.println("Key pressed: " + keyEvent.getCode());
                    if (keyEvent.getCode() == KeyCode.ENTER) {
                        System.out.println("Test!");
                    }
                }
            });

        Button shutDown = new Button("Shutdown");
        shutDown.setPrefWidth(110);
        shutDown.setPrefHeight(10);
        shutDown.setTranslateX(width - 115);
        shutDown.setTranslateY(height - 35);
        rootGroup.getChildren().add(shutDown);

        Button restart = new Button("Restart");
        restart.setPrefWidth(110);
        restart.setPrefHeight(10);
        restart.setTranslateX(width - 115);
        restart.setTranslateY(height - 75);
        rootGroup.getChildren().add(restart);

        shutDown.setOnAction(new EventHandler<ActionEvent>() {
            @Override public void handle(ActionEvent e) {
                // Shutdown the computer.
                try {
                    shutDown();
                } catch (Exception ex){
                    System.out.println("Problem shutting down: " + ex.getMessage());
                    setStatusText("Problem shutting down!!!!");
                }
            }
        });

        restart.setOnAction(new EventHandler<ActionEvent>() {
            @Override public void handle(ActionEvent e) {
                // Shutdown the computer.
                try {
                    restartServer();
                } catch (Exception ex){
                    System.out.println("Problem restarting: " + ex.getMessage());
                    setStatusText("Problem restarting!!!!");
                }
            }
        });

        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        System.out.println("Starting system...");

        if (System.getProperty("screenWidth") != null) {
            width = Integer.valueOf(System.getProperty("screenWidth"));
        }

        if (System.getProperty("screenHeight") != null) {
            height = Integer.valueOf(System.getProperty("screenHeight"));
        }

        Application.launch(args);

    }
}

There is a need to mirror the FrameBuffer to the SPI. 需要将FrameBuffer镜像到SPI。 fbcp: https://github.com/tasanakorn/rpi-fbcp fbcp: https//github.com/tasanakorn/rpi-fbcp

The main display has to be configured correctly to have the same resolution. 主显示器必须正确配置为具有相同的分辨率。 So in /boot/config.txt. 因此在/boot/config.txt中。 In my case: 就我而言:

disable_overscan=1

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

That only left me with a little problem left with the touch screen as the xy are swapped. 交换xy时,触摸屏只剩下一点点问题。 This should be able to be fixed by changing the 应该可以通过更改

swap_xy=X 

parameter in /etc/modules but for me that hasn't worked so far. / etc / modules中的参数,但对我来说到目前为止还没有奏效。 I do want to use the screen in landscape, so rotating the image is not really an option. 我确实想在横向使用屏幕,所以旋转图像并不是真正的选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM