![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Version12.04.18
Fork of Micromouse_beta by
IRSensor.cpp@1:d9e840c48b1e, 2018-03-31 (annotated)
- Committer:
- ruesipat
- Date:
- Sat Mar 31 16:45:57 2018 +0000
- Revision:
- 1:d9e840c48b1e
- Parent:
- 0:a9fe4ef404bf
j
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ruesipat | 0:a9fe4ef404bf | 1 | #include <cmath> |
ruesipat | 0:a9fe4ef404bf | 2 | #include "IRSensor.h" |
ruesipat | 0:a9fe4ef404bf | 3 | |
ruesipat | 0:a9fe4ef404bf | 4 | using namespace std; |
ruesipat | 0:a9fe4ef404bf | 5 | |
ruesipat | 1:d9e840c48b1e | 6 | |
ruesipat | 1:d9e840c48b1e | 7 | IRSensor::IRSensor(AnalogIn& distance) : |
ruesipat | 1:d9e840c48b1e | 8 | distance(distance) |
ruesipat | 1:d9e840c48b1e | 9 | {} |
ruesipat | 0:a9fe4ef404bf | 10 | |
ruesipat | 0:a9fe4ef404bf | 11 | IRSensor::~IRSensor() {} |
ruesipat | 0:a9fe4ef404bf | 12 | |
ruesipat | 0:a9fe4ef404bf | 13 | float IRSensor::read() |
ruesipat | 0:a9fe4ef404bf | 14 | { |
ruesipat | 1:d9e840c48b1e | 15 | double d = distance * 3.3f; // Change the value to be in the 0 to 3300 range |
ruesipat | 1:d9e840c48b1e | 16 | |
ruesipat | 1:d9e840c48b1e | 17 | //DONT TOUCH |
ruesipat | 1:d9e840c48b1e | 18 | //y = 14.098x6 - 147.35x5 + 627.68x4 - 1403.5x3 + 1765.1x2 - 1236.9x + 430.44 POLYNOMFUNKTION AUS EXCEL |
ruesipat | 1:d9e840c48b1e | 19 | float f = 14.098f*((d)*(d)*(d)*(d)*(d)*(d)) - 147.35f*((d)*(d)*(d)*(d)*(d)) + 627.68*((d)*(d)*(d)*(d)) - 1403.5f*((d)*(d)*(d)) + 1765.1f*((d)*(d)) - 1236.9f*(d) + 430.44f; // Lesen der Distanz in [mm] |
ruesipat | 1:d9e840c48b1e | 20 | |
ruesipat | 1:d9e840c48b1e | 21 | return f; |
ruesipat | 0:a9fe4ef404bf | 22 | } |