work in progress day 0

This commit is contained in:
interfisch 2018-12-27 00:56:32 +01:00
commit c35ea00a6a
17 changed files with 37578 additions and 0 deletions

BIN
20181205_tafel.jpg Normal file

Binary file not shown.

After

(image error) Size: 66 KiB

Binary file not shown.

After

(image error) Size: 38 KiB

BIN
20181213_tafel.jpg Normal file

Binary file not shown.

After

(image error) Size: 85 KiB

Binary file not shown.

After

(image error) Size: 63 KiB

Binary file not shown.

Binary file not shown.

After

(image error) Size: 41 KiB

Binary file not shown.

View file

@ -0,0 +1,125 @@
#define PIN_LED 13
#define PIN_SW1 2
#define PIN_SW2 3
#define PIN_FLASH 5
volatile boolean sw1_flag = false;
volatile boolean sw2_flag = false;
volatile boolean sw1_released = true;
volatile boolean sw2_released = true;
unsigned long sw1_lastTime=0;
unsigned long sw2_lastTime=0;
unsigned long sw1_lastTimeMicros=0;
unsigned long sw2_lastTimeMicros=0;
#define SWDEBOUNCE 500
float sensordistance = 0.37; //in meters
#define TIMESCOUNT 20
uint8_t times_index=0;
float times[TIMESCOUNT];
void setup() {
pinMode(PIN_LED, OUTPUT);
pinMode(PIN_SW1, INPUT_PULLUP);
pinMode(PIN_SW2, INPUT_PULLUP);
pinMode(PIN_FLASH, OUTPUT);
digitalWrite(PIN_FLASH, HIGH);
for (uint8_t i=0;i<TIMESCOUNT;i++){
times[i]=15;
}
Serial.begin(115200);
}
void loop() {
//digitalWrite(PIN_LED, sw1_flag);
if (sw1_released && !digitalRead(PIN_SW1)){ //pressed
sw1_released=false;
if (sw1_lastTime+SWDEBOUNCE<millis()){
sw1_flag=true;
sw1_lastTime=millis();
sw1_lastTimeMicros=micros();
}
}else if (!sw1_released && digitalRead(PIN_SW1)){ //released
sw1_released=true;
}
if (sw2_released && !digitalRead(PIN_SW2)){ //pressed
sw2_released=false;
if (sw2_lastTime+SWDEBOUNCE<millis()){
sw2_flag=true;
sw2_lastTime=millis();
sw2_lastTimeMicros=micros();
}
}else if (!sw2_released && digitalRead(PIN_SW2)){ //released
sw2_released=true;
}
if (sw1_flag){
sw1_flag=false;
//Serial.println("SW1");
}
if (sw2_flag){
sw2_flag=false;
//Serial.println("SW2");
unsigned long timediff=sw2_lastTimeMicros-sw1_lastTimeMicros;
//Serial.println(timediff);
float meterpersecond=1.0/timediff*sensordistance*1000000; // meter per s
//Serial.print(meterpersecond);
//Serial.println(" m/s");
float kmh=meterpersecond*3.6;
if (kmh>=1){
if (kmh>getTimesMax()){
digitalWrite(PIN_FLASH, LOW); //Trigger flash
delay(100);
digitalWrite(PIN_FLASH, HIGH);
}
Serial.println(kmh);
//Serial.println(" kmh");
//add time to last times queue
times_index++;
times_index%=TIMESCOUNT-1;
times[times_index]=kmh;
}
}
}
float getTimesMax(){
float timesmax=0;
for (uint8_t i=0;i<TIMESCOUNT;i++){
if (timesmax<times[i]){
timesmax=times[i];
}
}
return timesmax;
}

View file

@ -0,0 +1,4 @@
1545871689576;13.18
1545871689576;13.05
1545871689576;12.91
1545871689576;12.47

View file

@ -0,0 +1,89 @@
import processing.serial.*;
import java.io.FileWriter;
import java.io.*;
import java.util.*;
Serial myPort;
String val = "0.0";
int speeds_show=5;
float[] speeds=new float[speeds_show];
int speeds_index=0; //points to next array index
float speedfloat=0;
Date d=new Date();
PrintWriter pw;
int unitdisplay=0;
int unitdisplay_count=2; //how much different units available
void setup() {
size(1500, 1000);
frameRate(30);
//String portName = "COM3";
String portName = "/dev/ttyUSB0";
myPort = new Serial(this, portName, 115200);
pw=createWriter("speeds.txt");
background(0);
}
// speed wird sein "20.08" oder
void draw() {
if ( myPort.available() > 0) {
val = myPort.readString();
print("val = " + val);
val = val.substring(0,val.length()-1);
speedfloat=float(val);
speeds[speeds_index]=speedfloat;
speeds_index++;
speeds_index%=speeds_show;
println(d.getTime()+";"+speedfloat);
pw.println(d.getTime()+";"+speedfloat);
pw.flush();
unitdisplay=int(random(0,unitdisplay_count));
unitdisplay=1;
println("unitdisplay: "+unitdisplay);
}
background(0);
fill(255);
textSize(150);
switch(unitdisplay){
case 0:
text(nf(speedfloat,1,2) + " km/h" , 100, 200);
break;
case 1:
text(nf(speedfloat*0.000809848,1,6) + " Mach" , 100, 200);
break;
}
textSize(80);
//println();
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);
//print(speeds[i]);
//print(",");
}
}

15862
teststecke_35c3_20180617a.dxf Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

15674
teststecke_35c3_20181213.dxf Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

Binary file not shown.

After

(image error) Size: 417 KiB

Binary file not shown.

After

(image error) Size: 360 KiB

Binary file not shown.

After

(image error) Size: 474 KiB