I have a program written in Processing 3.x, which I have tested on an x86 PC, after exporting the program without bundling Java. The same process also exported an arm64 and armv6hf version. I tested the linux64 version with OpenJDK 11.x on my PC and it works OK.
When I run the arm64 or the armv6hf program on a Raspberry Pi with OpenJDK 11.x installed, my 1000 x 1000 pixel screen opens up but its just blank. I don’t get my graphics, even though the /data folder has the graphics PNG files.
I suspect this has something to do with the serial interface, on which data is streaming in from a data source on a RasPi Pico. But then, on the PC, if there’s a serial interface missing, the Processing program just hangs. On the RasPi 4, the screen is opening up sans graphics but nothing is locking up. So it just could be something else…
Is there a way I can scan the serial interfaces and select an interface programmatically?
My Processing code, Arduino Pico code and graphics files are as under:
Processing code:
import processing.serial.*; //importing serial library
PImage beam; // to store meter needle image
PImage display; // to store meter image
PImage mapTile; // store map tile
float increment;
float previousAzimuth = 0;
float currentAzimuth = 0;
float plottedAzimuth;
String azimuthString;
int nl = 10;
int inByte; //to store incomming value from serial port
int reading=0; //to store mapped inByte value
Serial azimuth; //naming our serial port as "arduino"
void setup(){ //only runs one time when program starts
background(0); //making background color as black
size(1000, 1000); //output window size 1000 x 1000 pixel
//fullScreen(); //output window size full screen
beam=loadImage("RadarBeam.png"); //loading timebase image
display=loadImage("RadarDisplay.png"); //loading radar rose image
mapTile=loadImage("Centre_Delhi.png"); //loading map tile
//beam.resize(66, 66); //resizing needle image to fit our meter
//printArray(Serial.list()); //listing serial port to find the port in which arduino is connected
azimuth = new Serial(this, Serial.list()[0], 115200); //initializing port, in my case arduino is no.4 in the list
}
void draw(){ //this will loop by 60 frame per second by default , frame rate can be changed by frameRate() function
if (azimuth.available()>0){ //checking whether there is incomming serial values
azimuthString = azimuth.readStringUntil(nl);
if (azimuthString != null){
currentAzimuth = float(azimuthString);
}
//currentAzimuth=azimuth.read(); //storing incoming values to variable inByte
if (currentAzimuth != previousAzimuth){
plottedAzimuth = currentAzimuth;
previousAzimuth = currentAzimuth;
}
else{
plottedAzimuth = previousAzimuth;
}
}
imageMode(CENTER); //draw image using center mode
//image(mapTile, width/2, height/2);
tint(255,255);
image(display, width/2, height/2); //drawing meter image
tint (255,128); //first param is tint color. second param is alpha channel
image(mapTile, width/2, height/2);
pushMatrix(); //saving current transformation matrix onto the matrix stack
imageMode(CORNERS); //draw image using corners mode
translate((width/2)+0, (height/2)+2); //translating "(width/2)+2, (height/2)+15" to "0,0"
//rotate(((HALF_PI)-19.69)+ plottedAzimuth); //rotation needle image to position to zero in meter image
rotate(-(HALF_PI) + radians(currentAzimuth));
image(beam, 0, 0, 350, 2); //drawing needle image
popMatrix();//removing the current transformation matrix off the matrix stack
println(currentAzimuth);
}
Arduino code:
int azimuth = 0;
void setup() {
Serial.begin(115200);
}
void loop() {
for(int i=0; i<360; i++){
//Serial.write(i);
Serial.println(i);
delayMicroseconds(28000);
}
}