add voltage, current, steer, speed and yaw
This commit is contained in:
parent
49b28848bc
commit
2019f08869
|
@ -3,36 +3,50 @@ import processing.serial.*;
|
||||||
Serial serialport;
|
Serial serialport;
|
||||||
Visualization visVoltage;
|
Visualization visVoltage;
|
||||||
Visualization visCurrent;
|
Visualization visCurrent;
|
||||||
|
Visualization visSteer;
|
||||||
|
Visualization visSpeed;
|
||||||
|
Visualization visYaw;
|
||||||
|
|
||||||
|
int steer=0;
|
||||||
|
int speed=0;
|
||||||
float voltage = 50;
|
float voltage = 50;
|
||||||
float current = 0.0;
|
float current = 0.0;
|
||||||
|
float yaw=0;
|
||||||
|
|
||||||
long lastReceive=0; //last time serial received
|
long lastReceive=0; //last time serial received
|
||||||
long lastDelay=0;
|
long lastDelay=0;
|
||||||
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
size(640, 360);
|
size(640, 450);
|
||||||
frameRate(100);
|
frameRate(100);
|
||||||
|
|
||||||
printArray(Serial.list());
|
printArray(Serial.list());
|
||||||
serialport = new Serial(this, Serial.list()[2], 115200);
|
serialport = new Serial(this, Serial.list()[32], 57600);
|
||||||
|
|
||||||
|
|
||||||
visVoltage = new BarV(50,150,10,100,10*3.3,12*4.2);
|
visVoltage = new BarV(50,150,10,100,10*3.3,12*4.2);
|
||||||
visVoltage.setcmain(color(100,100,100));
|
visVoltage.setcmain(color(100,100,100));
|
||||||
//vis = new BarH(150,150,100,10,0,100);
|
//vis = new BarH(150,150,100,10,0,100);
|
||||||
//visVoltage = new Tacho(150,150,100,0,100);
|
//visVoltage = new Tacho(150,150,100,0,100);
|
||||||
//vis = new Direction(150,150,100,0,100,0,1);
|
//vis = new Direction(150,150,100,0,100,0,1,0);
|
||||||
|
|
||||||
visVoltage.setShowMinMax(true);
|
visVoltage.setShowMinMax(true);
|
||||||
visVoltage.setTitle("Voltage [V]");
|
visVoltage.setTitle("Voltage [V]");
|
||||||
|
|
||||||
visCurrent= new Tacho(150+250,150,100,0,50);
|
visCurrent= new Tacho(150+250,150,100,0,100);
|
||||||
visCurrent.setShowMinMax(true);
|
visCurrent.setShowMinMax(true);
|
||||||
visCurrent.setTitle("Current [A]");
|
visCurrent.setTitle("Current [A]");
|
||||||
|
|
||||||
|
visSteer = new BarH(10,340,100,10,-1000,1000);
|
||||||
|
visSteer.setTitle("Steer");
|
||||||
|
|
||||||
|
visSpeed = new BarV(10+100/2-5,300,10,100,-1000,1000);
|
||||||
|
visSpeed.setTitle("Speed");
|
||||||
|
|
||||||
|
visYaw = new Direction(150+250,300,100,0,360,0,1,0);
|
||||||
|
visYaw.setTitle("Yaw");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw() {
|
void draw() {
|
||||||
|
@ -41,10 +55,16 @@ void draw() {
|
||||||
background(255);
|
background(255);
|
||||||
visVoltage.setValue(voltage);
|
visVoltage.setValue(voltage);
|
||||||
visCurrent.setValue(current);
|
visCurrent.setValue(current);
|
||||||
|
visSteer.setValue(steer);
|
||||||
|
visSpeed.setValue(speed);
|
||||||
|
visYaw.setValue(yaw);
|
||||||
|
|
||||||
|
|
||||||
visVoltage.drawVis();
|
visVoltage.drawVis();
|
||||||
visCurrent.drawVis();
|
visCurrent.drawVis();
|
||||||
|
visSteer.drawVis();
|
||||||
|
visSpeed.drawVis();
|
||||||
|
visYaw.drawVis();
|
||||||
|
|
||||||
fill(color(0,0,0));
|
fill(color(0,0,0));
|
||||||
textSize(12);
|
textSize(12);
|
||||||
|
@ -53,22 +73,27 @@ void draw() {
|
||||||
_delay=millis()-lastReceive;
|
_delay=millis()-lastReceive;
|
||||||
}
|
}
|
||||||
text("Delay="+(_delay), 5,12);
|
text("Delay="+(_delay), 5,12);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void receive()
|
public void receive()
|
||||||
{
|
{
|
||||||
boolean received=false;
|
boolean received=false;
|
||||||
byte[] inBuffer = new byte[8];
|
byte[] inBuffer = new byte[16];
|
||||||
while(serialport.available()>0) {
|
while(serialport.available()>0) {
|
||||||
received=true;
|
|
||||||
inBuffer = serialport.readBytes();
|
inBuffer = serialport.readBytes();
|
||||||
serialport.readBytes(inBuffer);
|
serialport.readBytes(inBuffer);
|
||||||
if (inBuffer != null) {
|
if (inBuffer != null && inBuffer.length==16) {
|
||||||
voltage = extract_float(inBuffer,0);
|
received=true;
|
||||||
current = extract_float(inBuffer,4);
|
|
||||||
|
steer = extract_int16_t(inBuffer,0);
|
||||||
|
speed = extract_int16_t(inBuffer,2);
|
||||||
|
voltage = extract_float(inBuffer,4);
|
||||||
|
current = extract_float(inBuffer,8);
|
||||||
|
yaw = extract_float(inBuffer,12);
|
||||||
|
//println("yaw="+yaw);
|
||||||
|
println("voltage="+voltage);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue