added server
This commit is contained in:
parent
9ff3d5654f
commit
4532f82d84
|
@ -1,38 +1,24 @@
|
||||||
import processing.serial.*;
|
import processing.serial.*;
|
||||||
|
import processing.net.*;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import spout.*;
|
import spout.*;
|
||||||
|
|
||||||
boolean spoutactive=true;
|
boolean spoutactive=true;
|
||||||
|
|
||||||
Spout spout;
|
Spout spout;
|
||||||
|
|
||||||
|
|
||||||
PFont fontregular;
|
PFont fontregular;
|
||||||
|
|
||||||
PImage image_line;
|
PImage image_line;
|
||||||
|
|
||||||
Serial myPort;
|
Serial myPort;
|
||||||
|
Server myServer;
|
||||||
String val = "0.0";
|
String val = "0.0";
|
||||||
|
|
||||||
int speeds_show=10;
|
int speeds_show=10;
|
||||||
float[] speeds=new float[speeds_show];
|
float[] speeds=new float[speeds_show];
|
||||||
int speeds_index=0; //points to next array index
|
int speeds_index=0; //points to next array index
|
||||||
|
|
||||||
float speedfloat=0;
|
float speedfloat=0;
|
||||||
|
|
||||||
float triggerspeedmin=15; //current triggerspeed
|
float triggerspeedmin=15; //current triggerspeed
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PrintWriter pw;
|
|
||||||
|
|
||||||
int unitdisplay=0;
|
int unitdisplay=0;
|
||||||
int unitdisplay_count=9; //how much different units available
|
int unitdisplay_count=9; //how much different units available
|
||||||
|
|
||||||
|
|
||||||
int xtextstart=10;
|
int xtextstart=10;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
@ -42,6 +28,7 @@ void setup() {
|
||||||
fontregular=createFont("Montserrat-Regular.ttf",64);
|
fontregular=createFont("Montserrat-Regular.ttf",64);
|
||||||
textFont(fontregular);
|
textFont(fontregular);
|
||||||
|
|
||||||
|
myServer = new Server(this, 2323);
|
||||||
image_line = loadImage("bleeptrackline.png");
|
image_line = loadImage("bleeptrackline.png");
|
||||||
|
|
||||||
//String portName = "COM5";
|
//String portName = "COM5";
|
||||||
|
@ -62,8 +49,6 @@ void setup() {
|
||||||
|
|
||||||
sendSpeedTrapValue(int(triggerspeedmin));
|
sendSpeedTrapValue(int(triggerspeedmin));
|
||||||
|
|
||||||
//pw=createWriter("speeds.txt");
|
|
||||||
|
|
||||||
background(0);
|
background(0);
|
||||||
|
|
||||||
|
|
||||||
|
@ -103,6 +88,7 @@ void draw() {
|
||||||
//triggerspeedmin=getTimesMax();
|
//triggerspeedmin=getTimesMax();
|
||||||
sendSpeedTrapValue(int(triggerspeedmin));
|
sendSpeedTrapValue(int(triggerspeedmin));
|
||||||
|
|
||||||
|
myServer.write(str(speedfloat));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -151,17 +137,15 @@ void draw() {
|
||||||
//Line
|
//Line
|
||||||
image(image_line, 10, 100);
|
image(image_line, 10, 100);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int reducesizefactor=40;
|
int reducesizefactor=40;
|
||||||
int lastytextpos=200;
|
int lastytextpos=200;
|
||||||
|
|
||||||
for (int i=speeds_show;i>0;i--){
|
for (int i=speeds_show;i>0;i--){
|
||||||
float colorpercentage=i*1.0/speeds_show;
|
float colorpercentage=i*1.0/speeds_show;
|
||||||
fill(0,132*colorpercentage+163*(1-colorpercentage),176*colorpercentage+86*(1-colorpercentage));
|
fill(0,132*colorpercentage+163*(1-colorpercentage),176*colorpercentage+86*(1-colorpercentage));
|
||||||
textSize(50-(1-colorpercentage)*reducesizefactor);
|
textSize(50-(1-colorpercentage)*reducesizefactor);
|
||||||
text( nf(speeds[(speeds_show+speeds_index-1+i)%speeds_show], 1,2) + " km/h", xtextstart, lastytextpos);
|
text( nf(speeds[(speeds_show+speeds_index-1+i)%speeds_show], 1,2) + " km/h", xtextstart, lastytextpos);
|
||||||
lastytextpos+=50-(1-colorpercentage)*reducesizefactor;
|
lastytextpos+=50-(1-colorpercentage)*reducesizefactor;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
textSize(40);
|
textSize(40);
|
||||||
|
@ -183,6 +167,7 @@ float getTimesMax(){
|
||||||
}
|
}
|
||||||
return speedmax;
|
return speedmax;
|
||||||
}
|
}
|
||||||
|
|
||||||
float getTimesPercentile(float p){ //p==1 would be max value
|
float getTimesPercentile(float p){ //p==1 would be max value
|
||||||
float[] sortedspeeds=sort(speeds);
|
float[] sortedspeeds=sort(speeds);
|
||||||
return sortedspeeds[int(p*sortedspeeds.length)];
|
return sortedspeeds[int(p*sortedspeeds.length)];
|
||||||
|
|
Loading…
Reference in New Issue