Added one task
Dependencies: mbed
mylib/devices/src/GP2Y0E03.cpp@0:fb4269aa5fb4, 2017-05-26 (annotated)
- Committer:
- PicYusuke
- Date:
- Fri May 26 03:51:19 2017 +0000
- Revision:
- 0:fb4269aa5fb4
hoge
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
PicYusuke | 0:fb4269aa5fb4 | 1 | #include "GP2Y0E03.h" |
PicYusuke | 0:fb4269aa5fb4 | 2 | |
PicYusuke | 0:fb4269aa5fb4 | 3 | const float d_max = 0.50f; |
PicYusuke | 0:fb4269aa5fb4 | 4 | const float d_min = 0.04f; |
PicYusuke | 0:fb4269aa5fb4 | 5 | const float v_max = 2.20f; |
PicYusuke | 0:fb4269aa5fb4 | 6 | const float v_min = 0.55f; |
PicYusuke | 0:fb4269aa5fb4 | 7 | |
PicYusuke | 0:fb4269aa5fb4 | 8 | float Get_Distance(float vin) |
PicYusuke | 0:fb4269aa5fb4 | 9 | { |
PicYusuke | 0:fb4269aa5fb4 | 10 | //return val: distance [m] |
PicYusuke | 0:fb4269aa5fb4 | 11 | |
PicYusuke | 0:fb4269aa5fb4 | 12 | float dist; |
PicYusuke | 0:fb4269aa5fb4 | 13 | |
PicYusuke | 0:fb4269aa5fb4 | 14 | dist = 0.6576f - vin * (d_max-d_min) / (v_max-v_min); |
PicYusuke | 0:fb4269aa5fb4 | 15 | if (dist> d_max) //測定限界 |
PicYusuke | 0:fb4269aa5fb4 | 16 | { |
PicYusuke | 0:fb4269aa5fb4 | 17 | return 0.0f; |
PicYusuke | 0:fb4269aa5fb4 | 18 | } |
PicYusuke | 0:fb4269aa5fb4 | 19 | |
PicYusuke | 0:fb4269aa5fb4 | 20 | return dist; |
PicYusuke | 0:fb4269aa5fb4 | 21 | } |