B4J Question Raspbian and B4J problem

ta1dr

Member
Licensed User
Longtime User
Hi All

I want to make like HMI device on raspbery pi 2 also write code B4J and copy java 1.8.0 download b4j-bridge.jar all ok
but my code work all pc notebook and netbook (windows xp,windows 7 and windows 8) didnt work raspbery pi

this code sample gauge trying...

B4X:
#Region  Project Attributes
    #MainFormWidth: 300
    #MainFormHeight: 400
  
#End Region

Sub Process_Globals
    Private fx As JFX
    Dim aci As Short=0
    Private MainForm As Form
    Dim csvGauge, csvNeedle As Canvas
    Dim bmpGauge, bmpNeedle As Image
    Dim imvGauge, imvNeedle As ImageView
    'Dim SRectGauge, DRectGauge, SRectNeedle, DRectNeedle As Rect
    Private ImageView1 As ImageView
    Private Button1 As Button
    Private Label1 As Label
    Private lbl2   As Label
    Private Slider1 As Slider
    Private my_font As Font
  
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.SetFormStyle("UNIFIED")
    MainForm.RootPane.LoadLayout("ekran1") 'Load the layout file.
    MainForm.Resizable=False
    MainForm.BackColor=fx.Colors.Blue
    MainForm.Show
    MainForm.Title="Gauge Test    Ahmet UCAN"
  
  
    csvGauge.Initialize("cvs")
    csvNeedle.Initialize("csv")
    lbl2.Initialize("")
    bmpGauge=fx.LoadImage(File.DirAssets,"led_base.png")
    bmpNeedle=fx.LoadImage(File.DirAssets,"led_nedle.png")
    Dim w,h As Double
    w=bmpGauge.Width '+ 100
    h=bmpGauge.Height'+100
    MainForm.RootPane.AddNode(csvGauge, 10, 10, w,h)
    MainForm.RootPane.AddNode(csvNeedle, 10, 10, bmpNeedle.Width,bmpNeedle.Height)
    MainForm.RootPane.AddNode(lbl2,120,180,100,50)
    csvGauge.DrawImage(bmpGauge,0dip,0dip,w,h)
    aci=0
    move_needle(0)
    Label1.Text="0"
    lbl2.Alpha=1
    lbl2.TextColor=fx.Colors.Red
    lbl2.Font=fx.CreateFont("",22,True,False)
    lbl2.Text="---"
End Sub
Sub Button1_Action
    'Dim x,y As Double
    Dim deg As Short
    If aci < 180 Then
        aci=aci + 1
    Else
        aci=0
    End If
    deg=(-90)+ aci
    move_needle(deg)
  
End Sub
Sub slider1_ValueChange (Value As Double)
    Dim a,n As Int
    n=Value
    a=(-90)+n
    move_needle(a)
    lbl2.Text=n
End Sub
Sub move_needle(teta As Short)
    Dim x,y As Double
    x=Abs(csvGauge.Width - csvNeedle.Width)/2
    y=Abs(csvGauge.Height - csvNeedle.Height)/2
    csvNeedle.ClearRect(x,y,bmpNeedle.Width,bmpNeedle.Height)
    Label1.Text=teta
    csvNeedle.DrawImageRotated(bmpNeedle,x,y,bmpNeedle.Width,bmpNeedle.Height,teta)
  
End Sub

I tried some way
a-) via bridge LTX terminal write program start and give error about 10 secons and RB lock
b-) copy jar file RB downloads folder and on LTC terminan

B4X:
[email protected] $ cd Downloads
[email protected] /Downloads $ java -jar gauge.jar
program start

about 10seconds give error and RB lock

c-) I tried Similey.jar ( example code from Erel) a and b method it is work on RB but RB like a lock mouse work , keyboard not work I want stop program I am cut power..

I didnt know what is the wrong ? I tried this about one week no any solition.
do you have any idea ?
(termination of my project had little time)

on PC screenshot
gauge_test.jpg
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I tried Similey.jar ( example code from Erel) a and b method it is work on RB but RB like a lock mouse work
This is how JavaFX apps work on the Raspberry Pi.

Run your app with B4J-Bridge and then you will be able to kill it from the IDE.

Does it work if you create a new project, without loading any layout?

Have you downloaded the correct java version as explained here: https://www.b4x.com/android/forum/t...b4j-from-the-scratch.59784/page-2#post-382028 ?

You should set the full path to this java when you run b4j-bridge.
 
Upvote 0

ta1dr

Member
Licensed User
Longtime User
Hi Erel

You right I load correct JAVA your link (jdk-8-linux-arm....) and
a-) I tried unpack tar file on LTX terminal (sudo tar.... ) and tried my code ( non-ui , ui) result same
b-) install java ( I read this toturial ) and tried again result same..
http://www.rpiblog.com/2014/03/installing-oracle-jdk-8-on-raspberry-pi.html

I tried last night
a-) if non-UI code work via bridge and sudo usr/bin/java......... command line on LTX terminal
b-) id any layout ( UI via WYS...designer) nor work...

I'm sleepless :)

no_ui_code.jpg ui_code.jpg
 
Upvote 0

ta1dr

Member
Licensed User
Longtime User
yep I tried that code

B4X:
    #MainFormWidth: 200
    #MainFormHeight: 200
#End Region

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.SetFormStyle("UNIFIED")
    MainForm.RootPane.LoadLayout("layout_me") 'Load the layout file.
    MainForm.Resizable=False
    MainForm.Show

win7 pc screenshot

win7_ss.jpg

and raspberry screenshot

rb_ss.jpg

I test via b4j-bridge...
 
Upvote 0

ta1dr

Member
Licensed User
Longtime User
You might get better results if you use scene builder instead of the internal designer.

I thing it is better way...

I tried button , slider and textfield give error..

tried canvas,label no any error..

thanks for all
 
Upvote 0

ta1dr

Member
Licensed User
Longtime User
new screenshot ( raspberry Pi 7" Touchscreen display photo)

PC:win8 java 8.60 and B4J & scene builder
RB:raspbian, java 1.8.0


resim1.jpg resim2.jpg
 
Upvote 0
Top