fix serial receive brake trim whitespaces

This commit is contained in:
interfisch 2021-03-29 01:22:07 +02:00
parent bb1841b4a6
commit fadd889722
1 changed files with 9 additions and 5 deletions

View File

@ -6,7 +6,8 @@ int vis_textsize=12; //copy from Visualization class
String logfile_name="LOG00180_random.TXT";
boolean useSerial=true; //false=read from csv log, true=read from serial port
String serial_port="COM3";
//String serial_port="COM3";
String serial_port="/dev/ttyUSB0";
Serial serial;
String serialString=""; //last read string
int serial_endchar=10; //10=ASCII Linefeed
@ -77,7 +78,8 @@ int brake;
color bg=color(0);
void setup() {
size(1920, 1080);
//size(1920, 1080);
size(1000, 800);
frameRate(100);
if (useSerial) {
@ -163,7 +165,7 @@ void setup() {
vis_throttle.setcmain(c_throttle);
vis_throttle.setTitle("Throttle");
color c_brake=color(200,200,50);
vis_brake = new BarH_cmd((int)(pos_vis_inputs.x-size_vis_inputs.x),(int)pos_vis_inputs.y,(int)size_vis_inputs.x,(int)size_vis_inputs.y,-1000,0);
vis_brake = new BarH_cmd((int)(pos_vis_inputs.x-size_vis_inputs.x),(int)pos_vis_inputs.y,(int)size_vis_inputs.x,(int)size_vis_inputs.y,0,1000);
vis_brake.setcmain(c_brake);
vis_brake.setTitle("Brake");
@ -247,7 +249,8 @@ void draw() {
vbat_Rear=parseFloat(list[16]);
currentAll=parseFloat(list[17]);
throttle=parseInt(list[18]);
brake=parseInt(list[19]);
brake=parseInt(trim(list[19]));
println("brake:"+brake);
}else{ //data missing or too much
dataErrorCount++;
}
@ -313,7 +316,8 @@ void draw() {
vis_current_RearR.setValue(current_RearR); vis_current_RearR.drawVis();
vis_throttle.setValue(throttle); vis_throttle.drawVis();
vis_brake.setValue(-brake); vis_brake.drawVis();
vis_brake.setValue(brake); vis_brake.drawVis();
int speed_mean=int((speed_FrontL+speed_FrontR+speed_RearL+speed_RearR)/4.0);
vis_c_speed_mean.setValue(speed_mean); vis_c_speed_mean.drawVis();