From 68270366adbe52909aff794f481b6241c038a56a Mon Sep 17 00:00:00 2001 From: Fisch Date: Thu, 27 Dec 2018 02:13:11 +0100 Subject: [PATCH] more speed units --- lichtschranke/speedshow/speedshow.pde | 43 ++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/lichtschranke/speedshow/speedshow.pde b/lichtschranke/speedshow/speedshow.pde index 937ba81..3d3a242 100644 --- a/lichtschranke/speedshow/speedshow.pde +++ b/lichtschranke/speedshow/speedshow.pde @@ -17,13 +17,13 @@ Date d=new Date(); PrintWriter pw; int unitdisplay=0; -int unitdisplay_count=2; //how much different units available +int unitdisplay_count=9; //how much different units available void setup() { size(1500, 1000); frameRate(30); - //String portName = "COM3"; - String portName = "/dev/ttyUSB0"; + String portName = "COM5"; + //String portName = "/dev/ttyUSB0"; myPort = new Serial(this, portName, 115200); pw=createWriter("speeds.txt"); @@ -67,8 +67,43 @@ void draw() { text(nf(speedfloat,1,2) + " km/h" , 100, 200); break; case 1: + text(nf(speedfloat*0.621371,1,2) + " mph" , 100, 200); + break; + case 2: text(nf(speedfloat*0.000809848,1,6) + " Mach" , 100, 200); break; + case 3: + text(nf(speedfloat*0.911344,1,2) + " ft/s" , 100, 200); + break; + case 4: + text(nf(speedfloat*0.277778,1,2) + " m/s" , 100, 200); + break; + case 5: + text(nf(speedfloat*0.539957,1,2) + " knots" , 100, 200); + break; + case 6: + text(nf(speedfloat*1079000000,1,0) + " c" , 100, 200); + break; + case 7: + text(nf(speedfloat*54.67469,1,0) + " ft/min" , 100, 200); + break; + case 8: + text(nf(pow((speedfloat*0.277778/0.836), 2.0/3),1,0) + " Bft" , 100, 200); + break; + + + + + + + + + + + + + + } @@ -78,7 +113,7 @@ void draw() { int ipos=1; for (int i=speeds_show;i>0;i--){ ipos++; - text( nf(speeds[(speeds_show+speeds_index-1+i)%speeds_show], 1,2) , 100, 250+(ipos)*80); + text( nf(speeds[(speeds_show+speeds_index-1+i)%speeds_show], 1,2) + "km/h", 100, 250+(ipos)*80); //print(speeds[i]); //print(",");