Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 3:7b0c215eb6a7
- Parent:
- 2:f501e506d62b
- Child:
- 4:1f443e7a0122
--- a/main.cpp Fri Mar 31 22:24:46 2017 +0000
+++ b/main.cpp Fri Mar 31 22:49:07 2017 +0000
@@ -57,7 +57,7 @@
write2bytes(sen2, sen3);
write2bytes(0x33, 0x03);
write2bytes(0x30, 0x08);
- wait(0.1);
+ //wait(0.1);
}
@@ -72,35 +72,22 @@
//get data from camera
camera1.read(slaveAddress, data_buf, 16);
- //print content of data buffer
- for(int i = 0; i < 16; i++){
- pc.printf(" data buf %d --> %c <-- \t as int --> %d <--\n", i, data_buf[i], (float) data_buf[i]);
-
- }
+// //print content of data buffer
+// for(int i = 0; i < 16; i++){
+// pc.printf(" data buf %d --> %c <-- \t as int --> %d <--\n", i, data_buf[i], (float) data_buf[i]);
+//
+// }
-
-
+
//POINT 1
//get data
point1x = data_buf[1];
point1y = data_buf[2];
s = data_buf[3];
- //load x,y
- point1x += (s & 0x30) << 4;
- point1y += (s & 0xC0) << 2;
-
- pc.printf("point1x %d <-- here\n", point1x);
-
- onex[0] = point1x;
- oney[0] = point1y;
-
- //onex[0] = point1x + ((s & 0x30) << 4);
- //oney[0] = point1y + ((s & 0xC0) << 2);
-
-
-
-
+ //load x,y
+ onex[0] = point1x + ((s & 0x30) << 4);
+ oney[0] = point1y + ((s & 0xC0) << 2);
//POINT 2
//get data
@@ -110,8 +97,7 @@
//load x,y
onex[1] = point2x + ((s & 0x30) << 4);
oney[1] = point2y + ((s & 0xC0) << 2);
-
-
+
//POINT 3
//get data
point3x = data_buf[7];
@@ -121,7 +107,6 @@
onex[2] = point3x + ((s & 0x30) << 4);
oney[2] = point3y + ((s & 0xC0) << 2);
-
//POINT 4
//get data
point4x = data_buf[10];
@@ -139,55 +124,36 @@
int y = ycor[i];
//determine what to print
//x coordinate
- if(x < 1000){
- pc.printf("");
- }
- if(x < 100){
- pc.printf("");
- }
- if(x < 10){
- pc.printf(" %d,", x);
- }
+ pc.printf(" %d,", x);
//y coordinate
- if(y < 1000){
- pc.printf("");
- }
- if(y < 100){
- pc.printf("");
- }
- if(y < 10){
- pc.printf(" %d", y);
- }
-
- pc.printf("\t");
+ pc.printf(" %d\t", y);
}
//new line and delay
pc.printf("\n");
- wait(0.1);
+ //wait(0.01);
}
int main() {
myled = 0;
- slaveAddress = IRsensorAddress >> 1;
+ //slaveAddress = IRsensorAddress >> 1;
+ slaveAddress = IRsensorAddress;
initCamera();
+ //update baud rate
+ pc.baud(115200);
+
while(1) {
+ wait(0.01);
myled = 1 - myled;
//get the camera data
readCameraData();
//print points
- printCamData(onex, oney);
-
-
-
-
-
-
+ printCamData(onex, oney);
}
}

