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:
- 15:54cee979f202
- Parent:
- 14:568d4dac4fb6
- Child:
- 16:6b4a71e6f75a
diff -r 568d4dac4fb6 -r 54cee979f202 main.cpp
--- a/main.cpp Sun Apr 02 22:49:19 2017 +0000
+++ b/main.cpp Wed Apr 05 00:46:12 2017 +0000
@@ -92,7 +92,7 @@
keyOut.putc(0x00);
//delay for pushing data
- wait(0.1); //how large does this need to be?
+ //wait(0.1); //how large does this need to be?
}
@@ -103,6 +103,7 @@
//move mouse
//handles only single finger actions
+ //TODO: uncomment
mouseCommand(0, (char) updatex[0], (char) updatey[0]);
//clear out changes
@@ -110,13 +111,14 @@
updatey[0] = 0;
//click
- if(toLeftClick){
- //send command to
- mouseCommand(0x01, 0 , 0);
-
- } else if (toRightClick){
- mouseCommand(0x02, 0 , 0);
- }
+ //TODO: uncomment
+// if(toLeftClick){
+// //send command to
+// mouseCommand(0x01, 0 , 0);
+//
+// } else if (toRightClick){
+// mouseCommand(0x02, 0 , 0);
+// }
//fip clicking to false
toLeftClick = false;
@@ -182,7 +184,6 @@
write2bytes(0x00, 0x02);
write2bytes(0x00, 0x00);
write2bytes(0x71, 0x01);
- write2bytes(0x00, sen0);
write2bytes(0x07, 0x00);
write2bytes(sen1, 0x1A);
write2bytes(sen2, sen3);
@@ -261,7 +262,7 @@
toRightClick = true;
//TODO: remove. for debugging purposes only
- //pc.printf("#########RIGHT mouse click \t");
+ pc.printf("#########RIGHT mouse click \t");
} else {
//initiate left click
//mouseCommand(0x01, 0 , 0);
@@ -270,7 +271,7 @@
toLeftClick = true;
//TODO: remove. for debugging purposes only
- //pc.printf("********LEFT mouse click \t");
+ pc.printf("********LEFT mouse click \t");
}
//reset counters
@@ -289,6 +290,8 @@
//NOTE: 1023 means nothing was detected
void readCameraData(void){
+ pc.printf("in read camera data \n");
+
//request data from camera
char out[1];
out[0] = 0x36;
@@ -374,6 +377,11 @@
//entrance to the code
int main() {
+
+ //set values initially to zero
+ updatex[0] = 0;
+ updatey[0] = 0;
+
myled = 0;
//slaveAddress = IRsensorAddress >> 1;
slaveAddress = IRsensorAddress;
@@ -383,27 +391,29 @@
pc.baud(115200);
//attach ticker for interrupt
- //mouseStateTicker.attach_us(&updateMouseState, 5000);
+ mouseStateTicker.attach_us(&updateMouseState, 100);
//loop to search for new info using the camera
while(1) {
-
- //wait
- //wait(0.04);
+
+ pc.printf("while\n");
//toggle test LED
myled = 1 - myled;
+ pc.printf("while2\n");
+
+
//get the camera data
readCameraData();
//printing mouse state -- FOR DEBUGGING
- pc.printf("update mouse %d, %d", updatex[0], updatey[0]);
- pc.printf("\tclick left %s", toLeftClick ? "true" : "false");
- pc.printf("\tclick right %s\n", toRightClick ? "true" : "false");
+// pc.printf("update mouse %d, %d", updatex[0], updatey[0]);
+// pc.printf("\tclick left %s", toLeftClick ? "true" : "false");
+// pc.printf("\tclick right %s\n", toRightClick ? "true" : "false");
//print points
- // printCamData(onex, oney);
+ printCamData(onex, oney);
//uncomment below to test infinite print
//keyOut.putc(0x41);

