change voltage diagram to bar

This commit is contained in:
interfisch 2019-06-09 23:23:57 +02:00
parent 373dca44d6
commit 5d7d8371f9
1 changed files with 11 additions and 8 deletions

View File

@ -14,20 +14,22 @@ long lastDelay=0;
void setup() {
size(640, 360);
frameRate(100);
printArray(Serial.list());
serialport = new Serial(this, Serial.list()[2], 9600);
serialport = new Serial(this, Serial.list()[2], 115200);
//vis = new BarV(150,150,10,100,0,100);
visVoltage = new BarV(50,150,10,100,10*3.3,12*4.2);
visVoltage.setcmain(color(100,100,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);
visVoltage.setShowMinMax(true);
visVoltage.setTitle("Voltage [V]");
visCurrent= new Tacho(150+250,150,100,0,100);
visCurrent= new Tacho(150+250,150,100,0,50);
visCurrent.setShowMinMax(true);
visCurrent.setTitle("Current [A]");
@ -36,7 +38,6 @@ void setup() {
void draw() {
receive();
background(255);
visVoltage.setValue(voltage);
visCurrent.setValue(current);
@ -59,15 +60,17 @@ void draw() {
public void receive()
{
boolean received=false;
byte[] inBuffer = new byte[8];
while(serialport.available()>0) {
//inBuffer = serialport.readBytes();
received=true;
inBuffer = serialport.readBytes();
serialport.readBytes(inBuffer);
//if (inBuffer != null) {
if (inBuffer != null) {
voltage = extract_float(inBuffer,0);
current = extract_float(inBuffer,4);
//}
}
}
if (received){