asdf
Dependencies: L3GD20 LSM303DLHC mbed
Diff: Headers/Sensors.h
- Revision:
- 6:6e96e93689df
- Parent:
- 5:9e504a5a1f48
--- a/Headers/Sensors.h Thu Apr 03 18:47:30 2014 +0000 +++ b/Headers/Sensors.h Thu Apr 03 19:21:58 2014 +0000 @@ -24,6 +24,7 @@ bool wallright = false; bool wallleft = false; float cal_R =0, cal_L =0, cal_F =0; +Timer t; float linearize(float sensor) { @@ -47,7 +48,39 @@ { wallLeft(); wallRight(); - wallFront(); - + wallFront(); } + +void initSensors() +{ + for(int i = 0; i < 100; i++) + { + float l = SenseL.read(); + float r = SenseR.read(); + float f = SenseF.read(); + + /* + leftWeightedAvg.add(l); + rightWeightedAvg.add(r); + frontWeightedAvg.add(f); + + + leftExpAvg.add(l); + frontExpAvg.add(f); + */ + leftExpAvg.add(l); + rightExpAvg.add(r); + frontExpAvg.add(f); + //leftBufferAvg.add(l); + //rightBufferAvg.add(r); + //frontBufferAvg.add(f); + + //WIRELESS.printf("%i || F: %f \n\r", i, frontExpAvg.average()); + } + cal_R = abs(log(1-rightExpAvg.average())); + cal_L = abs(log(1-leftExpAvg.average())); + //cal_F = abs(log(1-frontExpAvg.average())); + //float avgRight = rightExpAvg.average(); +} + #endif \ No newline at end of file