test
Dependencies: S11059 VL6180X m3pi mbed
Fork of tc_agent by
main.cpp@1:6340d62d759f, 2016-07-19 (annotated)
- Committer:
- tennisbaca
- Date:
- Tue Jul 19 00:53:45 2016 +0000
- Revision:
- 1:6340d62d759f
- Parent:
- 0:2508f38e90fe
- Child:
- 2:3ebca956fd36
yoshi
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sburg | 0:2508f38e90fe | 1 | #include "VL6180.h" |
sburg | 0:2508f38e90fe | 2 | #include "mbed.h" |
tennisbaca | 1:6340d62d759f | 3 | #include "m3pi.h" |
tennisbaca | 1:6340d62d759f | 4 | #include "S11059-SoftI2C.h" |
sburg | 0:2508f38e90fe | 5 | |
tennisbaca | 1:6340d62d759f | 6 | VL6180 rf(p28, p27); //I2C sda and scl |
sburg | 0:2508f38e90fe | 7 | Serial pc(USBTX, USBRX); //USB serial |
tennisbaca | 1:6340d62d759f | 8 | S11059 col(p19,p20); |
tennisbaca | 1:6340d62d759f | 9 | m3pi m3pi; |
tennisbaca | 1:6340d62d759f | 10 | Timer t; |
sburg | 0:2508f38e90fe | 11 | |
sburg | 0:2508f38e90fe | 12 | int main() { |
tennisbaca | 1:6340d62d759f | 13 | m3pi.cls(); |
tennisbaca | 1:6340d62d759f | 14 | m3pi.locate(0,0); |
tennisbaca | 1:6340d62d759f | 15 | m3pi.printf("Sensor"); |
tennisbaca | 1:6340d62d759f | 16 | m3pi.locate(0,1); |
tennisbaca | 1:6340d62d759f | 17 | m3pi.printf("Check"); |
tennisbaca | 1:6340d62d759f | 18 | wait(1); |
sburg | 0:2508f38e90fe | 19 | float reading; |
tennisbaca | 1:6340d62d759f | 20 | float time[2]; |
tennisbaca | 1:6340d62d759f | 21 | int bl=0; |
tennisbaca | 1:6340d62d759f | 22 | char buf[255]; |
tennisbaca | 1:6340d62d759f | 23 | |
tennisbaca | 1:6340d62d759f | 24 | m3pi.cls(); |
sburg | 0:2508f38e90fe | 25 | while(1) { |
tennisbaca | 1:6340d62d759f | 26 | m3pi.cls(); |
tennisbaca | 1:6340d62d759f | 27 | t.start(); |
tennisbaca | 1:6340d62d759f | 28 | time[0] = t.read(); |
sburg | 0:2508f38e90fe | 29 | reading = rf; |
tennisbaca | 1:6340d62d759f | 30 | t.stop(); |
tennisbaca | 1:6340d62d759f | 31 | time[1] = t.read(); |
tennisbaca | 1:6340d62d759f | 32 | |
tennisbaca | 1:6340d62d759f | 33 | |
tennisbaca | 1:6340d62d759f | 34 | int len = 0; |
tennisbaca | 1:6340d62d759f | 35 | //m3pi.locate(0,0); |
tennisbaca | 1:6340d62d759f | 36 | //len = sprintf(buf,"%f",reading); |
tennisbaca | 1:6340d62d759f | 37 | m3pi.locate(0,1); |
tennisbaca | 1:6340d62d759f | 38 | m3pi.printf("%f",time[1]-time[0]); |
tennisbaca | 1:6340d62d759f | 39 | pc.printf("Read %4.1f cm\n\r", reading); |
tennisbaca | 1:6340d62d759f | 40 | m3pi.print(buf,len); |
sburg | 0:2508f38e90fe | 41 | } |
sburg | 0:2508f38e90fe | 42 | } |